@backstage/plugin-scaffolder-react 1.8.4-next.1 → 1.8.5-next.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.
- package/CHANGELOG.md +42 -0
- package/alpha/package.json +1 -1
- package/dist/alpha.esm.js +19 -1451
- package/dist/alpha.esm.js.map +1 -1
- package/dist/api/ref.esm.js +12 -0
- package/dist/api/ref.esm.js.map +1 -0
- package/dist/extensions/index.esm.js +25 -0
- package/dist/extensions/index.esm.js.map +1 -0
- package/dist/extensions/keys.esm.js +5 -0
- package/dist/extensions/keys.esm.js.map +1 -0
- package/dist/hooks/useCustomFieldExtensions.esm.js +16 -0
- package/dist/hooks/useCustomFieldExtensions.esm.js.map +1 -0
- package/dist/hooks/useCustomLayouts.esm.js +16 -0
- package/dist/hooks/useCustomLayouts.esm.js.map +1 -0
- package/dist/hooks/useEventStream.esm.js +167 -0
- package/dist/hooks/useEventStream.esm.js.map +1 -0
- package/dist/index.esm.js +7 -228
- package/dist/index.esm.js.map +1 -1
- package/dist/layouts/createScaffolderLayout.esm.js +17 -0
- package/dist/layouts/createScaffolderLayout.esm.js.map +1 -0
- package/dist/layouts/keys.esm.js +5 -0
- package/dist/layouts/keys.esm.js.map +1 -0
- package/dist/next/components/Form/DescriptionFieldTemplate.esm.js +37 -0
- package/dist/next/components/Form/DescriptionFieldTemplate.esm.js.map +1 -0
- package/dist/next/components/Form/FieldTemplate.esm.js +65 -0
- package/dist/next/components/Form/FieldTemplate.esm.js.map +1 -0
- package/dist/next/components/Form/Form.esm.js +44 -0
- package/dist/next/components/Form/Form.esm.js.map +1 -0
- package/dist/next/components/ReviewState/ReviewState.esm.js +43 -0
- package/dist/next/components/ReviewState/ReviewState.esm.js.map +1 -0
- package/dist/next/components/ScaffolderField/ScaffolderField.esm.js +52 -0
- package/dist/next/components/ScaffolderField/ScaffolderField.esm.js.map +1 -0
- package/dist/next/components/ScaffolderPageContextMenu/ScaffolderPageContextMenu.esm.js +63 -0
- package/dist/next/components/ScaffolderPageContextMenu/ScaffolderPageContextMenu.esm.js.map +1 -0
- package/dist/next/components/Stepper/ErrorListTemplate/errorListTemplate.esm.js +32 -0
- package/dist/next/components/Stepper/ErrorListTemplate/errorListTemplate.esm.js.map +1 -0
- package/dist/next/components/Stepper/FieldOverrides/DescriptionField.esm.js +7 -0
- package/dist/next/components/Stepper/FieldOverrides/DescriptionField.esm.js.map +1 -0
- package/dist/next/components/Stepper/FieldOverrides/index.esm.js +2 -0
- package/dist/next/components/Stepper/FieldOverrides/index.esm.js.map +1 -0
- package/dist/next/components/Stepper/Stepper.esm.js +203 -0
- package/dist/next/components/Stepper/Stepper.esm.js.map +1 -0
- package/dist/next/components/Stepper/createAsyncValidators.esm.js +80 -0
- package/dist/next/components/Stepper/createAsyncValidators.esm.js.map +1 -0
- package/dist/next/components/Stepper/utils.esm.js +27 -0
- package/dist/next/components/Stepper/utils.esm.js.map +1 -0
- package/dist/next/components/TaskLogStream/TaskLogStream.esm.js +23 -0
- package/dist/next/components/TaskLogStream/TaskLogStream.esm.js.map +1 -0
- package/dist/next/components/TaskSteps/StepIcon.esm.js +52 -0
- package/dist/next/components/TaskSteps/StepIcon.esm.js.map +1 -0
- package/dist/next/components/TaskSteps/StepTime.esm.js +36 -0
- package/dist/next/components/TaskSteps/StepTime.esm.js.map +1 -0
- package/dist/next/components/TaskSteps/TaskBorder.esm.js +29 -0
- package/dist/next/components/TaskSteps/TaskBorder.esm.js.map +1 -0
- package/dist/next/components/TaskSteps/TaskSteps.esm.js +54 -0
- package/dist/next/components/TaskSteps/TaskSteps.esm.js.map +1 -0
- package/dist/next/components/TemplateCard/CardHeader.esm.js +41 -0
- package/dist/next/components/TemplateCard/CardHeader.esm.js.map +1 -0
- package/dist/next/components/TemplateCard/CardLink.esm.js +17 -0
- package/dist/next/components/TemplateCard/CardLink.esm.js.map +1 -0
- package/dist/next/components/TemplateCard/TemplateCard.esm.js +114 -0
- package/dist/next/components/TemplateCard/TemplateCard.esm.js.map +1 -0
- package/dist/next/components/TemplateCategoryPicker/TemplateCategoryPicker.esm.js +80 -0
- package/dist/next/components/TemplateCategoryPicker/TemplateCategoryPicker.esm.js.map +1 -0
- package/dist/next/components/TemplateGroup/TemplateGroup.esm.js +30 -0
- package/dist/next/components/TemplateGroup/TemplateGroup.esm.js.map +1 -0
- package/dist/next/components/TemplateGroups/TemplateGroups.esm.js +52 -0
- package/dist/next/components/TemplateGroups/TemplateGroups.esm.js.map +1 -0
- package/dist/next/components/TemplateOutputs/DefaultTemplateOutputs.esm.js +51 -0
- package/dist/next/components/TemplateOutputs/DefaultTemplateOutputs.esm.js.map +1 -0
- package/dist/next/components/TemplateOutputs/LinkOutputs.esm.js +40 -0
- package/dist/next/components/TemplateOutputs/LinkOutputs.esm.js.map +1 -0
- package/dist/next/components/TemplateOutputs/TextOutputs.esm.js +39 -0
- package/dist/next/components/TemplateOutputs/TextOutputs.esm.js.map +1 -0
- package/dist/next/components/Workflow/Workflow.esm.js +83 -0
- package/dist/next/components/Workflow/Workflow.esm.js.map +1 -0
- package/dist/next/hooks/useFilteredSchemaProperties.esm.js +44 -0
- package/dist/next/hooks/useFilteredSchemaProperties.esm.js.map +1 -0
- package/dist/next/hooks/useFormDataFromQuery.esm.js +21 -0
- package/dist/next/hooks/useFormDataFromQuery.esm.js.map +1 -0
- package/dist/next/hooks/useTemplateParameterSchema.esm.js +19 -0
- package/dist/next/hooks/useTemplateParameterSchema.esm.js.map +1 -0
- package/dist/next/hooks/useTemplateSchema.esm.js +46 -0
- package/dist/next/hooks/useTemplateSchema.esm.js.map +1 -0
- package/dist/next/hooks/useTemplateTimeSaved.esm.js +25 -0
- package/dist/next/hooks/useTemplateTimeSaved.esm.js.map +1 -0
- package/dist/next/hooks/useTransformSchemaToProps.esm.js +24 -0
- package/dist/next/hooks/useTransformSchemaToProps.esm.js.map +1 -0
- package/dist/next/lib/schema.esm.js +108 -0
- package/dist/next/lib/schema.esm.js.map +1 -0
- package/dist/{esm/ref-NRtFlQHB.esm.js → secrets/SecretsContext.esm.js} +3 -11
- package/dist/secrets/SecretsContext.esm.js.map +1 -0
- package/package.json +20 -20
- package/dist/esm/ref-NRtFlQHB.esm.js.map +0 -1
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { useImmerReducer } from 'use-immer';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { useApi } from '@backstage/core-plugin-api';
|
|
4
|
+
import { scaffolderApiRef } from '../api/ref.esm.js';
|
|
5
|
+
|
|
6
|
+
function reducer(draft, action) {
|
|
7
|
+
var _a, _b, _c;
|
|
8
|
+
switch (action.type) {
|
|
9
|
+
case "INIT": {
|
|
10
|
+
draft.steps = action.data.spec.steps.reduce((current, next) => {
|
|
11
|
+
current[next.id] = { status: "open", id: next.id };
|
|
12
|
+
return current;
|
|
13
|
+
}, {});
|
|
14
|
+
draft.stepLogs = action.data.spec.steps.reduce((current, next) => {
|
|
15
|
+
current[next.id] = [];
|
|
16
|
+
return current;
|
|
17
|
+
}, {});
|
|
18
|
+
draft.loading = false;
|
|
19
|
+
draft.error = void 0;
|
|
20
|
+
draft.completed = false;
|
|
21
|
+
draft.task = action.data;
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
case "LOGS": {
|
|
25
|
+
const entries = action.data;
|
|
26
|
+
for (const entry of entries) {
|
|
27
|
+
const logLine = `${entry.createdAt} ${entry.body.message}`;
|
|
28
|
+
if (!entry.body.stepId || !((_a = draft.steps) == null ? void 0 : _a[entry.body.stepId])) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const currentStepLog = (_b = draft.stepLogs) == null ? void 0 : _b[entry.body.stepId];
|
|
32
|
+
const currentStep = (_c = draft.steps) == null ? void 0 : _c[entry.body.stepId];
|
|
33
|
+
if (currentStep) {
|
|
34
|
+
if (entry.body.status && entry.body.status !== currentStep.status) {
|
|
35
|
+
currentStep.status = entry.body.status;
|
|
36
|
+
if (currentStep.status === "processing") {
|
|
37
|
+
currentStep.startedAt = entry.createdAt;
|
|
38
|
+
}
|
|
39
|
+
if (["cancelled", "completed", "failed"].includes(currentStep.status)) {
|
|
40
|
+
currentStep.endedAt = entry.createdAt;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
currentStepLog == null ? void 0 : currentStepLog.push(logLine);
|
|
45
|
+
}
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
case "COMPLETED": {
|
|
49
|
+
draft.completed = true;
|
|
50
|
+
draft.output = action.data.body.output;
|
|
51
|
+
draft.error = action.data.body.error;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
case "CANCELLED": {
|
|
55
|
+
draft.cancelled = true;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
case "RECOVERED": {
|
|
59
|
+
for (const stepId in draft.steps) {
|
|
60
|
+
if (draft.steps.hasOwnProperty(stepId)) {
|
|
61
|
+
draft.steps[stepId].startedAt = void 0;
|
|
62
|
+
draft.steps[stepId].endedAt = void 0;
|
|
63
|
+
draft.steps[stepId].status = "open";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
case "ERROR": {
|
|
69
|
+
draft.error = action.data;
|
|
70
|
+
draft.loading = false;
|
|
71
|
+
draft.completed = true;
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
default:
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const useTaskEventStream = (taskId) => {
|
|
79
|
+
const scaffolderApi = useApi(scaffolderApiRef);
|
|
80
|
+
const [state, dispatch] = useImmerReducer(reducer, {
|
|
81
|
+
cancelled: false,
|
|
82
|
+
loading: true,
|
|
83
|
+
completed: false,
|
|
84
|
+
stepLogs: {},
|
|
85
|
+
steps: {}
|
|
86
|
+
});
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
let didCancel = false;
|
|
89
|
+
let subscription;
|
|
90
|
+
let logPusher;
|
|
91
|
+
let retryCount = 1;
|
|
92
|
+
const startStreamLogProcess = () => scaffolderApi.getTask(taskId).then(
|
|
93
|
+
(task) => {
|
|
94
|
+
if (didCancel) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
dispatch({ type: "INIT", data: task });
|
|
98
|
+
const observable = scaffolderApi.streamLogs({ taskId });
|
|
99
|
+
const collectedLogEvents = new Array();
|
|
100
|
+
function emitLogs() {
|
|
101
|
+
if (collectedLogEvents.length) {
|
|
102
|
+
const logs = collectedLogEvents.splice(
|
|
103
|
+
0,
|
|
104
|
+
collectedLogEvents.length
|
|
105
|
+
);
|
|
106
|
+
dispatch({ type: "LOGS", data: logs });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
logPusher = setInterval(emitLogs, 500);
|
|
110
|
+
subscription = observable.subscribe({
|
|
111
|
+
next: (event) => {
|
|
112
|
+
retryCount = 1;
|
|
113
|
+
switch (event.type) {
|
|
114
|
+
case "log":
|
|
115
|
+
return collectedLogEvents.push(event);
|
|
116
|
+
case "cancelled":
|
|
117
|
+
dispatch({ type: "CANCELLED" });
|
|
118
|
+
return void 0;
|
|
119
|
+
case "completion":
|
|
120
|
+
emitLogs();
|
|
121
|
+
dispatch({ type: "COMPLETED", data: event });
|
|
122
|
+
return void 0;
|
|
123
|
+
case "recovered":
|
|
124
|
+
dispatch({ type: "RECOVERED", data: event });
|
|
125
|
+
return void 0;
|
|
126
|
+
default:
|
|
127
|
+
throw new Error(
|
|
128
|
+
`Unhandled event type ${event.type} in observer`
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
error: (error) => {
|
|
133
|
+
emitLogs();
|
|
134
|
+
const maxRetries = 3;
|
|
135
|
+
if (!error.message) {
|
|
136
|
+
error.message = `We cannot connect at the moment, trying again in some seconds... Retrying (${retryCount > maxRetries ? maxRetries : retryCount}/${maxRetries} retries)`;
|
|
137
|
+
}
|
|
138
|
+
setTimeout(() => {
|
|
139
|
+
retryCount += 1;
|
|
140
|
+
void startStreamLogProcess();
|
|
141
|
+
}, 15e3);
|
|
142
|
+
dispatch({ type: "ERROR", data: error });
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
},
|
|
146
|
+
(error) => {
|
|
147
|
+
if (!didCancel) {
|
|
148
|
+
dispatch({ type: "ERROR", data: error });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
void startStreamLogProcess();
|
|
153
|
+
return () => {
|
|
154
|
+
didCancel = true;
|
|
155
|
+
if (subscription) {
|
|
156
|
+
subscription.unsubscribe();
|
|
157
|
+
}
|
|
158
|
+
if (logPusher) {
|
|
159
|
+
clearInterval(logPusher);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}, [scaffolderApi, dispatch, taskId]);
|
|
163
|
+
return state;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export { useTaskEventStream };
|
|
167
|
+
//# sourceMappingURL=useEventStream.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEventStream.esm.js","sources":["../../src/hooks/useEventStream.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useImmerReducer } from 'use-immer';\nimport { useEffect } from 'react';\n\nimport { useApi } from '@backstage/core-plugin-api';\nimport { Subscription } from '@backstage/types';\nimport {\n LogEvent,\n scaffolderApiRef,\n ScaffolderTask,\n ScaffolderTaskOutput,\n ScaffolderTaskStatus,\n} from '../api';\n\n/**\n * The status of the step being processed\n *\n * @public\n */\nexport type ScaffolderStep = {\n id: string;\n status: ScaffolderTaskStatus;\n endedAt?: string;\n startedAt?: string;\n};\n\n/**\n * A task event from the event stream\n *\n * @public\n */\nexport type TaskStream = {\n cancelled: boolean;\n loading: boolean;\n error?: Error;\n stepLogs: { [stepId in string]: string[] };\n completed: boolean;\n task?: ScaffolderTask;\n steps: { [stepId in string]: ScaffolderStep };\n output?: ScaffolderTaskOutput;\n};\n\ntype ReducerLogEntry = {\n createdAt: string;\n body: {\n stepId?: string;\n status?: ScaffolderTaskStatus;\n message: string;\n output?: ScaffolderTaskOutput;\n error?: Error;\n recoverStrategy?: 'none' | 'startOver';\n };\n};\n\ntype ReducerAction =\n | { type: 'INIT'; data: ScaffolderTask }\n | { type: 'CANCELLED' }\n | { type: 'RECOVERED'; data: ReducerLogEntry }\n | { type: 'LOGS'; data: ReducerLogEntry[] }\n | { type: 'COMPLETED'; data: ReducerLogEntry }\n | { type: 'ERROR'; data: Error };\n\nfunction reducer(draft: TaskStream, action: ReducerAction) {\n switch (action.type) {\n case 'INIT': {\n draft.steps = action.data.spec.steps.reduce((current, next) => {\n current[next.id] = { status: 'open', id: next.id };\n return current;\n }, {} as { [stepId in string]: ScaffolderStep });\n draft.stepLogs = action.data.spec.steps.reduce((current, next) => {\n current[next.id] = [];\n return current;\n }, {} as { [stepId in string]: string[] });\n draft.loading = false;\n draft.error = undefined;\n draft.completed = false;\n draft.task = action.data;\n return;\n }\n\n case 'LOGS': {\n const entries = action.data;\n const logLines = [];\n\n for (const entry of entries) {\n const logLine = `${entry.createdAt} ${entry.body.message}`;\n logLines.push(logLine);\n\n if (!entry.body.stepId || !draft.steps?.[entry.body.stepId]) {\n continue;\n }\n\n const currentStepLog = draft.stepLogs?.[entry.body.stepId];\n const currentStep = draft.steps?.[entry.body.stepId];\n\n if (currentStep) {\n if (entry.body.status && entry.body.status !== currentStep.status) {\n currentStep.status = entry.body.status;\n\n if (currentStep.status === 'processing') {\n currentStep.startedAt = entry.createdAt;\n }\n\n if (\n ['cancelled', 'completed', 'failed'].includes(currentStep.status)\n ) {\n currentStep.endedAt = entry.createdAt;\n }\n }\n }\n\n currentStepLog?.push(logLine);\n }\n\n return;\n }\n\n case 'COMPLETED': {\n draft.completed = true;\n draft.output = action.data.body.output;\n draft.error = action.data.body.error;\n\n return;\n }\n\n case 'CANCELLED': {\n draft.cancelled = true;\n return;\n }\n\n case 'RECOVERED': {\n for (const stepId in draft.steps) {\n if (draft.steps.hasOwnProperty(stepId)) {\n draft.steps[stepId].startedAt = undefined;\n draft.steps[stepId].endedAt = undefined;\n draft.steps[stepId].status = 'open';\n }\n }\n return;\n }\n\n case 'ERROR': {\n draft.error = action.data;\n draft.loading = false;\n draft.completed = true;\n return;\n }\n\n default:\n return;\n }\n}\n\n/**\n * A hook to stream the logs of a task being processed\n *\n * @public\n */\nexport const useTaskEventStream = (taskId: string): TaskStream => {\n const scaffolderApi = useApi(scaffolderApiRef);\n const [state, dispatch] = useImmerReducer(reducer, {\n cancelled: false,\n loading: true,\n completed: false,\n stepLogs: {} as { [stepId in string]: string[] },\n steps: {} as { [stepId in string]: ScaffolderStep },\n });\n\n useEffect(() => {\n let didCancel = false;\n let subscription: Subscription | undefined;\n let logPusher: NodeJS.Timeout | undefined;\n let retryCount = 1;\n const startStreamLogProcess = () =>\n scaffolderApi.getTask(taskId).then(\n task => {\n if (didCancel) {\n return;\n }\n dispatch({ type: 'INIT', data: task });\n\n // TODO(blam): Use a normal fetch to fetch the current log for the event stream\n // and use that for an INIT_EVENTs dispatch event, and then\n // use the last event ID to subscribe using after option to\n // stream logs. Without this, if you have a lot of logs, it can look like the\n // task is being rebuilt on load as it progresses through the steps at a slower\n // rate whilst it builds the status from the event logs\n const observable = scaffolderApi.streamLogs({ taskId });\n\n const collectedLogEvents = new Array<LogEvent>();\n\n function emitLogs() {\n if (collectedLogEvents.length) {\n const logs = collectedLogEvents.splice(\n 0,\n collectedLogEvents.length,\n );\n dispatch({ type: 'LOGS', data: logs });\n }\n }\n\n logPusher = setInterval(emitLogs, 500);\n\n subscription = observable.subscribe({\n next: event => {\n retryCount = 1;\n switch (event.type) {\n case 'log':\n return collectedLogEvents.push(event);\n case 'cancelled':\n dispatch({ type: 'CANCELLED' });\n return undefined;\n case 'completion':\n emitLogs();\n dispatch({ type: 'COMPLETED', data: event });\n return undefined;\n case 'recovered':\n dispatch({ type: 'RECOVERED', data: event });\n return undefined;\n default:\n throw new Error(\n `Unhandled event type ${event.type} in observer`,\n );\n }\n },\n error: error => {\n emitLogs();\n // in some cases the error is a refused connection from backend\n // this can happen from internet issues or proxy problems\n // so we try to reconnect again after some time\n // just to restart the fetch process\n // details here https://github.com/backstage/backstage/issues/15002\n\n const maxRetries = 3;\n\n if (!error.message) {\n error.message = `We cannot connect at the moment, trying again in some seconds... Retrying (${\n retryCount > maxRetries ? maxRetries : retryCount\n }/${maxRetries} retries)`;\n }\n\n setTimeout(() => {\n retryCount += 1;\n void startStreamLogProcess();\n }, 15000);\n\n dispatch({ type: 'ERROR', data: error });\n },\n });\n },\n error => {\n if (!didCancel) {\n dispatch({ type: 'ERROR', data: error });\n }\n },\n );\n void startStreamLogProcess();\n return () => {\n didCancel = true;\n if (subscription) {\n subscription.unsubscribe();\n }\n if (logPusher) {\n clearInterval(logPusher);\n }\n };\n }, [scaffolderApi, dispatch, taskId]);\n\n return state;\n};\n"],"names":[],"mappings":";;;;;AA4EA,SAAS,OAAA,CAAQ,OAAmB,MAAuB,EAAA;AA5E3D,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AA6EE,EAAA,QAAQ,OAAO,IAAM;AAAA,IACnB,KAAK,MAAQ,EAAA;AACX,MAAM,KAAA,CAAA,KAAA,GAAQ,OAAO,IAAK,CAAA,IAAA,CAAK,MAAM,MAAO,CAAA,CAAC,SAAS,IAAS,KAAA;AAC7D,QAAQ,OAAA,CAAA,IAAA,CAAK,EAAE,CAAI,GAAA,EAAE,QAAQ,MAAQ,EAAA,EAAA,EAAI,KAAK,EAAG,EAA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,EAAA,QAAA,EAAU,MAAM,CAAC,CAAA,CAAA;AAEpC,EAAO,OAAA,KAAA,CAAA;AACT;;;;"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,229 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const FIELD_EXTENSION_WRAPPER_KEY = "scaffolder.extensions.wrapper.v1";
|
|
9
|
-
const FIELD_EXTENSION_KEY = "scaffolder.extensions.field.v1";
|
|
10
|
-
|
|
11
|
-
function createScaffolderFieldExtension(options) {
|
|
12
|
-
return {
|
|
13
|
-
expose() {
|
|
14
|
-
const FieldExtensionDataHolder = () => null;
|
|
15
|
-
attachComponentData(
|
|
16
|
-
FieldExtensionDataHolder,
|
|
17
|
-
FIELD_EXTENSION_KEY,
|
|
18
|
-
options
|
|
19
|
-
);
|
|
20
|
-
return FieldExtensionDataHolder;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
const ScaffolderFieldExtensions = () => null;
|
|
25
|
-
attachComponentData(
|
|
26
|
-
ScaffolderFieldExtensions,
|
|
27
|
-
FIELD_EXTENSION_WRAPPER_KEY,
|
|
28
|
-
true
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
const useCustomFieldExtensions = (outlet) => {
|
|
32
|
-
return useElementFilter(
|
|
33
|
-
outlet,
|
|
34
|
-
(elements) => elements.selectByComponentData({
|
|
35
|
-
key: FIELD_EXTENSION_WRAPPER_KEY
|
|
36
|
-
}).findComponentData({
|
|
37
|
-
key: FIELD_EXTENSION_KEY
|
|
38
|
-
})
|
|
39
|
-
);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const LAYOUTS_KEY = "scaffolder.layout.v1";
|
|
43
|
-
const LAYOUTS_WRAPPER_KEY = "scaffolder.layouts.wrapper.v1";
|
|
44
|
-
|
|
45
|
-
const useCustomLayouts = (outlet) => {
|
|
46
|
-
return useElementFilter(
|
|
47
|
-
outlet,
|
|
48
|
-
(elements) => elements.selectByComponentData({
|
|
49
|
-
key: LAYOUTS_WRAPPER_KEY
|
|
50
|
-
}).findComponentData({
|
|
51
|
-
key: LAYOUTS_KEY
|
|
52
|
-
})
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
function reducer(draft, action) {
|
|
57
|
-
var _a, _b, _c;
|
|
58
|
-
switch (action.type) {
|
|
59
|
-
case "INIT": {
|
|
60
|
-
draft.steps = action.data.spec.steps.reduce((current, next) => {
|
|
61
|
-
current[next.id] = { status: "open", id: next.id };
|
|
62
|
-
return current;
|
|
63
|
-
}, {});
|
|
64
|
-
draft.stepLogs = action.data.spec.steps.reduce((current, next) => {
|
|
65
|
-
current[next.id] = [];
|
|
66
|
-
return current;
|
|
67
|
-
}, {});
|
|
68
|
-
draft.loading = false;
|
|
69
|
-
draft.error = void 0;
|
|
70
|
-
draft.completed = false;
|
|
71
|
-
draft.task = action.data;
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
case "LOGS": {
|
|
75
|
-
const entries = action.data;
|
|
76
|
-
for (const entry of entries) {
|
|
77
|
-
const logLine = `${entry.createdAt} ${entry.body.message}`;
|
|
78
|
-
if (!entry.body.stepId || !((_a = draft.steps) == null ? void 0 : _a[entry.body.stepId])) {
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
const currentStepLog = (_b = draft.stepLogs) == null ? void 0 : _b[entry.body.stepId];
|
|
82
|
-
const currentStep = (_c = draft.steps) == null ? void 0 : _c[entry.body.stepId];
|
|
83
|
-
if (currentStep) {
|
|
84
|
-
if (entry.body.status && entry.body.status !== currentStep.status) {
|
|
85
|
-
currentStep.status = entry.body.status;
|
|
86
|
-
if (currentStep.status === "processing") {
|
|
87
|
-
currentStep.startedAt = entry.createdAt;
|
|
88
|
-
}
|
|
89
|
-
if (["cancelled", "completed", "failed"].includes(currentStep.status)) {
|
|
90
|
-
currentStep.endedAt = entry.createdAt;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
currentStepLog == null ? void 0 : currentStepLog.push(logLine);
|
|
95
|
-
}
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
case "COMPLETED": {
|
|
99
|
-
draft.completed = true;
|
|
100
|
-
draft.output = action.data.body.output;
|
|
101
|
-
draft.error = action.data.body.error;
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
case "CANCELLED": {
|
|
105
|
-
draft.cancelled = true;
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
case "RECOVERED": {
|
|
109
|
-
for (const stepId in draft.steps) {
|
|
110
|
-
if (draft.steps.hasOwnProperty(stepId)) {
|
|
111
|
-
draft.steps[stepId].startedAt = void 0;
|
|
112
|
-
draft.steps[stepId].endedAt = void 0;
|
|
113
|
-
draft.steps[stepId].status = "open";
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
case "ERROR": {
|
|
119
|
-
draft.error = action.data;
|
|
120
|
-
draft.loading = false;
|
|
121
|
-
draft.completed = true;
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
default:
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
const useTaskEventStream = (taskId) => {
|
|
129
|
-
const scaffolderApi = useApi(scaffolderApiRef);
|
|
130
|
-
const [state, dispatch] = useImmerReducer(reducer, {
|
|
131
|
-
cancelled: false,
|
|
132
|
-
loading: true,
|
|
133
|
-
completed: false,
|
|
134
|
-
stepLogs: {},
|
|
135
|
-
steps: {}
|
|
136
|
-
});
|
|
137
|
-
useEffect(() => {
|
|
138
|
-
let didCancel = false;
|
|
139
|
-
let subscription;
|
|
140
|
-
let logPusher;
|
|
141
|
-
let retryCount = 1;
|
|
142
|
-
const startStreamLogProcess = () => scaffolderApi.getTask(taskId).then(
|
|
143
|
-
(task) => {
|
|
144
|
-
if (didCancel) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
dispatch({ type: "INIT", data: task });
|
|
148
|
-
const observable = scaffolderApi.streamLogs({ taskId });
|
|
149
|
-
const collectedLogEvents = new Array();
|
|
150
|
-
function emitLogs() {
|
|
151
|
-
if (collectedLogEvents.length) {
|
|
152
|
-
const logs = collectedLogEvents.splice(
|
|
153
|
-
0,
|
|
154
|
-
collectedLogEvents.length
|
|
155
|
-
);
|
|
156
|
-
dispatch({ type: "LOGS", data: logs });
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
logPusher = setInterval(emitLogs, 500);
|
|
160
|
-
subscription = observable.subscribe({
|
|
161
|
-
next: (event) => {
|
|
162
|
-
retryCount = 1;
|
|
163
|
-
switch (event.type) {
|
|
164
|
-
case "log":
|
|
165
|
-
return collectedLogEvents.push(event);
|
|
166
|
-
case "cancelled":
|
|
167
|
-
dispatch({ type: "CANCELLED" });
|
|
168
|
-
return void 0;
|
|
169
|
-
case "completion":
|
|
170
|
-
emitLogs();
|
|
171
|
-
dispatch({ type: "COMPLETED", data: event });
|
|
172
|
-
return void 0;
|
|
173
|
-
case "recovered":
|
|
174
|
-
dispatch({ type: "RECOVERED", data: event });
|
|
175
|
-
return void 0;
|
|
176
|
-
default:
|
|
177
|
-
throw new Error(
|
|
178
|
-
`Unhandled event type ${event.type} in observer`
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
error: (error) => {
|
|
183
|
-
emitLogs();
|
|
184
|
-
const maxRetries = 3;
|
|
185
|
-
if (!error.message) {
|
|
186
|
-
error.message = `We cannot connect at the moment, trying again in some seconds... Retrying (${retryCount > maxRetries ? maxRetries : retryCount}/${maxRetries} retries)`;
|
|
187
|
-
}
|
|
188
|
-
setTimeout(() => {
|
|
189
|
-
retryCount += 1;
|
|
190
|
-
void startStreamLogProcess();
|
|
191
|
-
}, 15e3);
|
|
192
|
-
dispatch({ type: "ERROR", data: error });
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
},
|
|
196
|
-
(error) => {
|
|
197
|
-
if (!didCancel) {
|
|
198
|
-
dispatch({ type: "ERROR", data: error });
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
);
|
|
202
|
-
void startStreamLogProcess();
|
|
203
|
-
return () => {
|
|
204
|
-
didCancel = true;
|
|
205
|
-
if (subscription) {
|
|
206
|
-
subscription.unsubscribe();
|
|
207
|
-
}
|
|
208
|
-
if (logPusher) {
|
|
209
|
-
clearInterval(logPusher);
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
}, [scaffolderApi, dispatch, taskId]);
|
|
213
|
-
return state;
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
function createScaffolderLayout(options) {
|
|
217
|
-
return {
|
|
218
|
-
expose() {
|
|
219
|
-
const LayoutDataHolder = () => null;
|
|
220
|
-
attachComponentData(LayoutDataHolder, LAYOUTS_KEY, options);
|
|
221
|
-
return LayoutDataHolder;
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
const ScaffolderLayouts = () => null;
|
|
226
|
-
attachComponentData(ScaffolderLayouts, LAYOUTS_WRAPPER_KEY, true);
|
|
227
|
-
|
|
228
|
-
export { ScaffolderFieldExtensions, ScaffolderLayouts, createScaffolderFieldExtension, createScaffolderLayout, scaffolderApiRef, useCustomFieldExtensions, useCustomLayouts, useTaskEventStream };
|
|
1
|
+
export { ScaffolderFieldExtensions, createScaffolderFieldExtension } from './extensions/index.esm.js';
|
|
2
|
+
export { SecretsContextProvider, useTemplateSecrets } from './secrets/SecretsContext.esm.js';
|
|
3
|
+
export { scaffolderApiRef } from './api/ref.esm.js';
|
|
4
|
+
export { useCustomFieldExtensions } from './hooks/useCustomFieldExtensions.esm.js';
|
|
5
|
+
export { useCustomLayouts } from './hooks/useCustomLayouts.esm.js';
|
|
6
|
+
export { useTaskEventStream } from './hooks/useEventStream.esm.js';
|
|
7
|
+
export { ScaffolderLayouts, createScaffolderLayout } from './layouts/createScaffolderLayout.esm.js';
|
|
229
8
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/extensions/keys.ts","../src/extensions/index.tsx","../src/hooks/useCustomFieldExtensions.ts","../src/layouts/keys.ts","../src/hooks/useCustomLayouts.ts","../src/hooks/useEventStream.ts","../src/layouts/createScaffolderLayout.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const FIELD_EXTENSION_WRAPPER_KEY = 'scaffolder.extensions.wrapper.v1';\n/**\n * The key used to store the field extension data for any `<FieldExtension />` component\n */\nexport const FIELD_EXTENSION_KEY = 'scaffolder.extensions.field.v1';\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n CustomFieldValidator,\n FieldExtensionOptions,\n FieldExtensionComponentProps,\n FieldExtensionUiSchema,\n CustomFieldExtensionSchema,\n} from './types';\nimport { Extension, attachComponentData } from '@backstage/core-plugin-api';\nimport { UIOptionsType } from '@rjsf/utils';\nimport { FIELD_EXTENSION_KEY, FIELD_EXTENSION_WRAPPER_KEY } from './keys';\n\n/**\n * Method for creating field extensions that can be used in the scaffolder\n * frontend form.\n * @public\n */\nexport function createScaffolderFieldExtension<\n TReturnValue = unknown,\n TInputProps extends UIOptionsType = {},\n>(\n options: FieldExtensionOptions<TReturnValue, TInputProps>,\n): Extension<FieldExtensionComponent<TReturnValue, TInputProps>> {\n return {\n expose() {\n const FieldExtensionDataHolder: any = () => null;\n\n attachComponentData(\n FieldExtensionDataHolder,\n FIELD_EXTENSION_KEY,\n options,\n );\n\n return FieldExtensionDataHolder;\n },\n };\n}\n\n/**\n * The Wrapping component for defining fields extensions inside\n *\n * @public\n */\nexport const ScaffolderFieldExtensions: React.ComponentType<\n React.PropsWithChildren<{}>\n> = (): JSX.Element | null => null;\n\nattachComponentData(\n ScaffolderFieldExtensions,\n FIELD_EXTENSION_WRAPPER_KEY,\n true,\n);\n\n/**\n * The type used to wrap up the Layout and embed the input props\n *\n * @public\n */\nexport type FieldExtensionComponent<_TReturnValue, _TInputProps> = () => null;\n\nexport type {\n CustomFieldValidator,\n FieldExtensionOptions,\n FieldExtensionComponentProps,\n FieldExtensionUiSchema,\n CustomFieldExtensionSchema,\n};\n\nexport * from './rjsf';\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useElementFilter } from '@backstage/core-plugin-api';\nimport { FieldExtensionOptions } from '../extensions';\nimport {\n FIELD_EXTENSION_KEY,\n FIELD_EXTENSION_WRAPPER_KEY,\n} from '../extensions/keys';\n\n/**\n * Hook that returns all custom field extensions from the current outlet.\n * @public\n */\nexport const useCustomFieldExtensions = <\n TComponentDataType = FieldExtensionOptions,\n>(\n outlet: React.ReactNode,\n) => {\n return useElementFilter(outlet, elements =>\n elements\n .selectByComponentData({\n key: FIELD_EXTENSION_WRAPPER_KEY,\n })\n .findComponentData<TComponentDataType>({\n key: FIELD_EXTENSION_KEY,\n }),\n );\n};\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport const LAYOUTS_KEY = 'scaffolder.layout.v1';\nexport const LAYOUTS_WRAPPER_KEY = 'scaffolder.layouts.wrapper.v1';\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useElementFilter } from '@backstage/core-plugin-api';\nimport { LAYOUTS_KEY, LAYOUTS_WRAPPER_KEY } from '../layouts/keys';\nimport { LayoutOptions } from '../layouts';\n\n/**\n * Hook that returns all custom field extensions from the current outlet.\n * @public\n */\nexport const useCustomLayouts = <TComponentDataType = LayoutOptions>(\n outlet: React.ReactNode,\n) => {\n return useElementFilter(outlet, elements =>\n elements\n .selectByComponentData({\n key: LAYOUTS_WRAPPER_KEY,\n })\n .findComponentData<TComponentDataType>({\n key: LAYOUTS_KEY,\n }),\n );\n};\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useImmerReducer } from 'use-immer';\nimport { useEffect } from 'react';\n\nimport { useApi } from '@backstage/core-plugin-api';\nimport { Subscription } from '@backstage/types';\nimport {\n LogEvent,\n scaffolderApiRef,\n ScaffolderTask,\n ScaffolderTaskOutput,\n ScaffolderTaskStatus,\n} from '../api';\n\n/**\n * The status of the step being processed\n *\n * @public\n */\nexport type ScaffolderStep = {\n id: string;\n status: ScaffolderTaskStatus;\n endedAt?: string;\n startedAt?: string;\n};\n\n/**\n * A task event from the event stream\n *\n * @public\n */\nexport type TaskStream = {\n cancelled: boolean;\n loading: boolean;\n error?: Error;\n stepLogs: { [stepId in string]: string[] };\n completed: boolean;\n task?: ScaffolderTask;\n steps: { [stepId in string]: ScaffolderStep };\n output?: ScaffolderTaskOutput;\n};\n\ntype ReducerLogEntry = {\n createdAt: string;\n body: {\n stepId?: string;\n status?: ScaffolderTaskStatus;\n message: string;\n output?: ScaffolderTaskOutput;\n error?: Error;\n recoverStrategy?: 'none' | 'startOver';\n };\n};\n\ntype ReducerAction =\n | { type: 'INIT'; data: ScaffolderTask }\n | { type: 'CANCELLED' }\n | { type: 'RECOVERED'; data: ReducerLogEntry }\n | { type: 'LOGS'; data: ReducerLogEntry[] }\n | { type: 'COMPLETED'; data: ReducerLogEntry }\n | { type: 'ERROR'; data: Error };\n\nfunction reducer(draft: TaskStream, action: ReducerAction) {\n switch (action.type) {\n case 'INIT': {\n draft.steps = action.data.spec.steps.reduce((current, next) => {\n current[next.id] = { status: 'open', id: next.id };\n return current;\n }, {} as { [stepId in string]: ScaffolderStep });\n draft.stepLogs = action.data.spec.steps.reduce((current, next) => {\n current[next.id] = [];\n return current;\n }, {} as { [stepId in string]: string[] });\n draft.loading = false;\n draft.error = undefined;\n draft.completed = false;\n draft.task = action.data;\n return;\n }\n\n case 'LOGS': {\n const entries = action.data;\n const logLines = [];\n\n for (const entry of entries) {\n const logLine = `${entry.createdAt} ${entry.body.message}`;\n logLines.push(logLine);\n\n if (!entry.body.stepId || !draft.steps?.[entry.body.stepId]) {\n continue;\n }\n\n const currentStepLog = draft.stepLogs?.[entry.body.stepId];\n const currentStep = draft.steps?.[entry.body.stepId];\n\n if (currentStep) {\n if (entry.body.status && entry.body.status !== currentStep.status) {\n currentStep.status = entry.body.status;\n\n if (currentStep.status === 'processing') {\n currentStep.startedAt = entry.createdAt;\n }\n\n if (\n ['cancelled', 'completed', 'failed'].includes(currentStep.status)\n ) {\n currentStep.endedAt = entry.createdAt;\n }\n }\n }\n\n currentStepLog?.push(logLine);\n }\n\n return;\n }\n\n case 'COMPLETED': {\n draft.completed = true;\n draft.output = action.data.body.output;\n draft.error = action.data.body.error;\n\n return;\n }\n\n case 'CANCELLED': {\n draft.cancelled = true;\n return;\n }\n\n case 'RECOVERED': {\n for (const stepId in draft.steps) {\n if (draft.steps.hasOwnProperty(stepId)) {\n draft.steps[stepId].startedAt = undefined;\n draft.steps[stepId].endedAt = undefined;\n draft.steps[stepId].status = 'open';\n }\n }\n return;\n }\n\n case 'ERROR': {\n draft.error = action.data;\n draft.loading = false;\n draft.completed = true;\n return;\n }\n\n default:\n return;\n }\n}\n\n/**\n * A hook to stream the logs of a task being processed\n *\n * @public\n */\nexport const useTaskEventStream = (taskId: string): TaskStream => {\n const scaffolderApi = useApi(scaffolderApiRef);\n const [state, dispatch] = useImmerReducer(reducer, {\n cancelled: false,\n loading: true,\n completed: false,\n stepLogs: {} as { [stepId in string]: string[] },\n steps: {} as { [stepId in string]: ScaffolderStep },\n });\n\n useEffect(() => {\n let didCancel = false;\n let subscription: Subscription | undefined;\n let logPusher: NodeJS.Timeout | undefined;\n let retryCount = 1;\n const startStreamLogProcess = () =>\n scaffolderApi.getTask(taskId).then(\n task => {\n if (didCancel) {\n return;\n }\n dispatch({ type: 'INIT', data: task });\n\n // TODO(blam): Use a normal fetch to fetch the current log for the event stream\n // and use that for an INIT_EVENTs dispatch event, and then\n // use the last event ID to subscribe using after option to\n // stream logs. Without this, if you have a lot of logs, it can look like the\n // task is being rebuilt on load as it progresses through the steps at a slower\n // rate whilst it builds the status from the event logs\n const observable = scaffolderApi.streamLogs({ taskId });\n\n const collectedLogEvents = new Array<LogEvent>();\n\n function emitLogs() {\n if (collectedLogEvents.length) {\n const logs = collectedLogEvents.splice(\n 0,\n collectedLogEvents.length,\n );\n dispatch({ type: 'LOGS', data: logs });\n }\n }\n\n logPusher = setInterval(emitLogs, 500);\n\n subscription = observable.subscribe({\n next: event => {\n retryCount = 1;\n switch (event.type) {\n case 'log':\n return collectedLogEvents.push(event);\n case 'cancelled':\n dispatch({ type: 'CANCELLED' });\n return undefined;\n case 'completion':\n emitLogs();\n dispatch({ type: 'COMPLETED', data: event });\n return undefined;\n case 'recovered':\n dispatch({ type: 'RECOVERED', data: event });\n return undefined;\n default:\n throw new Error(\n `Unhandled event type ${event.type} in observer`,\n );\n }\n },\n error: error => {\n emitLogs();\n // in some cases the error is a refused connection from backend\n // this can happen from internet issues or proxy problems\n // so we try to reconnect again after some time\n // just to restart the fetch process\n // details here https://github.com/backstage/backstage/issues/15002\n\n const maxRetries = 3;\n\n if (!error.message) {\n error.message = `We cannot connect at the moment, trying again in some seconds... Retrying (${\n retryCount > maxRetries ? maxRetries : retryCount\n }/${maxRetries} retries)`;\n }\n\n setTimeout(() => {\n retryCount += 1;\n void startStreamLogProcess();\n }, 15000);\n\n dispatch({ type: 'ERROR', data: error });\n },\n });\n },\n error => {\n if (!didCancel) {\n dispatch({ type: 'ERROR', data: error });\n }\n },\n );\n void startStreamLogProcess();\n return () => {\n didCancel = true;\n if (subscription) {\n subscription.unsubscribe();\n }\n if (logPusher) {\n clearInterval(logPusher);\n }\n };\n }, [scaffolderApi, dispatch, taskId]);\n\n return state;\n};\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { LAYOUTS_KEY, LAYOUTS_WRAPPER_KEY } from './keys';\nimport { attachComponentData, Extension } from '@backstage/core-plugin-api';\nimport type { FormProps as SchemaFormProps } from '@rjsf/core';\nimport React from 'react';\n\n/**\n * The field template from `@rjsf/core` which is a react component that gets passed `@rjsf/core` field related props.\n *\n * @public\n */\nexport type LayoutTemplate<T = any> = NonNullable<\n SchemaFormProps<T>['uiSchema']\n>['ui:ObjectFieldTemplate'];\n\n/**\n * The type of layouts that is passed to the TemplateForms\n *\n * @public\n */\nexport interface LayoutOptions<P = any> {\n name: string;\n component: LayoutTemplate<P>;\n}\n\n/**\n * A type used to wrap up the FieldExtension to embed the ReturnValue and the InputProps\n * @public\n */\nexport type LayoutComponent<_TInputProps> = () => null;\n\n/**\n * Method for creating custom Layouts that can be used in the scaffolder frontend form\n *\n * @public\n */\nexport function createScaffolderLayout<TInputProps = unknown>(\n options: LayoutOptions,\n): Extension<LayoutComponent<TInputProps>> {\n return {\n expose() {\n const LayoutDataHolder: any = () => null;\n\n attachComponentData(LayoutDataHolder, LAYOUTS_KEY, options);\n\n return LayoutDataHolder;\n },\n };\n}\n\n/**\n * The wrapping component for defining scaffolder layouts as children\n *\n * @public\n */\nexport const ScaffolderLayouts: React.ComponentType<\n React.PropsWithChildren<{}>\n> = (): JSX.Element | null => null;\n\nattachComponentData(ScaffolderLayouts, LAYOUTS_WRAPPER_KEY, true);\n"],"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AAO,MAAM;AACX,MAAY,SAAA,GAAA,IAAA,CAAA;AACZ,MAAA,IAAI,YAAc,EAAA;AAChB,QAAA,YAAA,CAAa,WAAY,EAAA,CAAA;AAAA,OAC3B;AACA,MAAA,IAAI,SAAW,EAAA;AACb,QAAA,aAAA,CAAc,SAAS,CAAA,CAAA;AAAA,OACzB;AAAA,KACF,CAAA;AAAA,GACC,EAAA,CAAC,aAAe,EAAA,QAAA,EAAU,MAAM,CAAC,CAAA,CAAA;AAEpC,EAAO,OAAA,KAAA,CAAA;AACT;;ACxOO,SAAS,uBACd,OACyC,EAAA;AACzC,EAAO,OAAA;AAAA,IACL,MAAS,GAAA;AACP,MAAA,MAAM,mBAAwB,MAAM,IAAA,CAAA;AAEpC,MAAoB,mBAAA,CAAA,gBAAA,EAAkB,aAAa,OAAO,CAAA,CAAA;AAE1D,MAAO,OAAA,gBAAA,CAAA;AAAA,KACT;AAAA,GACF,CAAA;AACF,CAAA;AAOO,MAAM,oBAET,MAA0B,KAAA;AAE9B,mBAAoB,CAAA,iBAAA,EAAmB,qBAAqB,IAAI,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LAYOUTS_WRAPPER_KEY, LAYOUTS_KEY } from './keys.esm.js';
|
|
2
|
+
import { attachComponentData } from '@backstage/core-plugin-api';
|
|
3
|
+
|
|
4
|
+
function createScaffolderLayout(options) {
|
|
5
|
+
return {
|
|
6
|
+
expose() {
|
|
7
|
+
const LayoutDataHolder = () => null;
|
|
8
|
+
attachComponentData(LayoutDataHolder, LAYOUTS_KEY, options);
|
|
9
|
+
return LayoutDataHolder;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const ScaffolderLayouts = () => null;
|
|
14
|
+
attachComponentData(ScaffolderLayouts, LAYOUTS_WRAPPER_KEY, true);
|
|
15
|
+
|
|
16
|
+
export { ScaffolderLayouts, createScaffolderLayout };
|
|
17
|
+
//# sourceMappingURL=createScaffolderLayout.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createScaffolderLayout.esm.js","sources":["../../src/layouts/createScaffolderLayout.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { LAYOUTS_KEY, LAYOUTS_WRAPPER_KEY } from './keys';\nimport { attachComponentData, Extension } from '@backstage/core-plugin-api';\nimport type { FormProps as SchemaFormProps } from '@rjsf/core';\nimport React from 'react';\n\n/**\n * The field template from `@rjsf/core` which is a react component that gets passed `@rjsf/core` field related props.\n *\n * @public\n */\nexport type LayoutTemplate<T = any> = NonNullable<\n SchemaFormProps<T>['uiSchema']\n>['ui:ObjectFieldTemplate'];\n\n/**\n * The type of layouts that is passed to the TemplateForms\n *\n * @public\n */\nexport interface LayoutOptions<P = any> {\n name: string;\n component: LayoutTemplate<P>;\n}\n\n/**\n * A type used to wrap up the FieldExtension to embed the ReturnValue and the InputProps\n * @public\n */\nexport type LayoutComponent<_TInputProps> = () => null;\n\n/**\n * Method for creating custom Layouts that can be used in the scaffolder frontend form\n *\n * @public\n */\nexport function createScaffolderLayout<TInputProps = unknown>(\n options: LayoutOptions,\n): Extension<LayoutComponent<TInputProps>> {\n return {\n expose() {\n const LayoutDataHolder: any = () => null;\n\n attachComponentData(LayoutDataHolder, LAYOUTS_KEY, options);\n\n return LayoutDataHolder;\n },\n };\n}\n\n/**\n * The wrapping component for defining scaffolder layouts as children\n *\n * @public\n */\nexport const ScaffolderLayouts: React.ComponentType<\n React.PropsWithChildren<{}>\n> = (): JSX.Element | null => null;\n\nattachComponentData(ScaffolderLayouts, LAYOUTS_WRAPPER_KEY, true);\n"],"names":[],"mappings":";;;AAmDO,SAAS,uBACd,OACyC,EAAA;AACzC,EAAO,OAAA;AAAA,IACL,MAAS,GAAA;AACP,MAAA,MAAM,mBAAwB,MAAM,IAAA,CAAA;AAEpC,MAAoB,mBAAA,CAAA,gBAAA,EAAkB,aAAa,OAAO,CAAA,CAAA;AAE1D,MAAO,OAAA,gBAAA,CAAA;AAAA,KACT;AAAA,GACF,CAAA;AACF,CAAA;AAOO,MAAM,oBAET,MAA0B,KAAA;AAE9B,mBAAoB,CAAA,iBAAA,EAAmB,qBAAqB,IAAI,CAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.esm.js","sources":["../../src/layouts/keys.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport const LAYOUTS_KEY = 'scaffolder.layout.v1';\nexport const LAYOUTS_WRAPPER_KEY = 'scaffolder.layouts.wrapper.v1';\n"],"names":[],"mappings":"AAeO,MAAM,WAAc,GAAA,uBAAA;AACpB,MAAM,mBAAsB,GAAA;;;;"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MarkdownContent } from '@backstage/core-components';
|
|
3
|
+
import Typography from '@material-ui/core/Typography';
|
|
4
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
5
|
+
|
|
6
|
+
const useStyles = makeStyles((theme) => ({
|
|
7
|
+
markdownDescription: {
|
|
8
|
+
fontSize: theme.typography.caption.fontSize,
|
|
9
|
+
margin: 0,
|
|
10
|
+
color: theme.palette.text.secondary,
|
|
11
|
+
"& :first-child": {
|
|
12
|
+
margin: 0,
|
|
13
|
+
marginTop: "3px"
|
|
14
|
+
// to keep the standard browser padding
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}));
|
|
18
|
+
const DescriptionFieldTemplate = (props) => {
|
|
19
|
+
const { id, description } = props;
|
|
20
|
+
const classes = useStyles();
|
|
21
|
+
if (description) {
|
|
22
|
+
if (typeof description === "string") {
|
|
23
|
+
return /* @__PURE__ */ React.createElement(
|
|
24
|
+
MarkdownContent,
|
|
25
|
+
{
|
|
26
|
+
content: description,
|
|
27
|
+
className: classes.markdownDescription
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
return /* @__PURE__ */ React.createElement(Typography, { id, variant: "subtitle2", style: { marginTop: "5px" } }, description);
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { DescriptionFieldTemplate };
|
|
37
|
+
//# sourceMappingURL=DescriptionFieldTemplate.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DescriptionFieldTemplate.esm.js","sources":["../../../../src/next/components/Form/DescriptionFieldTemplate.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\n\nimport { MarkdownContent } from '@backstage/core-components';\nimport Typography from '@material-ui/core/Typography';\nimport { makeStyles } from '@material-ui/core/styles';\nimport {\n DescriptionFieldProps,\n FormContextType,\n RJSFSchema,\n StrictRJSFSchema,\n} from '@rjsf/utils';\n\nconst useStyles = makeStyles(theme => ({\n markdownDescription: {\n fontSize: theme.typography.caption.fontSize,\n margin: 0,\n color: theme.palette.text.secondary,\n '& :first-child': {\n margin: 0,\n marginTop: '3px', // to keep the standard browser padding\n },\n },\n}));\n\n/** The `DescriptionField` is the template to use to render the description of a field\n * @alpha\n * @param props - The `DescriptionFieldProps` for this component\n */\nexport const DescriptionFieldTemplate = <\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n props: DescriptionFieldProps<T, S, F>,\n) => {\n const { id, description } = props;\n const classes = useStyles();\n\n if (description) {\n if (typeof description === 'string') {\n return (\n <MarkdownContent\n content={description}\n className={classes.markdownDescription}\n />\n );\n }\n\n return (\n <Typography id={id} variant=\"subtitle2\" style={{ marginTop: '5px' }}>\n {description}\n </Typography>\n );\n }\n\n return null;\n};\n"],"names":[],"mappings":";;;;;AA2BA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,mBAAqB,EAAA;AAAA,IACnB,QAAA,EAAU,KAAM,CAAA,UAAA,CAAW,OAAQ,CAAA,QAAA;AAAA,IACnC,MAAQ,EAAA,CAAA;AAAA,IACR,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,IAAK,CAAA,SAAA;AAAA,IAC1B,gBAAkB,EAAA;AAAA,MAChB,MAAQ,EAAA,CAAA;AAAA,MACR,SAAW,EAAA,KAAA;AAAA;AAAA,KACb;AAAA,GACF;AACF,CAAE,CAAA,CAAA,CAAA;AAMW,MAAA,wBAAA,GAA2B,CAKtC,KACG,KAAA;AACH,EAAM,MAAA,EAAE,EAAI,EAAA,WAAA,EAAgB,GAAA,KAAA,CAAA;AAC5B,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAE1B,EAAA,IAAI,WAAa,EAAA;AACf,IAAI,IAAA,OAAO,gBAAgB,QAAU,EAAA;AACnC,MACE,uBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,eAAA;AAAA,QAAA;AAAA,UACC,OAAS,EAAA,WAAA;AAAA,UACT,WAAW,OAAQ,CAAA,mBAAA;AAAA,SAAA;AAAA,OACrB,CAAA;AAAA,KAEJ;AAEA,IACE,uBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,EAAA,EAAQ,OAAQ,EAAA,WAAA,EAAY,OAAO,EAAE,SAAA,EAAW,KAAM,EAAA,EAAA,EAC/D,WACH,CAAA,CAAA;AAAA,GAEJ;AAEA,EAAO,OAAA,IAAA,CAAA;AACT;;;;"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { getUiOptions, getTemplate } from '@rjsf/utils';
|
|
3
|
+
import { ScaffolderField } from '../ScaffolderField/ScaffolderField.esm.js';
|
|
4
|
+
|
|
5
|
+
const FieldTemplate = (props) => {
|
|
6
|
+
const {
|
|
7
|
+
id,
|
|
8
|
+
children,
|
|
9
|
+
classNames,
|
|
10
|
+
style,
|
|
11
|
+
disabled,
|
|
12
|
+
displayLabel,
|
|
13
|
+
hidden,
|
|
14
|
+
label,
|
|
15
|
+
onDropPropertyClick,
|
|
16
|
+
onKeyChange,
|
|
17
|
+
readonly,
|
|
18
|
+
required,
|
|
19
|
+
rawErrors = [],
|
|
20
|
+
errors,
|
|
21
|
+
help,
|
|
22
|
+
rawDescription,
|
|
23
|
+
schema,
|
|
24
|
+
uiSchema,
|
|
25
|
+
registry
|
|
26
|
+
} = props;
|
|
27
|
+
const uiOptions = getUiOptions(uiSchema);
|
|
28
|
+
const WrapIfAdditionalTemplate = getTemplate("WrapIfAdditionalTemplate", registry, uiOptions);
|
|
29
|
+
if (hidden) {
|
|
30
|
+
return /* @__PURE__ */ React.createElement("div", { style: { display: "none" } }, children);
|
|
31
|
+
}
|
|
32
|
+
return /* @__PURE__ */ React.createElement(
|
|
33
|
+
WrapIfAdditionalTemplate,
|
|
34
|
+
{
|
|
35
|
+
classNames,
|
|
36
|
+
style,
|
|
37
|
+
disabled,
|
|
38
|
+
id,
|
|
39
|
+
label,
|
|
40
|
+
onDropPropertyClick,
|
|
41
|
+
onKeyChange,
|
|
42
|
+
readonly,
|
|
43
|
+
required,
|
|
44
|
+
schema,
|
|
45
|
+
uiSchema,
|
|
46
|
+
registry
|
|
47
|
+
},
|
|
48
|
+
/* @__PURE__ */ React.createElement(
|
|
49
|
+
ScaffolderField,
|
|
50
|
+
{
|
|
51
|
+
displayLabel,
|
|
52
|
+
rawErrors,
|
|
53
|
+
help,
|
|
54
|
+
disabled,
|
|
55
|
+
rawDescription,
|
|
56
|
+
errors,
|
|
57
|
+
required
|
|
58
|
+
},
|
|
59
|
+
children
|
|
60
|
+
)
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export { FieldTemplate };
|
|
65
|
+
//# sourceMappingURL=FieldTemplate.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldTemplate.esm.js","sources":["../../../../src/next/components/Form/FieldTemplate.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\n\nimport {\n FieldTemplateProps,\n FormContextType,\n RJSFSchema,\n StrictRJSFSchema,\n getTemplate,\n getUiOptions,\n} from '@rjsf/utils';\n\nimport { ScaffolderField } from '../ScaffolderField';\n\n/** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field\n * content, (label, description, children, errors and help) inside of a `WrapIfAdditional` component.\n * @alpha\n * @param props - The `FieldTemplateProps` for this component\n */\nexport const FieldTemplate = <\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n props: FieldTemplateProps<T, S, F>,\n) => {\n const {\n id,\n children,\n classNames,\n style,\n disabled,\n displayLabel,\n hidden,\n label,\n onDropPropertyClick,\n onKeyChange,\n readonly,\n required,\n rawErrors = [],\n errors,\n help,\n rawDescription,\n schema,\n uiSchema,\n registry,\n } = props;\n\n const uiOptions = getUiOptions<T, S, F>(uiSchema);\n const WrapIfAdditionalTemplate = getTemplate<\n 'WrapIfAdditionalTemplate',\n T,\n S,\n F\n >('WrapIfAdditionalTemplate', registry, uiOptions);\n\n if (hidden) {\n return <div style={{ display: 'none' }}>{children}</div>;\n }\n return (\n <WrapIfAdditionalTemplate\n classNames={classNames}\n style={style}\n disabled={disabled}\n id={id}\n label={label}\n onDropPropertyClick={onDropPropertyClick}\n onKeyChange={onKeyChange}\n readonly={readonly}\n required={required}\n schema={schema}\n uiSchema={uiSchema}\n registry={registry}\n >\n <ScaffolderField\n displayLabel={displayLabel}\n rawErrors={rawErrors}\n help={help}\n disabled={disabled}\n rawDescription={rawDescription}\n errors={errors}\n required={required}\n >\n {children}\n </ScaffolderField>\n </WrapIfAdditionalTemplate>\n );\n};\n"],"names":[],"mappings":";;;;AAiCa,MAAA,aAAA,GAAgB,CAK3B,KACG,KAAA;AACH,EAAM,MAAA;AAAA,IACJ,EAAA;AAAA,IACA,QAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,YAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,IACA,mBAAA;AAAA,IACA,WAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,YAAY,EAAC;AAAA,IACb,MAAA;AAAA,IACA,IAAA;AAAA,IACA,cAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA;AAAA,IACA,QA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