@sisense/sdk-modeling 1.8.0 → 1.10.0

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.
@@ -0,0 +1 @@
1
+ export declare function prepareDescription(description: string): string;
@@ -0,0 +1,3 @@
1
+ export function prepareDescription(description) {
2
+ return '`' + description.replace(/\\/g, '\\\\').replace(/`/g, '\\`') + '`';
3
+ }
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-use-before-define */
2
- /* eslint-disable max-lines */
3
2
  import { MetadataTypes, DateLevels, normalizeName, } from '@sisense/sdk-data';
4
3
  import { ElementWriter, NEWLINE, rnt, writeIndented } from './base.js';
4
+ import { prepareDescription } from '../utils/prepare-description.js';
5
5
  export class DimensionWriter extends ElementWriter {
6
6
  constructor(dimension, isNested) {
7
7
  super(dimension, normalizeName(dimension.name));
@@ -96,6 +96,9 @@ export class DateDimensionWriter extends ElementWriter {
96
96
  writeIndented(stream, `createDateDimension({${NEWLINE}`, 0);
97
97
  writeIndented(stream, `name: '${this.element.name}',${NEWLINE}`, ident + 1);
98
98
  writeIndented(stream, `expression: '${this.element.expression}',`, ident + 1);
99
+ if (this.element.description) {
100
+ writeIndented(stream, `description: ${prepareDescription(this.element.description)},`, ident + 1);
101
+ }
99
102
  stream.write(NEWLINE);
100
103
  writeIndented(stream, `}),`, ident);
101
104
  if (!this.isNested) {
@@ -121,6 +124,7 @@ export class AttributeWriter extends ElementWriter {
121
124
  ${rnt(ident + 2)}name: '${this.element.name}',\
122
125
  ${rnt(ident + 2)}type: '${this.element.type}',\
123
126
  ${rnt(ident + 2)}expression: '${this.element.expression}',\
127
+ ${this.element.description ? `${rnt(ident + 2)}description: ${prepareDescription(this.element.description)},` : ''}\
124
128
  ${rnt(ident + 1)}}),`, ident);
125
129
  }
126
130
  }
@@ -4,6 +4,7 @@
4
4
  /* eslint-disable sonarjs/no-nested-template-literals */
5
5
  import { normalizeName } from '@sisense/sdk-data';
6
6
  import { NEWLINE, rnt, writeIndented, ElementWriter } from './base.js';
7
+ import { prepareDescription } from '../utils/prepare-description.js';
7
8
  export class MeasureWriter extends ElementWriter {
8
9
  constructor(measure, isNested) {
9
10
  super(measure, normalizeName(measure.name));
@@ -30,7 +31,7 @@ export class BaseMeasureWriter extends MeasureWriter {
30
31
  ${rnt(idnt + 1)}agg: "${this.element.aggregation}"${this.element.getFormat()
31
32
  ? `,${rnt(idnt + 1)}format:"${this.element.getFormat()}"`
32
33
  : ''}${this.element.description
33
- ? `,${rnt(idnt + 1)}description:"${this.element.description}"`
34
+ ? `,${rnt(idnt + 1)}description: ${prepareDescription(this.element.description)}`
34
35
  : ''}})`, idnt);
35
36
  }
36
37
  }
@@ -55,7 +56,7 @@ export class MeasureTemplateWriter extends MeasureWriter {
55
56
  ${rnt(ident + 1)}agg: "*"${this.element.getFormat()
56
57
  ? `,${rnt(ident + 1)}format:"${this.element.getFormat()}"`
57
58
  : ''}${this.element.description
58
- ? `,${rnt(ident + 1)}description:"${this.element.description}"`
59
+ ? `,${rnt(ident + 1)}description: ${prepareDescription(this.element.description)}`
59
60
  : ''}})`, ident);
60
61
  }
61
62
  }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "Sisense",
12
12
  "Compose SDK"
13
13
  ],
14
- "version": "1.8.0",
14
+ "version": "1.10.0",
15
15
  "author": "Sisense",
16
16
  "license": "SEE LICENSE IN LICENSE.md",
17
17
  "type": "module",
@@ -20,7 +20,7 @@
20
20
  "module": "./dist/index.js",
21
21
  "types": "./dist/index.d.ts",
22
22
  "dependencies": {
23
- "@sisense/sdk-data": "^1.8.0",
23
+ "@sisense/sdk-data": "^1.10.0",
24
24
  "prettier": "^3.2.5",
25
25
  "typescript": "4.8.4"
26
26
  },