@knpkv/codecommit-core 0.1.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 (106) hide show
  1. package/dist/AwsClient/createPullRequest.d.ts +9 -0
  2. package/dist/AwsClient/createPullRequest.d.ts.map +1 -0
  3. package/dist/AwsClient/createPullRequest.js +25 -0
  4. package/dist/AwsClient/createPullRequest.js.map +1 -0
  5. package/dist/AwsClient/getCallerIdentity.d.ts +9 -0
  6. package/dist/AwsClient/getCallerIdentity.d.ts.map +1 -0
  7. package/dist/AwsClient/getCallerIdentity.js +17 -0
  8. package/dist/AwsClient/getCallerIdentity.js.map +1 -0
  9. package/dist/AwsClient/getCommentsForPullRequest.d.ts +10 -0
  10. package/dist/AwsClient/getCommentsForPullRequest.d.ts.map +1 -0
  11. package/dist/AwsClient/getCommentsForPullRequest.js +111 -0
  12. package/dist/AwsClient/getCommentsForPullRequest.js.map +1 -0
  13. package/dist/AwsClient/getPullRequest.d.ts +9 -0
  14. package/dist/AwsClient/getPullRequest.d.ts.map +1 -0
  15. package/dist/AwsClient/getPullRequest.js +74 -0
  16. package/dist/AwsClient/getPullRequest.js.map +1 -0
  17. package/dist/AwsClient/getPullRequests.d.ts +13 -0
  18. package/dist/AwsClient/getPullRequests.d.ts.map +1 -0
  19. package/dist/AwsClient/getPullRequests.js +123 -0
  20. package/dist/AwsClient/getPullRequests.js.map +1 -0
  21. package/dist/AwsClient/index.d.ts +30 -0
  22. package/dist/AwsClient/index.d.ts.map +1 -0
  23. package/dist/AwsClient/index.js +42 -0
  24. package/dist/AwsClient/index.js.map +1 -0
  25. package/dist/AwsClient/internal.d.ts +83 -0
  26. package/dist/AwsClient/internal.d.ts.map +1 -0
  27. package/dist/AwsClient/internal.js +52 -0
  28. package/dist/AwsClient/internal.js.map +1 -0
  29. package/dist/AwsClient/listBranches.d.ts +9 -0
  30. package/dist/AwsClient/listBranches.d.ts.map +1 -0
  31. package/dist/AwsClient/listBranches.js +23 -0
  32. package/dist/AwsClient/listBranches.js.map +1 -0
  33. package/dist/AwsClient/updatePullRequestDescription.d.ts +9 -0
  34. package/dist/AwsClient/updatePullRequestDescription.d.ts.map +1 -0
  35. package/dist/AwsClient/updatePullRequestDescription.js +20 -0
  36. package/dist/AwsClient/updatePullRequestDescription.js.map +1 -0
  37. package/dist/AwsClient/updatePullRequestTitle.d.ts +9 -0
  38. package/dist/AwsClient/updatePullRequestTitle.d.ts.map +1 -0
  39. package/dist/AwsClient/updatePullRequestTitle.js +20 -0
  40. package/dist/AwsClient/updatePullRequestTitle.js.map +1 -0
  41. package/dist/AwsClientConfig.d.ts +58 -0
  42. package/dist/AwsClientConfig.d.ts.map +1 -0
  43. package/dist/AwsClientConfig.js +28 -0
  44. package/dist/AwsClientConfig.js.map +1 -0
  45. package/dist/ConfigService/detectProfiles.d.ts +8 -0
  46. package/dist/ConfigService/detectProfiles.d.ts.map +1 -0
  47. package/dist/ConfigService/detectProfiles.js +21 -0
  48. package/dist/ConfigService/detectProfiles.js.map +1 -0
  49. package/dist/ConfigService/index.d.ts +21 -0
  50. package/dist/ConfigService/index.d.ts.map +1 -0
  51. package/dist/ConfigService/index.js +33 -0
  52. package/dist/ConfigService/index.js.map +1 -0
  53. package/dist/ConfigService/internal.d.ts +57 -0
  54. package/dist/ConfigService/internal.d.ts.map +1 -0
  55. package/dist/ConfigService/internal.js +55 -0
  56. package/dist/ConfigService/internal.js.map +1 -0
  57. package/dist/ConfigService/load.d.ts +18 -0
  58. package/dist/ConfigService/load.d.ts.map +1 -0
  59. package/dist/ConfigService/load.js +41 -0
  60. package/dist/ConfigService/load.js.map +1 -0
  61. package/dist/ConfigService/save.d.ts +9 -0
  62. package/dist/ConfigService/save.d.ts.map +1 -0
  63. package/dist/ConfigService/save.js +18 -0
  64. package/dist/ConfigService/save.js.map +1 -0
  65. package/dist/DateUtils.d.ts +4 -0
  66. package/dist/DateUtils.d.ts.map +1 -0
  67. package/dist/DateUtils.js +17 -0
  68. package/dist/DateUtils.js.map +1 -0
  69. package/dist/Domain.d.ts +277 -0
  70. package/dist/Domain.d.ts.map +1 -0
  71. package/dist/Domain.js +138 -0
  72. package/dist/Domain.js.map +1 -0
  73. package/dist/Errors.d.ts +135 -0
  74. package/dist/Errors.d.ts.map +1 -0
  75. package/dist/Errors.js +102 -0
  76. package/dist/Errors.js.map +1 -0
  77. package/dist/NotificationsService.d.ts +45 -0
  78. package/dist/NotificationsService.d.ts.map +1 -0
  79. package/dist/NotificationsService.js +57 -0
  80. package/dist/NotificationsService.js.map +1 -0
  81. package/dist/PRService/index.d.ts +28 -0
  82. package/dist/PRService/index.d.ts.map +1 -0
  83. package/dist/PRService/index.js +41 -0
  84. package/dist/PRService/index.js.map +1 -0
  85. package/dist/PRService/internal.d.ts +7 -0
  86. package/dist/PRService/internal.d.ts.map +1 -0
  87. package/dist/PRService/internal.js +2 -0
  88. package/dist/PRService/internal.js.map +1 -0
  89. package/dist/PRService/refresh.d.ts +10 -0
  90. package/dist/PRService/refresh.d.ts.map +1 -0
  91. package/dist/PRService/refresh.js +76 -0
  92. package/dist/PRService/refresh.js.map +1 -0
  93. package/dist/PRService/setAllAccounts.d.ts +9 -0
  94. package/dist/PRService/setAllAccounts.d.ts.map +1 -0
  95. package/dist/PRService/setAllAccounts.js +23 -0
  96. package/dist/PRService/setAllAccounts.js.map +1 -0
  97. package/dist/PRService/toggleAccount.d.ts +9 -0
  98. package/dist/PRService/toggleAccount.d.ts.map +1 -0
  99. package/dist/PRService/toggleAccount.js +29 -0
  100. package/dist/PRService/toggleAccount.js.map +1 -0
  101. package/dist/index.d.ts +26 -0
  102. package/dist/index.d.ts.map +1 -0
  103. package/dist/index.js +27 -0
  104. package/dist/index.js.map +1 -0
  105. package/package.json +42 -0
  106. package/src/index.ts +27 -0
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Comprehensive error hierarchy for CodeCommit operations.
3
+ *
4
+ * All errors use `Schema.TaggedError` for serialization + pattern matching.
5
+ * Errors are yieldable — no `Effect.fail()` wrapper needed.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { Errors } from "@knpkv/codecommit-core"
10
+ *
11
+ * // Yield directly in Effect.gen
12
+ * yield* new Errors.AwsCredentialError({ profile: "dev", region: "us-east-1", cause: err })
13
+ *
14
+ * // Pattern match with catchTags
15
+ * effect.pipe(
16
+ * Effect.catchTags({
17
+ * AwsCredentialError: (e) => handleAuth(e),
18
+ * AwsApiError: (e) => handleApi(e)
19
+ * })
20
+ * )
21
+ * ```
22
+ *
23
+ * @category Errors
24
+ * @module
25
+ */
26
+ import { Schema } from "effect";
27
+ declare const AwsCredentialError_base: Schema.TaggedErrorClass<AwsCredentialError, "AwsCredentialError", {
28
+ readonly _tag: Schema.tag<"AwsCredentialError">;
29
+ } & {
30
+ profile: Schema.brand<typeof Schema.String, "AwsProfileName">;
31
+ region: Schema.brand<typeof Schema.String, "AwsRegion">;
32
+ cause: typeof Schema.Defect;
33
+ }>;
34
+ /**
35
+ * AWS credential acquisition failure.
36
+ *
37
+ * @category Errors
38
+ */
39
+ export declare class AwsCredentialError extends AwsCredentialError_base {
40
+ }
41
+ declare const AwsThrottleError_base: Schema.TaggedErrorClass<AwsThrottleError, "AwsThrottleError", {
42
+ readonly _tag: Schema.tag<"AwsThrottleError">;
43
+ } & {
44
+ operation: typeof Schema.String;
45
+ retryCount: typeof Schema.Number;
46
+ cause: typeof Schema.Defect;
47
+ }>;
48
+ /**
49
+ * AWS API throttling / rate limiting.
50
+ *
51
+ * @category Errors
52
+ */
53
+ export declare class AwsThrottleError extends AwsThrottleError_base {
54
+ }
55
+ declare const AwsApiError_base: Schema.TaggedErrorClass<AwsApiError, "AwsApiError", {
56
+ readonly _tag: Schema.tag<"AwsApiError">;
57
+ } & {
58
+ operation: typeof Schema.String;
59
+ profile: Schema.brand<typeof Schema.String, "AwsProfileName">;
60
+ region: Schema.brand<typeof Schema.String, "AwsRegion">;
61
+ cause: typeof Schema.Defect;
62
+ }>;
63
+ /**
64
+ * AWS API call failure.
65
+ *
66
+ * @category Errors
67
+ */
68
+ export declare class AwsApiError extends AwsApiError_base {
69
+ }
70
+ declare const ConfigError_base: Schema.TaggedErrorClass<ConfigError, "ConfigError", {
71
+ readonly _tag: Schema.tag<"ConfigError">;
72
+ } & {
73
+ message: typeof Schema.String;
74
+ cause: Schema.optional<typeof Schema.Defect>;
75
+ }>;
76
+ /**
77
+ * Configuration load/save failure.
78
+ *
79
+ * @category Errors
80
+ */
81
+ export declare class ConfigError extends ConfigError_base {
82
+ }
83
+ declare const ConfigParseError_base: Schema.TaggedErrorClass<ConfigParseError, "ConfigParseError", {
84
+ readonly _tag: Schema.tag<"ConfigParseError">;
85
+ } & {
86
+ path: typeof Schema.String;
87
+ cause: typeof Schema.Defect;
88
+ }>;
89
+ /**
90
+ * Configuration file parse failure (JSON or Schema validation).
91
+ *
92
+ * @category Errors
93
+ */
94
+ export declare class ConfigParseError extends ConfigParseError_base {
95
+ }
96
+ declare const ProfileDetectionError_base: Schema.TaggedErrorClass<ProfileDetectionError, "ProfileDetectionError", {
97
+ readonly _tag: Schema.tag<"ProfileDetectionError">;
98
+ } & {
99
+ message: typeof Schema.String;
100
+ cause: Schema.optional<typeof Schema.Defect>;
101
+ }>;
102
+ /**
103
+ * AWS profile detection failure.
104
+ *
105
+ * @category Errors
106
+ */
107
+ export declare class ProfileDetectionError extends ProfileDetectionError_base {
108
+ }
109
+ declare const RefreshError_base: Schema.TaggedErrorClass<RefreshError, "RefreshError", {
110
+ readonly _tag: Schema.tag<"RefreshError">;
111
+ } & {
112
+ failedAccounts: Schema.Array$<typeof Schema.String>;
113
+ cause: Schema.optional<typeof Schema.Defect>;
114
+ }>;
115
+ /**
116
+ * Refresh orchestration failure — one or more accounts failed.
117
+ *
118
+ * @category Errors
119
+ */
120
+ export declare class RefreshError extends RefreshError_base {
121
+ }
122
+ /**
123
+ * Union of errors from AwsClient methods.
124
+ *
125
+ * @category Errors
126
+ */
127
+ export type AwsClientError = AwsCredentialError | AwsThrottleError | AwsApiError;
128
+ /**
129
+ * Union of all CodeCommit errors for exhaustive matching.
130
+ *
131
+ * @category Errors
132
+ */
133
+ export type CodeCommitError = AwsCredentialError | AwsThrottleError | AwsApiError | ConfigError | ConfigParseError | ProfileDetectionError | RefreshError;
134
+ export {};
135
+ //# sourceMappingURL=Errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Errors.d.ts","sourceRoot":"","sources":["../src/Errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;;;;;;;;AAG/B;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,uBAOvC;CAAG;;;;;;;;AAEJ;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,qBAOrC;CAAG;;;;;;;;;AAEJ;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,gBAQhC;CAAG;;;;;;;AAEJ;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,gBAMhC;CAAG;;;;;;;AAEJ;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,qBAMrC;CAAG;;;;;;;AAEJ;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,0BAM1C;CAAG;;;;;;;AAEJ;;;;GAIG;AACH,qBAAa,YAAa,SAAQ,iBAMjC;CAAG;AAEJ;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,WAAW,CAAA;AAEhF;;;;GAIG;AACH,MAAM,MAAM,eAAe,GACvB,kBAAkB,GAClB,gBAAgB,GAChB,WAAW,GACX,WAAW,GACX,gBAAgB,GAChB,qBAAqB,GACrB,YAAY,CAAA"}
package/dist/Errors.js ADDED
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Comprehensive error hierarchy for CodeCommit operations.
3
+ *
4
+ * All errors use `Schema.TaggedError` for serialization + pattern matching.
5
+ * Errors are yieldable — no `Effect.fail()` wrapper needed.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { Errors } from "@knpkv/codecommit-core"
10
+ *
11
+ * // Yield directly in Effect.gen
12
+ * yield* new Errors.AwsCredentialError({ profile: "dev", region: "us-east-1", cause: err })
13
+ *
14
+ * // Pattern match with catchTags
15
+ * effect.pipe(
16
+ * Effect.catchTags({
17
+ * AwsCredentialError: (e) => handleAuth(e),
18
+ * AwsApiError: (e) => handleApi(e)
19
+ * })
20
+ * )
21
+ * ```
22
+ *
23
+ * @category Errors
24
+ * @module
25
+ */
26
+ import { Schema } from "effect";
27
+ import { AwsProfileName, AwsRegion } from "./Domain.js";
28
+ /**
29
+ * AWS credential acquisition failure.
30
+ *
31
+ * @category Errors
32
+ */
33
+ export class AwsCredentialError extends Schema.TaggedError()("AwsCredentialError", {
34
+ profile: AwsProfileName,
35
+ region: AwsRegion,
36
+ cause: Schema.Defect
37
+ }) {
38
+ }
39
+ /**
40
+ * AWS API throttling / rate limiting.
41
+ *
42
+ * @category Errors
43
+ */
44
+ export class AwsThrottleError extends Schema.TaggedError()("AwsThrottleError", {
45
+ operation: Schema.String,
46
+ retryCount: Schema.Number,
47
+ cause: Schema.Defect
48
+ }) {
49
+ }
50
+ /**
51
+ * AWS API call failure.
52
+ *
53
+ * @category Errors
54
+ */
55
+ export class AwsApiError extends Schema.TaggedError()("AwsApiError", {
56
+ operation: Schema.String,
57
+ profile: AwsProfileName,
58
+ region: AwsRegion,
59
+ cause: Schema.Defect
60
+ }) {
61
+ }
62
+ /**
63
+ * Configuration load/save failure.
64
+ *
65
+ * @category Errors
66
+ */
67
+ export class ConfigError extends Schema.TaggedError()("ConfigError", {
68
+ message: Schema.String,
69
+ cause: Schema.optional(Schema.Defect)
70
+ }) {
71
+ }
72
+ /**
73
+ * Configuration file parse failure (JSON or Schema validation).
74
+ *
75
+ * @category Errors
76
+ */
77
+ export class ConfigParseError extends Schema.TaggedError()("ConfigParseError", {
78
+ path: Schema.String,
79
+ cause: Schema.Defect
80
+ }) {
81
+ }
82
+ /**
83
+ * AWS profile detection failure.
84
+ *
85
+ * @category Errors
86
+ */
87
+ export class ProfileDetectionError extends Schema.TaggedError()("ProfileDetectionError", {
88
+ message: Schema.String,
89
+ cause: Schema.optional(Schema.Defect)
90
+ }) {
91
+ }
92
+ /**
93
+ * Refresh orchestration failure — one or more accounts failed.
94
+ *
95
+ * @category Errors
96
+ */
97
+ export class RefreshError extends Schema.TaggedError()("RefreshError", {
98
+ failedAccounts: Schema.Array(Schema.String),
99
+ cause: Schema.optional(Schema.Defect)
100
+ }) {
101
+ }
102
+ //# sourceMappingURL=Errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Errors.js","sourceRoot":"","sources":["../src/Errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvD;;;;GAIG;AACH,MAAM,OAAO,kBAAmB,SAAQ,MAAM,CAAC,WAAW,EAAsB,CAC9E,oBAAoB,EACpB;IACE,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,MAAM,CAAC,MAAM;CACrB,CACF;CAAG;AAEJ;;;;GAIG;AACH,MAAM,OAAO,gBAAiB,SAAQ,MAAM,CAAC,WAAW,EAAoB,CAC1E,kBAAkB,EAClB;IACE,SAAS,EAAE,MAAM,CAAC,MAAM;IACxB,UAAU,EAAE,MAAM,CAAC,MAAM;IACzB,KAAK,EAAE,MAAM,CAAC,MAAM;CACrB,CACF;CAAG;AAEJ;;;;GAIG;AACH,MAAM,OAAO,WAAY,SAAQ,MAAM,CAAC,WAAW,EAAe,CAChE,aAAa,EACb;IACE,SAAS,EAAE,MAAM,CAAC,MAAM;IACxB,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,MAAM,CAAC,MAAM;CACrB,CACF;CAAG;AAEJ;;;;GAIG;AACH,MAAM,OAAO,WAAY,SAAQ,MAAM,CAAC,WAAW,EAAe,CAChE,aAAa,EACb;IACE,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;CACtC,CACF;CAAG;AAEJ;;;;GAIG;AACH,MAAM,OAAO,gBAAiB,SAAQ,MAAM,CAAC,WAAW,EAAoB,CAC1E,kBAAkB,EAClB;IACE,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM;CACrB,CACF;CAAG;AAEJ;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,MAAM,CAAC,WAAW,EAAyB,CACpF,uBAAuB,EACvB;IACE,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;CACtC,CACF;CAAG;AAEJ;;;;GAIG;AACH,MAAM,OAAO,YAAa,SAAQ,MAAM,CAAC,WAAW,EAAgB,CAClE,cAAc,EACd;IACE,cAAc,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;CACtC,CACF;CAAG"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Notification state management service.
3
+ *
4
+ * Manages application notifications using `SubscriptionRef` for reactive state
5
+ * and `Clock.currentTimeMillis` for timestamps (testable with `TestClock`).
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { NotificationsService } from "@knpkv/codecommit-core"
10
+ *
11
+ * const program = Effect.gen(function* () {
12
+ * const notifications = yield* NotificationsService
13
+ * yield* notifications.add({ type: "info", title: "Refresh", message: "Complete" })
14
+ * })
15
+ * ```
16
+ *
17
+ * @category Service
18
+ * @module
19
+ */
20
+ import { Context, Effect, Layer, SubscriptionRef } from "effect";
21
+ import type { NotificationsState, NotificationType } from "./Domain.js";
22
+ declare const NotificationsService_base: Context.TagClass<NotificationsService, "@knpkv/codecommit-core/NotificationsService", {
23
+ readonly state: SubscriptionRef.SubscriptionRef<NotificationsState>;
24
+ readonly add: (item: {
25
+ readonly type: NotificationType;
26
+ readonly title: string;
27
+ readonly message: string;
28
+ }) => Effect.Effect<void>;
29
+ readonly clear: Effect.Effect<void>;
30
+ }>;
31
+ /**
32
+ * Notifications service.
33
+ *
34
+ * @category Service
35
+ */
36
+ export declare class NotificationsService extends NotificationsService_base {
37
+ }
38
+ /**
39
+ * Live notifications service using Clock for timestamps.
40
+ *
41
+ * @category Service
42
+ */
43
+ export declare const NotificationsServiceLive: Layer.Layer<NotificationsService, never, never>;
44
+ export {};
45
+ //# sourceMappingURL=NotificationsService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationsService.d.ts","sourceRoot":"","sources":["../src/NotificationsService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAS,OAAO,EAAY,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AACjF,OAAO,KAAK,EAAoB,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;;oBAcrE,eAAe,CAAC,eAAe,CAAC,kBAAkB,CAAC;kBACrD,CAAC,IAAI,EAAE;QACnB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAA;QAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;QACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KACzB,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;oBACT,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;;AAdvC;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,yBAWvC;CAAG;AAMN;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,iDA4BpC,CAAA"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Notification state management service.
3
+ *
4
+ * Manages application notifications using `SubscriptionRef` for reactive state
5
+ * and `Clock.currentTimeMillis` for timestamps (testable with `TestClock`).
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { NotificationsService } from "@knpkv/codecommit-core"
10
+ *
11
+ * const program = Effect.gen(function* () {
12
+ * const notifications = yield* NotificationsService
13
+ * yield* notifications.add({ type: "info", title: "Refresh", message: "Complete" })
14
+ * })
15
+ * ```
16
+ *
17
+ * @category Service
18
+ * @module
19
+ */
20
+ import { Clock, Context, DateTime, Effect, Layer, SubscriptionRef } from "effect";
21
+ // ---------------------------------------------------------------------------
22
+ // Service Definition
23
+ // ---------------------------------------------------------------------------
24
+ /**
25
+ * Notifications service.
26
+ *
27
+ * @category Service
28
+ */
29
+ export class NotificationsService extends Context.Tag("@knpkv/codecommit-core/NotificationsService")() {
30
+ }
31
+ // ---------------------------------------------------------------------------
32
+ // Live Implementation
33
+ // ---------------------------------------------------------------------------
34
+ /**
35
+ * Live notifications service using Clock for timestamps.
36
+ *
37
+ * @category Service
38
+ */
39
+ export const NotificationsServiceLive = Layer.effect(NotificationsService, Effect.gen(function* () {
40
+ const state = yield* SubscriptionRef.make({
41
+ items: []
42
+ });
43
+ const add = (item) => Effect.gen(function* () {
44
+ const now = yield* Clock.currentTimeMillis;
45
+ const timestamp = DateTime.toDate(DateTime.unsafeMake(now));
46
+ const notification = {
47
+ ...item,
48
+ timestamp
49
+ };
50
+ yield* SubscriptionRef.update(state, (s) => ({
51
+ items: [...s.items, notification]
52
+ }));
53
+ }).pipe(Effect.withSpan("NotificationsService.add"));
54
+ const clear = SubscriptionRef.update(state, () => ({ items: [] }));
55
+ return { state, add, clear };
56
+ }));
57
+ //# sourceMappingURL=NotificationsService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationsService.js","sourceRoot":"","sources":["../src/NotificationsService.ts"],"names":[],"mappings":"AAAA;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AAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;IAElE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;AAC9B,CAAC,CAAC,CACH,CAAA"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Pull request orchestration service.
3
+ *
4
+ * @category Service
5
+ * @module
6
+ */
7
+ import { Context, Effect, Layer, SubscriptionRef } from "effect";
8
+ import type { AwsClient } from "../AwsClient/index.js";
9
+ import type { ConfigService } from "../ConfigService/index.js";
10
+ import type { AppState, AwsProfileName, NotificationType } from "../Domain.js";
11
+ import { NotificationsService } from "../NotificationsService.js";
12
+ declare const PRService_base: Context.TagClass<PRService, "@knpkv/codecommit-core/PRService", {
13
+ readonly state: SubscriptionRef.SubscriptionRef<AppState>;
14
+ readonly refresh: Effect.Effect<void>;
15
+ readonly toggleAccount: (profile: AwsProfileName) => Effect.Effect<void>;
16
+ readonly setAllAccounts: (enabled: boolean, profiles?: Array<AwsProfileName>) => Effect.Effect<void>;
17
+ readonly clearNotifications: Effect.Effect<void>;
18
+ readonly addNotification: (item: {
19
+ readonly type: NotificationType;
20
+ readonly title: string;
21
+ readonly message: string;
22
+ }) => Effect.Effect<void>;
23
+ }>;
24
+ export declare class PRService extends PRService_base {
25
+ }
26
+ export declare const PRServiceLive: Layer.Layer<PRService, never, NotificationsService | AwsClient | ConfigService>;
27
+ export {};
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/PRService/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;;oBAY7C,eAAe,CAAC,eAAe,CAAC,QAAQ,CAAC;sBACvC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;4BACb,CAAC,OAAO,EAAE,cAAc,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;6BAC/C,CACvB,OAAO,EAAE,OAAO,EAChB,QAAQ,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,KAC7B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;iCACK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;8BACtB,CAAC,IAAI,EAAE;QAC/B,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAA;QAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;QACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KACzB,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;;AAf7B,qBAAa,SAAU,SAAQ,cAiB5B;CAAG;AAMN,eAAO,MAAM,aAAa,iFA4BzB,CAAA"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Pull request orchestration service.
3
+ *
4
+ * @category Service
5
+ * @module
6
+ */
7
+ import { Context, Effect, Layer, SubscriptionRef } from "effect";
8
+ import { NotificationsService } from "../NotificationsService.js";
9
+ import { makeRefresh } from "./refresh.js";
10
+ import { makeSetAllAccounts } from "./setAllAccounts.js";
11
+ import { makeToggleAccount } from "./toggleAccount.js";
12
+ // ---------------------------------------------------------------------------
13
+ // Service Definition
14
+ // ---------------------------------------------------------------------------
15
+ export class PRService extends Context.Tag("@knpkv/codecommit-core/PRService")() {
16
+ }
17
+ // ---------------------------------------------------------------------------
18
+ // Live Implementation
19
+ // ---------------------------------------------------------------------------
20
+ export const PRServiceLive = Layer.effect(PRService, Effect.gen(function* () {
21
+ const notificationsService = yield* NotificationsService;
22
+ const ctx = yield* Effect.context();
23
+ const state = yield* SubscriptionRef.make({
24
+ pullRequests: [],
25
+ accounts: [],
26
+ status: "idle"
27
+ });
28
+ const provide = (effect) => Effect.provide(effect, ctx);
29
+ const refresh = provide(makeRefresh(state));
30
+ const toggleAccount = makeToggleAccount(state, refresh);
31
+ const setAllAccounts = makeSetAllAccounts(state, refresh);
32
+ return {
33
+ state,
34
+ refresh,
35
+ toggleAccount: (p) => provide(toggleAccount(p)),
36
+ setAllAccounts: (e, ps) => provide(setAllAccounts(e, ps)),
37
+ clearNotifications: notificationsService.clear,
38
+ addNotification: notificationsService.add
39
+ };
40
+ }));
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/PRService/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAIhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAEtD,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E,MAAM,OAAO,SAAU,SAAQ,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,EAiB3E;CAAG;AAEN,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CACvC,SAAS,EACT,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,oBAAoB,GAAG,KAAK,CAAC,CAAC,oBAAoB,CAAA;IACxD,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,EAAoD,CAAA;IAErF,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,eAAe,CAAC,IAAI,CAAW;QAClD,YAAY,EAAE,EAAE;QAChB,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,MAAM;KACf,CAAC,CAAA;IAEF,MAAM,OAAO,GAAG,CAAO,MAA6E,EAAE,EAAE,CACtG,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAE7B,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAA;IAC3C,MAAM,aAAa,GAAG,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IACvD,MAAM,cAAc,GAAG,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IAEzD,OAAO;QACL,KAAK;QACL,OAAO;QACP,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QAC/C,cAAc,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACzD,kBAAkB,EAAE,oBAAoB,CAAC,KAAK;QAC9C,eAAe,EAAE,oBAAoB,CAAC,GAAG;KAC1C,CAAA;AACH,CAAC,CAAC,CACH,CAAA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ import type { SubscriptionRef } from "effect";
5
+ import type { AppState } from "../Domain.js";
6
+ export type PRState = SubscriptionRef.SubscriptionRef<AppState>;
7
+ //# sourceMappingURL=internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/PRService/internal.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE5C,MAAM,MAAM,OAAO,GAAG,eAAe,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/PRService/internal.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ import { Effect } from "effect";
5
+ import { AwsClient } from "../AwsClient/index.js";
6
+ import { ConfigService } from "../ConfigService/index.js";
7
+ import { NotificationsService } from "../NotificationsService.js";
8
+ import type { PRState } from "./internal.js";
9
+ export declare const makeRefresh: (state: PRState) => Effect.Effect<void, never, ConfigService | AwsClient | NotificationsService>;
10
+ //# sourceMappingURL=refresh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../src/PRService/refresh.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAA0B,MAAM,EAA2B,MAAM,QAAQ,CAAA;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C,eAAO,MAAM,WAAW,GACtB,OAAO,OAAO,KACb,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,aAAa,GAAG,SAAS,GAAG,oBAAoB,CAwG3E,CAAA"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ import { Cause, Clock, DateTime, Effect, Stream, SubscriptionRef } from "effect";
5
+ import { AwsClient } from "../AwsClient/index.js";
6
+ import { ConfigService } from "../ConfigService/index.js";
7
+ import { NotificationsService } from "../NotificationsService.js";
8
+ export const makeRefresh = (state) => Effect.gen(function* () {
9
+ const configService = yield* ConfigService;
10
+ const awsClient = yield* AwsClient;
11
+ const notificationsService = yield* NotificationsService;
12
+ yield* SubscriptionRef.update(state, (s) => ({
13
+ ...s,
14
+ pullRequests: [],
15
+ status: "loading",
16
+ error: undefined
17
+ }));
18
+ yield* notificationsService.clear;
19
+ const config = yield* configService.load.pipe(Effect.catchAll((e) => Effect.fail(new Error(`Config load failed: ${e.message}`))));
20
+ const detected = yield* configService.detectProfiles.pipe(Effect.catchAll(() => Effect.succeed([])));
21
+ const accountsState = detected.map((d) => {
22
+ const configured = config.accounts.find((a) => a.profile === d.name);
23
+ return {
24
+ profile: d.name,
25
+ region: configured?.regions?.[0] ?? d.region ?? "",
26
+ enabled: configured?.enabled ?? false
27
+ };
28
+ });
29
+ yield* SubscriptionRef.update(state, (s) => ({ ...s, accounts: accountsState }));
30
+ const enabledAccounts = config.accounts.filter((a) => a.enabled);
31
+ if (enabledAccounts.length === 0) {
32
+ const now = yield* Clock.currentTimeMillis;
33
+ yield* SubscriptionRef.update(state, (s) => ({ ...s, status: "idle", lastUpdated: DateTime.toDate(DateTime.unsafeMake(now)) }));
34
+ return;
35
+ }
36
+ const firstAccount = enabledAccounts[0];
37
+ const firstRegion = firstAccount.regions?.[0] ?? "us-east-1";
38
+ yield* awsClient.getCallerIdentity({ profile: firstAccount.profile, region: firstRegion }).pipe(Effect.tap((user) => SubscriptionRef.update(state, (s) => ({ ...s, currentUser: user }))), Effect.catchAll(() => Effect.void));
39
+ const accountLabels = enabledAccounts.flatMap((a) => (a.regions ?? []).map((r) => `${a.profile}(${r})`));
40
+ yield* SubscriptionRef.update(state, (s) => ({
41
+ ...s,
42
+ statusDetail: accountLabels.join(", ")
43
+ }));
44
+ const streams = enabledAccounts.flatMap((account) => (account.regions ?? []).map((region) => {
45
+ const label = `${account.profile} (${region})`;
46
+ return awsClient.getPullRequests({ profile: account.profile, region }).pipe(Stream.map((pr) => ({ pr, label })), Stream.catchAllCause((cause) => {
47
+ const errorStr = Cause.pretty(cause).split("\n")[0] ?? "Unknown error";
48
+ return Stream.fromEffect(notificationsService.add({
49
+ type: "error",
50
+ title: label,
51
+ message: errorStr
52
+ })).pipe(Stream.flatMap(() => Stream.empty));
53
+ }));
54
+ }));
55
+ yield* Stream.mergeAll(streams, { concurrency: 2 }).pipe(Stream.runForEach(({ label, pr }) => SubscriptionRef.update(state, (s) => {
56
+ const prs = s.pullRequests;
57
+ const insertIdx = prs.findIndex((p) => p.creationDate.getTime() < pr.creationDate.getTime());
58
+ const newPrs = insertIdx === -1 ? [...prs, pr] : [...prs.slice(0, insertIdx), pr, ...prs.slice(insertIdx)];
59
+ return {
60
+ ...s,
61
+ pullRequests: newPrs,
62
+ statusDetail: `${label} #${pr.id} ${pr.repositoryName}`
63
+ };
64
+ })));
65
+ const now = yield* Clock.currentTimeMillis;
66
+ yield* SubscriptionRef.update(state, (s) => ({
67
+ ...s,
68
+ status: "idle",
69
+ statusDetail: undefined,
70
+ lastUpdated: DateTime.toDate(DateTime.unsafeMake(now))
71
+ }));
72
+ }).pipe(Effect.withSpan("PRService.refresh"), Effect.timeout("120 seconds"), Effect.catchAllCause((cause) => {
73
+ const errorStr = Cause.pretty(cause).split("\n")[0] ?? "Unknown error";
74
+ return SubscriptionRef.update(state, (s) => ({ ...s, status: "error", error: errorStr }));
75
+ }));
76
+ //# sourceMappingURL=refresh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refresh.js","sourceRoot":"","sources":["../../src/PRService/refresh.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CA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AM,GAAG,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAA;IAC1C,KAAK,CAAC,CAAC,eAAe,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3C,GAAG,CAAC;QACJ,MAAM,EAAE,MAAe;QACvB,YAAY,EAAE,SAAS;QACvB,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;KACvD,CAAC,CAAC,CAAA;AACL,CAAC,CAAC,CAAC,IAAI,CACL,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EACpC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAC7B,MAAM,CAAC,aAAa,CAAC,CAAC,KAAK,EAAE,EAAE;IAC7B,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,eAAe,CAAA;IACtE,OAAO,eAAe,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,OAAgB,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAA;AACpG,CAAC,CAAC,CACH,CAAA"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ import { Effect } from "effect";
5
+ import { ConfigService } from "../ConfigService/index.js";
6
+ import type { AwsProfileName } from "../Domain.js";
7
+ import type { PRState } from "./internal.js";
8
+ export declare const makeSetAllAccounts: (state: PRState, refresh: Effect.Effect<void>) => (enabled: boolean, profiles?: Array<AwsProfileName>) => Effect.Effect<void, never, ConfigService>;
9
+ //# sourceMappingURL=setAllAccounts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setAllAccounts.d.ts","sourceRoot":"","sources":["../../src/PRService/setAllAccounts.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,cAAc,CAAA;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C,eAAO,MAAM,kBAAkB,GAC7B,OAAO,OAAO,EACd,SAAS,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAE7B,SAAS,OAAO,EAAE,WAAW,KAAK,CAAC,cAAc,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,aAAa,CAmBxC,CAAA"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ import { Effect } from "effect";
5
+ import { ConfigService } from "../ConfigService/index.js";
6
+ export const makeSetAllAccounts = (state, refresh) => (enabled, profiles) => Effect.gen(function* () {
7
+ const configService = yield* ConfigService;
8
+ const config = yield* configService.load.pipe(Effect.orDie);
9
+ const detected = yield* configService.detectProfiles.pipe(Effect.orDie);
10
+ const targetProfiles = profiles ?? detected.map((d) => d.name);
11
+ const newAccounts = targetProfiles.map((profile) => {
12
+ const existing = config.accounts.find((a) => a.profile === profile);
13
+ const det = detected.find((d) => d.name === profile);
14
+ return {
15
+ profile,
16
+ regions: existing?.regions ?? [det?.region ?? "us-east-1"],
17
+ enabled
18
+ };
19
+ });
20
+ yield* configService.save({ ...config, accounts: newAccounts }).pipe(Effect.orDie);
21
+ yield* refresh;
22
+ }).pipe(Effect.withSpan("PRService.setAllAccounts"));
23
+ //# sourceMappingURL=setAllAccounts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setAllAccounts.js","sourceRoot":"","sources":["../../src/PRService/setAllAccounts.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAA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;IAClF,KAAK,CAAC,CAAC,OAAO,CAAA;AAChB,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,0BAA0B,CAAC,CAAC,CAAA"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ import { Effect } from "effect";
5
+ import { ConfigService } from "../ConfigService/index.js";
6
+ import type { AwsProfileName } from "../Domain.js";
7
+ import type { PRState } from "./internal.js";
8
+ export declare const makeToggleAccount: (state: PRState, refresh: Effect.Effect<void>) => (profile: AwsProfileName) => Effect.Effect<void, never, ConfigService>;
9
+ //# sourceMappingURL=toggleAccount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toggleAccount.d.ts","sourceRoot":"","sources":["../../src/PRService/toggleAccount.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,cAAc,CAAA;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C,eAAO,MAAM,iBAAiB,GAC5B,OAAO,OAAO,EACd,SAAS,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAE7B,SAAS,cAAc,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,aAAa,CAwBd,CAAA"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ import { Effect } from "effect";
5
+ import { ConfigService } from "../ConfigService/index.js";
6
+ export const makeToggleAccount = (state, refresh) => (profile) => Effect.gen(function* () {
7
+ const configService = yield* ConfigService;
8
+ const config = yield* configService.load.pipe(Effect.orDie);
9
+ const existingIdx = config.accounts.findIndex((a) => a.profile === profile);
10
+ const newAccounts = [...config.accounts];
11
+ if (existingIdx >= 0) {
12
+ newAccounts[existingIdx] = {
13
+ ...newAccounts[existingIdx],
14
+ enabled: !newAccounts[existingIdx].enabled
15
+ };
16
+ }
17
+ else {
18
+ const detected = yield* configService.detectProfiles.pipe(Effect.orDie);
19
+ const p = detected.find((d) => d.name === profile);
20
+ newAccounts.push({
21
+ profile,
22
+ regions: [p?.region ?? "us-east-1"],
23
+ enabled: true
24
+ });
25
+ }
26
+ yield* configService.save({ ...config, accounts: newAccounts }).pipe(Effect.orDie);
27
+ yield* refresh;
28
+ }).pipe(Effect.withSpan("PRService.toggleAccount"));
29
+ //# sourceMappingURL=toggleAccount.js.map