@spotify/backstage-plugin-search-backend-module-skill-exchange 0.4.6 → 0.5.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,28 @@
1
1
  # @spotify/backstage-plugin-search-backend-module-skill-exchange
2
2
 
3
+ ## 0.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependency `backstage` to `1.47.0`.
8
+ - Updated dependencies
9
+ - @spotify/backstage-plugin-skill-exchange-common@0.2.13
10
+ - @spotify/backstage-plugin-skill-exchange-node@0.6.1
11
+
12
+ ## 0.5.0
13
+
14
+ ### Minor Changes
15
+
16
+ - Refined user search results to display only current skill proficiencies
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependency `backstage` to `1.46.0`.
21
+ - Updated dependencies
22
+ - Updated dependencies
23
+ - @spotify/backstage-plugin-skill-exchange-common@0.2.12
24
+ - @spotify/backstage-plugin-skill-exchange-node@0.6.0
25
+
3
26
  ## 0.4.6
4
27
 
5
28
  ### Patch Changes
@@ -1,6 +1,7 @@
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=`
1
+ "use strict";var l=require("@backstage/catalog-model"),h=require("@backstage/plugin-search-backend-node");class o extends h.DecoratorBase{#t;#i;#s;#a;#n;#r=0;#e;static#l=`
2
2
  query SelfReportedSkills {
3
3
  getPublicSelfReportedSkill {
4
+ level
4
5
  skill {
5
6
  id
6
7
  name
@@ -9,5 +10,5 @@
9
10
  user
10
11
  }
11
12
  }
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
+ `;constructor({cache:t,catalog:i,logger:e,skillExchangeClient:r,auth:s}){super(),this.#i=t,this.#t=e,this.#s=i,this.#a=r,this.#n=s}async#o(){const t=await this.#a.doPost("/graphql",{query:o.#l});let i={};return t.ok?i=((await t.json()).data?.getPublicSelfReportedSkill||[]).filter(({level:e})=>e>0).reduce((e,{user:r,skill:s})=>({...e,[r.toLowerCase()]:[...e[r.toLowerCase()]||[],s]}),i):this.#t.error(`Error fetching self reported skills: ${await t.text()}`),i}async initialize(){this.#r=0,this.#e=await this.#o(),this.#t.info(`Found ${Object.keys(this.#e).length} skill profiles available for decorating`)}async getUserEntity(t){const i=`SkillProfileDecorator:${t}`,e=await this.#i.get(i);if(e)return e;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(i,JSON.parse(JSON.stringify(r))),r}async decorate(t){if(!this.#e||t.kind!=="User")return t;const i=t.authorization?.resourceRef||l.stringifyEntityRef({namespace:t.namespace,kind:t.kind,name:t.location.split("/").at(-1)}),e=await this.getUserEntity(i);if(!i||!e)return this.#t.error(`Could not find user entity to decorate, skipping over this document ${i}`),t;const r=this.#e[i.toLowerCase()]?.map(({name:a})=>a)??[],s=e.relations?.filter(({type:a})=>a==="memberOf")?.map(({targetRef:a})=>l.parseEntityRef(a)).filter(({kind:a})=>a==="group").map(l.stringifyEntityRef),c=s?.map(a=>l.parseEntityRef(a).name)||[],n=[];return t.text&&n.push(t.text),r.length&&n.push(r.join(", ")),s?.length&&(n.push(s.join(", ")),n.push(c.join(", "))),t.text=n.join(" || "),t.displayName=e.spec.profile?.displayName,t.picture=e.spec.profile?.picture,t.name=e.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=o;
13
14
  //# sourceMappingURL=SkillProfileDecorator.cjs.js.map
@@ -1,2 +1,2 @@
1
- "use strict";var s=require("@spotify/backstage-plugin-skill-exchange-node"),l=require("./SkillProfileDecorator.cjs.js");class i{types=["software-catalog"];#t;#e;#i;#r;#o;discovery;static fromConfig(t,e){return new i({config:t,...e})}constructor({cache:t,config:e,logger:c,discovery:r,catalog:a,auth:o}){this.#e=c,this.discovery=r,this.#t=t.withOptions({defaultTtl:60*60*1e3}),this.#i=a,this.#r=new s.SkillExchangeClient({config:e,discovery:r,auth:o}),this.#o=o}async getDecorator(){return new l.SkillProfileDecorator({cache:this.#t,catalog:this.#i,logger:this.#e,skillExchangeClient:this.#r,auth:this.#o})}}exports.SkillProfileDecoratorFactory=i;
1
+ "use strict";var s=require("@spotify/backstage-plugin-skill-exchange-node"),l=require("./SkillProfileDecorator.cjs.js");class i{types=["software-catalog"];#t;#e;#i;#r;#o;discovery;static fromConfig(t,e){return new i({config:t,...e})}constructor({cache:t,config:e,logger:c,discovery:r,catalog:a,auth:o}){this.#e=c,this.discovery=r,this.#t=t.withOptions({defaultTtl:3600*1e3}),this.#i=a,this.#r=new s.SkillExchangeClient({config:e,discovery:r,auth:o}),this.#o=o}async getDecorator(){return new l.SkillProfileDecorator({cache:this.#t,catalog:this.#i,logger:this.#e,skillExchangeClient:this.#r,auth:this.#o})}}exports.SkillProfileDecoratorFactory=i;
2
2
  //# sourceMappingURL=SkillProfileDecoratorFactory.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.4.6",
4
+ "version": "0.5.1",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "homepage": "https://backstage.spotify.com",
7
7
  "main": "dist/index.cjs.js",
@@ -28,20 +28,20 @@
28
28
  "postpack": "backstage-cli package postpack"
29
29
  },
30
30
  "dependencies": {
31
- "@backstage/backend-defaults": "^0.13.1",
32
- "@backstage/backend-plugin-api": "^1.5.0",
31
+ "@backstage/backend-defaults": "^0.15.0",
32
+ "@backstage/backend-plugin-api": "^1.6.1",
33
33
  "@backstage/catalog-client": "^1.12.1",
34
34
  "@backstage/catalog-model": "^1.7.6",
35
35
  "@backstage/config": "^1.3.6",
36
- "@backstage/plugin-catalog-node": "^1.20.0",
37
- "@backstage/plugin-search-backend-node": "^1.3.17",
36
+ "@backstage/plugin-catalog-node": "^1.20.1",
37
+ "@backstage/plugin-search-backend-node": "^1.4.0",
38
38
  "@backstage/plugin-search-common": "^1.2.21",
39
- "@spotify/backstage-plugin-skill-exchange-common": "^0.2.11",
40
- "@spotify/backstage-plugin-skill-exchange-node": "^0.5.3"
39
+ "@spotify/backstage-plugin-skill-exchange-common": "^0.2.13",
40
+ "@spotify/backstage-plugin-skill-exchange-node": "^0.6.1"
41
41
  },
42
42
  "devDependencies": {
43
- "@backstage/backend-test-utils": "^1.10.0",
44
- "@backstage/cli": "^0.34.5"
43
+ "@backstage/backend-test-utils": "^1.10.3",
44
+ "@backstage/cli": "^0.35.2"
45
45
  },
46
46
  "files": [
47
47
  "dist",