Skip to content

Commit

Permalink
Convert all imports to ts
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelBCarter committed Aug 8, 2024
1 parent 4bf955f commit 40455dd
Show file tree
Hide file tree
Showing 84 changed files with 132 additions and 132 deletions.
4 changes: 2 additions & 2 deletions src/bin/docker-build.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { execSync } from 'node:child_process'

import { getFlagsString } from './getFlags.js'
import { safeExit } from './safeExit.js'
import { getFlagsString } from './getFlags.ts'
import { safeExit } from './safeExit.ts'

safeExit(async () => {
console.log(`Docker build [${process.cwd()}]`)
Expand Down
2 changes: 1 addition & 1 deletion src/bin/generate-dotenv.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { execSync } from 'node:child_process'

import { safeExit } from './safeExit.js'
import { safeExit } from './safeExit.ts'

safeExit(() => {
console.log(`Generate .env [${process.cwd()}]`)
Expand Down
2 changes: 1 addition & 1 deletion src/bin/start-meta.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getEnvFromAws, tryParseInt } from '@xylabs/sdk-api-express-ecs'

import { metaServer } from '../modules/index.js'
import { metaServer } from '../modules/index.ts'

void (async () => {
const port = tryParseInt(process.env.PORT) || 8083
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { asyncHandler } from '@xylabs/sdk-api-express-ecs'
import { RequestHandler } from 'express'
import { StatusCodes } from 'http-status-codes'

import { MountPathAndMiddleware } from '../../types/index.js'
import { MountPathAndMiddleware } from '../../types/index.ts'

const handleStatusCode: RequestHandler = (req, res, _next) => {
const { code } = req.params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {
RouteMatcher,
stringToArrayBuffer,
} from '../../lib/index.js'
import { ApplicationMiddlewareOptions, MountPathAndMiddleware } from '../../types/index.js'
import { useIndexAndDynamicPreviewImage } from './lib/index.js'
import { ApplicationMiddlewareOptions, MountPathAndMiddleware } from '../../types/index.ts'
import { useIndexAndDynamicPreviewImage } from './lib/index.ts'

/**
* The max-age cache control header time (in seconds)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getImageMeta } from '../getImageMeta.js'
import { getImageMeta } from '../getImageMeta.ts'

describe('getImageMeta', () => {
const cases = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Server } from 'node:http'
import { StatusCodes } from 'http-status-codes'
import { SuperTest, Test } from 'supertest'

import { getServerOnPort } from '../../../spec/index.js'
import { getServerOnPort } from '../../../spec/index.ts'

describe('dynamicShare', () => {
const port = 12_346
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { forget } from '@xylabs/forget'

import { FileRepository, preCacheFacebookShare } from '../../../../lib/index.js'
import { generateImage } from './generateImage.js'
import { tryGetPreviewUrlFromPage } from './getPreviewUrlFromPage.js'
import { height, width } from './imageGenerator.js'
import { pageImageExists } from './pageImageExists.js'
import { FileRepository, preCacheFacebookShare } from '../../../../lib/index.ts'
import { generateImage } from './generateImage.ts'
import { tryGetPreviewUrlFromPage } from './getPreviewUrlFromPage.ts'
import { height, width } from './imageGenerator.ts'
import { pageImageExists } from './pageImageExists.ts'

/**
* Ensures a page preview image exists for the supplied uri. If the image does not exist,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FileRepository, RepositoryFile, useSpaPage } from '../../../../lib/index.js'
import { getImageUrlFromPageUrl } from '../url/index.js'
import { imageGenerator, type } from './imageGenerator.js'
import { FileRepository, RepositoryFile, useSpaPage } from '../../../../lib/index.ts'
import { getImageUrlFromPageUrl } from '../url/index.ts'
import { imageGenerator, type } from './imageGenerator.ts'

export const generateImage = (url: string, previewUrl: string, imageRepository: FileRepository, width: number, height: number) => {
return useSpaPage(previewUrl, async (page) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meta, OpenGraphMeta, TwitterMeta } from '@xyo-network/sdk-meta'

import { defaultViewportSize } from '../../../../lib/index.js'
import { getImageUrlFromPageUrl } from '../url/index.js'
import { defaultViewportSize } from '../../../../lib/index.ts'
import { getImageUrlFromPageUrl } from '../url/index.ts'

/**
* Generates the expected metadata for the resultant preview image of a Live Share page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { assertEx } from '@xylabs/assert'
import he from 'he'
const { decode } = he

import { useSpaPage } from '../../../../lib/index.js'
import { useSpaPage } from '../../../../lib/index.ts'

/**
* The property name of the meta element
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FileRepository } from '../../../../lib/index.js'
import { getImageUrlFromPageUrl } from '../url/index.js'
import { FileRepository } from '../../../../lib/index.ts'
import { getImageUrlFromPageUrl } from '../url/index.ts'

/**
* Checks if the page image exists in the cache
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MemoryFileRepository } from '../../../../../lib/index.js'
import { ensureImageExists } from '../ensureImageExists.js'
import { MemoryFileRepository } from '../../../../../lib/index.ts'
import { ensureImageExists } from '../ensureImageExists.ts'

describe.skip('ensureImageExists', () => {
let average = 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getImageMeta } from '../getImageMeta.js'
import { getImageMeta } from '../getImageMeta.ts'

describe('getImageMeta', () => {
const cases = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { metaBuilder } from '@xyo-network/sdk-meta'

import { FileRepository } from '../../../../../lib/index.js'
import { ensureImageExists, getImageMeta } from '../../image/index.js'
import { FileRepository } from '../../../../../lib/index.ts'
import { ensureImageExists, getImageMeta } from '../../image/index.ts'

export const useIndexAndDeferredPreviewImage = (url: string, imageRepository: FileRepository, indexHtml: string): string => {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join, removeQueryParam } from '../../../../lib/index.js'
import { join, removeQueryParam } from '../../../../lib/index.ts'

/**
* Generates the url of the preview image for a Live Share page
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getImageUrlFromPageUrl } from '../getImageUrlFromPageUrl.js'
import { getImageUrlFromPageUrl } from '../getImageUrlFromPageUrl.ts'

describe('getImageUrl', () => {
const cases: [width: number, height: number][] = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getPageUrlFromImageUrl } from '../getPageUrlFromImageUrl.js'
import { getPageUrlFromImageUrl } from '../getPageUrlFromImageUrl.ts'

describe('getPageUrlFromImageUrl', () => {
const cases: [imageUrl: string, pageUrl: string][] = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getImageUrlFromPageUrl } from '../getImageUrlFromPageUrl.js'
import { getPageUrlFromImageUrl } from '../getPageUrlFromImageUrl.js'
import { getImageUrlFromPageUrl } from '../getImageUrlFromPageUrl.ts'
import { getPageUrlFromImageUrl } from '../getPageUrlFromImageUrl.ts'

describe('url helpers', () => {
const cases: [pageUrl: string][] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {
RouteMatcher,
stringToArrayBuffer,
} from '../../lib/index.js'
import { ApplicationMiddlewareOptions, MountPathAndMiddleware } from '../../types/index.js'
import { ensureImageExists, getPageUrlFromImageUrl, useIndexAndDeferredPreviewImage } from './lib/index.js'
import { ApplicationMiddlewareOptions, MountPathAndMiddleware } from '../../types/index.ts'
import { ensureImageExists, getPageUrlFromImageUrl, useIndexAndDeferredPreviewImage } from './lib/index.ts'

/**
* The max-age cache control header time (in seconds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { StatusCodes } from 'http-status-codes'
import { MatchImageSnapshotOptions, toMatchImageSnapshot } from 'jest-image-snapshot'
import { SuperTest, Test } from 'supertest'

import { getServerOnPort } from '../../../spec/index.js'
import { getServerOnPort } from '../../../spec/index.ts'

describe('liveShare', () => {
const port = 12_345
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { exists } from '../exists.js'
import { exists } from '../exists.ts'

describe('exists', () => {
describe('when path exists returns true', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { StatusCodes } from 'http-status-codes'
import { LRUCache } from 'lru-cache'
import serveStatic, { ServeStaticOptions } from 'serve-static'

import { getAdjustedPath, isHtmlLike } from '../../lib/index.js'
import { MetaCacheLocals } from '../../middleware/index.js'
import { ApplicationMiddlewareOptions, MountPathAndMiddleware } from '../../types/index.js'
import { exists } from './lib/index.js'
import { getAdjustedPath, isHtmlLike } from '../../lib/index.ts'
import { MetaCacheLocals } from '../../middleware/index.ts'
import { ApplicationMiddlewareOptions, MountPathAndMiddleware } from '../../types/index.ts'
import { exists } from './lib/index.ts'

/**
* The max-age cache control header time (in seconds)
Expand Down
2 changes: 1 addition & 1 deletion src/modules/metaServer/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { server } from './server/index.js'
import { server } from './server/index.ts'

export const metaServer = (port?: number) => {
server(port)
Expand Down
2 changes: 1 addition & 1 deletion src/modules/metaServer/lib/aws/config/accessKeyId.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { generateEnvVarHelpers } from '../../env/index.js'
import { generateEnvVarHelpers } from '../../env/index.ts'

export const { hasEnvVar: hasAccessKeyId, tryGetEnvVar: tryGetAccessKeyId, getEnvVar: getAccessKeyId } = generateEnvVarHelpers('AWS_ACCESS_KEY_ID')
2 changes: 1 addition & 1 deletion src/modules/metaServer/lib/aws/config/region.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateEnvVarHelpers } from '../../env/index.js'
import { generateEnvVarHelpers } from '../../env/index.ts'

/**
* Checks if the AWS_DEFAULT_REGION environment variable is defined
Expand Down
2 changes: 1 addition & 1 deletion src/modules/metaServer/lib/aws/config/secretAccessKey.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateEnvVarHelpers } from '../../env/index.js'
import { generateEnvVarHelpers } from '../../env/index.ts'

export const {
hasEnvVar: hasSecretAccessKey,
Expand Down
2 changes: 1 addition & 1 deletion src/modules/metaServer/lib/aws/s3/getAwsS3ClientConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { S3ClientConfig } from '@aws-sdk/client-s3'

import { getAccessKeyId, getRegionOrDefault, getSecretAccessKey, hasAccessKeyId, hasSecretAccessKey } from '../config/index.js'
import { getAccessKeyId, getRegionOrDefault, getSecretAccessKey, hasAccessKeyId, hasSecretAccessKey } from '../config/index.ts'

export const getAwsS3ClientConfig: () => S3ClientConfig = () => {
const config: S3ClientConfig = {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/metaServer/lib/aws/s3/getDefaultBucket.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateEnvVarHelpers } from '../../env/index.js'
import { generateEnvVarHelpers } from '../../env/index.ts'

/**
* Determines the default AWS S3 bucket to use.
Expand Down
2 changes: 1 addition & 1 deletion src/modules/metaServer/lib/aws/s3/hasAwsS3ClientConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hasAccessKeyId, hasSecretAccessKey } from '../config/index.js'
import { hasAccessKeyId, hasSecretAccessKey } from '../config/index.ts'

/**
* Checks if the enough information exists in the environment to create an AWS S3 client
Expand Down
6 changes: 3 additions & 3 deletions src/modules/metaServer/lib/aws/s3/store/spec/S3Store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import Path from 'node:path'
import { S3ClientConfig } from '@aws-sdk/client-s3'
import { describeIf } from '@xylabs/jest-helpers'

import { getAwsS3ClientConfig } from '../../getAwsS3ClientConfig.js'
import { getDefaultTestBucket, hasBucket } from '../../getDefaultBucket.js'
import { S3Store } from '../S3Store.js'
import { getAwsS3ClientConfig } from '../../getAwsS3ClientConfig.ts'
import { getDefaultTestBucket, hasBucket } from '../../getDefaultBucket.ts'
import { S3Store } from '../S3Store.ts'

describeIf(hasBucket())('S3Store', () => {
let config: S3ClientConfig
Expand Down
4 changes: 2 additions & 2 deletions src/modules/metaServer/lib/browser/useBrowser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Browser, launch, Viewport } from 'puppeteer'

import { getBrowserArgs } from './getBrowserArgs.js'
import { defaultViewportSize } from './ViewPortSize.js'
import { getBrowserArgs } from './getBrowserArgs.ts'
import { defaultViewportSize } from './ViewPortSize.ts'

export const viewPortDefaults: Viewport = {
...defaultViewportSize,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getArchivistDomainFromUri, networkToArchivistUri } from '../getArchivistDomainFromUri.js'
import { getArchivistDomainFromUri, networkToArchivistUri } from '../getArchivistDomainFromUri.ts'

const prodUrls = [
'https://node.xyo.network',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isArchivistDomain } from '../isArchivistDomain.js'
import { isArchivistDomain } from '../isArchivistDomain.ts'

const archivistDomains = ['https://beta.api.archivist.xyo.network', 'https://api.archivist.xyo.network', 'http://localhost:8080']

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isExploreDomain } from '../isExploreDomain.js'
import { isExploreDomain } from '../isExploreDomain.ts'

const exploreDomains = ['https://beta.explore.xyo.network', 'https://explore.xyo.network', 'http://localhost:3000']

Expand Down
2 changes: 1 addition & 1 deletion src/modules/metaServer/lib/domain/spec/isLocalhost.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isLocalhost } from '../isLocalhost.js'
import { isLocalhost } from '../isLocalhost.ts'

const localhostStrings = [
'localhost',
Expand Down
6 changes: 3 additions & 3 deletions src/modules/metaServer/lib/env/generateEnvVarHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getEnvVar } from './getEnvVar.js'
import { hasEnvVar } from './hasEnvVar.js'
import { tryGetEnvVar } from './tryGetEnvVar.js'
import { getEnvVar } from './getEnvVar.ts'
import { hasEnvVar } from './hasEnvVar.ts'
import { tryGetEnvVar } from './tryGetEnvVar.ts'

/**
* Helper methods for interacting with an ENV VAR
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getContentType } from '../getContentType.js'
import { getContentType } from '../getContentType.ts'

const pathsWithRealExtensions = [
'index.html',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isKnownFileExtension } from '../isKnownFileExtension.js'
import { isKnownFileExtension } from '../isKnownFileExtension.ts'

const pathsWithRealExtensions = [
'index.html',
Expand Down
4 changes: 2 additions & 2 deletions src/modules/metaServer/lib/head/spec/getRenderedHead.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { usePage } from '../../page/index.js'
import { getRenderedHead, getRenderedMeta, getRenderedMetaElements, getSelectiveHeadElements } from '../getRenderedHead.js'
import { usePage } from '../../page/index.ts'
import { getRenderedHead, getRenderedMeta, getRenderedMetaElements, getSelectiveHeadElements } from '../getRenderedHead.ts'

const uris = ['https://www.youtube.com/watch?v=Kauv7MVPcsA']

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PageRenderingOptions, usePage } from '../page/index.js'
import { PageRenderingOptions, usePage } from '../page/index.ts'

export interface CanvasImageOptions extends PageRenderingOptions {
canvasSelector: string
Expand Down
6 changes: 3 additions & 3 deletions src/modules/metaServer/lib/image/generateImageFromPage.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Page, ScreenshotOptions } from 'puppeteer'

import { defaultPageRenderingOptions, PageRenderingOptions, usePage } from '../page/index.js'
import { ImageEncoding } from './ImageEncoding.js'
import { ImageType } from './ImageType.js'
import { defaultPageRenderingOptions, PageRenderingOptions, usePage } from '../page/index.ts'
import { ImageEncoding } from './ImageEncoding.ts'
import { ImageType } from './ImageType.ts'

export type PageImageOptions = PageRenderingOptions & {
encoding?: ImageEncoding
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { renderAndGenerateImageFromPage } from '../generateImageFromPage.js'
import { renderAndGenerateImageFromPage } from '../generateImageFromPage.ts'

describe('generateImageFromPage', () => {
it('generates image from page', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { MatchImageSnapshotOptions, toMatchImageSnapshot } from 'jest-image-snapshot'

import { usePage } from '../../../page/index.js'
import { join } from '../../../uri/index.js'
import { summaryCardImageFromPage } from '../summaryCardImageFromPage.js'
import { usePage } from '../../../page/index.ts'
import { join } from '../../../uri/index.ts'
import { summaryCardImageFromPage } from '../summaryCardImageFromPage.ts'

const opts: MatchImageSnapshotOptions = {
customDiffConfig: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { MatchImageSnapshotOptions, toMatchImageSnapshot } from 'jest-image-snapshot'

import { usePage } from '../../../page/index.js'
import { join } from '../../../uri/index.js'
import { summaryCardWithLargeImageFromPage } from '../summaryCardWithLargeImageFromPage.js'
import { usePage } from '../../../page/index.ts'
import { join } from '../../../uri/index.ts'
import { summaryCardWithLargeImageFromPage } from '../summaryCardWithLargeImageFromPage.ts'

const opts: MatchImageSnapshotOptions = {
customDiffConfig: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Page, ScreenshotOptions, Viewport } from 'puppeteer'

import { generateImageBufferFromPage } from '../generateImageFromPage.js'
import { generateImageBufferFromPage } from '../generateImageFromPage.ts'

const opts: ScreenshotOptions = {
encoding: 'binary',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Page, ScreenshotOptions, Viewport } from 'puppeteer'

import { defaultViewportSize } from '../../browser/index.js'
import { generateImageBufferFromPage } from '../generateImageFromPage.js'
import { defaultViewportSize } from '../../browser/index.ts'
import { generateImageBufferFromPage } from '../generateImageFromPage.ts'

const opts: ScreenshotOptions = {
encoding: 'binary',
Expand Down
2 changes: 1 addition & 1 deletion src/modules/metaServer/lib/page/PageRenderingOptions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { WaitForOptions } from 'puppeteer'

import { ViewPortSize } from '../browser/index.js'
import { ViewPortSize } from '../browser/index.ts'

export type PageRenderingOptions = WaitForOptions & {
viewportSize?: ViewPortSize
Expand Down
Loading

0 comments on commit 40455dd

Please sign in to comment.