@sisense/sdk-modeling 1.10.0 → 1.11.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.
@@ -2,6 +2,7 @@
2
2
  import { Writer } from './interfaces.js';
3
3
  export declare const NEWLINE = "\n";
4
4
  export declare function writeIndented(stream: NodeJS.WritableStream, s: string, idnt: number): void;
5
+ export declare function escapeSpecialChars(expression: string): string;
5
6
  export declare function template(strings: TemplateStringsArray, ...keys: string[]): any;
6
7
  export declare function rnt(idnt: number): string;
7
8
  export declare function indent(ident: number): string;
@@ -7,6 +7,9 @@ export function writeIndented(stream, s, idnt) {
7
7
  }
8
8
  stream.write(s);
9
9
  }
10
+ export function escapeSpecialChars(expression) {
11
+ return expression.replace(/'/g, "\\'");
12
+ }
10
13
  // export function ident(stream:WriteStream, ident:number) {
11
14
  // if (ident > 0) {
12
15
  // stream.write("\t".repeat(ident));
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-use-before-define */
2
2
  import { MetadataTypes, DateLevels, normalizeName, } from '@sisense/sdk-data';
3
- import { ElementWriter, NEWLINE, rnt, writeIndented } from './base.js';
3
+ import { ElementWriter, NEWLINE, escapeSpecialChars, rnt, writeIndented } from './base.js';
4
4
  import { prepareDescription } from '../utils/prepare-description.js';
5
5
  export class DimensionWriter extends ElementWriter {
6
6
  constructor(dimension, isNested) {
@@ -95,7 +95,7 @@ export class DateDimensionWriter extends ElementWriter {
95
95
  writeDef(stream, ident) {
96
96
  writeIndented(stream, `createDateDimension({${NEWLINE}`, 0);
97
97
  writeIndented(stream, `name: '${this.element.name}',${NEWLINE}`, ident + 1);
98
- writeIndented(stream, `expression: '${this.element.expression}',`, ident + 1);
98
+ writeIndented(stream, `expression: '${escapeSpecialChars(this.element.expression)}',`, ident + 1);
99
99
  if (this.element.description) {
100
100
  writeIndented(stream, `description: ${prepareDescription(this.element.description)},`, ident + 1);
101
101
  }
@@ -123,7 +123,7 @@ export class AttributeWriter extends ElementWriter {
123
123
  writeIndented(stream, `createAttribute({\
124
124
  ${rnt(ident + 2)}name: '${this.element.name}',\
125
125
  ${rnt(ident + 2)}type: '${this.element.type}',\
126
- ${rnt(ident + 2)}expression: '${this.element.expression}',\
126
+ ${rnt(ident + 2)}expression: '${escapeSpecialChars(this.element.expression)}',\
127
127
  ${this.element.description ? `${rnt(ident + 2)}description: ${prepareDescription(this.element.description)},` : ''}\
128
128
  ${rnt(ident + 1)}}),`, ident);
129
129
  }
@@ -133,6 +133,6 @@ export class LevelWriter extends ElementWriter {
133
133
  super(level, normalizeName(level.name));
134
134
  }
135
135
  write(stream, ident) {
136
- writeIndented(stream, `createAttribute({name: '${this.name}', expression: '${this.element.expression}', granularity: '${this.element.granularity}'}),`, ident);
136
+ writeIndented(stream, `createAttribute({name: '${this.name}', expression: '${escapeSpecialChars(this.element.expression)}', granularity: '${this.element.granularity}'}),`, ident);
137
137
  }
138
138
  }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "Sisense",
12
12
  "Compose SDK"
13
13
  ],
14
- "version": "1.10.0",
14
+ "version": "1.11.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.10.0",
23
+ "@sisense/sdk-data": "^1.11.0",
24
24
  "prettier": "^3.2.5",
25
25
  "typescript": "4.8.4"
26
26
  },