@pega/dx-component-builder-sdk 8.23.14 → 8.23.15

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/dx-component-builder-sdk",
3
- "version": "8.23.14",
3
+ "version": "8.23.15",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
package/src/cli.js CHANGED
@@ -59,7 +59,7 @@ const parseArgumentsIntoOptions = rawArgs => {
59
59
  task: args._[0],
60
60
  git: true, // args['--git'] || false
61
61
  runInstall: true, // args['--install'] || false
62
- skipBundle: false,
62
+ skipBundle: args['--skipBundle'] || false,
63
63
  params: rawArgs
64
64
  };
65
65
  };
@@ -53,7 +53,7 @@ export const getBuildComponentQuestions = async (category) => {
53
53
  const defaultPegaConfig = await getPegaServerConfig();
54
54
 
55
55
  if (components.length == 0) {
56
- console.log(chalk.bold.yellow(`No components to build`));
56
+ console.log(chalk.redBright("No components to build"));
57
57
  process.exit(1);
58
58
  }
59
59
 
@@ -47,7 +47,7 @@ export const getBuildComponentQuestions = async (category) => {
47
47
  const defaultPegaConfig = await getPegaServerConfig();
48
48
 
49
49
  if (components.length == 0) {
50
- console.log(chalk.bold.yellow(`No components to build`));
50
+ console.log(chalk.redBright("No components to build"));
51
51
  process.exit(1);
52
52
  }
53
53
 
@@ -26,7 +26,8 @@ export const Base{{COMPONENT_CLASS_NAME}} = () => {
26
26
  return {
27
27
  updateFieldValue: (propName, theValue) => {
28
28
  setValue(theValue);
29
- }
29
+ },
30
+ triggerFieldChange: () => {/* nothing */}
30
31
  };
31
32
  },
32
33
  getStateProps: () => {
@@ -41,7 +41,7 @@ export default function {{COMPONENT_CLASS_NAME}}(props: any) {
41
41
  const propName = pConn.getStateProps().value;
42
42
  const helperTextToDisplay = validatemessage || helperText;
43
43
 
44
- const [decValue, setDecimalvalue] = useState();
44
+ const [decValue, setDecimalvalue] = useState("");
45
45
  const [theCurrDec, setCurrDec] = useState(".");
46
46
  const [theCurrSep, setCurrSep] = useState(",");
47
47
 
@@ -49,7 +49,7 @@ export default function {{COMPONENT_CLASS_NAME}}(props: any) {
49
49
  'data-test-id': testId
50
50
  };
51
51
 
52
- const [currValue, setCurrValue] = useState();
52
+ const [currValue, setCurrValue] = useState("");
53
53
  const [theCurrSym, setCurrSym] = useState("$");
54
54
  const [theCurrDec, setCurrDec] = useState(".");
55
55
  const [theCurrSep, setCurrSep] = useState(",");
@@ -49,6 +49,7 @@ export const Base{{COMPONENT_CLASS_NAME}} = () => {
49
49
  if(config.type === 'AppAnnouncement') {
50
50
  return (
51
51
  <AppAnnouncement
52
+ key='announcement'
52
53
  header='Announcements'
53
54
  description={configProps.description}
54
55
  image={configProps.image.replace(/ /g, '+')}
@@ -62,16 +62,16 @@ export default function {{COMPONENT_CLASS_NAME}}(props) {
62
62
  }
63
63
 
64
64
  {{COMPONENT_CLASS_NAME}}.defaultProps = {
65
- header: PropTypes.string,
66
- description: PropTypes.string,
67
- datasource: PropTypes.instanceOf(Object),
68
- whatsnewlink: PropTypes.string
69
- };
70
-
71
- {{COMPONENT_CLASS_NAME}}.propTypes = {
72
65
  header: "",
73
66
  description: "",
74
67
  // image: "",
75
68
  datasource: [],
76
69
  whatsnewlink: ""
77
70
  };
71
+
72
+ {{COMPONENT_CLASS_NAME}}.propTypes = {
73
+ header: PropTypes.string,
74
+ description: PropTypes.string,
75
+ datasource: PropTypes.instanceOf(Object),
76
+ whatsnewlink: PropTypes.string
77
+ };
@@ -55,6 +55,12 @@ export const getBuildCategory = async (options) => {
55
55
 
56
56
  export const getPublishComponentQuestions = async (category) => {
57
57
  const components = await getComponentsObj(true, category);
58
+
59
+ if (components.length == 0) {
60
+ console.log(chalk.redBright("No components to publish"));
61
+ process.exit(1);
62
+ }
63
+
58
64
  const defaultPegaConfig = await getPegaServerConfig();
59
65
 
60
66
  return [
@@ -241,7 +247,16 @@ export const publishComponentToServer = async data => {
241
247
  /* TODO - Handle refresh_token */
242
248
  } else if (status == 200) {
243
249
  console.log(chalk.bold.green(`Success : ${respData.message}`));
244
- } else {
250
+ }
251
+ else if (status === 403) {
252
+ // eslint-disable-next-line prefer-promise-reject-errors
253
+ Promise.reject(
254
+ `${chalk.bold.red(
255
+ 'Error forbidden: User does not have privileges to Publish.'
256
+ )}`
257
+ );
258
+ }
259
+ else {
245
260
  throw new Error(`${respData.message}`);
246
261
  }
247
262
  })
@@ -56,6 +56,12 @@ export const getBuildCategory = async (options) => {
56
56
 
57
57
  export const getPublishComponentQuestions = async () => {
58
58
  const components = await getComponentsObj();
59
+
60
+ if (components.length == 0) {
61
+ console.log(chalk.redBright("No components to publish"));
62
+ process.exit(1);
63
+ }
64
+
59
65
  const defaultPegaConfig = await getPegaServerConfig();
60
66
 
61
67
  return [
@@ -238,7 +244,16 @@ export const publishComponentToServer = async data => {
238
244
  /* TODO - Handle refresh_token */
239
245
  } else if (status == 200) {
240
246
  console.log(chalk.bold.green(`Success : ${respData.message}`));
241
- } else {
247
+ }
248
+ else if (status === 403) {
249
+ // eslint-disable-next-line prefer-promise-reject-errors
250
+ Promise.reject(
251
+ `${chalk.bold.red(
252
+ 'Error forbidden: User does not have privileges to Publish.'
253
+ )}`
254
+ );
255
+ }
256
+ else {
242
257
  throw new Error(`${respData.message}`);
243
258
  }
244
259
  })
@@ -9,7 +9,7 @@ import {
9
9
  COMPONENT_SCHEMA,
10
10
  CATEGORY_CUSTOM,
11
11
  CATEGORY_OVERRIDE } from '../../constants.js';
12
-
12
+
13
13
  import {
14
14
  getComponentDirectoryPath,
15
15
  getComponents,
@@ -34,7 +34,7 @@ const allowedOverrideSubtypes = [
34
34
  ...COMPONENT_SCHEMA.subtype.field.map(({ value }) => value),
35
35
  ...COMPONENT_SCHEMA.subtype.template.map(({ value }) => value),
36
36
  ...COMPONENT_SCHEMA.subtype.widget.map(({ value }) => value)
37
- ]), "ACTION", "DATA_CAPTURE", "SUMMARY", "CASEVIEW", "DATAVIEW", "LIST"
37
+ ]), "ACTION", "DATA_CAPTURE", "SUMMARY", "CASEVIEW", "DATAVIEW", "LIST", "TAB"
38
38
  ];
39
39
 
40
40
  const schema = {
@@ -312,7 +312,7 @@ const overrideSchema = {
312
312
  };
313
313
 
314
314
  const validateSchema = ajv.compile(schema);
315
- const validateOverideSchema = ajv.compile(overrideSchema);
315
+ const validateOverrideSchema = ajv.compile(overrideSchema);
316
316
 
317
317
 
318
318
 
@@ -352,7 +352,7 @@ export default async (option, category = CATEGORY_CUSTOM) => {
352
352
  }
353
353
  else if (category === CATEGORY_OVERRIDE) {
354
354
  // for now, if now file just end
355
- console.log(`${chalk.bold.yellow('Config file not availabe for: ' + componentToValidate)}`);
355
+ console.log(`${chalk.bold.yellow('Config file not available for: ' + componentToValidate)}`);
356
356
  return;
357
357
  }
358
358
  }
@@ -360,7 +360,7 @@ export default async (option, category = CATEGORY_CUSTOM) => {
360
360
  //const data = JSON.parse(fs.readFileSync(path.resolve(configFile), 'utf8'));
361
361
  const data = JSON.parse(configData);
362
362
 
363
- const valid = (category === CATEGORY_OVERRIDE) ? validateOverideSchema(data) : validateSchema(data);
363
+ const valid = (category === CATEGORY_OVERRIDE) ? validateOverrideSchema(data) : validateSchema(data);
364
364
 
365
365
  if (valid) {
366
366
 
@@ -383,6 +383,12 @@ export default async (option, category = CATEGORY_CUSTOM) => {
383
383
 
384
384
  console.log(`${chalk.bold.green(componentToValidate)} schema is valid`);
385
385
  } else {
386
- throw new Error(`Invalid: ${ajv.errorsText(validateSchema.errors)}`);
386
+ if (category === CATEGORY_OVERRIDE) {
387
+ throw new Error(`Invalid: ${ajv.errorsText(validateOverrideSchema.errors)}`);
388
+ }
389
+ else {
390
+ throw new Error(`Invalid: ${ajv.errorsText(validateSchema.errors)}`);
391
+ }
392
+
387
393
  }
388
394
  };
package/src/util.js CHANGED
@@ -120,6 +120,8 @@ export const deleteServerComponent = async componentKey => {
120
120
  try {
121
121
  const OauthData = fs.readFileSync(TOKEN_PATH, 'utf8');
122
122
 
123
+ let status = 500;
124
+
123
125
  if (OauthData) {
124
126
  const {
125
127
  access_token: accessToken,
@@ -133,7 +135,10 @@ export const deleteServerComponent = async componentKey => {
133
135
  Authorization: `${tokenType} ${accessToken}`
134
136
  }
135
137
  })
136
- .then(response => response.text())
138
+ .then(response => {
139
+ status = response.status;
140
+ return response.text();
141
+ })
137
142
  .then(resp => {
138
143
  const respData = JSON.parse(resp);
139
144
  if (respData.status == 200) {
@@ -142,7 +147,21 @@ export const deleteServerComponent = async componentKey => {
142
147
  throw new Error(`${respData.message}`);
143
148
  }
144
149
  })
145
- .catch(e => Promise.reject(`${chalk.bold.red(e)}`));
150
+ .catch(e => {
151
+ if (status === 403) {
152
+ // eslint-disable-next-line prefer-promise-reject-errors
153
+ Promise.reject(
154
+ `${chalk.bold.red(
155
+ 'Error forbidden: User does not have privileges to Delete.'
156
+ )}`
157
+ );
158
+ }
159
+ else {
160
+ // eslint-disable-next-line prefer-promise-reject-errors
161
+ Promise.reject(`${chalk.bold.red(e)}`)
162
+ }
163
+
164
+ });
146
165
  }
147
166
  } catch (error) {
148
167
  console.log(`\n${chalk.bold.red(error)}`);