Skip to content

Commit 01427cf

Browse files
committed
chore: format
1 parent 933a629 commit 01427cf

19 files changed

+54
-54
lines changed

.github/workflows/issue.yml

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
issue_comment:
77
types: [created, edited]
88

9-
109
jobs:
1110
notify-discord:
1211
runs-on: ubuntu-latest

.github/workflows/npm-publish.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ env:
1515
false: 🔴
1616

1717
jobs:
18-
1918
release:
2019
runs-on: ubuntu-latest
2120
steps:
@@ -25,7 +24,7 @@ jobs:
2524
uses: halvardssm/[email protected]
2625
with:
2726
token: ${{ secrets.GITHUB_TOKEN }}
28-
path: "./package.json" # optional, will use ./package.json by default
27+
path: './package.json' # optional, will use ./package.json by default
2928

3029
- run: |
3130
echo 'Release created: ${{steps.release.outputs.release_created}}' # 'true' or 'false'
@@ -43,7 +42,6 @@ jobs:
4342
Release : ${{ env[steps.release.outputs.release_created] }}
4443
Tag: ${{ steps.version.outputs.release_tag }}
4544
46-
4745
publish-npm:
4846
needs: release
4947
runs-on: ubuntu-latest

index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import attachmentManager from './services/main.js'
22

3-
43
export { configure } from './configure.js'
54
export { Attachment } from './src/attachments/attachment.js'
65
export { attachment } from './src/decorators/attachment.js'

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,4 @@
8686
"volta": {
8787
"node": "20.17.0"
8888
}
89-
}
89+
}

src/adapters/exif.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import { fileTypeFromBuffer, fileTypeFromFile } from 'file-type'
1414
import { bufferToTempFile, cleanObject, use } from '../utils/helpers.js'
1515
import { attachmentManager } from '../../index.js'
1616

17-
export const exif = async (input: Input): Promise<Exif|undefined> => {
18-
17+
export const exif = async (input: Input): Promise<Exif | undefined> => {
1918
let fileType
2019
let buffer
2120

@@ -119,9 +118,8 @@ async function imageExif(buffer: Buffer) {
119118
return cleanObject(data)
120119
}
121120

122-
123121
async function videoExif(input: Input) {
124-
return new Promise<Exif|undefined>(async (resolve) => {
122+
return new Promise<Exif | undefined>(async (resolve) => {
125123
const ffmpeg = await use('fluent-ffmpeg')
126124

127125
let file = input
@@ -148,7 +146,7 @@ async function videoExif(input: Input) {
148146
dimension: {
149147
width: data.streams[0].width,
150148
height: data.streams[0].height,
151-
}
149+
},
152150
})
153151
})
154152
})

src/attachment_manager.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ export class AttachmentManager {
9393
}
9494
}
9595

96-
async computeUrl(attachment: AttachmentType | AttachmentBase, signedUrlOptions?: SignedURLOptions) {
96+
async computeUrl(
97+
attachment: AttachmentType | AttachmentBase,
98+
signedUrlOptions?: SignedURLOptions
99+
) {
97100
const disk = attachment.getDisk()
98101
const fileVisibility = await disk.getVisibility(attachment.path!)
99102

src/attachments/attachment.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ export class Attachment extends AttachmentBase implements AttachmentInterface {
7171
return super.getUrl()
7272
}
7373

74-
getSignedUrl(variantNameOrOptions?: string | SignedURLOptions, signedUrlOptions?: SignedURLOptions) {
74+
getSignedUrl(
75+
variantNameOrOptions?: string | SignedURLOptions,
76+
signedUrlOptions?: SignedURLOptions
77+
) {
7578
let variantName: string | undefined
7679
let options: SignedURLOptions | undefined = signedUrlOptions
7780

@@ -111,7 +114,7 @@ export class Attachment extends AttachmentBase implements AttachmentInterface {
111114
this.variants.forEach((v) => {
112115
v.setOptions({
113116
...this.options,
114-
variants: []
117+
variants: [],
115118
})
116119
})
117120
}

src/attachments/attachment_base.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class AttachmentBase implements AttachmentBaseInterface {
8888
if (this.url) {
8989
return {
9090
...this.toObject(),
91-
url: this.url
91+
url: this.url,
9292
}
9393
}
9494

src/converters/autodetect_converter.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ import ImageConverter from './image_converter.js'
1313
import VideoThumnailConverter from './video_thumbnail_converter.js'
1414

1515
export default class AutodetectConverter extends Converter {
16-
1716
async handle({ input, options }: ConverterAttributes) {
18-
1917
let converter
2018
let fileType
2119

@@ -34,7 +32,7 @@ export default class AutodetectConverter extends Converter {
3432
if (converter) {
3533
return await converter.handle({
3634
input,
37-
options
35+
options,
3836
})
3937
}
4038
}

src/converters/document_thumbnail_converter.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ export default class DocumentThumbnailConverter extends Converter {
2424
const converter = new ImageConverter()
2525
return await converter.handle({
2626
input: outputBuffer,
27-
options
27+
options,
2828
})
2929
}
3030

3131
return outputBuffer
32-
} catch(err) {
32+
} catch (err) {
3333
logger.error({ err })
3434
}
3535
}
@@ -44,7 +44,7 @@ export default class DocumentThumbnailConverter extends Converter {
4444
childProcessOptions: {
4545
timeout: 60 * 1000,
4646
},
47-
binaryPaths
47+
binaryPaths,
4848
})
4949

5050
if (Buffer.isBuffer(input)) {

src/converters/image_converter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default class ImageConverter extends Converter {
3131
.toBuffer()
3232

3333
return buffer
34-
} catch(err) {
34+
} catch (err) {
3535
logger.error({ err })
3636
}
3737
}

src/converters/pdf_thumbnail_converter.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ export default class PdfThumbnailConverter extends Converter {
2727
const converter = new ImageConverter()
2828
return await converter.handle({
2929
input: filePath,
30-
options
30+
options,
3131
})
3232
}
3333

3434
return filePath
35-
} catch(err) {
35+
} catch (err) {
3636
logger.error({ err })
3737
}
3838
}

src/converters/video_thumbnail_converter.ts

+9-11
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import ImageConverter from './image_converter.js'
1717
import { bufferToTempFile, use } from '../utils/helpers.js'
1818

1919
export default class VideoThumbnailConvert extends Converter {
20-
2120
async handle({ input, options }: ConverterAttributes) {
2221
try {
2322
const ffmpeg = await use('fluent-ffmpeg')
@@ -27,12 +26,12 @@ export default class VideoThumbnailConvert extends Converter {
2726
const converter = new ImageConverter()
2827
return await converter.handle({
2928
input: filePath,
30-
options
29+
options,
3130
})
3231
} else {
3332
return filePath
3433
}
35-
} catch(err) {
34+
} catch (err) {
3635
logger.error({ err })
3736
}
3837
}
@@ -44,7 +43,7 @@ export default class VideoThumbnailConvert extends Converter {
4443
file = await bufferToTempFile(input)
4544
}
4645

47-
return new Promise<string|false>((resolve) => {
46+
return new Promise<string | false>((resolve) => {
4847
const folder = os.tmpdir()
4948
const filename = `${cuid()}.png`
5049

@@ -57,13 +56,12 @@ export default class VideoThumbnailConvert extends Converter {
5756
}
5857

5958
ff.screenshots({
60-
count: 1,
61-
filename,
62-
folder,
63-
})
64-
.on('end', () => {
65-
resolve(path.join(folder, filename))
66-
})
59+
count: 1,
60+
filename,
61+
folder,
62+
}).on('end', () => {
63+
resolve(path.join(folder, filename))
6764
})
65+
})
6866
}
6967
}

src/decorators/attachment.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ export const attachment = (options?: LucidOptions) => {
2121
const defaultConfig = attachmentManager.getConfig()
2222
const defaultOptions = {
2323
meta: defaultConfig.meta !== undefined ? defaultConfig.meta : defaultOptionsDecorator.meta,
24-
rename: defaultConfig.rename !== undefined ? defaultConfig.rename : defaultOptionsDecorator.rename,
25-
preComputeUrl: defaultConfig.preComputeUrl !== undefined ? defaultConfig.preComputeUrl : defaultOptionsDecorator.preComputeUrl,
24+
rename:
25+
defaultConfig.rename !== undefined ? defaultConfig.rename : defaultOptionsDecorator.rename,
26+
preComputeUrl:
27+
defaultConfig.preComputeUrl !== undefined
28+
? defaultConfig.preComputeUrl
29+
: defaultOptionsDecorator.preComputeUrl,
2630
}
2731

2832
if (!options || options?.meta === undefined) {

src/errors.ts

+3-12
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,14 @@ export const E_CANNOT_CREATE_ATTACHMENT = createError<[key: string]>(
6262
/**
6363
* Is not a Buffer
6464
*/
65-
export const E_ISNOT_BUFFER = createError(
66-
'Is not a Buffer',
67-
'E_ISNOT_BUFFER'
68-
)
65+
export const E_ISNOT_BUFFER = createError('Is not a Buffer', 'E_ISNOT_BUFFER')
6966

7067
/**
7168
* Is not a Base64
7269
*/
73-
export const E_ISNOT_BASE64 = createError(
74-
'Is not a Base64',
75-
'E_ISNOT_BASE64'
76-
)
70+
export const E_ISNOT_BASE64 = createError('Is not a Base64', 'E_ISNOT_BASE64')
7771

7872
/**
7973
* Unable to read file
8074
*/
81-
export const ENOENT = createError(
82-
'File not found',
83-
'ENOENT'
84-
)
75+
export const ENOENT = createError('File not found', 'ENOENT')

src/mixins/attachmentable.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ import {
2424
generateVariants,
2525
preComputeUrl,
2626
} from '../utils/actions.js'
27-
import { clone, getAttachmentAttributeNames, getDirtyAttachmentAttributeNames } from '../utils/helpers.js'
27+
import {
28+
clone,
29+
getAttachmentAttributeNames,
30+
getDirtyAttachmentAttributeNames,
31+
} from '../utils/helpers.js'
2832
import { defaultStateAttributeMixin } from '../utils/default_values.js'
2933

3034
export const Attachmentable = <Model extends NormalizeConstructor<typeof BaseModel>>(

src/types/attachment.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ export type Attachment = AttachmentBase & {
4343
createVariant(key: string, input: Input): Promise<Variant>
4444
getVariant(variantName: string): Variant | undefined
4545
getUrl(variantName?: string): Promise<string>
46-
getSignedUrl(variantNameOrOptions?: string | SignedURLOptions, signedUrlOptions?: SignedURLOptions): Promise<string>
46+
getSignedUrl(
47+
variantNameOrOptions?: string | SignedURLOptions,
48+
signedUrlOptions?: SignedURLOptions
49+
): Promise<string>
4750
toObject(): AttachmentAttributes
4851
}
4952

src/utils/default_values.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const defaultOptionsDecorator = {
1111
preComputeUrl: false,
1212
variants: [],
1313
meta: true,
14-
rename: true
14+
rename: true,
1515
}
1616

1717
export const defaultStateAttributeMixin = {

src/utils/helpers.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ export function getAttachmentAttributeNames(modelInstance: ModelWithAttachment)
2727

2828
export function getDirtyAttachmentAttributeNames(modelInstance: ModelWithAttachment) {
2929
return Object.keys(modelInstance.$dirty).filter(
30-
(attr) => modelInstance.$dirty[attr] instanceof Attachment || modelInstance.$original[attr] instanceof Attachment
30+
(attr) =>
31+
modelInstance.$dirty[attr] instanceof Attachment ||
32+
modelInstance.$original[attr] instanceof Attachment
3133
)
3234
}
3335

@@ -99,7 +101,7 @@ export async function use(module: string) {
99101

100102
return result
101103
} catch (err) {
102-
throw new errors.E_MISSING_PACKAGE([module], { cause: err})
104+
throw new errors.E_MISSING_PACKAGE([module], { cause: err })
103105
}
104106
}
105107

0 commit comments

Comments
 (0)