declastruct-github 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/.test/assets/getSampleGithubContext.d.ts +6 -0
- package/dist/.test/assets/getSampleGithubContext.js +18 -0
- package/dist/.test/assets/getSampleGithubContext.js.map +1 -0
- package/dist/.test/assets/getSampleRepo.d.ts +9 -0
- package/dist/.test/assets/getSampleRepo.js +19 -0
- package/dist/.test/assets/getSampleRepo.js.map +1 -0
- package/dist/access/daos/DeclaredGithubBranchDao.d.ts +10 -0
- package/dist/access/daos/DeclaredGithubBranchDao.js +35 -0
- package/dist/access/daos/DeclaredGithubBranchDao.js.map +1 -0
- package/dist/access/daos/DeclaredGithubBranchProtectionDao.d.ts +9 -0
- package/dist/access/daos/DeclaredGithubBranchProtectionDao.js +34 -0
- package/dist/access/daos/DeclaredGithubBranchProtectionDao.js.map +1 -0
- package/dist/access/daos/DeclaredGithubRepoConfigDao.d.ts +9 -0
- package/dist/access/daos/DeclaredGithubRepoConfigDao.js +34 -0
- package/dist/access/daos/DeclaredGithubRepoConfigDao.js.map +1 -0
- package/dist/access/daos/DeclaredGithubRepoDao.d.ts +9 -0
- package/dist/access/daos/DeclaredGithubRepoDao.js +34 -0
- package/dist/access/daos/DeclaredGithubRepoDao.js.map +1 -0
- package/dist/access/sdks/getGithubClient.d.ts +8 -0
- package/dist/access/sdks/getGithubClient.js +22 -0
- package/dist/access/sdks/getGithubClient.js.map +1 -0
- package/dist/contract/sdks/declastruct.acceptance.test.d.ts +1 -0
- package/dist/contract/sdks/declastruct.acceptance.test.js +104 -0
- package/dist/contract/sdks/declastruct.acceptance.test.js.map +1 -0
- package/dist/contract/sdks/index.d.ts +10 -0
- package/dist/contract/sdks/index.js +20 -0
- package/dist/contract/sdks/index.js.map +1 -0
- package/dist/domain.objects/ContextGithubApi.d.ts +9 -0
- package/dist/domain.objects/ContextGithubApi.js +3 -0
- package/dist/domain.objects/ContextGithubApi.js.map +1 -0
- package/dist/domain.objects/DeclaredGithubBranch.d.ts +39 -0
- package/dist/domain.objects/DeclaredGithubBranch.js +12 -0
- package/dist/domain.objects/DeclaredGithubBranch.js.map +1 -0
- package/dist/domain.objects/DeclaredGithubBranchProtection.d.ts +108 -0
- package/dist/domain.objects/DeclaredGithubBranchProtection.js +12 -0
- package/dist/domain.objects/DeclaredGithubBranchProtection.js.map +1 -0
- package/dist/domain.objects/DeclaredGithubRepo.d.ts +57 -0
- package/dist/domain.objects/DeclaredGithubRepo.js +9 -0
- package/dist/domain.objects/DeclaredGithubRepo.js.map +1 -0
- package/dist/domain.objects/DeclaredGithubRepoConfig.d.ts +100 -0
- package/dist/domain.objects/DeclaredGithubRepoConfig.js +12 -0
- package/dist/domain.objects/DeclaredGithubRepoConfig.js.map +1 -0
- package/dist/domain.objects/DeclastructGithubProvider.d.ts +17 -0
- package/dist/domain.objects/DeclastructGithubProvider.js +3 -0
- package/dist/domain.objects/DeclastructGithubProvider.js.map +1 -0
- package/dist/domain.operations/branch/castToDeclaredGithubBranch.d.ts +15 -0
- package/dist/domain.operations/branch/castToDeclaredGithubBranch.js +39 -0
- package/dist/domain.operations/branch/castToDeclaredGithubBranch.js.map +1 -0
- package/dist/domain.operations/branch/getBranch.d.ts +14 -0
- package/dist/domain.operations/branch/getBranch.integration.test.d.ts +1 -0
- package/dist/domain.operations/branch/getBranch.integration.test.js +59 -0
- package/dist/domain.operations/branch/getBranch.integration.test.js.map +1 -0
- package/dist/domain.operations/branch/getBranch.js +50 -0
- package/dist/domain.operations/branch/getBranch.js.map +1 -0
- package/dist/domain.operations/branch/getBranchCommitShaByRepoDefault.d.ts +11 -0
- package/dist/domain.operations/branch/getBranchCommitShaByRepoDefault.js +37 -0
- package/dist/domain.operations/branch/getBranchCommitShaByRepoDefault.js.map +1 -0
- package/dist/domain.operations/branch/getBranches.d.ts +23 -0
- package/dist/domain.operations/branch/getBranches.integration.test.d.ts +1 -0
- package/dist/domain.operations/branch/getBranches.integration.test.js +40 -0
- package/dist/domain.operations/branch/getBranches.integration.test.js.map +1 -0
- package/dist/domain.operations/branch/getBranches.js +33 -0
- package/dist/domain.operations/branch/getBranches.js.map +1 -0
- package/dist/domain.operations/branch/setBranch.d.ts +12 -0
- package/dist/domain.operations/branch/setBranch.integration.test.d.ts +1 -0
- package/dist/domain.operations/branch/setBranch.integration.test.js +65 -0
- package/dist/domain.operations/branch/setBranch.integration.test.js.map +1 -0
- package/dist/domain.operations/branch/setBranch.js +100 -0
- package/dist/domain.operations/branch/setBranch.js.map +1 -0
- package/dist/domain.operations/branch/setBranch.test.d.ts +1 -0
- package/dist/domain.operations/branch/setBranch.test.js +151 -0
- package/dist/domain.operations/branch/setBranch.test.js.map +1 -0
- package/dist/domain.operations/branchProtection/castToDeclaredGithubBranchProtection.d.ts +14 -0
- package/dist/domain.operations/branchProtection/castToDeclaredGithubBranchProtection.js +66 -0
- package/dist/domain.operations/branchProtection/castToDeclaredGithubBranchProtection.js.map +1 -0
- package/dist/domain.operations/branchProtection/getBranchProtection.d.ts +14 -0
- package/dist/domain.operations/branchProtection/getBranchProtection.integration.test.d.ts +1 -0
- package/dist/domain.operations/branchProtection/getBranchProtection.integration.test.js +63 -0
- package/dist/domain.operations/branchProtection/getBranchProtection.integration.test.js.map +1 -0
- package/dist/domain.operations/branchProtection/getBranchProtection.js +53 -0
- package/dist/domain.operations/branchProtection/getBranchProtection.js.map +1 -0
- package/dist/domain.operations/branchProtection/setBranchProtection.d.ts +12 -0
- package/dist/domain.operations/branchProtection/setBranchProtection.integration.test.d.ts +1 -0
- package/dist/domain.operations/branchProtection/setBranchProtection.integration.test.js +96 -0
- package/dist/domain.operations/branchProtection/setBranchProtection.integration.test.js.map +1 -0
- package/dist/domain.operations/branchProtection/setBranchProtection.js +90 -0
- package/dist/domain.operations/branchProtection/setBranchProtection.js.map +1 -0
- package/dist/domain.operations/branchProtection/setBranchProtection.test.d.ts +1 -0
- package/dist/domain.operations/branchProtection/setBranchProtection.test.js +173 -0
- package/dist/domain.operations/branchProtection/setBranchProtection.test.js.map +1 -0
- package/dist/domain.operations/provider/getDeclastructGithubProvider.d.ts +11 -0
- package/dist/domain.operations/provider/getDeclastructGithubProvider.integration.test.d.ts +1 -0
- package/dist/domain.operations/provider/getDeclastructGithubProvider.integration.test.js +212 -0
- package/dist/domain.operations/provider/getDeclastructGithubProvider.integration.test.js.map +1 -0
- package/dist/domain.operations/provider/getDeclastructGithubProvider.js +44 -0
- package/dist/domain.operations/provider/getDeclastructGithubProvider.js.map +1 -0
- package/dist/domain.operations/repo/castToDeclaredGithubRepo.d.ts +10 -0
- package/dist/domain.operations/repo/castToDeclaredGithubRepo.js +42 -0
- package/dist/domain.operations/repo/castToDeclaredGithubRepo.js.map +1 -0
- package/dist/domain.operations/repo/getRepo.d.ts +14 -0
- package/dist/domain.operations/repo/getRepo.integration.test.d.ts +1 -0
- package/dist/domain.operations/repo/getRepo.integration.test.js +45 -0
- package/dist/domain.operations/repo/getRepo.integration.test.js.map +1 -0
- package/dist/domain.operations/repo/getRepo.js +38 -0
- package/dist/domain.operations/repo/getRepo.js.map +1 -0
- package/dist/domain.operations/repo/getRepos.d.ts +21 -0
- package/dist/domain.operations/repo/getRepos.integration.test.d.ts +1 -0
- package/dist/domain.operations/repo/getRepos.integration.test.js +28 -0
- package/dist/domain.operations/repo/getRepos.integration.test.js.map +1 -0
- package/dist/domain.operations/repo/getRepos.js +41 -0
- package/dist/domain.operations/repo/getRepos.js.map +1 -0
- package/dist/domain.operations/repo/setRepo.d.ts +12 -0
- package/dist/domain.operations/repo/setRepo.integration.test.d.ts +1 -0
- package/dist/domain.operations/repo/setRepo.integration.test.js +29 -0
- package/dist/domain.operations/repo/setRepo.integration.test.js.map +1 -0
- package/dist/domain.operations/repo/setRepo.js +70 -0
- package/dist/domain.operations/repo/setRepo.js.map +1 -0
- package/dist/domain.operations/repo/setRepo.test.d.ts +1 -0
- package/dist/domain.operations/repo/setRepo.test.js +150 -0
- package/dist/domain.operations/repo/setRepo.test.js.map +1 -0
- package/dist/domain.operations/repoConfig/castToDeclaredGithubRepoConfig.d.ts +15 -0
- package/dist/domain.operations/repoConfig/castToDeclaredGithubRepoConfig.js +36 -0
- package/dist/domain.operations/repoConfig/castToDeclaredGithubRepoConfig.js.map +1 -0
- package/dist/domain.operations/repoConfig/getRepoConfig.d.ts +14 -0
- package/dist/domain.operations/repoConfig/getRepoConfig.integration.test.d.ts +1 -0
- package/dist/domain.operations/repoConfig/getRepoConfig.integration.test.js +55 -0
- package/dist/domain.operations/repoConfig/getRepoConfig.integration.test.js.map +1 -0
- package/dist/domain.operations/repoConfig/getRepoConfig.js +47 -0
- package/dist/domain.operations/repoConfig/getRepoConfig.js.map +1 -0
- package/dist/domain.operations/repoConfig/setRepoConfig.d.ts +12 -0
- package/dist/domain.operations/repoConfig/setRepoConfig.integration.test.d.ts +1 -0
- package/dist/domain.operations/repoConfig/setRepoConfig.integration.test.js +87 -0
- package/dist/domain.operations/repoConfig/setRepoConfig.integration.test.js.map +1 -0
- package/dist/domain.operations/repoConfig/setRepoConfig.js +65 -0
- package/dist/domain.operations/repoConfig/setRepoConfig.js.map +1 -0
- package/package.json +104 -0
- package/readme.md +181 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { DomainEntity, RefByUnique } from 'domain-objects';
|
|
2
|
+
import { DeclaredGithubBranch } from './DeclaredGithubBranch';
|
|
3
|
+
/**
|
|
4
|
+
* .what = a declarative structure which represents GitHub branch protection rules
|
|
5
|
+
* .why = enables declarative management of branch protection settings following declastruct patterns
|
|
6
|
+
*/
|
|
7
|
+
export interface DeclaredGithubBranchProtection {
|
|
8
|
+
/**
|
|
9
|
+
* .what = reference to the branch this protection applies to
|
|
10
|
+
* .note = 1:1 relationship - protection is part of branch, not separate resource
|
|
11
|
+
*/
|
|
12
|
+
branch: RefByUnique<typeof DeclaredGithubBranch>;
|
|
13
|
+
/**
|
|
14
|
+
* .what = whether to enforce rules for administrators
|
|
15
|
+
*/
|
|
16
|
+
enforceAdmins?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* .what = whether to allow branch deletion
|
|
19
|
+
*/
|
|
20
|
+
allowsDeletions?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* .what = whether to allow force pushes
|
|
23
|
+
*/
|
|
24
|
+
allowsForcePushes?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* .what = whether to require linear history (no merge commits)
|
|
27
|
+
*/
|
|
28
|
+
requireLinearHistory?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* .what = whether to block branch creation matching this pattern
|
|
31
|
+
*/
|
|
32
|
+
blockCreations?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* .what = whether to lock branch (read-only)
|
|
35
|
+
*/
|
|
36
|
+
lockBranch?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* .what = whether to allow fork syncing
|
|
39
|
+
*/
|
|
40
|
+
allowForkSyncing?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* .what = required status check settings
|
|
43
|
+
* .note = null if not configured
|
|
44
|
+
*/
|
|
45
|
+
requiredStatusChecks?: {
|
|
46
|
+
/**
|
|
47
|
+
* .what = whether branch must be up to date before merging
|
|
48
|
+
*/
|
|
49
|
+
strict: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* .what = required status check context names
|
|
52
|
+
*/
|
|
53
|
+
contexts: string[];
|
|
54
|
+
} | null;
|
|
55
|
+
/**
|
|
56
|
+
* .what = required pull request review settings
|
|
57
|
+
* .note = null if not configured
|
|
58
|
+
*/
|
|
59
|
+
requiredPullRequestReviews?: {
|
|
60
|
+
/**
|
|
61
|
+
* .what = whether to dismiss stale reviews when new commits are pushed
|
|
62
|
+
*/
|
|
63
|
+
dismissStaleReviews?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* .what = whether to require review from code owners
|
|
66
|
+
*/
|
|
67
|
+
requireCodeOwnerReviews?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* .what = number of required approving reviews
|
|
70
|
+
*/
|
|
71
|
+
requiredApprovingReviewCount?: number;
|
|
72
|
+
/**
|
|
73
|
+
* .what = who can dismiss pull request reviews
|
|
74
|
+
*/
|
|
75
|
+
dismissalRestrictions?: {
|
|
76
|
+
users?: string[];
|
|
77
|
+
teams?: string[];
|
|
78
|
+
apps?: string[];
|
|
79
|
+
};
|
|
80
|
+
} | null;
|
|
81
|
+
/**
|
|
82
|
+
* .what = who can push to this branch
|
|
83
|
+
* .note = null if no restrictions
|
|
84
|
+
*/
|
|
85
|
+
restrictions?: {
|
|
86
|
+
users?: string[];
|
|
87
|
+
teams?: string[];
|
|
88
|
+
apps?: string[];
|
|
89
|
+
} | null;
|
|
90
|
+
/**
|
|
91
|
+
* .what = whether to require signed commits
|
|
92
|
+
*/
|
|
93
|
+
requiredSignatures?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* .what = whether to require conversation resolution before merging
|
|
96
|
+
*/
|
|
97
|
+
requiredConversationResolution?: boolean;
|
|
98
|
+
}
|
|
99
|
+
export declare class DeclaredGithubBranchProtection extends DomainEntity<DeclaredGithubBranchProtection> implements DeclaredGithubBranchProtection {
|
|
100
|
+
static unique: readonly ["branch"];
|
|
101
|
+
static nested: {
|
|
102
|
+
branch: {
|
|
103
|
+
new (props: RefByUnique<typeof DeclaredGithubBranch, any, any, any>): RefByUnique<typeof DeclaredGithubBranch, any, any, any>;
|
|
104
|
+
build<TDobj extends import("domain-objects").Refable<TShape, TPrimary, TUnique>, TShape extends import("domain-objects/dist/reference/Refable").DomainObjectShape = any, TPrimary extends readonly string[] = any, TUnique extends readonly string[] = any>(props: RefByUnique<TDobj, TShape, TPrimary, TUnique>): RefByUnique<TDobj, TShape, TPrimary, TUnique>;
|
|
105
|
+
as<TDobj_1 extends import("domain-objects").Refable<TShape_1, TPrimary_1, TUnique_1>, TShape_1 extends import("domain-objects/dist/reference/Refable").DomainObjectShape = any, TPrimary_1 extends readonly string[] = any, TUnique_1 extends readonly string[] = any>(props: RefByUnique<TDobj_1, TShape_1, TPrimary_1, TUnique_1>): RefByUnique<TDobj_1, TShape_1, TPrimary_1, TUnique_1>;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeclaredGithubBranchProtection = void 0;
|
|
4
|
+
const domain_objects_1 = require("domain-objects");
|
|
5
|
+
class DeclaredGithubBranchProtection extends domain_objects_1.DomainEntity {
|
|
6
|
+
}
|
|
7
|
+
exports.DeclaredGithubBranchProtection = DeclaredGithubBranchProtection;
|
|
8
|
+
DeclaredGithubBranchProtection.unique = ['branch'];
|
|
9
|
+
DeclaredGithubBranchProtection.nested = {
|
|
10
|
+
branch: (domain_objects_1.RefByUnique),
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=DeclaredGithubBranchProtection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeclaredGithubBranchProtection.js","sourceRoot":"","sources":["../../src/domain.objects/DeclaredGithubBranchProtection.ts"],"names":[],"mappings":";;;AAAA,mDAA2D;AAqH3D,MAAa,8BACX,SAAQ,6BAA4C;;AADtD,wEAQC;AAJe,qCAAM,GAAG,CAAC,QAAQ,CAAU,CAAC;AAC7B,qCAAM,GAAG;IACrB,MAAM,EAAE,CAAA,4BAAwC,CAAA;CACjD,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { UniDateTime } from '@ehmpathy/uni-time';
|
|
2
|
+
import { DomainEntity } from 'domain-objects';
|
|
3
|
+
/**
|
|
4
|
+
* .what = a declarative structure which represents a GitHub repository
|
|
5
|
+
* .why = enables declarative management of GitHub repos following declastruct patterns
|
|
6
|
+
*/
|
|
7
|
+
export interface DeclaredGithubRepo {
|
|
8
|
+
/**
|
|
9
|
+
* .what = GitHub's internal repo ID
|
|
10
|
+
* .note = is @metadata -> may be undefined
|
|
11
|
+
*/
|
|
12
|
+
id?: number;
|
|
13
|
+
/**
|
|
14
|
+
* .what = when the repo was created
|
|
15
|
+
* .note = is @metadata -> may be undefined
|
|
16
|
+
*/
|
|
17
|
+
createdAt?: UniDateTime;
|
|
18
|
+
/**
|
|
19
|
+
* .what = when the repo was last updated
|
|
20
|
+
* .note = is @metadata -> may be undefined
|
|
21
|
+
*/
|
|
22
|
+
updatedAt?: UniDateTime;
|
|
23
|
+
/**
|
|
24
|
+
* .what = organization or user name
|
|
25
|
+
*/
|
|
26
|
+
owner: string;
|
|
27
|
+
/**
|
|
28
|
+
* .what = repository name
|
|
29
|
+
*/
|
|
30
|
+
name: string;
|
|
31
|
+
/**
|
|
32
|
+
* .what = repository description
|
|
33
|
+
* .note = null if not set
|
|
34
|
+
*/
|
|
35
|
+
description: string | null;
|
|
36
|
+
/**
|
|
37
|
+
* .what = homepage URL
|
|
38
|
+
* .note = null if not set
|
|
39
|
+
*/
|
|
40
|
+
homepage: string | null;
|
|
41
|
+
/**
|
|
42
|
+
* .what = whether the repo is private
|
|
43
|
+
*/
|
|
44
|
+
private: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* .what = visibility setting
|
|
47
|
+
* .note = public, private, or internal (for enterprise)
|
|
48
|
+
*/
|
|
49
|
+
visibility: 'public' | 'private' | 'internal';
|
|
50
|
+
/**
|
|
51
|
+
* .what = whether the repo is archived
|
|
52
|
+
*/
|
|
53
|
+
archived: boolean;
|
|
54
|
+
}
|
|
55
|
+
export declare class DeclaredGithubRepo extends DomainEntity<DeclaredGithubRepo> implements DeclaredGithubRepo {
|
|
56
|
+
static unique: readonly ["owner", "name"];
|
|
57
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeclaredGithubRepo = void 0;
|
|
4
|
+
const domain_objects_1 = require("domain-objects");
|
|
5
|
+
class DeclaredGithubRepo extends domain_objects_1.DomainEntity {
|
|
6
|
+
}
|
|
7
|
+
exports.DeclaredGithubRepo = DeclaredGithubRepo;
|
|
8
|
+
DeclaredGithubRepo.unique = ['owner', 'name'];
|
|
9
|
+
//# sourceMappingURL=DeclaredGithubRepo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeclaredGithubRepo.js","sourceRoot":"","sources":["../../src/domain.objects/DeclaredGithubRepo.ts"],"names":[],"mappings":";;;AACA,mDAA8C;AAgE9C,MAAa,kBACX,SAAQ,6BAAgC;;AAD1C,gDAKC;AADe,yBAAM,GAAG,CAAC,OAAO,EAAE,MAAM,CAAU,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { DomainEntity, RefByUnique } from 'domain-objects';
|
|
2
|
+
import { DeclaredGithubRepo } from './DeclaredGithubRepo';
|
|
3
|
+
/**
|
|
4
|
+
* .what = a declarative structure which represents a GitHub repository's configuration
|
|
5
|
+
* .why = enables declarative management of GitHub repo config settings following declastruct patterns
|
|
6
|
+
*/
|
|
7
|
+
export interface DeclaredGithubRepoConfig {
|
|
8
|
+
/**
|
|
9
|
+
* .what = reference to the repository this configuration belongs to
|
|
10
|
+
* .note = 1:1 relationship - config is part of repo, not separate resource
|
|
11
|
+
*/
|
|
12
|
+
repo: RefByUnique<typeof DeclaredGithubRepo>;
|
|
13
|
+
/**
|
|
14
|
+
* .what = name of the default branch
|
|
15
|
+
* .note = e.g., 'main', 'master', 'develop'
|
|
16
|
+
*/
|
|
17
|
+
defaultBranch?: string;
|
|
18
|
+
/**
|
|
19
|
+
* .what = whether issues are enabled
|
|
20
|
+
*/
|
|
21
|
+
hasIssues?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* .what = whether projects are enabled
|
|
24
|
+
*/
|
|
25
|
+
hasProjects?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* .what = whether wiki is enabled
|
|
28
|
+
*/
|
|
29
|
+
hasWiki?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* .what = whether downloads are enabled
|
|
32
|
+
*/
|
|
33
|
+
hasDownloads?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* .what = whether this is a template repository
|
|
36
|
+
*/
|
|
37
|
+
isTemplate?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* .what = whether squash merging is allowed
|
|
40
|
+
*/
|
|
41
|
+
allowSquashMerge?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* .what = whether merge commits are allowed
|
|
44
|
+
*/
|
|
45
|
+
allowMergeCommit?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* .what = whether rebase merging is allowed
|
|
48
|
+
*/
|
|
49
|
+
allowRebaseMerge?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* .what = whether auto-merge is allowed
|
|
52
|
+
* .note = may be undefined
|
|
53
|
+
*/
|
|
54
|
+
allowAutoMerge?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* .what = whether to delete head branches after PRs are merged
|
|
57
|
+
* .note = may be undefined
|
|
58
|
+
*/
|
|
59
|
+
deleteBranchOnMerge?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* .what = whether to allow updating branches with latest base branch
|
|
62
|
+
* .note = may be undefined
|
|
63
|
+
*/
|
|
64
|
+
allowUpdateBranch?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* .what = default commit title for squash merges
|
|
67
|
+
* .note = may be undefined
|
|
68
|
+
*/
|
|
69
|
+
squashMergeCommitTitle?: 'PR_TITLE' | 'COMMIT_OR_PR_TITLE';
|
|
70
|
+
/**
|
|
71
|
+
* .what = default commit message for squash merges
|
|
72
|
+
* .note = may be undefined
|
|
73
|
+
*/
|
|
74
|
+
squashMergeCommitMessage?: 'PR_BODY' | 'COMMIT_MESSAGES' | 'BLANK';
|
|
75
|
+
/**
|
|
76
|
+
* .what = default commit title for merge commits
|
|
77
|
+
* .note = may be undefined
|
|
78
|
+
*/
|
|
79
|
+
mergeCommitTitle?: 'PR_TITLE' | 'MERGE_MESSAGE';
|
|
80
|
+
/**
|
|
81
|
+
* .what = default commit message for merge commits
|
|
82
|
+
* .note = may be undefined
|
|
83
|
+
*/
|
|
84
|
+
mergeCommitMessage?: 'PR_TITLE' | 'PR_BODY' | 'BLANK';
|
|
85
|
+
/**
|
|
86
|
+
* .what = whether web commit signoff is required
|
|
87
|
+
* .note = may be undefined
|
|
88
|
+
*/
|
|
89
|
+
webCommitSignoffRequired?: boolean;
|
|
90
|
+
}
|
|
91
|
+
export declare class DeclaredGithubRepoConfig extends DomainEntity<DeclaredGithubRepoConfig> implements DeclaredGithubRepoConfig {
|
|
92
|
+
static unique: readonly ["repo"];
|
|
93
|
+
static nested: {
|
|
94
|
+
repo: {
|
|
95
|
+
new (props: RefByUnique<typeof DeclaredGithubRepo, any, any, any>): RefByUnique<typeof DeclaredGithubRepo, any, any, any>;
|
|
96
|
+
build<TDobj extends import("domain-objects").Refable<TShape, TPrimary, TUnique>, TShape extends import("domain-objects/dist/reference/Refable").DomainObjectShape = any, TPrimary extends readonly string[] = any, TUnique extends readonly string[] = any>(props: RefByUnique<TDobj, TShape, TPrimary, TUnique>): RefByUnique<TDobj, TShape, TPrimary, TUnique>;
|
|
97
|
+
as<TDobj_1 extends import("domain-objects").Refable<TShape_1, TPrimary_1, TUnique_1>, TShape_1 extends import("domain-objects/dist/reference/Refable").DomainObjectShape = any, TPrimary_1 extends readonly string[] = any, TUnique_1 extends readonly string[] = any>(props: RefByUnique<TDobj_1, TShape_1, TPrimary_1, TUnique_1>): RefByUnique<TDobj_1, TShape_1, TPrimary_1, TUnique_1>;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeclaredGithubRepoConfig = void 0;
|
|
4
|
+
const domain_objects_1 = require("domain-objects");
|
|
5
|
+
class DeclaredGithubRepoConfig extends domain_objects_1.DomainEntity {
|
|
6
|
+
}
|
|
7
|
+
exports.DeclaredGithubRepoConfig = DeclaredGithubRepoConfig;
|
|
8
|
+
DeclaredGithubRepoConfig.unique = ['repo'];
|
|
9
|
+
DeclaredGithubRepoConfig.nested = {
|
|
10
|
+
repo: (domain_objects_1.RefByUnique),
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=DeclaredGithubRepoConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeclaredGithubRepoConfig.js","sourceRoot":"","sources":["../../src/domain.objects/DeclaredGithubRepoConfig.ts"],"names":[],"mappings":";;;AAAA,mDAA2D;AA8G3D,MAAa,wBACX,SAAQ,6BAAsC;;AADhD,4DAQC;AAJe,+BAAM,GAAG,CAAC,MAAM,CAAU,CAAC;AAC3B,+BAAM,GAAG;IACrB,IAAI,EAAE,CAAA,4BAAsC,CAAA;CAC7C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DeclastructDao, DeclastructProvider } from 'declastruct';
|
|
2
|
+
import type { ContextLogTrail } from 'simple-log-methods';
|
|
3
|
+
import { ContextGithubApi } from './ContextGithubApi';
|
|
4
|
+
import { DeclaredGithubBranch } from './DeclaredGithubBranch';
|
|
5
|
+
import { DeclaredGithubBranchProtection } from './DeclaredGithubBranchProtection';
|
|
6
|
+
import { DeclaredGithubRepo } from './DeclaredGithubRepo';
|
|
7
|
+
import { DeclaredGithubRepoConfig } from './DeclaredGithubRepoConfig';
|
|
8
|
+
/**
|
|
9
|
+
* .what = the declastruct provider for github resources
|
|
10
|
+
* .why = provides type safety and reusability for the github provider
|
|
11
|
+
*/
|
|
12
|
+
export type DeclastructGithubProvider = DeclastructProvider<{
|
|
13
|
+
DeclaredGithubRepo: DeclastructDao<DeclaredGithubRepo, typeof DeclaredGithubRepo, ContextGithubApi & ContextLogTrail>;
|
|
14
|
+
DeclaredGithubBranch: DeclastructDao<DeclaredGithubBranch, typeof DeclaredGithubBranch, ContextGithubApi & ContextLogTrail>;
|
|
15
|
+
DeclaredGithubRepoConfig: DeclastructDao<DeclaredGithubRepoConfig, typeof DeclaredGithubRepoConfig, ContextGithubApi & ContextLogTrail>;
|
|
16
|
+
DeclaredGithubBranchProtection: DeclastructDao<DeclaredGithubBranchProtection, typeof DeclaredGithubBranchProtection, ContextGithubApi & ContextLogTrail>;
|
|
17
|
+
}, ContextGithubApi & ContextLogTrail>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeclastructGithubProvider.js","sourceRoot":"","sources":["../../src/domain.objects/DeclastructGithubProvider.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Endpoints } from '@octokit/types';
|
|
2
|
+
import { RefByUnique } from 'domain-objects';
|
|
3
|
+
import { HasMetadata } from 'type-fns';
|
|
4
|
+
import { DeclaredGithubBranch } from '../../domain.objects/DeclaredGithubBranch';
|
|
5
|
+
import { DeclaredGithubRepo } from '../../domain.objects/DeclaredGithubRepo';
|
|
6
|
+
type GithubBranchResponse = Endpoints['GET /repos/{owner}/{repo}/branches/{branch}']['response']['data'] | Endpoints['GET /repos/{owner}/{repo}/branches']['response']['data'][number];
|
|
7
|
+
/**
|
|
8
|
+
* .what = casts GitHub API branch response to DeclaredGithubBranch
|
|
9
|
+
* .why = transforms external API shape to our domain model with type safety and validation
|
|
10
|
+
*/
|
|
11
|
+
export declare const castToDeclaredGithubBranch: (input: {
|
|
12
|
+
branch: GithubBranchResponse;
|
|
13
|
+
repo: RefByUnique<typeof DeclaredGithubRepo>;
|
|
14
|
+
}) => HasMetadata<DeclaredGithubBranch>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.castToDeclaredGithubBranch = void 0;
|
|
4
|
+
const domain_objects_1 = require("domain-objects");
|
|
5
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
6
|
+
const type_fns_1 = require("type-fns");
|
|
7
|
+
const DeclaredGithubBranch_1 = require("../../domain.objects/DeclaredGithubBranch");
|
|
8
|
+
const DeclaredGithubRepo_1 = require("../../domain.objects/DeclaredGithubRepo");
|
|
9
|
+
/**
|
|
10
|
+
* .what = extracts required value from object or throws
|
|
11
|
+
* .why = ensures type safety and fail-fast behavior for missing required fields
|
|
12
|
+
*/
|
|
13
|
+
const getOrThrow = (obj, key) => {
|
|
14
|
+
const value = obj[key];
|
|
15
|
+
// if its not undefined, return it
|
|
16
|
+
if ((0, type_fns_1.isNotUndefined)(value))
|
|
17
|
+
return value;
|
|
18
|
+
// otherwise, fail fast
|
|
19
|
+
helpful_errors_1.UnexpectedCodePathError.throw(`${String(key)} not found on response`, {
|
|
20
|
+
input: obj,
|
|
21
|
+
key,
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* .what = casts GitHub API branch response to DeclaredGithubBranch
|
|
26
|
+
* .why = transforms external API shape to our domain model with type safety and validation
|
|
27
|
+
*/
|
|
28
|
+
const castToDeclaredGithubBranch = (input) => {
|
|
29
|
+
return DeclaredGithubBranch_1.DeclaredGithubBranch.as({
|
|
30
|
+
name: getOrThrow(input.branch, 'name'),
|
|
31
|
+
repo: input.repo instanceof DeclaredGithubRepo_1.DeclaredGithubRepo
|
|
32
|
+
? (0, domain_objects_1.refByUnique)(input.repo)
|
|
33
|
+
: input.repo,
|
|
34
|
+
commit: { sha: getOrThrow(getOrThrow(input.branch, 'commit'), 'sha') },
|
|
35
|
+
protected: input.branch.protected,
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
exports.castToDeclaredGithubBranch = castToDeclaredGithubBranch;
|
|
39
|
+
//# sourceMappingURL=castToDeclaredGithubBranch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"castToDeclaredGithubBranch.js","sourceRoot":"","sources":["../../../src/domain.operations/branch/castToDeclaredGithubBranch.ts"],"names":[],"mappings":";;;AACA,mDAA0D;AAC1D,mDAAyD;AACzD,uCAAqE;AAErE,oFAAiF;AACjF,gFAA6E;AAE7E;;;GAGG;AACH,MAAM,UAAU,GAAG,CACjB,GAAM,EACN,GAAM,EACc,EAAE;IACtB,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IAEvB,kCAAkC;IAClC,IAAI,IAAA,yBAAc,EAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAExC,uBAAuB;IACvB,wCAAuB,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,wBAAwB,EAAE;QACpE,KAAK,EAAE,GAAG;QACV,GAAG;KACJ,CAAC,CAAC;AACL,CAAC,CAAC;AAMF;;;GAGG;AACI,MAAM,0BAA0B,GAAG,CAAC,KAG1C,EAAqC,EAAE;IACtC,OAAO,2CAAoB,CAAC,EAAE,CAAC;QAC7B,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC;QACtC,IAAI,EACF,KAAK,CAAC,IAAI,YAAY,uCAAkB;YACtC,CAAC,CAAC,IAAA,4BAAW,EAA4B,KAAK,CAAC,IAAI,CAAC;YACpD,CAAC,CAAC,KAAK,CAAC,IAAI;QAChB,MAAM,EAAE,EAAE,GAAG,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,EAAE;QACtE,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS;KAClC,CAAsC,CAAC;AAC1C,CAAC,CAAC;AAbW,QAAA,0BAA0B,8BAarC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RefByUnique } from 'domain-objects';
|
|
2
|
+
import { HasMetadata, PickOne } from 'type-fns';
|
|
3
|
+
import { VisualogicContext } from 'visualogic';
|
|
4
|
+
import { ContextGithubApi } from '../../domain.objects/ContextGithubApi';
|
|
5
|
+
import { DeclaredGithubBranch } from '../../domain.objects/DeclaredGithubBranch';
|
|
6
|
+
/**
|
|
7
|
+
* .what = gets a GitHub branch
|
|
8
|
+
* .why = retrieves current state of a branch from GitHub API for declarative management
|
|
9
|
+
*/
|
|
10
|
+
export declare const getBranch: (input: {
|
|
11
|
+
by: PickOne<{
|
|
12
|
+
unique: RefByUnique<typeof DeclaredGithubBranch>;
|
|
13
|
+
}>;
|
|
14
|
+
}, context: ContextGithubApi & VisualogicContext) => Promise<HasMetadata<DeclaredGithubBranch> | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const test_fns_1 = require("test-fns");
|
|
4
|
+
const getSampleGithubContext_1 = require("../../.test/assets/getSampleGithubContext");
|
|
5
|
+
const getSampleRepo_1 = require("../../.test/assets/getSampleRepo");
|
|
6
|
+
const getBranch_1 = require("./getBranch");
|
|
7
|
+
const log = console;
|
|
8
|
+
describe('getBranch', () => {
|
|
9
|
+
const context = { log, ...(0, getSampleGithubContext_1.getSampleGithubContext)() };
|
|
10
|
+
(0, test_fns_1.given)('a live example repo with a main branch', () => {
|
|
11
|
+
(0, test_fns_1.then)('we should be able to get the branch state', async () => {
|
|
12
|
+
const sampleRepo = (0, getSampleRepo_1.getSampleRepo)({
|
|
13
|
+
owner: 'ehmpathy',
|
|
14
|
+
name: 'declastruct-github-demo',
|
|
15
|
+
});
|
|
16
|
+
const branch = await (0, getBranch_1.getBranch)({
|
|
17
|
+
by: {
|
|
18
|
+
unique: {
|
|
19
|
+
repo: {
|
|
20
|
+
owner: sampleRepo.owner,
|
|
21
|
+
name: sampleRepo.name,
|
|
22
|
+
},
|
|
23
|
+
name: 'main',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
}, context);
|
|
27
|
+
console.log(branch);
|
|
28
|
+
expect(branch).toBeDefined();
|
|
29
|
+
expect(branch?.name).toBe('main');
|
|
30
|
+
expect(branch?.repo).toEqual({
|
|
31
|
+
owner: sampleRepo.owner,
|
|
32
|
+
name: sampleRepo.name,
|
|
33
|
+
});
|
|
34
|
+
expect(branch?.commit?.sha).toBeDefined();
|
|
35
|
+
expect(typeof branch?.protected).toBe('boolean');
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
(0, test_fns_1.given)('a branch that does not exist', () => {
|
|
39
|
+
(0, test_fns_1.then)('it should return null', async () => {
|
|
40
|
+
const sampleRepo = (0, getSampleRepo_1.getSampleRepo)({
|
|
41
|
+
owner: 'ehmpathy',
|
|
42
|
+
name: 'declastruct-github-demo',
|
|
43
|
+
});
|
|
44
|
+
const branch = await (0, getBranch_1.getBranch)({
|
|
45
|
+
by: {
|
|
46
|
+
unique: {
|
|
47
|
+
repo: {
|
|
48
|
+
owner: sampleRepo.owner,
|
|
49
|
+
name: sampleRepo.name,
|
|
50
|
+
},
|
|
51
|
+
name: 'branch-that-does-not-exist-99999',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
}, context);
|
|
55
|
+
expect(branch).toBeNull();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=getBranch.integration.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBranch.integration.test.js","sourceRoot":"","sources":["../../../src/domain.operations/branch/getBranch.integration.test.ts"],"names":[],"mappings":";;AAAA,uCAAuC;AAEvC,sFAAmF;AACnF,oEAAiE;AACjE,2CAAwC;AAExC,MAAM,GAAG,GAAG,OAAO,CAAC;AAEpB,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,GAAG,IAAA,+CAAsB,GAAE,EAAE,CAAC;IAErD,IAAA,gBAAK,EAAC,wCAAwC,EAAE,GAAG,EAAE;QACnD,IAAA,eAAI,EAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;YAC3D,MAAM,UAAU,GAAG,IAAA,6BAAa,EAAC;gBAC/B,KAAK,EAAE,UAAU;gBACjB,IAAI,EAAE,yBAAyB;aAChC,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAS,EAC5B;gBACE,EAAE,EAAE;oBACF,MAAM,EAAE;wBACN,IAAI,EAAE;4BACJ,KAAK,EAAE,UAAU,CAAC,KAAK;4BACvB,IAAI,EAAE,UAAU,CAAC,IAAI;yBACtB;wBACD,IAAI,EAAE,MAAM;qBACb;iBACF;aACF,EACD,OAAO,CACR,CAAC;YAEF,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACpB,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;YAC7B,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAClC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC;gBAC3B,KAAK,EAAE,UAAU,CAAC,KAAK;gBACvB,IAAI,EAAE,UAAU,CAAC,IAAI;aACtB,CAAC,CAAC;YACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;YAC1C,MAAM,CAAC,OAAO,MAAM,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAA,gBAAK,EAAC,8BAA8B,EAAE,GAAG,EAAE;QACzC,IAAA,eAAI,EAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE;YACvC,MAAM,UAAU,GAAG,IAAA,6BAAa,EAAC;gBAC/B,KAAK,EAAE,UAAU;gBACjB,IAAI,EAAE,yBAAyB;aAChC,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAS,EAC5B;gBACE,EAAE,EAAE;oBACF,MAAM,EAAE;wBACN,IAAI,EAAE;4BACJ,KAAK,EAAE,UAAU,CAAC,KAAK;4BACvB,IAAI,EAAE,UAAU,CAAC,IAAI;yBACtB;wBACD,IAAI,EAAE,kCAAkC;qBACzC;iBACF;aACF,EACD,OAAO,CACR,CAAC;YAEF,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC5B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBranch = void 0;
|
|
4
|
+
const as_procedure_1 = require("as-procedure");
|
|
5
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
6
|
+
const getGithubClient_1 = require("../../access/sdks/getGithubClient");
|
|
7
|
+
const castToDeclaredGithubBranch_1 = require("./castToDeclaredGithubBranch");
|
|
8
|
+
/**
|
|
9
|
+
* .what = gets a GitHub branch
|
|
10
|
+
* .why = retrieves current state of a branch from GitHub API for declarative management
|
|
11
|
+
*/
|
|
12
|
+
exports.getBranch = (0, as_procedure_1.asProcedure)(async (input, context) => {
|
|
13
|
+
// get cached GitHub client
|
|
14
|
+
const github = (0, getGithubClient_1.getGithubClient)({}, context);
|
|
15
|
+
// determine owner, repo, and branch name from input
|
|
16
|
+
const { repo, branch } = (() => {
|
|
17
|
+
if (input.by.unique) {
|
|
18
|
+
return {
|
|
19
|
+
repo: input.by.unique.repo,
|
|
20
|
+
branch: input.by.unique.name,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
helpful_errors_1.UnexpectedCodePathError.throw('not referenced by unique. how not?', {
|
|
24
|
+
input,
|
|
25
|
+
});
|
|
26
|
+
})();
|
|
27
|
+
// execute the GitHub API call
|
|
28
|
+
try {
|
|
29
|
+
const response = await github.repos.getBranch({
|
|
30
|
+
owner: repo.owner,
|
|
31
|
+
repo: repo.name,
|
|
32
|
+
branch,
|
|
33
|
+
});
|
|
34
|
+
return (0, castToDeclaredGithubBranch_1.castToDeclaredGithubBranch)({
|
|
35
|
+
branch: response.data,
|
|
36
|
+
repo: input.by.unique.repo,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (!(error instanceof Error))
|
|
41
|
+
throw error;
|
|
42
|
+
// return null for 404/not found
|
|
43
|
+
if (error.message.includes('Not Found') ||
|
|
44
|
+
error.message.includes('Branch not found'))
|
|
45
|
+
return null;
|
|
46
|
+
// throw helpful error for all other failures
|
|
47
|
+
throw new helpful_errors_1.HelpfulError('github.getBranch error', { cause: error });
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=getBranch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBranch.js","sourceRoot":"","sources":["../../../src/domain.operations/branch/getBranch.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAE3C,mDAAuE;AAIvE,uEAAoE;AAGpE,6EAA0E;AAE1E;;;GAGG;AACU,QAAA,SAAS,GAAG,IAAA,0BAAW,EAClC,KAAK,EACH,KAIC,EACD,OAA6C,EACM,EAAE;IACrD,2BAA2B;IAC3B,MAAM,MAAM,GAAG,IAAA,iCAAe,EAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAE5C,oDAAoD;IACpD,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE;QAC7B,IAAI,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC;YACpB,OAAO;gBACL,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI;gBAC1B,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI;aAC7B,CAAC;QACJ,CAAC;QAED,wCAAuB,CAAC,KAAK,CAAC,oCAAoC,EAAE;YAClE,KAAK;SACN,CAAC,CAAC;IACL,CAAC,CAAC,EAAE,CAAC;IAEL,8BAA8B;IAC9B,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC;YAC5C,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM;SACP,CAAC,CAAC;QACH,OAAO,IAAA,uDAA0B,EAAC;YAChC,MAAM,EAAE,QAAQ,CAAC,IAAI;YACrB,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI;SAC3B,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;QAE3C,gCAAgC;QAChC,IACE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;YACnC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC;YAE1C,OAAO,IAAI,CAAC;QAEd,6CAA6C;QAC7C,MAAM,IAAI,6BAAY,CAAC,wBAAwB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACrE,CAAC;AACH,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RefByUnique } from 'domain-objects';
|
|
2
|
+
import { VisualogicContext } from 'visualogic';
|
|
3
|
+
import { ContextGithubApi } from '../../domain.objects/ContextGithubApi';
|
|
4
|
+
import { DeclaredGithubRepo } from '../../domain.objects/DeclaredGithubRepo';
|
|
5
|
+
/**
|
|
6
|
+
* .what = gets the commit SHA of a repository's default branch
|
|
7
|
+
* .why = enables creating branches from the default branch when no commit SHA is specified
|
|
8
|
+
*/
|
|
9
|
+
export declare const getBranchCommitShaByRepoDefault: (input: {
|
|
10
|
+
repo: RefByUnique<typeof DeclaredGithubRepo>;
|
|
11
|
+
}, context: ContextGithubApi & VisualogicContext) => Promise<string>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBranchCommitShaByRepoDefault = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
const getGithubClient_1 = require("../../access/sdks/getGithubClient");
|
|
6
|
+
const getBranch_1 = require("./getBranch");
|
|
7
|
+
/**
|
|
8
|
+
* .what = gets the commit SHA of a repository's default branch
|
|
9
|
+
* .why = enables creating branches from the default branch when no commit SHA is specified
|
|
10
|
+
*/
|
|
11
|
+
const getBranchCommitShaByRepoDefault = async (input, context) => {
|
|
12
|
+
// get cached GitHub client
|
|
13
|
+
const github = (0, getGithubClient_1.getGithubClient)({}, context);
|
|
14
|
+
// get the repository to find its default branch
|
|
15
|
+
const repoResponse = await github.repos.get({
|
|
16
|
+
owner: input.repo.owner,
|
|
17
|
+
repo: input.repo.name,
|
|
18
|
+
});
|
|
19
|
+
const defaultBranch = repoResponse.data.default_branch;
|
|
20
|
+
// get the default branch to find its commit SHA
|
|
21
|
+
const defaultBranchData = await (0, getBranch_1.getBranch)({
|
|
22
|
+
by: {
|
|
23
|
+
unique: {
|
|
24
|
+
repo: input.repo,
|
|
25
|
+
name: defaultBranch,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
}, context);
|
|
29
|
+
if (!defaultBranchData?.commit?.sha) {
|
|
30
|
+
helpful_errors_1.UnexpectedCodePathError.throw('default branch has no commit', {
|
|
31
|
+
defaultBranch,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return defaultBranchData.commit.sha;
|
|
35
|
+
};
|
|
36
|
+
exports.getBranchCommitShaByRepoDefault = getBranchCommitShaByRepoDefault;
|
|
37
|
+
//# sourceMappingURL=getBranchCommitShaByRepoDefault.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBranchCommitShaByRepoDefault.js","sourceRoot":"","sources":["../../../src/domain.operations/branch/getBranchCommitShaByRepoDefault.ts"],"names":[],"mappings":";;;AACA,mDAAyD;AAGzD,uEAAoE;AAGpE,2CAAwC;AAExC;;;GAGG;AACI,MAAM,+BAA+B,GAAG,KAAK,EAClD,KAEC,EACD,OAA6C,EAC5B,EAAE;IACnB,2BAA2B;IAC3B,MAAM,MAAM,GAAG,IAAA,iCAAe,EAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAE5C,gDAAgD;IAChD,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;QAC1C,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK;QACvB,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI;KACtB,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC;IAEvD,gDAAgD;IAChD,MAAM,iBAAiB,GAAG,MAAM,IAAA,qBAAS,EACvC;QACE,EAAE,EAAE;YACF,MAAM,EAAE;gBACN,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,IAAI,EAAE,aAAa;aACpB;SACF;KACF,EACD,OAAO,CACR,CAAC;IAEF,IAAI,CAAC,iBAAiB,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;QACpC,wCAAuB,CAAC,KAAK,CAAC,8BAA8B,EAAE;YAC5D,aAAa;SACd,CAAC,CAAC;IACL,CAAC;IAED,OAAO,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC;AACtC,CAAC,CAAC;AArCW,QAAA,+BAA+B,mCAqC1C"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { RefByUnique } from 'domain-objects';
|
|
2
|
+
import { HasMetadata } from 'type-fns';
|
|
3
|
+
import { VisualogicContext } from 'visualogic';
|
|
4
|
+
import { ContextGithubApi } from '../../domain.objects/ContextGithubApi';
|
|
5
|
+
import { DeclaredGithubBranch } from '../../domain.objects/DeclaredGithubBranch';
|
|
6
|
+
import { DeclaredGithubRepo } from '../../domain.objects/DeclaredGithubRepo';
|
|
7
|
+
/**
|
|
8
|
+
* .what = lists GitHub branches for a repository
|
|
9
|
+
* .why = retrieves multiple branches from GitHub API for declarative management
|
|
10
|
+
*/
|
|
11
|
+
export declare const getBranches: (input: {
|
|
12
|
+
where: {
|
|
13
|
+
repo: RefByUnique<typeof DeclaredGithubRepo>;
|
|
14
|
+
};
|
|
15
|
+
page?: {
|
|
16
|
+
range?: {
|
|
17
|
+
until: {
|
|
18
|
+
page: number;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
limit?: number;
|
|
22
|
+
};
|
|
23
|
+
}, context: ContextGithubApi & VisualogicContext) => Promise<HasMetadata<DeclaredGithubBranch>[]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|