diff --git a/forge/routes/api/deviceLive.js b/forge/routes/api/deviceLive.js
index 5859b8131a..5e497de420 100644
--- a/forge/routes/api/deviceLive.js
+++ b/forge/routes/api/deviceLive.js
@@ -409,6 +409,14 @@ module.exports = async function (app) {
updateSettingsForCatalogue('@flowfuse-certified-nodes', cat)
}
}
+ if (team.getProperty('extraCatalogues', null)) {
+ for (const cat of team.getProperty('extraCatalogues')) {
+ const catURL = new URL(cat)
+ if (response.palette.catalogues.indexOf(catURL.toString()) === -1) {
+ response.palette.catalogues.push(catURL.toString())
+ }
+ }
+ }
} catch (err) {
app.log.error(`Failed to configure platform npm registry for device ${err.toString()}`)
}
diff --git a/forge/routes/api/project.js b/forge/routes/api/project.js
index deee511e1f..5999cabb40 100644
--- a/forge/routes/api/project.js
+++ b/forge/routes/api/project.js
@@ -1000,6 +1000,14 @@ module.exports = async function (app) {
updateSettingsForCatalogue('@flowfuse-certified-nodes', cat)
}
}
+ if (team.getProperty('extraCatalogues', null)) {
+ for (const cat of team.TeamType.properties.extraCatalogues) {
+ const catURL = new URL(cat)
+ if (settings.settings.palette.catalogue.indexOf(catURL.toString()) === -1) {
+ settings.settings.palette.catalogue.push(catURL.toString())
+ }
+ }
+ }
} catch (err) {
app.log.error('Failed to configure platform npm registry for project', err)
}
diff --git a/frontend/src/pages/admin/TeamTypes/dialogs/TeamTypeEditDialog.vue b/frontend/src/pages/admin/TeamTypes/dialogs/TeamTypeEditDialog.vue
index c7fe961a2a..da74c082cd 100644
--- a/frontend/src/pages/admin/TeamTypes/dialogs/TeamTypeEditDialog.vue
+++ b/frontend/src/pages/admin/TeamTypes/dialogs/TeamTypeEditDialog.vue
@@ -179,6 +179,10 @@
Persistent File storage limit (Mb)
Persistent Context storage limit (Mb)
+
+ Extra Certified Nodes Catalogue URLs, one per line, must be https://
+
+
@@ -336,6 +340,11 @@ export default {
this.input.autoStack.hours[`${hours[d]}`] = true
}
}
+ if (teamType.properties?.extraCatalogues) {
+ this.input.properties.extraCatalogues = teamType.properties.extraCatalogues.join('\n')
+ } else {
+ this.input.properties.extraCatalogues = ''
+ }
} else {
this.editDisabled = false
this.input = {
@@ -359,7 +368,8 @@ export default {
allowDisable: true,
days: [],
hours: []
- }
+ },
+ extraCatalogues: ''
},
autoStack: {
days: {},
@@ -422,7 +432,8 @@ export default {
days: {},
hours: {}
},
- enableAllFeatures: false
+ enableAllFeatures: false,
+ extraCatalogues: ''
}
},
errors: {},
@@ -440,6 +451,17 @@ export default {
})
},
formValid () {
+ const extraCataloguesArray = this.input.properties.extraCatalogues.split('\n').filter(cat => cat.trim().length > 0)
+ for (const cat of extraCataloguesArray) {
+ try {
+ const u = new URL(cat)
+ if (u.protocol !== 'https:') {
+ return false
+ }
+ } catch (err) {
+ return false
+ }
+ }
return (this.input.name)
},
isEditingExisting () {
@@ -543,6 +565,18 @@ export default {
}
}
+ opts.properties.extraCatalogues = []
+ const extraCataloguesArray = this.input.properties.extraCatalogues.split('\n').filter(cat => cat.trim().length > 0)
+ for (const cat of extraCataloguesArray) {
+ try {
+ // eslint-disable-next-line no-unused-vars
+ const u = new URL(cat)
+ opts.properties.extraCatalogues.push(cat)
+ } catch (err) {
+ // Ignore invalid URL
+ }
+ }
+
if (this.teamType) {
// For edits, we cannot touch the properties
// TODO: what can be edited when in use?
diff --git a/test/unit/forge/routes/api/device_spec.js b/test/unit/forge/routes/api/device_spec.js
index 2d9441a457..286c0823c7 100644
--- a/test/unit/forge/routes/api/device_spec.js
+++ b/test/unit/forge/routes/api/device_spec.js
@@ -1907,6 +1907,34 @@ describe('Device API', async function () {
`)
})
})
+ describe('Extra Catalogues from TeamType', function () {
+ async function setTeamTypeCatalogues (cats) {
+ const defaultTeamTypeProperties = app.defaultTeamType.properties
+ defaultTeamTypeProperties.extraCatalogues = cats
+ app.defaultTeamType.properties = defaultTeamTypeProperties
+ await app.defaultTeamType.save()
+ }
+ let cats
+ before(async function () {
+ const defaultTeamTypeProperties = app.defaultTeamType.properties
+ cats = defaultTeamTypeProperties.extraCatalogues
+ })
+ afterEach(async function () {
+ const defaultTeamTypeProperties = app.defaultTeamType.properties
+ defaultTeamTypeProperties.extraCatalogues = cats
+ app.defaultTeamType.properties = defaultTeamTypeProperties
+ await app.defaultTeamType.save()
+ })
+ it('should include catalogues from TeamType', async function () {
+ await setTeamTypeCatalogues([
+ 'https://example.com/cat-from-team-type.json'
+ ])
+ const device = await createDevice({ name: 'CertifiedNodes', type: '', team: TestObjects.ATeam.hashid, as: TestObjects.tokens.alice })
+ const liveSettings = await getLiveSettings(device)
+ liveSettings.palette.should.have.property('catalogues')
+ liveSettings.palette.catalogues.should.containEql('https://example.com/cat-from-team-type.json')
+ })
+ })
})
describe('device remote editor (unlicensed)', function () {
diff --git a/test/unit/forge/routes/api/project_spec.js b/test/unit/forge/routes/api/project_spec.js
index 41ecf4ab9d..09edcdae6b 100644
--- a/test/unit/forge/routes/api/project_spec.js
+++ b/test/unit/forge/routes/api/project_spec.js
@@ -1111,6 +1111,109 @@ describe('Project API', function () {
`)
})
})
+ describe('Apply TeamType extra Catalogues', function () {
+ async function setTeamTypeCatalogues (cats) {
+ const defaultTeamTypeProperties = app.defaultTeamType.properties
+ defaultTeamTypeProperties.extraCatalogues = cats
+ app.defaultTeamType.properties = defaultTeamTypeProperties
+ await app.defaultTeamType.save()
+ }
+ let cats
+ before(async function () {
+ const defaultTeamTypeProperties = app.defaultTeamType.properties
+ cats = defaultTeamTypeProperties.extraCatalogues
+ })
+ afterEach(async function () {
+ const defaultTeamTypeProperties = app.defaultTeamType.properties
+ defaultTeamTypeProperties.extraCatalogues = cats
+ app.defaultTeamType.properties = defaultTeamTypeProperties
+ await app.defaultTeamType.save()
+ })
+ it('Should add extra catalogue to project', async function () {
+ await setTeamTypeCatalogues([
+ 'https://example.com/team-type-cat.json'
+ ])
+
+ const projectName = generateProjectName()
+ const response = await app.inject({
+ method: 'POST',
+ url: '/api/v1/projects',
+ payload: {
+ name: projectName,
+ applicationId: TestObjects.ApplicationA.hashid,
+ projectType: TestObjects.projectType1.hashid,
+ template: TestObjects.template1.hashid,
+ stack: TestObjects.stack1.hashid
+ },
+ cookies: { sid: TestObjects.tokens.alice }
+ })
+ response.statusCode.should.equal(200)
+ const result = response.json()
+
+ const newProject = await app.db.models.Project.byId(result.id)
+ const newAccessToken = (await newProject.refreshAuthTokens()).token
+ const runtimeSettings = (await app.inject({
+ method: 'GET',
+ url: `/api/v1/projects/${newProject.id}/settings`,
+ headers: {
+ authorization: `Bearer ${newAccessToken}`
+ }
+ })).json()
+
+ const settings = runtimeSettings.settings
+ settings.should.have.property('palette')
+ settings.palette.should.have.property('npmrc')
+ settings.palette.should.have.property('catalogue')
+ settings.palette.catalogue.should.containEql('https://example.com/team-type-cat.json')
+ })
+ it('Should add extra catalogue to project only if not present', async function () {
+ await setTeamTypeCatalogues([
+ 'https://example.com/team-type-cat.json',
+ 'https://EXAMPLE.com/team-type-cat.json',
+ 'https://example.com/cat2.json'
+ ])
+
+ const projectName = generateProjectName()
+ const response = await app.inject({
+ method: 'POST',
+ url: '/api/v1/projects',
+ payload: {
+ name: projectName,
+ applicationId: TestObjects.ApplicationA.hashid,
+ projectType: TestObjects.projectType1.hashid,
+ template: TestObjects.template1.hashid,
+ stack: TestObjects.stack1.hashid
+ },
+ cookies: { sid: TestObjects.tokens.alice }
+ })
+ response.statusCode.should.equal(200)
+ const result = response.json()
+
+ const newProject = await app.db.models.Project.byId(result.id)
+ const newAccessToken = (await newProject.refreshAuthTokens()).token
+ const runtimeSettings = (await app.inject({
+ method: 'GET',
+ url: `/api/v1/projects/${newProject.id}/settings`,
+ headers: {
+ authorization: `Bearer ${newAccessToken}`
+ }
+ })).json()
+
+ const settings = runtimeSettings.settings
+ settings.should.have.property('palette')
+ settings.palette.should.have.property('npmrc')
+ settings.palette.should.have.property('catalogue')
+ settings.palette.catalogue.should.have.length(6)
+ settings.palette.catalogue.should.containEql('https://example.com/team-type-cat.json')
+ settings.palette.catalogue.should.containEql('https://example.com/cat2.json')
+ let index = settings.palette.catalogue.indexOf('https://example.com/team-type-cat.json')
+ settings.palette.catalogue.splice(index, 1)
+ index = settings.palette.catalogue.indexOf('https://example.com/cat2.json')
+ settings.palette.catalogue.splice(index, 1)
+ settings.palette.catalogue.should.not.containEql('https://example.com/cat2.json')
+ settings.palette.catalogue.should.have.length(4)
+ })
+ })
})
describe('Apply Flow Blueprint', function () {