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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Uladzimir Kasacheuski
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ContextGithubApi } from '../../domain.objects/ContextGithubApi';
|
|
2
|
+
/**
|
|
3
|
+
* .what = provides sample GitHub context for testing
|
|
4
|
+
* .why = allows integration tests to access GitHub API with credentials from environment
|
|
5
|
+
*/
|
|
6
|
+
export declare const getSampleGithubContext: () => ContextGithubApi;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSampleGithubContext = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
/**
|
|
6
|
+
* .what = provides sample GitHub context for testing
|
|
7
|
+
* .why = allows integration tests to access GitHub API with credentials from environment
|
|
8
|
+
*/
|
|
9
|
+
const getSampleGithubContext = () => ({
|
|
10
|
+
github: {
|
|
11
|
+
token: process.env.GITHUB_TOKEN ??
|
|
12
|
+
helpful_errors_1.UnexpectedCodePathError.throw('GITHUB_TOKEN env var must be set for tests', {
|
|
13
|
+
GITHUB_TOKEN: process.env.GITHUB_TOKEN,
|
|
14
|
+
}),
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
exports.getSampleGithubContext = getSampleGithubContext;
|
|
18
|
+
//# sourceMappingURL=getSampleGithubContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSampleGithubContext.js","sourceRoot":"","sources":["../../../src/.test/assets/getSampleGithubContext.ts"],"names":[],"mappings":";;;AAAA,mDAAyD;AAIzD;;;GAGG;AACI,MAAM,sBAAsB,GAAG,GAAqB,EAAE,CAAC,CAAC;IAC7D,MAAM,EAAE;QACN,KAAK,EACH,OAAO,CAAC,GAAG,CAAC,YAAY;YACxB,wCAAuB,CAAC,KAAK,CAC3B,4CAA4C,EAC5C;gBACE,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;aACvC,CACF;KACJ;CACF,CAAC,CAAC;AAXU,QAAA,sBAAsB,0BAWhC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DeclaredGithubRepo } from '../../domain.objects/DeclaredGithubRepo';
|
|
2
|
+
/**
|
|
3
|
+
* .what = provides sample repo for testing
|
|
4
|
+
* .why = allows integration tests to use a real GitHub repo for testing operations
|
|
5
|
+
*/
|
|
6
|
+
export declare const getSampleRepo: (input: {
|
|
7
|
+
owner: string;
|
|
8
|
+
name: string;
|
|
9
|
+
}) => DeclaredGithubRepo;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSampleRepo = void 0;
|
|
4
|
+
const DeclaredGithubRepo_1 = require("../../domain.objects/DeclaredGithubRepo");
|
|
5
|
+
/**
|
|
6
|
+
* .what = provides sample repo for testing
|
|
7
|
+
* .why = allows integration tests to use a real GitHub repo for testing operations
|
|
8
|
+
*/
|
|
9
|
+
const getSampleRepo = (input) => DeclaredGithubRepo_1.DeclaredGithubRepo.as({
|
|
10
|
+
owner: input.owner,
|
|
11
|
+
name: input.name,
|
|
12
|
+
description: null,
|
|
13
|
+
homepage: null,
|
|
14
|
+
private: false,
|
|
15
|
+
visibility: 'public',
|
|
16
|
+
archived: false,
|
|
17
|
+
});
|
|
18
|
+
exports.getSampleRepo = getSampleRepo;
|
|
19
|
+
//# sourceMappingURL=getSampleRepo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSampleRepo.js","sourceRoot":"","sources":["../../../src/.test/assets/getSampleRepo.ts"],"names":[],"mappings":";;;AAAA,gFAA6E;AAE7E;;;GAGG;AACI,MAAM,aAAa,GAAG,CAAC,KAG7B,EAAsB,EAAE,CACvB,uCAAkB,CAAC,EAAE,CAAC;IACpB,KAAK,EAAE,KAAK,CAAC,KAAK;IAClB,IAAI,EAAE,KAAK,CAAC,IAAI;IAChB,WAAW,EAAE,IAAI;IACjB,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,QAAQ;IACpB,QAAQ,EAAE,KAAK;CAChB,CAAC,CAAC;AAZQ,QAAA,aAAa,iBAYrB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DeclastructDao } from 'declastruct';
|
|
2
|
+
import type { ContextLogTrail } from 'simple-log-methods';
|
|
3
|
+
import { ContextGithubApi } from '../../domain.objects/ContextGithubApi';
|
|
4
|
+
import { DeclaredGithubBranch } from '../../domain.objects/DeclaredGithubBranch';
|
|
5
|
+
/**
|
|
6
|
+
* .what = declastruct DAO for github branch resources
|
|
7
|
+
* .why = wraps existing branch operations to conform to declastruct interface
|
|
8
|
+
* .note = upsert allows updating the branch's commit SHA
|
|
9
|
+
*/
|
|
10
|
+
export declare const DeclaredGithubBranchDao: DeclastructDao<DeclaredGithubBranch, typeof DeclaredGithubBranch, ContextGithubApi & ContextLogTrail>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeclaredGithubBranchDao = void 0;
|
|
4
|
+
const declastruct_1 = require("declastruct");
|
|
5
|
+
const domain_objects_1 = require("domain-objects");
|
|
6
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
7
|
+
const DeclaredGithubBranch_1 = require("../../domain.objects/DeclaredGithubBranch");
|
|
8
|
+
const getBranch_1 = require("../../domain.operations/branch/getBranch");
|
|
9
|
+
const setBranch_1 = require("../../domain.operations/branch/setBranch");
|
|
10
|
+
/**
|
|
11
|
+
* .what = declastruct DAO for github branch resources
|
|
12
|
+
* .why = wraps existing branch operations to conform to declastruct interface
|
|
13
|
+
* .note = upsert allows updating the branch's commit SHA
|
|
14
|
+
*/
|
|
15
|
+
exports.DeclaredGithubBranchDao = new declastruct_1.DeclastructDao({
|
|
16
|
+
get: {
|
|
17
|
+
byUnique: async (input, context) => {
|
|
18
|
+
return (0, getBranch_1.getBranch)({ by: { unique: input } }, context);
|
|
19
|
+
},
|
|
20
|
+
byRef: async (input, context) => {
|
|
21
|
+
if ((0, domain_objects_1.isRefByUnique)({ of: DeclaredGithubBranch_1.DeclaredGithubBranch })(input))
|
|
22
|
+
return (0, getBranch_1.getBranch)({ by: { unique: input } }, context);
|
|
23
|
+
helpful_errors_1.UnexpectedCodePathError.throw('unsupported ref type', { input });
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
set: {
|
|
27
|
+
finsert: async (input, context) => {
|
|
28
|
+
return (0, setBranch_1.setBranch)({ finsert: input }, context);
|
|
29
|
+
},
|
|
30
|
+
upsert: async (input, context) => {
|
|
31
|
+
return (0, setBranch_1.setBranch)({ upsert: input }, context);
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=DeclaredGithubBranchDao.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeclaredGithubBranchDao.js","sourceRoot":"","sources":["../../../src/access/daos/DeclaredGithubBranchDao.ts"],"names":[],"mappings":";;;AAAA,6CAA6C;AAC7C,mDAA+C;AAC/C,mDAAyD;AAIzD,oFAAiF;AACjF,wEAAqE;AACrE,wEAAqE;AAErE;;;;GAIG;AACU,QAAA,uBAAuB,GAAG,IAAI,4BAAc,CAIvD;IACA,GAAG,EAAE;QACH,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACjC,OAAO,IAAA,qBAAS,EAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;QACvD,CAAC;QACD,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAC9B,IAAI,IAAA,8BAAa,EAAC,EAAE,EAAE,EAAE,2CAAoB,EAAE,CAAC,CAAC,KAAK,CAAC;gBACpD,OAAO,IAAA,qBAAS,EAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;YACvD,wCAAuB,CAAC,KAAK,CAAC,sBAAsB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACnE,CAAC;KACF;IACD,GAAG,EAAE;QACH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAChC,OAAO,IAAA,qBAAS,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;QAChD,CAAC;QACD,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAC/B,OAAO,IAAA,qBAAS,EAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;QAC/C,CAAC;KACF;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DeclastructDao } from 'declastruct';
|
|
2
|
+
import type { ContextLogTrail } from 'simple-log-methods';
|
|
3
|
+
import { ContextGithubApi } from '../../domain.objects/ContextGithubApi';
|
|
4
|
+
import { DeclaredGithubBranchProtection } from '../../domain.objects/DeclaredGithubBranchProtection';
|
|
5
|
+
/**
|
|
6
|
+
* .what = declastruct DAO for github branch protection resources
|
|
7
|
+
* .why = wraps existing branch protection operations to conform to declastruct interface
|
|
8
|
+
*/
|
|
9
|
+
export declare const DeclaredGithubBranchProtectionDao: DeclastructDao<DeclaredGithubBranchProtection, typeof DeclaredGithubBranchProtection, ContextGithubApi & ContextLogTrail>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeclaredGithubBranchProtectionDao = void 0;
|
|
4
|
+
const declastruct_1 = require("declastruct");
|
|
5
|
+
const domain_objects_1 = require("domain-objects");
|
|
6
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
7
|
+
const DeclaredGithubBranchProtection_1 = require("../../domain.objects/DeclaredGithubBranchProtection");
|
|
8
|
+
const getBranchProtection_1 = require("../../domain.operations/branchProtection/getBranchProtection");
|
|
9
|
+
const setBranchProtection_1 = require("../../domain.operations/branchProtection/setBranchProtection");
|
|
10
|
+
/**
|
|
11
|
+
* .what = declastruct DAO for github branch protection resources
|
|
12
|
+
* .why = wraps existing branch protection operations to conform to declastruct interface
|
|
13
|
+
*/
|
|
14
|
+
exports.DeclaredGithubBranchProtectionDao = new declastruct_1.DeclastructDao({
|
|
15
|
+
get: {
|
|
16
|
+
byUnique: async (input, context) => {
|
|
17
|
+
return (0, getBranchProtection_1.getBranchProtection)({ by: { unique: input } }, context);
|
|
18
|
+
},
|
|
19
|
+
byRef: async (input, context) => {
|
|
20
|
+
if ((0, domain_objects_1.isRefByUnique)({ of: DeclaredGithubBranchProtection_1.DeclaredGithubBranchProtection })(input))
|
|
21
|
+
return (0, getBranchProtection_1.getBranchProtection)({ by: { unique: input } }, context);
|
|
22
|
+
helpful_errors_1.UnexpectedCodePathError.throw('unsupported ref type', { input });
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
set: {
|
|
26
|
+
finsert: async (input, context) => {
|
|
27
|
+
return (0, setBranchProtection_1.setBranchProtection)({ finsert: input }, context);
|
|
28
|
+
},
|
|
29
|
+
upsert: async (input, context) => {
|
|
30
|
+
return (0, setBranchProtection_1.setBranchProtection)({ upsert: input }, context);
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=DeclaredGithubBranchProtectionDao.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeclaredGithubBranchProtectionDao.js","sourceRoot":"","sources":["../../../src/access/daos/DeclaredGithubBranchProtectionDao.ts"],"names":[],"mappings":";;;AAAA,6CAA6C;AAC7C,mDAA+C;AAC/C,mDAAyD;AAIzD,wGAAqG;AACrG,sGAAmG;AACnG,sGAAmG;AAEnG;;;GAGG;AACU,QAAA,iCAAiC,GAAG,IAAI,4BAAc,CAIjE;IACA,GAAG,EAAE;QACH,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACjC,OAAO,IAAA,yCAAmB,EAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;QACjE,CAAC;QACD,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAC9B,IAAI,IAAA,8BAAa,EAAC,EAAE,EAAE,EAAE,+DAA8B,EAAE,CAAC,CAAC,KAAK,CAAC;gBAC9D,OAAO,IAAA,yCAAmB,EAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;YACjE,wCAAuB,CAAC,KAAK,CAAC,sBAAsB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACnE,CAAC;KACF;IACD,GAAG,EAAE;QACH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAChC,OAAO,IAAA,yCAAmB,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;QAC1D,CAAC;QACD,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAC/B,OAAO,IAAA,yCAAmB,EAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;QACzD,CAAC;KACF;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DeclastructDao } from 'declastruct';
|
|
2
|
+
import type { ContextLogTrail } from 'simple-log-methods';
|
|
3
|
+
import { ContextGithubApi } from '../../domain.objects/ContextGithubApi';
|
|
4
|
+
import { DeclaredGithubRepoConfig } from '../../domain.objects/DeclaredGithubRepoConfig';
|
|
5
|
+
/**
|
|
6
|
+
* .what = declastruct DAO for github repository configuration resources
|
|
7
|
+
* .why = wraps existing repo config operations to conform to declastruct interface
|
|
8
|
+
*/
|
|
9
|
+
export declare const DeclaredGithubRepoConfigDao: DeclastructDao<DeclaredGithubRepoConfig, typeof DeclaredGithubRepoConfig, ContextGithubApi & ContextLogTrail>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeclaredGithubRepoConfigDao = void 0;
|
|
4
|
+
const declastruct_1 = require("declastruct");
|
|
5
|
+
const domain_objects_1 = require("domain-objects");
|
|
6
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
7
|
+
const DeclaredGithubRepoConfig_1 = require("../../domain.objects/DeclaredGithubRepoConfig");
|
|
8
|
+
const getRepoConfig_1 = require("../../domain.operations/repoConfig/getRepoConfig");
|
|
9
|
+
const setRepoConfig_1 = require("../../domain.operations/repoConfig/setRepoConfig");
|
|
10
|
+
/**
|
|
11
|
+
* .what = declastruct DAO for github repository configuration resources
|
|
12
|
+
* .why = wraps existing repo config operations to conform to declastruct interface
|
|
13
|
+
*/
|
|
14
|
+
exports.DeclaredGithubRepoConfigDao = new declastruct_1.DeclastructDao({
|
|
15
|
+
get: {
|
|
16
|
+
byUnique: async (input, context) => {
|
|
17
|
+
return (0, getRepoConfig_1.getRepoConfig)({ by: { unique: input } }, context);
|
|
18
|
+
},
|
|
19
|
+
byRef: async (input, context) => {
|
|
20
|
+
if ((0, domain_objects_1.isRefByUnique)({ of: DeclaredGithubRepoConfig_1.DeclaredGithubRepoConfig })(input))
|
|
21
|
+
return (0, getRepoConfig_1.getRepoConfig)({ by: { unique: input } }, context);
|
|
22
|
+
helpful_errors_1.UnexpectedCodePathError.throw('unsupported ref type', { input });
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
set: {
|
|
26
|
+
finsert: async (input, context) => {
|
|
27
|
+
return (0, setRepoConfig_1.setRepoConfig)({ finsert: input }, context);
|
|
28
|
+
},
|
|
29
|
+
upsert: async (input, context) => {
|
|
30
|
+
return (0, setRepoConfig_1.setRepoConfig)({ upsert: input }, context);
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=DeclaredGithubRepoConfigDao.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeclaredGithubRepoConfigDao.js","sourceRoot":"","sources":["../../../src/access/daos/DeclaredGithubRepoConfigDao.ts"],"names":[],"mappings":";;;AAAA,6CAA6C;AAC7C,mDAA+C;AAC/C,mDAAyD;AAIzD,4FAAyF;AACzF,oFAAiF;AACjF,oFAAiF;AAEjF;;;GAGG;AACU,QAAA,2BAA2B,GAAG,IAAI,4BAAc,CAI3D;IACA,GAAG,EAAE;QACH,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACjC,OAAO,IAAA,6BAAa,EAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;QAC3D,CAAC;QACD,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAC9B,IAAI,IAAA,8BAAa,EAAC,EAAE,EAAE,EAAE,mDAAwB,EAAE,CAAC,CAAC,KAAK,CAAC;gBACxD,OAAO,IAAA,6BAAa,EAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;YAC3D,wCAAuB,CAAC,KAAK,CAAC,sBAAsB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACnE,CAAC;KACF;IACD,GAAG,EAAE;QACH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAChC,OAAO,IAAA,6BAAa,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;QACpD,CAAC;QACD,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAC/B,OAAO,IAAA,6BAAa,EAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;QACnD,CAAC;KACF;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DeclastructDao } from 'declastruct';
|
|
2
|
+
import type { ContextLogTrail } from 'simple-log-methods';
|
|
3
|
+
import { ContextGithubApi } from '../../domain.objects/ContextGithubApi';
|
|
4
|
+
import { DeclaredGithubRepo } from '../../domain.objects/DeclaredGithubRepo';
|
|
5
|
+
/**
|
|
6
|
+
* .what = declastruct DAO for github repository resources
|
|
7
|
+
* .why = wraps existing repo operations to conform to declastruct interface
|
|
8
|
+
*/
|
|
9
|
+
export declare const DeclaredGithubRepoDao: DeclastructDao<DeclaredGithubRepo, typeof DeclaredGithubRepo, ContextGithubApi & ContextLogTrail>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeclaredGithubRepoDao = void 0;
|
|
4
|
+
const declastruct_1 = require("declastruct");
|
|
5
|
+
const domain_objects_1 = require("domain-objects");
|
|
6
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
7
|
+
const DeclaredGithubRepo_1 = require("../../domain.objects/DeclaredGithubRepo");
|
|
8
|
+
const getRepo_1 = require("../../domain.operations/repo/getRepo");
|
|
9
|
+
const setRepo_1 = require("../../domain.operations/repo/setRepo");
|
|
10
|
+
/**
|
|
11
|
+
* .what = declastruct DAO for github repository resources
|
|
12
|
+
* .why = wraps existing repo operations to conform to declastruct interface
|
|
13
|
+
*/
|
|
14
|
+
exports.DeclaredGithubRepoDao = new declastruct_1.DeclastructDao({
|
|
15
|
+
get: {
|
|
16
|
+
byUnique: async (input, context) => {
|
|
17
|
+
return (0, getRepo_1.getRepo)({ by: { unique: input } }, context);
|
|
18
|
+
},
|
|
19
|
+
byRef: async (input, context) => {
|
|
20
|
+
if ((0, domain_objects_1.isRefByUnique)({ of: DeclaredGithubRepo_1.DeclaredGithubRepo })(input))
|
|
21
|
+
return (0, getRepo_1.getRepo)({ by: { unique: input } }, context);
|
|
22
|
+
helpful_errors_1.UnexpectedCodePathError.throw('unsupported ref type', { input });
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
set: {
|
|
26
|
+
finsert: async (input, context) => {
|
|
27
|
+
return (0, setRepo_1.setRepo)({ finsert: input }, context);
|
|
28
|
+
},
|
|
29
|
+
upsert: async (input, context) => {
|
|
30
|
+
return (0, setRepo_1.setRepo)({ upsert: input }, context);
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=DeclaredGithubRepoDao.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeclaredGithubRepoDao.js","sourceRoot":"","sources":["../../../src/access/daos/DeclaredGithubRepoDao.ts"],"names":[],"mappings":";;;AAAA,6CAA6C;AAC7C,mDAA+C;AAC/C,mDAAyD;AAIzD,gFAA6E;AAC7E,kEAA+D;AAC/D,kEAA+D;AAE/D;;;GAGG;AACU,QAAA,qBAAqB,GAAG,IAAI,4BAAc,CAIrD;IACA,GAAG,EAAE;QACH,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACjC,OAAO,IAAA,iBAAO,EAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;QACrD,CAAC;QACD,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAC9B,IAAI,IAAA,8BAAa,EAAC,EAAE,EAAE,EAAE,uCAAkB,EAAE,CAAC,CAAC,KAAK,CAAC;gBAClD,OAAO,IAAA,iBAAO,EAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;YACrD,wCAAuB,CAAC,KAAK,CAAC,sBAAsB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACnE,CAAC;KACF;IACD,GAAG,EAAE;QACH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAChC,OAAO,IAAA,iBAAO,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;QAC9C,CAAC;QACD,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAC/B,OAAO,IAAA,iBAAO,EAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;QAC7C,CAAC;KACF;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ContextGithubApi } from '../../domain.objects/ContextGithubApi';
|
|
2
|
+
/**
|
|
3
|
+
* .what = returns a cached GitHub API client instance
|
|
4
|
+
* .why = prevents redundant Octokit instantiation while maintaining proper auth context
|
|
5
|
+
*/
|
|
6
|
+
export declare const getGithubClient: (input: unknown, context: ContextGithubApi) => import("@octokit/core").Octokit & import("@octokit/plugin-rest-endpoint-methods/dist-types/generated/method-types").RestEndpointMethods & import("@octokit/plugin-rest-endpoint-methods").Api & {
|
|
7
|
+
paginate: import("@octokit/plugin-paginate-rest").PaginateInterface;
|
|
8
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGithubClient = void 0;
|
|
4
|
+
const rest_1 = require("@octokit/rest");
|
|
5
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
6
|
+
const simple_in_memory_cache_1 = require("simple-in-memory-cache");
|
|
7
|
+
const type_fns_1 = require("type-fns");
|
|
8
|
+
const with_simple_cache_1 = require("with-simple-cache");
|
|
9
|
+
/**
|
|
10
|
+
* .what = returns a cached GitHub API client instance
|
|
11
|
+
* .why = prevents redundant Octokit instantiation while maintaining proper auth context
|
|
12
|
+
*/
|
|
13
|
+
exports.getGithubClient = (0, with_simple_cache_1.withSimpleCache)((input, context) => new rest_1.Octokit({ auth: context.github.token }), {
|
|
14
|
+
cache: (0, simple_in_memory_cache_1.createCache)(),
|
|
15
|
+
serialize: {
|
|
16
|
+
key: (_, context) => context.github?.token ??
|
|
17
|
+
helpful_errors_1.UnexpectedCodePathError.throw('context.github.token was not supplied', {
|
|
18
|
+
forInput: (0, type_fns_1.pick)(context, ['github']),
|
|
19
|
+
}),
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=getGithubClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getGithubClient.js","sourceRoot":"","sources":["../../../src/access/sdks/getGithubClient.ts"],"names":[],"mappings":";;;AAAA,wCAAwC;AACxC,mDAAyD;AACzD,mEAAqD;AACrD,uCAAgC;AAChC,yDAAoD;AAIpD;;;GAGG;AACU,QAAA,eAAe,GAAG,IAAA,mCAAe,EAC5C,CAAC,KAAc,EAAE,OAAyB,EAAE,EAAE,CAC5C,IAAI,cAAO,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAC7C;IACE,KAAK,EAAE,IAAA,oCAAW,GAAE;IACpB,SAAS,EAAE;QACT,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,CAClB,OAAO,CAAC,MAAM,EAAE,KAAK;YACrB,wCAAuB,CAAC,KAAK,CAAC,uCAAuC,EAAE;gBACrE,QAAQ,EAAE,IAAA,eAAI,EAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC;aACpC,CAAC;KACL;CACF,CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const child_process_1 = require("child_process");
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const test_fns_1 = require("test-fns");
|
|
7
|
+
const getSampleGithubContext_1 = require("../../.test/assets/getSampleGithubContext");
|
|
8
|
+
const getDeclastructGithubProvider_1 = require("../../domain.operations/provider/getDeclastructGithubProvider");
|
|
9
|
+
const log = console;
|
|
10
|
+
/**
|
|
11
|
+
* .what = acceptance tests for declastruct CLI workflow
|
|
12
|
+
* .why = validates end-to-end usage of declastruct-github with declastruct CLI
|
|
13
|
+
*/
|
|
14
|
+
describe('declastruct CLI workflow', () => {
|
|
15
|
+
const githubContext = (0, getSampleGithubContext_1.getSampleGithubContext)();
|
|
16
|
+
(0, test_fns_1.given)('a declastruct resources file', () => {
|
|
17
|
+
const testDir = (0, path_1.join)(__dirname, '.test', '.temp', 'acceptance', `run.${new Date().toISOString()}`);
|
|
18
|
+
const resourcesFile = (0, path_1.join)(__dirname, '.test', 'assets', 'resources.acceptance.ts');
|
|
19
|
+
const planFile = (0, path_1.join)(testDir, 'plan.json');
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
// ensure clean test directory
|
|
22
|
+
(0, fs_1.mkdirSync)(testDir, { recursive: true });
|
|
23
|
+
});
|
|
24
|
+
(0, test_fns_1.when)('generating a plan via declastruct CLI', () => {
|
|
25
|
+
(0, test_fns_1.then)('creates a valid plan file', async () => {
|
|
26
|
+
/**
|
|
27
|
+
* .what = validates declastruct plan command produces valid JSON output
|
|
28
|
+
* .why = ensures CLI can parse resources file and generate plan
|
|
29
|
+
*/
|
|
30
|
+
// execute declastruct plan command
|
|
31
|
+
(0, child_process_1.execSync)(`npx declastruct plan --wish ${resourcesFile} --into ${planFile}`, { stdio: 'inherit', env: process.env });
|
|
32
|
+
// verify plan file exists
|
|
33
|
+
const planExists = (0, fs_1.existsSync)(planFile);
|
|
34
|
+
expect(planExists).toBe(true);
|
|
35
|
+
// verify plan contains expected structure
|
|
36
|
+
const plan = JSON.parse((0, fs_1.readFileSync)(planFile, 'utf-8'));
|
|
37
|
+
expect(plan).toHaveProperty('changes');
|
|
38
|
+
expect(Array.isArray(plan.changes)).toBe(true);
|
|
39
|
+
});
|
|
40
|
+
(0, test_fns_1.then)('plan includes repo and config resources', async () => {
|
|
41
|
+
/**
|
|
42
|
+
* .what = validates plan includes all declared resources
|
|
43
|
+
* .why = ensures declastruct correctly processes resource declarations
|
|
44
|
+
*/
|
|
45
|
+
// execute plan generation
|
|
46
|
+
(0, child_process_1.execSync)(`npx declastruct plan --wish ${resourcesFile} --into ${planFile}`, { stdio: 'inherit', env: process.env });
|
|
47
|
+
// parse plan
|
|
48
|
+
const plan = JSON.parse((0, fs_1.readFileSync)(planFile, 'utf-8'));
|
|
49
|
+
// verify resources
|
|
50
|
+
const repoResource = plan.changes.find((r) => r.forResource.class === 'DeclaredGithubRepo');
|
|
51
|
+
const configResource = plan.changes.find((r) => r.forResource.class === 'DeclaredGithubRepoConfig');
|
|
52
|
+
expect(repoResource).toBeDefined();
|
|
53
|
+
expect(repoResource.forResource.slug).toContain('declastruct-github-demo');
|
|
54
|
+
expect(configResource).toBeDefined();
|
|
55
|
+
expect(configResource.forResource.slug).toContain('declastruct-github-demo');
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
(0, test_fns_1.when)('applying a plan via declastruct CLI', () => {
|
|
59
|
+
(0, test_fns_1.then)('executes changes and verifies resources exist', async () => {
|
|
60
|
+
/**
|
|
61
|
+
* .what = validates declastruct apply command works with github provider
|
|
62
|
+
* .why = ensures end-to-end workflow from plan to reality
|
|
63
|
+
* .note = uses existing declastruct-github-demo repo for idempotent test
|
|
64
|
+
*/
|
|
65
|
+
// generate plan
|
|
66
|
+
(0, child_process_1.execSync)(`npx declastruct plan --wish ${resourcesFile} --into ${planFile}`, { stdio: 'inherit', env: process.env });
|
|
67
|
+
// apply plan
|
|
68
|
+
(0, child_process_1.execSync)(`npx declastruct apply --plan ${planFile}`, {
|
|
69
|
+
stdio: 'inherit',
|
|
70
|
+
env: process.env,
|
|
71
|
+
});
|
|
72
|
+
// verify resources exist via github API
|
|
73
|
+
const provider = (0, getDeclastructGithubProvider_1.getDeclastructGithubProvider)({
|
|
74
|
+
credentials: { token: githubContext.github.token },
|
|
75
|
+
}, { log });
|
|
76
|
+
const repo = await provider.daos.DeclaredGithubRepo.get.byUnique({
|
|
77
|
+
owner: 'ehmpathy',
|
|
78
|
+
name: 'declastruct-github-demo',
|
|
79
|
+
}, provider.context);
|
|
80
|
+
expect(repo).toBeDefined();
|
|
81
|
+
expect(repo.name).toBe('declastruct-github-demo');
|
|
82
|
+
});
|
|
83
|
+
(0, test_fns_1.then)('is idempotent - applying same plan twice succeeds', async () => {
|
|
84
|
+
/**
|
|
85
|
+
* .what = validates applying the same plan multiple times is safe
|
|
86
|
+
* .why = ensures declastruct operations follow idempotency requirements
|
|
87
|
+
*/
|
|
88
|
+
// generate plan
|
|
89
|
+
(0, child_process_1.execSync)(`npx declastruct plan --wish ${resourcesFile} --into ${planFile}`, { stdio: 'inherit', env: process.env });
|
|
90
|
+
// apply plan first time
|
|
91
|
+
(0, child_process_1.execSync)(`npx declastruct apply --plan ${planFile}`, {
|
|
92
|
+
stdio: 'inherit',
|
|
93
|
+
env: process.env,
|
|
94
|
+
});
|
|
95
|
+
// apply plan second time - should succeed without errors
|
|
96
|
+
(0, child_process_1.execSync)(`npx declastruct apply --plan ${planFile}`, {
|
|
97
|
+
stdio: 'inherit',
|
|
98
|
+
env: process.env,
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
//# sourceMappingURL=declastruct.acceptance.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declastruct.acceptance.test.js","sourceRoot":"","sources":["../../../src/contract/sdks/declastruct.acceptance.test.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = public SDK exports for declastruct-github package
|
|
3
|
+
* .why = enables consumers to use the declastruct provider interface and domain objects
|
|
4
|
+
*/
|
|
5
|
+
export { getDeclastructGithubProvider } from '../../domain.operations/provider/getDeclastructGithubProvider';
|
|
6
|
+
export type { DeclastructGithubProvider } from '../../domain.objects/DeclastructGithubProvider';
|
|
7
|
+
export { DeclaredGithubRepo } from '../../domain.objects/DeclaredGithubRepo';
|
|
8
|
+
export { DeclaredGithubBranch } from '../../domain.objects/DeclaredGithubBranch';
|
|
9
|
+
export { DeclaredGithubRepoConfig } from '../../domain.objects/DeclaredGithubRepoConfig';
|
|
10
|
+
export { DeclaredGithubBranchProtection } from '../../domain.objects/DeclaredGithubBranchProtection';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* .what = public SDK exports for declastruct-github package
|
|
4
|
+
* .why = enables consumers to use the declastruct provider interface and domain objects
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DeclaredGithubBranchProtection = exports.DeclaredGithubRepoConfig = exports.DeclaredGithubBranch = exports.DeclaredGithubRepo = exports.getDeclastructGithubProvider = void 0;
|
|
8
|
+
// provider
|
|
9
|
+
var getDeclastructGithubProvider_1 = require("../../domain.operations/provider/getDeclastructGithubProvider");
|
|
10
|
+
Object.defineProperty(exports, "getDeclastructGithubProvider", { enumerable: true, get: function () { return getDeclastructGithubProvider_1.getDeclastructGithubProvider; } });
|
|
11
|
+
// domain objects
|
|
12
|
+
var DeclaredGithubRepo_1 = require("../../domain.objects/DeclaredGithubRepo");
|
|
13
|
+
Object.defineProperty(exports, "DeclaredGithubRepo", { enumerable: true, get: function () { return DeclaredGithubRepo_1.DeclaredGithubRepo; } });
|
|
14
|
+
var DeclaredGithubBranch_1 = require("../../domain.objects/DeclaredGithubBranch");
|
|
15
|
+
Object.defineProperty(exports, "DeclaredGithubBranch", { enumerable: true, get: function () { return DeclaredGithubBranch_1.DeclaredGithubBranch; } });
|
|
16
|
+
var DeclaredGithubRepoConfig_1 = require("../../domain.objects/DeclaredGithubRepoConfig");
|
|
17
|
+
Object.defineProperty(exports, "DeclaredGithubRepoConfig", { enumerable: true, get: function () { return DeclaredGithubRepoConfig_1.DeclaredGithubRepoConfig; } });
|
|
18
|
+
var DeclaredGithubBranchProtection_1 = require("../../domain.objects/DeclaredGithubBranchProtection");
|
|
19
|
+
Object.defineProperty(exports, "DeclaredGithubBranchProtection", { enumerable: true, get: function () { return DeclaredGithubBranchProtection_1.DeclaredGithubBranchProtection; } });
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contract/sdks/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,WAAW;AACX,8GAA6G;AAApG,4IAAA,4BAA4B,OAAA;AAGrC,iBAAiB;AACjB,8EAA6E;AAApE,wHAAA,kBAAkB,OAAA;AAC3B,kFAAiF;AAAxE,4HAAA,oBAAoB,OAAA;AAC7B,0FAAyF;AAAhF,oIAAA,wBAAwB,OAAA;AACjC,sGAAqG;AAA5F,gJAAA,8BAA8B,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextGithubApi.js","sourceRoot":"","sources":["../../src/domain.objects/ContextGithubApi.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { DomainEntity, RefByUnique } from 'domain-objects';
|
|
2
|
+
import { DeclaredGithubRepo } from './DeclaredGithubRepo';
|
|
3
|
+
/**
|
|
4
|
+
* .what = a declarative structure which represents a GitHub branch
|
|
5
|
+
* .why = enables declarative management of GitHub branches following declastruct patterns
|
|
6
|
+
*/
|
|
7
|
+
export interface DeclaredGithubBranch {
|
|
8
|
+
/**
|
|
9
|
+
* .what = the commit that this branch points to
|
|
10
|
+
* .note = is @metadata -> may be undefined
|
|
11
|
+
*/
|
|
12
|
+
commit?: {
|
|
13
|
+
sha: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* .what = whether branch protection is enabled
|
|
17
|
+
* .note = is @metadata -> may be undefined
|
|
18
|
+
*/
|
|
19
|
+
protected?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* .what = reference to the repository this branch belongs to
|
|
22
|
+
*/
|
|
23
|
+
repo: RefByUnique<typeof DeclaredGithubRepo>;
|
|
24
|
+
/**
|
|
25
|
+
* .what = branch name
|
|
26
|
+
* .note = e.g., 'main', 'develop', 'feature/add-auth'
|
|
27
|
+
*/
|
|
28
|
+
name: string;
|
|
29
|
+
}
|
|
30
|
+
export declare class DeclaredGithubBranch extends DomainEntity<DeclaredGithubBranch> implements DeclaredGithubBranch {
|
|
31
|
+
static unique: readonly ["repo", "name"];
|
|
32
|
+
static nested: {
|
|
33
|
+
repo: {
|
|
34
|
+
new (props: RefByUnique<typeof DeclaredGithubRepo, any, any, any>): RefByUnique<typeof DeclaredGithubRepo, any, any, any>;
|
|
35
|
+
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>;
|
|
36
|
+
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>;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeclaredGithubBranch = void 0;
|
|
4
|
+
const domain_objects_1 = require("domain-objects");
|
|
5
|
+
class DeclaredGithubBranch extends domain_objects_1.DomainEntity {
|
|
6
|
+
}
|
|
7
|
+
exports.DeclaredGithubBranch = DeclaredGithubBranch;
|
|
8
|
+
DeclaredGithubBranch.unique = ['repo', 'name'];
|
|
9
|
+
DeclaredGithubBranch.nested = {
|
|
10
|
+
repo: (domain_objects_1.RefByUnique),
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=DeclaredGithubBranch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeclaredGithubBranch.js","sourceRoot":"","sources":["../../src/domain.objects/DeclaredGithubBranch.ts"],"names":[],"mappings":";;;AAAA,mDAA2D;AAiC3D,MAAa,oBACX,SAAQ,6BAAkC;;AAD5C,oDAQC;AAJe,2BAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAU,CAAC;AACnC,2BAAM,GAAG;IACrB,IAAI,EAAE,CAAA,4BAAsC,CAAA;CAC7C,CAAC"}
|