🏷️(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:
@@ -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;
|
||||
|
||||
@@ -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}/`,
|
||||
|
||||
Reference in New Issue
Block a user