This repository has been archived by the owner on Jan 25, 2025. It is now read-only.
-
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.
- Loading branch information
Showing
17 changed files
with
231 additions
and
65 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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,23 @@ | ||
import BaseData from '@sx/base-data' | ||
|
||
|
||
enum RepositoryType { | ||
BITBUCKET = 'bitbucket', | ||
GITHUB = 'github', | ||
GITLAB = 'gitlab' | ||
} | ||
|
||
interface RepositoryApiData extends BaseData { | ||
created_at: string | null | ||
entity_type: string | null | ||
external_id: string | null | ||
full_name: string | null | ||
id: number | null | ||
name: string | null | ||
type: RepositoryType | null | ||
updated_at: string | null | ||
url: string | null | ||
} | ||
|
||
export default RepositoryApiData | ||
export { RepositoryType } |
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,17 @@ | ||
import BaseInterface from '@sx/base-interface' | ||
import {RepositoryType} from '@sx/repositories/contracts/repository-api-data' | ||
|
||
|
||
interface RepositoryInterface extends BaseInterface { | ||
createdAt: Date | null | ||
entityType: string | null | ||
externalId: string | null | ||
fullName: string | null | ||
id: number | null | ||
name: string | null | ||
type: RepositoryType | ||
updatedAt: Date | null | ||
url: string | null | ||
} | ||
|
||
export default RepositoryInterface |
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 BaseService, {ServiceOperation} from '@sx/base-service' | ||
import RepositoryInterface from '@sx/repositories/contracts/repository' | ||
import Repository from '@sx/repositories/repository' | ||
|
||
|
||
class RepositoriesService extends BaseService<Repository, RepositoryInterface>{ | ||
public baseUrl = 'https://api.app.shortcut.com/api/v3/repositories' | ||
protected factory = (data: RepositoryInterface) => new Repository(data) | ||
public availableOperations: ServiceOperation[] = ['get', 'list'] | ||
} | ||
|
||
export default RepositoriesService |
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,26 @@ | ||
import ShortcutResource, {ResourceOperation} from '@sx/base-resource' | ||
import RepositoryInterface from '@sx/repositories/contracts/repository' | ||
import {RepositoryType} from '@sx/repositories/contracts/repository-api-data' | ||
|
||
|
||
class Repository extends ShortcutResource<RepositoryInterface> implements RepositoryInterface { | ||
public availableOperations: ResourceOperation[] = [] | ||
|
||
createdAt: Date | null | ||
entityType: string | null | ||
externalId: string | null | ||
fullName: string | null | ||
id: number | null | ||
name: string | null | ||
type: RepositoryType | ||
updatedAt: Date | null | ||
url: string | null | ||
|
||
constructor(init: RepositoryInterface) { | ||
super() | ||
Object.assign(this, init) | ||
this.changedFields = [] | ||
} | ||
} | ||
|
||
export default Repository |
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
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
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
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 RepositoriesService from '@sx/repositories/repositories-service' | ||
|
||
|
||
describe('RepositoriesService', () => { | ||
it('should instantiate a new RepositoriesService', () => { | ||
const repositoriesService = new RepositoriesService({headers: {}}) | ||
expect(repositoriesService).toBeInstanceOf(RepositoriesService) | ||
expect(repositoriesService.baseUrl).toEqual('https://api.app.shortcut.com/api/v3/repositories') | ||
expect(repositoriesService.availableOperations).toEqual(['get', 'list']) | ||
}) | ||
}) |
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 RepositoryInterface from '@sx/repositories/contracts/repository' | ||
import Repository from '@sx/repositories/repository' | ||
|
||
|
||
describe('Repository', () => { | ||
it('should instantiate a new Repository', () => { | ||
const repositoryData = { | ||
createdAt: new Date(), | ||
entityType: 'entityType', | ||
externalId: 'externalId', | ||
fullName: 'fullName', | ||
id: 1, | ||
name: 'name', | ||
type: 'type', | ||
updatedAt: new Date(), | ||
url: 'url' | ||
} as object as RepositoryInterface | ||
const repository = new Repository(repositoryData) | ||
expect(repository).toBeInstanceOf(Repository) | ||
expect(repository.createdAt).toEqual(repositoryData.createdAt) | ||
expect(repository.entityType).toEqual(repositoryData.entityType) | ||
expect(repository.externalId).toEqual(repositoryData.externalId) | ||
expect(repository.fullName).toEqual(repositoryData.fullName) | ||
expect(repository.id).toEqual(repositoryData.id) | ||
expect(repository.name).toEqual(repositoryData.name) | ||
expect(repository.type).toEqual(repositoryData.type) | ||
expect(repository.updatedAt).toEqual(repositoryData.updatedAt) | ||
expect(repository.url).toEqual(repositoryData.url) | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.