diff --git a/src/lib/api/adapters/crew.adapter.ts b/src/lib/api/adapters/crew.adapter.ts index d05515b4..1e9b3c08 100644 --- a/src/lib/api/adapters/crew.adapter.ts +++ b/src/lib/api/adapters/crew.adapter.ts @@ -1,6 +1,7 @@ import { BaseAdapter } from './base.adapter' import { DEFAULT_ADAPTER_CONFIG } from './config' -import type { RequestOptions } from './types' +import type { RequestOptions, PaginatedResponse } from './types' +import type { Party } from '$lib/types/api/party' import type { Crew, CrewMembership, @@ -31,6 +32,23 @@ export class CrewAdapter extends BaseAdapter { return response.crew } + /** + * Get parties shared with the user's crew + */ + async getSharedParties( + page = 1, + perPage = 20, + options?: RequestOptions + ): Promise<{ parties: Party[]; meta: { page: number; totalPages: number; count: number; perPage: number } }> { + return this.request<{ parties: Party[]; meta: { page: number; totalPages: number; count: number; perPage: number } }>( + '/crew/shared_parties', + { + ...options, + params: { page, per_page: perPage } + } + ) + } + /** * Create a new crew (user becomes captain) */ diff --git a/src/lib/api/adapters/party.adapter.ts b/src/lib/api/adapters/party.adapter.ts index 53f26d8a..0e8eb07a 100644 --- a/src/lib/api/adapters/party.adapter.ts +++ b/src/lib/api/adapters/party.adapter.ts @@ -12,6 +12,7 @@ import { BaseAdapter } from './base.adapter' import type { AdapterOptions, PaginatedResponse } from './types' import { DEFAULT_ADAPTER_CONFIG } from './config' import type { Party, GridWeapon, GridCharacter, GridSummon } from '$lib/types/api/party' +import type { PartyShare } from '$lib/types/api/partyShare' /** * Parameters for creating a new party @@ -409,6 +410,28 @@ export class PartyAdapter extends BaseAdapter { this.clearCache(`/parties/${shortcode}`) } + /** + * Share a party with the current user's crew + * @param partyId - The party's UUID + */ + async shareWithCrew(partyId: string): Promise { + const response = await this.request<{ share: PartyShare }>(`/parties/${partyId}/shares`, { + method: 'POST' + }) + return response.share + } + + /** + * Remove a party share + * @param partyId - The party's UUID + * @param shareId - The share's UUID to remove + */ + async removeShare(partyId: string, shareId: string): Promise { + await this.request(`/parties/${partyId}/shares/${shareId}`, { + method: 'DELETE' + }) + } + /** * Clears the cache for party-related data */ diff --git a/src/lib/types/api/party.ts b/src/lib/types/api/party.ts index de224d17..10c60cb9 100644 --- a/src/lib/types/api/party.ts +++ b/src/lib/types/api/party.ts @@ -16,6 +16,7 @@ import type { } from './entities' import type { GridArtifact, CollectionArtifact } from './artifact' import type { AugmentSkill, Befoulment } from './weaponStatModifier' +import type { PartyShare } from './partyShare' // Grid item types - these are the junction tables between Party and entities @@ -139,6 +140,8 @@ export interface Party { user?: User sourceParty?: Party remixes?: Party[] + /** Shares for this party (only present for owner) */ + shares?: PartyShare[] // Local client state localId?: string diff --git a/src/lib/types/api/partyShare.ts b/src/lib/types/api/partyShare.ts new file mode 100644 index 00000000..c3a27d4a --- /dev/null +++ b/src/lib/types/api/partyShare.ts @@ -0,0 +1,10 @@ +// PartyShare type for party sharing with crews/groups +// Based on PartyShareBlueprint from Rails API + +export interface PartyShare { + id: string + shareableType: string + shareableId: string + shareableName?: string + createdAt: string +}