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

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,24 @@
1
1
  # @spotify/backstage-plugin-search-backend-module-skill-exchange
2
2
 
3
+ ## 0.2.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Update to Backstage v1.32.0
8
+ - Updated dependencies
9
+ - @spotify/backstage-plugin-skill-exchange-common@0.2.2
10
+ - @spotify/backstage-plugin-skill-exchange-node@0.2.3
11
+
12
+ ## 0.2.2
13
+
14
+ ### Patch Changes
15
+
16
+ - Minor fixes and improvements
17
+ - Update to Backstage v1.31.1
18
+ - Updated dependencies
19
+ - @spotify/backstage-plugin-skill-exchange-node@0.2.2
20
+ - @spotify/backstage-plugin-skill-exchange-common@0.2.1
21
+
3
22
  ## 0.2.1
4
23
 
5
24
  ### Patch Changes
@@ -51,7 +70,6 @@
51
70
  ### Patch Changes
52
71
 
53
72
  - Updated backstage dependencies to `v1.26.0`
54
- - Updated dependencies
55
73
  - Updated dependencies
56
74
  - @spotify/backstage-plugin-skill-exchange-node@0.1.1
57
75
  - @spotify/backstage-plugin-skill-exchange-common@0.1.1
@@ -0,0 +1,13 @@
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=`
2
+ query SelfReportedSkills {
3
+ getPublicSelfReportedSkill {
4
+ skill {
5
+ id
6
+ name
7
+ category
8
+ }
9
+ user
10
+ }
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;
13
+ //# sourceMappingURL=SkillProfileDecorator.cjs.js.map
@@ -0,0 +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;
2
+ //# sourceMappingURL=SkillProfileDecoratorFactory.cjs.js.map
package/dist/index.cjs.js CHANGED
@@ -1,13 +1,2 @@
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=`
2
- query SelfReportedSkills {
3
- getPublicSelfReportedSkill {
4
- skill {
5
- id
6
- name
7
- category
8
- }
9
- user
10
- }
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;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./module.cjs.js");exports.default=e.searchModuleSkillExchange;
13
2
  //# 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 };
@@ -0,0 +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;
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.1",
4
+ "version": "0.2.3",
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.1",
30
+ "@backstage/catalog-client": "^1.7.1",
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.1",
34
+ "@backstage/plugin-search-backend-node": "^1.3.3",
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.2",
37
+ "@spotify/backstage-plugin-skill-exchange-node": "^0.2.3",
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.1",
42
+ "@backstage/cli": "^0.28.0",
43
43
  "node-fetch": "^2.6.7"
44
44
  },
45
45
  "files": [