diff --git a/package.json b/package.json index 93228e3..05a9144 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tiny-crud", - "version": "1.0.20", + "version": "1.0.21", "description": "", "main": "dist/bundle.cjs.js", "module": "dist/bundle.esm.js", diff --git a/src/__tests__/book-storage.test.ts b/src/__tests__/book-repository.test.ts similarity index 98% rename from src/__tests__/book-storage.test.ts rename to src/__tests__/book-repository.test.ts index 4645d12..92fe450 100644 --- a/src/__tests__/book-storage.test.ts +++ b/src/__tests__/book-repository.test.ts @@ -1,7 +1,7 @@ import dayjs from "dayjs"; import { BookModel } from "./helper/book-model"; -import { Book } from "./helper/book-storage"; -import { PlainObject } from "../storage-lib"; +import { Book } from "./helper/book-repository"; +import { PlainObject } from "../repository-lib"; describe('Test Book Storage', () => { diff --git a/src/__tests__/chat-storage.test.ts b/src/__tests__/chat-repository.test.ts similarity index 98% rename from src/__tests__/chat-storage.test.ts rename to src/__tests__/chat-repository.test.ts index c1735bb..490addb 100644 --- a/src/__tests__/chat-storage.test.ts +++ b/src/__tests__/chat-repository.test.ts @@ -1,6 +1,6 @@ -import { PlainObject } from "../storage-lib"; +import { PlainObject } from "../repository-lib"; import { ChatModel } from "./helper/chat-model"; -import { Chat } from "./helper/chat-storage"; +import { Chat } from "./helper/chat-repository"; describe('Use Gitlab Test Chat Storage', () => { diff --git a/src/__tests__/helper/book-model.ts b/src/__tests__/helper/book-model.ts index 7984a6c..f25a9c6 100644 --- a/src/__tests__/helper/book-model.ts +++ b/src/__tests__/helper/book-model.ts @@ -1,5 +1,4 @@ -import { BaseModel } from "../../storage-lib"; - +import { BaseModel } from '../../repository-lib/'; export interface BookModel extends BaseModel { book_name: string; book_author: string; diff --git a/src/__tests__/helper/book-storage.ts b/src/__tests__/helper/book-repository.ts similarity index 57% rename from src/__tests__/helper/book-storage.ts rename to src/__tests__/helper/book-repository.ts index f21f32d..67bd7fa 100644 --- a/src/__tests__/helper/book-storage.ts +++ b/src/__tests__/helper/book-repository.ts @@ -1,9 +1,9 @@ -import { GithubStorage } from "../../storage-lib"; +import { GithubRepository } from "../../repository-lib"; import { SingletonFactory } from "../../utils"; import { BookModel } from "./book-model"; import { githubRequest } from "./helper"; -class BookStorage extends GithubStorage { +class BookRepository extends GithubRepository { constructor() { super(githubRequest); } @@ -12,4 +12,4 @@ class BookStorage extends GithubStorage { /** * test github api with a book storage instance. */ -export const Book = SingletonFactory.createInstance(BookStorage); \ No newline at end of file +export const Book = SingletonFactory.createInstance(BookRepository); \ No newline at end of file diff --git a/src/__tests__/helper/chat-model.ts b/src/__tests__/helper/chat-model.ts index d7a2784..8552b1a 100644 --- a/src/__tests__/helper/chat-model.ts +++ b/src/__tests__/helper/chat-model.ts @@ -1,4 +1,4 @@ -import { BaseModel } from "../../storage-lib"; +import { BaseModel } from "../../repository-lib"; export interface ChatModel extends BaseModel { participants: string[]; diff --git a/src/__tests__/helper/chat-storage.ts b/src/__tests__/helper/chat-repository.ts similarity index 60% rename from src/__tests__/helper/chat-storage.ts rename to src/__tests__/helper/chat-repository.ts index cbc7ea3..8b553d9 100644 --- a/src/__tests__/helper/chat-storage.ts +++ b/src/__tests__/helper/chat-repository.ts @@ -1,9 +1,9 @@ -import { GitlabStorage } from "../../storage-lib"; +import { GitlabRepository } from "../../repository-lib"; import { ChatModel } from "./chat-model"; import { GITLAB_NUMBER, gitlabRequest } from "./helper"; import { SingletonFactory } from "../../utils"; -class ChatStorage extends GitlabStorage { +class ChatRepository extends GitlabRepository { constructor() { super(gitlabRequest, GITLAB_NUMBER); } @@ -12,4 +12,4 @@ class ChatStorage extends GitlabStorage { /** * test gitlab api with a chat storage instance. */ -export const Chat = SingletonFactory.createInstance(ChatStorage); \ No newline at end of file +export const Chat = SingletonFactory.createInstance(ChatRepository); \ No newline at end of file diff --git a/src/__tests__/helper/user-model.ts b/src/__tests__/helper/user-model.ts index 37bcc76..5e673c0 100644 --- a/src/__tests__/helper/user-model.ts +++ b/src/__tests__/helper/user-model.ts @@ -1,4 +1,4 @@ -import { BaseModel } from "../.."; +import { BaseModel } from "../../repository-lib"; export interface UserModel extends BaseModel { name: string; age: number; diff --git a/src/__tests__/helper/user-storage.ts b/src/__tests__/helper/user-repository.ts similarity index 59% rename from src/__tests__/helper/user-storage.ts rename to src/__tests__/helper/user-repository.ts index f7c09eb..1216c4e 100644 --- a/src/__tests__/helper/user-storage.ts +++ b/src/__tests__/helper/user-repository.ts @@ -1,9 +1,10 @@ -import { GiteeStorage } from '../..'; + +import { GiteeRepository } from '../../repository-lib'; import { SingletonFactory } from '../../utils'; import { GITEE_NUMBER, giteeRequest } from './helper'; import { UserModel } from './user-model'; -export class UserStorage extends GiteeStorage { +export class UserRepository extends GiteeRepository { constructor() { super(giteeRequest, GITEE_NUMBER); } @@ -12,4 +13,4 @@ export class UserStorage extends GiteeStorage { /** * test gitee api with a user storage instance. */ -export const User = SingletonFactory.createInstance(UserStorage); \ No newline at end of file +export const User = SingletonFactory.createInstance(UserRepository); \ No newline at end of file diff --git a/src/__tests__/user-storage.test.ts b/src/__tests__/user-repository.test.ts similarity index 98% rename from src/__tests__/user-storage.test.ts rename to src/__tests__/user-repository.test.ts index 7d97a39..8e8deb4 100644 --- a/src/__tests__/user-storage.test.ts +++ b/src/__tests__/user-repository.test.ts @@ -1,6 +1,6 @@ -import { PlainObject } from "../storage-lib"; +import { PlainObject } from "../repository-lib"; import { UserModel } from "./helper/user-model"; -import { User } from "./helper/user-storage"; +import { User } from "./helper/user-repository"; import dayjs from 'dayjs'; describe('Test User Storage', () => { diff --git a/src/index.ts b/src/index.ts index 35b8e37..41c8aa2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,8 @@ import { createRequest } from "./request-lib/create-request"; -import { BaseModel, GiteeStorage, GithubStorage, GitlabStorage, PlainObject } from "./storage-lib"; +import { BaseModel, GiteeRepository, GitlabRepository, GithubRepository, PlainObject } from "./repository-lib"; import { SingletonFactory } from "./utils" export { createRequest, BaseModel, PlainObject, - GiteeStorage, GithubStorage, GitlabStorage, SingletonFactory + GiteeRepository, GitlabRepository, GithubRepository, SingletonFactory }; diff --git a/src/storage-lib/base/author.ts b/src/repository-lib/base/author.ts similarity index 100% rename from src/storage-lib/base/author.ts rename to src/repository-lib/base/author.ts diff --git a/src/storage-lib/base/base-comment.ts b/src/repository-lib/base/base-comment.ts similarity index 100% rename from src/storage-lib/base/base-comment.ts rename to src/repository-lib/base/base-comment.ts diff --git a/src/storage-lib/base/base-model.ts b/src/repository-lib/base/base-model.ts similarity index 96% rename from src/storage-lib/base/base-model.ts rename to src/repository-lib/base/base-model.ts index 3e6d978..c358d20 100644 --- a/src/storage-lib/base/base-model.ts +++ b/src/repository-lib/base/base-model.ts @@ -1,7 +1,7 @@ -import { Author } from "./author"; -export interface BaseModel { - id: number; - updated_at: string; - created_at: string; - created_by: Author; +import { Author } from "./author"; +export interface BaseModel { + id: number; + updated_at: string; + created_at: string; + created_by: Author; } \ No newline at end of file diff --git a/src/storage-lib/base/base-params.ts b/src/repository-lib/base/base-params.ts similarity index 98% rename from src/storage-lib/base/base-params.ts rename to src/repository-lib/base/base-params.ts index c6727e0..a3dfbb5 100644 --- a/src/storage-lib/base/base-params.ts +++ b/src/repository-lib/base/base-params.ts @@ -1,5 +1,5 @@ -import { GiteeParams } from "../gitee/gitee-params"; -import { GithubParams } from "../github/github-params"; -import { GitlabParams } from "../gitlab/gitlab-params"; - +import { GiteeParams } from "../gitee/gitee-params"; +import { GithubParams } from "../github/github-params"; +import { GitlabParams } from "../gitlab/gitlab-params"; + export type BaseParams = GiteeParams | GithubParams | GitlabParams; \ No newline at end of file diff --git a/src/storage-lib/base/base-storage.ts b/src/repository-lib/base/base-repository.ts similarity index 96% rename from src/storage-lib/base/base-storage.ts rename to src/repository-lib/base/base-repository.ts index efd200e..49b5b5a 100644 --- a/src/storage-lib/base/base-storage.ts +++ b/src/repository-lib/base/base-repository.ts @@ -1,165 +1,165 @@ -import { BaseRequest } from "../../request-lib"; -import { Author } from "./author"; -import { BaseComment } from "./base-comment"; -import { BaseModel } from "./base-model"; -import { BaseParams } from "./base-params"; -import { PlainObject } from "./plain-object"; -import { RouteType } from "./route-type"; - -export abstract class BaseStorage { - protected endpoint: string; - protected issueNumber: string; - protected readonly useEncrypt: boolean; - protected readonly encryptFn?: (data: string) => string; - protected readonly decryptFn?: (data: string) => string; - - constructor(protected request: BaseRequest, issueNumber?: string) { - this.endpoint = request.getEndpoint(); - - const { useEncrypt, encryptFn, decryptFn } = request.options; - this.useEncrypt = useEncrypt || false; - this.encryptFn = encryptFn; - this.decryptFn = decryptFn; - - if (request.options.issueNumber != null) { - this.issueNumber = request.options.issueNumber; - } else if (issueNumber != null) { - this.issueNumber = issueNumber; - } else { - throw new Error('issueNumber is required'); - } - } - - protected abstract extractUser(comment: BaseComment): Author | null; - - protected getRoute(routeType: keyof typeof RouteType, id?: number): string { - switch (routeType) { - case RouteType.find: - case RouteType.create: - return `${this.endpoint}/issues/${this.issueNumber}/comments`; - case RouteType.findById: - case RouteType.updateById: - case RouteType.deleteById: - return `${this.endpoint}/issues/comments/${id}`; - case RouteType.detail: - return `${this.endpoint}/issues/${this.issueNumber}` - default: - throw new Error(`routeType ${routeType} is not supported`); - } - } - - /** - * Finds items in the storage based on the provided parameters. - * @param params - The parameters used for filtering the items. - * @returns A promise that resolves to an array of items found in the storage. - */ - async find(params?: BaseParams): Promise { - const url = this.getRoute(RouteType.find); - const response = await this.request.get(url, params); - return response.map((item) => this.deserialize(item)); - } - - /** - * Find records by ID. - * @param id Indicates the ID of the record - * @returns Matches the record - */ - async findById(id: number) { - const url = this.getRoute(RouteType.findById, id); - const response = await this.request.get(url); - return this.deserialize(response); - } - - /** - * Creates a new record in the storage. - * - * @param data The data to be stored. - * @returns A promise that resolves to the created record. - */ - async create(data: PlainObject): Promise { - const url = this.getRoute(RouteType.create); - const body = this.serialize>(data); - const response = await this.request.post(url, body); - return this.deserialize(response); - } - - - /** - * Creates multiple records in the storage. - * - * @param data - An array of objects representing the records to be created. - * @param order - Specifies whether the records should be created in the order they appear in the array. Default is false. - * @returns A promise that resolves to an array of created records. - */ - async createAll(data: PlainObject[], order = false): Promise { - if (order === false) { - return Promise.all(data.map((item) => this.create(item))); - } - - const result: T[] = []; - for (const item of data) { - result.push(await this.create(item)); - } - return result; - } - - /** - * Updates a record by its ID. - * @param id - The ID of the record to update. - * @param data - The updated data for the record. - * @returns A promise that resolves to the updated record. - */ - async updateById(id: number, data: PlainObject): Promise { - const url = this.getRoute(RouteType.updateById, id); - const body = this.serialize>(data); - const response = await this.request.patch(url, body); - return this.deserialize(response); - } - - /** - * Deletes an item from the storage by its ID. - * @param id The ID of the item to delete. - * @returns A Promise that resolves when the item is successfully deleted. - */ - async deleteById(id: number): Promise { - const url = this.getRoute(RouteType.deleteById, id); - await this.request.delete(url); - } - - /** - * Deletes all items from the storage. - * @returns A Promise that resolves when all items are deleted. - */ - async deleteAll(): Promise { - const findUrl = this.getRoute(RouteType.find); - const findResult = await this.request.get(findUrl); - await Promise.all(findResult.map((item) => this.deleteById(item.id))); - } - - // 序列化: 将对象转换为字符串 - protected serialize(obj: T): string { - return (this.useEncrypt && this.encryptFn) - ? this.encryptFn(JSON.stringify(obj)) - : JSON.stringify(obj); - } - - // 反序列化: 将字符串转换为对象 - protected deserialize(comment: BaseComment): T { - const { id, body, created_at, updated_at } = comment; - - const parsedBody = this.useEncrypt && this.decryptFn - ? JSON.parse(this.decryptFn(body)) - : JSON.parse(body); - const created_by = this.extractUser(comment); - - const result: T = { - id, - ...parsedBody, - updated_at, - created_at, - created_by - } - - return result; - } +import { BaseRequest } from "../../request-lib"; +import { Author } from "./author"; +import { BaseComment } from "./base-comment"; +import { BaseModel } from "./base-model"; +import { BaseParams } from "./base-params"; +import { PlainObject } from "./plain-object"; +import { RouteType } from "./route-type"; + +export abstract class BaseRepository { + protected endpoint: string; + protected issueNumber: string; + protected readonly useEncrypt: boolean; + protected readonly encryptFn?: (data: string) => string; + protected readonly decryptFn?: (data: string) => string; + + constructor(protected request: BaseRequest, issueNumber?: string) { + this.endpoint = request.getEndpoint(); + + const { useEncrypt, encryptFn, decryptFn } = request.options; + this.useEncrypt = useEncrypt || false; + this.encryptFn = encryptFn; + this.decryptFn = decryptFn; + + if (request.options.issueNumber != null) { + this.issueNumber = request.options.issueNumber; + } else if (issueNumber != null) { + this.issueNumber = issueNumber; + } else { + throw new Error('issueNumber is required'); + } + } + + protected abstract extractUser(comment: BaseComment): Author | null; + + protected getRoute(routeType: keyof typeof RouteType, id?: number): string { + switch (routeType) { + case RouteType.find: + case RouteType.create: + return `${this.endpoint}/issues/${this.issueNumber}/comments`; + case RouteType.findById: + case RouteType.updateById: + case RouteType.deleteById: + return `${this.endpoint}/issues/comments/${id}`; + case RouteType.detail: + return `${this.endpoint}/issues/${this.issueNumber}` + default: + throw new Error(`routeType ${routeType} is not supported`); + } + } + + /** + * Finds items in the storage based on the provided parameters. + * @param params - The parameters used for filtering the items. + * @returns A promise that resolves to an array of items found in the storage. + */ + async find(params?: BaseParams): Promise { + const url = this.getRoute(RouteType.find); + const response = await this.request.get(url, params); + return response.map((item) => this.deserialize(item)); + } + + /** + * Find records by ID. + * @param id Indicates the ID of the record + * @returns Matches the record + */ + async findById(id: number) { + const url = this.getRoute(RouteType.findById, id); + const response = await this.request.get(url); + return this.deserialize(response); + } + + /** + * Creates a new record in the storage. + * + * @param data The data to be stored. + * @returns A promise that resolves to the created record. + */ + async create(data: PlainObject): Promise { + const url = this.getRoute(RouteType.create); + const body = this.serialize>(data); + const response = await this.request.post(url, body); + return this.deserialize(response); + } + + + /** + * Creates multiple records in the storage. + * + * @param data - An array of objects representing the records to be created. + * @param order - Specifies whether the records should be created in the order they appear in the array. Default is false. + * @returns A promise that resolves to an array of created records. + */ + async createAll(data: PlainObject[], order = false): Promise { + if (order === false) { + return Promise.all(data.map((item) => this.create(item))); + } + + const result: T[] = []; + for (const item of data) { + result.push(await this.create(item)); + } + return result; + } + + /** + * Updates a record by its ID. + * @param id - The ID of the record to update. + * @param data - The updated data for the record. + * @returns A promise that resolves to the updated record. + */ + async updateById(id: number, data: PlainObject): Promise { + const url = this.getRoute(RouteType.updateById, id); + const body = this.serialize>(data); + const response = await this.request.patch(url, body); + return this.deserialize(response); + } + + /** + * Deletes an item from the storage by its ID. + * @param id The ID of the item to delete. + * @returns A Promise that resolves when the item is successfully deleted. + */ + async deleteById(id: number): Promise { + const url = this.getRoute(RouteType.deleteById, id); + await this.request.delete(url); + } + + /** + * Deletes all items from the storage. + * @returns A Promise that resolves when all items are deleted. + */ + async deleteAll(): Promise { + const findUrl = this.getRoute(RouteType.find); + const findResult = await this.request.get(findUrl); + await Promise.all(findResult.map((item) => this.deleteById(item.id))); + } + + // 序列化: 将对象转换为字符串 + protected serialize(obj: T): string { + return (this.useEncrypt && this.encryptFn) + ? this.encryptFn(JSON.stringify(obj)) + : JSON.stringify(obj); + } + + // 反序列化: 将字符串转换为对象 + protected deserialize(comment: BaseComment): T { + const { id, body, created_at, updated_at } = comment; + + const parsedBody = this.useEncrypt && this.decryptFn + ? JSON.parse(this.decryptFn(body)) + : JSON.parse(body); + const created_by = this.extractUser(comment); + + const result: T = { + id, + ...parsedBody, + updated_at, + created_at, + created_by + } + + return result; + } } \ No newline at end of file diff --git a/src/storage-lib/base/issue-detail.ts b/src/repository-lib/base/issue-detail.ts similarity index 100% rename from src/storage-lib/base/issue-detail.ts rename to src/repository-lib/base/issue-detail.ts diff --git a/src/storage-lib/base/plain-object.ts b/src/repository-lib/base/plain-object.ts similarity index 100% rename from src/storage-lib/base/plain-object.ts rename to src/repository-lib/base/plain-object.ts diff --git a/src/storage-lib/base/route-type.ts b/src/repository-lib/base/route-type.ts similarity index 100% rename from src/storage-lib/base/route-type.ts rename to src/repository-lib/base/route-type.ts diff --git a/src/storage-lib/gitee/gitee-detail.ts b/src/repository-lib/gitee/gitee-detail.ts similarity index 100% rename from src/storage-lib/gitee/gitee-detail.ts rename to src/repository-lib/gitee/gitee-detail.ts diff --git a/src/storage-lib/gitee/gitee-options.ts b/src/repository-lib/gitee/gitee-options.ts similarity index 100% rename from src/storage-lib/gitee/gitee-options.ts rename to src/repository-lib/gitee/gitee-options.ts diff --git a/src/storage-lib/gitee/gitee-params.ts b/src/repository-lib/gitee/gitee-params.ts similarity index 96% rename from src/storage-lib/gitee/gitee-params.ts rename to src/repository-lib/gitee/gitee-params.ts index 33a51b3..d0b7415 100644 --- a/src/storage-lib/gitee/gitee-params.ts +++ b/src/repository-lib/gitee/gitee-params.ts @@ -1,6 +1,6 @@ -export type GiteeParams = { - since?: string; - page?: number; - per_page?: number; - order?: 'asc' | 'desc'; +export type GiteeParams = { + since?: string; + page?: number; + per_page?: number; + order?: 'asc' | 'desc'; }; \ No newline at end of file diff --git a/src/storage-lib/gitee/gitee-storage.ts b/src/repository-lib/gitee/gitee-repository.ts similarity index 92% rename from src/storage-lib/gitee/gitee-storage.ts rename to src/repository-lib/gitee/gitee-repository.ts index 6151f5f..eff7031 100644 --- a/src/storage-lib/gitee/gitee-storage.ts +++ b/src/repository-lib/gitee/gitee-repository.ts @@ -2,14 +2,14 @@ import { BaseRequest } from "../../request-lib"; import { Author } from "../base/author"; import { BaseComment } from "../base/base-comment"; import { BaseModel } from "../base/base-model"; -import { BaseStorage } from "../base/base-storage"; +import { BaseRepository } from "../base/base-repository"; import { IssueDetail } from "../base/issue-detail"; import { RouteType } from "../base/route-type"; import { GiteeDetail } from "./gitee-detail"; import { GiteeParams } from "./gitee-params"; import { GiteeUser } from "./gitee-user"; -export class GiteeStorage extends BaseStorage { +export class GiteeRepository extends BaseRepository { constructor(protected request: BaseRequest, issueNumber?: string) { super(request, issueNumber); diff --git a/src/storage-lib/gitee/gitee-user.ts b/src/repository-lib/gitee/gitee-user.ts similarity index 95% rename from src/storage-lib/gitee/gitee-user.ts rename to src/repository-lib/gitee/gitee-user.ts index 2376a8c..c3d94b5 100644 --- a/src/storage-lib/gitee/gitee-user.ts +++ b/src/repository-lib/gitee/gitee-user.ts @@ -1,31 +1,31 @@ -export interface GiteeUser { - id: number; - login: string; - name: string; - avatar_url: string; - url: string; - html_url: string; - remark: string; - followers_url: string; - following_url: string; - gists_url: string; - starred_url: string; - subscriptions_url: string; - organizations_url: string; - repos_url: string; - events_url: string; - received_events_url: string; - type: string; - blog: string | null; - weibo: string | null; - bio: string; - public_repos: number; - public_gists: number; - followers: number; - following: number; - stared: number; - watched: number; - created_at: string; - updated_at: string; - email: string | null; +export interface GiteeUser { + id: number; + login: string; + name: string; + avatar_url: string; + url: string; + html_url: string; + remark: string; + followers_url: string; + following_url: string; + gists_url: string; + starred_url: string; + subscriptions_url: string; + organizations_url: string; + repos_url: string; + events_url: string; + received_events_url: string; + type: string; + blog: string | null; + weibo: string | null; + bio: string; + public_repos: number; + public_gists: number; + followers: number; + following: number; + stared: number; + watched: number; + created_at: string; + updated_at: string; + email: string | null; } \ No newline at end of file diff --git a/src/storage-lib/github/github-detail.ts b/src/repository-lib/github/github-detail.ts similarity index 100% rename from src/storage-lib/github/github-detail.ts rename to src/repository-lib/github/github-detail.ts diff --git a/src/storage-lib/github/github-options.ts b/src/repository-lib/github/github-options.ts similarity index 100% rename from src/storage-lib/github/github-options.ts rename to src/repository-lib/github/github-options.ts diff --git a/src/storage-lib/github/github-params.ts b/src/repository-lib/github/github-params.ts similarity index 95% rename from src/storage-lib/github/github-params.ts rename to src/repository-lib/github/github-params.ts index 4b3f20c..9a41842 100644 --- a/src/storage-lib/github/github-params.ts +++ b/src/repository-lib/github/github-params.ts @@ -1,5 +1,5 @@ -export type GithubParams = { - since?: string; - page?: number; - per_page?: number; +export type GithubParams = { + since?: string; + page?: number; + per_page?: number; }; \ No newline at end of file diff --git a/src/storage-lib/github/github-storage.ts b/src/repository-lib/github/github-repository.ts similarity index 92% rename from src/storage-lib/github/github-storage.ts rename to src/repository-lib/github/github-repository.ts index 003c354..1673e32 100644 --- a/src/storage-lib/github/github-storage.ts +++ b/src/repository-lib/github/github-repository.ts @@ -2,14 +2,14 @@ import { BaseRequest } from "../../request-lib"; import { Author } from "../base/author"; import { BaseComment } from "../base/base-comment"; import { BaseModel } from "../base/base-model"; -import { BaseStorage } from "../base/base-storage"; +import { BaseRepository } from "../base/base-repository"; import { IssueDetail } from "../base/issue-detail"; import { RouteType } from "../base/route-type"; import { GithubDetail } from "./github-detail"; import { GithubParams } from "./github-params"; import { GithubUser } from "./github-user"; -export class GithubStorage extends BaseStorage { +export class GithubRepository extends BaseRepository { constructor(protected request: BaseRequest, issueNumber?: string) { super(request, issueNumber); diff --git a/src/storage-lib/github/github-user.ts b/src/repository-lib/github/github-user.ts similarity index 96% rename from src/storage-lib/github/github-user.ts rename to src/repository-lib/github/github-user.ts index c33add1..3e00189 100644 --- a/src/storage-lib/github/github-user.ts +++ b/src/repository-lib/github/github-user.ts @@ -1,34 +1,34 @@ -export interface GithubUser { - login: string; - id: number; - node_id: string; - avatar_url: string; - gravatar_id: string; - url: string; - html_url: string; - followers_url: string; - following_url: string; - gists_url: string; - starred_url: string; - subscriptions_url: string; - organizations_url: string; - repos_url: string; - events_url: string; - received_events_url: string; - type: string; - site_admin: boolean; - name: string; - company: string | null; - blog: string; - location: string | null; - email: string | null; - hireable: boolean | null; - bio: string; - twitter_username: string | null; - public_repos: number; - public_gists: number; - followers: number; - following: number; - created_at: string; - updated_at: string; +export interface GithubUser { + login: string; + id: number; + node_id: string; + avatar_url: string; + gravatar_id: string; + url: string; + html_url: string; + followers_url: string; + following_url: string; + gists_url: string; + starred_url: string; + subscriptions_url: string; + organizations_url: string; + repos_url: string; + events_url: string; + received_events_url: string; + type: string; + site_admin: boolean; + name: string; + company: string | null; + blog: string; + location: string | null; + email: string | null; + hireable: boolean | null; + bio: string; + twitter_username: string | null; + public_repos: number; + public_gists: number; + followers: number; + following: number; + created_at: string; + updated_at: string; } \ No newline at end of file diff --git a/src/storage-lib/gitlab/gitlab-detail.ts b/src/repository-lib/gitlab/gitlab-detail.ts similarity index 100% rename from src/storage-lib/gitlab/gitlab-detail.ts rename to src/repository-lib/gitlab/gitlab-detail.ts diff --git a/src/storage-lib/gitlab/gitlab-options.ts b/src/repository-lib/gitlab/gitlab-options.ts similarity index 100% rename from src/storage-lib/gitlab/gitlab-options.ts rename to src/repository-lib/gitlab/gitlab-options.ts diff --git a/src/storage-lib/gitlab/gitlab-params.ts b/src/repository-lib/gitlab/gitlab-params.ts similarity index 97% rename from src/storage-lib/gitlab/gitlab-params.ts rename to src/repository-lib/gitlab/gitlab-params.ts index 3ddd926..f67c59b 100644 --- a/src/storage-lib/gitlab/gitlab-params.ts +++ b/src/repository-lib/gitlab/gitlab-params.ts @@ -1,4 +1,4 @@ -export type GitlabParams = { - sort?: 'asc' | 'desc'; - order_by?: 'created_at' | 'updated_at'; +export type GitlabParams = { + sort?: 'asc' | 'desc'; + order_by?: 'created_at' | 'updated_at'; }; \ No newline at end of file diff --git a/src/storage-lib/gitlab/gitlab-storage.ts b/src/repository-lib/gitlab/gitlab-repository.ts similarity index 96% rename from src/storage-lib/gitlab/gitlab-storage.ts rename to src/repository-lib/gitlab/gitlab-repository.ts index 58a8542..51de6ef 100644 --- a/src/storage-lib/gitlab/gitlab-storage.ts +++ b/src/repository-lib/gitlab/gitlab-repository.ts @@ -1,7 +1,7 @@ import { BaseRequest } from "../../request-lib"; import { BaseComment } from "../base/base-comment"; import { BaseModel } from "../base/base-model"; -import { BaseStorage } from "../base/base-storage"; +import { BaseRepository } from "../base/base-repository"; import { IssueDetail } from "../base/issue-detail"; import { PlainObject } from "../base/plain-object"; import { RouteType } from "../base/route-type"; @@ -10,7 +10,7 @@ import { GitlabDetail } from "./gitlab-detail"; import { GitlabParams } from "./gitlab-params"; import { GitlabUser } from "./gitlab-user"; -export class GitlabStorage extends BaseStorage { +export class GitlabRepository extends BaseRepository { constructor(protected request: BaseRequest, issueNumber?: string) { super(request, issueNumber); diff --git a/src/storage-lib/gitlab/gitlab-user.ts b/src/repository-lib/gitlab/gitlab-user.ts similarity index 96% rename from src/storage-lib/gitlab/gitlab-user.ts rename to src/repository-lib/gitlab/gitlab-user.ts index 8b62120..2a9747b 100644 --- a/src/storage-lib/gitlab/gitlab-user.ts +++ b/src/repository-lib/gitlab/gitlab-user.ts @@ -1,42 +1,42 @@ -export interface GitlabUser { - id: number; - username: string; - name: string; - state: string; - locked: boolean; - avatar_url: string; - web_url: string; - created_at: string; - bio: string; - location: string; - public_email: string | null; - skype: string; - linkedin: string; - twitter: string; - discord: string; - website_url: string; - organization: string; - job_title: string; - pronouns: string | null; - bot: boolean; - work_information: any | null; - local_time: string | null; - last_sign_in_at: string | null; - confirmed_at: string; - last_activity_on: string; - email: string; - theme_id: number; - color_scheme_id: number; - projects_limit: number; - current_sign_in_at: string | null; - identities: any[]; - can_create_group: boolean; - can_create_project: boolean; - two_factor_enabled: boolean; - external: boolean; - private_profile: boolean; - commit_email: string; - shared_runners_minutes_limit: number | null; - extra_shared_runners_minutes_limit: number | null; - scim_identities: any[]; +export interface GitlabUser { + id: number; + username: string; + name: string; + state: string; + locked: boolean; + avatar_url: string; + web_url: string; + created_at: string; + bio: string; + location: string; + public_email: string | null; + skype: string; + linkedin: string; + twitter: string; + discord: string; + website_url: string; + organization: string; + job_title: string; + pronouns: string | null; + bot: boolean; + work_information: any | null; + local_time: string | null; + last_sign_in_at: string | null; + confirmed_at: string; + last_activity_on: string; + email: string; + theme_id: number; + color_scheme_id: number; + projects_limit: number; + current_sign_in_at: string | null; + identities: any[]; + can_create_group: boolean; + can_create_project: boolean; + two_factor_enabled: boolean; + external: boolean; + private_profile: boolean; + commit_email: string; + shared_runners_minutes_limit: number | null; + extra_shared_runners_minutes_limit: number | null; + scim_identities: any[]; } \ No newline at end of file diff --git a/src/storage-lib/index.ts b/src/repository-lib/index.ts similarity index 71% rename from src/storage-lib/index.ts rename to src/repository-lib/index.ts index 34f9baa..59aa21f 100644 --- a/src/storage-lib/index.ts +++ b/src/repository-lib/index.ts @@ -1,14 +1,14 @@ -export { BaseModel } from './base/base-model'; -export { PlainObject } from './base/plain-object'; -/** Gitee */ -export { GiteeUser } from './gitee/gitee-user'; -export { GiteeOptions } from './gitee/gitee-options'; -export { GiteeStorage } from './gitee/gitee-storage'; -/** Github */ -export { GithubUser } from './github/github-user'; -export { GithubOptions } from './github/github-options'; -export { GithubStorage } from './github/github-storage'; -/** Gitlab */ -export { GitlabUser } from './gitlab/gitlab-user'; -export { GitlabOptions } from './gitlab/gitlab-options'; -export { GitlabStorage } from './gitlab/gitlab-storage'; \ No newline at end of file +export { BaseModel } from './base/base-model'; +export { PlainObject } from './base/plain-object'; +/** Gitee */ +export { GiteeUser } from './gitee/gitee-user'; +export { GiteeOptions } from './gitee/gitee-options'; +export { GiteeRepository } from './gitee/gitee-repository'; +/** Github */ +export { GithubUser } from './github/github-user'; +export { GithubOptions } from './github/github-options'; +export { GithubRepository } from './github/github-repository'; +/** Gitlab */ +export { GitlabUser } from './gitlab/gitlab-user'; +export { GitlabOptions } from './gitlab/gitlab-options'; +export { GitlabRepository } from './gitlab/gitlab-repository'; \ No newline at end of file diff --git a/src/request-lib/base/base-request.ts b/src/request-lib/base/base-request.ts index 27aa54d..6faaf28 100644 --- a/src/request-lib/base/base-request.ts +++ b/src/request-lib/base/base-request.ts @@ -1,5 +1,5 @@ import { StoragePlatform } from "../../enums"; -import { GiteeUser, GithubUser, GitlabUser } from "../../storage-lib"; +import { GiteeUser, GithubUser, GitlabUser } from "../../repository-lib"; import { RequestMethods } from "./request-methods"; import { RequestOptions } from "./request-options"; diff --git a/src/request-lib/base/request-options.ts b/src/request-lib/base/request-options.ts index de2356a..e022b62 100644 --- a/src/request-lib/base/request-options.ts +++ b/src/request-lib/base/request-options.ts @@ -1,4 +1,4 @@ -import { GiteeOptions, GithubOptions, GitlabOptions } from "../../storage-lib"; +import { GiteeOptions, GithubOptions, GitlabOptions } from "../../repository-lib"; import { AxiosOptions } from "../axios/axios-options"; import { WxOptions } from "../wx/wx-options";