@backstage-community/plugin-copilot-backend 0.6.0 → 0.7.1

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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # @backstage-community/plugin-copilot-backend
2
2
 
3
+ ## 0.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 86f6523: Fix handling of optional editors attribute
8
+
9
+ ## 0.7.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 2bae2d2: Backstage version bump to v1.36.1
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [2bae2d2]
18
+ - @backstage-community/plugin-copilot-common@0.7.0
19
+
3
20
  ## 0.6.0
4
21
 
5
22
  ### Minor Changes
@@ -30,29 +30,29 @@ function filterIdeCompletionMetrics(metrics, type, team) {
30
30
  }
31
31
  function filterIdeCompletionLanguageMetrics(metrics, type, team) {
32
32
  return metrics.flatMap(
33
- (metric) => metric.copilot_ide_code_completions.languages.map((language) => ({
33
+ (metric) => metric.copilot_ide_code_completions.languages?.map((language) => ({
34
34
  day: metric.date,
35
35
  type,
36
36
  team_name: team,
37
37
  language: language.name,
38
38
  total_engaged_users: language.total_engaged_users
39
- }))
39
+ })) || []
40
40
  ).filter((language) => language.total_engaged_users > 0);
41
41
  }
42
42
  function filterIdeCompletionEditorMetrics(metrics, type, team) {
43
43
  return metrics.flatMap(
44
- (metric) => metric.copilot_ide_code_completions.editors.map((editor) => ({
44
+ (metric) => metric.copilot_ide_code_completions.editors?.map((editor) => ({
45
45
  day: metric.date,
46
46
  type,
47
47
  team_name: team,
48
48
  editor: editor.name,
49
49
  total_engaged_users: editor.total_engaged_users
50
- }))
50
+ })) || []
51
51
  ).filter((editor) => editor.total_engaged_users > 0);
52
52
  }
53
53
  function filterIdeCompletionEditorModelMetrics(metrics, type, team) {
54
54
  return metrics.flatMap(
55
- (metric) => metric.copilot_ide_code_completions.editors.flatMap(
55
+ (metric) => metric.copilot_ide_code_completions.editors?.flatMap(
56
56
  (editor) => editor.models.map((model) => ({
57
57
  day: metric.date,
58
58
  type,
@@ -61,12 +61,12 @@ function filterIdeCompletionEditorModelMetrics(metrics, type, team) {
61
61
  model: model.name,
62
62
  total_engaged_users: model.total_engaged_users
63
63
  }))
64
- )
64
+ ) || []
65
65
  ).filter((model) => model.total_engaged_users > 0);
66
66
  }
67
67
  function filterIdeCompletionEditorModelLanguageMetrics(metrics, type, team) {
68
68
  return metrics.flatMap(
69
- (metric) => metric.copilot_ide_code_completions.editors.flatMap(
69
+ (metric) => metric.copilot_ide_code_completions.editors?.flatMap(
70
70
  (editor) => editor.models.flatMap(
71
71
  (model) => model.languages.map((language) => ({
72
72
  day: metric.date,
@@ -82,7 +82,7 @@ function filterIdeCompletionEditorModelLanguageMetrics(metrics, type, team) {
82
82
  total_code_lines_suggested: language.total_code_lines_suggested
83
83
  }))
84
84
  )
85
- )
85
+ ) || []
86
86
  ).filter((language) => language.total_engaged_users > 0);
87
87
  }
88
88
  function filterIdeChatMetrics(metrics, type, team) {
@@ -95,18 +95,18 @@ function filterIdeChatMetrics(metrics, type, team) {
95
95
  }
96
96
  function filterIdeEditorMetrics(metrics, type, team) {
97
97
  return metrics.flatMap(
98
- (metric) => metric.copilot_ide_chat.editors.map((editor) => ({
98
+ (metric) => metric.copilot_ide_chat.editors?.map((editor) => ({
99
99
  day: metric.date,
100
100
  type,
101
101
  team_name: team,
102
102
  editor: editor.name,
103
103
  total_engaged_users: editor.total_engaged_users
104
- }))
104
+ })) || []
105
105
  ).filter((editor) => editor.total_engaged_users > 0);
106
106
  }
107
107
  function filterIdeChatEditorModelMetrics(metrics, type, team) {
108
108
  return metrics.flatMap(
109
- (metric) => metric.copilot_ide_chat.editors.flatMap(
109
+ (metric) => metric.copilot_ide_chat.editors?.flatMap(
110
110
  (editor) => editor.models.map((model) => ({
111
111
  day: metric.date,
112
112
  type,
@@ -118,7 +118,7 @@ function filterIdeChatEditorModelMetrics(metrics, type, team) {
118
118
  total_chats: model.total_chats,
119
119
  total_chat_insertion_events: model.total_chat_insertion_events
120
120
  }))
121
- )
121
+ ) || []
122
122
  ).filter((model) => model.total_engaged_users > 0);
123
123
  }
124
124
 
@@ -1 +1 @@
1
- {"version":3,"file":"metricHelpers.cjs.js","sources":["../../src/utils/metricHelpers.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { DateTime } from 'luxon';\nimport {\n CopilotIdeChatsDb,\n CopilotIdeChatsEditorModelDb,\n CopilotIdeChatsEditorsDb,\n CopilotIdeCodeCompletionsDb,\n CopilotIdeCodeCompletionsEditorModelLanguagesDb,\n CopilotIdeCodeCompletionsEditorModelsDb,\n CopilotIdeCodeCompletionsEditorsDb,\n CopilotIdeCodeCompletionsLanguageDb,\n CopilotMetricsDb,\n MetricDbRow,\n} from '../db/DatabaseHandler';\nimport {\n Metric,\n MetricsType,\n CopilotMetrics,\n} from '@backstage-community/plugin-copilot-common';\n\nexport function filterNewMetricsV2(\n metrics: CopilotMetrics[],\n lastDay?: string,\n): CopilotMetrics[] {\n return metrics\n .sort(\n (a, b) =>\n DateTime.fromISO(a.date).toMillis() -\n DateTime.fromISO(b.date).toMillis(),\n )\n .filter(metric => {\n const metricDate = DateTime.fromISO(metric.date);\n\n const lastDayDate = lastDay\n ? DateTime.fromJSDate(new Date(lastDay))\n : null;\n\n return !lastDay || (lastDayDate?.isValid && metricDate > lastDayDate);\n });\n}\n\nexport function filterBaseMetrics(\n metrics: CopilotMetrics[],\n type: MetricsType,\n team?: string,\n): CopilotMetricsDb[] {\n return metrics\n .map(metric => ({\n day: metric.date,\n type: type,\n team_name: team,\n total_engaged_users: metric.total_engaged_users,\n total_active_users: metric.total_active_users,\n }))\n .filter(metric => metric.total_engaged_users > 0);\n}\n\nexport function filterIdeCompletionMetrics(\n metrics: CopilotMetrics[],\n type: MetricsType,\n team?: string,\n): CopilotIdeCodeCompletionsDb[] {\n return metrics\n .map(metric => ({\n day: metric.date,\n type: type,\n team_name: team,\n total_engaged_users:\n metric.copilot_ide_code_completions.total_engaged_users,\n }))\n .filter(completion => completion.total_engaged_users > 0);\n}\n\nexport function filterIdeCompletionLanguageMetrics(\n metrics: CopilotMetrics[],\n type: MetricsType,\n team?: string,\n): CopilotIdeCodeCompletionsLanguageDb[] {\n return metrics\n .flatMap((metric: CopilotMetrics) =>\n metric.copilot_ide_code_completions.languages.map(language => ({\n day: metric.date,\n type: type,\n team_name: team,\n language: language.name,\n total_engaged_users: language.total_engaged_users,\n })),\n )\n .filter(language => language.total_engaged_users > 0);\n}\nexport function filterIdeCompletionEditorMetrics(\n metrics: CopilotMetrics[],\n type: MetricsType,\n team?: string,\n): CopilotIdeCodeCompletionsEditorsDb[] {\n return metrics\n .flatMap((metric: CopilotMetrics) =>\n metric.copilot_ide_code_completions.editors.map(editor => ({\n day: metric.date,\n type: type,\n team_name: team,\n editor: editor.name,\n total_engaged_users: editor.total_engaged_users,\n })),\n )\n .filter(editor => editor.total_engaged_users > 0);\n}\n\nexport function filterIdeCompletionEditorModelMetrics(\n metrics: CopilotMetrics[],\n type: MetricsType,\n team?: string,\n): CopilotIdeCodeCompletionsEditorModelsDb[] {\n return metrics\n .flatMap((metric: CopilotMetrics) =>\n metric.copilot_ide_code_completions.editors.flatMap(editor =>\n editor.models.map(model => ({\n day: metric.date,\n type: type,\n team_name: team,\n editor: editor.name,\n model: model.name,\n total_engaged_users: model.total_engaged_users,\n })),\n ),\n )\n .filter(model => model.total_engaged_users > 0);\n}\nexport function filterIdeCompletionEditorModelLanguageMetrics(\n metrics: CopilotMetrics[],\n type: MetricsType,\n team?: string,\n): CopilotIdeCodeCompletionsEditorModelLanguagesDb[] {\n return metrics\n .flatMap((metric: CopilotMetrics) =>\n metric.copilot_ide_code_completions.editors.flatMap(editor =>\n editor.models.flatMap(model =>\n model.languages.map(language => ({\n day: metric.date,\n type: type,\n team_name: team,\n editor: editor.name,\n model: model.name,\n language: language.name,\n total_engaged_users: language.total_engaged_users,\n total_code_acceptances: language.total_code_acceptances,\n total_code_suggestions: language.total_code_suggestions,\n total_code_lines_accepted: language.total_code_lines_accepted,\n total_code_lines_suggested: language.total_code_lines_suggested,\n })),\n ),\n ),\n )\n .filter(language => language.total_engaged_users > 0);\n}\n\nexport function filterIdeChatMetrics(\n metrics: CopilotMetrics[],\n type: MetricsType,\n team?: string,\n): CopilotIdeChatsDb[] {\n return metrics\n .map((metric: CopilotMetrics) => ({\n day: metric.date,\n type: type,\n team_name: team,\n total_engaged_users: metric.copilot_ide_chat.total_engaged_users,\n }))\n .filter(chat => chat.total_engaged_users > 0);\n}\n\nexport function filterIdeEditorMetrics(\n metrics: CopilotMetrics[],\n type: MetricsType,\n team?: string,\n): CopilotIdeChatsEditorsDb[] {\n return metrics\n .flatMap((metric: CopilotMetrics) =>\n metric.copilot_ide_chat.editors.map(editor => ({\n day: metric.date,\n type: type,\n team_name: team,\n editor: editor.name,\n total_engaged_users: editor.total_engaged_users,\n })),\n )\n .filter(editor => editor.total_engaged_users > 0);\n}\n\nexport function filterIdeChatEditorModelMetrics(\n metrics: CopilotMetrics[],\n type: MetricsType,\n team?: string,\n): CopilotIdeChatsEditorModelDb[] {\n return metrics\n .flatMap((metric: CopilotMetrics) =>\n metric.copilot_ide_chat.editors.flatMap(editor =>\n editor.models.map(model => ({\n day: metric.date,\n type: type,\n team_name: team,\n editor: editor.name,\n model: model.name,\n total_engaged_users: model.total_engaged_users,\n total_chat_copy_events: model.total_chat_copy_events,\n total_chats: model.total_chats,\n total_chat_insertion_events: model.total_chat_insertion_events,\n })),\n ),\n )\n .filter(model => model.total_engaged_users > 0);\n}\n\nexport function prepareMetricsForInsert(\n metrics: Metric[],\n type: MetricsType,\n team_name?: string,\n): MetricDbRow[] {\n return metrics.map(({ breakdown, ...rest }) => ({\n ...rest,\n type,\n team_name,\n breakdown: JSON.stringify(breakdown),\n })) as MetricDbRow[];\n}\n"],"names":["DateTime"],"mappings":";;;;AAkCgB,SAAA,kBAAA,CACd,SACA,OACkB,EAAA;AAClB,EAAA,OAAO,OACJ,CAAA,IAAA;AAAA,IACC,CAAC,CAAA,EAAG,CACF,KAAAA,cAAA,CAAS,QAAQ,CAAE,CAAA,IAAI,CAAE,CAAA,QAAA,KACzBA,cAAS,CAAA,OAAA,CAAQ,CAAE,CAAA,IAAI,EAAE,QAAS;AAAA,GACtC,CACC,OAAO,CAAU,MAAA,KAAA;AAChB,IAAA,MAAM,UAAa,GAAAA,cAAA,CAAS,OAAQ,CAAA,MAAA,CAAO,IAAI,CAAA;AAE/C,IAAM,MAAA,WAAA,GAAc,UAChBA,cAAS,CAAA,UAAA,CAAW,IAAI,IAAK,CAAA,OAAO,CAAC,CACrC,GAAA,IAAA;AAEJ,IAAA,OAAO,CAAC,OAAA,IAAY,WAAa,EAAA,OAAA,IAAW,UAAa,GAAA,WAAA;AAAA,GAC1D,CAAA;AACL;AAEgB,SAAA,iBAAA,CACd,OACA,EAAA,IAAA,EACA,IACoB,EAAA;AACpB,EAAO,OAAA,OAAA,CACJ,IAAI,CAAW,MAAA,MAAA;AAAA,IACd,KAAK,MAAO,CAAA,IAAA;AAAA,IACZ,IAAA;AAAA,IACA,SAAW,EAAA,IAAA;AAAA,IACX,qBAAqB,MAAO,CAAA,mBAAA;AAAA,IAC5B,oBAAoB,MAAO,CAAA;AAAA,IAC3B,CACD,CAAA,MAAA,CAAO,CAAU,MAAA,KAAA,MAAA,CAAO,sBAAsB,CAAC,CAAA;AACpD;AAEgB,SAAA,0BAAA,CACd,OACA,EAAA,IAAA,EACA,IAC+B,EAAA;AAC/B,EAAO,O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KAAM,CAAA,IAAA;AAAA,QACb,qBAAqB,KAAM,CAAA,mBAAA;AAAA,QAC3B,wBAAwB,KAAM,CAAA,sBAAA;AAAA,QAC9B,aAAa,KAAM,CAAA,WAAA;AAAA,QACnB,6BAA6B,KAAM,CAAA;AAAA,OACnC,CAAA;AAAA;AACJ,GAED,CAAA,MAAA,CAAO,CAAS,KAAA,KAAA,KAAA,CAAM,sBAAsB,CAAC,CAAA;AAClD;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"metricHelpers.cjs.js","sources":["../../src/utils/metricHelpers.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { DateTime } from 'luxon';\nimport {\n CopilotIdeChatsDb,\n CopilotIdeChatsEditorModelDb,\n CopilotIdeChatsEditorsDb,\n CopilotIdeCodeCompletionsDb,\n CopilotIdeCodeCompletionsEditorModelLanguagesDb,\n CopilotIdeCodeCompletionsEditorModelsDb,\n CopilotIdeCodeCompletionsEditorsDb,\n CopilotIdeCodeCompletionsLanguageDb,\n CopilotMetricsDb,\n MetricDbRow,\n} from '../db/DatabaseHandler';\nimport {\n Metric,\n MetricsType,\n CopilotMetrics,\n} from '@backstage-community/plugin-copilot-common';\n\nexport function filterNewMetricsV2(\n metrics: CopilotMetrics[],\n lastDay?: string,\n): CopilotMetrics[] {\n return metrics\n .sort(\n (a, b) =>\n DateTime.fromISO(a.date).toMillis() -\n DateTime.fromISO(b.date).toMillis(),\n )\n .filter(metric => {\n const metricDate = DateTime.fromISO(metric.date);\n\n const lastDayDate = lastDay\n ? DateTime.fromJSDate(new Date(lastDay))\n : null;\n\n return !lastDay || (lastDayDate?.isValid && metricDate > lastDayDate);\n });\n}\n\nexport function filterBaseMetrics(\n metrics: CopilotMetrics[],\n type: MetricsType,\n team?: string,\n): CopilotMetricsDb[] {\n return metrics\n .map(metric => ({\n day: metric.date,\n type: type,\n team_name: team,\n total_engaged_users: metric.total_engaged_users,\n total_active_users: metric.total_active_users,\n }))\n .filter(metric => metric.total_engaged_users > 0);\n}\n\nexport function filterIdeCompletionMetrics(\n metrics: CopilotMetrics[],\n type: MetricsType,\n team?: string,\n): CopilotIdeCodeCompletionsDb[] {\n return metrics\n .map(metric => ({\n day: metric.date,\n type: type,\n team_name: team,\n total_engaged_users:\n metric.copilot_ide_code_completions.total_engaged_users,\n }))\n .filter(completion => completion.total_engaged_users > 0);\n}\n\nexport function filterIdeCompletionLanguageMetrics(\n metrics: CopilotMetrics[],\n type: MetricsType,\n team?: string,\n): CopilotIdeCodeCompletionsLanguageDb[] {\n return metrics\n .flatMap(\n (metric: CopilotMetrics) =>\n metric.copilot_ide_code_completions.languages?.map(language => ({\n day: metric.date,\n type: type,\n team_name: team,\n language: language.name,\n total_engaged_users: language.total_engaged_users,\n })) || [],\n )\n .filter(language => language.total_engaged_users > 0);\n}\nexport function filterIdeCompletionEditorMetrics(\n metrics: CopilotMetrics[],\n type: MetricsType,\n team?: string,\n): CopilotIdeCodeCompletionsEditorsDb[] {\n return metrics\n .flatMap(\n (metric: CopilotMetrics) =>\n metric.copilot_ide_code_completions.editors?.map(editor => ({\n day: metric.date,\n type: type,\n team_name: team,\n editor: editor.name,\n total_engaged_users: editor.total_engaged_users,\n })) || [],\n )\n .filter(editor => editor.total_engaged_users > 0);\n}\n\nexport function filterIdeCompletionEditorModelMetrics(\n metrics: CopilotMetrics[],\n type: MetricsType,\n team?: string,\n): CopilotIdeCodeCompletionsEditorModelsDb[] {\n return metrics\n .flatMap(\n (metric: CopilotMetrics) =>\n metric.copilot_ide_code_completions.editors?.flatMap(editor =>\n editor.models.map(model => ({\n day: metric.date,\n type: type,\n team_name: team,\n editor: editor.name,\n model: model.name,\n total_engaged_users: model.total_engaged_users,\n })),\n ) || [],\n )\n .filter(model => model.total_engaged_users > 0);\n}\nexport function filterIdeCompletionEditorModelLanguageMetrics(\n metrics: CopilotMetrics[],\n type: MetricsType,\n team?: string,\n): CopilotIdeCodeCompletionsEditorModelLanguagesDb[] {\n return metrics\n .flatMap(\n (metric: CopilotMetrics) =>\n metric.copilot_ide_code_completions.editors?.flatMap(editor =>\n editor.models.flatMap(model =>\n model.languages.map(language => ({\n day: metric.date,\n type: type,\n team_name: team,\n editor: editor.name,\n model: model.name,\n language: language.name,\n total_engaged_users: language.total_engaged_users,\n total_code_acceptances: language.total_code_acceptances,\n total_code_suggestions: language.total_code_suggestions,\n total_code_lines_accepted: language.total_code_lines_accepted,\n total_code_lines_suggested: language.total_code_lines_suggested,\n })),\n ),\n ) || [],\n )\n .filter(language => language.total_engaged_users > 0);\n}\n\nexport function filterIdeChatMetrics(\n metrics: CopilotMetrics[],\n type: MetricsType,\n team?: string,\n): CopilotIdeChatsDb[] {\n return metrics\n .map((metric: CopilotMetrics) => ({\n day: metric.date,\n type: type,\n team_name: team,\n total_engaged_users: metric.copilot_ide_chat.total_engaged_users,\n }))\n .filter(chat => chat.total_engaged_users > 0);\n}\n\nexport function filterIdeEditorMetrics(\n metrics: CopilotMetrics[],\n type: MetricsType,\n team?: string,\n): CopilotIdeChatsEditorsDb[] {\n return metrics\n .flatMap(\n (metric: CopilotMetrics) =>\n metric.copilot_ide_chat.editors?.map(editor => ({\n day: metric.date,\n type: type,\n team_name: team,\n editor: editor.name,\n total_engaged_users: editor.total_engaged_users,\n })) || [],\n )\n .filter(editor => editor.total_engaged_users > 0);\n}\n\nexport function filterIdeChatEditorModelMetrics(\n metrics: CopilotMetrics[],\n type: MetricsType,\n team?: string,\n): CopilotIdeChatsEditorModelDb[] {\n return metrics\n .flatMap(\n (metric: CopilotMetrics) =>\n metric.copilot_ide_chat.editors?.flatMap(editor =>\n editor.models.map(model => ({\n day: metric.date,\n type: type,\n team_name: team,\n editor: editor.name,\n model: model.name,\n total_engaged_users: model.total_engaged_users,\n total_chat_copy_events: model.total_chat_copy_events,\n total_chats: model.total_chats,\n total_chat_insertion_events: model.total_chat_insertion_events,\n })),\n ) || [],\n )\n .filter(model => model.total_engaged_users > 0);\n}\n\nexport function prepareMetricsForInsert(\n metrics: Metric[],\n type: MetricsType,\n team_name?: string,\n): MetricDbRow[] {\n return metrics.map(({ breakdown, ...rest }) => ({\n ...rest,\n type,\n team_name,\n breakdown: JSON.stringify(breakdown),\n })) as MetricDbRow[];\n}\n"],"names":["DateTime"],"mappings":";;;;AAkCgB,SAAA,kBAAA,CACd,SACA,OACkB,EAAA;AAClB,EAAA,OAAO,OACJ,CAAA,IAAA;AAAA,IACC,CAAC,CAAA,EAAG,CACF,KAAAA,cAAA,CAAS,QAAQ,CAAE,CAAA,IAAI,CAAE,CAAA,QAAA,KACzBA,cAAS,CAAA,OAAA,CAAQ,CAAE,CAAA,IAAI,EAAE,QAAS;AAAA,GACtC,CACC,OAAO,CAAU,MAAA,KAAA;AAChB,IAAA,MAAM,UAAa,GAAAA,cAAA,CAAS,OAAQ,CAAA,MAAA,CAAO,IAAI,CAAA;AAE/C,IAAM,MAAA,WAAA,GAAc,UAChBA,cAAS,CAAA,UAAA,CAAW,IAAI,IAAK,CAAA,OAAO,CAAC,CACrC,GAAA,IAAA;AAEJ,IAAA,OAAO,CAAC,OAAA,IAAY,WAAa,EAAA,OAAA,IAAW,UAAa,GAAA,WAAA;AAAA,GAC1D,CAAA;AACL;AAEgB,SAAA,iBAAA,CACd,OACA,EAAA,IAAA,EACA,IACoB,EAAA;AACpB,EAAO,OAAA,OAAA,CACJ,IAAI,CAAW,MAAA,MAAA;AAAA,IACd,KAAK,MAAO,CAAA,IAAA;AAAA,IACZ,IAAA;AAAA,IACA,SAAW,EAAA,IAAA;AAAA,IACX,qBAAqB,MAAO,CAAA,mBAAA;AA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vC,MAAA,KAAA,MAAA,CAAO,MAAO,CAAA,GAAA,CAAI,CAAU,KAAA,MAAA;AAAA,QAC1B,KAAK,MAAO,CAAA,IAAA;AAAA,QACZ,IAAA;AAAA,QACA,SAAW,EAAA,IAAA;AAAA,QACX,QAAQ,MAAO,CAAA,IAAA;AAAA,QACf,OAAO,KAAM,CAAA,IAAA;AAAA,QACb,qBAAqB,KAAM,CAAA,mBAAA;AAAA,QAC3B,wBAAwB,KAAM,CAAA,sBAAA;AAAA,QAC9B,aAAa,KAAM,CAAA,WAAA;AAAA,QACnB,6BAA6B,KAAM,CAAA;AAAA,OACnC,CAAA;AAAA,SACC;AAAC,GAET,CAAA,MAAA,CAAO,CAAS,KAAA,KAAA,KAAA,CAAM,sBAAsB,CAAC,CAAA;AAClD;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage-community/plugin-copilot-backend",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "homepage": "https://backstage.io",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.cjs.js",
@@ -17,7 +17,10 @@
17
17
  "@backstage-community/plugin-copilot",
18
18
  "@backstage-community/plugin-copilot-backend",
19
19
  "@backstage-community/plugin-copilot-common"
20
- ]
20
+ ],
21
+ "features": {
22
+ ".": "@backstage/BackendFeature"
23
+ }
21
24
  },
22
25
  "publishConfig": {
23
26
  "access": "public",
@@ -39,10 +42,10 @@
39
42
  "postpack": "backstage-cli package postpack"
40
43
  },
41
44
  "dependencies": {
42
- "@backstage-community/plugin-copilot-common": "^0.6.0",
43
- "@backstage/backend-app-api": "^1.1.1",
44
- "@backstage/backend-defaults": "^0.7.0",
45
- "@backstage/backend-plugin-api": "^1.1.1",
45
+ "@backstage-community/plugin-copilot-common": "^0.7.0",
46
+ "@backstage/backend-app-api": "^1.2.0",
47
+ "@backstage/backend-defaults": "^0.8.1",
48
+ "@backstage/backend-plugin-api": "^1.2.0",
46
49
  "@backstage/config": "^1.3.2",
47
50
  "@backstage/errors": "^1.2.7",
48
51
  "@backstage/integration": "^1.16.1",
@@ -57,11 +60,11 @@
57
60
  "zod": "^3.23.8"
58
61
  },
59
62
  "devDependencies": {
60
- "@backstage/backend-test-utils": "^1.2.1",
61
- "@backstage/cli": "^0.29.6",
62
- "@backstage/plugin-auth-backend": "^0.24.2",
63
- "@backstage/plugin-auth-backend-module-guest-provider": "^0.2.4",
64
- "@backstage/test-utils": "^1.7.4",
63
+ "@backstage/backend-test-utils": "^1.3.0",
64
+ "@backstage/cli": "^0.30.0",
65
+ "@backstage/plugin-auth-backend": "^0.24.3",
66
+ "@backstage/plugin-auth-backend-module-guest-provider": "^0.2.5",
67
+ "@backstage/test-utils": "^1.7.5",
65
68
  "@types/node-fetch": "^2.6.11",
66
69
  "@types/supertest": "^2.0.8",
67
70
  "msw": "^1.0.0",