🏷️(service-worker) retype the doc creation in SW

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.
This commit is contained in:
Anthony LC
2024-10-08 16:08:58 +02:00
committed by Anthony LC
parent dcbef9630e
commit 638e1aedb7
2 changed files with 27 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ export interface Access {
user: User;
abilities: {
destroy: boolean;
partial_update: boolean;
retrieve: boolean;
set_role_to: Role[];
update: boolean;
@@ -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;

View File

@@ -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';
@@ -181,7 +186,8 @@ export class ApiPlugin implements WorkboxPlugin {
.clone()
.json()) as Partial<Doc>;
const newResponse = {
const newResponse: Doc = {
title: '',
...bodyMutate,
id: uuid,
content: '',
@@ -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}/`,