merchi_sdk_ts 1.7.1 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,6 +26,18 @@ import { Entity } from '../entity.js';
26
26
  import { MerchiFile } from './file.js';
27
27
  import { Job } from './job.js';
28
28
  import { Product } from './product.js';
29
+ /**
30
+ * Runtime type tag only. The API returns `customisationMap` as arbitrary JSON;
31
+ * the entity layer refuses `Object` from decorator metadata, so we cannot use
32
+ * `any` / plain object without an explicit `type` option here. A const class
33
+ * expression is used so `noUnusedLocals` counts the symbol as used (a named
34
+ * class referenced only from decorators can trigger TS6196).
35
+ */
36
+ var customisationMapPropertyType = /** @class */ (function () {
37
+ function customisationMapPropertyType() {
38
+ }
39
+ return customisationMapPropertyType;
40
+ }());
29
41
  var DraftTemplate = /** @class */ (function (_super) {
30
42
  __extends(DraftTemplate, _super);
31
43
  function DraftTemplate() {
@@ -91,7 +103,7 @@ var DraftTemplate = /** @class */ (function (_super) {
91
103
  __metadata("design:type", Array)
92
104
  ], DraftTemplate.prototype, "draftPreviewLayers", void 0);
93
105
  __decorate([
94
- DraftTemplate.property(),
106
+ DraftTemplate.property({ type: customisationMapPropertyType }),
95
107
  __metadata("design:type", Object)
96
108
  ], DraftTemplate.prototype, "customisationMap", void 0);
97
109
  __decorate([
@@ -4,3 +4,9 @@ test('can make DraftTemplate', function () {
4
4
  var draftTemplate = new merchi.DraftTemplate();
5
5
  expect(draftTemplate).toBeTruthy();
6
6
  });
7
+ test('customisationMap accepts JSON object from server', function () {
8
+ var merchi = new Merchi();
9
+ var draftTemplate = new merchi.DraftTemplate();
10
+ draftTemplate.fromJson({ customisationMap: { regions: [] } });
11
+ expect(draftTemplate.customisationMap).toEqual({ regions: [] });
12
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "merchi_sdk_ts",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "repository": "git@github.com:merchisdk/merchi_sdk_ts.git",
@@ -5,3 +5,10 @@ test('can make DraftTemplate', () => {
5
5
  const draftTemplate = new merchi.DraftTemplate();
6
6
  expect(draftTemplate).toBeTruthy();
7
7
  });
8
+
9
+ test('customisationMap accepts JSON object from server', () => {
10
+ const merchi = new Merchi();
11
+ const draftTemplate = new merchi.DraftTemplate();
12
+ draftTemplate.fromJson({ customisationMap: { regions: [] } });
13
+ expect(draftTemplate.customisationMap).toEqual({ regions: [] });
14
+ });
@@ -6,6 +6,15 @@ import { Product } from './product.js';
6
6
  import { VariationField } from './variation_field.js';
7
7
  import { VariationFieldsOption } from './variation_fields_option.js';
8
8
 
9
+ /**
10
+ * Runtime type tag only. The API returns `customisationMap` as arbitrary JSON;
11
+ * the entity layer refuses `Object` from decorator metadata, so we cannot use
12
+ * `any` / plain object without an explicit `type` option here. A const class
13
+ * expression is used so `noUnusedLocals` counts the symbol as used (a named
14
+ * class referenced only from decorators can trigger TS6196).
15
+ */
16
+ const customisationMapPropertyType = class {};
17
+
9
18
  export class DraftTemplate extends Entity {
10
19
  protected static resourceName = 'draft_templates';
11
20
  protected static singularName = 'draftTemplate';
@@ -61,8 +70,8 @@ export class DraftTemplate extends Entity {
61
70
  // analyser leaves it alone). ``customisationMapFileId`` records the
62
71
  // ``file.id`` the cached map was generated from so the analyser
63
72
  // knows when to re-run after the template image is replaced.
64
- @DraftTemplate.property()
65
- public customisationMap?: any | null;
73
+ @DraftTemplate.property({type: customisationMapPropertyType})
74
+ public customisationMap?: Record<string, unknown> | null;
66
75
 
67
76
  @DraftTemplate.property()
68
77
  public customisationMapSource?: string | null;