From 904bd1731447796cf1a2bd992c89f889f2a6263a Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 2 Aug 2021 17:26:29 +0200 Subject: Renamed the shared types package to api --- packages/api/package.json | 8 ++++ packages/api/src/branch.d.ts | 10 +++++ packages/api/src/commit.d.ts | 48 ++++++++++++++++++++++ packages/api/src/index.d.ts | 12 ++++++ packages/api/src/info.d.ts | 4 ++ packages/api/src/misc.d.ts | 4 ++ packages/api/src/repository.d.ts | 12 ++++++ packages/api/src/tag.d.ts | 7 ++++ packages/api/src/tree.d.ts | 12 ++++++ packages/client/package.json | 2 +- packages/client/src/components/CommitPatch.vue | 2 +- packages/client/src/components/HomeHeader.vue | 2 +- packages/client/src/views/Home.vue | 2 +- packages/client/src/views/Repository.vue | 2 +- packages/client/src/views/RepositoryAbout.vue | 2 +- packages/client/src/views/RepositoryCommit.vue | 2 +- packages/client/src/views/RepositoryLog.vue | 2 +- packages/client/src/views/RepositoryTree.vue | 2 +- packages/server/package.json | 2 +- packages/server/src/routes/api/v1/index.ts | 2 +- packages/server/src/routes/api/v1/repo/branches.ts | 2 +- packages/server/src/routes/api/v1/repo/index.ts | 2 +- packages/server/src/routes/api/v1/repo/log.ts | 2 +- packages/shared_types/package.json | 8 ---- packages/shared_types/src/branch.d.ts | 10 ----- packages/shared_types/src/commit.d.ts | 48 ---------------------- packages/shared_types/src/index.d.ts | 7 ---- packages/shared_types/src/info.d.ts | 4 -- packages/shared_types/src/misc.d.ts | 4 -- packages/shared_types/src/repository.d.ts | 12 ------ packages/shared_types/src/tag.d.ts | 7 ---- packages/shared_types/src/tree.d.ts | 12 ------ test/int/api.int.test.ts | 2 +- 33 files changed, 132 insertions(+), 127 deletions(-) create mode 100644 packages/api/package.json create mode 100644 packages/api/src/branch.d.ts create mode 100644 packages/api/src/commit.d.ts create mode 100644 packages/api/src/index.d.ts create mode 100644 packages/api/src/info.d.ts create mode 100644 packages/api/src/misc.d.ts create mode 100644 packages/api/src/repository.d.ts create mode 100644 packages/api/src/tag.d.ts create mode 100644 packages/api/src/tree.d.ts delete mode 100644 packages/shared_types/package.json delete mode 100644 packages/shared_types/src/branch.d.ts delete mode 100644 packages/shared_types/src/commit.d.ts delete mode 100644 packages/shared_types/src/index.d.ts delete mode 100644 packages/shared_types/src/info.d.ts delete mode 100644 packages/shared_types/src/misc.d.ts delete mode 100644 packages/shared_types/src/repository.d.ts delete mode 100644 packages/shared_types/src/tag.d.ts delete mode 100644 packages/shared_types/src/tree.d.ts diff --git a/packages/api/package.json b/packages/api/package.json new file mode 100644 index 0000000..55b33b5 --- /dev/null +++ b/packages/api/package.json @@ -0,0 +1,8 @@ +{ + "name": "api", + "version": "1.0.0", + "main": "src/index.d.ts", + "author": "HampusMat", + "license": "MIT", + "private": true +} diff --git a/packages/api/src/branch.d.ts b/packages/api/src/branch.d.ts new file mode 100644 index 0000000..a32515e --- /dev/null +++ b/packages/api/src/branch.d.ts @@ -0,0 +1,10 @@ +import { LatestCommit } from "./commit"; + +export interface BranchSummary { + id: string, + name: string +} + +export interface Branch extends BranchSummary { + latest_commit: LatestCommit +} \ No newline at end of file diff --git a/packages/api/src/commit.d.ts b/packages/api/src/commit.d.ts new file mode 100644 index 0000000..6eb598c --- /dev/null +++ b/packages/api/src/commit.d.ts @@ -0,0 +1,48 @@ +import { Author } from "./misc"; + +export type Hunk = { + new_start: number, + new_lines_cnt: number, + new_lines: number[], + old_start: number, + old_lines_cnt: number, + deleted_lines: number[], + hunk: string +} + +export type Patch = { + additions: number, + deletions: number, + from: string, + to: string, + too_large: boolean, + hunks: Hunk[] +} +export interface Commit { + message: string, + author: Author, + date: number, + insertions: number, + deletions: number, + files_changed: number, + diff: Patch[] +} + +export type LogCommit = { + id: string, + author: { + name: string, + email: string + }, + message: string, + date: number, + insertions: number, + deletions: number, + files_changed: number +} + +export type LatestCommit = { + id: string, + message: string, + date: number +} \ No newline at end of file diff --git a/packages/api/src/index.d.ts b/packages/api/src/index.d.ts new file mode 100644 index 0000000..eeb31ad --- /dev/null +++ b/packages/api/src/index.d.ts @@ -0,0 +1,12 @@ +/** + * Interfaces and types used both client-side and server-side. + * + * @module api + */ +export { Tree, TreeEntry } from "./tree"; +export { Commit, Patch, Hunk, LatestCommit, LogCommit } from "./commit"; +export { Repository, RepositorySummary } from "./repository"; +export { Branch, BranchSummary } from "./branch"; +export { Author } from "./misc"; +export { Tag } from "./tag"; +export { Info } from "./info"; \ No newline at end of file diff --git a/packages/api/src/info.d.ts b/packages/api/src/info.d.ts new file mode 100644 index 0000000..1101cea --- /dev/null +++ b/packages/api/src/info.d.ts @@ -0,0 +1,4 @@ +export type Info = { + title: string, + about: string, +} \ No newline at end of file diff --git a/packages/api/src/misc.d.ts b/packages/api/src/misc.d.ts new file mode 100644 index 0000000..e43fae5 --- /dev/null +++ b/packages/api/src/misc.d.ts @@ -0,0 +1,4 @@ +export type Author = { + name: string, + email: string +} \ No newline at end of file diff --git a/packages/api/src/repository.d.ts b/packages/api/src/repository.d.ts new file mode 100644 index 0000000..cb4d246 --- /dev/null +++ b/packages/api/src/repository.d.ts @@ -0,0 +1,12 @@ +interface RepositoryBase { + name: string, + description: string | null +} + +export interface RepositorySummary extends RepositoryBase { + last_updated: number | string +} + +export interface Repository extends RepositoryBase { + has_readme: boolean +} \ No newline at end of file diff --git a/packages/api/src/tag.d.ts b/packages/api/src/tag.d.ts new file mode 100644 index 0000000..7c418da --- /dev/null +++ b/packages/api/src/tag.d.ts @@ -0,0 +1,7 @@ +import { Author } from "./misc"; + +export type Tag = { + name: string, + author: Author, + date: number +} \ No newline at end of file diff --git a/packages/api/src/tree.d.ts b/packages/api/src/tree.d.ts new file mode 100644 index 0000000..d2b4708 --- /dev/null +++ b/packages/api/src/tree.d.ts @@ -0,0 +1,12 @@ +import { LatestCommit } from "./commit"; + +export type TreeEntry = { + name: string, + type: "tree" | "blob", + latest_commit: LatestCommit +}; + +export type Tree = { + type: "tree" | "blob", + content: string | TreeEntry[] +}; \ No newline at end of file diff --git a/packages/client/package.json b/packages/client/package.json index a82dafd..54068d6 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -40,7 +40,7 @@ "eslint-plugin-vue": "^7.14.0", "sass": "^1.26.5", "sass-loader": "^12.1.0", - "shared_types": "^1.0.0", + "api": "^1.0.0", "typescript": "^4.3.5", "vue-eslint-parser": "^7.9.0", "webpack": "^5.46.0" diff --git a/packages/client/src/components/CommitPatch.vue b/packages/client/src/components/CommitPatch.vue index 4a3a999..b0e8086 100644 --- a/packages/client/src/components/CommitPatch.vue +++ b/packages/client/src/components/CommitPatch.vue @@ -2,7 +2,7 @@ import { defineComponent, h, PropType, VNode } from "vue"; import hljs from "highlight.js"; import hljs_languages from "../util/hljs-languages"; -import { Patch } from "shared_types"; +import { Patch } from "api"; export default defineComponent({ name: "CommitPatch", diff --git a/packages/client/src/components/HomeHeader.vue b/packages/client/src/components/HomeHeader.vue index a6e640e..dc266aa 100644 --- a/packages/client/src/components/HomeHeader.vue +++ b/packages/client/src/components/HomeHeader.vue @@ -9,7 +9,7 @@