-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: metadata package scaffold (#52)
- Loading branch information
Showing
15 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "@zkchainhub/metadata", | ||
"version": "1.0.0", | ||
"main": "./dist/src/index.js", | ||
"typings": "./dist/src/index.d.ts", | ||
"type": "module", | ||
"directories": { | ||
"src": "src" | ||
}, | ||
"files": [ | ||
"dist/*", | ||
"package.json", | ||
"!**/*.tsbuildinfo" | ||
], | ||
"scripts": { | ||
"build": "tsc -p tsconfig.build.json", | ||
"check-types": "tsc --noEmit -p ./tsconfig.json", | ||
"clean": "rm -rf dist", | ||
"lint": "eslint \"{src,test}/**/*.{js,ts,json}\"", | ||
"lint:fix": "pnpm lint --fix", | ||
"format": "prettier --check \"{src,test}/**/*.{js,ts,json}\"", | ||
"format:fix": "prettier --write \"{src,test}/**/*.{js,ts,json}\"", | ||
"test": "vitest run --config vitest.config.ts --passWithNoTests", | ||
"test:cov": "vitest run --config vitest.config.ts --coverage" | ||
}, | ||
"dependencies": { | ||
"@zkchainhub/shared": "workspace:*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export type { IMetadataService } from "./internal.js"; | ||
|
||
export { StaticMetadataService, GithubMetadataService } from "./internal.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./external.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./metadata.interface.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Token, TokenType, ZKChainMetadata } from "@zkchainhub/shared"; | ||
|
||
export interface IMetadataService { | ||
getChainsMetadata(): Promise<ZKChainMetadata>; | ||
getTokensMetadata(): Promise<Token<TokenType>[]>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./interfaces/index.js"; | ||
export * from "./services/index.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Token, TokenType, ZKChainMetadata } from "@zkchainhub/shared"; | ||
|
||
import { IMetadataService } from "../interfaces/index.js"; | ||
|
||
export class GithubMetadataService implements IMetadataService { | ||
async getChainsMetadata(): Promise<ZKChainMetadata> { | ||
//TODO: Implement this method | ||
throw new Error("Method not implemented."); | ||
} | ||
|
||
async getTokensMetadata(): Promise<Token<TokenType>[]> { | ||
//TODO: Implement this method | ||
throw new Error("Method not implemented."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./githubMetadata.service.js"; | ||
export * from "./staticMetadata.service.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Token, tokens, TokenType, ZKChainMetadata, zkChainsMetadata } from "@zkchainhub/shared"; | ||
|
||
import { IMetadataService } from "../interfaces/index.js"; | ||
|
||
export class StaticMetadataService implements IMetadataService { | ||
async getChainsMetadata(): Promise<ZKChainMetadata> { | ||
return structuredClone(zkChainsMetadata); | ||
} | ||
async getTokensMetadata(): Promise<Token<TokenType>[]> { | ||
return Array.from(tokens); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/metadata/test/unit/services/githubMetadata.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { describe, it } from "vitest"; | ||
|
||
describe("GithubMetadataService", () => { | ||
describe("getChainsMetadata", () => { | ||
it.skip("returns the ZKChainMetadata"); | ||
}); | ||
|
||
describe("getTokensMetadata", () => { | ||
it.skip("return an array of Token objects"); | ||
}); | ||
}); |
30 changes: 30 additions & 0 deletions
30
packages/metadata/test/unit/services/staticMetadata.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { beforeEach, describe, expect, expectTypeOf, it } from "vitest"; | ||
|
||
import { Token, TokenType, ZKChainMetadata } from "@zkchainhub/shared"; | ||
|
||
import { StaticMetadataService } from "../../../src/internal.js"; | ||
|
||
describe("StaticMetadataService", () => { | ||
let metadataService: StaticMetadataService; | ||
|
||
beforeEach(() => { | ||
metadataService = new StaticMetadataService(); | ||
}); | ||
|
||
describe("getChainsMetadata", () => { | ||
it("should return the ZKChainMetadata", async () => { | ||
const result = await metadataService.getChainsMetadata(); | ||
expect(result).toBeDefined(); | ||
expectTypeOf(result).toEqualTypeOf<ZKChainMetadata>(); | ||
}); | ||
}); | ||
|
||
describe("getTokensMetadata", () => { | ||
it("should return an array of Token objects", async () => { | ||
const result = await metadataService.getTokensMetadata(); | ||
expect(result).toBeDefined(); | ||
expect(Array.isArray(result)).toBe(true); | ||
expectTypeOf(result).toEqualTypeOf<Token<TokenType>[]>(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "../../tsconfig.build.json", | ||
"compilerOptions": { | ||
"composite": true, | ||
"declarationMap": true, | ||
"declaration": true, | ||
"outDir": "dist" | ||
}, | ||
"include": ["src/**/*"], | ||
"exclude": ["node_modules", "dist", "test"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["src/**/*"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import path from "path"; | ||
import { defineConfig } from "vitest/config"; | ||
|
||
export default defineConfig({ | ||
test: { | ||
globals: true, // Use Vitest's global API without importing it in each file | ||
environment: "node", // Use the Node.js environment | ||
include: ["test/**/*.spec.ts"], // Include test files | ||
exclude: ["node_modules", "dist"], // Exclude certain directories | ||
coverage: { | ||
provider: "v8", | ||
reporter: ["text", "json", "html"], // Coverage reporters | ||
exclude: ["node_modules", "dist"], // Files to exclude from coverage | ||
}, | ||
}, | ||
resolve: { | ||
alias: { | ||
// Setup path alias based on tsconfig paths | ||
"@": path.resolve(__dirname, "src"), | ||
}, | ||
}, | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.