Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions .github/workflows/pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ jobs:
# Fails the PR if there are syntax errors or bad practices
run: npm run lint

- name: Run Type Checker (TypeScript)
# Fails the PR if typings do not match the implementation
run: npm run type-check

# JOB 2: Build and Test (Functionality)
# Runs parallel to code-quality for faster feedback
build-and-test:
Expand Down
121 changes: 121 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// Type definitions for AlgoScope SDK

// src/lib/utils.js
export interface StepParams {
lineKey: string;
type: string;
array?: number[];
indices?: number[];
sortedIndices?: number[];
message?: string;
variables?: Record<string, any>;
duration?: number;
[key: string]: any;
}

export interface StepResult {
lineKey: string;
type: string;
array: number[];
indices: number[];
sortedIndices: number[];
message: string;
variables: Record<string, any>;
duration?: number;
[key: string]: any;
}

export function createStep(params: StepParams): StepResult;

export function calculateStepDelay(
stepDuration?: number,
speed?: number,
minDelay?: number
): number;

export function generateRandomArray(
length: number,
min: number,
max: number
): number[];

export function swap(arr: number[], i: number, j: number): void;

export function formatComplex(re?: number, im?: number): string;


// src/lib/favorites.js
export const FAVORITES_KEY: string;

export interface FavoriteItem {
id: string;
[key: string]: any;
}

export function getFavorites(): FavoriteItem[];

export function saveFavorites(list: FavoriteItem[]): void;

export function isFavoriteId(id: string): boolean;

export function addFavorite(item: FavoriteItem): void;

export function removeFavorite(id: string): void;

export function toggleFavorite(item: FavoriteItem): void;

export function subscribeFavoritesChange(callback: () => void): () => void;


// src/lib/testCaseStore.js
export interface TestCaseParams {
id?: string;
name: string;
algorithm: string;
input: string;
description?: string;
pinned?: boolean;
createdAt?: string;
usedAt?: string;
}

export interface TestCaseEntry {
id: string;
name: string;
algorithm: string;
input: string;
description: string;
pinned: boolean;
createdAt: string;
usedAt: string;
}

export function buildTestCaseEntry(params: TestCaseParams): TestCaseEntry;

export function saveTestCase(params: {
name: string;
algorithm: string;
input: string;
description?: string;
}): Promise<TestCaseEntry>;

export function getAllTestCases(algorithm?: string | null): Promise<TestCaseEntry[]>;

export function deleteTestCase(id: string): Promise<void>;

export function togglePin(id: string): Promise<TestCaseEntry>;

export function searchTestCases(query: string): Promise<TestCaseEntry[]>;

export function updateUsedAt(id: string): Promise<TestCaseEntry>;

export function exportTestCases(testcases: TestCaseEntry[]): void;

export function importTestCases(file: File): Promise<{
success: number;
skipped: number;
}>;


// src/lib/version.js
export const APP_VERSION: string;
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './src/lib/utils.js'
export * from './src/lib/favorites.js'
export * from './src/lib/testCaseStore.js'
export * from './src/lib/version.js'
Loading
Loading