@saooti/octopus-sdk 41.8.3 → 41.8.4

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,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 41.8.4 (24/03/2026)
4
+
5
+ **Fix**
6
+
7
+ - **14291** - Correction vérification sur droits de transcription
8
+
3
9
  ## 41.8.3 (23/03/2026)
4
10
 
5
11
  **Fix**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saooti/octopus-sdk",
3
- "version": "41.8.3",
3
+ "version": "41.8.4",
4
4
  "private": false,
5
5
  "description": "Javascript SDK for using octopus",
6
6
  "author": "Saooti",
@@ -0,0 +1,47 @@
1
+ import { classicApi, ModuleApi } from ".yalc/@saooti/octopus-sdk";
2
+
3
+ /** State of the translation */
4
+ export enum TranslationState {
5
+ /** Translation in progress */
6
+ TRANSLATING = 'TRANSLATING',
7
+ /** Translation is finished */
8
+ FINISHED = 'FINISHED',
9
+ /** Translation has failed */
10
+ FAILED = 'FAILED',
11
+ /** AI limit has exceeded during translation */
12
+ AI_LIMIT_EXCEEDED = 'AI_LIMIT_EXCEEDED'
13
+ }
14
+
15
+ /** Data for one translation */
16
+ export interface TranslationData {
17
+ /** Language of translation */
18
+ language: string;
19
+ /** State of the translation */
20
+ state: TranslationState;
21
+ }
22
+
23
+ /** Translation data for one podcast. Contains data of all generated translations. */
24
+ export interface PodcastTranslationData {
25
+ /** ID of the podcast */
26
+ podcastId: number;
27
+ /** Native language of the podcast */
28
+ nativeLanguage: string;
29
+ /** Translation data */
30
+ translations: Array<TranslationData>;
31
+ }
32
+
33
+ /**
34
+ * Returns the translations defined on the podcast
35
+ * @param podcastId ID of the podcast
36
+ * @returns Promise containing the translation data for the podcast
37
+ */
38
+ async function getTranslations(podcastId: number): Promise<PodcastTranslationData> {
39
+ return classicApi.fetchData<PodcastTranslationData>({
40
+ api: ModuleApi.SPEECHTOTEXT,
41
+ path: 'transcription/' + podcastId
42
+ });
43
+ }
44
+
45
+ export const transcriptionApi = {
46
+ getTranslations
47
+ };
@@ -66,7 +66,7 @@ export const useRights = () => {
66
66
  }
67
67
 
68
68
  function canDuplicatePodcast(): boolean {
69
- // Same as creationm but notably without PODCAST_CRUD and
69
+ // Same as creation but notably without PODCAST_CRUD and
70
70
  // RESTRICTED_ANIMATION
71
71
  return roleContainsAny(
72
72
  'ADMIN',
@@ -149,8 +149,16 @@ export const useRights = () => {
149
149
  return roleContainsAny('ADMIN', 'ORGANISATION');
150
150
  }
151
151
 
152
- function canEditTranscript(): boolean {
153
- return roleContainsAny('ADMIN', 'ORGANISATION', 'PRODUCTION', 'RESTRICTED_PRODUCTION');
152
+ function canEditTranscript(podcast: Podcast): boolean {
153
+ if(roleContainsAny('ADMIN', 'ORGANISATION', 'PRODUCTION')) {
154
+ return true;
155
+ }
156
+
157
+ if (roleContainsAny('RESTRICTED_PRODUCTION', 'RESTRICTED_ANIMATION')) {
158
+ return podcast.createdByUserId === authStore.authProfile?.userId;
159
+ }
160
+
161
+ return false;
154
162
  }
155
163
 
156
164
  function canSeeHistory(): boolean {
@@ -245,6 +245,31 @@ describe('useRights', () => {
245
245
  });
246
246
  });
247
247
 
248
+ describe('canEditTranscript', () => {
249
+ const ownPodcast = { podcastId: 1, createdByUserId: 'test-user-123' } as Podcast;
250
+ const otherPodcast = { podcastId: 2, createdByUserId: 'other-user' } as Podcast;
251
+
252
+ ['ADMIN', 'ORGANISATION', 'PRODUCTION'].forEach(role => {
253
+ it(`allows ${role} to edit transcript of any podcast`, async () => {
254
+ await setup([role]);
255
+ expect(useRights().canEditTranscript(otherPodcast)).toBe(true);
256
+ });
257
+ });
258
+
259
+ ['RESTRICTED_PRODUCTION', 'RESTRICTED_ANIMATION'].forEach(role => {
260
+ it(`${role} can only edit transcript of own podcast`, async () => {
261
+ await setup([role]);
262
+ expect(useRights().canEditTranscript(ownPodcast)).toBe(true);
263
+ expect(useRights().canEditTranscript(otherPodcast)).toBe(false);
264
+ });
265
+ });
266
+
267
+ it('denies unrelated roles', async () => {
268
+ await setup(['PODCAST_CRUD']);
269
+ expect(useRights().canEditTranscript(ownPodcast)).toBe(false);
270
+ });
271
+ });
272
+
248
273
  describe('Other permissions', () => {
249
274
  describe('canEditCodeInsertPlayer', () => {
250
275
  ['ADMIN', 'ORGANISATION'].forEach(role => {