diff --git a/packages/resource-discussions/src/graph.ts b/packages/resource-discussions/src/graph.ts index 682f8ca..ce739b3 100644 --- a/packages/resource-discussions/src/graph.ts +++ b/packages/resource-discussions/src/graph.ts @@ -151,6 +151,10 @@ export class ResourceGraph { socialResourceTypes.profile, socialResourceValues.id ) + this.graph.addDirectedEdge( + socialResourceTypes.space, + socialResourceValues.id + ) /** * Chain diff --git a/packages/resource-discussions/src/types/social.ts b/packages/resource-discussions/src/types/social.ts index 16fcc8a..bddb85e 100644 --- a/packages/resource-discussions/src/types/social.ts +++ b/packages/resource-discussions/src/types/social.ts @@ -1,10 +1,11 @@ import { socialApps } from '../constants' -type SocialResourceType = 'post' | 'profile' +type SocialResourceType = 'post' | 'profile' | 'space' export const socialResourceTypes = { post: 'post', - profile: 'profile' + profile: 'profile', + space: 'space' } as const export const socialResourceValueRequiredState = { @@ -19,6 +20,8 @@ export type SocialResourceValue = R extends 'post' ? { id: string } : R extends 'profile' ? { id: string } + : R extends 'space' + ? { id: string } : never type SocialPostResourceType = { @@ -29,10 +32,15 @@ type SocialProfileResourceType = { resourceType: 'profile' resourceValue: SocialResourceValue<'profile'> } +type SocialSpaceResourceType = { + resourceType: 'space' + resourceValue: SocialResourceValue<'space'> +} type SocialResourceTypeValue = | SocialPostResourceType | SocialProfileResourceType + | SocialSpaceResourceType export type SocialSchemaParameters = { schema: 'social' } & { app: (typeof socialApps)[number] | string diff --git a/packages/resource-discussions/tests/resourceLinking.test.ts b/packages/resource-discussions/tests/resourceLinking.test.ts index 2f5f69a..297ef54 100644 --- a/packages/resource-discussions/tests/resourceLinking.test.ts +++ b/packages/resource-discussions/tests/resourceLinking.test.ts @@ -139,4 +139,19 @@ describe('Resource Linking Unit', () => { 'Provided parameters for resource are invalid. Please, check field "schema".' ) }) + + test('SocialResource should ingest parameters with "schema === social"', () => { + const resourceValue: Resource = new Resource({ + schema: 'social', + app: 'subid', + resourceType: 'space', + resourceValue: { + id: 'spaceId' + } + }) + + expect(resourceValue.toResourceId()).toEqual( + 'social://app:subid/resourceType:space/id:spaceId' + ) + }) })