@pega/custom-dx-components 0.23.1 → 0.23.3

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.
Files changed (43) hide show
  1. package/package.json +2 -1
  2. package/src/constants.js +3 -0
  3. package/src/tasks/create/templates/Constellation/Field/Boolean/config.json.mustache +1 -0
  4. package/src/tasks/create/templates/Constellation/Field/Date/config.json.mustache +1 -0
  5. package/src/tasks/create/templates/Constellation/Field/DateTime/config.json.mustache +1 -0
  6. package/src/tasks/create/templates/Constellation/Field/Decimal/config.json.mustache +1 -0
  7. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/config.json.mustache +1 -0
  8. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/config.json.mustache +1 -0
  9. package/src/tasks/create/templates/Constellation/Field/Integer/config.json.mustache +1 -0
  10. package/src/tasks/create/templates/Constellation/Field/Picklist/config.json.mustache +1 -0
  11. package/src/tasks/create/templates/Constellation/Field/Text/config.json.mustache +1 -0
  12. package/src/tasks/create/templates/Constellation/Field/Text-Email/config.json.mustache +1 -0
  13. package/src/tasks/create/templates/Constellation/Field/Text-Input/config.json.mustache +1 -0
  14. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/config.json.mustache +1 -0
  15. package/src/tasks/create/templates/Constellation/Field/Text-Phone/config.json.mustache +1 -0
  16. package/src/tasks/create/templates/Constellation/Field/Text-URL/config.json.mustache +1 -0
  17. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/config.json.mustache +1 -0
  18. package/src/tasks/create/templates/Constellation/Template/DETAILS/config.json.mustache +1 -0
  19. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/config.json.mustache +1 -0
  20. package/src/tasks/create/templates/Constellation/Template/FORM/config.json.mustache +1 -0
  21. package/src/tasks/create/templates/Constellation/Template/FORM-region/config.json.mustache +1 -0
  22. package/src/tasks/create/templates/Constellation/Template/PAGE/config.json.mustache +1 -0
  23. package/src/tasks/create/templates/Constellation/Widget/CASE/config.json.mustache +1 -0
  24. package/src/tasks/create/templates/Constellation/Widget/PAGE/config.json.mustache +1 -0
  25. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/config.json.mustache +1 -0
  26. package/src/tasks/generate-ai/aiPrompt.txt.mustache +13 -111
  27. package/src/tasks/generate-ai/aiPromptDavinci.txt.mustache +14 -0
  28. package/src/tasks/generate-ai/helper.js +310 -104
  29. package/src/tasks/generate-ai/index.js +5 -4
  30. package/src/tasks/init/template/package.json.mustache +1 -1
  31. package/src/tasks/init/template/src/components/_components.md +1 -0
  32. package/src/util.js +125 -0
  33. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURL.stories.tsx +0 -19
  34. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURL.styles.ts +0 -5
  35. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURL.types.ts +0 -10
  36. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURLDisplay.tsx +0 -25
  37. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURLInput.tsx +0 -24
  38. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/config.json +0 -13
  39. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/index.ts +0 -2
  40. package/src/tasks/init/template/src/components/Organization_Library_VideoPlayer/config.json +0 -44
  41. package/src/tasks/init/template/src/components/Organization_Library_VideoPlayer/demo.stories.jsx +0 -40
  42. package/src/tasks/init/template/src/components/Organization_Library_VideoPlayer/index.jsx +0 -42
  43. package/src/tasks/init/template/src/components/Organization_Library_VideoPlayer/styles.js +0 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/custom-dx-components",
3
- "version": "0.23.1",
3
+ "version": "0.23.3",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
@@ -33,6 +33,7 @@
33
33
  "gitignore": "^0.7.0",
34
34
  "inquirer": "^9.1.1",
35
35
  "listr": "^0.14.3",
36
+ "lodash": "^4.17.21",
36
37
  "mini-css-extract-plugin": "2.6.1",
37
38
  "mustache": "^4.2.0",
38
39
  "ncp": "^2.0.0",
package/src/constants.js CHANGED
@@ -7,6 +7,7 @@ export const TOKEN_PATH = 'node_modules/@pega/custom-dx-components/.access_token
7
7
  export const SERVICE_TOKEN_PATH = 'node_modules/@pega/custom-dx-components/.service_token';
8
8
  export const OOTB_COMPONENTS = 'node_modules/@pega/custom-dx-components/.ootb_components';
9
9
  export const AI_PROMPT_FILENAME = 'aiPrompt.txt.mustache';
10
+ export const AI_DAVINCI_PROMPT_FILENAME = 'aiPromptDavinci.txt.mustache';
10
11
 
11
12
  /* REST end points */
12
13
  export const PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/publish_component';
@@ -14,6 +15,8 @@ export const LIST_COMPONENT_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/list_c
14
15
  export const OOTB_COMPONENT_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/ootb_component';
15
16
  export const DELETE_COMPONENT_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/delete_component';
16
17
  export const BOOTSTRAP_SERVICE_REST_ENDPOINT = "PRRestService/application/v2/data_views/D_pxBootstrapConfig";
18
+ export const DXCOMPGENAI_SERVICE_REST_ENDPOINT = "PRRestService/application/v2/data_views/D_DXCompAIGenList";
19
+
17
20
  export const SERVICES_AI_REST_ENDPOINT = 'generativeai';
18
21
  export const INF_TOKEN_URL_V1 = 'PRRestService/oauth2/v1/token';
19
22
  export const INF_AUTHORIZE_URL_V1 = 'PRRestService/oauth2/v1/authorize';
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  "icon": "images/pz-checkbox-active.svg",
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  "icon": "images/pz-date-time-active.svg",
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  "icon": "images/pz-text-input-active.svg",
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  "icon": "images/pz-decimal-active.svg",
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  "icon": "images/pz-currency-active.svg",
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  "icon": "images/pz-text-input-active.svg",
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  {{#IS_TEMPLATE}}
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  "icon": "images/pz-dropdown-active.svg",
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  {{#IS_TEMPLATE}}
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  "icon": "images/pz-email-active.svg",
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": "Text",
12
13
  "icon": "images/pz-text-input-active.svg",
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  "icon": "images/pz-text-area-active.svg",
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  "icon": "images/pz-phone-active.svg",
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  "icon": "images/pz-url-active.svg",
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  "icon": "images/pz-date-time-active.svg",
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  "icon": "OneColumnDetails.svg",
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  "icon": "TwoColumnDetails.svg",
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  "icon": "DefaultForm.svg",
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  "icon": "TwoColumn.svg",
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  "icon": "OneColumnPage.svg",
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  "icon": "OneColumnPage.svg",
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  "icon": "OneColumnPage.svg",
@@ -7,6 +7,7 @@
7
7
  "library": "{{LIBRARY}}",
8
8
  "allowedApplications": {{{ALLOWEDAPPS}}},
9
9
  "componentKey": "{{COMPONENT_KEY}}",
10
+ "compName" : "{{COMPONENT_CLASS_NAME}}",
10
11
  "type": "{{TYPE}}",
11
12
  "subtype": {{{SUB_TYPE}}},
12
13
  "icon": "OneColumnPage.svg",
@@ -1,121 +1,23 @@
1
- Your task is to generate a custom DX component based on the Pega Constellation architecture. A custom DX component is a React functional component that uses hooks. Create the first iteration of this component using the code template below, delimited by the second set of triple backticks.
1
+ You are a Pega Digital Experience (DX) Component and React expert who only produces sample code with no additional narrative. A Pega React DX Component is a functional component that uses hooks, PropTypes and StyledComponents.
2
2
 
3
- Replace MyOrg, MyLib and MyComponent with the text specified in InputProperties called organization, library and name respectively that is provided in the in the json properties array delimited by the fourth set of triple backticks. Be aware that MyComponent should be derived from the last part of the componentKey text that is delimited by a '_'. Based on the example component definition delimited by the third set of three backticks, replace the component props and PropTypes with the properties defined in the properties json array delimited by the fourth set of backticks.
4
3
 
5
- DesignSystemComponents is an array of jsx React components. Replace the DesignSystemComponents import with the comma delimited list of imported components from '@pega/cosmos-react-core' with the text specified in DesignSystemComponents, delimited by the first set of triple backticks. Also add in the jsx components in the render function.
4
+ Very important: The name of the component comes from component definition compName.
6
5
 
7
- {{COMPONENT_ADDITIONAL}}
6
+ Very important: The type of component to be created comes from component definition subtype.
7
+
8
+ Very important: A DX component has all of it's data passed in via a single object that must always be called props. The object properties are then destructured in the component. There is always a function passed in called getPConnect() that is required. All event handlers are created in the same component and not passed in via the props object. Apart from getPConnect() all of the object properties are defined in an array called properties in a file called config.json (a.k.a the component definition).
8
9
 
9
- DesignSystemComponents:
10
- ```{{COMPONENT_DSC}}```
11
10
 
12
- Template:
13
- ```
14
- import PropTypes from 'prop-types';
15
- import { DesignSystemComponents } from '@pega/cosmos-react-core';
16
- import StyledMyOrgMyLibMyComponentWrapper from './styles';
11
+ Presentation components are imported from the Constellation Design System from the packages @pega/cosmos-react-core, @pega/cosmos-react-work, @pega/cosmos-react-social.
17
12
 
18
- export default function MyOrgMyLibMyComponent(props) {
19
- const { getPConnect, visibility, disabled, required, aNumber, aString, aBoolean } = props;
13
+ {{COMPONENT_ADDITIONAL}}
14
+
15
+ Build a component defined by subtype in component definition.
20
16
 
21
- const pConn = getPConnect();
17
+ Should use the following design system components
22
18
 
23
- return (
24
- <StyledMyOrgMyLibMyPageWidgetWrapper>
25
- <DesignSystemComponent
26
- input1 = {aNumber}
27
- input2 = {aString}
28
- input3 = {aBoolean}
29
- />
30
- </StyledMyOrgMyLibMyPageWidgetWrapper>
31
- );
32
- }
19
+ DesignSystemComponents:
20
+ {{COMPONENT_DSC}}
33
21
 
34
- MyOrgMyLibMyComponent.defaultProps = {
35
- aString: '',
36
- aNumber: 0,
37
- aBoolean: false,
38
- visibility: true,
39
- disabled: false,
40
- required: false
41
- }
42
- MyOrgMyLibMyComponent.propTypes = {
43
- aString: PropTypes.string,
44
- aNumber: PropTypes.number,
45
- aBoolean: PropTypes.bool,
46
- visibility: PropTypes.string.bool,
47
- disabled: PropTypes.string.bool,
48
- required: PropTypes.string.bool,
49
- getPConnect: PropTypes.func.isRequired
50
- }
51
- ```
52
- ExampleComponentDefinition:
53
- ```
54
- {
55
- "name": "MyOrg_MyLib_MyComponent",
56
- "label": "My Component",
57
- "description": "My Component",
58
- "organization": "MyOrg",
59
- "version": "01.01.01",
60
- "library": "MyLib",
61
- "allowedApplications": [],
62
- "componentKey": "MyOrg_MyLib_MyComponent",
63
- "type": "",
64
- "subtype": "",
65
- "properties": [
66
- {
67
- "name": "aString",
68
- "label": "aString value",
69
- "format": "TEXT"
70
- },
71
- {
72
- "name": "aBoolean",
73
- "label": "aBoolean value",
74
- "format": "BOOLEAN"
75
- },
76
- {
77
- "name": "aNumber",
78
- "label": "aNumber value",
79
- "format": "NUMBER",
80
- "defaultValue": "0"
81
- },
82
- {
83
- "name": "visibility",
84
- "label": "Visible",
85
- "format": "VISIBILITY"
86
- },
87
- {
88
- "name": "disabled",
89
- "label": "Disabled",
90
- "format": "DISABLED",
91
- "visibility": "(!$this.readOnly = true)"
92
- },
93
- {
94
- "name": "required",
95
- "label": "Required",
96
- "format": "REQUIRED",
97
- "visibility": "(!$this.readOnly = true)"
98
- },
99
- {
100
- "label": "Advanced",
101
- "format": "GROUP",
102
- "collapsible": true,
103
- "properties": [
104
- {
105
- "name": "testId",
106
- "label": "Test ID",
107
- "format": "TEXT",
108
- "ignorePattern": "[^-_\\p{N}\\p{L}]",
109
- "includeAnnotations": false
110
- }
111
- ]
112
- }
113
- ],
114
- "defaultConfig": {
115
- }
116
- }
117
- ```
118
- InputProperties:
119
- ```
22
+ Here is the component definition
120
23
  {{COMPONENT_CONFIG}}
121
- ```
@@ -0,0 +1,14 @@
1
+ You are a Pega Digital Experience (DX) Component and React expert who only produces sample code with no additional narrative. A Pega React DX Component is a functional component that uses hooks, PropTypes and StyledComponents.
2
+
3
+
4
+ Very important: The name of the component comes from component definition compName.
5
+
6
+ Very important: A DX component has all of it's data passed in via a single object that must always be called props. The object properties are then destructured in the component. There is always a function passed in called getPConnect() that is required. All event handlers are created in the same component and not passed in via the props object. Apart from getPConnect() all of the object properties are defined in an array called properties in a file called config.json (a.k.a the component definition).
7
+
8
+
9
+ Presentation components are imported from the Constellation Design System from the packages @pega/cosmos-react-core, @pega/cosmos-react-work, @pega/cosmos-react-social.
10
+
11
+ {{COMPONENT_ADDITIONAL}}
12
+
13
+ Here is the component definition
14
+ {{COMPONENT_CONFIG}}