declastruct-github 1.0.3 → 1.0.5

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.
Files changed (90) hide show
  1. package/dist/access/daos/DeclaredGithubBranchDao.d.ts +1 -1
  2. package/dist/access/daos/DeclaredGithubBranchProtectionDao.d.ts +1 -1
  3. package/dist/access/daos/DeclaredGithubRepoConfigDao.d.ts +1 -1
  4. package/dist/access/daos/DeclaredGithubRepoDao.d.ts +1 -1
  5. package/dist/access/sdks/getGithubClient.d.ts +3 -4
  6. package/dist/access/sdks/getGithubClient.js.map +1 -1
  7. package/dist/contract/sdks/index.d.ts +4 -4
  8. package/dist/contract/sdks/index.js +8 -8
  9. package/dist/contract/sdks/index.js.map +1 -1
  10. package/dist/domain/constants.d.ts +3 -0
  11. package/dist/domain/constants.js +5 -0
  12. package/dist/domain/constants.js.map +1 -0
  13. package/dist/domain.objects/DeclaredGithubBranch.d.ts +1 -1
  14. package/dist/domain.objects/DeclaredGithubBranchProtection.d.ts +1 -1
  15. package/dist/domain.objects/DeclaredGithubRepo.d.ts +1 -1
  16. package/dist/domain.objects/DeclaredGithubRepoConfig.d.ts +1 -1
  17. package/dist/domain.objects/DeclastructGithubProvider.d.ts +6 -6
  18. package/dist/domain.operations/branch/castToDeclaredGithubBranch.d.ts +3 -3
  19. package/dist/domain.operations/branch/castToDeclaredGithubBranch.js.map +1 -1
  20. package/dist/domain.operations/branch/getBranch.d.ts +5 -5
  21. package/dist/domain.operations/branch/getBranchCommitShaByRepoDefault.d.ts +4 -4
  22. package/dist/domain.operations/branch/getBranches.d.ts +6 -6
  23. package/dist/domain.operations/branch/setBranch.d.ts +4 -4
  24. package/dist/domain.operations/branchProtection/castToDeclaredGithubBranchProtection.d.ts +3 -3
  25. package/dist/domain.operations/branchProtection/castToDeclaredGithubBranchProtection.js.map +1 -1
  26. package/dist/domain.operations/branchProtection/getBranchProtection.d.ts +5 -5
  27. package/dist/domain.operations/branchProtection/setBranchProtection.d.ts +4 -4
  28. package/dist/domain.operations/provider/getDeclastructGithubProvider.d.ts +1 -1
  29. package/dist/domain.operations/repo/castToDeclaredGithubRepo.d.ts +2 -2
  30. package/dist/domain.operations/repo/castToDeclaredGithubRepo.js.map +1 -1
  31. package/dist/domain.operations/repo/getRepo.d.ts +5 -5
  32. package/dist/domain.operations/repo/getRepos.d.ts +4 -4
  33. package/dist/domain.operations/repo/setRepo.d.ts +4 -4
  34. package/dist/domain.operations/repoConfig/castToDeclaredGithubRepoConfig.d.ts +3 -3
  35. package/dist/domain.operations/repoConfig/castToDeclaredGithubRepoConfig.js.map +1 -1
  36. package/dist/domain.operations/repoConfig/getRepoConfig.d.ts +5 -5
  37. package/dist/domain.operations/repoConfig/setRepoConfig.d.ts +4 -4
  38. package/license.md +21 -0
  39. package/package.json +34 -39
  40. package/dist/.test/assets/getSampleGithubContext.d.ts +0 -6
  41. package/dist/.test/assets/getSampleGithubContext.js +0 -18
  42. package/dist/.test/assets/getSampleGithubContext.js.map +0 -1
  43. package/dist/.test/assets/getSampleRepo.d.ts +0 -9
  44. package/dist/.test/assets/getSampleRepo.js +0 -16
  45. package/dist/.test/assets/getSampleRepo.js.map +0 -1
  46. package/dist/contract/sdks/declastruct.acceptance.test.d.ts +0 -1
  47. package/dist/contract/sdks/declastruct.acceptance.test.js +0 -104
  48. package/dist/contract/sdks/declastruct.acceptance.test.js.map +0 -1
  49. package/dist/domain.operations/branch/getBranch.integration.test.d.ts +0 -1
  50. package/dist/domain.operations/branch/getBranch.integration.test.js +0 -59
  51. package/dist/domain.operations/branch/getBranch.integration.test.js.map +0 -1
  52. package/dist/domain.operations/branch/getBranches.integration.test.d.ts +0 -1
  53. package/dist/domain.operations/branch/getBranches.integration.test.js +0 -40
  54. package/dist/domain.operations/branch/getBranches.integration.test.js.map +0 -1
  55. package/dist/domain.operations/branch/setBranch.integration.test.d.ts +0 -1
  56. package/dist/domain.operations/branch/setBranch.integration.test.js +0 -65
  57. package/dist/domain.operations/branch/setBranch.integration.test.js.map +0 -1
  58. package/dist/domain.operations/branch/setBranch.test.d.ts +0 -1
  59. package/dist/domain.operations/branch/setBranch.test.js +0 -151
  60. package/dist/domain.operations/branch/setBranch.test.js.map +0 -1
  61. package/dist/domain.operations/branchProtection/getBranchProtection.integration.test.d.ts +0 -1
  62. package/dist/domain.operations/branchProtection/getBranchProtection.integration.test.js +0 -63
  63. package/dist/domain.operations/branchProtection/getBranchProtection.integration.test.js.map +0 -1
  64. package/dist/domain.operations/branchProtection/setBranchProtection.integration.test.d.ts +0 -1
  65. package/dist/domain.operations/branchProtection/setBranchProtection.integration.test.js +0 -96
  66. package/dist/domain.operations/branchProtection/setBranchProtection.integration.test.js.map +0 -1
  67. package/dist/domain.operations/branchProtection/setBranchProtection.test.d.ts +0 -1
  68. package/dist/domain.operations/branchProtection/setBranchProtection.test.js +0 -173
  69. package/dist/domain.operations/branchProtection/setBranchProtection.test.js.map +0 -1
  70. package/dist/domain.operations/provider/getDeclastructGithubProvider.integration.test.d.ts +0 -1
  71. package/dist/domain.operations/provider/getDeclastructGithubProvider.integration.test.js +0 -212
  72. package/dist/domain.operations/provider/getDeclastructGithubProvider.integration.test.js.map +0 -1
  73. package/dist/domain.operations/repo/getRepo.integration.test.d.ts +0 -1
  74. package/dist/domain.operations/repo/getRepo.integration.test.js +0 -45
  75. package/dist/domain.operations/repo/getRepo.integration.test.js.map +0 -1
  76. package/dist/domain.operations/repo/getRepos.integration.test.d.ts +0 -1
  77. package/dist/domain.operations/repo/getRepos.integration.test.js +0 -28
  78. package/dist/domain.operations/repo/getRepos.integration.test.js.map +0 -1
  79. package/dist/domain.operations/repo/setRepo.integration.test.d.ts +0 -1
  80. package/dist/domain.operations/repo/setRepo.integration.test.js +0 -29
  81. package/dist/domain.operations/repo/setRepo.integration.test.js.map +0 -1
  82. package/dist/domain.operations/repo/setRepo.test.d.ts +0 -1
  83. package/dist/domain.operations/repo/setRepo.test.js +0 -150
  84. package/dist/domain.operations/repo/setRepo.test.js.map +0 -1
  85. package/dist/domain.operations/repoConfig/getRepoConfig.integration.test.d.ts +0 -1
  86. package/dist/domain.operations/repoConfig/getRepoConfig.integration.test.js +0 -55
  87. package/dist/domain.operations/repoConfig/getRepoConfig.integration.test.js.map +0 -1
  88. package/dist/domain.operations/repoConfig/setRepoConfig.integration.test.d.ts +0 -1
  89. package/dist/domain.operations/repoConfig/setRepoConfig.integration.test.js +0 -87
  90. package/dist/domain.operations/repoConfig/setRepoConfig.integration.test.js.map +0 -1
@@ -1,18 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,9 +0,0 @@
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;
@@ -1,16 +0,0 @@
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
- visibility: 'public',
14
- });
15
- exports.getSampleRepo = getSampleRepo;
16
- //# sourceMappingURL=getSampleRepo.js.map
@@ -1 +0,0 @@
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,UAAU,EAAE,QAAQ;CACrB,CAAC,CAAC;AATQ,QAAA,aAAa,iBASrB"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,104 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"declastruct.acceptance.test.js","sourceRoot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AQ,EAAE,EACjE,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CACvC,CAAC;gBAEF,wBAAwB;gBACxB,IAAA,wBAAQ,EAAC,gCAAgC,QAAQ,EAAE,EAAE;oBACnD,KAAK,EAAE,SAAS;oBAChB,GAAG,EAAE,OAAO,CAAC,GAAG;iBACjB,CAAC,CAAC;gBAEH,yDAAyD;gBACzD,IAAA,wBAAQ,EAAC,gCAAgC,QAAQ,EAAE,EAAE;oBACnD,KAAK,EAAE,SAAS;oBAChB,GAAG,EAAE,OAAO,CAAC,GAAG;iBACjB,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,59 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,40 +0,0 @@
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 getBranches_1 = require("./getBranches");
7
- const log = console;
8
- describe('getBranches', () => {
9
- const context = { log, ...(0, getSampleGithubContext_1.getSampleGithubContext)() };
10
- (0, test_fns_1.given)('a live example repo with branches', () => {
11
- (0, test_fns_1.then)('we should be able to list its branches', async () => {
12
- const sampleRepo = (0, getSampleRepo_1.getSampleRepo)({
13
- owner: 'ehmpathy',
14
- name: 'declastruct-github-demo',
15
- });
16
- const branches = await (0, getBranches_1.getBranches)({
17
- where: {
18
- repo: {
19
- owner: sampleRepo.owner,
20
- name: sampleRepo.name,
21
- },
22
- },
23
- }, context);
24
- console.log(branches);
25
- expect(branches).toBeDefined();
26
- expect(Array.isArray(branches)).toBe(true);
27
- expect(branches.length).toBeGreaterThan(0);
28
- // verify first branch has expected shape
29
- const firstBranch = branches[0];
30
- expect(firstBranch?.name).toBeDefined();
31
- expect(firstBranch?.commit?.sha).toBeDefined();
32
- expect(firstBranch?.repo).toEqual({
33
- owner: sampleRepo.owner,
34
- name: sampleRepo.name,
35
- });
36
- expect(typeof firstBranch?.protected).toBe('boolean');
37
- });
38
- });
39
- });
40
- //# sourceMappingURL=getBranches.integration.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getBranches.integration.test.js","sourceRoot":"","sources":["../../../src/domain.operations/branch/getBranches.integration.test.ts"],"names":[],"mappings":";;AAAA,uCAAuC;AAEvC,sFAAmF;AACnF,oEAAiE;AACjE,+CAA4C;AAE5C,MAAM,GAAG,GAAG,OAAO,CAAC;AAEpB,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,GAAG,IAAA,+CAAsB,GAAE,EAAE,CAAC;IAErD,IAAA,gBAAK,EAAC,mCAAmC,EAAE,GAAG,EAAE;QAC9C,IAAA,eAAI,EAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;YACxD,MAAM,UAAU,GAAG,IAAA,6BAAa,EAAC;gBAC/B,KAAK,EAAE,UAAU;gBACjB,IAAI,EAAE,yBAAyB;aAChC,CAAC,CAAC;YAEH,MAAM,QAAQ,GAAG,MAAM,IAAA,yBAAW,EAChC;gBACE,KAAK,EAAE;oBACL,IAAI,EAAE;wBACJ,KAAK,EAAE,UAAU,CAAC,KAAK;wBACvB,IAAI,EAAE,UAAU,CAAC,IAAI;qBACtB;iBACF;aACF,EACD,OAAO,CACR,CAAC;YAEF,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACtB,MAAM,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;YAC/B,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC3C,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;YAE3C,yCAAyC;YACzC,MAAM,WAAW,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;YAChC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;YACxC,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;YAC/C,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC;gBAChC,KAAK,EAAE,UAAU,CAAC,KAAK;gBACvB,IAAI,EAAE,UAAU,CAAC,IAAI;aACtB,CAAC,CAAC;YACH,MAAM,CAAC,OAAO,WAAW,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const helpful_errors_1 = require("helpful-errors");
4
- const getSampleGithubContext_1 = require("../../.test/assets/getSampleGithubContext");
5
- const getSampleRepo_1 = require("../../.test/assets/getSampleRepo");
6
- const getBranch_1 = require("./getBranch");
7
- const setBranch_1 = require("./setBranch");
8
- const log = console;
9
- describe('setBranch', () => {
10
- const context = { log, ...(0, getSampleGithubContext_1.getSampleGithubContext)() };
11
- describe('live tests', () => {
12
- it('should create a new branch with explicit commit.sha', async () => {
13
- const sampleRepo = (0, getSampleRepo_1.getSampleRepo)({
14
- owner: 'ehmpathy',
15
- name: 'declastruct-github-demo',
16
- });
17
- // Get a commit SHA from the demo repo's main branch
18
- const demoRepoBranch = (await (0, getBranch_1.getBranch)({
19
- by: {
20
- unique: {
21
- repo: { owner: 'ehmpathy', name: 'declastruct-github-demo' },
22
- name: 'main',
23
- },
24
- },
25
- }, context)) ??
26
- helpful_errors_1.UnexpectedCodePathError.throw('demo repo branch not found', {
27
- sampleRepo,
28
- });
29
- const branchName = `test-branch-${Date.now()}`;
30
- const result = await (0, setBranch_1.setBranch)({
31
- finsert: {
32
- repo: {
33
- owner: sampleRepo.owner,
34
- name: sampleRepo.name,
35
- },
36
- name: branchName,
37
- commit: { sha: demoRepoBranch.commit.sha },
38
- },
39
- }, context);
40
- expect(result).toBeDefined();
41
- expect(result.name).toBe(branchName);
42
- expect(result.commit?.sha).toBe(demoRepoBranch.commit.sha);
43
- });
44
- it('should return existing branch for finsert', async () => {
45
- // Use the main declastruct-github repo which we know exists
46
- const sampleRepo = (0, getSampleRepo_1.getSampleRepo)({
47
- owner: 'ehmpathy',
48
- name: 'declastruct-github',
49
- });
50
- const result = await (0, setBranch_1.setBranch)({
51
- finsert: {
52
- repo: {
53
- owner: sampleRepo.owner,
54
- name: sampleRepo.name,
55
- },
56
- name: 'main',
57
- },
58
- }, context);
59
- expect(result).toBeDefined();
60
- expect(result.name).toBe('main');
61
- expect(result.commit?.sha).toBeDefined();
62
- });
63
- });
64
- });
65
- //# sourceMappingURL=setBranch.integration.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setBranch.integration.test.js","sourceRoot":"","sources":["../../../src/domain.operations/branch/setBranch.integration.test.ts"],"names":[],"mappings":";;AAAA,mDAAyD;AAEzD,sFAAmF;AACnF,oEAAiE;AACjE,2CAAwC;AACxC,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,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QAC1B,EAAE,CAAC,qDAAqD,EAAE,KAAK,IAAI,EAAE;YACnE,MAAM,UAAU,GAAG,IAAA,6BAAa,EAAC;gBAC/B,KAAK,EAAE,UAAU;gBACjB,IAAI,EAAE,yBAAyB;aAChC,CAAC,CAAC;YAEH,oDAAoD;YACpD,MAAM,cAAc,GAClB,CAAC,MAAM,IAAA,qBAAS,EACd;gBACE,EAAE,EAAE;oBACF,MAAM,EAAE;wBACN,IAAI,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,yBAAyB,EAAE;wBAC5D,IAAI,EAAE,MAAM;qBACb;iBACF;aACF,EACD,OAAO,CACR,CAAC;gBACF,wCAAuB,CAAC,KAAK,CAAC,4BAA4B,EAAE;oBAC1D,UAAU;iBACX,CAAC,CAAC;YAEL,MAAM,UAAU,GAAG,eAAe,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;YAE/C,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAS,EAC5B;gBACE,OAAO,EAAE;oBACP,IAAI,EAAE;wBACJ,KAAK,EAAE,UAAU,CAAC,KAAK;wBACvB,IAAI,EAAE,UAAU,CAAC,IAAI;qBACtB;oBACD,IAAI,EAAE,UAAU;oBAChB,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,CAAC,MAAO,CAAC,GAAG,EAAE;iBAC5C;aACF,EACD,OAAO,CACR,CAAC;YAEF,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;YAC7B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACrC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,MAAO,CAAC,GAAG,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;YACzD,4DAA4D;YAC5D,MAAM,UAAU,GAAG,IAAA,6BAAa,EAAC;gBAC/B,KAAK,EAAE,UAAU;gBACjB,IAAI,EAAE,oBAAoB;aAC3B,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAS,EAC5B;gBACE,OAAO,EAAE;oBACP,IAAI,EAAE;wBACJ,KAAK,EAAE,UAAU,CAAC,KAAK;wBACvB,IAAI,EAAE,UAAU,CAAC,IAAI;qBACtB;oBACD,IAAI,EAAE,MAAM;iBACb;aACF,EACD,OAAO,CACR,CAAC;YAEF,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;YAC7B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACjC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,151 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const getBranchModule = __importStar(require("./getBranch"));
27
- const setBranch_1 = require("./setBranch");
28
- jest.mock('@octokit/rest', () => ({
29
- Octokit: jest.fn(),
30
- }));
31
- jest.mock('./getBranch');
32
- const mockCreateRef = jest.fn();
33
- const mockGet = jest.fn();
34
- const { Octokit } = jest.requireMock('@octokit/rest');
35
- Octokit.mockImplementation(() => ({
36
- git: {
37
- createRef: mockCreateRef,
38
- },
39
- repos: {
40
- get: mockGet,
41
- },
42
- }));
43
- const context = {
44
- github: { token: 'test-token' },
45
- log: console,
46
- };
47
- const branchSample = {
48
- repo: {
49
- owner: 'test-owner',
50
- name: 'test-repo',
51
- },
52
- name: 'test-branch',
53
- commit: { sha: 'abc123' },
54
- };
55
- describe('setBranch', () => {
56
- beforeEach(() => {
57
- jest.clearAllMocks();
58
- });
59
- it('returns early for finsert if branch already exists (before)', async () => {
60
- const before = {
61
- ...branchSample,
62
- commit: { sha: 'abc123' },
63
- protected: false,
64
- };
65
- getBranchModule.getBranch.mockResolvedValue(before);
66
- const result = await (0, setBranch_1.setBranch)({ finsert: branchSample }, context);
67
- expect(result).toBe(before);
68
- expect(getBranchModule.getBranch).toHaveBeenCalled();
69
- expect(mockCreateRef).not.toHaveBeenCalled();
70
- });
71
- it('returns existing for upsert if branch exists and no commit.sha change', async () => {
72
- const before = {
73
- ...branchSample,
74
- commit: { sha: 'abc123' },
75
- protected: false,
76
- };
77
- getBranchModule.getBranch.mockResolvedValue(before);
78
- const result = await (0, setBranch_1.setBranch)({ upsert: branchSample }, context);
79
- expect(result).toBe(before);
80
- expect(getBranchModule.getBranch).toHaveBeenCalled();
81
- expect(mockCreateRef).not.toHaveBeenCalled();
82
- });
83
- it('creates branch with specified commit.sha', async () => {
84
- const branchWithCommit = {
85
- ...branchSample,
86
- commit: { sha: 'specifiedSha123' },
87
- };
88
- // first getBranch call returns null (branch doesn't exist)
89
- // second getBranch call returns created branch
90
- getBranchModule.getBranch
91
- .mockResolvedValueOnce(null)
92
- .mockResolvedValueOnce({
93
- ...branchSample,
94
- commit: { sha: 'specifiedSha123' },
95
- protected: false,
96
- });
97
- mockCreateRef.mockResolvedValue({ data: {} });
98
- const result = await (0, setBranch_1.setBranch)({ finsert: branchWithCommit }, context);
99
- expect(mockCreateRef).toHaveBeenCalledWith({
100
- owner: 'test-owner',
101
- repo: 'test-repo',
102
- ref: 'refs/heads/test-branch',
103
- sha: 'specifiedSha123',
104
- });
105
- expect(result.commit?.sha).toBe('specifiedSha123');
106
- });
107
- it('creates branch from default branch if commit.sha not specified', async () => {
108
- const branchWithoutCommit = {
109
- repo: {
110
- owner: 'test-owner',
111
- name: 'test-repo',
112
- },
113
- name: 'test-branch',
114
- };
115
- // first getBranch call returns null (branch doesn't exist)
116
- // second getBranch call returns default branch
117
- // third getBranch call returns created branch
118
- getBranchModule.getBranch
119
- .mockResolvedValueOnce(null)
120
- .mockResolvedValueOnce({
121
- ...branchSample,
122
- name: 'main',
123
- commit: { sha: 'defaultSha456' },
124
- protected: false,
125
- })
126
- .mockResolvedValueOnce({
127
- ...branchSample,
128
- commit: { sha: 'defaultSha456' },
129
- protected: false,
130
- });
131
- mockGet.mockResolvedValue({
132
- data: {
133
- default_branch: 'main',
134
- },
135
- });
136
- mockCreateRef.mockResolvedValue({ data: {} });
137
- const result = await (0, setBranch_1.setBranch)({ finsert: branchWithoutCommit }, context);
138
- expect(mockGet).toHaveBeenCalledWith({
139
- owner: 'test-owner',
140
- repo: 'test-repo',
141
- });
142
- expect(mockCreateRef).toHaveBeenCalledWith({
143
- owner: 'test-owner',
144
- repo: 'test-repo',
145
- ref: 'refs/heads/test-branch',
146
- sha: 'defaultSha456',
147
- });
148
- expect(result.commit?.sha).toBe('defaultSha456');
149
- });
150
- });
151
- //# sourceMappingURL=setBranch.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setBranch.test.js","sourceRoot":"","sources":["../../../src/domain.operations/branch/setBranch.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAIA,6DAA+C;AAC/C,2CAAwC;AAExC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE,CAAC,CAAC;IAChC,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;CACnB,CAAC,CAAC,CAAC;AACJ,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AAEzB,MAAM,aAAa,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAChC,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAE1B,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;AACtD,OAAO,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAC;IAChC,GAAG,EAAE;QACH,SAAS,EAAE,aAAa;KACzB;IACD,KAAK,EAAE;QACL,GAAG,EAAE,OAAO;KACb;CACF,CAAC,CAAC,CAAC;AAEJ,MAAM,OAAO,GAAyC;IACpD,MAAM,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE;IAC/B,GAAG,EAAE,OAAO;CACb,CAAC;AAEF,MAAM,YAAY,GAAyB;IACzC,IAAI,EAAE;QACJ,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,WAAW;KAClB;IACD,IAAI,EAAE,aAAa;IACnB,MA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AI,CAAC;aAC3B,qBAAqB,CAAC;YACrB,GAAG,YAAY;YACf,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE;YAChC,SAAS,EAAE,KAAK;SACjB,CAAC;aACD,qBAAqB,CAAC;YACrB,GAAG,YAAY;YACf,MAAM,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE;YAChC,SAAS,EAAE,KAAK;SACjB,CAAC,CAAC;QAEL,OAAO,CAAC,iBAAiB,CAAC;YACxB,IAAI,EAAE;gBACJ,cAAc,EAAE,MAAM;aACvB;SACF,CAAC,CAAC;QAEH,aAAa,CAAC,iBAAiB,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAE9C,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAS,EAAC,EAAE,OAAO,EAAE,mBAAmB,EAAE,EAAE,OAAO,CAAC,CAAC;QAE1E,MAAM,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAAC;YACnC,KAAK,EAAE,YAAY;YACnB,IAAI,EAAE,WAAW;SAClB,CAAC,CAAC;QACH,MAAM,CAAC,aAAa,CAAC,CAAC,oBAAoB,CAAC;YACzC,KAAK,EAAE,YAAY;YACnB,IAAI,EAAE,WAAW;YACjB,GAAG,EAAE,wBAAwB;YAC7B,GAAG,EAAE,eAAe;SACrB,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,63 +0,0 @@
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 getBranchProtection_1 = require("./getBranchProtection");
7
- const log = console;
8
- describe('getBranchProtection', () => {
9
- const context = { log, ...(0, getSampleGithubContext_1.getSampleGithubContext)() };
10
- (0, test_fns_1.given)('a protected branch exists', () => {
11
- (0, test_fns_1.then)('we should be able to get its protection rules', async () => {
12
- const sampleRepo = (0, getSampleRepo_1.getSampleRepo)({
13
- owner: 'ehmpathy',
14
- name: 'declastruct-github-demo',
15
- });
16
- const protection = await (0, getBranchProtection_1.getBranchProtection)({
17
- by: {
18
- unique: {
19
- branch: {
20
- repo: {
21
- owner: sampleRepo.owner,
22
- name: sampleRepo.name,
23
- },
24
- name: 'main',
25
- },
26
- },
27
- },
28
- }, context);
29
- console.log(protection);
30
- // May be null if branch has no protection
31
- if (protection) {
32
- expect(protection.branch.repo.owner).toBe(sampleRepo.owner);
33
- expect(protection.branch.repo.name).toBe(sampleRepo.name);
34
- expect(protection.branch.name).toBe('main');
35
- }
36
- });
37
- });
38
- (0, test_fns_1.given)('an unprotected branch', () => {
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
- // Try to get protection for a branch that likely doesn't have protection
45
- const protection = await (0, getBranchProtection_1.getBranchProtection)({
46
- by: {
47
- unique: {
48
- branch: {
49
- repo: {
50
- owner: sampleRepo.owner,
51
- name: sampleRepo.name,
52
- },
53
- name: 'test-branch-unprotected-99999',
54
- },
55
- },
56
- },
57
- }, context);
58
- // Should return null for non-existent branch or unprotected branch
59
- expect(protection).toBeNull();
60
- });
61
- });
62
- });
63
- //# sourceMappingURL=getBranchProtection.integration.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getBranchProtection.integration.test.js","sourceRoot":"","sources":["../../../src/domain.operations/branchProtection/getBranchProtection.integration.test.ts"],"names":[],"mappings":";;AAAA,uCAAuC;AAEvC,sFAAmF;AACnF,oEAAiE;AACjE,+DAA4D;AAE5D,MAAM,GAAG,GAAG,OAAO,CAAC;AAEpB,QAAQ,CAAC,qBAAqB,EAAE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