@spotify/backstage-plugin-search-backend-module-skill-exchange 0.2.2 → 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,12 +1,20 @@
|
|
|
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
|
+
|
|
3
12
|
## 0.2.2
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
6
15
|
|
|
7
16
|
- Minor fixes and improvements
|
|
8
17
|
- Update to Backstage v1.31.1
|
|
9
|
-
- Updated dependencies
|
|
10
18
|
- Updated dependencies
|
|
11
19
|
- @spotify/backstage-plugin-skill-exchange-node@0.2.2
|
|
12
20
|
- @spotify/backstage-plugin-skill-exchange-common@0.2.1
|
|
@@ -62,7 +70,6 @@
|
|
|
62
70
|
### Patch Changes
|
|
63
71
|
|
|
64
72
|
- Updated backstage dependencies to `v1.26.0`
|
|
65
|
-
- Updated dependencies
|
|
66
73
|
- Updated dependencies
|
|
67
74
|
- @spotify/backstage-plugin-skill-exchange-node@0.1.1
|
|
68
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
|
|
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: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;
|
|
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
|
|
@@ -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.
|
|
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",
|
|
@@ -26,20 +26,20 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@backstage/backend-common": "^0.25.0",
|
|
29
|
-
"@backstage/backend-plugin-api": "^1.0.
|
|
30
|
-
"@backstage/catalog-client": "^1.7.
|
|
29
|
+
"@backstage/backend-plugin-api": "^1.0.1",
|
|
30
|
+
"@backstage/catalog-client": "^1.7.1",
|
|
31
31
|
"@backstage/catalog-model": "^1.7.0",
|
|
32
32
|
"@backstage/config": "^1.2.0",
|
|
33
|
-
"@backstage/plugin-catalog-node": "^1.13.
|
|
34
|
-
"@backstage/plugin-search-backend-node": "^1.3.
|
|
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.
|
|
37
|
-
"@spotify/backstage-plugin-skill-exchange-node": "^0.2.
|
|
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": "^1.0.
|
|
42
|
-
"@backstage/cli": "^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": [
|