Skip to content

Commit 53d3a08

Browse files
authored
style(formatting): cleaned code formatting using prettier (#67)
Commit changes code style only, no logic or functionality changed re: #55
1 parent 408adac commit 53d3a08

File tree

102 files changed

+2292
-1335
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+2292
-1335
lines changed

cli/config-manage.ts

+54-16
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ if (fs.existsSync(deployConfig)) {
1515
const configFromFile: DeployConfig = JSON.parse(
1616
fs.readFileSync(deployConfig, 'utf8')
1717
)
18-
console.log(formatText('A configuration already exists.', { bold: true, backgroundColor: 'bg-yellow' }))
18+
console.log(
19+
formatText('A configuration already exists.', {
20+
bold: true,
21+
backgroundColor: 'bg-yellow'
22+
})
23+
)
1924
let existingConfigChoice: string | null = null
2025
let readyToProceed = false
2126
while (!readyToProceed) {
@@ -289,16 +294,30 @@ if (['UPDATE', 'NEW'].includes(configStyle)) {
289294
* Does the user want to configure a Host Name & ACM Cert for the Frontend Cloudfront
290295
*/
291296
let configHostname = false
292-
if (config.ui?.acmCertificateArn === undefined || config.ui.hostName === undefined) {
293-
console.log(formatText('Do you want to configure a custom hostname for the frontend?',
294-
{ textColor: 'blue' }))
295-
console.log(formatText('Requires a hostname & a pre-existing AWS Certificate Manager public cert ARN.' +
296-
'For more information, visit https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-request-public.html',
297-
{ italic: true }))
297+
if (
298+
config.ui?.acmCertificateArn === undefined ||
299+
config.ui.hostName === undefined
300+
) {
301+
console.log(
302+
formatText(
303+
'Do you want to configure a custom hostname for the frontend?',
304+
{ textColor: 'blue' }
305+
)
306+
)
307+
console.log(
308+
formatText(
309+
'Requires a hostname & a pre-existing AWS Certificate Manager public cert ARN.' +
310+
'For more information, visit https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-request-public.html',
311+
{ italic: true }
312+
)
313+
)
298314
let loopA = true
299315
while (loopA) {
300316
const response = prompter(
301-
formatText('Do you want to proceed? (y/N):', { bold: true, textColor: 'blue' }),
317+
formatText('Do you want to proceed? (y/N):', {
318+
bold: true,
319+
textColor: 'blue'
320+
}),
302321
'N'
303322
)
304323
if (response.toLowerCase() === 'y') {
@@ -321,19 +340,28 @@ if (['UPDATE', 'NEW'].includes(configStyle)) {
321340
if (configHostname) {
322341
let loopB = true
323342
while (loopB) {
324-
const existingHostname = ((config.ui?.hostName) != null) ? config.ui.hostName : ''
343+
const existingHostname =
344+
config.ui?.hostName != null ? config.ui.hostName : ''
325345
const response = prompter(
326-
formatText(`Enter the hostname you want to use for the frontend:(${existingHostname})`, { textColor: 'blue' })
346+
formatText(
347+
`Enter the hostname you want to use for the frontend:(${existingHostname})`,
348+
{ textColor: 'blue' }
349+
)
327350
)
328-
const hostnameRegex = /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$/
351+
const hostnameRegex =
352+
/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$/
329353
if (response.length > 0 && hostnameRegex.test(response)) {
330354
if (config.ui === undefined) {
331355
config.ui = {}
332356
}
333357
config.ui.hostName = response
334358
loopB = false
335359
break
336-
} else if (response.length < 1 && config.ui?.hostName !== undefined && config.ui.hostName !== null) {
360+
} else if (
361+
response.length < 1 &&
362+
config.ui?.hostName !== undefined &&
363+
config.ui.hostName !== null
364+
) {
337365
loopB = false
338366
break
339367
} else {
@@ -348,9 +376,15 @@ if (['UPDATE', 'NEW'].includes(configStyle)) {
348376
}
349377
let loopC = true
350378
while (loopC) {
351-
const existingAcmCert = ((config.ui?.acmCertificateArn) != null) ? config.ui.acmCertificateArn : ''
379+
const existingAcmCert =
380+
config.ui?.acmCertificateArn != null
381+
? config.ui.acmCertificateArn
382+
: ''
352383
const response = prompter(
353-
formatText(`Enter the ACM Certificate ARN you want to use for the frontend:(${existingAcmCert})`, { textColor: 'blue' })
384+
formatText(
385+
`Enter the ACM Certificate ARN you want to use for the frontend:(${existingAcmCert})`,
386+
{ textColor: 'blue' }
387+
)
354388
)
355389
const acmCertRegex = /^arn:aws:acm:\S+:\d+:\w+\/\S+$/
356390
if (response.length > 0 && acmCertRegex.test(response)) {
@@ -360,8 +394,12 @@ if (['UPDATE', 'NEW'].includes(configStyle)) {
360394
config.ui.acmCertificateArn = response
361395
loopC = false
362396
break
363-
} else if (response.length < 1 && config.ui?.acmCertificateArn !== undefined && config.ui.acmCertificateArn !== null) {
364-
loopC = false;
397+
} else if (
398+
response.length < 1 &&
399+
config.ui?.acmCertificateArn !== undefined &&
400+
config.ui.acmCertificateArn !== null
401+
) {
402+
loopC = false
365403
break
366404
} else {
367405
console.log(

cli/config.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import figlet from 'figlet'
44

55
const program = new Command()
66

7-
console.log(figlet.textSync('GenAI Newsletter', {
8-
font: 'Slant'
9-
}))
7+
console.log(
8+
figlet.textSync('GenAI Newsletter', {
9+
font: 'Slant'
10+
})
11+
)
1012

1113
program
1214
.name('npm run config')

lib/api/functions/bundle.ts

+25-22
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,29 @@ import path from 'path'
1616

1717
const outDir = path.join(__dirname, 'out')
1818

19-
const resolverFunctions = fs.readdirSync(path.join(__dirname, 'resolver')).map((functionName) => {
20-
return path.join(__dirname, 'resolver', functionName, 'index.ts')
21-
})
22-
const pipelineFunctions = fs.readdirSync(path.join(__dirname, 'pipeline')).map((functionName) => {
23-
return path.join(__dirname, 'pipeline', functionName, 'index.ts')
24-
})
19+
const resolverFunctions = fs
20+
.readdirSync(path.join(__dirname, 'resolver'))
21+
.map((functionName) => {
22+
return path.join(__dirname, 'resolver', functionName, 'index.ts')
23+
})
24+
const pipelineFunctions = fs
25+
.readdirSync(path.join(__dirname, 'pipeline'))
26+
.map((functionName) => {
27+
return path.join(__dirname, 'pipeline', functionName, 'index.ts')
28+
})
2529

26-
esbuild.build({
27-
bundle: true,
28-
entryPoints: [
29-
...resolverFunctions,
30-
...pipelineFunctions
31-
],
32-
outdir: outDir,
33-
sourcemap: 'inline',
34-
sourcesContent: false,
35-
external: ['@aws-appsync/utils'],
36-
platform: 'node',
37-
target: 'esnext',
38-
format: 'esm',
39-
minify: false,
40-
logLevel: 'info'
41-
}).catch(() => process.exit(1))
30+
esbuild
31+
.build({
32+
bundle: true,
33+
entryPoints: [...resolverFunctions, ...pipelineFunctions],
34+
outdir: outDir,
35+
sourcemap: 'inline',
36+
sourcesContent: false,
37+
external: ['@aws-appsync/utils'],
38+
platform: 'node',
39+
target: 'esnext',
40+
format: 'esm',
41+
minify: false,
42+
logLevel: 'info'
43+
})
44+
.catch(() => process.exit(1))

lib/api/functions/pipeline/createDataFeed/index.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { type Context, util, type LambdaRequest, type AppSyncIdentityLambda } from '@aws-appsync/utils'
1+
import {
2+
type Context,
3+
util,
4+
type LambdaRequest,
5+
type AppSyncIdentityLambda
6+
} from '@aws-appsync/utils'
27

38
export function request (ctx: Context): LambdaRequest {
49
const { args } = ctx

lib/api/functions/pipeline/createNewsletter/index.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { type Context, util, type LambdaRequest, type AppSyncIdentityLambda } from '@aws-appsync/utils'
1+
import {
2+
type Context,
3+
util,
4+
type LambdaRequest,
5+
type AppSyncIdentityLambda
6+
} from '@aws-appsync/utils'
27

38
export function request (ctx: Context): LambdaRequest {
49
const { args } = ctx

lib/api/functions/pipeline/filterListByAuthorization/index.ts

+15-4
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,28 @@
44
* SPDX-License-Identifier: MIT-0
55
*/
66

7-
import { type LambdaRequest, util, type Context, type AppSyncIdentityLambda } from '@aws-appsync/utils'
7+
import {
8+
type LambdaRequest,
9+
util,
10+
type Context,
11+
type AppSyncIdentityLambda
12+
} from '@aws-appsync/utils'
813
import { convertAvpObjectsToGraphql } from '../../resolver-helper'
914

1015
export function request (ctx: Context): LambdaRequest {
11-
console.log(`[Filter List by Authorization Request] request ctx ${JSON.stringify(ctx)}`)
16+
console.log(
17+
`[Filter List by Authorization Request] request ctx ${JSON.stringify(ctx)}`
18+
)
1219
const { source, args } = ctx
1320
const identity = ctx.identity as AppSyncIdentityLambda
1421
return {
1522
operation: 'Invoke',
1623
payload: {
1724
userId: identity.resolverContext.userId,
1825
accountId: identity.resolverContext.accountId,
19-
requestContext: JSON.parse(identity.resolverContext.requestContext as string),
26+
requestContext: JSON.parse(
27+
identity.resolverContext.requestContext as string
28+
),
2029
result: ctx.prev.result,
2130
arguments: args,
2231
source
@@ -33,7 +42,9 @@ export function response (ctx: Context): any {
3342
if (result.isAuthorized !== true) {
3443
util.unauthorized()
3544
}
36-
console.log('[IsAuthorized] response result $', { result: JSON.stringify(result) })
45+
console.log('[IsAuthorized] response result $', {
46+
result: JSON.stringify(result)
47+
})
3748
return {
3849
isAuthorized: true,
3950
items: convertAvpObjectsToGraphql(result)

lib/api/functions/pipeline/getDataFeed/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { type DynamoDBGetItemRequest, type Context } from '@aws-appsync/utils'
22
import * as ddb from '@aws-appsync/utils/dynamodb'
3-
import { addAccountToItem, convertFieldIdToObjectId } from '../../resolver-helper'
3+
import {
4+
addAccountToItem,
5+
convertFieldIdToObjectId
6+
} from '../../resolver-helper'
47

58
export function request (ctx: Context): DynamoDBGetItemRequest {
69
const { id } = ctx.args.input

lib/api/functions/pipeline/getNewsletter/index.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import {
44
type DynamoDBGetItemRequest
55
} from '@aws-appsync/utils'
66
import * as ddb from '@aws-appsync/utils/dynamodb'
7-
import { addAccountToItem, convertFieldIdToObjectId } from '../../resolver-helper'
7+
import {
8+
addAccountToItem,
9+
convertFieldIdToObjectId
10+
} from '../../resolver-helper'
811

9-
export function request (
10-
ctx: Context
11-
): DynamoDBGetItemRequest {
12+
export function request (ctx: Context): DynamoDBGetItemRequest {
1213
console.log('getNewsletter request', { ctx })
1314
const { id } = ctx.args.input
1415
return ddb.get({

lib/api/functions/pipeline/getPublication/index.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import {
44
type DynamoDBGetItemRequest
55
} from '@aws-appsync/utils'
66
import * as ddb from '@aws-appsync/utils/dynamodb'
7-
import { addAccountToItem, convertFieldIdToObjectId } from '../../resolver-helper'
7+
import {
8+
addAccountToItem,
9+
convertFieldIdToObjectId
10+
} from '../../resolver-helper'
811

912
export function request (ctx: Context): DynamoDBGetItemRequest {
1013
const { newsletterId, publicationId } = ctx.args.input
@@ -20,7 +23,8 @@ export const response = (ctx: Context): any => {
2023
if (ctx.error !== undefined && ctx.error !== null) {
2124
util.error(ctx.error.message, ctx.error.type)
2225
}
23-
const { emailKey, createdAt, newsletterId, publicationId, accountId } = ctx.result
26+
const { emailKey, createdAt, newsletterId, publicationId, accountId } =
27+
ctx.result
2428
let path = ''
2529
if (emailKey !== undefined) {
2630
path = emailKey

lib/api/functions/pipeline/isAuthorized/index.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
* SPDX-License-Identifier: MIT-0
55
*/
66

7-
import { type LambdaRequest, util, type Context, type AppSyncIdentityLambda } from '@aws-appsync/utils'
7+
import {
8+
type LambdaRequest,
9+
util,
10+
type Context,
11+
type AppSyncIdentityLambda
12+
} from '@aws-appsync/utils'
813
import { convertAvpObjectToGraphql } from '../../resolver-helper'
914

1015
export function request (ctx: Context): LambdaRequest {
@@ -15,7 +20,9 @@ export function request (ctx: Context): LambdaRequest {
1520
payload: {
1621
userId: identity.resolverContext.userId,
1722
accountId: identity.resolverContext.accountId,
18-
requestContext: JSON.parse(identity.resolverContext.requestContext as string),
23+
requestContext: JSON.parse(
24+
identity.resolverContext.requestContext as string
25+
),
1926
result: ctx.prev.result,
2027
arguments: args,
2128
source,

lib/api/functions/pipeline/listDataFeedsById/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ export function request (ctx: Context): DynamoDBBatchGetItemRequest {
99
return {
1010
operation: 'BatchGetItem',
1111
tables: {
12-
[NEWSLETTER_TABLE]: ctx.args.dataFeedIds.map((dataFeedId: string) => util.dynamodb.toMapValues({ dataFeedId }))
12+
[NEWSLETTER_TABLE]: ctx.args.dataFeedIds.map((dataFeedId: string) =>
13+
util.dynamodb.toMapValues({ dataFeedId })
14+
)
1315
}
1416
}
1517
}

lib/api/functions/pipeline/listDataFeedsDiscoverable/index.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@ import {
55
type DynamoDBQueryRequest
66
} from '@aws-appsync/utils'
77
import * as ddb from '@aws-appsync/utils/dynamodb'
8-
import { addAccountToItems, convertFieldIdsToObjectIds, filterForDuplicatesById } from '../../resolver-helper'
8+
import {
9+
addAccountToItems,
10+
convertFieldIdsToObjectIds,
11+
filterForDuplicatesById
12+
} from '../../resolver-helper'
913

1014
export function request (ctx: Context): DynamoDBQueryRequest {
1115
const dataFeedTypeIndex = 'type-index' // TODO - Make ENV variable
1216
const input = ctx.args.input
13-
const includeDiscoverable = input?.includeDiscoverable !== undefined ? input.includeDiscoverable : ctx.stash.lookupDefinition.includeDiscoverable ?? false
17+
const includeDiscoverable =
18+
input?.includeDiscoverable !== undefined
19+
? input.includeDiscoverable
20+
: ctx.stash.lookupDefinition.includeDiscoverable ?? false
1421
if (includeDiscoverable === false) {
1522
runtime.earlyReturn(ctx.prev.result)
1623
}

lib/api/functions/pipeline/listDataFeedsOwned/index.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,20 @@ import {
1111
type AppSyncIdentityLambda
1212
} from '@aws-appsync/utils'
1313
import * as ddb from '@aws-appsync/utils/dynamodb'
14-
import { addAccountToItems, convertFieldIdsToObjectIds, filterForDuplicatesById } from '../../resolver-helper'
14+
import {
15+
addAccountToItems,
16+
convertFieldIdsToObjectIds,
17+
filterForDuplicatesById
18+
} from '../../resolver-helper'
1519
const dataFeedTypeIndex = 'type-index' // TODO - Make ENV variable
1620

1721
export function request (ctx: Context): DynamoDBQueryRequest {
1822
const identity = ctx.identity as AppSyncIdentityLambda
1923
const input = ctx.args.input
20-
const includeOwned = input?.includeOwned !== undefined ? input.includeOwned : ctx.stash.lookupDefinition.includeOwned ?? true
24+
const includeOwned =
25+
input?.includeOwned !== undefined
26+
? input.includeOwned
27+
: ctx.stash.lookupDefinition.includeOwned ?? true
2128
if (includeOwned === false) {
2229
runtime.earlyReturn(ctx.prev.result)
2330
}

0 commit comments

Comments
 (0)