@spotify/backstage-plugin-search-backend-module-skill-exchange 0.2.4 → 0.3.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,27 @@
1
1
  # @spotify/backstage-plugin-search-backend-module-skill-exchange
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Remove support for the legacy backend system.
8
+
9
+ ### Patch Changes
10
+
11
+ - Update to Backstage `v1.35.0`
12
+ - Updated dependencies
13
+ - @spotify/backstage-plugin-skill-exchange-node@0.3.0
14
+ - @spotify/backstage-plugin-skill-exchange-common@0.2.5
15
+
16
+ ## 0.2.5
17
+
18
+ ### Patch Changes
19
+
20
+ - Update to Backstage `v1.34.0`
21
+ - Updated dependencies
22
+ - @spotify/backstage-plugin-skill-exchange-common@0.2.4
23
+ - @spotify/backstage-plugin-skill-exchange-node@0.2.5
24
+
3
25
  ## 0.2.4
4
26
 
5
27
  ### Patch 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;#s;#n;#r;#a=0;#e;static#o=`
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=`
2
2
  query SelfReportedSkills {
3
3
  getPublicSelfReportedSkill {
4
4
  skill {
@@ -9,5 +9,5 @@
9
9
  user
10
10
  }
11
11
  }
12
- `;constructor({cacheClient:t,catalogClient:e,logger:i,skillExchangeClient:a,auth:r}){super(),this.#i=t,this.#t=i,this.#s=e,this.#n=a,this.#r=r}async#l(){const t=await this.#n.doPost("/graphql",{query:o.#o});let e={};return t.ok?e=((await t.json()).data?.getPublicSelfReportedSkill||[]).reduce((i,{user:a,skill:r})=>({...i,[a.toLowerCase()]:[...i[a.toLowerCase()]||[],r]}),e):this.#t.error(`Error fetching self reported skills: ${await t.text()}`),e}async initialize(){this.#a=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),{token:a}=await this.#r.getPluginRequestToken({onBehalfOf:await this.#r.getOwnServiceCredentials(),targetPluginId:"catalog"});if(i)return i;const r=await this.#s.getEntityByRef(t,{token:a}).catch(n=>{this.#t.error(`Error while retrieving entity with ref: ${t}`,n)});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 a=this.#e[e.toLowerCase()]?.map(({name:s})=>s)??[],r=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),a.length&&n.push(a.join(", ")),r?.length&&n.push(r.join(", ")),t.text=n.join(" || "),t.displayName=i.spec.profile?.displayName,t.picture=i.spec.profile?.picture,t.name=i.metadata.name,t.skills=a,t.teams=r||[],this.#a++,t}async finalize(){this.#e=void 0,this.#t.info(`Decorated ${this.#a} documents with skill profile data`)}}exports.SkillProfileDecorator=o;
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;
13
13
  //# sourceMappingURL=SkillProfileDecorator.cjs.js.map
@@ -1,2 +1,2 @@
1
- "use strict";var a=require("@spotify/backstage-plugin-skill-exchange-node"),s=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:l,auth:o}){this.#e=c,this.discovery=r,this.#t=t.getClient({defaultTtl:60*60*1e3}),this.#i=l,this.#r=new a.SkillExchangeClient({config:e,discovery:r,auth:o}),this.#o=o}async getDecorator(){return new s.SkillProfileDecorator({cacheClient:this.#t,catalogClient: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: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;
2
2
  //# sourceMappingURL=SkillProfileDecoratorFactory.cjs.js.map
@@ -1,2 +1,2 @@
1
- "use strict";var r=require("@backstage/backend-common"),e=require("@backstage/backend-plugin-api"),n=require("@backstage/plugin-catalog-node/alpha"),h=require("@backstage/plugin-search-backend-node/alpha");require("@backstage/catalog-model"),require("@backstage/plugin-search-backend-node");var u=require("./decorator/SkillProfileDecoratorFactory.cjs.js");const d=e.createBackendModule({pluginId:"search",moduleId:"skill-exchange",register(c){c.registerInit({deps:{config:e.coreServices.rootConfig,cache:e.coreServices.cache,discovery:e.coreServices.discovery,logger:e.coreServices.logger,envScheduler:e.coreServices.scheduler,auth:e.coreServices.auth,catalog:n.catalogServiceRef,registry:h.searchIndexRegistryExtensionPoint},async init({registry:o,config:a,cache:i,discovery:g,logger:l,catalog:t,auth:s}){o.addDecorator({factory:u.SkillProfileDecoratorFactory.fromConfig(a,{catalog:t,discovery:g,auth:s,logger:r.loggerToWinstonLogger(l),cache:r.cacheToPluginCacheManager(i)})})}})}});exports.searchModuleSkillExchange=d;
1
+ "use strict";var e=require("@backstage/backend-plugin-api"),s=require("@backstage/plugin-catalog-node"),n=require("@backstage/plugin-search-backend-node/alpha");require("@backstage/catalog-model"),require("@backstage/plugin-search-backend-node");var u=require("./decorator/SkillProfileDecoratorFactory.cjs.js");const d=e.createBackendModule({pluginId:"search",moduleId:"skill-exchange",register(r){r.registerInit({deps:{config:e.coreServices.rootConfig,cache:e.coreServices.cache,discovery:e.coreServices.discovery,logger:e.coreServices.logger,envScheduler:e.coreServices.scheduler,auth:e.coreServices.auth,catalog:s.catalogServiceRef,registry:n.searchIndexRegistryExtensionPoint},async init({registry:c,config:o,cache:i,discovery:a,logger:l,catalog:t,auth:g}){c.addDecorator({factory:u.SkillProfileDecoratorFactory.fromConfig(o,{catalog:t,discovery:a,auth:g,logger:l,cache:i})})}})}});exports.searchModuleSkillExchange=d;
2
2
  //# sourceMappingURL=module.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.2.4",
4
+ "version": "0.3.0",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "homepage": "https://backstage.spotify.com",
7
7
  "main": "dist/index.cjs.js",
@@ -25,21 +25,20 @@
25
25
  "postpack": "backstage-cli package postpack"
26
26
  },
27
27
  "dependencies": {
28
- "@backstage/backend-common": "^0.25.0",
29
- "@backstage/backend-plugin-api": "^1.0.2",
30
- "@backstage/catalog-client": "^1.8.0",
31
- "@backstage/catalog-model": "^1.7.1",
32
- "@backstage/config": "^1.3.0",
33
- "@backstage/plugin-catalog-node": "^1.14.0",
34
- "@backstage/plugin-search-backend-node": "^1.3.5",
35
- "@backstage/plugin-search-common": "^1.2.15",
36
- "@spotify/backstage-plugin-skill-exchange-common": "^0.2.3",
37
- "@spotify/backstage-plugin-skill-exchange-node": "^0.2.4",
38
- "winston": "^3.2.1"
28
+ "@backstage/backend-defaults": "^0.7.0",
29
+ "@backstage/backend-plugin-api": "^1.1.1",
30
+ "@backstage/catalog-client": "^1.9.1",
31
+ "@backstage/catalog-model": "^1.7.3",
32
+ "@backstage/config": "^1.3.2",
33
+ "@backstage/plugin-catalog-node": "^1.15.1",
34
+ "@backstage/plugin-search-backend-node": "^1.3.7",
35
+ "@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
38
  },
40
39
  "devDependencies": {
41
- "@backstage/backend-test-utils": "^1.1.0",
42
- "@backstage/cli": "^0.29.2",
40
+ "@backstage/backend-test-utils": "^1.2.1",
41
+ "@backstage/cli": "^0.29.5",
43
42
  "node-fetch": "^2.6.7"
44
43
  },
45
44
  "files": [