@backstage/plugin-scaffolder-react 1.7.1-next.2 → 1.8.0-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.
@@ -2,9 +2,6 @@ import { createVersionedContext, createVersionedValueMap, getOrCreateGlobalSingl
2
2
  import React, { useState, useContext, useCallback } from 'react';
3
3
  import { createApiRef } from '@backstage/core-plugin-api';
4
4
 
5
- const FIELD_EXTENSION_WRAPPER_KEY = "scaffolder.extensions.wrapper.v1";
6
- const FIELD_EXTENSION_KEY = "scaffolder.extensions.field.v1";
7
-
8
5
  const SecretsContext = createVersionedContext("secrets-context");
9
6
  const SecretsContextProvider = (props) => {
10
7
  const [secrets, setSecrets] = useState({});
@@ -41,5 +38,5 @@ const scaffolderApiRef = getOrCreateGlobalSingleton(
41
38
  })
42
39
  );
43
40
 
44
- export { FIELD_EXTENSION_WRAPPER_KEY as F, SecretsContextProvider as S, FIELD_EXTENSION_KEY as a, scaffolderApiRef as s, useTemplateSecrets as u };
45
- //# sourceMappingURL=ref-6fdfc121.esm.js.map
41
+ export { SecretsContextProvider as S, scaffolderApiRef as s, useTemplateSecrets as u };
42
+ //# sourceMappingURL=ref-e2ee478c.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref-e2ee478c.esm.js","sources":["../../src/secrets/SecretsContext.tsx","../../src/api/ref.ts"],"sourcesContent":["/*\n * Copyright 2022 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 {\n createVersionedContext,\n createVersionedValueMap,\n} from '@backstage/version-bridge';\nimport React, {\n useState,\n useCallback,\n useContext,\n PropsWithChildren,\n} from 'react';\n\n/**\n * The contents of the `SecretsContext`\n */\ntype SecretsContextContents = {\n secrets: Record<string, string>;\n setSecrets: React.Dispatch<React.SetStateAction<Record<string, string>>>;\n};\n\n/**\n * The context to hold the Secrets.\n */\nconst SecretsContext = createVersionedContext<{\n 1: SecretsContextContents;\n}>('secrets-context');\n\n/**\n * The Context Provider that holds the state for the secrets.\n * @public\n */\nexport const SecretsContextProvider = (props: PropsWithChildren<{}>) => {\n const [secrets, setSecrets] = useState<Record<string, string>>({});\n\n return (\n <SecretsContext.Provider\n value={createVersionedValueMap({ 1: { secrets, setSecrets } })}\n >\n {props.children}\n </SecretsContext.Provider>\n );\n};\n\n/**\n * The return type from the useTemplateSecrets hook.\n * @public\n */\nexport interface ScaffolderUseTemplateSecrets {\n setSecrets: (input: Record<string, string>) => void;\n secrets: Record<string, string>;\n}\n\n/**\n * Hook to access the secrets context to be able to set secrets that are\n * passed to the Scaffolder backend.\n * @public\n */\nexport const useTemplateSecrets = (): ScaffolderUseTemplateSecrets => {\n const value = useContext(SecretsContext)?.atVersion(1);\n\n if (!value) {\n throw new Error(\n 'useTemplateSecrets must be used within a SecretsContextProvider',\n );\n }\n\n const { setSecrets: updateSecrets, secrets = {} } = value;\n\n const setSecrets = useCallback(\n (input: Record<string, string>) => {\n updateSecrets(currentSecrets => ({ ...currentSecrets, ...input }));\n },\n [updateSecrets],\n );\n\n return { setSecrets, secrets };\n};\n","/*\n * Copyright 2022 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 { createApiRef } from '@backstage/core-plugin-api';\nimport { ScaffolderApi } from './types';\nimport { getOrCreateGlobalSingleton } from '@backstage/version-bridge';\n\n/** @public */\nexport const scaffolderApiRef = getOrCreateGlobalSingleton(\n 'scaffolder:scaffolder-api-ref',\n () =>\n createApiRef<ScaffolderApi>({\n id: 'plugin.scaffolder.service',\n }),\n);\n"],"names":[],"mappings":";;;;AAqCA,MAAM,cAAA,GAAiB,uBAEpB,iBAAiB,CAAA,CAAA;AAMP,MAAA,sBAAA,GAAyB,CAAC,KAAiC,KAAA;AACtE,EAAA,MAAM,CAAC,OAAS,EAAA,UAAU,CAAI,GAAA,QAAA,CAAiC,EAAE,CAAA,CAAA;AAEjE,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,cAAe,CAAA,QAAA;AAAA,IAAf;AAAA,MACC,KAAA,EAAO,wBAAwB,EAAE,CAAA,EAAG,EAAE,OAAS,EAAA,UAAA,IAAc,CAAA;AAAA,KAAA;AAAA,IAE5D,KAAM,CAAA,QAAA;AAAA,GACT,CAAA;AAEJ,EAAA;AAgBO,MAAM,qBAAqB,MAAoC;AAvEtE,EAAA,IAAA,EAAA,CAAA;AAwEE,EAAA,MAAM,KAAQ,GAAA,CAAA,EAAA,GAAA,UAAA,CAAW,cAAc,CAAA,KAAzB,mBAA4B,SAAU,CAAA,CAAA,CAAA,CAAA;AAEpD,EAAA,IAAI,CAAC,KAAO,EAAA;AACV,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,iEAAA;AAAA,KACF,CAAA;AAAA,GACF;AAEA,EAAA,MAAM,EAAE,UAAY,EAAA,aAAA,EAAe,OAAU,GAAA,IAAO,GAAA,KAAA,CAAA;AAEpD,EAAA,MAAM,UAAa,GAAA,WAAA;AAAA,IACjB,CAAC,KAAkC,KAAA;AACjC,MAAA,aAAA,CAAc,qBAAmB,EAAE,GAAG,cAAgB,EAAA,GAAG,OAAQ,CAAA,CAAA,CAAA;AAAA,KACnE;AAAA,IACA,CAAC,aAAa,CAAA;AAAA,GAChB,CAAA;AAEA,EAAO,OAAA,EAAE,YAAY,OAAQ,EAAA,CAAA;AAC/B;;ACrEO,MAAM,gBAAmB,GAAA,0BAAA;AAAA,EAC9B,+BAAA;AAAA,EACA,MACE,YAA4B,CAAA;AAAA,IAC1B,EAAI,EAAA,2BAAA;AAAA,GACL,CAAA;AACL;;;;"}
package/dist/index.d.ts CHANGED
@@ -428,6 +428,7 @@ type ScaffolderOutputText = {
428
428
  title?: string;
429
429
  icon?: string;
430
430
  content?: string;
431
+ default?: boolean;
431
432
  };
432
433
  /** @public */
433
434
  type ScaffolderTaskOutput = {
@@ -442,7 +443,7 @@ type ScaffolderTaskOutput = {
442
443
  * @public
443
444
  */
444
445
  type LogEvent = {
445
- type: 'log' | 'completion' | 'cancelled';
446
+ type: 'log' | 'completion' | 'cancelled' | 'recovered';
446
447
  body: {
447
448
  message: string;
448
449
  stepId?: string;
package/dist/index.esm.js CHANGED
@@ -1,10 +1,13 @@
1
1
  import { attachComponentData, useElementFilter, useApi } from '@backstage/core-plugin-api';
2
- import { F as FIELD_EXTENSION_WRAPPER_KEY, a as FIELD_EXTENSION_KEY, s as scaffolderApiRef } from './esm/ref-6fdfc121.esm.js';
3
- export { S as SecretsContextProvider, s as scaffolderApiRef, u as useTemplateSecrets } from './esm/ref-6fdfc121.esm.js';
2
+ import { s as scaffolderApiRef } from './esm/ref-e2ee478c.esm.js';
3
+ export { S as SecretsContextProvider, s as scaffolderApiRef, u as useTemplateSecrets } from './esm/ref-e2ee478c.esm.js';
4
4
  import { useImmerReducer } from 'use-immer';
5
5
  import { useEffect } from 'react';
6
6
  import '@backstage/version-bridge';
7
7
 
8
+ const FIELD_EXTENSION_WRAPPER_KEY = "scaffolder.extensions.wrapper.v1";
9
+ const FIELD_EXTENSION_KEY = "scaffolder.extensions.field.v1";
10
+
8
11
  function createScaffolderFieldExtension(options) {
9
12
  return {
10
13
  expose() {
@@ -77,13 +80,15 @@ function reducer(draft, action) {
77
80
  }
78
81
  const currentStepLog = (_b = draft.stepLogs) == null ? void 0 : _b[entry.body.stepId];
79
82
  const currentStep = (_c = draft.steps) == null ? void 0 : _c[entry.body.stepId];
80
- if (entry.body.status && entry.body.status !== currentStep.status) {
81
- currentStep.status = entry.body.status;
82
- if (currentStep.status === "processing") {
83
- currentStep.startedAt = entry.createdAt;
84
- }
85
- if (["cancelled", "completed", "failed"].includes(currentStep.status)) {
86
- currentStep.endedAt = entry.createdAt;
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
+ }
87
92
  }
88
93
  }
89
94
  currentStepLog == null ? void 0 : currentStepLog.push(logLine);
@@ -100,6 +105,16 @@ function reducer(draft, action) {
100
105
  draft.cancelled = true;
101
106
  return;
102
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
+ }
103
118
  case "ERROR": {
104
119
  draft.error = action.data;
105
120
  draft.loading = false;
@@ -144,6 +159,7 @@ const useTaskEventStream = (taskId) => {
144
159
  logPusher = setInterval(emitLogs, 500);
145
160
  subscription = observable.subscribe({
146
161
  next: (event) => {
162
+ retryCount = 1;
147
163
  switch (event.type) {
148
164
  case "log":
149
165
  return collectedLogEvents.push(event);
@@ -154,6 +170,9 @@ const useTaskEventStream = (taskId) => {
154
170
  emitLogs();
155
171
  dispatch({ type: "COMPLETED", data: event });
156
172
  return void 0;
173
+ case "recovered":
174
+ dispatch({ type: "RECOVERED", data: event });
175
+ return void 0;
157
176
  default:
158
177
  throw new Error(
159
178
  `Unhandled event type ${event.type} in observer`
@@ -162,15 +181,14 @@ const useTaskEventStream = (taskId) => {
162
181
  },
163
182
  error: (error) => {
164
183
  emitLogs();
184
+ const maxRetries = 3;
165
185
  if (!error.message) {
166
- error.message = `We cannot connect at the moment, trying again in some seconds... Retrying (${retryCount}/3 retries)`;
167
- }
168
- if (retryCount <= 3) {
169
- setTimeout(() => {
170
- retryCount += 1;
171
- startStreamLogProcess();
172
- }, 15e3);
186
+ error.message = `We cannot connect at the moment, trying again in some seconds... Retrying (${retryCount > maxRetries ? maxRetries : retryCount}/${maxRetries} retries)`;
173
187
  }
188
+ setTimeout(() => {
189
+ retryCount += 1;
190
+ void startStreamLogProcess();
191
+ }, 15e3);
174
192
  dispatch({ type: "ERROR", data: error });
175
193
  }
176
194
  });
@@ -181,7 +199,7 @@ const useTaskEventStream = (taskId) => {
181
199
  }
182
200
  }
183
201
  );
184
- startStreamLogProcess();
202
+ void startStreamLogProcess();
185
203
  return () => {
186
204
  didCancel = true;
187
205
  if (subscription) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../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 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 };\n};\n\ntype ReducerAction =\n | { type: 'INIT'; data: ScaffolderTask }\n | { type: 'CANCELLED' }\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 (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 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 '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 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 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 if (!error.message) {\n error.message = `We cannot connect at the moment, trying again in some seconds... Retrying (${retryCount}/3 retries)`;\n }\n\n if (retryCount <= 3) {\n setTimeout(() => {\n retryCount += 1;\n startStreamLogProcess();\n }, 15000);\n }\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 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"],"names":[],"mappings":";;;;;;;AAgCO,SAAS,+BAId,OAC+D,EAAA;AAC/D,EAAO,OAAA;AAAA,IACL,MAAS,GAAA;AACP,MAAA,MAAM,2BAAgC,MAAM,IAAA,CAAA;AAE5C,MAAA,mBAAA;AAAA,QACE,wBAAA;AAAA,QACA,mBAAA;AAAA,QACA,OAAA;AAAA,OACF,CAAA;AAEA,MAAO,OAAA,wBAAA,CAAA;AAAA,KACT;AAAA,GACF,CAAA;AACF,CAAA;AAOO,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AAS,EAAA,IAAA,EAAM,OAAO,CAAA,CAAA;AAAA,SACzC;AAAA,OACF;AAAA,KACF,CAAA;AACF,IAAsB,qBAAA,EAAA,CAAA;AACtB,IAAA,OAAO,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;;ACnNO,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":["../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"],"names":[],"mappings":";;;;;;;AAgBO,MAAM,2BAA8B,GAAA,kCAAA,CAAA;AAIpC,MAAM,mBAAsB,GAAA,gCAAA;;ACY5B,SAAS,+BAId,OAC+D,EAAA;AAC/D,EAAO,OAAA;AAAA,IACL,MAAS,GAAA;AACP,MAAA,MAAM,2BAAgC,MAAM,IAAA,CAAA;AAE5C,MAAA,mBAAA;AAAA,QACE,wBAAA;AAAA,QACA,mBAAA;AAAA,QACA,OAAA;AAAA,OACF,CAAA;AAEA,MAAO,OAAA,wBAAA,CAAA;AAAA,KACT;AAAA,GACF,CAAA;AACF,CAAA;AAOO,MAAM,4BAET,MAA0B,KAAA;AAE9B,mBAAA;AAAA,EACE,yBAAA;AAAA,EACA,2BAAA;AAAA,EACA,IAAA;AACF,CAAA;;ACxCa,MAAA,wBAAA,GAA2B,CAGtC,MACG,KAAA;AACH,EAAO,OAAA,gBAA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AAAA,KACT;AAAA,GACF,CAAA;AACF,CAAA;AAOO,MAAM,oBAET,MAA0B,KAAA;AAE9B,mBAAoB,CAAA,iBAAA,EAAmB,qBAAqB,IAAI,CAAA;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-react",
3
3
  "description": "A frontend library that helps other Backstage plugins interact with the Scaffolder",
4
- "version": "1.7.1-next.2",
4
+ "version": "1.8.0-next.0",
5
5
  "main": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -44,12 +44,12 @@
44
44
  "start": "backstage-cli package start"
45
45
  },
46
46
  "dependencies": {
47
- "@backstage/catalog-client": "^1.5.2-next.0",
47
+ "@backstage/catalog-client": "^1.6.0-next.0",
48
48
  "@backstage/catalog-model": "^1.4.3",
49
- "@backstage/core-components": "^0.13.10-next.1",
50
- "@backstage/core-plugin-api": "^1.8.2-next.0",
51
- "@backstage/plugin-catalog-react": "^1.9.3-next.2",
52
- "@backstage/plugin-scaffolder-common": "^1.4.4",
49
+ "@backstage/core-components": "^0.13.10",
50
+ "@backstage/core-plugin-api": "^1.8.2",
51
+ "@backstage/plugin-catalog-react": "^1.9.4-next.0",
52
+ "@backstage/plugin-scaffolder-common": "^1.5.0-next.0",
53
53
  "@backstage/theme": "^0.5.0",
54
54
  "@backstage/types": "^1.1.1",
55
55
  "@backstage/version-bridge": "^1.0.7",
@@ -57,10 +57,10 @@
57
57
  "@material-ui/icons": "^4.9.1",
58
58
  "@material-ui/lab": "4.0.0-alpha.61",
59
59
  "@react-hookz/web": "^23.0.0",
60
- "@rjsf/core": "5.15.1",
61
- "@rjsf/material-ui": "5.15.1",
62
- "@rjsf/utils": "5.15.1",
63
- "@rjsf/validator-ajv8": "5.15.1",
60
+ "@rjsf/core": "5.16.1",
61
+ "@rjsf/material-ui": "5.16.1",
62
+ "@rjsf/utils": "5.16.1",
63
+ "@rjsf/validator-ajv8": "5.16.1",
64
64
  "@types/json-schema": "^7.0.9",
65
65
  "@types/react": "^16.13.1 || ^17.0.0",
66
66
  "classnames": "^2.2.6",
@@ -83,11 +83,11 @@
83
83
  "react-router-dom": "6.0.0-beta.0 || ^6.3.0"
84
84
  },
85
85
  "devDependencies": {
86
- "@backstage/cli": "^0.25.1-next.1",
87
- "@backstage/core-app-api": "^1.11.3-next.0",
88
- "@backstage/plugin-catalog": "^1.16.1-next.2",
89
- "@backstage/plugin-catalog-common": "^1.0.19",
90
- "@backstage/test-utils": "^1.4.7-next.1",
86
+ "@backstage/cli": "^0.25.2-next.0",
87
+ "@backstage/core-app-api": "^1.11.3",
88
+ "@backstage/plugin-catalog": "^1.17.0-next.0",
89
+ "@backstage/plugin-catalog-common": "^1.0.20",
90
+ "@backstage/test-utils": "^1.5.0-next.0",
91
91
  "@testing-library/dom": "^9.0.0",
92
92
  "@testing-library/jest-dom": "^6.0.0",
93
93
  "@testing-library/react": "^14.0.0",
@@ -1 +0,0 @@
1
- {"version":3,"file":"ref-6fdfc121.esm.js","sources":["../../src/extensions/keys.ts","../../src/secrets/SecretsContext.tsx","../../src/api/ref.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 2022 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 {\n createVersionedContext,\n createVersionedValueMap,\n} from '@backstage/version-bridge';\nimport React, {\n useState,\n useCallback,\n useContext,\n PropsWithChildren,\n} from 'react';\n\n/**\n * The contents of the `SecretsContext`\n */\ntype SecretsContextContents = {\n secrets: Record<string, string>;\n setSecrets: React.Dispatch<React.SetStateAction<Record<string, string>>>;\n};\n\n/**\n * The context to hold the Secrets.\n */\nconst SecretsContext = createVersionedContext<{\n 1: SecretsContextContents;\n}>('secrets-context');\n\n/**\n * The Context Provider that holds the state for the secrets.\n * @public\n */\nexport const SecretsContextProvider = (props: PropsWithChildren<{}>) => {\n const [secrets, setSecrets] = useState<Record<string, string>>({});\n\n return (\n <SecretsContext.Provider\n value={createVersionedValueMap({ 1: { secrets, setSecrets } })}\n >\n {props.children}\n </SecretsContext.Provider>\n );\n};\n\n/**\n * The return type from the useTemplateSecrets hook.\n * @public\n */\nexport interface ScaffolderUseTemplateSecrets {\n setSecrets: (input: Record<string, string>) => void;\n secrets: Record<string, string>;\n}\n\n/**\n * Hook to access the secrets context to be able to set secrets that are\n * passed to the Scaffolder backend.\n * @public\n */\nexport const useTemplateSecrets = (): ScaffolderUseTemplateSecrets => {\n const value = useContext(SecretsContext)?.atVersion(1);\n\n if (!value) {\n throw new Error(\n 'useTemplateSecrets must be used within a SecretsContextProvider',\n );\n }\n\n const { setSecrets: updateSecrets, secrets = {} } = value;\n\n const setSecrets = useCallback(\n (input: Record<string, string>) => {\n updateSecrets(currentSecrets => ({ ...currentSecrets, ...input }));\n },\n [updateSecrets],\n );\n\n return { setSecrets, secrets };\n};\n","/*\n * Copyright 2022 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 { createApiRef } from '@backstage/core-plugin-api';\nimport { ScaffolderApi } from './types';\nimport { getOrCreateGlobalSingleton } from '@backstage/version-bridge';\n\n/** @public */\nexport const scaffolderApiRef = getOrCreateGlobalSingleton(\n 'scaffolder:scaffolder-api-ref',\n () =>\n createApiRef<ScaffolderApi>({\n id: 'plugin.scaffolder.service',\n }),\n);\n"],"names":[],"mappings":";;;;AAgBO,MAAM,2BAA8B,GAAA,mCAAA;AAIpC,MAAM,mBAAsB,GAAA;;ACiBnC,MAAM,cAAA,GAAiB,uBAEpB,iBAAiB,CAAA,CAAA;AAMP,MAAA,sBAAA,GAAyB,CAAC,KAAiC,KAAA;AACtE,EAAA,MAAM,CAAC,OAAS,EAAA,UAAU,CAAI,GAAA,QAAA,CAAiC,EAAE,CAAA,CAAA;AAEjE,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,cAAe,CAAA,QAAA;AAAA,IAAf;AAAA,MACC,KAAA,EAAO,wBAAwB,EAAE,CAAA,EAAG,EAAE,OAAS,EAAA,UAAA,IAAc,CAAA;AAAA,KAAA;AAAA,IAE5D,KAAM,CAAA,QAAA;AAAA,GACT,CAAA;AAEJ,EAAA;AAgBO,MAAM,qBAAqB,MAAoC;AAvEtE,EAAA,IAAA,EAAA,CAAA;AAwEE,EAAA,MAAM,KAAQ,GAAA,CAAA,EAAA,GAAA,UAAA,CAAW,cAAc,CAAA,KAAzB,mBAA4B,SAAU,CAAA,CAAA,CAAA,CAAA;AAEpD,EAAA,IAAI,CAAC,KAAO,EAAA;AACV,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,i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