@spotify/backstage-plugin-search-backend-module-skill-exchange 0.3.0 → 0.4.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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @spotify/backstage-plugin-search-backend-module-skill-exchange
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Use native `fetch` instead of `node-fetch`.
8
+
9
+ ### Patch Changes
10
+
11
+ - Update to Backstage `v1.36.0`
12
+ - Update team search dropdown in Home and Embeds to use the human readable `spec.profile.displayName` instead of `metadata.name`.
13
+ - Updated dependencies
14
+ - @spotify/backstage-plugin-skill-exchange-common@0.2.6
15
+ - @spotify/backstage-plugin-skill-exchange-node@0.4.0
16
+
3
17
  ## 0.3.0
4
18
 
5
19
  ### Minor Changes
@@ -1,4 +1,4 @@
1
- "use strict";var l=require("@backstage/catalog-model"),c=require("@backstage/plugin-search-backend-node");class o extends c.DecoratorBase{#t;#i;#a;#s;#n;#r=0;#e;static#o=`
1
+ "use strict";var o=require("@backstage/catalog-model"),c=require("@backstage/plugin-search-backend-node");class l extends c.DecoratorBase{#t;#i;#s;#a;#n;#r=0;#e;static#o=`
2
2
  query SelfReportedSkills {
3
3
  getPublicSelfReportedSkill {
4
4
  skill {
@@ -9,5 +9,5 @@
9
9
  user
10
10
  }
11
11
  }
12
- `;constructor({cache:t,catalog:e,logger:i,skillExchangeClient:r,auth:a}){super(),this.#i=t,this.#t=i,this.#a=e,this.#s=r,this.#n=a}async#l(){const t=await this.#s.doPost("/graphql",{query:o.#o});let e={};return t.ok?e=((await t.json()).data?.getPublicSelfReportedSkill||[]).reduce((i,{user:r,skill:a})=>({...i,[r.toLowerCase()]:[...i[r.toLowerCase()]||[],a]}),e):this.#t.error(`Error fetching self reported skills: ${await t.text()}`),e}async initialize(){this.#r=0,this.#e=await this.#l(),this.#t.info(`Found ${Object.keys(this.#e).length} skill profiles available for decorating`)}async getUserEntity(t){const e=`SkillProfileDecorator:${t}`,i=await this.#i.get(e);if(i)return i;const r=await this.#a.getEntityByRef(t,{credentials:await this.#n.getOwnServiceCredentials()}).catch(a=>{this.#t.error(`Error while retrieving entity with ref: ${t}`,a)});if(r)return await this.#i.set(e,JSON.parse(JSON.stringify(r))),r}async decorate(t){if(!this.#e||t.kind!=="User")return t;const e=t.authorization?.resourceRef||l.stringifyEntityRef({namespace:t.namespace,kind:t.kind,name:t.location.split("/").at(-1)}),i=await this.getUserEntity(e);if(!e||!i)return this.#t.error(`Could not find user entity to decorate, skipping over this document ${e}`),t;const r=this.#e[e.toLowerCase()]?.map(({name:s})=>s)??[],a=i.relations?.filter(({type:s})=>s==="memberOf")?.map(({targetRef:s})=>l.parseEntityRef(s)).filter(({kind:s})=>s==="group").map(({name:s})=>s),n=[];return t.text&&n.push(t.text),r.length&&n.push(r.join(", ")),a?.length&&n.push(a.join(", ")),t.text=n.join(" || "),t.displayName=i.spec.profile?.displayName,t.picture=i.spec.profile?.picture,t.name=i.metadata.name,t.skills=r,t.teams=a||[],this.#r++,t}async finalize(){this.#e=void 0,this.#t.info(`Decorated ${this.#r} documents with skill profile data`)}}exports.SkillProfileDecorator=o;
12
+ `;constructor({cache:t,catalog:e,logger:i,skillExchangeClient:r,auth:s}){super(),this.#i=t,this.#t=i,this.#s=e,this.#a=r,this.#n=s}async#l(){const t=await this.#a.doPost("/graphql",{query:l.#o});let e={};return t.ok?e=((await t.json()).data?.getPublicSelfReportedSkill||[]).reduce((i,{user:r,skill:s})=>({...i,[r.toLowerCase()]:[...i[r.toLowerCase()]||[],s]}),e):this.#t.error(`Error fetching self reported skills: ${await t.text()}`),e}async initialize(){this.#r=0,this.#e=await this.#l(),this.#t.info(`Found ${Object.keys(this.#e).length} skill profiles available for decorating`)}async getUserEntity(t){const e=`SkillProfileDecorator:${t}`,i=await this.#i.get(e);if(i)return i;const r=await this.#s.getEntityByRef(t,{credentials:await this.#n.getOwnServiceCredentials()}).catch(s=>{this.#t.error(`Error while retrieving entity with ref: ${t}`,s)});if(r)return await this.#i.set(e,JSON.parse(JSON.stringify(r))),r}async decorate(t){if(!this.#e||t.kind!=="User")return t;const e=t.authorization?.resourceRef||o.stringifyEntityRef({namespace:t.namespace,kind:t.kind,name:t.location.split("/").at(-1)}),i=await this.getUserEntity(e);if(!e||!i)return this.#t.error(`Could not find user entity to decorate, skipping over this document ${e}`),t;const r=this.#e[e.toLowerCase()]?.map(({name:a})=>a)??[],s=i.relations?.filter(({type:a})=>a==="memberOf")?.map(({targetRef:a})=>o.parseEntityRef(a)).filter(({kind:a})=>a==="group").map(o.stringifyEntityRef),n=[];return t.text&&n.push(t.text),r.length&&n.push(r.join(", ")),s?.length&&n.push(s.join(", ")),t.text=n.join(" || "),t.displayName=i.spec.profile?.displayName,t.picture=i.spec.profile?.picture,t.name=i.metadata.name,t.skills=r,t.teams=s||[],this.#r++,t}async finalize(){this.#e=void 0,this.#t.info(`Decorated ${this.#r} documents with skill profile data`)}}exports.SkillProfileDecorator=l;
13
13
  //# sourceMappingURL=SkillProfileDecorator.cjs.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spotify/backstage-plugin-search-backend-module-skill-exchange",
3
3
  "description": "The skill-exchange backend module for the search plugin.",
4
- "version": "0.3.0",
4
+ "version": "0.4.0",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "homepage": "https://backstage.spotify.com",
7
7
  "main": "dist/index.cjs.js",
@@ -13,7 +13,10 @@
13
13
  "backstage": {
14
14
  "role": "backend-plugin-module",
15
15
  "pluginId": "search",
16
- "pluginPackage": "@backstage/plugin-search-backend"
16
+ "pluginPackage": "@backstage/plugin-search-backend",
17
+ "features": {
18
+ ".": "@backstage/BackendFeature"
19
+ }
17
20
  },
18
21
  "scripts": {
19
22
  "start": "backstage-cli package start",
@@ -25,21 +28,20 @@
25
28
  "postpack": "backstage-cli package postpack"
26
29
  },
27
30
  "dependencies": {
28
- "@backstage/backend-defaults": "^0.7.0",
29
- "@backstage/backend-plugin-api": "^1.1.1",
31
+ "@backstage/backend-defaults": "^0.8.0",
32
+ "@backstage/backend-plugin-api": "^1.2.0",
30
33
  "@backstage/catalog-client": "^1.9.1",
31
34
  "@backstage/catalog-model": "^1.7.3",
32
35
  "@backstage/config": "^1.3.2",
33
- "@backstage/plugin-catalog-node": "^1.15.1",
34
- "@backstage/plugin-search-backend-node": "^1.3.7",
36
+ "@backstage/plugin-catalog-node": "^1.16.0",
37
+ "@backstage/plugin-search-backend-node": "^1.3.8",
35
38
  "@backstage/plugin-search-common": "^1.2.17",
36
- "@spotify/backstage-plugin-skill-exchange-common": "^0.2.5",
37
- "@spotify/backstage-plugin-skill-exchange-node": "^0.3.0"
39
+ "@spotify/backstage-plugin-skill-exchange-common": "^0.2.6",
40
+ "@spotify/backstage-plugin-skill-exchange-node": "^0.4.0"
38
41
  },
39
42
  "devDependencies": {
40
- "@backstage/backend-test-utils": "^1.2.1",
41
- "@backstage/cli": "^0.29.5",
42
- "node-fetch": "^2.6.7"
43
+ "@backstage/backend-test-utils": "^1.3.0",
44
+ "@backstage/cli": "^0.30.0"
43
45
  },
44
46
  "files": [
45
47
  "dist",