From 9bfeb9627ab2fac05f00bcea965f1d7afbe08392 Mon Sep 17 00:00:00 2001 From: SWH-Relewise Date: Wed, 17 Jan 2024 12:55:36 +0100 Subject: [PATCH 1/3] Fix: generated json for mulitlingual collections --- packages/client/src/models/dataValue.ts | 11 ++++++++--- .../products/updates.integration.test.ts | 7 +++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/client/src/models/dataValue.ts b/packages/client/src/models/dataValue.ts index 41005b9..54aebdc 100644 --- a/packages/client/src/models/dataValue.ts +++ b/packages/client/src/models/dataValue.ts @@ -19,6 +19,11 @@ export interface CollectionWithType { $values: T[]; } +export interface CollectionWithTypeNo$values { + $type: string; + values: T[]; +} + export interface MultiCurrencyWithType extends MultiCurrency { $type: string; } @@ -51,12 +56,12 @@ export class StringCollectionDataValue extends DataValueBase> { +export class MultilingualCollectionDataValue extends DataValueBase> { constructor(values: { values: string[], language: string }[]) { super('MultilingualCollection', { - $type: 'System.Collections.Generic.List`1[[Relewise.Client.DataTypes.Multilingual, Relewise.Client]], System.Private.CoreLib', - $values: values.map(x => ({ values: x.values, language: { value: x.language } })), + $type: 'Relewise.Client.DataTypes.MultilingualCollection, Relewise.Client', + values: values.map(x => ({ values: x.values, language: { value: x.language } })), }); } diff --git a/packages/integrations/tests/integration-tests/products/updates.integration.test.ts b/packages/integrations/tests/integration-tests/products/updates.integration.test.ts index c2e0644..fd19f51 100644 --- a/packages/integrations/tests/integration-tests/products/updates.integration.test.ts +++ b/packages/integrations/tests/integration-tests/products/updates.integration.test.ts @@ -21,6 +21,7 @@ test('Create Product', async() => { 'Tags': DataValueFactory.stringCollection(['fall collection', 'blue', 'good-deal']), 'InStock': DataValueFactory.boolean(true), 'Removed': null, + 'Materials': DataValueFactory.multilingualCollection([{ values: ['Wood', 'Metal'], language: 'da' }]), 'Complex': DataValueFactory.object({ 'nestedDataKey': DataValueFactory.string('Key'), }), @@ -49,6 +50,12 @@ test('Create Product', async() => { displayName: [{ language: 'da', value: 'Tilbud' }], }))); + console.log('*******************************************'); + console.log(product.build().product?.data); + console.log('*******************************************'); + console.log( await integrator.updateProduct(product.build()).catch((e) => console.log(e))); + console.log('*******************************************'); + await integrator.updateProduct(product.build()); const enable = new ProductAdministrativeActionBuilder({ From 080869b988cc84429bdf32229d251aeeca637c36 Mon Sep 17 00:00:00 2001 From: SWH-Relewise Date: Wed, 17 Jan 2024 12:56:32 +0100 Subject: [PATCH 2/3] Remove debugging console logs --- .../integration-tests/products/updates.integration.test.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/integrations/tests/integration-tests/products/updates.integration.test.ts b/packages/integrations/tests/integration-tests/products/updates.integration.test.ts index fd19f51..b03e8ee 100644 --- a/packages/integrations/tests/integration-tests/products/updates.integration.test.ts +++ b/packages/integrations/tests/integration-tests/products/updates.integration.test.ts @@ -50,12 +50,6 @@ test('Create Product', async() => { displayName: [{ language: 'da', value: 'Tilbud' }], }))); - console.log('*******************************************'); - console.log(product.build().product?.data); - console.log('*******************************************'); - console.log( await integrator.updateProduct(product.build()).catch((e) => console.log(e))); - console.log('*******************************************'); - await integrator.updateProduct(product.build()); const enable = new ProductAdministrativeActionBuilder({ From 8e02cc8f82b64634446c37b2b4651c130b75cc38 Mon Sep 17 00:00:00 2001 From: SWH-Relewise Date: Wed, 17 Jan 2024 13:56:56 +0100 Subject: [PATCH 3/3] Rename to MultilingualCollectionWithType --- packages/client/src/models/dataValue.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/client/src/models/dataValue.ts b/packages/client/src/models/dataValue.ts index 54aebdc..0aaa138 100644 --- a/packages/client/src/models/dataValue.ts +++ b/packages/client/src/models/dataValue.ts @@ -19,7 +19,7 @@ export interface CollectionWithType { $values: T[]; } -export interface CollectionWithTypeNo$values { +export interface MultilingualCollectionWithType { $type: string; values: T[]; } @@ -56,7 +56,7 @@ export class StringCollectionDataValue extends DataValueBase> { +export class MultilingualCollectionDataValue extends DataValueBase> { constructor(values: { values: string[], language: string }[]) { super('MultilingualCollection', {