declastruct-github 1.1.1 → 1.2.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.
Files changed (86) hide show
  1. package/dist/access/daos/DeclaredGithubOrgDao.d.ts +10 -0
  2. package/dist/access/daos/DeclaredGithubOrgDao.js +44 -0
  3. package/dist/access/daos/DeclaredGithubOrgDao.js.map +1 -0
  4. package/dist/access/daos/DeclaredGithubOrgMemberPrivilegesDao.d.ts +10 -0
  5. package/dist/access/daos/DeclaredGithubOrgMemberPrivilegesDao.js +44 -0
  6. package/dist/access/daos/DeclaredGithubOrgMemberPrivilegesDao.js.map +1 -0
  7. package/dist/access/daos/DeclaredGithubOrgSecretDao.d.ts +10 -0
  8. package/dist/access/daos/DeclaredGithubOrgSecretDao.js +47 -0
  9. package/dist/access/daos/DeclaredGithubOrgSecretDao.js.map +1 -0
  10. package/dist/access/daos/DeclaredGithubOrgVariableDao.d.ts +9 -0
  11. package/dist/access/daos/DeclaredGithubOrgVariableDao.js +46 -0
  12. package/dist/access/daos/DeclaredGithubOrgVariableDao.js.map +1 -0
  13. package/dist/contract/sdks/index.d.ts +4 -0
  14. package/dist/contract/sdks/index.js +10 -1
  15. package/dist/contract/sdks/index.js.map +1 -1
  16. package/dist/domain.objects/DeclaredGithubAppPermissions.d.ts +6 -2
  17. package/dist/domain.objects/DeclaredGithubAppPermissions.js.map +1 -1
  18. package/dist/domain.objects/DeclaredGithubOrg.d.ts +59 -0
  19. package/dist/domain.objects/DeclaredGithubOrg.js +15 -0
  20. package/dist/domain.objects/DeclaredGithubOrg.js.map +1 -0
  21. package/dist/domain.objects/DeclaredGithubOrgMemberPrivileges.d.ts +85 -0
  22. package/dist/domain.objects/DeclaredGithubOrgMemberPrivileges.js +13 -0
  23. package/dist/domain.objects/DeclaredGithubOrgMemberPrivileges.js.map +1 -0
  24. package/dist/domain.objects/DeclaredGithubOrgSecret.d.ts +63 -0
  25. package/dist/domain.objects/DeclaredGithubOrgSecret.js +14 -0
  26. package/dist/domain.objects/DeclaredGithubOrgSecret.js.map +1 -0
  27. package/dist/domain.objects/DeclaredGithubOrgVariable.d.ts +54 -0
  28. package/dist/domain.objects/DeclaredGithubOrgVariable.js +13 -0
  29. package/dist/domain.objects/DeclaredGithubOrgVariable.js.map +1 -0
  30. package/dist/domain.objects/DeclaredGithubRepo.d.ts +1 -0
  31. package/dist/domain.objects/DeclaredGithubRepo.js +1 -0
  32. package/dist/domain.objects/DeclaredGithubRepo.js.map +1 -1
  33. package/dist/domain.objects/DeclastructGithubProvider.d.ts +8 -0
  34. package/dist/domain.operations/app/castToDeclaredGithubApp.js +2 -1
  35. package/dist/domain.operations/app/castToDeclaredGithubApp.js.map +1 -1
  36. package/dist/domain.operations/org/castToDeclaredGithubOrg.d.ts +12 -0
  37. package/dist/domain.operations/org/castToDeclaredGithubOrg.js +29 -0
  38. package/dist/domain.operations/org/castToDeclaredGithubOrg.js.map +1 -0
  39. package/dist/domain.operations/org/getOneOrg.d.ts +14 -0
  40. package/dist/domain.operations/org/getOneOrg.js +31 -0
  41. package/dist/domain.operations/org/getOneOrg.js.map +1 -0
  42. package/dist/domain.operations/org/setOrg.d.ts +17 -0
  43. package/dist/domain.operations/org/setOrg.js +50 -0
  44. package/dist/domain.operations/org/setOrg.js.map +1 -0
  45. package/dist/domain.operations/orgMemberPrivileges/castToDeclaredGithubOrgMemberPrivileges.d.ts +15 -0
  46. package/dist/domain.operations/orgMemberPrivileges/castToDeclaredGithubOrgMemberPrivileges.js +47 -0
  47. package/dist/domain.operations/orgMemberPrivileges/castToDeclaredGithubOrgMemberPrivileges.js.map +1 -0
  48. package/dist/domain.operations/orgMemberPrivileges/getOneOrgMemberPrivileges.d.ts +14 -0
  49. package/dist/domain.operations/orgMemberPrivileges/getOneOrgMemberPrivileges.js +36 -0
  50. package/dist/domain.operations/orgMemberPrivileges/getOneOrgMemberPrivileges.js.map +1 -0
  51. package/dist/domain.operations/orgMemberPrivileges/setOrgMemberPrivileges.d.ts +16 -0
  52. package/dist/domain.operations/orgMemberPrivileges/setOrgMemberPrivileges.js +64 -0
  53. package/dist/domain.operations/orgMemberPrivileges/setOrgMemberPrivileges.js.map +1 -0
  54. package/dist/domain.operations/orgSecret/castToDeclaredGithubOrgSecret.d.ts +17 -0
  55. package/dist/domain.operations/orgSecret/castToDeclaredGithubOrgSecret.js +28 -0
  56. package/dist/domain.operations/orgSecret/castToDeclaredGithubOrgSecret.js.map +1 -0
  57. package/dist/domain.operations/orgSecret/delOrgSecret.d.ts +11 -0
  58. package/dist/domain.operations/orgSecret/delOrgSecret.js +27 -0
  59. package/dist/domain.operations/orgSecret/delOrgSecret.js.map +1 -0
  60. package/dist/domain.operations/orgSecret/getAllOrgSecrets.d.ts +14 -0
  61. package/dist/domain.operations/orgSecret/getAllOrgSecrets.js +27 -0
  62. package/dist/domain.operations/orgSecret/getAllOrgSecrets.js.map +1 -0
  63. package/dist/domain.operations/orgSecret/getOneOrgSecret.d.ts +15 -0
  64. package/dist/domain.operations/orgSecret/getOneOrgSecret.js +35 -0
  65. package/dist/domain.operations/orgSecret/getOneOrgSecret.js.map +1 -0
  66. package/dist/domain.operations/orgSecret/setOrgSecret.d.ts +17 -0
  67. package/dist/domain.operations/orgSecret/setOrgSecret.js +123 -0
  68. package/dist/domain.operations/orgSecret/setOrgSecret.js.map +1 -0
  69. package/dist/domain.operations/orgVariable/castToDeclaredGithubOrgVariable.d.ts +16 -0
  70. package/dist/domain.operations/orgVariable/castToDeclaredGithubOrgVariable.js +26 -0
  71. package/dist/domain.operations/orgVariable/castToDeclaredGithubOrgVariable.js.map +1 -0
  72. package/dist/domain.operations/orgVariable/delOrgVariable.d.ts +11 -0
  73. package/dist/domain.operations/orgVariable/delOrgVariable.js +27 -0
  74. package/dist/domain.operations/orgVariable/delOrgVariable.js.map +1 -0
  75. package/dist/domain.operations/orgVariable/getAllOrgVariables.d.ts +13 -0
  76. package/dist/domain.operations/orgVariable/getAllOrgVariables.js +28 -0
  77. package/dist/domain.operations/orgVariable/getAllOrgVariables.js.map +1 -0
  78. package/dist/domain.operations/orgVariable/getOneOrgVariable.d.ts +14 -0
  79. package/dist/domain.operations/orgVariable/getOneOrgVariable.js +34 -0
  80. package/dist/domain.operations/orgVariable/getOneOrgVariable.js.map +1 -0
  81. package/dist/domain.operations/orgVariable/setOrgVariable.d.ts +12 -0
  82. package/dist/domain.operations/orgVariable/setOrgVariable.js +69 -0
  83. package/dist/domain.operations/orgVariable/setOrgVariable.js.map +1 -0
  84. package/dist/domain.operations/provider/getDeclastructGithubProvider.js +9 -0
  85. package/dist/domain.operations/provider/getDeclastructGithubProvider.js.map +1 -1
  86. package/package.json +3 -1
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.delOrgSecret = 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
+ /**
8
+ * .what = deletes a GitHub Organization secret
9
+ * .why = enables declarative management of org-level secrets
10
+ */
11
+ exports.delOrgSecret = (0, as_procedure_1.asProcedure)(async (input, context) => {
12
+ const github = (0, getGithubClient_1.getGithubClient)({}, context);
13
+ // extract unique key fields
14
+ const secret = input.secret;
15
+ try {
16
+ await github.actions.deleteOrgSecret({
17
+ org: secret.org.login,
18
+ secret_name: secret.name,
19
+ });
20
+ }
21
+ catch (error) {
22
+ if (!(error instanceof Error))
23
+ throw error;
24
+ throw new helpful_errors_1.HelpfulError('github.delOrgSecret error', { cause: error });
25
+ }
26
+ });
27
+ //# sourceMappingURL=delOrgSecret.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delOrgSecret.js","sourceRoot":"","sources":["../../../src/domain.operations/orgSecret/delOrgSecret.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAE3C,mDAA8C;AAG9C,uEAAoE;AAIpE;;;GAGG;AACU,QAAA,YAAY,GAAG,IAAA,0BAAW,EACrC,KAAK,EACH,KAAsD,EACtD,OAA6C,EAC9B,EAAE;IACjB,MAAM,MAAM,GAAG,IAAA,iCAAe,EAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAE5C,4BAA4B;IAC5B,MAAM,MAAM,GAAG,KAAK,CAAC,MAAkD,CAAC;IAExE,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC;YACnC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK;YACrB,WAAW,EAAE,MAAM,CAAC,IAAI;SACzB,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;QAC3C,MAAM,IAAI,6BAAY,CAAC,2BAA2B,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACxE,CAAC;AACH,CAAC,CACF,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { RefByUnique } from 'domain-objects';
2
+ import type { HasMetadata } from 'type-fns';
3
+ import type { VisualogicContext } from 'visualogic';
4
+ import type { ContextGithubApi } from '../../domain.objects/ContextGithubApi';
5
+ import type { DeclaredGithubOrg } from '../../domain.objects/DeclaredGithubOrg';
6
+ import type { DeclaredGithubOrgSecret } from '../../domain.objects/DeclaredGithubOrgSecret';
7
+ /**
8
+ * .what = gets all GitHub Organization secrets (metadata only)
9
+ * .why = retrieves current state for declarative management
10
+ * .note = values are NEVER returned - secrets are write-only
11
+ */
12
+ export declare const getAllOrgSecrets: (input: {
13
+ org: RefByUnique<typeof DeclaredGithubOrg>;
14
+ }, context: ContextGithubApi & VisualogicContext) => Promise<HasMetadata<DeclaredGithubOrgSecret>[]>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAllOrgSecrets = 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 castToDeclaredGithubOrgSecret_1 = require("./castToDeclaredGithubOrgSecret");
8
+ /**
9
+ * .what = gets all GitHub Organization secrets (metadata only)
10
+ * .why = retrieves current state for declarative management
11
+ * .note = values are NEVER returned - secrets are write-only
12
+ */
13
+ exports.getAllOrgSecrets = (0, as_procedure_1.asProcedure)(async (input, context) => {
14
+ const github = (0, getGithubClient_1.getGithubClient)({}, context);
15
+ try {
16
+ const response = await github.actions.listOrgSecrets({
17
+ org: input.org.login,
18
+ });
19
+ return response.data.secrets.map((s) => (0, castToDeclaredGithubOrgSecret_1.castToDeclaredGithubOrgSecret)({ data: s, org: input.org }));
20
+ }
21
+ catch (error) {
22
+ if (!(error instanceof Error))
23
+ throw error;
24
+ throw new helpful_errors_1.HelpfulError('github.getAllOrgSecrets error', { cause: error });
25
+ }
26
+ });
27
+ //# sourceMappingURL=getAllOrgSecrets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAllOrgSecrets.js","sourceRoot":"","sources":["../../../src/domain.operations/orgSecret/getAllOrgSecrets.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAE3C,mDAA8C;AAI9C,uEAAoE;AAIpE,mFAAgF;AAEhF;;;;GAIG;AACU,QAAA,gBAAgB,GAAG,IAAA,0BAAW,EACzC,KAAK,EACH,KAAqD,EACrD,OAA6C,EACI,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,iCAAe,EAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAE5C,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC;YACnD,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK;SACrB,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACrC,IAAA,6DAA6B,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAC3D,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;QAC3C,MAAM,IAAI,6BAAY,CAAC,+BAA+B,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC,CACF,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { RefByUnique } from 'domain-objects';
2
+ import type { HasMetadata, PickOne } from 'type-fns';
3
+ import type { VisualogicContext } from 'visualogic';
4
+ import type { ContextGithubApi } from '../../domain.objects/ContextGithubApi';
5
+ import type { DeclaredGithubOrgSecret } from '../../domain.objects/DeclaredGithubOrgSecret';
6
+ /**
7
+ * .what = gets a GitHub Organization secret (metadata only)
8
+ * .why = retrieves current state for declarative management
9
+ * .note = value is NEVER returned - secrets are write-only
10
+ */
11
+ export declare const getOneOrgSecret: (input: {
12
+ by: PickOne<{
13
+ unique: RefByUnique<typeof DeclaredGithubOrgSecret>;
14
+ }>;
15
+ }, context: ContextGithubApi & VisualogicContext) => Promise<HasMetadata<DeclaredGithubOrgSecret> | null>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOneOrgSecret = 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 castToDeclaredGithubOrgSecret_1 = require("./castToDeclaredGithubOrgSecret");
8
+ /**
9
+ * .what = gets a GitHub Organization secret (metadata only)
10
+ * .why = retrieves current state for declarative management
11
+ * .note = value is NEVER returned - secrets are write-only
12
+ */
13
+ exports.getOneOrgSecret = (0, as_procedure_1.asProcedure)(async (input, context) => {
14
+ const github = (0, getGithubClient_1.getGithubClient)({}, context);
15
+ const { org, name } = (() => {
16
+ if (input.by.unique)
17
+ return { org: input.by.unique.org, name: input.by.unique.name };
18
+ helpful_errors_1.UnexpectedCodePathError.throw('not referenced by unique', { input });
19
+ })();
20
+ try {
21
+ const response = await github.actions.getOrgSecret({
22
+ org: org.login,
23
+ secret_name: name,
24
+ });
25
+ return (0, castToDeclaredGithubOrgSecret_1.castToDeclaredGithubOrgSecret)({ data: response.data, org });
26
+ }
27
+ catch (error) {
28
+ if (!(error instanceof Error))
29
+ throw error;
30
+ if (error.message.includes('Not Found'))
31
+ return null;
32
+ throw new helpful_errors_1.HelpfulError('github.getOrgSecret error', { cause: error });
33
+ }
34
+ });
35
+ //# sourceMappingURL=getOneOrgSecret.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getOneOrgSecret.js","sourceRoot":"","sources":["../../../src/domain.operations/orgSecret/getOneOrgSecret.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAE3C,mDAAuE;AAIvE,uEAAoE;AAGpE,mFAAgF;AAEhF;;;;GAIG;AACU,QAAA,eAAe,GAAG,IAAA,0BAAW,EACxC,KAAK,EACH,KAIC,EACD,OAA6C,EACS,EAAE;IACxD,MAAM,MAAM,GAAG,IAAA,iCAAe,EAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAE5C,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,GAAG,EAAE;QAC1B,IAAI,KAAK,CAAC,EAAE,CAAC,MAAM;YACjB,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAClE,wCAAuB,CAAC,KAAK,CAAC,0BAA0B,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACvE,CAAC,CAAC,EAAE,CAAC;IAEL,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC;YACjD,GAAG,EAAE,GAAG,CAAC,KAAK;YACd,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;QACH,OAAO,IAAA,6DAA6B,EAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;IACrE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;QAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;YAAE,OAAO,IAAI,CAAC;QACrD,MAAM,IAAI,6BAAY,CAAC,2BAA2B,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACxE,CAAC;AACH,CAAC,CACF,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { HasMetadata, PickOne } from 'type-fns';
2
+ import type { VisualogicContext } from 'visualogic';
3
+ import type { ContextGithubApi } from '../../domain.objects/ContextGithubApi';
4
+ import type { DeclaredGithubOrgSecret } from '../../domain.objects/DeclaredGithubOrgSecret';
5
+ /**
6
+ * .what = sets a GitHub Organization secret
7
+ * .why = enables declarative management of org-level secrets
8
+ *
9
+ * WRITE-ONLY PATTERN:
10
+ * - If value is undefined and secret exists: keeps existing value (no-op)
11
+ * - If value is undefined and secret doesn't exist: throws error (must provide value)
12
+ * - If value is provided: encrypts and creates/updates secret
13
+ */
14
+ export declare const setOrgSecret: (input: PickOne<{
15
+ finsert: DeclaredGithubOrgSecret;
16
+ upsert: DeclaredGithubOrgSecret;
17
+ }>, context: ContextGithubApi & VisualogicContext) => Promise<HasMetadata<DeclaredGithubOrgSecret>>;
@@ -0,0 +1,123 @@
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
+ exports.setOrgSecret = void 0;
27
+ const as_procedure_1 = require("as-procedure");
28
+ const helpful_errors_1 = require("helpful-errors");
29
+ const getGithubClient_1 = require("../../access/sdks/getGithubClient");
30
+ const getRepo_1 = require("../repo/getRepo");
31
+ const getOneOrgSecret_1 = require("./getOneOrgSecret");
32
+ /**
33
+ * .what = encrypts a secret value using the org's public key
34
+ * .why = GitHub requires secrets to be encrypted before sending
35
+ * .note = uses dynamic import to avoid module init issues in test environments
36
+ */
37
+ const encryptSecret = async (input) => {
38
+ // dynamic import to avoid libsodium init issues at module load time
39
+ const sodium = await Promise.resolve().then(() => __importStar(require('libsodium-wrappers'))).then((m) => m.default);
40
+ await sodium.ready;
41
+ const binKey = sodium.from_base64(input.publicKey, sodium.base64_variants.ORIGINAL);
42
+ const binSec = sodium.from_string(input.value);
43
+ const encBytes = sodium.crypto_box_seal(binSec, binKey);
44
+ return sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL);
45
+ };
46
+ /**
47
+ * .what = sets a GitHub Organization secret
48
+ * .why = enables declarative management of org-level secrets
49
+ *
50
+ * WRITE-ONLY PATTERN:
51
+ * - If value is undefined and secret exists: keeps existing value (no-op)
52
+ * - If value is undefined and secret doesn't exist: throws error (must provide value)
53
+ * - If value is provided: encrypts and creates/updates secret
54
+ */
55
+ exports.setOrgSecret = (0, as_procedure_1.asProcedure)(async (input, context) => {
56
+ const desired = input.finsert ?? input.upsert;
57
+ const github = (0, getGithubClient_1.getGithubClient)({}, context);
58
+ // Check if secret exists (metadata only)
59
+ const before = await (0, getOneOrgSecret_1.getOneOrgSecret)({ by: { unique: { org: desired.org, name: desired.name } } }, context);
60
+ // If finsert and found, return as-is (no changes needed)
61
+ if (before && input.finsert)
62
+ return before;
63
+ // If no value provided and secret doesn't exist, error
64
+ if (!desired.value && !before) {
65
+ throw new helpful_errors_1.HelpfulError('Cannot create secret without a value. ' +
66
+ 'Provide the secret value via process.env or directly.', { desiredSecret: desired });
67
+ }
68
+ // If no value provided and secret exists, check if we can skip the update
69
+ // NOTE: GitHub API requires encrypted_value for PUT, so we cannot update
70
+ // visibility without re-providing the value.
71
+ if (!desired.value && before) {
72
+ const visibilityChanged = desired.visibility !== before.visibility;
73
+ const selectedReposChanged = desired.visibility === 'selected' &&
74
+ JSON.stringify(desired.selectedRepositoryNames?.sort()) !==
75
+ JSON.stringify(before.selectedRepositoryNames?.sort());
76
+ if (visibilityChanged || selectedReposChanged) {
77
+ throw new helpful_errors_1.HelpfulError('Cannot update secret visibility without re-providing the secret value. ' +
78
+ 'GitHub API requires the encrypted value for any secret update.', {
79
+ desiredSecret: desired,
80
+ currentVisibility: before.visibility,
81
+ desiredVisibility: desired.visibility,
82
+ });
83
+ }
84
+ // No changes needed, return existing metadata
85
+ return before;
86
+ }
87
+ // Get org's public key for encryption
88
+ const keyResponse = await github.actions.getOrgPublicKey({
89
+ org: desired.org.login,
90
+ });
91
+ // Encrypt the secret value
92
+ const encryptedValue = await encryptSecret({
93
+ value: desired.value,
94
+ publicKey: keyResponse.data.key,
95
+ });
96
+ // Resolve repo IDs if visibility is 'selected'
97
+ const selectedRepositoryIds = desired.visibility === 'selected' && desired.selectedRepositoryNames
98
+ ? await Promise.all(desired.selectedRepositoryNames.map(async (name) => {
99
+ const repo = await (0, getRepo_1.getRepo)({ by: { unique: { owner: desired.org.login, name } } }, context);
100
+ if (!repo)
101
+ throw new helpful_errors_1.HelpfulError(`Repository not found: ${desired.org.login}/${name}`);
102
+ return repo.id;
103
+ }))
104
+ : undefined;
105
+ // Create or update secret
106
+ try {
107
+ await github.actions.createOrUpdateOrgSecret({
108
+ org: desired.org.login,
109
+ secret_name: desired.name,
110
+ encrypted_value: encryptedValue,
111
+ key_id: keyResponse.data.key_id,
112
+ visibility: desired.visibility,
113
+ selected_repository_ids: selectedRepositoryIds,
114
+ });
115
+ return (await (0, getOneOrgSecret_1.getOneOrgSecret)({ by: { unique: { org: desired.org, name: desired.name } } }, context));
116
+ }
117
+ catch (error) {
118
+ if (!(error instanceof Error))
119
+ throw error;
120
+ throw new helpful_errors_1.HelpfulError('github.setOrgSecret error', { cause: error });
121
+ }
122
+ });
123
+ //# sourceMappingURL=setOrgSecret.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setOrgSecret.js","sourceRoot":"","sources":["../../../src/domain.operations/orgSecret/setOrgSecret.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA2C;AAC3C,mDAA8C;AAI9C,uEAAoE;AAGpE,6CAA0C;AAC1C,uDAAoD;AAEpD;;;;GAIG;AACH,MAAM,aAAa,GAAG,KAAK,EAAE,KAG5B,EAAmB,EAAE;IACpB,oEAAoE;IACpE,MAAM,MAAM,GAAG,MAAM,kDAAO,oBAAoB,IAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IACzE,MAAM,MAAM,CAAC,KAAK,CAAC;IACnB,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAC/B,KAAK,CAAC,SAAS,EACf,MAAM,CAAC,eAAe,CAAC,QAAQ,CAChC,CAAC;IACF,MAAM,MAAM,GAA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,CAAC,KAAK,IAAI,IAAI,EAAE,CACrD,CAAC;YACJ,OAAO,IAAI,CAAC,EAAG,CAAC;QAClB,CAAC,CAAC,CACH;QACH,CAAC,CAAC,SAAS,CAAC;IAEhB,0BAA0B;IAC1B,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,OAAO,CAAC,uBAAuB,CAAC;YAC3C,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK;YACtB,WAAW,EAAE,OAAO,CAAC,IAAI;YACzB,eAAe,EAAE,cAAc;YAC/B,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,MAAM;YAC/B,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,uBAAuB,EAAE,qBAAqB;SAC/C,CAAC,CAAC;QAEH,OAAO,CAAC,MAAM,IAAA,iCAAe,EAC3B,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,EAC5D,OAAO,CACR,CAAE,CAAC;IACN,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;QAC3C,MAAM,IAAI,6BAAY,CAAC,2BAA2B,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACxE,CAAC;AACH,CAAC,CACF,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { Endpoints } from '@octokit/types';
2
+ import type { RefByUnique } from 'domain-objects';
3
+ import type { HasMetadata } from 'type-fns';
4
+ import type { DeclaredGithubOrg } from '../../domain.objects/DeclaredGithubOrg';
5
+ import { DeclaredGithubOrgVariable } from '../../domain.objects/DeclaredGithubOrgVariable';
6
+ type GithubOrgVariableResponse = Endpoints['GET /orgs/{org}/actions/variables/{name}']['response']['data'];
7
+ type GithubOrgVariableListItem = Endpoints['GET /orgs/{org}/actions/variables']['response']['data']['variables'][number];
8
+ /**
9
+ * .what = casts GitHub API variable response to DeclaredGithubOrgVariable
10
+ * .why = transforms external API shape to our domain model
11
+ */
12
+ export declare const castToDeclaredGithubOrgVariable: (input: {
13
+ data: GithubOrgVariableResponse | GithubOrgVariableListItem;
14
+ org: RefByUnique<typeof DeclaredGithubOrg>;
15
+ }) => HasMetadata<DeclaredGithubOrgVariable>;
16
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.castToDeclaredGithubOrgVariable = void 0;
4
+ const uni_time_1 = require("@ehmpathy/uni-time");
5
+ const DeclaredGithubOrgVariable_1 = require("../../domain.objects/DeclaredGithubOrgVariable");
6
+ /**
7
+ * .what = casts GitHub API variable response to DeclaredGithubOrgVariable
8
+ * .why = transforms external API shape to our domain model
9
+ */
10
+ const castToDeclaredGithubOrgVariable = (input) => {
11
+ return DeclaredGithubOrgVariable_1.DeclaredGithubOrgVariable.as({
12
+ org: input.org,
13
+ name: input.data.name,
14
+ value: input.data.value,
15
+ visibility: input.data.visibility,
16
+ // selectedRepositoryNames not set - not returned in API response
17
+ createdAt: input.data.created_at
18
+ ? (0, uni_time_1.asUniDateTime)(input.data.created_at)
19
+ : undefined,
20
+ updatedAt: input.data.updated_at
21
+ ? (0, uni_time_1.asUniDateTime)(input.data.updated_at)
22
+ : undefined,
23
+ });
24
+ };
25
+ exports.castToDeclaredGithubOrgVariable = castToDeclaredGithubOrgVariable;
26
+ //# sourceMappingURL=castToDeclaredGithubOrgVariable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"castToDeclaredGithubOrgVariable.js","sourceRoot":"","sources":["../../../src/domain.operations/orgVariable/castToDeclaredGithubOrgVariable.ts"],"names":[],"mappings":";;;AAAA,iDAAmD;AAMnD,8FAA2F;AAQ3F;;;GAGG;AACI,MAAM,+BAA+B,GAAG,CAAC,KAG/C,EAA0C,EAAE;IAC3C,OAAO,qDAAyB,CAAC,EAAE,CAAC;QAClC,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI;QACrB,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK;QACvB,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,UAA4C;QACnE,iEAAiE;QACjE,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,UAAU;YAC9B,CAAC,CAAC,IAAA,wBAAa,EAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC;YACtC,CAAC,CAAC,SAAS;QACb,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,UAAU;YAC9B,CAAC,CAAC,IAAA,wBAAa,EAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC;YACtC,CAAC,CAAC,SAAS;KACd,CAA2C,CAAC;AAC/C,CAAC,CAAC;AAjBW,QAAA,+BAA+B,mCAiB1C"}
@@ -0,0 +1,11 @@
1
+ import type { Ref } from 'domain-objects';
2
+ import type { VisualogicContext } from 'visualogic';
3
+ import type { ContextGithubApi } from '../../domain.objects/ContextGithubApi';
4
+ import type { DeclaredGithubOrgVariable } from '../../domain.objects/DeclaredGithubOrgVariable';
5
+ /**
6
+ * .what = deletes a GitHub Organization variable
7
+ * .why = enables declarative management of org-level variables
8
+ */
9
+ export declare const delOrgVariable: (input: {
10
+ variable: Ref<typeof DeclaredGithubOrgVariable>;
11
+ }, context: ContextGithubApi & VisualogicContext) => Promise<void>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.delOrgVariable = 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
+ /**
8
+ * .what = deletes a GitHub Organization variable
9
+ * .why = enables declarative management of org-level variables
10
+ */
11
+ exports.delOrgVariable = (0, as_procedure_1.asProcedure)(async (input, context) => {
12
+ const github = (0, getGithubClient_1.getGithubClient)({}, context);
13
+ // extract unique key fields
14
+ const variable = input.variable;
15
+ try {
16
+ await github.actions.deleteOrgVariable({
17
+ org: variable.org.login,
18
+ name: variable.name,
19
+ });
20
+ }
21
+ catch (error) {
22
+ if (!(error instanceof Error))
23
+ throw error;
24
+ throw new helpful_errors_1.HelpfulError('github.delOrgVariable error', { cause: error });
25
+ }
26
+ });
27
+ //# sourceMappingURL=delOrgVariable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delOrgVariable.js","sourceRoot":"","sources":["../../../src/domain.operations/orgVariable/delOrgVariable.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAE3C,mDAA8C;AAG9C,uEAAoE;AAIpE;;;GAGG;AACU,QAAA,cAAc,GAAG,IAAA,0BAAW,EACvC,KAAK,EACH,KAA0D,EAC1D,OAA6C,EAC9B,EAAE;IACjB,MAAM,MAAM,GAAG,IAAA,iCAAe,EAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAE5C,4BAA4B;IAC5B,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAoD,CAAC;IAE5E,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC;YACrC,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,KAAK;YACvB,IAAI,EAAE,QAAQ,CAAC,IAAI;SACpB,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;QAC3C,MAAM,IAAI,6BAAY,CAAC,6BAA6B,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC,CACF,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { RefByUnique } from 'domain-objects';
2
+ import type { HasMetadata } from 'type-fns';
3
+ import type { VisualogicContext } from 'visualogic';
4
+ import type { ContextGithubApi } from '../../domain.objects/ContextGithubApi';
5
+ import type { DeclaredGithubOrg } from '../../domain.objects/DeclaredGithubOrg';
6
+ import type { DeclaredGithubOrgVariable } from '../../domain.objects/DeclaredGithubOrgVariable';
7
+ /**
8
+ * .what = gets all GitHub Organization variables
9
+ * .why = retrieves current state for declarative management
10
+ */
11
+ export declare const getAllOrgVariables: (input: {
12
+ org: RefByUnique<typeof DeclaredGithubOrg>;
13
+ }, context: ContextGithubApi & VisualogicContext) => Promise<HasMetadata<DeclaredGithubOrgVariable>[]>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAllOrgVariables = 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 castToDeclaredGithubOrgVariable_1 = require("./castToDeclaredGithubOrgVariable");
8
+ /**
9
+ * .what = gets all GitHub Organization variables
10
+ * .why = retrieves current state for declarative management
11
+ */
12
+ exports.getAllOrgVariables = (0, as_procedure_1.asProcedure)(async (input, context) => {
13
+ const github = (0, getGithubClient_1.getGithubClient)({}, context);
14
+ try {
15
+ const response = await github.actions.listOrgVariables({
16
+ org: input.org.login,
17
+ });
18
+ return response.data.variables.map((v) => (0, castToDeclaredGithubOrgVariable_1.castToDeclaredGithubOrgVariable)({ data: v, org: input.org }));
19
+ }
20
+ catch (error) {
21
+ if (!(error instanceof Error))
22
+ throw error;
23
+ throw new helpful_errors_1.HelpfulError('github.getAllOrgVariables error', {
24
+ cause: error,
25
+ });
26
+ }
27
+ });
28
+ //# sourceMappingURL=getAllOrgVariables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAllOrgVariables.js","sourceRoot":"","sources":["../../../src/domain.operations/orgVariable/getAllOrgVariables.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAE3C,mDAA8C;AAI9C,uEAAoE;AAIpE,uFAAoF;AAEpF;;;GAGG;AACU,QAAA,kBAAkB,GAAG,IAAA,0BAAW,EAC3C,KAAK,EACH,KAAqD,EACrD,OAA6C,EACM,EAAE;IACrD,MAAM,MAAM,GAAG,IAAA,iCAAe,EAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAE5C,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC;YACrD,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK;SACrB,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACvC,IAAA,iEAA+B,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAC7D,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;QAC3C,MAAM,IAAI,6BAAY,CAAC,iCAAiC,EAAE;YACxD,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CACF,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { RefByUnique } from 'domain-objects';
2
+ import type { HasMetadata, PickOne } from 'type-fns';
3
+ import type { VisualogicContext } from 'visualogic';
4
+ import type { ContextGithubApi } from '../../domain.objects/ContextGithubApi';
5
+ import type { DeclaredGithubOrgVariable } from '../../domain.objects/DeclaredGithubOrgVariable';
6
+ /**
7
+ * .what = gets a GitHub Organization variable
8
+ * .why = retrieves current state for declarative management
9
+ */
10
+ export declare const getOneOrgVariable: (input: {
11
+ by: PickOne<{
12
+ unique: RefByUnique<typeof DeclaredGithubOrgVariable>;
13
+ }>;
14
+ }, context: ContextGithubApi & VisualogicContext) => Promise<HasMetadata<DeclaredGithubOrgVariable> | null>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOneOrgVariable = 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 castToDeclaredGithubOrgVariable_1 = require("./castToDeclaredGithubOrgVariable");
8
+ /**
9
+ * .what = gets a GitHub Organization variable
10
+ * .why = retrieves current state for declarative management
11
+ */
12
+ exports.getOneOrgVariable = (0, as_procedure_1.asProcedure)(async (input, context) => {
13
+ const github = (0, getGithubClient_1.getGithubClient)({}, context);
14
+ const { org, name } = (() => {
15
+ if (input.by.unique)
16
+ return { org: input.by.unique.org, name: input.by.unique.name };
17
+ helpful_errors_1.UnexpectedCodePathError.throw('not referenced by unique', { input });
18
+ })();
19
+ try {
20
+ const response = await github.actions.getOrgVariable({
21
+ org: org.login,
22
+ name,
23
+ });
24
+ return (0, castToDeclaredGithubOrgVariable_1.castToDeclaredGithubOrgVariable)({ data: response.data, org });
25
+ }
26
+ catch (error) {
27
+ if (!(error instanceof Error))
28
+ throw error;
29
+ if (error.message.includes('Not Found'))
30
+ return null;
31
+ throw new helpful_errors_1.HelpfulError('github.getOrgVariable error', { cause: error });
32
+ }
33
+ });
34
+ //# sourceMappingURL=getOneOrgVariable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getOneOrgVariable.js","sourceRoot":"","sources":["../../../src/domain.operations/orgVariable/getOneOrgVariable.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAE3C,mDAAuE;AAIvE,uEAAoE;AAGpE,uFAAoF;AAEpF;;;GAGG;AACU,QAAA,iBAAiB,GAAG,IAAA,0BAAW,EAC1C,KAAK,EACH,KAIC,EACD,OAA6C,EACW,EAAE;IAC1D,MAAM,MAAM,GAAG,IAAA,iCAAe,EAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAE5C,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,GAAG,EAAE;QAC1B,IAAI,KAAK,CAAC,EAAE,CAAC,MAAM;YACjB,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAClE,wCAAuB,CAAC,KAAK,CAAC,0BAA0B,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACvE,CAAC,CAAC,EAAE,CAAC;IAEL,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC;YACnD,GAAG,EAAE,GAAG,CAAC,KAAK;YACd,IAAI;SACL,CAAC,CAAC;QACH,OAAO,IAAA,iEAA+B,EAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;IACvE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;QAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;YAAE,OAAO,IAAI,CAAC;QACrD,MAAM,IAAI,6BAAY,CAAC,6BAA6B,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC,CACF,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { HasMetadata, PickOne } from 'type-fns';
2
+ import type { VisualogicContext } from 'visualogic';
3
+ import type { ContextGithubApi } from '../../domain.objects/ContextGithubApi';
4
+ import type { DeclaredGithubOrgVariable } from '../../domain.objects/DeclaredGithubOrgVariable';
5
+ /**
6
+ * .what = sets a GitHub Organization variable
7
+ * .why = enables declarative management of org-level variables
8
+ */
9
+ export declare const setOrgVariable: (input: PickOne<{
10
+ finsert: DeclaredGithubOrgVariable;
11
+ upsert: DeclaredGithubOrgVariable;
12
+ }>, context: ContextGithubApi & VisualogicContext) => Promise<HasMetadata<DeclaredGithubOrgVariable>>;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setOrgVariable = 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 getRepo_1 = require("../repo/getRepo");
8
+ const getOneOrgVariable_1 = require("./getOneOrgVariable");
9
+ /**
10
+ * .what = sets a GitHub Organization variable
11
+ * .why = enables declarative management of org-level variables
12
+ */
13
+ exports.setOrgVariable = (0, as_procedure_1.asProcedure)(async (input, context) => {
14
+ const desired = input.finsert ?? input.upsert;
15
+ const github = (0, getGithubClient_1.getGithubClient)({}, context);
16
+ // Check if variable exists
17
+ const before = await (0, getOneOrgVariable_1.getOneOrgVariable)({ by: { unique: { org: desired.org, name: desired.name } } }, context);
18
+ // Resolve repo IDs if visibility is 'selected'
19
+ const selectedRepositoryIds = desired.visibility === 'selected' && desired.selectedRepositoryNames
20
+ ? await Promise.all(desired.selectedRepositoryNames.map(async (name) => {
21
+ const repo = await (0, getRepo_1.getRepo)({ by: { unique: { owner: desired.org.login, name } } }, context);
22
+ if (!repo)
23
+ throw new helpful_errors_1.HelpfulError(`Repository not found: ${desired.org.login}/${name}`);
24
+ return repo.id;
25
+ }))
26
+ : undefined;
27
+ // If finsert and found, return as-is
28
+ if (before && input.finsert)
29
+ return before;
30
+ // If exists, update
31
+ if (before && input.upsert) {
32
+ try {
33
+ await github.actions.updateOrgVariable({
34
+ org: desired.org.login,
35
+ name: desired.name,
36
+ value: desired.value,
37
+ visibility: desired.visibility,
38
+ selected_repository_ids: selectedRepositoryIds,
39
+ });
40
+ return (await (0, getOneOrgVariable_1.getOneOrgVariable)({ by: { unique: { org: desired.org, name: desired.name } } }, context));
41
+ }
42
+ catch (error) {
43
+ if (!(error instanceof Error))
44
+ throw error;
45
+ throw new helpful_errors_1.HelpfulError('github.setOrgVariable.update error', {
46
+ cause: error,
47
+ });
48
+ }
49
+ }
50
+ // Create new variable
51
+ try {
52
+ await github.actions.createOrgVariable({
53
+ org: desired.org.login,
54
+ name: desired.name,
55
+ value: desired.value,
56
+ visibility: desired.visibility,
57
+ selected_repository_ids: selectedRepositoryIds,
58
+ });
59
+ return (await (0, getOneOrgVariable_1.getOneOrgVariable)({ by: { unique: { org: desired.org, name: desired.name } } }, context));
60
+ }
61
+ catch (error) {
62
+ if (!(error instanceof Error))
63
+ throw error;
64
+ throw new helpful_errors_1.HelpfulError('github.setOrgVariable.create error', {
65
+ cause: error,
66
+ });
67
+ }
68
+ });
69
+ //# sourceMappingURL=setOrgVariable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setOrgVariable.js","sourceRoot":"","sources":["../../../src/domain.operations/orgVariable/setOrgVariable.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAC3C,mDAA8C;AAI9C,uEAAoE;AAGpE,6CAA0C;AAC1C,2DAAwD;AAExD;;;GAGG;AACU,QAAA,cAAc,GAAG,IAAA,0BAAW,EACvC,KAAK,EACH,KAGE,EACF,OAA6C,EACI,EAAE;IACnD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC;IAC9C,MAAM,MAAM,GAAG,IAAA,iCAAe,EAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAE5C,2BAA2B;IAC3B,MAAM,MAAM,GAAG,MAAM,IAAA,qCAAiB,EACpC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,EAC5D,OAAO,CACR,CAAC;IAEF,+CAA+C;IAC/C,MAAM,qBAAqB,GACzB,OAAO,CAAC,UAAU,KAAK,UAAU,IAAI,OAAO,CAAC,uBAAuB;QAClE,CAAC,CAAC,MAAM,OAAO,CAAC,GAAG,CACf,OAAO,CAAC,uBAAuB,CAAC,GAAG,CAAC,KAAK,EAAE,I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K;aACb,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,sBAAsB;IACtB,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC;YACrC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK;YACtB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,uBAAuB,EAAE,qBAAqB;SAC/C,CAAC,CAAC;QAEH,OAAO,CAAC,MAAM,IAAA,qCAAiB,EAC7B,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,EAC5D,OAAO,CACR,CAAE,CAAC;IACN,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;QAC3C,MAAM,IAAI,6BAAY,CAAC,oCAAoC,EAAE;YAC3D,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CACF,CAAC"}
@@ -6,6 +6,10 @@ const DeclaredGithubAppDao_1 = require("../../access/daos/DeclaredGithubAppDao")
6
6
  const DeclaredGithubAppInstallationDao_1 = require("../../access/daos/DeclaredGithubAppInstallationDao");
7
7
  const DeclaredGithubBranchDao_1 = require("../../access/daos/DeclaredGithubBranchDao");
8
8
  const DeclaredGithubBranchProtectionDao_1 = require("../../access/daos/DeclaredGithubBranchProtectionDao");
9
+ const DeclaredGithubOrgDao_1 = require("../../access/daos/DeclaredGithubOrgDao");
10
+ const DeclaredGithubOrgMemberPrivilegesDao_1 = require("../../access/daos/DeclaredGithubOrgMemberPrivilegesDao");
11
+ const DeclaredGithubOrgSecretDao_1 = require("../../access/daos/DeclaredGithubOrgSecretDao");
12
+ const DeclaredGithubOrgVariableDao_1 = require("../../access/daos/DeclaredGithubOrgVariableDao");
9
13
  const DeclaredGithubRepoConfigDao_1 = require("../../access/daos/DeclaredGithubRepoConfigDao");
10
14
  const DeclaredGithubRepoDao_1 = require("../../access/daos/DeclaredGithubRepoDao");
11
15
  /**
@@ -28,6 +32,11 @@ const getDeclastructGithubProvider = (input, context) => {
28
32
  DeclaredGithubBranchProtection: DeclaredGithubBranchProtectionDao_1.DeclaredGithubBranchProtectionDao,
29
33
  DeclaredGithubApp: DeclaredGithubAppDao_1.DeclaredGithubAppDao,
30
34
  DeclaredGithubAppInstallation: DeclaredGithubAppInstallationDao_1.DeclaredGithubAppInstallationDao,
35
+ // Organization resources
36
+ DeclaredGithubOrg: DeclaredGithubOrgDao_1.DeclaredGithubOrgDao,
37
+ DeclaredGithubOrgMemberPrivileges: DeclaredGithubOrgMemberPrivilegesDao_1.DeclaredGithubOrgMemberPrivilegesDao,
38
+ DeclaredGithubOrgVariable: DeclaredGithubOrgVariableDao_1.DeclaredGithubOrgVariableDao,
39
+ DeclaredGithubOrgSecret: DeclaredGithubOrgSecretDao_1.DeclaredGithubOrgSecretDao,
31
40
  };
32
41
  // return provider with all required properties
33
42
  return new declastruct_1.DeclastructProvider({
@@ -1 +1 @@
1
- {"version":3,"file":"getDeclastructGithubProvider.js","sourceRoot":"","sources":["../../../src/domain.operations/provider/getDeclastructGithubProvider.ts"],"names":[],"mappings":";;;AAAA,6CAAkD;AAGlD,iFAA8E;AAC9E,yGAAsG;AACtG,uFAAoF;AACpF,2GAAwG;AACxG,+FAA4F;AAC5F,mFAAgF;AAIhF;;;GAGG;AACI,MAAM,4BAA4B,GAAG,CAC1C,KAIC,EACD,OAAwB,EACG,EAAE;IAC7B,+CAA+C;IAC/C,MAAM,eAAe,GAAuC;QAC1D,GAAG,OAAO;QACV,MAAM,EAAE;YACN,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,KAAK;SAC/B;KACF,CAAC;IAEF,8CAA8C;IAC9C,MAAM,IAAI,GAAG;QACX,kBAAkB,EAAE,6CAAqB;QACzC,oBAAoB,EAAE,iDAAuB;QAC7C,wBAAwB,EAAE,yDAA2B;QACrD,8BAA8B,EAAE,qEAAiC;QACjE,iBAAiB,EAAE,2CAAoB;QACvC,6BAA6B,EAAE,mEAAgC;KAChE,CAAC;IAEF,+CAA+C;IAC/C,OAAO,IAAI,iCAAmB,CAAC;QAC7B,IAAI,EAAE,QAAQ;QACd,IAAI;QACJ,OAAO,EAAE,eAAe;QACxB,KAAK,EAAE;YACL,SAAS,EAAE,KAAK,IAAI,EAAE;gBACpB,sCAAsC;YACxC,CAAC;YACD,QAAQ,EAAE,KAAK,IAAI,EAAE;gBACnB,yCAAyC;YAC3C,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAxCW,QAAA,4BAA4B,gCAwCvC"}
1
+ {"version":3,"file":"getDeclastructGithubProvider.js","sourceRoot":"","sources":["../../../src/domain.operations/provider/getDeclastructGithubProvider.ts"],"names":[],"mappings":";;;AAAA,6CAAkD;AAGlD,iFAA8E;AAC9E,yGAAsG;AACtG,uFAAoF;AACpF,2GAAwG;AACxG,iFAA8E;AAC9E,iHAA8G;AAC9G,6FAA0F;AAC1F,iGAA8F;AAC9F,+FAA4F;AAC5F,mFAAgF;AAIhF;;;GAGG;AACI,MAAM,4BAA4B,GAAG,CAC1C,KAIC,EACD,OAAwB,EACG,EAAE;IAC7B,+CAA+C;IAC/C,MAAM,eAAe,GAAuC;QAC1D,GAAG,OAAO;QACV,MAAM,EAAE;YACN,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,KAAK;SAC/B;KACF,CAAC;IAEF,8CAA8C;IAC9C,MAAM,IAAI,GAAG;QACX,kBAAkB,EAAE,6CAAqB;QACzC,oBAAoB,EAAE,iDAAuB;QAC7C,wBAAwB,EAAE,yDAA2B;QACrD,8BAA8B,EAAE,qEAAiC;QACjE,iBAAiB,EAAE,2CAAoB;QACvC,6BAA6B,EAAE,mEAAgC;QAC/D,yBAAyB;QACzB,iBAAiB,EAAE,2CAAoB;QACvC,iCAAiC,EAAE,2EAAoC;QACvE,yBAAyB,EAAE,2DAA4B;QACvD,uBAAuB,EAAE,uDAA0B;KACpD,CAAC;IAEF,+CAA+C;IAC/C,OAAO,IAAI,iCAAmB,CAAC;QAC7B,IAAI,EAAE,QAAQ;QACd,IAAI;QACJ,OAAO,EAAE,eAAe;QACxB,KAAK,EAAE;YACL,SAAS,EAAE,KAAK,IAAI,EAAE;gBACpB,sCAAsC;YACxC,CAAC;YACD,QAAQ,EAAE,KAAK,IAAI,EAAE;gBACnB,yCAAyC;YAC3C,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AA7CW,QAAA,4BAA4B,gCA6CvC"}