@pega/custom-dx-components 0.0.1 → 0.23.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.
- package/.vscode/extensions.json +1 -1
- package/README.md +6 -189
- package/package.json +34 -32
- package/src/auth.js +608 -0
- package/src/cli.js +42 -0
- package/src/constants.js +125 -8
- package/src/tasks/authenticate/helper.js +91 -8
- package/src/tasks/authenticate/index.js +169 -49
- package/src/tasks/build/helper.js +122 -0
- package/src/tasks/build/index.js +54 -0
- package/src/tasks/build-all/helper.js +70 -0
- package/src/tasks/build-all/index.js +79 -0
- package/src/tasks/{publish/bundle → bundle}/builder/index.js +49 -5
- package/src/tasks/{publish/bundle → bundle}/builder/webpack.config.js +5 -3
- package/src/tasks/{publish/bundle → bundle}/index.js +2 -2
- package/src/tasks/create/index.js +87 -64
- package/src/tasks/create/templates/Constellation/Field/Boolean/Boolean.js.mustache +38 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +26 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/config.json.mustache +146 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +61 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +170 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +61 -0
- package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +41 -0
- package/src/tasks/create/templates/Constellation/Field/Date/config.json.mustache +196 -0
- package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +439 -0
- package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +73 -0
- package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +256 -0
- package/src/tasks/create/templates/Constellation/Field/Date/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/Date/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Date/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/config.json.mustache +257 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +92 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/date-utils.js.mustache +287 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +328 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +73 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +254 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/config.json.mustache +279 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +49 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +273 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/config.json.mustache +292 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +53 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +299 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/config.json.mustache +94 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +49 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +281 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/config.json.mustache +348 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +49 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +336 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/config.json.mustache +115 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +78 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +351 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/mock.stories.js.mustache +67 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/suggestions-handler.js +10 -0
- package/src/tasks/create/{template → templates/Constellation/Field/Text}/config.json.mustache +15 -5
- package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +51 -0
- package/src/tasks/create/{template → templates/Constellation/Field/Text}/index.jsx.mustache +5 -0
- package/src/tasks/create/templates/Constellation/Field/Text/mock.stories.js.mustache +13 -0
- package/src/tasks/create/templates/Constellation/Field/Text/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/config.json.mustache +112 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +48 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +231 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/mock.stories.js.mustache +22 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/StatusWork.jsx +26 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/config.json.mustache +112 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +48 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +239 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/config.json.mustache +112 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +48 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +231 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/mock.stories.js.mustache +20 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/config.json.mustache +124 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +46 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +267 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/mock.stories.js.mustache +37 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/config.json.mustache +238 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +46 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +232 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/mock.stories.js.mustache +22 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/text-url.jsx.mustache +173 -0
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/config.json.mustache +186 -0
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/demo.stories.jsx.mustache +57 -0
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/index.jsx.mustache +213 -0
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/mock.stories.js.mustache +20 -0
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/time-of-day.js.mustache +287 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/OneColumnDetails.svg +22 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/StatusWork.jsx.mustache +26 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/config.json.mustache +36 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +132 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +86 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +189 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +152 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +26 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/TwoColumnDetails.svg +28 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/config.json.mustache +43 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +136 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +86 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +230 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +155 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/DefaultForm.svg +29 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/config.json.mustache +46 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +169 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +45 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +137 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/TwoColumn.svg +38 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/config.json.mustache +28 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +178 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +48 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +143 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/GetNextWork.jsx.mustache +35 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/OneColumnPage.svg +36 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/config.json.mustache +33 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +102 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +70 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/localizations.json.mustache +4 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/mock.stories.js.mustache +94 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +229 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/OneColumnPage.svg +36 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/config.json.mustache +24 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +78 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +76 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +390 -0
- package/src/tasks/create/{template → templates/Constellation/Widget/CASE}/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Widget/PAGE/OneColumnPage.svg +36 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/config.json.mustache +60 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +30 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/index.jsx.mustache +48 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +23 -0
- package/src/tasks/{init/template/src/components/Organization_Library_VideoPlayer/styles.js → create/templates/Constellation/Widget/PAGE/styles.js.mustache} +3 -1
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Avatar.jsx.mustache +75 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/OneColumnPage.svg +36 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Operator.jsx.mustache +240 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/config.json.mustache +67 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +68 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +110 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/mock.stories.js.mustache +51 -0
- package/src/tasks/{init/template/src/components/Organization_Library_MediaURL/MediaURL.styles.ts → create/templates/Constellation/Widget/PAGE-CASE/styles.js.mustache} +3 -1
- package/src/tasks/create-all/index.js +398 -0
- package/src/tasks/delete/helper.js +6 -4
- package/src/tasks/delete/index.js +4 -0
- package/src/tasks/delete-all/helper.js +153 -0
- package/src/tasks/delete-all/index.js +49 -0
- package/src/tasks/generate-ai/aiPrompt.txt.mustache +23 -0
- package/src/tasks/generate-ai/aiPromptDavinci.txt.mustache +14 -0
- package/src/tasks/generate-ai/helper.js +357 -0
- package/src/tasks/generate-ai/index.js +34 -0
- package/src/tasks/index.js +7 -0
- package/src/tasks/init/index.js +9 -3
- package/src/tasks/init/template/.eslintignore +8 -0
- package/src/tasks/init/template/.eslintrc.json +186 -5
- package/src/tasks/init/template/.vscode/extensions.json +1 -1
- package/src/tasks/init/template/README.md +80 -61
- package/src/tasks/init/template/keys/DX-ComponentDev.zip +0 -0
- package/src/tasks/init/template/keys/dxcb.crt +32 -0
- package/src/tasks/init/template/keys/dxcb.key +51 -0
- package/src/tasks/init/template/package.json.mustache +44 -21
- package/src/tasks/init/template/src/components/_components.md +1 -0
- package/src/tasks/init/template/tasks.config.json +19 -5
- package/src/tasks/init/template/templateNPMRC.txt +8 -0
- package/src/tasks/linter/index.js +46 -0
- package/src/tasks/list/helper.js +19 -6
- package/src/tasks/list/index.js +4 -0
- package/src/tasks/publish/helper.js +13 -4
- package/src/tasks/publish/index.js +14 -1
- package/src/tasks/publish-all/helper.js +154 -0
- package/src/tasks/publish-all/index.js +95 -0
- package/src/tasks/rename/index.js +314 -0
- package/src/tasks/validator/index.js +291 -18
- package/src/util.js +372 -6
- package/src/tasks/create/template/demo.stories.jsx.mustache +0 -44
- package/src/tasks/init/template/src/components/MBTAList/MBTAList.stories.tsx +0 -10
- package/src/tasks/init/template/src/components/MBTAList/MBTAList.tsx +0 -122
- package/src/tasks/init/template/src/components/MBTAList/icons/accessible.icon.tsx +0 -14
- package/src/tasks/init/template/src/components/MBTAList/icons/bus.icon.tsx +0 -13
- package/src/tasks/init/template/src/components/MBTAList/icons/mbta.icon.tsx +0 -10
- package/src/tasks/init/template/src/components/MBTAList/icons/subway.icon.tsx +0 -14
- package/src/tasks/init/template/src/components/MBTAList/index.ts +0 -2
- package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURL.stories.tsx +0 -19
- package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURL.types.ts +0 -10
- package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURLDisplay.tsx +0 -25
- package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURLInput.tsx +0 -24
- package/src/tasks/init/template/src/components/Organization_Library_MediaURL/config.json +0 -13
- package/src/tasks/init/template/src/components/Organization_Library_MediaURL/index.ts +0 -2
- package/src/tasks/init/template/src/components/Organization_Library_VideoPlayer/config.json +0 -44
- package/src/tasks/init/template/src/components/Organization_Library_VideoPlayer/demo.stories.jsx +0 -40
- package/src/tasks/init/template/src/components/Organization_Library_VideoPlayer/index.jsx +0 -42
- /package/src/tasks/{publish/bundle → bundle}/builder/modules.js +0 -0
- /package/src/tasks/{publish/bundle → bundle}/builder/paths.js +0 -0
package/src/util.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
2
3
|
import { join } from 'path';
|
|
3
4
|
import { promisify } from 'util';
|
|
4
5
|
import https from 'https';
|
|
@@ -7,6 +8,10 @@ import chalk from 'chalk';
|
|
|
7
8
|
import mustache from 'mustache';
|
|
8
9
|
import pascalCase from 'pascalcase';
|
|
9
10
|
import fetch from 'node-fetch';
|
|
11
|
+
import { createRequire } from 'module';
|
|
12
|
+
|
|
13
|
+
import _ from 'lodash';
|
|
14
|
+
|
|
10
15
|
|
|
11
16
|
import {
|
|
12
17
|
COMPONENTS_DIRECTORY_PATH,
|
|
@@ -15,11 +20,16 @@ import {
|
|
|
15
20
|
OOTB_COMPONENT_SERVICE_REST_ENDPOINT,
|
|
16
21
|
DELETE_COMPONENT_SERVICE_REST_ENDPOINT,
|
|
17
22
|
OOTB_COMPONENTS,
|
|
18
|
-
|
|
23
|
+
SERVICES_AI_REST_ENDPOINT,
|
|
24
|
+
BOOTSTRAP_SERVICE_REST_ENDPOINT,
|
|
25
|
+
DXCOMPGENAI_SERVICE_REST_ENDPOINT,
|
|
26
|
+
SERVICE_TOKEN_PATH
|
|
19
27
|
} from './constants.js';
|
|
20
28
|
|
|
21
29
|
const access = promisify(fs.access);
|
|
22
30
|
|
|
31
|
+
let servicesToken = "";
|
|
32
|
+
|
|
23
33
|
export const checkPathAccess = async (path, options = {}) => {
|
|
24
34
|
const { errorMessage } = options;
|
|
25
35
|
|
|
@@ -51,7 +61,7 @@ export const deleteLocalComponent = async componentKey => {
|
|
|
51
61
|
|
|
52
62
|
const directory = join(currentDirectory, data[COMPONENTS_DIRECTORY_PATH], componentKey);
|
|
53
63
|
|
|
54
|
-
fs.
|
|
64
|
+
fs.rm(directory, { recursive: true }, err => {
|
|
55
65
|
if (err) {
|
|
56
66
|
throw err;
|
|
57
67
|
}
|
|
@@ -74,7 +84,9 @@ export const deleteServerComponent = async componentKey => {
|
|
|
74
84
|
token_type: tokenType,
|
|
75
85
|
refresh_token: refreshToken
|
|
76
86
|
} = JSON.parse(OauthData);
|
|
77
|
-
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
await fetch(deleteUrl, {
|
|
78
90
|
method: 'DELETE',
|
|
79
91
|
agent: new https.Agent({ rejectUnauthorized: false }),
|
|
80
92
|
headers: {
|
|
@@ -83,12 +95,23 @@ export const deleteServerComponent = async componentKey => {
|
|
|
83
95
|
})
|
|
84
96
|
.then(response => response.text())
|
|
85
97
|
.then(resp => {
|
|
86
|
-
|
|
98
|
+
let respData;
|
|
99
|
+
try {
|
|
100
|
+
respData = JSON.parse(resp);
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
console.log(chalk.bold.redBright(`Failure : ${resp}`));
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
|
|
87
108
|
if (respData.status == 200) {
|
|
88
109
|
console.log(chalk.bold.green(`Success : ${respData.message}`));
|
|
89
110
|
} else {
|
|
90
111
|
throw new Error(`${respData.message}`);
|
|
91
112
|
}
|
|
113
|
+
|
|
114
|
+
|
|
92
115
|
})
|
|
93
116
|
.catch(e => Promise.reject(`${chalk.bold.red(e)}`));
|
|
94
117
|
}
|
|
@@ -97,6 +120,7 @@ export const deleteServerComponent = async componentKey => {
|
|
|
97
120
|
}
|
|
98
121
|
};
|
|
99
122
|
|
|
123
|
+
|
|
100
124
|
export const getComponents = async () => {
|
|
101
125
|
const currentDirectory = process.cwd();
|
|
102
126
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
@@ -120,6 +144,91 @@ export const getComponents = async () => {
|
|
|
120
144
|
.map(dirent => dirent.name);
|
|
121
145
|
};
|
|
122
146
|
|
|
147
|
+
export const getComponentsOfType = async (componentType) => {
|
|
148
|
+
const componentList = await getComponents();
|
|
149
|
+
let filteredList = Array();
|
|
150
|
+
if (componentList.length > 0) {
|
|
151
|
+
|
|
152
|
+
const currentDirectory = process.cwd();
|
|
153
|
+
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
154
|
+
|
|
155
|
+
await checkPathAccess(pegaConfigJsonPath);
|
|
156
|
+
|
|
157
|
+
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
158
|
+
data = JSON.parse(data);
|
|
159
|
+
|
|
160
|
+
if (!data[COMPONENTS_DIRECTORY_PATH]) {
|
|
161
|
+
console.error(
|
|
162
|
+
`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
|
|
163
|
+
);
|
|
164
|
+
process.exit(1);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const directory = join(currentDirectory, data[COMPONENTS_DIRECTORY_PATH]);
|
|
168
|
+
const arTypes = componentType.split(",");
|
|
169
|
+
|
|
170
|
+
for (let index in componentList) {
|
|
171
|
+
let compDir = directory + path.sep + componentList[index];
|
|
172
|
+
let type = await getComponentConfigType(compDir);
|
|
173
|
+
if (arTypes.includes(type)) {
|
|
174
|
+
filteredList.push( componentList[index]);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
return filteredList;
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
return componentList;
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
export const getSubComponents = async (directory, type) => {
|
|
191
|
+
|
|
192
|
+
const subDirectory = join(directory, type);
|
|
193
|
+
return fs
|
|
194
|
+
.readdirSync(subDirectory, { withFileTypes: true })
|
|
195
|
+
.filter(dirent => dirent.isDirectory())
|
|
196
|
+
.map(dirent => dirent.name);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
export const getDirectoryFiles = async (directory) => {
|
|
201
|
+
return fs
|
|
202
|
+
.readdirSync(directory, { withFileTypes: true })
|
|
203
|
+
.filter(dirent => !dirent.isDirectory())
|
|
204
|
+
.map(dirent => dirent.name);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
export const getComponentsObj = async () => {
|
|
209
|
+
|
|
210
|
+
let compList = new Array();
|
|
211
|
+
|
|
212
|
+
//const componentList = await getDirectoryFiles(directory);
|
|
213
|
+
const componentList = await getComponents();
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
if (componentList.length > 0) {
|
|
217
|
+
|
|
218
|
+
compList.push(...componentList.map(
|
|
219
|
+
name => {
|
|
220
|
+
const container = {};
|
|
221
|
+
container.name = name;
|
|
222
|
+
container.value = name;
|
|
223
|
+
|
|
224
|
+
return container;
|
|
225
|
+
}
|
|
226
|
+
));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return compList;
|
|
230
|
+
}
|
|
231
|
+
|
|
123
232
|
export const getPegaConfig = async () => {
|
|
124
233
|
const currentDirectory = process.cwd();
|
|
125
234
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
@@ -132,11 +241,41 @@ export const getPegaConfig = async () => {
|
|
|
132
241
|
return data;
|
|
133
242
|
};
|
|
134
243
|
|
|
244
|
+
export const getAIPromptData = async (aiPromptPath) => {
|
|
245
|
+
await checkPathAccess(aiPromptPath);
|
|
246
|
+
|
|
247
|
+
let data = fs.readFileSync(aiPromptPath, { encoding: 'utf8' });
|
|
248
|
+
|
|
249
|
+
return data;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export const getComponentConfigJson = async (componentDirectory) => {
|
|
253
|
+
|
|
254
|
+
const filePath = join(componentDirectory, "config.json");
|
|
255
|
+
await checkPathAccess(filePath);
|
|
256
|
+
|
|
257
|
+
let data = fs.readFileSync(filePath, { encoding: 'utf8' });
|
|
258
|
+
|
|
259
|
+
data = _.unescape(data);
|
|
260
|
+
|
|
261
|
+
return data;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export const getComponentConfigType = async (componentDirectory) => {
|
|
265
|
+
const configData = await getComponentConfigJson(componentDirectory);
|
|
266
|
+
|
|
267
|
+
let data = JSON.parse(configData);
|
|
268
|
+
|
|
269
|
+
return data.type;
|
|
270
|
+
|
|
271
|
+
}
|
|
272
|
+
|
|
135
273
|
export const getPegaServerConfig = async () => {
|
|
136
274
|
const config = await getPegaConfig();
|
|
137
275
|
return config['server-config'];
|
|
138
276
|
};
|
|
139
277
|
|
|
278
|
+
|
|
140
279
|
export const getComponentDefaults = async () => {
|
|
141
280
|
const config = await getPegaConfig();
|
|
142
281
|
return config.component;
|
|
@@ -218,6 +357,25 @@ export const validateRulesetVersion = str => {
|
|
|
218
357
|
return regex.test(str);
|
|
219
358
|
};
|
|
220
359
|
|
|
360
|
+
export const showVersion = () => {
|
|
361
|
+
// get package version, so can display at start
|
|
362
|
+
const require = createRequire(import.meta.url);
|
|
363
|
+
const pData = require("@pega/custom-dx-components/package.json");
|
|
364
|
+
|
|
365
|
+
console.log(chalk.green("DX Component Builder v" + pData.version));
|
|
366
|
+
|
|
367
|
+
// do a check of node version, it should be 18 or greater
|
|
368
|
+
const arNodeVersion = process.versions.node.split(".");
|
|
369
|
+
|
|
370
|
+
const nodeMajorVersion = parseInt(arNodeVersion[0]);
|
|
371
|
+
const nodeMinorVersion = parseInt(arNodeVersion[1]);
|
|
372
|
+
|
|
373
|
+
if (nodeMajorVersion < 18) {
|
|
374
|
+
console.log(chalk.redBright("DX Component Builder - SDK requires node v18 or greater, current version: " + process.version));
|
|
375
|
+
process.exit(1);
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
|
|
221
379
|
export const getOOTBComponents = async () => {
|
|
222
380
|
return new Promise((resolve, reject) => {
|
|
223
381
|
fs.readFile(OOTB_COMPONENTS, 'utf-8', async (err, data) => {
|
|
@@ -272,6 +430,214 @@ export const getOOTBComponents = async () => {
|
|
|
272
430
|
});
|
|
273
431
|
};
|
|
274
432
|
|
|
275
|
-
|
|
276
|
-
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
export const storeServicesToken = async () => {
|
|
436
|
+
const { server } = await getPegaServerConfig();
|
|
437
|
+
const url = constructCompleteUrl(server, BOOTSTRAP_SERVICE_REST_ENDPOINT);
|
|
438
|
+
|
|
439
|
+
let returnToken = "";
|
|
440
|
+
|
|
441
|
+
try {
|
|
442
|
+
const OauthData = fs.readFileSync(TOKEN_PATH, 'utf8');
|
|
443
|
+
if (OauthData) {
|
|
444
|
+
let {
|
|
445
|
+
access_token: accessToken,
|
|
446
|
+
token_type: tokenType,
|
|
447
|
+
refresh_token: refreshToken
|
|
448
|
+
} = JSON.parse(OauthData);
|
|
449
|
+
|
|
450
|
+
await fetch(url, {
|
|
451
|
+
method: 'GET',
|
|
452
|
+
agent: new https.Agent({ rejectUnauthorized: false }),
|
|
453
|
+
headers: {
|
|
454
|
+
Authorization: `${tokenType} ${accessToken}`
|
|
455
|
+
},
|
|
456
|
+
})
|
|
457
|
+
.then(response => response.text())
|
|
458
|
+
.then(data => {
|
|
459
|
+
|
|
460
|
+
try {
|
|
461
|
+
const returnData = JSON.parse(data);
|
|
462
|
+
|
|
463
|
+
if (returnData != null && returnData.pyConfigJSON) {
|
|
464
|
+
const returnJSON = JSON.parse(returnData.pyConfigJSON);
|
|
465
|
+
const strToken = JSON.stringify(returnJSON.tokens, null, 2);
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
fs.writeFileSync(SERVICE_TOKEN_PATH, strToken, err => {
|
|
469
|
+
if (err) {
|
|
470
|
+
Promise.reject(`${chalk.bold.red(err)}`);
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
//returnToken = returnJSON.tokens.C11NB2S;
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
//returnToken = "";
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
catch {
|
|
480
|
+
Promise.reject(`${chalk.bold.red(data)}`);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
})
|
|
485
|
+
.catch(e => Promise.reject(`${chalk.bold.red(e)}`));
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
catch (error) {
|
|
489
|
+
throw new Error('Error occurred in validation', error);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
//return returnToken;
|
|
493
|
+
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
export const getAIComponent = async (prompt) => {
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
const { servicesServer } = await getPegaServerConfig();
|
|
500
|
+
if (servicesServer === undefined) {
|
|
501
|
+
Promise.reject(`${chalk.bold.red("ERROR: servicesServer not defined in tasks.config.json" )}`);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
const serviceUrl = constructCompleteUrl(servicesServer, SERVICES_AI_REST_ENDPOINT);
|
|
505
|
+
|
|
506
|
+
const jsonBody = { "prompt" : prompt };
|
|
507
|
+
|
|
508
|
+
let returnCode = "";
|
|
509
|
+
|
|
510
|
+
try {
|
|
511
|
+
const OauthData = fs.readFileSync(TOKEN_PATH, 'utf8');
|
|
512
|
+
const ServicesData = fs.readFileSync(SERVICE_TOKEN_PATH, 'utf8');
|
|
513
|
+
if (OauthData && ServicesData) {
|
|
514
|
+
let {
|
|
515
|
+
access_token: accessToken,
|
|
516
|
+
token_type: tokenType,
|
|
517
|
+
refresh_token: refreshToken
|
|
518
|
+
} = JSON.parse(OauthData);
|
|
519
|
+
|
|
520
|
+
const { C11NB2S } = JSON.parse(ServicesData);
|
|
521
|
+
|
|
522
|
+
// services needs Bearer with a big "B"
|
|
523
|
+
tokenType = convertIntoPascalCase(tokenType);
|
|
524
|
+
|
|
525
|
+
await fetch(serviceUrl, {
|
|
526
|
+
method: 'POST',
|
|
527
|
+
agent: new https.Agent({ rejectUnauthorized: false }),
|
|
528
|
+
headers: {
|
|
529
|
+
Authorization: `${tokenType} ${C11NB2S}`,
|
|
530
|
+
'Accept': 'application/json',
|
|
531
|
+
'Content-Type': 'application/json'
|
|
532
|
+
},
|
|
533
|
+
body: JSON.stringify(jsonBody),
|
|
534
|
+
})
|
|
535
|
+
.then(response => response.text())
|
|
536
|
+
.then(data => {
|
|
537
|
+
|
|
538
|
+
try {
|
|
539
|
+
const returnData = JSON.parse(data);
|
|
540
|
+
|
|
541
|
+
if (returnData != null && returnData.code) {
|
|
542
|
+
returnCode = returnData.code;
|
|
543
|
+
}
|
|
544
|
+
else {
|
|
545
|
+
returnCode = "";
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
catch {
|
|
549
|
+
Promise.reject(`Error in AI generation: \n ${chalk.bold.red(data)}`);
|
|
550
|
+
//throw new Error('Error occurred in validation', data);
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
})
|
|
555
|
+
.catch(e => Promise.reject(`Error in AI generation: \n ${chalk.bold.red(e)}`));
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
catch (error) {
|
|
559
|
+
if (error.code === 'ENOENT') {
|
|
560
|
+
Promise.reject(`${chalk.bold.red("ERROR: Need to authenticate or reauthenticate.")}`);
|
|
561
|
+
}
|
|
562
|
+
else {
|
|
563
|
+
throw new Error('Error occurred in validation', error);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
return returnCode;
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
export const getInfinityAIComponent = async (prompt) => {
|
|
573
|
+
const { server } = await getPegaServerConfig();
|
|
574
|
+
const dataPageUrl = constructCompleteUrl(server, DXCOMPGENAI_SERVICE_REST_ENDPOINT);
|
|
575
|
+
|
|
576
|
+
const jsonBody = { "dataViewParameters" : { "Prompt" : prompt } };
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
let returnCode = "";
|
|
581
|
+
|
|
582
|
+
try {
|
|
583
|
+
const OauthData = fs.readFileSync(TOKEN_PATH, 'utf8');
|
|
584
|
+
|
|
585
|
+
if (OauthData) {
|
|
586
|
+
let {
|
|
587
|
+
access_token: accessToken,
|
|
588
|
+
token_type: tokenType,
|
|
589
|
+
refresh_token: refreshToken
|
|
590
|
+
} = JSON.parse(OauthData);
|
|
591
|
+
|
|
592
|
+
// services needs Bearer with a big "B"
|
|
593
|
+
//tokenType = convertIntoPascalCase(tokenType);
|
|
594
|
+
|
|
595
|
+
await fetch(dataPageUrl, {
|
|
596
|
+
method: 'POST',
|
|
597
|
+
agent: new https.Agent({ rejectUnauthorized: false }),
|
|
598
|
+
headers: {
|
|
599
|
+
Authorization: `${tokenType} ${accessToken}`
|
|
600
|
+
},
|
|
601
|
+
body: JSON.stringify(jsonBody),
|
|
602
|
+
})
|
|
603
|
+
.then(response => response.text())
|
|
604
|
+
.then(data => {
|
|
605
|
+
|
|
606
|
+
try {
|
|
607
|
+
const returnData = JSON.parse(data);
|
|
608
|
+
|
|
609
|
+
if (returnData != null && returnData.data) {
|
|
610
|
+
returnCode = returnData.data[0].pyValue;
|
|
611
|
+
}
|
|
612
|
+
else if (returnData != null && returnData.errors) {
|
|
613
|
+
if (returnData.errors[0].message.indexOf("token") >= 0) {
|
|
614
|
+
Promise.reject(`${chalk.bold.red("ERROR: Need to authenticate or reauthenticate.")}`);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
returnCode = "";
|
|
619
|
+
Promise.reject(`Error in AI generation: \n ${chalk.bold.red(data)}`);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
catch {
|
|
623
|
+
Promise.reject(`Error in AI generation: \n ${chalk.bold.red(data)}`);
|
|
624
|
+
//throw new Error('Error occurred in validation', data);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
})
|
|
629
|
+
.catch(e => Promise.reject(`Error in AI generation: \n ${chalk.bold.red(e)}`));
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
catch (error) {
|
|
633
|
+
if (error.code === 'ENOENT') {
|
|
634
|
+
Promise.reject(`${chalk.bold.red("ERROR: Need to authenticate or reauthenticate.")}`);
|
|
635
|
+
}
|
|
636
|
+
else {
|
|
637
|
+
throw new Error('Error occurred in validation', error);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
return returnCode;
|
|
277
643
|
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { withKnobs, text, boolean } from '@storybook/addon-knobs';
|
|
3
|
-
|
|
4
|
-
import {{COMPONENT_CLASS_NAME}} from './index.jsx';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: '{{COMPONENT_CLASS_NAME}}',
|
|
8
|
-
decorators: [withKnobs],
|
|
9
|
-
component: {{COMPONENT_CLASS_NAME}}
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const base{{COMPONENT_CLASS_NAME}} = () => {
|
|
13
|
-
const [value, setValue] = useState('test value');
|
|
14
|
-
|
|
15
|
-
const props = {
|
|
16
|
-
getPConnect: () => {
|
|
17
|
-
return {
|
|
18
|
-
getActionsApi: () => {
|
|
19
|
-
return {
|
|
20
|
-
updateFieldValue: (propName, value) => {
|
|
21
|
-
setValue(value);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
},
|
|
25
|
-
getStateProps: () => {
|
|
26
|
-
return { value: '.name' };
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
},
|
|
30
|
-
value,
|
|
31
|
-
placeholder: text('Placeholder', 'Test placeholder'),
|
|
32
|
-
disabled: boolean('Disabled', false),
|
|
33
|
-
readOnly: boolean('Disabled', false),
|
|
34
|
-
required: boolean('Disabled', false),
|
|
35
|
-
label: text('Label', 'Sample Label'),
|
|
36
|
-
testId: text('Test id', 'text-12344566')
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<>
|
|
41
|
-
<{{COMPONENT_CLASS_NAME}} {...props} />
|
|
42
|
-
</>
|
|
43
|
-
);
|
|
44
|
-
};
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState, useContext } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Flex,
|
|
4
|
-
SummaryList,
|
|
5
|
-
SummaryListItem,
|
|
6
|
-
ViewAll,
|
|
7
|
-
ModalManagerContext,
|
|
8
|
-
Modal,
|
|
9
|
-
registerIcon,
|
|
10
|
-
Icon,
|
|
11
|
-
MetaList,
|
|
12
|
-
MetaListProps
|
|
13
|
-
} from '@pega/cosmos-react-core';
|
|
14
|
-
|
|
15
|
-
import * as accessibleIcon from './icons/accessible.icon';
|
|
16
|
-
import * as busIcon from './icons/bus.icon';
|
|
17
|
-
import * as mbtaIcon from './icons/mbta.icon';
|
|
18
|
-
import * as subwayIcon from './icons/subway.icon';
|
|
19
|
-
|
|
20
|
-
registerIcon(accessibleIcon, busIcon, mbtaIcon, subwayIcon);
|
|
21
|
-
|
|
22
|
-
export interface MBTAListProps {}
|
|
23
|
-
|
|
24
|
-
const params = new URLSearchParams([
|
|
25
|
-
['page[offset]', '0'],
|
|
26
|
-
['page[limit]', '1000'],
|
|
27
|
-
['filter[latitude]', '42.362339984866466'],
|
|
28
|
-
['filter[longitude]', '-71.07999650212442'],
|
|
29
|
-
['filter[radius]', '0.01'],
|
|
30
|
-
['filter[route_type]', '1,3']
|
|
31
|
-
]);
|
|
32
|
-
|
|
33
|
-
const MBTAList = (props: MBTAListProps) => {
|
|
34
|
-
const [items, setItems] = useState<SummaryListItem[]>();
|
|
35
|
-
const [error, setError] = useState<string>();
|
|
36
|
-
const { create } = useContext(ModalManagerContext);
|
|
37
|
-
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
const controller = new AbortController();
|
|
40
|
-
|
|
41
|
-
fetch(`https://api-v3.mbta.com/stops?${params}`, { signal: controller.signal })
|
|
42
|
-
.then(async res => {
|
|
43
|
-
if (!res.ok) throw new Error(`Responded with "${res.status}"`);
|
|
44
|
-
|
|
45
|
-
const { data } = await res.json();
|
|
46
|
-
if (controller.signal.aborted) return;
|
|
47
|
-
|
|
48
|
-
setItems(
|
|
49
|
-
// TODO: Type the api response: https://api-v3.mbta.com/docs/swagger/index.html#/Stop/ApiWeb_StopController_index
|
|
50
|
-
data.map(({ id, attributes }: any) => {
|
|
51
|
-
const meta: MetaListProps['items'] = [];
|
|
52
|
-
|
|
53
|
-
if (attributes.wheelchair_boarding) {
|
|
54
|
-
meta.push(
|
|
55
|
-
<>
|
|
56
|
-
<Icon name='accessible' style={{ width: '1em', height: '1em' }} />
|
|
57
|
-
Wheelchair boarding
|
|
58
|
-
</>
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (attributes.vehicle_type === 1) {
|
|
63
|
-
meta.push(attributes.platform_name);
|
|
64
|
-
return {
|
|
65
|
-
id,
|
|
66
|
-
visual: <Icon name='subway' />,
|
|
67
|
-
primary: attributes.name,
|
|
68
|
-
secondary: <MetaList items={meta} />
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
meta.push(attributes.name);
|
|
73
|
-
return {
|
|
74
|
-
id,
|
|
75
|
-
visual: <Icon name='bus' />,
|
|
76
|
-
primary: attributes.on_street,
|
|
77
|
-
secondary: <MetaList items={meta} />
|
|
78
|
-
};
|
|
79
|
-
})
|
|
80
|
-
);
|
|
81
|
-
})
|
|
82
|
-
.catch((err: unknown) => {
|
|
83
|
-
if (controller.signal.aborted) return;
|
|
84
|
-
|
|
85
|
-
if (err instanceof Error) {
|
|
86
|
-
setError(err.message);
|
|
87
|
-
} else {
|
|
88
|
-
setError('An error occurred.');
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
return () => {
|
|
93
|
-
controller.abort();
|
|
94
|
-
};
|
|
95
|
-
}, []);
|
|
96
|
-
|
|
97
|
-
return (
|
|
98
|
-
<SummaryList
|
|
99
|
-
{...props}
|
|
100
|
-
icon='mbta'
|
|
101
|
-
name='Stops near Pega'
|
|
102
|
-
count={items?.length}
|
|
103
|
-
items={items?.slice(0, 3) ?? []}
|
|
104
|
-
loading={!items && !error}
|
|
105
|
-
error={error ? { message: error } : undefined}
|
|
106
|
-
onViewAll={() => {
|
|
107
|
-
create(Modal, {
|
|
108
|
-
heading: (
|
|
109
|
-
<Flex container={{ gap: 1, alignItems: 'center' }}>
|
|
110
|
-
<Icon name='mbta' />
|
|
111
|
-
Stops near Pega
|
|
112
|
-
</Flex>
|
|
113
|
-
),
|
|
114
|
-
count: items?.length,
|
|
115
|
-
children: <ViewAll items={items ?? []} />
|
|
116
|
-
});
|
|
117
|
-
}}
|
|
118
|
-
/>
|
|
119
|
-
);
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export default MBTAList;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// FontAwesome "accessible" icon
|
|
2
|
-
// https://fontawesome.com/license
|
|
3
|
-
// Converted from SVG to Cosmos Icon format
|
|
4
|
-
|
|
5
|
-
export const name = 'accessible';
|
|
6
|
-
|
|
7
|
-
export const Component = () => (
|
|
8
|
-
<path
|
|
9
|
-
fill='currentColor'
|
|
10
|
-
d='M423.9 255.8L411 413.1c-3.3 40.7-63.9 35.1-60.6-4.9l10-122.5-41.1 2.3c10.1 20.7 15.8 43.9 15.8 68.5 0 41.2-16.1 78.7-42.3 106.5l-39.3-39.3c57.9-63.7 13.1-167.2-74-167.2-25.9 0-49.5 9.9-67.2 26L73 243.2c22-20.7 50.1-35.1 81.4-40.2l75.3-85.7-42.6-24.8-51.6 46c-30 26.8-70.6-18.5-40.5-45.4l68-60.7c9.8-8.8 24.1-10.2 35.5-3.6 0 0 139.3 80.9 139.5 81.1 16.2 10.1 20.7 36 6.1 52.6L285.7 229l106.1-5.9c18.5-1.1 33.6 14.4 32.1 32.7zm-64.9-154c28.1 0 50.9-22.8 50.9-50.9C409.9 22.8 387.1 0 359 0c-28.1 0-50.9 22.8-50.9 50.9 0 28.1 22.8 50.9 50.9 50.9zM179.6 456.5c-80.6 0-127.4-90.6-82.7-156.1l-39.7-39.7C36.4 287 24 320.3 24 356.4c0 130.7 150.7 201.4 251.4 122.5l-39.7-39.7c-16 10.9-35.3 17.3-56.1 17.3z'
|
|
11
|
-
/>
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
export const viewBox = '0 0 448 512';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export const name = 'bus';
|
|
2
|
-
|
|
3
|
-
export const Component = () => (
|
|
4
|
-
<>
|
|
5
|
-
<path d='m12.06 24c6.72-.17 12.11-5.64 11.94-12.06a12 12 0 1 0 -11.94 12.06' fill='#ffc72c' />
|
|
6
|
-
<path
|
|
7
|
-
d='m18.78 10.67-.66-5.17c-.16-.93-.75-1.3-1.63-1.68a14.25 14.25 0 0 0 -4.49-.82 14.32 14.32 0 0 0 -4.5.82c-.86.37-1.45.75-1.63 1.68l-.66 5.17v7.15h1.17v1.25a1 1 0 0 0 1.91 0v-1.25h7.45v1.25a.91.91 0 0 0 .48.8 1 1 0 0 0 1 0 .88.88 0 0 0 .47-.8v-1.25h1.13zm-9.57-6.36h5.61a.42.42 0 0 1 .43.41.42.42 0 0 1 -.43.42h-5.61a.43.43 0 0 1 -.43-.42.42.42 0 0 1 .43-.41zm-2.79 6.21.58-4.09a.54.54 0 0 1 .51-.43h9.06a.56.56 0 0 1 .54.44l.54 4.09a.33.33 0 0 1 0 .14.49.49 0 0 1 -.16.37.54.54 0 0 1 -.38.15h-10.17a.56.56 0 0 1 -.38-.19.57.57 0 0 1 -.14-.38.33.33 0 0 1 0-.1zm.92 5.09a1 1 0 1 1 1-1 1 1 0 0 1 -.3.7 1 1 0 0 1 -.7.3zm9.36 0a1 1 0 1 1 1-1 1 1 0 0 1 -.3.7 1.06 1.06 0 0 1 -.72.29z'
|
|
8
|
-
fill='#1c1e23'
|
|
9
|
-
/>
|
|
10
|
-
</>
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
export const viewBox = '0 0 24 24';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export const name = 'mbta';
|
|
2
|
-
|
|
3
|
-
export const Component = () => (
|
|
4
|
-
<>
|
|
5
|
-
<circle cx='250' cy='250' r='239' stroke='#000' strokeWidth='22' fill='#fff' />
|
|
6
|
-
<path d='M92,138.5h316v79.5h-118.25v194h-79.5v-194h-118.25z' />
|
|
7
|
-
</>
|
|
8
|
-
);
|
|
9
|
-
|
|
10
|
-
export const viewBox = '0 0 500 500';
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export const name = 'subway';
|
|
2
|
-
|
|
3
|
-
export const Component = () => (
|
|
4
|
-
<>
|
|
5
|
-
<path d='m24 0a24 24 0 1 0 24 24 24 24 0 0 0 -24-24' fill='#494f5b' />
|
|
6
|
-
<g fill='#fff'>
|
|
7
|
-
<path d='m25.8889 5.8222a1.4111 1.4111 0 1 0 -1.4111-1.4111 1.411 1.411 0 0 0 1.4111 1.4111z' />
|
|
8
|
-
<path d='m31.4555 34.2111a4.9779 4.9779 0 0 0 3.889-4.8222v-18.1445a5.0112 5.0112 0 0 0 -5.0778-4.9111h-12.5333a5.0112 5.0112 0 0 0 -5.1 4.9v18.1556a4.9779 4.9779 0 0 0 3.8889 4.8222l-5.8556 8.7889h3.4l4.1889-6.1445h11.5555l4.1889 6.1445h3.3333zm-10.7555-25.9889a.8445.8445 0 0 1 .8445-.8111h4.9555a.8444.8444 0 0 1 .8333.8111v1.4445l-.0006.0339a.8334.8334 0 0 1 -.866.7994l-4.9222-.0111a.8333.8333 0 0 1 -.8445-.8222zm-3.1111 23.3334a2.2223 2.2223 0 1 1 2.2222-2.2223 2.2223 2.2223 0 0 1 -2.2222 2.2223zm.2889-11.8112c-.0758.0036-.1518.0036-.2276 0a2.4221 2.4221 0 0 1 -2.3057-2.5333v-3.2667a2.4109 2.4109 0 0 1 2.5333-2.5444h12.2222a2.4113 2.4113 0 0 1 2.5333 2.5444v3.2667q.0054.1137 0 .2276a2.4221 2.4221 0 0 1 -2.5333 2.3057zm12.4333 11.8112a2.2334 2.2334 0 1 1 .0223 0z' />
|
|
9
|
-
<path d='m22.1445 5.8222h-.0334.0337a1.4113 1.4113 0 1 0 -1.4115-1.4115 1.4111 1.4111 0 0 0 1.4115 1.4119z' />
|
|
10
|
-
</g>
|
|
11
|
-
</>
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
export const viewBox = '0 0 48 48';
|