Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/find-deadcode.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Find deadcode

on:
pull_request:

jobs:
find_deadcode:
runs-on: ubuntu-latest
timeout-minutes: 1

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '22.x'
cache: yarn

- name: Install dependencies
run: yarn

- name: Find deadcode
run: yarn find-deadcode
8 changes: 8 additions & 0 deletions knip.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"entry": ["src/cli/*.ts"],
"project": ["src/**/*.ts"],
"ignoreDependencies": ["express", "@types/express"],
"rules": {
"enumMembers": "off"
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@internxt/inxt-js",
"author": "Internxt <hello@internxt.com>",
"version": "3.1.2",
"version": "3.1.3",
"description": "",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand All @@ -18,29 +18,29 @@
"lint:fix": "yarn run lint --fix",
"cli": "ts-node --files src/cli/index.ts",
"format": "prettier --write src/**/*.{js,jsx,tsx,ts} tests/**/*.{js,jsx,tsx,ts}",
"find-deadcode": "knip",
"prepare": "husky"
},
"keywords": [],
"license": "ISC",
"devDependencies": {
"@internxt/eslint-config-internxt": "^2.1.0",
"@internxt/prettier-config": "^2.0.1",
"@types/archiver": "^7.0.0",
"@types/async": "=3.2.9",
"@types/express": "^5.0.6",
"@types/node": "^25.6.0",
"@vitest/coverage-istanbul": "^4.1.5",
"archiver": "^7.0.1",
"commander": "^14.0.3",
"dotenv": "^17.4.2",
"eslint": "^10.3.0",
"express": "^5.2.1",
"husky": "^9.1.7",
"knip": "^6.13.1",
"lint-staged": "^17.0.2",
"prettier": "^3.8.3",
"rimraf": "^6.1.3",
"ts-node": "^10.9.2",
"typescript": "^6.0.3",
"uuid": "^14.0.0",
"vitest": "^4.1.5"
},
"dependencies": {
Expand Down
20 changes: 0 additions & 20 deletions src/api/Contract.ts

This file was deleted.

7 changes: 0 additions & 7 deletions src/api/FileObjectUploadProtocol.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/api/Shard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,3 @@ export interface Shard {
operation: string;
url: string;
}

export function buildRequestUrl(shard: Shard) {
const { address, port } = shard.farmer;

return `http://${address}:${port}/download/link/${shard.hash}`;
}
7 changes: 0 additions & 7 deletions src/api/constants.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
export const DEFAULT_INXT_MIRRORS = 6;

/* EVENTS */
export const UPLOAD_CANCELLED = 'UPLOAD CANCELLED';

/* ERRORS */
export const ENCRYPTION_KEY_NOT_PROVIDED = 'Encryption key was not provided';
export const BUCKET_ID_NOT_PROVIDED = 'Bucket id was not provided';

export const MIN_SHARD_SIZE = 2097152;
export const MAX_SHARD_SIZE = 4294967296;
export const SHARD_MULTIPLE_BACK = 4;
2 changes: 1 addition & 1 deletion src/api/fileinfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function GetFileInfo(
});
}

export async function GetFileMirror(
async function GetFileMirror(
config: EnvironmentConfig,
bucketId: string,
fileId: string,
Expand Down
2 changes: 0 additions & 2 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
export * from './ActionState';
export * from './Abortable';
export * from './Bucket';
export * from './Contract';
export * from './EnvironmentConfig';
export * from './ExchangeReport';
export * from './FileObject';
export * from './fileinfo';
export * from './FileObjectUploadProtocol';
export * from './Shard';
12 changes: 2 additions & 10 deletions src/lib/core/download/dynamicStrategy.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
import { ActionState, Shard } from '../../../api';
import { Shard } from '../../../api';

import { DownloadStrategy } from './strategy';
import {
DownloadOneShardStrategy,
DownloadOneShardStrategyParams,
DownloadOneStreamStrategy,
DownloadOneStreamStrategyParams,
DownloadOptions,
} from '.';
import { Events } from '..';

export type DownloadDynamicStrategyLabel = 'Dynamic';
export type DownloadDynamicStrategyObject<T> = {
label: DownloadDynamicStrategyLabel;
label: 'Dynamic';
params: T extends DownloadOneShardStrategy ? DownloadOneShardStrategyParams : DownloadOneStreamStrategyParams;
};
export type DownloadDynamicStrategyFunction<T> = (
bucketId: string,
fileId: string,
opts: DownloadOptions,
strategyObj: DownloadDynamicStrategyObject<T>,
) => ActionState;

export class DownloadDynamicStrategy<
T = DownloadOneShardStrategy | DownloadOneStreamStrategy,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/download/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export * from './oneStreamStrategy';
export * from './oneShardStrategy';
export * from './dynamicStrategy';

export type DownloadFinishedCallback = (err: Error | null, fileStream: Readable | null) => void;
type DownloadFinishedCallback = (err: Error | null, fileStream: Readable | null) => void;
export type DownloadProgressCallback = (
progress: number,
downloadedBytes: number | null,
Expand Down
15 changes: 1 addition & 14 deletions src/lib/core/download/oneShardStrategy.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
import { createDecipheriv, Decipheriv, randomBytes } from 'crypto';
import { Events } from '..';

import { Abortable, ActionState, Shard } from '../../../api';
import { Abortable, Shard } from '../../../api';

import { getStream } from '../../../services/request';
import { HashStream, ProgressNotifier, Events as ProgressEvents } from '../../utils/streams';
import { wrap } from '../../utils/error';
import { DownloadStrategy, DownloadParams } from './strategy';
import { DownloadOptions } from '.';
import { logger } from '../../utils/logger';

export interface DownloadOneShardStrategyParams extends DownloadParams {
useProxy: boolean;
chunkSize?: number;
}

export type DownloadOneShardStrategyLabel = 'OneShardOnly';
export type DownloadOneShardStrategyObject = {
label: DownloadOneShardStrategyLabel;
params: DownloadOneShardStrategyParams;
};
export type DownloadOneShardStrategyFunction = (
bucketId: string,
fileId: string,
opts: DownloadOptions,
strategyObj: DownloadOneShardStrategyObject,
) => ActionState;

export class DownloadOneShardStrategy extends DownloadStrategy {
private abortables: Abortable[] = [];
private downloadProgress = 0;
Expand Down
15 changes: 1 addition & 14 deletions src/lib/core/download/oneStreamStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,20 @@ import { createDecipheriv, Decipheriv, randomBytes } from 'crypto';
import { Readable } from 'stream';
import { Events } from '..';

import { Abortable, ActionState, Shard } from '../../../api';
import { Abortable, Shard } from '../../../api';

import { getStream } from '../../../services/request';
import { HashStream, ProgressNotifier, Events as ProgressEvents } from '../../utils/streams';
import { wrap } from '../../utils/error';
import { logger } from '../../utils/logger';
import { DownloadStrategy, DownloadParams } from './strategy';
import { DownloadOptions } from '.';

export interface DownloadOneStreamStrategyParams extends DownloadParams {
concurrency: number;
useProxy: boolean;
chunkSize?: number;
}

export type DownloadOneStreamStrategyLabel = 'OneStreamOnly';
export type DownloadOneStreamStrategyObject = {
label: DownloadOneStreamStrategyLabel;
params: DownloadOneStreamStrategyParams;
};
export type DownloadOneStreamStrategyFunction = (
bucketId: string,
fileId: string,
opts: DownloadOptions,
strategyObj: DownloadOneStreamStrategyObject,
) => ActionState;

export class DownloadOneStreamStrategy extends DownloadStrategy {
private abortables: Abortable[] = [];
private internalBuffer: Buffer[] = [];
Expand Down
1 change: 0 additions & 1 deletion src/lib/core/download/strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { EventEmitter } from 'events';
import { DownloadDynamicStrategyObject, DownloadOptions } from '.';
import { Abortable, ActionState, Shard } from '../../../api';

export type DownloadStrategyLabel = string;
export type DownloadStrategyObject<T> = DownloadDynamicStrategyObject<T>;
export type DownloadStrategyFunction<T> = (
bucketId: string,
Expand Down
2 changes: 0 additions & 2 deletions src/lib/core/upload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ export type UploadProgressCallback = (
uploadedBytes: number | null,
totalBytes: number | null,
) => void;
export type EncryptProgressCallback = (progress: number) => void;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this type is being used at cli, so bump the version using minor instead of patch. Just in case any of the other removed exports are being used in other projects

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


export interface UploadOptions {
progressCallback: UploadProgressCallback;
encryptProgressCallback?: EncryptProgressCallback;
fileSize: number;
source: Readable;
abortSignal?: AbortSignal;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/core/upload/uploadV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async function putFile(url: string, body: Readable, fileSize: number, signal?: A
await responseBody.dump();
}

export async function uploadFileV2(
async function uploadFileV2(
network: Network,
fileSize: number,
source: Readable,
Expand Down Expand Up @@ -95,7 +95,7 @@ export async function uploadFileV2(
);
}

export async function uploadFileMultipart(
async function uploadFileMultipart(
network: Network,
fileSize: number,
source: Readable,
Expand Down
13 changes: 0 additions & 13 deletions src/lib/models/Contract.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/lib/models/Farmer.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/lib/models/Mirror.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/lib/models/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
export * from './Contract';
export * from './Farmer';
export * from './Mirror';
// export * from './Shard';
export * from './ShardMeta';
35 changes: 0 additions & 35 deletions src/lib/utils/MerkleTree.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/lib/utils/crypto/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ export const BUCKET_META_MAGIC = [
66, 150, 71, 16, 50, 114, 88, 160, 163, 35, 154, 65, 162, 213, 226, 215, 70, 138, 57, 61, 52, 19, 210, 170, 38, 164,
162, 200, 86, 201, 2, 81,
];
export const BUCKET_NAME_MAGIC = '398734aab3c4c30c9f22590e83a95f7e43556a45fc2b3060e0c39fde31f50272';
Loading
Loading