alchemy 2.0.0-beta.16 → 2.0.0-beta.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/alchemy.js +79 -6
- package/bin/alchemy.js.map +1 -1
- package/bin/cli.js +9 -7
- package/bin/commands/deploy.ts +11 -2
- package/bin/commands/profile.ts +21 -1
- package/bin/commands/state.ts +91 -1
- package/lib/Auth/Credentials.d.ts +6 -0
- package/lib/Auth/Credentials.d.ts.map +1 -1
- package/lib/Auth/Credentials.js +12 -1
- package/lib/Auth/Credentials.js.map +1 -1
- package/lib/Auth/Profile.d.ts +5 -0
- package/lib/Auth/Profile.d.ts.map +1 -1
- package/lib/Auth/Profile.js +11 -0
- package/lib/Auth/Profile.js.map +1 -1
- package/lib/Cloudflare/ApiToken/AccountApiToken.d.ts +2 -1
- package/lib/Cloudflare/ApiToken/AccountApiToken.d.ts.map +1 -1
- package/lib/Cloudflare/ApiToken/AccountApiToken.js +6 -5
- package/lib/Cloudflare/ApiToken/AccountApiToken.js.map +1 -1
- package/lib/Cloudflare/ApiToken/Common.d.ts +5 -11
- package/lib/Cloudflare/ApiToken/Common.d.ts.map +1 -1
- package/lib/Cloudflare/ApiToken/Common.js +4 -14
- package/lib/Cloudflare/ApiToken/Common.js.map +1 -1
- package/lib/Cloudflare/ApiToken/UserApiToken.js +4 -4
- package/lib/Cloudflare/ApiToken/UserApiToken.js.map +1 -1
- package/lib/GitHub/Comment.d.ts +2 -1
- package/lib/GitHub/Comment.d.ts.map +1 -1
- package/lib/GitHub/Comment.js +1 -0
- package/lib/GitHub/Comment.js.map +1 -1
- package/lib/GitHub/Providers.d.ts.map +1 -1
- package/lib/GitHub/Providers.js +2 -1
- package/lib/GitHub/Providers.js.map +1 -1
- package/lib/GitHub/Secret.d.ts +2 -2
- package/lib/GitHub/Secret.d.ts.map +1 -1
- package/lib/GitHub/Variable.d.ts +2 -2
- package/lib/GitHub/Variable.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Auth/Credentials.ts +17 -1
- package/src/Auth/Profile.ts +15 -0
- package/src/Cloudflare/ApiToken/AccountApiToken.ts +6 -5
- package/src/Cloudflare/ApiToken/Common.ts +6 -18
- package/src/Cloudflare/ApiToken/UserApiToken.ts +4 -4
- package/src/GitHub/Comment.ts +4 -1
- package/src/GitHub/Providers.ts +8 -2
- package/src/GitHub/Secret.ts +2 -2
- package/src/GitHub/Variable.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Comment.js","sourceRoot":"","sources":["../../src/GitHub/Comment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"Comment.js","sourceRoot":"","sources":["../../src/GitHub/Comment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAiEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAU,gBAAgB,CAAC,CAAC;AAE3D,SAAS,YAAY,CAAC,KAAmB;IACvC,OAAO,CACL,KAAK,CAAC,KAA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AA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Providers.d.ts","sourceRoot":"","sources":["../../src/GitHub/Providers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAG3C,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAIhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;;AAErD,qBAAa,SAAU,SAAQ,cAE9B;CAAG;AAEJ,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;AAEhF;;;GAGG;AACH,eAAO,MAAM,SAAS,+JAWnB,CAAC"}
|
package/lib/GitHub/Providers.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as Layer from "effect/Layer";
|
|
2
2
|
import * as Provider from "../Provider.js";
|
|
3
3
|
import { GitHubAuth } from "./AuthProvider.js";
|
|
4
|
+
import { Comment, CommentProvider } from "./Comment.js";
|
|
4
5
|
import * as Credentials from "./Credentials.js";
|
|
5
6
|
import { Secret, SecretProvider } from "./Secret.js";
|
|
6
7
|
import { Variable, VariableProvider } from "./Variable.js";
|
|
@@ -11,5 +12,5 @@ export class Providers extends Provider.ProviderCollection()("GitHub") {
|
|
|
11
12
|
* GitHub providers (Secret, Variable) plus the GitHub AuthProvider that
|
|
12
13
|
* `alchemy login` discovers.
|
|
13
14
|
*/
|
|
14
|
-
export const providers = () => Layer.effect(Providers, Provider.collection([Secret, Variable])).pipe(Layer.provide(Layer.mergeAll(SecretProvider(), VariableProvider())), Layer.provideMerge(Credentials.fromAuthProvider()), Layer.provideMerge(GitHubAuth), Layer.orDie);
|
|
15
|
+
export const providers = () => Layer.effect(Providers, Provider.collection([Comment, Secret, Variable])).pipe(Layer.provide(Layer.mergeAll(CommentProvider(), SecretProvider(), VariableProvider())), Layer.provideMerge(Credentials.fromAuthProvider()), Layer.provideMerge(GitHubAuth), Layer.orDie);
|
|
15
16
|
//# sourceMappingURL=Providers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Providers.js","sourceRoot":"","sources":["../../src/GitHub/Providers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,OAAO,SAAU,SAAQ,QAAQ,CAAC,kBAAkB,EAAa,CACrE,QAAQ,CACT;CAAG;AAIJ;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE,CAC5B,KAAK,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"Providers.js","sourceRoot":"","sources":["../../src/GitHub/Providers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,OAAO,SAAU,SAAQ,QAAQ,CAAC,kBAAkB,EAAa,CACrE,QAAQ,CACT;CAAG;AAIJ;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE,CAC5B,KAAK,CAAC,MAAM,CACV,SAAS,EACT,QAAQ,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CACjD,CAAC,IAAI,CACJ,KAAK,CAAC,OAAO,CACX,KAAK,CAAC,QAAQ,CAAC,eAAe,EAAE,EAAE,cAAc,EAAE,EAAE,gBAAgB,EAAE,CAAC,CACxE,EACD,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,gBAAgB,EAAE,CAAC,EAClD,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,EAC9B,KAAK,CAAC,KAAK,CACZ,CAAC"}
|
package/lib/GitHub/Secret.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as Redacted from "effect/Redacted";
|
|
|
2
2
|
import * as Provider from "../Provider.ts";
|
|
3
3
|
import { Resource } from "../Resource.ts";
|
|
4
4
|
import { GitHubCredentials } from "./Credentials.ts";
|
|
5
|
-
import type
|
|
5
|
+
import type * as GitHub from "./Providers.ts";
|
|
6
6
|
export interface SecretProps {
|
|
7
7
|
/**
|
|
8
8
|
* Repository owner (user or organization).
|
|
@@ -32,7 +32,7 @@ export interface Secret extends Resource<"GitHub.Secret", SecretProps, {
|
|
|
32
32
|
* ISO-8601 timestamp of the last update.
|
|
33
33
|
*/
|
|
34
34
|
updatedAt: string;
|
|
35
|
-
}, never, Providers> {
|
|
35
|
+
}, never, GitHub.Providers> {
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* A GitHub Actions repository or environment secret.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Secret.d.ts","sourceRoot":"","sources":["../../src/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@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Provider from "../Provider.ts";
|
|
2
2
|
import { Resource } from "../Resource.ts";
|
|
3
3
|
import { GitHubCredentials } from "./Credentials.ts";
|
|
4
|
-
import type
|
|
4
|
+
import type * as GitHub from "./Providers.ts";
|
|
5
5
|
export interface VariableProps {
|
|
6
6
|
/**
|
|
7
7
|
* Repository owner (user or organization).
|
|
@@ -25,7 +25,7 @@ export interface Variable extends Resource<"GitHub.Variable", VariableProps, {
|
|
|
25
25
|
* ISO-8601 timestamp of the last update.
|
|
26
26
|
*/
|
|
27
27
|
updatedAt: string;
|
|
28
|
-
}, never, Providers> {
|
|
28
|
+
}, never, GitHub.Providers> {
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* A GitHub Actions repository variable.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Variable.d.ts","sourceRoot":"","sources":["../../src/GitHub/Variable.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"Variable.d.ts","sourceRoot":"","sources":["../../src/GitHub/Variable.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,QAAS,SAAQ,QAAQ,CACxC,iBAAiB,EACjB,aAAa,EACb;IACE;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB,EACD,KAAK,EACL,MAAM,CAAC,SAAS,CACjB;CAAG;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,eAAO,MAAM,QAAQ,kDAAwC,CAAC;AAO9D,eAAO,MAAM,gBAAgB,2FAiDzB,CAAC"}
|
package/package.json
CHANGED
package/src/Auth/Credentials.ts
CHANGED
|
@@ -6,8 +6,11 @@ import { rootDir } from "./Profile.ts";
|
|
|
6
6
|
|
|
7
7
|
const credentialsDirPath = path.join(rootDir, "credentials");
|
|
8
8
|
|
|
9
|
+
export const profileCredentialsDirPath = (profile: string) =>
|
|
10
|
+
path.join(credentialsDirPath, profile);
|
|
11
|
+
|
|
9
12
|
export const credentialsFilePath = (profile: string, provider: string) =>
|
|
10
|
-
path.join(
|
|
13
|
+
path.join(profileCredentialsDirPath(profile), `${provider}.json`);
|
|
11
14
|
|
|
12
15
|
export const readCredentials = Effect.fnUntraced(function* <T>(
|
|
13
16
|
profile: string,
|
|
@@ -46,6 +49,19 @@ export const deleteCredentials = Effect.fnUntraced(function* (
|
|
|
46
49
|
.pipe(Effect.catch(() => Effect.void));
|
|
47
50
|
});
|
|
48
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Recursively remove the `~/.alchemy/credentials/{profile}` directory
|
|
54
|
+
* containing all per-provider secrets for `profile`. No-op if it doesn't exist.
|
|
55
|
+
*/
|
|
56
|
+
export const deleteProfileCredentials = Effect.fnUntraced(function* (
|
|
57
|
+
profile: string,
|
|
58
|
+
) {
|
|
59
|
+
const fs = yield* FileSystem.FileSystem;
|
|
60
|
+
yield* fs
|
|
61
|
+
.remove(profileCredentialsDirPath(profile), { recursive: true })
|
|
62
|
+
.pipe(Effect.catch(() => Effect.void));
|
|
63
|
+
});
|
|
64
|
+
|
|
49
65
|
export function displayRedacted(
|
|
50
66
|
r: Redacted.Redacted<string>,
|
|
51
67
|
visibleChars = 4,
|
package/src/Auth/Profile.ts
CHANGED
|
@@ -91,6 +91,21 @@ export const setProfile = (name: string, profile: AlchemyProfile) =>
|
|
|
91
91
|
Effect.flatMap(writeConfig),
|
|
92
92
|
);
|
|
93
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Remove `name` and all its provider credentials from the on-disk config.
|
|
96
|
+
* Returns `true` if the profile existed and was removed, `false` otherwise.
|
|
97
|
+
*/
|
|
98
|
+
export const deleteProfile = (name: string) =>
|
|
99
|
+
readConfig.pipe(
|
|
100
|
+
Effect.flatMap((config) => {
|
|
101
|
+
if (!(name in config.profiles)) {
|
|
102
|
+
return Effect.succeed(false);
|
|
103
|
+
}
|
|
104
|
+
delete config.profiles[name];
|
|
105
|
+
return writeConfig(config).pipe(Effect.as(true));
|
|
106
|
+
}),
|
|
107
|
+
);
|
|
108
|
+
|
|
94
109
|
/**
|
|
95
110
|
* Returns a `ConfigProvider` that overrides `ALCHEMY_PROFILE` with the
|
|
96
111
|
* given `profile` (when explicitly passed via the CLI `--profile` flag),
|
|
@@ -50,6 +50,7 @@ export type AccountApiToken = Resource<
|
|
|
50
50
|
* ```typescript
|
|
51
51
|
* const token = yield* Cloudflare.AccountApiToken("ci-token", {
|
|
52
52
|
* name: "my-ci-token",
|
|
53
|
+
* accountId,
|
|
53
54
|
* policies: [
|
|
54
55
|
* {
|
|
55
56
|
* effect: "allow",
|
|
@@ -57,7 +58,7 @@ export type AccountApiToken = Resource<
|
|
|
57
58
|
* "Workers Scripts Write",
|
|
58
59
|
* "Workers KV Storage Write",
|
|
59
60
|
* ],
|
|
60
|
-
* resources: {
|
|
61
|
+
* resources: { [`com.cloudflare.api.account.${accountId}`]: "*" },
|
|
61
62
|
* },
|
|
62
63
|
* ],
|
|
63
64
|
* });
|
|
@@ -120,10 +121,10 @@ export const AccountApiTokenProvider = () =>
|
|
|
120
121
|
const oldName = output?.name ?? (yield* resolveName(id, olds?.name));
|
|
121
122
|
const newName = yield* resolveName(id, news.name);
|
|
122
123
|
const oldPolicyFp = policyFingerprint(
|
|
123
|
-
resolvePolicies(olds?.policies ?? []
|
|
124
|
+
resolvePolicies(olds?.policies ?? []),
|
|
124
125
|
);
|
|
125
126
|
const newPolicyFp = policyFingerprint(
|
|
126
|
-
resolvePolicies(news.policies
|
|
127
|
+
resolvePolicies(news.policies),
|
|
127
128
|
);
|
|
128
129
|
const oldCondFp = conditionFingerprint(olds?.condition);
|
|
129
130
|
const newCondFp = conditionFingerprint(news.condition);
|
|
@@ -140,7 +141,7 @@ export const AccountApiTokenProvider = () =>
|
|
|
140
141
|
create: Effect.fn(function* ({ id, news }) {
|
|
141
142
|
const accountId = news.accountId ?? defaultAccountId;
|
|
142
143
|
const name = yield* resolveName(id, news.name);
|
|
143
|
-
const policies = resolvePolicies(news.policies
|
|
144
|
+
const policies = resolvePolicies(news.policies);
|
|
144
145
|
const result = yield* createToken({
|
|
145
146
|
accountId,
|
|
146
147
|
name,
|
|
@@ -163,7 +164,7 @@ export const AccountApiTokenProvider = () =>
|
|
|
163
164
|
update: Effect.fn(function* ({ id, news, output }) {
|
|
164
165
|
const accountId = news.accountId ?? defaultAccountId;
|
|
165
166
|
const name = yield* resolveName(id, news.name);
|
|
166
|
-
const policies = resolvePolicies(news.policies
|
|
167
|
+
const policies = resolvePolicies(news.policies);
|
|
167
168
|
const result = yield* updateToken({
|
|
168
169
|
accountId,
|
|
169
170
|
tokenId: output.tokenId,
|
|
@@ -6,14 +6,13 @@ import {
|
|
|
6
6
|
/**
|
|
7
7
|
* Resource keys recognized by Cloudflare API token policies.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Cloudflare requires the account ID to be embedded directly in the resource
|
|
10
|
+
* key (e.g. `com.cloudflare.api.account.<accountId>`); pass the fully-qualified
|
|
11
|
+
* key — no rewriting is performed.
|
|
12
12
|
*
|
|
13
13
|
* @see https://developers.cloudflare.com/fundamentals/api/reference/permissions/
|
|
14
14
|
*/
|
|
15
15
|
export type ApiTokenResourceKey =
|
|
16
|
-
| "com.cloudflare.api.account"
|
|
17
16
|
| `com.cloudflare.api.account.${string}`
|
|
18
17
|
| `com.cloudflare.api.account.zone.${string}`
|
|
19
18
|
| `com.cloudflare.edge.r2.bucket.${string}`
|
|
@@ -86,35 +85,24 @@ export const resolvePermissionGroup = (ref: ApiTokenPermissionGroupRef) => {
|
|
|
86
85
|
return ref.meta ? { id: ref.id, meta: ref.meta } : { id: ref.id };
|
|
87
86
|
};
|
|
88
87
|
|
|
89
|
-
|
|
90
|
-
* Rewrite the bare `"com.cloudflare.api.account"` key to the
|
|
91
|
-
* account-scoped form. Pass `accountId: undefined` to leave keys unchanged
|
|
92
|
-
* (e.g. for user-owned tokens whose policies don't carry an account scope).
|
|
93
|
-
*/
|
|
94
|
-
export const resolveResources = (
|
|
88
|
+
const resolveResources = (
|
|
95
89
|
resources: ApiTokenPolicy["resources"],
|
|
96
|
-
accountId: string | undefined,
|
|
97
90
|
): Record<string, string> => {
|
|
98
91
|
const out: Record<string, string> = {};
|
|
99
92
|
for (const [key, value] of Object.entries(resources)) {
|
|
100
93
|
if (value === undefined) continue;
|
|
101
|
-
|
|
102
|
-
out[`com.cloudflare.api.account.${accountId}`] = value;
|
|
103
|
-
} else {
|
|
104
|
-
out[key] = value;
|
|
105
|
-
}
|
|
94
|
+
out[key] = value;
|
|
106
95
|
}
|
|
107
96
|
return out;
|
|
108
97
|
};
|
|
109
98
|
|
|
110
99
|
export const resolvePolicies = (
|
|
111
100
|
policies: ApiTokenPolicy[],
|
|
112
|
-
accountId: string | undefined,
|
|
113
101
|
): ResolvedPolicy[] =>
|
|
114
102
|
policies.map((policy) => ({
|
|
115
103
|
effect: policy.effect,
|
|
116
104
|
permissionGroups: policy.permissionGroups.map(resolvePermissionGroup),
|
|
117
|
-
resources: resolveResources(policy.resources
|
|
105
|
+
resources: resolveResources(policy.resources),
|
|
118
106
|
}));
|
|
119
107
|
|
|
120
108
|
export const policyFingerprint = (policies: ResolvedPolicy[]): string =>
|
|
@@ -100,10 +100,10 @@ export const UserApiTokenProvider = () =>
|
|
|
100
100
|
const oldName = output?.name ?? (yield* resolveName(id, olds?.name));
|
|
101
101
|
const newName = yield* resolveName(id, news.name);
|
|
102
102
|
const oldPolicyFp = policyFingerprint(
|
|
103
|
-
resolvePolicies(olds?.policies ?? []
|
|
103
|
+
resolvePolicies(olds?.policies ?? []),
|
|
104
104
|
);
|
|
105
105
|
const newPolicyFp = policyFingerprint(
|
|
106
|
-
resolvePolicies(news.policies
|
|
106
|
+
resolvePolicies(news.policies),
|
|
107
107
|
);
|
|
108
108
|
const oldCondFp = conditionFingerprint(olds?.condition);
|
|
109
109
|
const newCondFp = conditionFingerprint(news.condition);
|
|
@@ -119,7 +119,7 @@ export const UserApiTokenProvider = () =>
|
|
|
119
119
|
}),
|
|
120
120
|
create: Effect.fn(function* ({ id, news }) {
|
|
121
121
|
const name = yield* resolveName(id, news.name);
|
|
122
|
-
const policies = resolvePolicies(news.policies
|
|
122
|
+
const policies = resolvePolicies(news.policies);
|
|
123
123
|
const result = yield* createToken({
|
|
124
124
|
name,
|
|
125
125
|
policies,
|
|
@@ -136,7 +136,7 @@ export const UserApiTokenProvider = () =>
|
|
|
136
136
|
}),
|
|
137
137
|
update: Effect.fn(function* ({ id, news, output }) {
|
|
138
138
|
const name = yield* resolveName(id, news.name);
|
|
139
|
-
const policies = resolvePolicies(news.policies
|
|
139
|
+
const policies = resolvePolicies(news.policies);
|
|
140
140
|
const result = yield* updateToken({
|
|
141
141
|
tokenId: output.tokenId,
|
|
142
142
|
name,
|
package/src/GitHub/Comment.ts
CHANGED
|
@@ -3,6 +3,7 @@ import * as Effect from "effect/Effect";
|
|
|
3
3
|
import * as Provider from "../Provider.ts";
|
|
4
4
|
import { Resource } from "../Resource.ts";
|
|
5
5
|
import { dedent } from "../Util/dedent.ts";
|
|
6
|
+
import * as GitHub from "./Providers.ts";
|
|
6
7
|
|
|
7
8
|
export interface CommentProps {
|
|
8
9
|
/**
|
|
@@ -62,7 +63,9 @@ export interface Comment extends Resource<
|
|
|
62
63
|
* ISO-8601 timestamp of the last update.
|
|
63
64
|
*/
|
|
64
65
|
updatedAt: string;
|
|
65
|
-
}
|
|
66
|
+
},
|
|
67
|
+
never,
|
|
68
|
+
GitHub.Providers
|
|
66
69
|
> {}
|
|
67
70
|
|
|
68
71
|
/**
|
package/src/GitHub/Providers.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as Layer from "effect/Layer";
|
|
2
2
|
import * as Provider from "../Provider.ts";
|
|
3
3
|
import { GitHubAuth } from "./AuthProvider.ts";
|
|
4
|
+
import { Comment, CommentProvider } from "./Comment.ts";
|
|
4
5
|
import * as Credentials from "./Credentials.ts";
|
|
5
6
|
import { Secret, SecretProvider } from "./Secret.ts";
|
|
6
7
|
import { Variable, VariableProvider } from "./Variable.ts";
|
|
@@ -18,8 +19,13 @@ export type ProviderRequirements = Layer.Services<ReturnType<typeof providers>>;
|
|
|
18
19
|
* `alchemy login` discovers.
|
|
19
20
|
*/
|
|
20
21
|
export const providers = () =>
|
|
21
|
-
Layer.effect(
|
|
22
|
-
|
|
22
|
+
Layer.effect(
|
|
23
|
+
Providers,
|
|
24
|
+
Provider.collection([Comment, Secret, Variable]),
|
|
25
|
+
).pipe(
|
|
26
|
+
Layer.provide(
|
|
27
|
+
Layer.mergeAll(CommentProvider(), SecretProvider(), VariableProvider()),
|
|
28
|
+
),
|
|
23
29
|
Layer.provideMerge(Credentials.fromAuthProvider()),
|
|
24
30
|
Layer.provideMerge(GitHubAuth),
|
|
25
31
|
Layer.orDie,
|
package/src/GitHub/Secret.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as Redacted from "effect/Redacted";
|
|
|
4
4
|
import * as Provider from "../Provider.ts";
|
|
5
5
|
import { Resource } from "../Resource.ts";
|
|
6
6
|
import { GitHubCredentials } from "./Credentials.ts";
|
|
7
|
-
import type
|
|
7
|
+
import type * as GitHub from "./Providers.ts";
|
|
8
8
|
|
|
9
9
|
export interface SecretProps {
|
|
10
10
|
/**
|
|
@@ -45,7 +45,7 @@ export interface Secret extends Resource<
|
|
|
45
45
|
updatedAt: string;
|
|
46
46
|
},
|
|
47
47
|
never,
|
|
48
|
-
Providers
|
|
48
|
+
GitHub.Providers
|
|
49
49
|
> {}
|
|
50
50
|
|
|
51
51
|
/**
|
package/src/GitHub/Variable.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as Effect from "effect/Effect";
|
|
|
2
2
|
import * as Provider from "../Provider.ts";
|
|
3
3
|
import { Resource } from "../Resource.ts";
|
|
4
4
|
import { GitHubCredentials } from "./Credentials.ts";
|
|
5
|
-
import type
|
|
5
|
+
import type * as GitHub from "./Providers.ts";
|
|
6
6
|
|
|
7
7
|
export interface VariableProps {
|
|
8
8
|
/**
|
|
@@ -36,7 +36,7 @@ export interface Variable extends Resource<
|
|
|
36
36
|
updatedAt: string;
|
|
37
37
|
},
|
|
38
38
|
never,
|
|
39
|
-
Providers
|
|
39
|
+
GitHub.Providers
|
|
40
40
|
> {}
|
|
41
41
|
|
|
42
42
|
/**
|