From ffac670e0ee45495cbdb940847552fea57d155ac Mon Sep 17 00:00:00 2001 From: srosset81 Date: Fri, 13 Dec 2024 17:50:10 +0100 Subject: [PATCH] Rename PodService to StorageService --- src/middleware/packages/auth/mixins/auth.js | 2 +- .../ldp/services/container/actions/createAndAttach.js | 2 +- .../packages/ldp/services/registry/actions/getUri.js | 2 +- src/middleware/packages/ldp/services/registry/index.js | 2 +- .../packages/ldp/services/resource/actions/generateId.js | 2 +- src/middleware/packages/solid/index.js | 2 +- .../notifications/channels/notification-channel.mixin.js | 2 +- .../packages/solid/services/{pod.js => storage.js} | 6 +++--- .../packages/solid/services/type-index/type-indexes.js | 4 ++-- .../solid/services/type-index/type-registrations.js | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) rename src/middleware/packages/solid/services/{pod.js => storage.js} (95%) diff --git a/src/middleware/packages/auth/mixins/auth.js b/src/middleware/packages/auth/mixins/auth.js index 5a5c23fd9..b2e02894a 100644 --- a/src/middleware/packages/auth/mixins/auth.js +++ b/src/middleware/packages/auth/mixins/auth.js @@ -162,7 +162,7 @@ const AuthMixin = { const baseUrlTrailing = urlJoin(this.settings.baseUrl, '/'); webId = webId || baseUrlTrailing + username; - const podUrl = await ctx.call('pod.getUrl', { webId }); + const podUrl = await ctx.call('solid-storage.getUrl', { webId }); // Check if capabilityUri is within the resource owner's pod if (!webId?.startsWith(baseUrlTrailing) || !capabilityUri?.startsWith(podUrl)) { diff --git a/src/middleware/packages/ldp/services/container/actions/createAndAttach.js b/src/middleware/packages/ldp/services/container/actions/createAndAttach.js index af6e5b881..f6a8e8aac 100644 --- a/src/middleware/packages/ldp/services/container/actions/createAndAttach.js +++ b/src/middleware/packages/ldp/services/container/actions/createAndAttach.js @@ -25,7 +25,7 @@ module.exports = { if (this.settings.podProvider && !webId) throw new Error(`The webId param is required in Pod provider config`); const rootContainerUri = this.settings.podProvider - ? await ctx.call('pod.getUrl', { webId }) + ? await ctx.call('solid-storage.getUrl', { webId }) : urlJoin(this.settings.baseUrl, '/'); const containerPath = containerUri.replace(rootContainerUri, '/'); diff --git a/src/middleware/packages/ldp/services/registry/actions/getUri.js b/src/middleware/packages/ldp/services/registry/actions/getUri.js index b3f123528..4b5dd27e4 100644 --- a/src/middleware/packages/ldp/services/registry/actions/getUri.js +++ b/src/middleware/packages/ldp/services/registry/actions/getUri.js @@ -14,7 +14,7 @@ module.exports = { const { path, webId } = ctx.params; if (this.settings.podProvider) { - const podUrl = await ctx.call('pod.getUrl', { webId }); + const podUrl = await ctx.call('solid-storage.getUrl', { webId }); return urlJoin(podUrl, path); } else { return urlJoin(this.settings.baseUrl, path); diff --git a/src/middleware/packages/ldp/services/registry/index.js b/src/middleware/packages/ldp/services/registry/index.js index 5d95cb435..d5a755e43 100644 --- a/src/middleware/packages/ldp/services/registry/index.js +++ b/src/middleware/packages/ldp/services/registry/index.js @@ -42,7 +42,7 @@ module.exports = { const { webId, accountData } = ctx.params; // We want to add user's containers only in Pod provider config if (this.settings.podProvider) { - const podUrl = await ctx.call('pod.getUrl', { webId }); + const podUrl = await ctx.call('solid-storage.getUrl', { webId }); const registeredContainers = await this.actions.list({ dataset: accountData.username }, { parentCtx: ctx }); // Go through each registered containers for (const container of Object.values(registeredContainers)) { diff --git a/src/middleware/packages/ldp/services/resource/actions/generateId.js b/src/middleware/packages/ldp/services/resource/actions/generateId.js index 707bf2e39..de6659ae4 100644 --- a/src/middleware/packages/ldp/services/resource/actions/generateId.js +++ b/src/middleware/packages/ldp/services/resource/actions/generateId.js @@ -24,7 +24,7 @@ module.exports = { if ((!this.settings.resourcesWithContainerPath || !containerUri) && !isContainer) { // Use the root container URI containerUri = this.settings.podProvider - ? await ctx.call('pod.getUrl', { webId: urlJoin(this.settings.baseUrl, ctx.meta.dataset) }) + ? await ctx.call('solid-storage.getUrl', { webId: urlJoin(this.settings.baseUrl, ctx.meta.dataset) }) : this.settings.baseUrl; } diff --git a/src/middleware/packages/solid/index.js b/src/middleware/packages/solid/index.js index 3712f8f91..ef283f1fd 100644 --- a/src/middleware/packages/solid/index.js +++ b/src/middleware/packages/solid/index.js @@ -1,5 +1,5 @@ module.exports = { - PodService: require('./services/pod'), + StorageService: require('./services/storage'), NotificationsProviderService: require('./services/notifications/provider'), NotificationsListenerService: require('./services/notifications/listener'), TypeIndexesService: require('./services/type-index/type-indexes') diff --git a/src/middleware/packages/solid/services/notifications/channels/notification-channel.mixin.js b/src/middleware/packages/solid/services/notifications/channels/notification-channel.mixin.js index c79a9bec7..f93c2aab7 100644 --- a/src/middleware/packages/solid/services/notifications/channels/notification-channel.mixin.js +++ b/src/middleware/packages/solid/services/notifications/channels/notification-channel.mixin.js @@ -43,7 +43,7 @@ module.exports = { } } }, - dependencies: ['api', 'pod'], + dependencies: ['api'], async created() { if (!this.settings.baseUrl) throw new Error('The baseUrl setting is required'); if (this.settings.sendOrReceive !== 'receive' && this.settings.sendOrReceive !== 'send') diff --git a/src/middleware/packages/solid/services/pod.js b/src/middleware/packages/solid/services/storage.js similarity index 95% rename from src/middleware/packages/solid/services/pod.js rename to src/middleware/packages/solid/services/storage.js index 22d566f99..0e40ba0bb 100644 --- a/src/middleware/packages/solid/services/pod.js +++ b/src/middleware/packages/solid/services/storage.js @@ -4,14 +4,14 @@ const { pim } = require('@semapps/ontologies'); /** @type {import('moleculer').ServiceSchema} */ module.exports = { - name: 'pod', + name: 'solid-storage', settings: { baseUrl: null, pathName: 'data' }, dependencies: ['ontologies', 'ldp.registry'], async started() { - if (!this.settings.baseUrl) throw new Error('The baseUrl setting of the pod service is required'); + if (!this.settings.baseUrl) throw new Error('The baseUrl setting of the solid-storage service is required'); await this.broker.call('ontologies.register', pim); @@ -27,7 +27,7 @@ module.exports = { actions: { async create(ctx) { const { username } = ctx.params; - if (!username) throw new Error('Cannot create pod without a username'); + if (!username) throw new Error('Cannot create Solid storage without a username'); await ctx.call('triplestore.dataset.create', { dataset: username, diff --git a/src/middleware/packages/solid/services/type-index/type-indexes.js b/src/middleware/packages/solid/services/type-index/type-indexes.js index 51086fa0a..d4133fa6b 100644 --- a/src/middleware/packages/solid/services/type-index/type-indexes.js +++ b/src/middleware/packages/solid/services/type-index/type-indexes.js @@ -82,7 +82,7 @@ module.exports = { const accounts = await ctx.call('auth.account.find'); for (const { webId } of accounts) { this.logger.info(`Migrating ${webId}...`); - const podUrl = await ctx.call('pod.getUrl', { webId }); + const podUrl = await ctx.call('solid-storage.getUrl', { webId }); await this.actions.createAndAttachToWebId({ webId }, { parentCtx: ctx }); // Go through each registered container and persist them @@ -122,7 +122,7 @@ module.exports = { // Go through each registered container for (const container of Object.values(registeredContainers)) { if (container.podsContainer !== true) { - const podUrl = await ctx.call('pod.getUrl', { webId }); + const podUrl = await ctx.call('solid-storage.getUrl', { webId }); const containerUri = urlJoin(podUrl, container.path); for (const type of arrayOf(container.acceptedTypes)) { this.logger.info(`Registering ${containerUri} with type ${type}...`); diff --git a/src/middleware/packages/solid/services/type-index/type-registrations.js b/src/middleware/packages/solid/services/type-index/type-registrations.js index 9461c1efd..3eda97080 100644 --- a/src/middleware/packages/solid/services/type-index/type-registrations.js +++ b/src/middleware/packages/solid/services/type-index/type-registrations.js @@ -337,7 +337,7 @@ module.exports = { const registeredContainers = await ctx.call('ldp.registry.list'); // Go through each Pod for (const { webId } of accounts) { - const podUrl = await ctx.call('pod.getUrl', { webId }); + const podUrl = await ctx.call('solid-storage.getUrl', { webId }); // Go through each registered container for (const container of Object.values(registeredContainers)) { if (container.podsContainer !== true) {