@@ -6,17 +6,28 @@ import {
66 startTransaction
77} from '@evershop/postgres-query-builder' ;
88import { getConnection } from '../../../../lib/postgres/connection.js' ;
9- import { hookable , hookBefore , hookAfter } from '../../../../lib/util/hookable.js' ;
9+ import {
10+ hookable ,
11+ hookBefore ,
12+ hookAfter
13+ } from '../../../../lib/util/hookable.js' ;
14+ import type {
15+ CmsPageRow ,
16+ CmsPageDescriptionRow
17+ } from '../../../../types/db/index.js' ;
1018
11- async function deletePageData ( uuid , connection ) {
19+ async function deletePageData ( uuid , connection ) : Promise < void > {
1220 await del ( 'cms_page' ) . where ( 'uuid' , '=' , uuid ) . execute ( connection ) ;
1321}
1422/**
1523 * Delete page service. This service will delete a page with all related data
1624 * @param {String } uuid
1725 * @param {Object } context
1826 */
19- async function deletePage ( uuid , context ) {
27+ const _deletePage = async function deletePage (
28+ uuid ,
29+ context
30+ ) : Promise < CmsPageRow & CmsPageDescriptionRow > {
2031 const connection = await getConnection ( ) ;
2132 await startTransaction ( connection ) ;
2233 try {
@@ -43,24 +54,24 @@ async function deletePage(uuid, context) {
4354 await rollback ( connection ) ;
4455 throw e ;
4556 }
46- }
57+ } ;
4758
48- export default async ( uuid , context ) => {
59+ export async function deletePage (
60+ uuid ,
61+ context
62+ ) : Promise < CmsPageRow & CmsPageDescriptionRow > {
4963 // Make sure the context is either not provided or is an object
5064 if ( context && typeof context !== 'object' ) {
5165 throw new Error ( 'Context must be an object' ) ;
5266 }
53- const page = await hookable ( deletePage , context ) ( uuid , context ) ;
67+ const page = await hookable ( _deletePage , context ) ( uuid , context ) ;
5468 return page ;
55- } ;
69+ }
5670
5771export function hookBeforeDeletePageData (
5872 callback : (
5973 this : Record < string , any > ,
60- ...args : [
61- uuid : any ,
62- connection : any
63- ]
74+ ...args : [ uuid : any , connection : any ]
6475 ) => void | Promise < void > ,
6576 priority : number = 10
6677) : void {
@@ -70,10 +81,7 @@ export function hookBeforeDeletePageData(
7081export function hookAfterDeletePageData (
7182 callback : (
7283 this : Record < string , any > ,
73- ...args : [
74- uuid : any ,
75- connection : any
76- ]
84+ ...args : [ uuid : any , connection : any ]
7785 ) => void | Promise < void > ,
7886 priority : number = 10
7987) : void {
@@ -83,10 +91,7 @@ export function hookAfterDeletePageData(
8391export function hookBeforeDeletePage (
8492 callback : (
8593 this : Record < string , any > ,
86- ...args : [
87- uuid : any ,
88- context : any
89- ]
94+ ...args : [ uuid : any , context : any ]
9095 ) => void | Promise < void > ,
9196 priority : number = 10
9297) : void {
@@ -96,10 +101,7 @@ export function hookBeforeDeletePage(
96101export function hookAfterDeletePage (
97102 callback : (
98103 this : Record < string , any > ,
99- ...args : [
100- uuid : any ,
101- context : any
102- ]
104+ ...args : [ uuid : any , context : any ]
103105 ) => void | Promise < void > ,
104106 priority : number = 10
105107) : void {
0 commit comments