Skip to content

Commit

Permalink
🏷️(service-worker) retype the doc creation in SW
Browse files Browse the repository at this point in the history
Recent changes made the doc creation in SW outdated.
This commit retype the doc creation in SW.
We adapt the main type to fit the new doc type.
  • Loading branch information
AntoLC committed Oct 8, 2024
1 parent dcbef96 commit 638e1ae
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface Access {
user: User;
abilities: {
destroy: boolean;
partial_update: boolean;
retrieve: boolean;
set_role_to: Role[];
update: boolean;
Expand Down Expand Up @@ -38,6 +39,7 @@ export interface Doc {
created_at: string;
updated_at: string;
abilities: {
attachment_upload: true;
destroy: boolean;
link_configuration: boolean;
manage_accesses: boolean;
Expand Down
28 changes: 25 additions & 3 deletions src/frontend/apps/impress/src/features/service-worker/ApiPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { WorkboxPlugin } from 'workbox-core';

import { Doc, DocsResponse } from '@/features/docs';
import {
Doc,
DocsResponse,
LinkReach,
Role,
} from '@/features/docs/doc-management';

import { DBRequest, DocsDB } from './DocsDB';
import { RequestSerializer } from './RequestSerializer';
Expand Down Expand Up @@ -181,7 +186,8 @@ export class ApiPlugin implements WorkboxPlugin {
.clone()
.json()) as Partial<Doc>;

const newResponse = {
const newResponse: Doc = {
title: '',
...bodyMutate,
id: uuid,
content: '',
Expand All @@ -197,13 +203,29 @@ export class ApiPlugin implements WorkboxPlugin {
update: true,
partial_update: true,
retrieve: true,
attachment_upload: true,
},
accesses: [
{
id: 'dummy-id',
role: Role.OWNER,
team: '',
user: {
id: 'dummy-id',
email: 'dummy-email',
},
abilities: {
destroy: false,
partial_update: false,
retrieve: true,
set_role_to: [],
update: false,
},
},
],
} as Doc;
link_reach: LinkReach.RESTRICTED,
link_role: 'reader',
};

await DocsDB.cacheResponse(
`${request.url}${uuid}/`,
Expand Down

0 comments on commit 638e1ae

Please sign in to comment.