@spotify/backstage-plugin-search-backend-module-skill-exchange 0.2.1 → 0.2.2

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,16 @@
1
1
  # @spotify/backstage-plugin-search-backend-module-skill-exchange
2
2
 
3
+ ## 0.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Minor fixes and improvements
8
+ - Update to Backstage v1.31.1
9
+ - Updated dependencies
10
+ - Updated dependencies
11
+ - @spotify/backstage-plugin-skill-exchange-node@0.2.2
12
+ - @spotify/backstage-plugin-skill-exchange-common@0.2.1
13
+
3
14
  ## 0.2.1
4
15
 
5
16
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var g=require("@backstage/backend-common"),n=require("@backstage/backend-plugin-api"),f=require("@backstage/plugin-catalog-node/alpha"),p=require("@backstage/plugin-search-backend-node/alpha"),h=require("@backstage/catalog-model"),k=require("@backstage/plugin-search-backend-node"),y=require("@spotify/backstage-plugin-skill-exchange-node");class c extends k.DecoratorBase{#e;#t;#a;#s;#i;#r=0;#o;static#n=`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var h=require("@backstage/backend-common"),n=require("@backstage/backend-plugin-api"),d=require("@backstage/plugin-catalog-node/alpha"),f=require("@backstage/plugin-search-backend-node/alpha"),g=require("@backstage/catalog-model"),p=require("@backstage/plugin-search-backend-node"),y=require("@spotify/backstage-plugin-skill-exchange-node");class c extends p.DecoratorBase{#e;#t;#r;#a;#i;#o=0;#s;static#n=`
2
2
  query SelfReportedSkills {
3
3
  getPublicSelfReportedSkill {
4
4
  skill {
@@ -9,5 +9,5 @@
9
9
  user
10
10
  }
11
11
  }
12
- `;constructor({cacheClient:e,catalogClient:t,logger:i,skillExchangeClient:a,auth:r}){super(),this.#t=e,this.#e=i,this.#a=t,this.#s=a,this.#i=r}async#c(){const e=await this.#s.doPost("/graphql",{query:c.#n});let t={};return e.ok?t=((await e.json()).data?.getPublicSelfReportedSkill||[]).reduce((i,{user:a,skill:r})=>({...i,[a.toLowerCase()]:[...i[a.toLowerCase()]||[],r]}),t):this.#e.error(`Error fetching self reported skills: ${await e.text()}`),t}async initialize(){this.#r=0,this.#o=await this.#c(),this.#e.info(`Found ${Object.keys(this.#o).length} skill profiles available for decorating`)}async getUserEntity(e){const t=`SkillProfileDecorator:${e}`,i=await this.#t.get(t),{token:a}=await this.#i.getPluginRequestToken({onBehalfOf:await this.#i.getOwnServiceCredentials(),targetPluginId:"catalog"});if(i)return i;const r=await this.#a.getEntityByRef(e,{token:a}).catch(o=>{this.#e.error(`Error while retrieving entity with ref: ${e}`,o)});if(r)return await this.#t.set(t,JSON.parse(JSON.stringify(r))),r}async decorate(e){if(!this.#o||e.kind!=="User")return e;const t=e.authorization?.resourceRef||h.stringifyEntityRef({namespace:e.namespace,kind:e.kind,name:e.location.split("/").at(-1)}),i=await this.getUserEntity(t);if(!t||!i)return this.#e.error(`Could not find user entity to decorate, skipping over this document ${t}`),e;const a=this.#o[t.toLowerCase()]?.map(({name:s})=>s)??[],r=i.relations?.filter(({type:s})=>s==="memberOf")?.map(({targetRef:s})=>h.parseEntityRef(s)).filter(({kind:s})=>s==="group").map(({name:s})=>s),o=[];return e.text&&o.push(e.text),a.length&&o.push(a.join(", ")),r?.length&&o.push(r.join(", ")),e.text=o.join(" || "),e.displayName=i.spec.profile?.displayName,e.picture=i.spec.profile?.picture,e.name=i.metadata.name,e.skills=a,e.teams=r||[],this.#r++,e}async finalize(){this.#o=void 0,this.#e.info(`Decorated ${this.#r} documents with skill profile data`)}}class l{types=["software-catalog"];#e;#t;#a;#s;#i;#r;discovery;static fromConfig(e,t){return new l({config:e,...t})}constructor({cache:e,config:t,logger:i,discovery:a,tokenManager:r,catalog:o,auth:s}){this.#t=i,this.discovery=a,this.#e=e.getClient({defaultTtl:60*60*1e3}),this.#a=o,this.#s=new y.SkillExchangeClient({config:t,discovery:a,tokenManager:r}),this.#i=r,this.#r=s}async getDecorator(){return new c({cacheClient:this.#e,catalogClient:this.#a,logger:this.#t,skillExchangeClient:this.#s,tokenManager:this.#i,auth:this.#r})}}const v=n.createBackendModule({pluginId:"search",moduleId:"skill-exchange",register(u){u.registerInit({deps:{config:n.coreServices.rootConfig,cache:n.coreServices.cache,discovery:n.coreServices.discovery,logger:n.coreServices.logger,tokenManager:n.coreServices.tokenManager,envScheduler:n.coreServices.scheduler,auth:n.coreServices.auth,catalog:f.catalogServiceRef,registry:p.searchIndexRegistryExtensionPoint},async init({registry:e,config:t,cache:i,discovery:a,logger:r,tokenManager:o,catalog:s,auth:d}){e.addDecorator({factory:l.fromConfig(t,{catalog:s,discovery:a,auth:d,tokenManager:o,logger:g.loggerToWinstonLogger(r),cache:g.cacheToPluginCacheManager(i)})})}})}});exports.default=v;
12
+ `;constructor({cacheClient:e,catalogClient:t,logger:i,skillExchangeClient:r,auth:a}){super(),this.#t=e,this.#e=i,this.#r=t,this.#a=r,this.#i=a}async#c(){const e=await this.#a.doPost("/graphql",{query:c.#n});let t={};return e.ok?t=((await e.json()).data?.getPublicSelfReportedSkill||[]).reduce((i,{user:r,skill:a})=>({...i,[r.toLowerCase()]:[...i[r.toLowerCase()]||[],a]}),t):this.#e.error(`Error fetching self reported skills: ${await e.text()}`),t}async initialize(){this.#o=0,this.#s=await this.#c(),this.#e.info(`Found ${Object.keys(this.#s).length} skill profiles available for decorating`)}async getUserEntity(e){const t=`SkillProfileDecorator:${e}`,i=await this.#t.get(t),{token:r}=await this.#i.getPluginRequestToken({onBehalfOf:await this.#i.getOwnServiceCredentials(),targetPluginId:"catalog"});if(i)return i;const a=await this.#r.getEntityByRef(e,{token:r}).catch(s=>{this.#e.error(`Error while retrieving entity with ref: ${e}`,s)});if(a)return await this.#t.set(t,JSON.parse(JSON.stringify(a))),a}async decorate(e){if(!this.#s||e.kind!=="User")return e;const t=e.authorization?.resourceRef||g.stringifyEntityRef({namespace:e.namespace,kind:e.kind,name:e.location.split("/").at(-1)}),i=await this.getUserEntity(t);if(!t||!i)return this.#e.error(`Could not find user entity to decorate, skipping over this document ${t}`),e;const r=this.#s[t.toLowerCase()]?.map(({name:o})=>o)??[],a=i.relations?.filter(({type:o})=>o==="memberOf")?.map(({targetRef:o})=>g.parseEntityRef(o)).filter(({kind:o})=>o==="group").map(({name:o})=>o),s=[];return e.text&&s.push(e.text),r.length&&s.push(r.join(", ")),a?.length&&s.push(a.join(", ")),e.text=s.join(" || "),e.displayName=i.spec.profile?.displayName,e.picture=i.spec.profile?.picture,e.name=i.metadata.name,e.skills=r,e.teams=a||[],this.#o++,e}async finalize(){this.#s=void 0,this.#e.info(`Decorated ${this.#o} documents with skill profile data`)}}class l{types=["software-catalog"];#e;#t;#r;#a;#i;discovery;static fromConfig(e,t){return new l({config:e,...t})}constructor({cache:e,config:t,logger:i,discovery:r,catalog:a,auth:s}){this.#t=i,this.discovery=r,this.#e=e.getClient({defaultTtl:60*60*1e3}),this.#r=a,this.#a=new y.SkillExchangeClient({config:t,discovery:r,auth:s}),this.#i=s}async getDecorator(){return new c({cacheClient:this.#e,catalogClient:this.#r,logger:this.#t,skillExchangeClient:this.#a,auth:this.#i})}}const k=n.createBackendModule({pluginId:"search",moduleId:"skill-exchange",register(u){u.registerInit({deps:{config:n.coreServices.rootConfig,cache:n.coreServices.cache,discovery:n.coreServices.discovery,logger:n.coreServices.logger,envScheduler:n.coreServices.scheduler,auth:n.coreServices.auth,catalog:d.catalogServiceRef,registry:f.searchIndexRegistryExtensionPoint},async init({registry:e,config:t,cache:i,discovery:r,logger:a,catalog:s,auth:o}){e.addDecorator({factory:l.fromConfig(t,{catalog:s,discovery:r,auth:o,logger:h.loggerToWinstonLogger(a),cache:h.cacheToPluginCacheManager(i)})})}})}});exports.default=k;
13
13
  //# sourceMappingURL=index.cjs.js.map
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
2
2
 
3
3
  /** @public */
4
- declare const searchModuleSkillExchange: _backstage_backend_plugin_api.BackendFeatureCompat;
4
+ declare const searchModuleSkillExchange: _backstage_backend_plugin_api.BackendFeature;
5
5
 
6
6
  export { searchModuleSkillExchange as default };
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.1",
4
+ "version": "0.2.2",
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,21 @@
25
25
  "postpack": "backstage-cli package postpack"
26
26
  },
27
27
  "dependencies": {
28
- "@backstage/backend-common": "^0.24.1",
29
- "@backstage/backend-plugin-api": "^0.8.1",
30
- "@backstage/catalog-client": "^1.6.6",
31
- "@backstage/catalog-model": "^1.6.0",
28
+ "@backstage/backend-common": "^0.25.0",
29
+ "@backstage/backend-plugin-api": "^1.0.0",
30
+ "@backstage/catalog-client": "^1.7.0",
31
+ "@backstage/catalog-model": "^1.7.0",
32
32
  "@backstage/config": "^1.2.0",
33
- "@backstage/plugin-catalog-node": "^1.12.6",
34
- "@backstage/plugin-search-backend-node": "^1.3.1",
33
+ "@backstage/plugin-catalog-node": "^1.13.0",
34
+ "@backstage/plugin-search-backend-node": "^1.3.2",
35
35
  "@backstage/plugin-search-common": "^1.2.14",
36
- "@spotify/backstage-plugin-skill-exchange-common": "^0.2.0",
37
- "@spotify/backstage-plugin-skill-exchange-node": "^0.2.1",
36
+ "@spotify/backstage-plugin-skill-exchange-common": "^0.2.1",
37
+ "@spotify/backstage-plugin-skill-exchange-node": "^0.2.2",
38
38
  "winston": "^3.2.1"
39
39
  },
40
40
  "devDependencies": {
41
- "@backstage/backend-test-utils": "^0.5.1",
42
- "@backstage/cli": "^0.27.0",
41
+ "@backstage/backend-test-utils": "^1.0.0",
42
+ "@backstage/cli": "^0.27.1",
43
43
  "node-fetch": "^2.6.7"
44
44
  },
45
45
  "files": [