@gaganref/confect-alchemy 10.6.0-fork.3 → 10.6.0-fork.31

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 (100) hide show
  1. package/dist/Backend.d.ts +64 -5
  2. package/dist/Backend.d.ts.map +1 -1
  3. package/dist/Backend.js +187 -3
  4. package/dist/Backend.js.map +1 -1
  5. package/dist/Code.d.ts +14 -2
  6. package/dist/Code.d.ts.map +1 -1
  7. package/dist/Code.js +2 -2
  8. package/dist/Code.js.map +1 -1
  9. package/dist/Confect.d.ts +1 -1
  10. package/dist/Confect.d.ts.map +1 -1
  11. package/dist/Confect.js +8 -3
  12. package/dist/Confect.js.map +1 -1
  13. package/dist/Convex.d.ts +4 -1
  14. package/dist/Convex.d.ts.map +1 -1
  15. package/dist/Convex.js +10 -1
  16. package/dist/Convex.js.map +1 -1
  17. package/dist/ConvexClient.d.ts +92 -3
  18. package/dist/ConvexClient.d.ts.map +1 -1
  19. package/dist/ConvexClient.js +149 -27
  20. package/dist/ConvexClient.js.map +1 -1
  21. package/dist/CustomDomain.d.ts +156 -0
  22. package/dist/CustomDomain.d.ts.map +1 -0
  23. package/dist/CustomDomain.js +255 -0
  24. package/dist/CustomDomain.js.map +1 -0
  25. package/dist/DeployKey.js +3 -3
  26. package/dist/Deployment.d.ts +29 -3
  27. package/dist/Deployment.d.ts.map +1 -1
  28. package/dist/Deployment.js +39 -15
  29. package/dist/Deployment.js.map +1 -1
  30. package/dist/EnvironmentVariables.d.ts +76 -21
  31. package/dist/EnvironmentVariables.d.ts.map +1 -1
  32. package/dist/EnvironmentVariables.js +203 -19
  33. package/dist/EnvironmentVariables.js.map +1 -1
  34. package/dist/LogStream.d.ts +134 -0
  35. package/dist/LogStream.d.ts.map +1 -0
  36. package/dist/LogStream.js +324 -0
  37. package/dist/LogStream.js.map +1 -0
  38. package/dist/Project.js +2 -2
  39. package/dist/Providers.d.ts.map +1 -1
  40. package/dist/Providers.js +30 -15
  41. package/dist/Providers.js.map +1 -1
  42. package/dist/UsageLimit.d.ts +140 -0
  43. package/dist/UsageLimit.d.ts.map +1 -0
  44. package/dist/UsageLimit.js +145 -0
  45. package/dist/UsageLimit.js.map +1 -0
  46. package/dist/internal/CodeDeployment.d.ts +28 -1
  47. package/dist/internal/CodeDeployment.d.ts.map +1 -1
  48. package/dist/internal/CodeDeployment.js +85 -2
  49. package/dist/internal/CodeDeployment.js.map +1 -1
  50. package/dist/internal/CommandRunner.d.ts +4 -0
  51. package/dist/internal/CommandRunner.d.ts.map +1 -1
  52. package/dist/internal/CommandRunner.js +92 -6
  53. package/dist/internal/CommandRunner.js.map +1 -1
  54. package/dist/internal/FileLock.js +1 -1
  55. package/dist/internal/FunctionsDirectory.d.ts +12 -0
  56. package/dist/internal/FunctionsDirectory.d.ts.map +1 -0
  57. package/dist/internal/FunctionsDirectory.js +22 -0
  58. package/dist/internal/FunctionsDirectory.js.map +1 -0
  59. package/dist/internal/Lifecycle.d.ts +1 -0
  60. package/dist/internal/Lifecycle.d.ts.map +1 -1
  61. package/dist/internal/Lifecycle.js +24 -2
  62. package/dist/internal/Lifecycle.js.map +1 -1
  63. package/dist/internal/LocalBackend.d.ts +9 -0
  64. package/dist/internal/LocalBackend.d.ts.map +1 -1
  65. package/dist/internal/LocalBackend.js +14 -5
  66. package/dist/internal/LocalBackend.js.map +1 -1
  67. package/dist/internal/LogStream.d.ts +115 -0
  68. package/dist/internal/LogStream.d.ts.map +1 -0
  69. package/dist/internal/LogStream.js +123 -0
  70. package/dist/internal/LogStream.js.map +1 -0
  71. package/dist/internal/MountInit.d.ts +4 -5
  72. package/dist/internal/MountInit.d.ts.map +1 -1
  73. package/dist/internal/MountInit.js +17 -36
  74. package/dist/internal/MountInit.js.map +1 -1
  75. package/dist/internal/PushLock.d.ts +1 -0
  76. package/dist/internal/PushLock.d.ts.map +1 -1
  77. package/dist/internal/PushLock.js +4 -3
  78. package/dist/internal/PushLock.js.map +1 -1
  79. package/dist/internal/ResourceIdentity.js +1 -1
  80. package/dist/internal/Zip.js +1 -1
  81. package/package.json +4 -4
  82. package/src/Backend.ts +422 -12
  83. package/src/Code.ts +13 -0
  84. package/src/Confect.ts +7 -1
  85. package/src/Convex.ts +24 -1
  86. package/src/ConvexClient.ts +364 -31
  87. package/src/CustomDomain.ts +453 -0
  88. package/src/Deployment.ts +74 -12
  89. package/src/EnvironmentVariables.ts +505 -19
  90. package/src/LogStream.ts +662 -0
  91. package/src/Providers.ts +18 -0
  92. package/src/UsageLimit.ts +253 -0
  93. package/src/internal/CodeDeployment.ts +115 -0
  94. package/src/internal/CommandRunner.ts +182 -1
  95. package/src/internal/FunctionsDirectory.ts +27 -0
  96. package/src/internal/Lifecycle.ts +21 -1
  97. package/src/internal/LocalBackend.ts +9 -0
  98. package/src/internal/LogStream.ts +154 -0
  99. package/src/internal/MountInit.ts +24 -65
  100. package/src/internal/PushLock.ts +4 -1
@@ -1,32 +1,185 @@
1
- import { ConvexClient, layer as layer$1 } from "./ConvexClient.js";
1
+ import { PushLock, PushLockError } from "./internal/PushLock.js";
2
+ import { ConvexApiError, ConvexClient, layer as layer$1 } from "./ConvexClient.js";
2
3
  import { checkpointCreate, shouldAdopt } from "./internal/Lifecycle.js";
4
+ import * as Arr from "effect/Array";
5
+ import * as Output from "alchemy/Output";
3
6
  import * as Effect from "effect/Effect";
7
+ import * as Rec from "effect/Record";
8
+ import * as Redacted from "effect/Redacted";
9
+ import * as Schema from "effect/Schema";
10
+ import * as Result from "effect/Result";
4
11
  import * as Provider from "alchemy/Provider";
5
12
  import { Resource } from "alchemy/Resource";
6
13
  import * as Layer from "effect/Layer";
7
14
  import * as FetchHttpClient from "effect/http/FetchHttpClient";
8
- import * as Redacted from "effect/Redacted";
9
- import * as Schema from "effect/Schema";
10
- import * as Arr from "effect/Array";
11
- import * as Rec from "effect/Record";
15
+ import * as Config from "effect/Config";
16
+ import * as Option from "effect/Option";
17
+ import * as Duration from "effect/Duration";
18
+ import * as Predicate from "effect/Predicate";
19
+ import * as Schedule from "effect/Schedule";
12
20
  import { OwnedBySomeoneElse, Unowned } from "alchemy/AdoptPolicy";
13
21
  import { isResolved } from "alchemy/Diff";
22
+ import * as Effectable from "effect/Effectable";
14
23
  // src/EnvironmentVariables.ts
15
- const EnvironmentVariables = Resource("Convex.EnvironmentVariables");
24
+ const environmentVariables = Resource("Convex.EnvironmentVariables");
25
+ const EnvironmentVariables = Object.assign(new Proxy(environmentVariables, { apply: (target, _this, args) => {
26
+ if (args.length === 1) return Object.assign(EnvironmentVariables, args[0]);
27
+ const [id, props] = args;
28
+ return target(id, (Effect.isEffect(props) ? props : Effect.succeed(props)).pipe(Effect.flatMap((options) => Effect.fromResult(validateSafety(options)).pipe(Effect.orDie, Effect.as({
29
+ ...options,
30
+ ...options.retry === void 0 ? {} : { retry: checkedRetry(options.retry) },
31
+ ...options.lock === void 0 ? {} : { lock: checkedLock(options.lock) }
32
+ })))));
33
+ } }), Effectable.Prototype({
34
+ label: "Resource<Convex.EnvironmentVariables>",
35
+ evaluate: () => Effect.succeed(EnvironmentVariables)
36
+ }));
16
37
  var EnvironmentTargetChange = class extends Schema.TaggedError()("EnvironmentTargetChange", { url: Schema.String }) {};
38
+ var EnvironmentVariableDrift = class extends Schema.TaggedError()("EnvironmentVariableDrift", { variableName: Schema.String }) {
39
+ get message() {
40
+ return `Environment variable ${this.variableName} differs from its last managed value`;
41
+ }
42
+ };
43
+ var EnvironmentVariableUnowned = class extends Schema.TaggedError()("EnvironmentVariableUnowned", { variableName: Schema.String }) {
44
+ get message() {
45
+ return `Environment variable ${this.variableName} is neither owned nor desired`;
46
+ }
47
+ };
48
+ var EnvironmentVariablesInvalidOption = class extends Schema.TaggedError()("EnvironmentVariablesInvalidOption", { option: Schema.Literals([
49
+ "maxAttempts",
50
+ "delay",
51
+ "deploymentName"
52
+ ]) }) {
53
+ get message() {
54
+ switch (this.option) {
55
+ case "maxAttempts": return "Environment retry maxAttempts must be an integer from 1 to 10";
56
+ case "delay": return "Environment retry delay must be from 1 to 10000 milliseconds";
57
+ case "deploymentName": return "Environment lock deploymentName must contain lowercase letters or digits separated by single hyphens";
58
+ }
59
+ }
60
+ };
61
+ const validateMaxAttempts = (maxAttempts) => Number.isInteger(maxAttempts) && maxAttempts >= 1 && maxAttempts <= 10 ? Result.succeed(void 0) : Result.fail(EnvironmentVariablesInvalidOption.make({ option: "maxAttempts" }));
62
+ const validateDelay = (delay) => {
63
+ const parsed = Duration.fromInput(delay);
64
+ return Option.isSome(parsed) && Duration.toMillis(parsed.value) >= 1 && Duration.toMillis(parsed.value) <= 1e4 ? Result.succeed(parsed.value) : Result.fail(EnvironmentVariablesInvalidOption.make({ option: "delay" }));
65
+ };
66
+ const validateDeploymentName = (deploymentName) => /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(deploymentName) ? Result.succeed(void 0) : Result.fail(EnvironmentVariablesInvalidOption.make({ option: "deploymentName" }));
67
+ const validateSafety = (options) => Result.gen(function* () {
68
+ let duration;
69
+ if ("retry" in options && options.retry !== void 0 && "maxAttempts" in options.retry && "delay" in options.retry) {
70
+ if (isResolved(options.retry.maxAttempts)) yield* validateMaxAttempts(options.retry.maxAttempts);
71
+ if (isResolved(options.retry.delay)) duration = yield* validateDelay(options.retry.delay);
72
+ }
73
+ if ("lock" in options && options.lock !== void 0 && "deploymentName" in options.lock && isResolved(options.lock.deploymentName)) yield* validateDeploymentName(options.lock.deploymentName);
74
+ return duration;
75
+ });
76
+ const checkedInput = (input, validate) => {
77
+ const check = (value) => Effect.fromResult(validate(value)).pipe(Effect.orDie, Effect.as(value));
78
+ if (Config.isConfig(input)) return input.pipe(Config.mapEffect(check));
79
+ return input;
80
+ };
81
+ const checkedRetry = (input) => {
82
+ if ("maxAttempts" in input && "delay" in input) return {
83
+ ...input,
84
+ maxAttempts: checkedInput(input.maxAttempts, validateMaxAttempts),
85
+ delay: checkedInput(input.delay, validateDelay)
86
+ };
87
+ return checkedInput(input, (retry) => validateSafety({ retry }));
88
+ };
89
+ const checkedLock = (input) => {
90
+ if ("deploymentName" in input) return {
91
+ ...input,
92
+ deploymentName: checkedInput(input.deploymentName, validateDeploymentName)
93
+ };
94
+ return checkedInput(input, (lock) => validateSafety({ lock }));
95
+ };
96
+ const ownershipConflict = (variableName) => new OwnedBySomeoneElse({
97
+ message: "An existing environment variable requires explicit adoption in a separate resource.",
98
+ resourceType: EnvironmentVariables.Type,
99
+ physicalName: variableName
100
+ });
101
+ const definedVariables = (variables) => Rec.filter(variables, (value) => value !== null && value !== void 0);
102
+ const optionsForDiff = (olds, news) => {
103
+ if (!("variables" in news)) return {
104
+ ...olds,
105
+ desiredNames: void 0,
106
+ desiredVariables: void 0
107
+ };
108
+ const desiredVariables = !Output.isExpr(news.variables) && !Effect.isEffect(news.variables) && Predicate.isReadonlyObject(news.variables) ? definedVariables(news.variables) : void 0;
109
+ return {
110
+ driftPolicy: isResolved(news.driftPolicy) ? news.driftPolicy : olds.driftPolicy,
111
+ adoptMatching: isResolved(news.adoptMatching) ? news.adoptMatching : olds.adoptMatching,
112
+ unownedPolicy: isResolved(news.unownedPolicy) ? news.unownedPolicy : olds.unownedPolicy,
113
+ lock: isResolved(news.lock) ? news.lock : olds.lock,
114
+ retry: isResolved(news.retry) ? news.retry : olds.retry,
115
+ desiredVariables,
116
+ desiredNames: desiredVariables === void 0 ? void 0 : Rec.keys(desiredVariables)
117
+ };
118
+ };
17
119
  const provider = Effect.gen(function* () {
18
120
  const client = yield* ConvexClient;
121
+ const lock = yield* Effect.serviceOption(PushLock);
122
+ const withSafety = Effect.fn("EnvironmentVariables.withSafety")(function* (options, effect) {
123
+ const duration = yield* Effect.fromResult(validateSafety(options));
124
+ let attempt = effect;
125
+ if (options.retry !== void 0 && duration !== void 0) {
126
+ const { maxAttempts } = options.retry;
127
+ attempt = effect.pipe(Effect.retry({
128
+ times: maxAttempts - 1,
129
+ schedule: Schedule.spaced(duration),
130
+ while: (error) => Schema.is(ConvexApiError)(error) && error.serverCode === "OptimisticConcurrencyControlFailure"
131
+ }));
132
+ }
133
+ if (options.lock === void 0) return yield* attempt;
134
+ if (Option.isNone(lock)) return yield* PushLockError.make({
135
+ deploymentName: options.lock.deploymentName,
136
+ reason: "configuration",
137
+ missing: "PushLock"
138
+ });
139
+ return yield* lock.value.withLock(options.lock.deploymentName, attempt);
140
+ });
19
141
  const redacted = (value) => typeof value === "string" ? Redacted.make(value) : value;
20
142
  const valueAt = (variables, name) => Rec.has(variables, name) ? variables[name] : void 0;
21
143
  const select = (variables, names) => Rec.fromEntries(Arr.flatMap(names, (name) => !Rec.has(variables, name) ? [] : [[name, variables[name]]]));
22
- return {
23
- diff: Effect.fn("EnvironmentVariables.diff")(function* ({ news, output }) {
144
+ const checkDrift = (policy, output, observed, desired) => {
145
+ if (policy !== "error" || output === void 0) return Effect.void;
146
+ const desiredVariables = Predicate.isReadonlyObject(desired) && !Output.isExpr(desired) && !Effect.isEffect(desired) ? desired : void 0;
147
+ for (const name of output.ownedNames) {
148
+ const previous = valueAt(output.variables, name);
149
+ const current = valueAt(observed, name);
150
+ const wanted = desiredVariables?.[name];
151
+ if (current === void 0 && desiredVariables !== void 0 && !Rec.has(desiredVariables, name)) continue;
152
+ if (current !== void 0 && (desiredVariables === void 0 || wanted !== void 0 && !isResolved(wanted))) continue;
153
+ if (current !== void 0 && (typeof wanted === "string" || Redacted.isRedacted(wanted)) && Redacted.value(current) === (typeof wanted === "string" ? wanted : Redacted.value(wanted))) continue;
154
+ if (previous === void 0 && current === void 0) continue;
155
+ if (previous === void 0 || current === void 0 || Redacted.value(previous) !== Redacted.value(current)) return Effect.fail(EnvironmentVariableDrift.make({ variableName: name }));
156
+ }
157
+ return Effect.void;
158
+ };
159
+ const checkUnowned = (policy, output, desiredNames, observed) => {
160
+ if (policy !== "error" || desiredNames === void 0) return Effect.void;
161
+ for (const name of Rec.keys(observed)) if (output?.ownedNames.includes(name) !== true && !desiredNames.includes(name)) return Effect.fail(EnvironmentVariableUnowned.make({ variableName: name }));
162
+ return Effect.void;
163
+ };
164
+ const service = {
165
+ diff: Effect.fn("EnvironmentVariables.diff")(function* ({ olds, news, output }) {
166
+ const options = optionsForDiff(olds, news);
167
+ if (output !== void 0 && (options.driftPolicy === "error" || options.unownedPolicy === "error" || options.adoptMatching === true)) {
168
+ const observed = yield* client.listEnvironmentVariables(output.url, output.deployKey);
169
+ yield* checkDrift(options.driftPolicy, output, observed, options.desiredVariables);
170
+ if (options.adoptMatching === true && Predicate.isReadonlyObject(options.desiredVariables) && !Output.isExpr(options.desiredVariables) && !Effect.isEffect(options.desiredVariables)) for (const [name, wanted] of Rec.toEntries(options.desiredVariables)) {
171
+ const current = valueAt(observed, name);
172
+ if (!output.ownedNames.includes(name) && current !== void 0 && (typeof wanted === "string" || Redacted.isRedacted(wanted)) && Redacted.value(current) !== (typeof wanted === "string" ? wanted : Redacted.value(wanted))) return yield* ownershipConflict(name);
173
+ }
174
+ yield* checkUnowned(options.unownedPolicy, output, options.desiredNames, observed);
175
+ }
24
176
  if (!isResolved(news) || output === void 0) return;
25
177
  if (news.url !== output.url) return yield* EnvironmentTargetChange.make({ url: output.url });
26
- const names = Rec.keys(news.variables);
178
+ const desired = definedVariables(news.variables);
179
+ const names = Rec.keys(desired);
27
180
  if (names.length !== output.ownedNames.length || Arr.some(names, (name) => !output.ownedNames.includes(name))) return { action: "update" };
28
181
  const variables = yield* client.listEnvironmentVariables(news.url, news.deployKey);
29
- for (const [name, value] of Rec.toEntries(news.variables)) {
182
+ for (const [name, value] of Rec.toEntries(desired)) {
30
183
  const observed = valueAt(variables, name);
31
184
  if (observed === void 0 || Redacted.value(observed) !== Redacted.value(redacted(value))) return { action: "update" };
32
185
  }
@@ -35,7 +188,9 @@ const provider = Effect.gen(function* () {
35
188
  const url = output?.url ?? olds.url;
36
189
  if (url === void 0 || olds.deployKey === void 0) return;
37
190
  const observed = yield* client.listEnvironmentVariables(url, olds.deployKey);
38
- const ownedNames = output?.ownedNames ?? Rec.keys(olds.variables);
191
+ yield* checkDrift(olds.driftPolicy, output, observed, definedVariables(olds.variables));
192
+ yield* checkUnowned(olds.unownedPolicy, output, Rec.keys(definedVariables(olds.variables)), observed);
193
+ const ownedNames = output?.ownedNames ?? Rec.keys(definedVariables(olds.variables));
39
194
  const variables = select(observed, ownedNames);
40
195
  if (output !== void 0) return {
41
196
  ...output,
@@ -43,6 +198,10 @@ const provider = Effect.gen(function* () {
43
198
  variables
44
199
  };
45
200
  if (Rec.keys(variables).length === 0) return void 0;
201
+ if (olds.adoptMatching === true) {
202
+ for (const [name, value] of Rec.toEntries(variables)) if (Redacted.value(value) !== Redacted.value(redacted(olds.variables[name]))) return yield* ownershipConflict(name);
203
+ return;
204
+ }
46
205
  return Unowned({
47
206
  url,
48
207
  deployKey: olds.deployKey,
@@ -52,11 +211,17 @@ const provider = Effect.gen(function* () {
52
211
  });
53
212
  }),
54
213
  reconcile: Effect.fn("EnvironmentVariables.reconcile")(function* ({ fqn, instanceId, news, output }) {
214
+ news = {
215
+ ...news,
216
+ variables: definedVariables(news.variables)
217
+ };
55
218
  if (output === void 0) yield* checkpointCreate(fqn, instanceId, news);
56
219
  if (output !== void 0 && output.url !== news.url) return yield* EnvironmentTargetChange.make({ url: output.url });
57
220
  const observed = yield* client.listEnvironmentVariables(news.url, news.deployKey);
221
+ yield* checkDrift(news.driftPolicy, output, observed, news.variables);
222
+ yield* checkUnowned(news.unownedPolicy, output, Rec.keys(news.variables), observed);
58
223
  const ownedNames = Rec.keys(news.variables);
59
- if (output === void 0 && (yield* shouldAdopt(fqn))) {
224
+ if (output === void 0 && news.adoptMatching !== true && (yield* shouldAdopt(fqn))) {
60
225
  const variables = select(observed, ownedNames);
61
226
  output = {
62
227
  url: news.url,
@@ -68,10 +233,21 @@ const provider = Effect.gen(function* () {
68
233
  yield* checkpointCreate(fqn, instanceId, news, output);
69
234
  }
70
235
  const previousNames = output?.ownedNames ?? [];
71
- for (const name of ownedNames) if (!previousNames.includes(name) && valueAt(observed, name) !== void 0) return yield* new OwnedBySomeoneElse({
72
- message: "An existing environment variable requires explicit adoption in a separate resource.",
73
- resourceType: EnvironmentVariables.Type,
74
- physicalName: name
236
+ let originals = output?.originals ?? {};
237
+ for (const name of ownedNames) {
238
+ const current = valueAt(observed, name);
239
+ if (previousNames.includes(name) || current === void 0) continue;
240
+ if (news.adoptMatching === true && Redacted.value(current) === Redacted.value(redacted(news.variables[name]))) {
241
+ originals = Rec.set(originals, name, current);
242
+ yield* Effect.logInfo(`Adopted environment variable ${name}`);
243
+ } else return yield* ownershipConflict(name);
244
+ }
245
+ if (output === void 0 && news.adoptMatching === true) yield* checkpointCreate(fqn, instanceId, news, {
246
+ url: news.url,
247
+ deployKey: news.deployKey,
248
+ ownedNames,
249
+ variables: select(observed, ownedNames),
250
+ originals
75
251
  });
76
252
  const desired = Rec.fromEntries(Arr.map(Rec.toEntries(news.variables), ([name, value]) => [name, redacted(value)]));
77
253
  const changes = [];
@@ -99,12 +275,14 @@ const provider = Effect.gen(function* () {
99
275
  deployKey: news.deployKey,
100
276
  ownedNames,
101
277
  variables: desired,
102
- originals: select(output?.originals ?? {}, ownedNames)
278
+ originals: select(originals, ownedNames)
103
279
  };
104
280
  }),
105
- delete: Effect.fn("EnvironmentVariables.delete")(function* ({ output }) {
281
+ delete: Effect.fn("EnvironmentVariables.delete")(function* ({ olds, output }) {
106
282
  const observed = yield* client.listEnvironmentVariables(output.url, output.deployKey).pipe(Effect.catchTag("ConvexNotFound", () => Effect.void));
107
283
  if (observed === void 0) return;
284
+ yield* checkDrift(olds.driftPolicy, output, observed, {});
285
+ yield* checkUnowned(olds.unownedPolicy, output, Rec.keys(definedVariables(olds.variables)), observed);
108
286
  const changes = [];
109
287
  for (const name of output.ownedNames) {
110
288
  const original = valueAt(output.originals, name);
@@ -119,6 +297,12 @@ const provider = Effect.gen(function* () {
119
297
  if (changes.length > 0) yield* client.updateEnvironmentVariables(output.url, output.deployKey, changes).pipe(Effect.catchTag("ConvexNotFound", () => Effect.void));
120
298
  })
121
299
  };
300
+ return {
301
+ diff: (input) => withSafety(optionsForDiff(input.olds, input.news), service.diff(input)),
302
+ read: (input) => withSafety(input.olds, service.read(input)),
303
+ reconcile: (input) => withSafety(input.news, service.reconcile(input)),
304
+ delete: (input) => withSafety(input.olds, service.delete(input))
305
+ };
122
306
  });
123
307
  /**
124
308
  * Under `alchemy dev` variables are managed on the local backend. A backend
@@ -131,6 +315,6 @@ const localProvider = Effect.map(provider, (service) => ({
131
315
  }));
132
316
  const layer = Provider.effect(EnvironmentVariables, provider);
133
317
  const localLayer = Provider.effect(EnvironmentVariables, localProvider).pipe(Layer.provide(layer$1({ mode: "local" }).pipe(Layer.provide(FetchHttpClient.layer))));
134
- export { EnvironmentTargetChange, EnvironmentVariables, layer, localLayer, localProvider, provider };
318
+ export { EnvironmentTargetChange, EnvironmentVariableDrift, EnvironmentVariableUnowned, EnvironmentVariables, EnvironmentVariablesInvalidOption, layer, localLayer, localProvider, provider };
135
319
 
136
320
  //# sourceMappingURL=EnvironmentVariables.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EnvironmentVariables.js","names":["ConvexClient.ConvexClient","ConvexClient.layer"],"sources":["../src/EnvironmentVariables.ts"],"sourcesContent":["import { OwnedBySomeoneElse, Unowned } from \"alchemy/AdoptPolicy\";\nimport { isResolved } from \"alchemy/Diff\";\nimport * as Provider from \"alchemy/Provider\";\nimport { Resource } from \"alchemy/Resource\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as FetchHttpClient from \"effect/http/FetchHttpClient\";\nimport * as Redacted from \"effect/Redacted\";\nimport * as Schema from \"effect/Schema\";\n\nimport * as ConvexClient from \"./ConvexClient.js\";\nimport type { Providers } from \"./Providers.js\";\nimport { checkpointCreate, shouldAdopt } from \"./internal/Lifecycle.js\";\nimport * as Arr from \"effect/Array\";\nimport * as Rec from \"effect/Record\";\n\nexport interface EnvironmentVariablesProps {\n readonly url: string;\n readonly deployKey: Redacted.Redacted<string>;\n readonly variables: Readonly<\n Record<string, string | Redacted.Redacted<string>>\n >;\n}\n\nexport interface EnvironmentVariablesAttributes {\n readonly url: string;\n readonly deployKey: Redacted.Redacted<string>;\n readonly ownedNames: ReadonlyArray<string>;\n readonly variables: Readonly<Record<string, Redacted.Redacted<string>>>;\n readonly originals: Readonly<Record<string, Redacted.Redacted<string>>>;\n}\n\nexport type EnvironmentVariables = Resource<\n \"Convex.EnvironmentVariables\",\n EnvironmentVariablesProps,\n EnvironmentVariablesAttributes,\n never,\n Providers\n>;\nexport const EnvironmentVariables = Resource<EnvironmentVariables>(\n \"Convex.EnvironmentVariables\",\n);\n\nexport class EnvironmentTargetChange extends Schema.TaggedError<\n EnvironmentTargetChange,\n { readonly brand: unique symbol }\n>()(\"EnvironmentTargetChange\", { url: Schema.String }) {}\n\nexport const provider = Effect.gen(function* () {\n const client = yield* ConvexClient.ConvexClient;\n const redacted = (value: string | Redacted.Redacted<string>) =>\n typeof value === \"string\" ? Redacted.make(value) : value;\n const valueAt = (\n variables: Readonly<Record<string, Redacted.Redacted<string>>>,\n name: string,\n ) => (Rec.has(variables, name) ? variables[name] : undefined);\n const select = (\n variables: Readonly<Record<string, Redacted.Redacted<string>>>,\n names: ReadonlyArray<string>,\n ) =>\n Rec.fromEntries(\n Arr.flatMap(names, (name) =>\n !Rec.has(variables, name) ? [] : [[name, variables[name]]],\n ),\n );\n return {\n diff: Effect.fn(\"EnvironmentVariables.diff\")(function* ({ news, output }) {\n if (!isResolved(news) || output === undefined) return;\n if (news.url !== output.url)\n return yield* EnvironmentTargetChange.make({\n url: output.url,\n });\n const names = Rec.keys(news.variables);\n if (\n names.length !== output.ownedNames.length ||\n Arr.some(names, (name) => !output.ownedNames.includes(name))\n )\n return { action: \"update\" };\n const variables = yield* client.listEnvironmentVariables(\n news.url,\n news.deployKey,\n );\n for (const [name, value] of Rec.toEntries(news.variables)) {\n const observed = valueAt(variables, name);\n if (\n observed === undefined ||\n Redacted.value(observed) !== Redacted.value(redacted(value))\n )\n return { action: \"update\" };\n }\n }),\n read: Effect.fn(\"EnvironmentVariables.read\")(function* ({ olds, output }) {\n const url = output?.url ?? olds.url;\n if (url === undefined || olds.deployKey === undefined) return;\n const observed = yield* client.listEnvironmentVariables(\n url,\n olds.deployKey,\n );\n const ownedNames = output?.ownedNames ?? Rec.keys(olds.variables);\n const variables = select(observed, ownedNames);\n if (output !== undefined)\n return { ...output, deployKey: olds.deployKey, variables };\n if (Rec.keys(variables).length === 0) return undefined;\n return Unowned({\n url,\n deployKey: olds.deployKey,\n ownedNames,\n variables,\n originals: variables,\n });\n }),\n reconcile: Effect.fn(\"EnvironmentVariables.reconcile\")(function* ({\n fqn,\n instanceId,\n news,\n output,\n }) {\n if (output === undefined) yield* checkpointCreate(fqn, instanceId, news);\n if (output !== undefined && output.url !== news.url)\n return yield* EnvironmentTargetChange.make({\n url: output.url,\n });\n const observed = yield* client.listEnvironmentVariables(\n news.url,\n news.deployKey,\n );\n const ownedNames = Rec.keys(news.variables);\n if (output === undefined && (yield* shouldAdopt(fqn))) {\n const variables = select(observed, ownedNames);\n output = {\n url: news.url,\n deployKey: news.deployKey,\n ownedNames,\n variables,\n originals: variables,\n };\n yield* checkpointCreate(fqn, instanceId, news, output);\n }\n const previousNames = output?.ownedNames ?? [];\n for (const name of ownedNames) {\n if (\n !previousNames.includes(name) &&\n valueAt(observed, name) !== undefined\n )\n return yield* new OwnedBySomeoneElse({\n message:\n \"An existing environment variable requires explicit adoption in a separate resource.\",\n resourceType: EnvironmentVariables.Type,\n physicalName: name,\n });\n }\n const desired = Rec.fromEntries(\n Arr.map(Rec.toEntries(news.variables), ([name, value]) => [\n name,\n redacted(value),\n ]),\n );\n const changes: Array<{\n name: string;\n value?: Redacted.Redacted<string>;\n }> = [];\n for (const [name, value] of Rec.toEntries(desired)) {\n const current = valueAt(observed, name);\n if (\n current === undefined ||\n Redacted.value(current) !== Redacted.value(value)\n )\n changes.push({ name, value });\n }\n for (const name of previousNames) {\n if (Rec.has(desired, name)) continue;\n const original =\n output !== undefined ? valueAt(output.originals, name) : undefined;\n const current = valueAt(observed, name);\n if (original !== undefined) {\n if (\n current === undefined ||\n Redacted.value(current) !== Redacted.value(original)\n )\n changes.push({ name, value: original });\n } else if (current !== undefined) changes.push({ name });\n }\n if (changes.length > 0)\n yield* client.updateEnvironmentVariables(\n news.url,\n news.deployKey,\n changes,\n );\n return {\n url: news.url,\n deployKey: news.deployKey,\n ownedNames,\n variables: desired,\n originals: select(output?.originals ?? {}, ownedNames),\n };\n }),\n delete: Effect.fn(\"EnvironmentVariables.delete\")(function* ({ output }) {\n const observed = yield* client\n .listEnvironmentVariables(output.url, output.deployKey)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void));\n if (observed === undefined) return;\n const changes: Array<{\n name: string;\n value?: Redacted.Redacted<string>;\n }> = [];\n for (const name of output.ownedNames) {\n const original = valueAt(output.originals, name);\n const current = valueAt(observed, name);\n if (original !== undefined) {\n if (\n current === undefined ||\n Redacted.value(current) !== Redacted.value(original)\n )\n changes.push({ name, value: original });\n } else if (current !== undefined) changes.push({ name });\n }\n if (changes.length > 0)\n yield* client\n .updateEnvironmentVariables(output.url, output.deployKey, changes)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void));\n }),\n } satisfies Provider.ProviderServiceInput<EnvironmentVariables>;\n});\n\n/**\n * Under `alchemy dev` variables are managed on the local backend. A backend\n * that is not running keeps its variables in its retained data, so removing\n * them is skipped rather than failing the apply.\n */\nexport const localProvider = Effect.map(\n provider,\n (service) =>\n ({\n ...service,\n delete: (input) =>\n service.delete(input).pipe(\n Effect.catchIf(\n (error) =>\n error._tag === \"ConvexApiError\" &&\n error.code === \"TransportError\",\n () => Effect.void,\n ),\n ),\n }) satisfies Provider.ProviderServiceInput<EnvironmentVariables>,\n);\n\nexport const layer = Provider.effect(EnvironmentVariables, provider);\nexport const localLayer = Provider.effect(\n EnvironmentVariables,\n localProvider,\n).pipe(\n Layer.provide(\n ConvexClient.layer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AyB,OAAO,KAAK,OAAO,SAAS,CAAC,CACtD,KAAK,OAAO,SAAS,wBAAwB,OAAO,IAAI,CAAC;GAC5D,IAAI,aAAa,KAAA,GAAW;GAC5B,MAAM,UAGD,CAAC;GACN,KAAK,MAAM,QAAQ,OAAO,YAAY;IACpC,MAAM,WAAW,QAAQ,OAAO,WAAW,IAAI;IAC/C,MAAM,UAAU,QAAQ,UAAU,IAAI;IACtC,IAAI,aAAa,KAAA,GAEb;SAAA,YAAY,KAAA,KACZ,SAAS,MAAM,OAAO,MAAM,SAAS,MAAM,QAAQ,GAEnD,QAAQ,KAAK;MAAE;MAAM,OAAO;KAAS,CAAC;IAAA,OACnC,IAAI,YAAY,KAAA,GAAW,QAAQ,KAAK,EAAE,KAAK,CAAC;GACzD;GACA,IAAI,QAAQ,SAAS,GACnB,OAAO,OACJ,2BAA2B,OAAO,KAAK,OAAO,WAAW,OAAO,CAAC,CACjE,KAAK,OAAO,SAAS,wBAAwB,OAAO,IAAI,CAAC;EAChE,CAAC;CACH;AACF,CAAC;;;;;;AAOD,MAAa,gBAAgB,OAAO,IAClC,WACC,aACE;CACC,GAAG;CACH,SAAS,UACP,QAAQ,OAAO,KAAK,CAAC,CAAC,KACpB,OAAO,SACJ,UACC,MAAM,SAAS,oBACf,MAAM,SAAS,wBACX,OAAO,IACf,CACF;AACJ,EACJ;AAEA,MAAa,QAAQ,SAAS,OAAO,sBAAsB,QAAQ;AACnE,MAAa,aAAa,SAAS,OACjC,sBACA,aACF,CAAC,CAAC,KACA,MAAM,QACJC,QAAmB,EAAE,MAAM,QAAQ,CAAC,CAAC,CAAC,KACpC,MAAM,QAAQ,gBAAgB,KAAK,CACrC,CACF,CACF"}
1
+ {"version":3,"file":"EnvironmentVariables.js","names":["ConvexClient.ConvexClient","ConvexClient.ConvexApiError","ConvexClient.layer"],"sources":["../src/EnvironmentVariables.ts"],"sourcesContent":["import { OwnedBySomeoneElse, Unowned } from \"alchemy/AdoptPolicy\";\nimport { isResolved } from \"alchemy/Diff\";\nimport type { Input, InputProps } from \"alchemy/Input\";\nimport * as Output from \"alchemy/Output\";\nimport * as Provider from \"alchemy/Provider\";\nimport {\n Resource,\n type ResourceClass,\n type ResourceConstructor,\n} from \"alchemy/Resource\";\nimport * as Effectable from \"effect/Effectable\";\nimport * as Config from \"effect/Config\";\nimport * as Result from \"effect/Result\";\nimport * as Duration from \"effect/Duration\";\nimport * as Option from \"effect/Option\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Schedule from \"effect/Schedule\";\nimport { PushLock, PushLockError } from \"./internal/PushLock.js\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as FetchHttpClient from \"effect/http/FetchHttpClient\";\nimport * as Redacted from \"effect/Redacted\";\nimport * as Schema from \"effect/Schema\";\n\nimport * as ConvexClient from \"./ConvexClient.js\";\nimport type { Providers } from \"./Providers.js\";\nimport { checkpointCreate, shouldAdopt } from \"./internal/Lifecycle.js\";\nimport * as Arr from \"effect/Array\";\nimport * as Rec from \"effect/Record\";\n\nexport interface EnvironmentVariablesProps {\n /**\n * Refuse live owned values that differ from both the last write and the\n * desired value. Defaults to `overwrite`.\n */\n readonly driftPolicy?: \"overwrite\" | \"error\";\n /**\n * Adopt unowned desired names only when their live values match. Defaults to\n * false.\n */\n readonly adoptMatching?: boolean;\n /**\n * Refuse live names that are neither owned nor desired. Defaults to `ignore`.\n */\n readonly unownedPolicy?: \"ignore\" | \"error\";\n /**\n * Share the deployment push lock for checks and writes. Absent by default.\n */\n readonly lock?: { readonly deploymentName: string };\n /**\n * Retry write conflicts only, with 1 to 10 attempts and a delay of 1 to 10000\n * ms. Absent means one attempt.\n */\n readonly retry?: {\n readonly maxAttempts: number;\n readonly delay: Duration.Input;\n };\n readonly url: string;\n readonly deployKey: Redacted.Redacted<string>;\n readonly variables: Readonly<\n Record<string, string | Redacted.Redacted<string>>\n >;\n}\n\nexport interface EnvironmentVariablesAttributes {\n readonly url: string;\n readonly deployKey: Redacted.Redacted<string>;\n readonly ownedNames: ReadonlyArray<string>;\n readonly variables: Readonly<Record<string, Redacted.Redacted<string>>>;\n readonly originals: Readonly<Record<string, Redacted.Redacted<string>>>;\n}\n\nexport type EnvironmentVariables = Resource<\n \"Convex.EnvironmentVariables\",\n EnvironmentVariablesProps,\n EnvironmentVariablesAttributes,\n never,\n Providers\n>;\nconst environmentVariables = Resource<EnvironmentVariables>(\n \"Convex.EnvironmentVariables\",\n);\n\n// Alchemy skips provider reads for fresh resources with unresolved inputs.\nexport const EnvironmentVariables: ResourceClass<EnvironmentVariables> =\n Object.assign(\n new Proxy(environmentVariables, {\n apply: <PropsReq>(\n target: ResourceClass<EnvironmentVariables>,\n _this: unknown,\n args:\n | [methods: object]\n | [\n id: string,\n props:\n | InputProps<EnvironmentVariablesProps>\n | Effect.Effect<\n InputProps<EnvironmentVariablesProps>,\n never,\n PropsReq\n >,\n ],\n ) => {\n if (args.length === 1)\n return Object.assign(EnvironmentVariables, args[0]);\n const [id, props] = args;\n return target(\n id,\n (Effect.isEffect(props) ? props : Effect.succeed(props)).pipe(\n Effect.flatMap((options) =>\n Effect.fromResult(validateSafety(options)).pipe(\n Effect.orDie,\n Effect.as({\n ...options,\n ...(options.retry === undefined\n ? {}\n : { retry: checkedRetry(options.retry) }),\n ...(options.lock === undefined\n ? {}\n : { lock: checkedLock(options.lock) }),\n }),\n ),\n ),\n ),\n );\n },\n }),\n Effectable.Prototype<\n Effect.Effect<ResourceConstructor<EnvironmentVariables>>\n >({\n label: \"Resource<Convex.EnvironmentVariables>\",\n evaluate: () => Effect.succeed(EnvironmentVariables),\n }),\n );\n\nexport class EnvironmentTargetChange extends Schema.TaggedError<\n EnvironmentTargetChange,\n { readonly brand: unique symbol }\n>()(\"EnvironmentTargetChange\", { url: Schema.String }) {}\n\nexport class EnvironmentVariableDrift extends Schema.TaggedError<\n EnvironmentVariableDrift,\n { readonly brand: unique symbol }\n>()(\"EnvironmentVariableDrift\", { variableName: Schema.String }) {\n override get message() {\n return `Environment variable ${this.variableName} differs from its last managed value`;\n }\n}\n\nexport class EnvironmentVariableUnowned extends Schema.TaggedError<\n EnvironmentVariableUnowned,\n { readonly brand: unique symbol }\n>()(\"EnvironmentVariableUnowned\", { variableName: Schema.String }) {\n override get message() {\n return `Environment variable ${this.variableName} is neither owned nor desired`;\n }\n}\n\nexport class EnvironmentVariablesInvalidOption extends Schema.TaggedError<\n EnvironmentVariablesInvalidOption,\n { readonly brand: unique symbol }\n>()(\"EnvironmentVariablesInvalidOption\", {\n option: Schema.Literals([\"maxAttempts\", \"delay\", \"deploymentName\"]),\n}) {\n override get message() {\n switch (this.option) {\n case \"maxAttempts\":\n return \"Environment retry maxAttempts must be an integer from 1 to 10\";\n case \"delay\":\n return \"Environment retry delay must be from 1 to 10000 milliseconds\";\n case \"deploymentName\":\n return \"Environment lock deploymentName must contain lowercase letters or digits separated by single hyphens\";\n }\n }\n}\n\ntype SafetyOptions = {\n readonly retry?: EnvironmentVariablesProps[\"retry\"];\n readonly lock?: EnvironmentVariablesProps[\"lock\"];\n};\n\nconst validateMaxAttempts = (\n maxAttempts: number,\n): Result.Result<void, EnvironmentVariablesInvalidOption> =>\n Number.isInteger(maxAttempts) && maxAttempts >= 1 && maxAttempts <= 10\n ? Result.succeed(undefined)\n : Result.fail(\n EnvironmentVariablesInvalidOption.make({ option: \"maxAttempts\" }),\n );\n\nconst validateDelay = (\n delay: Duration.Input,\n): Result.Result<Duration.Duration, EnvironmentVariablesInvalidOption> => {\n const parsed = Duration.fromInput(delay);\n return Option.isSome(parsed) &&\n Duration.toMillis(parsed.value) >= 1 &&\n Duration.toMillis(parsed.value) <= 10000\n ? Result.succeed(parsed.value)\n : Result.fail(EnvironmentVariablesInvalidOption.make({ option: \"delay\" }));\n};\n\nconst validateDeploymentName = (\n deploymentName: string,\n): Result.Result<void, EnvironmentVariablesInvalidOption> =>\n /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(deploymentName)\n ? Result.succeed(undefined)\n : Result.fail(\n EnvironmentVariablesInvalidOption.make({ option: \"deploymentName\" }),\n );\n\nconst validateSafety = (\n options: Input<SafetyOptions>,\n): Result.Result<\n Duration.Duration | undefined,\n EnvironmentVariablesInvalidOption\n> =>\n Result.gen(function* () {\n let duration: Duration.Duration | undefined;\n if (\n \"retry\" in options &&\n options.retry !== undefined &&\n \"maxAttempts\" in options.retry &&\n \"delay\" in options.retry\n ) {\n if (isResolved(options.retry.maxAttempts))\n yield* validateMaxAttempts(options.retry.maxAttempts);\n if (isResolved(options.retry.delay))\n duration = yield* validateDelay(options.retry.delay);\n }\n if (\n \"lock\" in options &&\n options.lock !== undefined &&\n \"deploymentName\" in options.lock &&\n isResolved(options.lock.deploymentName)\n )\n yield* validateDeploymentName(options.lock.deploymentName);\n return duration;\n });\n\nconst checkedInput = <A>(\n input: Exclude<Input<A>, undefined>,\n validate: (\n value: A,\n ) => Result.Result<unknown, EnvironmentVariablesInvalidOption>,\n): Exclude<Input<A>, undefined> => {\n const check = (value: A) =>\n Effect.fromResult(validate(value)).pipe(Effect.orDie, Effect.as(value));\n if (Config.isConfig(input)) return input.pipe(Config.mapEffect(check));\n return input;\n};\n\nconst checkedRetry = (\n input: Exclude<Input<SafetyOptions[\"retry\"]>, undefined>,\n): Exclude<Input<SafetyOptions[\"retry\"]>, undefined> => {\n if (\"maxAttempts\" in input && \"delay\" in input)\n return {\n ...input,\n maxAttempts: checkedInput(input.maxAttempts, validateMaxAttempts),\n delay: checkedInput(input.delay, validateDelay),\n };\n return checkedInput(input, (retry) => validateSafety({ retry }));\n};\n\nconst checkedLock = (\n input: Exclude<Input<SafetyOptions[\"lock\"]>, undefined>,\n): Exclude<Input<SafetyOptions[\"lock\"]>, undefined> => {\n if (\"deploymentName\" in input)\n return {\n ...input,\n deploymentName: checkedInput(\n input.deploymentName,\n validateDeploymentName,\n ),\n };\n return checkedInput(input, (lock) => validateSafety({ lock }));\n};\n\nconst ownershipConflict = (variableName: string) =>\n new OwnedBySomeoneElse({\n message:\n \"An existing environment variable requires explicit adoption in a separate resource.\",\n resourceType: EnvironmentVariables.Type,\n physicalName: variableName,\n });\n\nconst definedVariables = <A>(variables: Readonly<Record<string, A>>) =>\n Rec.filter(variables, (value) => value !== null && value !== undefined);\n\nconst optionsForDiff = (\n olds: EnvironmentVariablesProps,\n news: Input<EnvironmentVariablesProps>,\n) => {\n if (!(\"variables\" in news))\n return { ...olds, desiredNames: undefined, desiredVariables: undefined };\n const desiredVariables =\n !Output.isExpr(news.variables) &&\n !Effect.isEffect(news.variables) &&\n Predicate.isReadonlyObject(news.variables)\n ? definedVariables<Input<string | Redacted.Redacted<string>>>(\n news.variables,\n )\n : undefined;\n return {\n driftPolicy: isResolved(news.driftPolicy)\n ? news.driftPolicy\n : olds.driftPolicy,\n adoptMatching: isResolved(news.adoptMatching)\n ? news.adoptMatching\n : olds.adoptMatching,\n unownedPolicy: isResolved(news.unownedPolicy)\n ? news.unownedPolicy\n : olds.unownedPolicy,\n lock: isResolved(news.lock) ? news.lock : olds.lock,\n retry: isResolved(news.retry) ? news.retry : olds.retry,\n desiredVariables,\n desiredNames:\n desiredVariables === undefined ? undefined : Rec.keys(desiredVariables),\n };\n};\n\nexport const provider = Effect.gen(function* () {\n const client = yield* ConvexClient.ConvexClient;\n const lock = yield* Effect.serviceOption(PushLock);\n const withSafety = Effect.fn(\"EnvironmentVariables.withSafety\")(function* <\n A,\n E,\n R,\n >(\n options: {\n readonly lock?: EnvironmentVariablesProps[\"lock\"];\n readonly retry?: EnvironmentVariablesProps[\"retry\"];\n },\n effect: Effect.Effect<A, E, R>,\n ) {\n const duration = yield* Effect.fromResult(validateSafety(options));\n let attempt = effect;\n if (options.retry !== undefined && duration !== undefined) {\n const { maxAttempts } = options.retry;\n attempt = effect.pipe(\n Effect.retry({\n times: maxAttempts - 1,\n schedule: Schedule.spaced(duration),\n while: (error) =>\n Schema.is(ConvexClient.ConvexApiError)(error) &&\n error.serverCode === \"OptimisticConcurrencyControlFailure\",\n }),\n );\n }\n if (options.lock === undefined) return yield* attempt;\n if (Option.isNone(lock))\n return yield* PushLockError.make({\n deploymentName: options.lock.deploymentName,\n reason: \"configuration\",\n missing: \"PushLock\",\n });\n return yield* lock.value.withLock(options.lock.deploymentName, attempt);\n });\n const redacted = (value: string | Redacted.Redacted<string>) =>\n typeof value === \"string\" ? Redacted.make(value) : value;\n const valueAt = (\n variables: Readonly<Record<string, Redacted.Redacted<string>>>,\n name: string,\n ) => (Rec.has(variables, name) ? variables[name] : undefined);\n const select = (\n variables: Readonly<Record<string, Redacted.Redacted<string>>>,\n names: ReadonlyArray<string>,\n ) =>\n Rec.fromEntries(\n Arr.flatMap(names, (name) =>\n !Rec.has(variables, name) ? [] : [[name, variables[name]]],\n ),\n );\n const checkDrift = (\n policy: EnvironmentVariablesProps[\"driftPolicy\"],\n output: EnvironmentVariablesAttributes | undefined,\n observed: ConvexClient.EnvironmentVariables,\n desired: Input<EnvironmentVariablesProps[\"variables\"]> | undefined,\n ) => {\n if (policy !== \"error\" || output === undefined) return Effect.void;\n const desiredVariables =\n Predicate.isReadonlyObject(desired) &&\n !Output.isExpr(desired) &&\n !Effect.isEffect(desired)\n ? desired\n : undefined;\n for (const name of output.ownedNames) {\n const previous = valueAt(output.variables, name);\n const current = valueAt(observed, name);\n const wanted = desiredVariables?.[name];\n if (\n current === undefined &&\n desiredVariables !== undefined &&\n !Rec.has(desiredVariables, name)\n )\n continue;\n if (\n current !== undefined &&\n (desiredVariables === undefined ||\n (wanted !== undefined && !isResolved(wanted)))\n )\n continue;\n if (\n current !== undefined &&\n (typeof wanted === \"string\" || Redacted.isRedacted(wanted)) &&\n Redacted.value(current) ===\n (typeof wanted === \"string\" ? wanted : Redacted.value(wanted))\n )\n continue;\n if (previous === undefined && current === undefined) continue;\n if (\n previous === undefined ||\n current === undefined ||\n Redacted.value(previous) !== Redacted.value(current)\n )\n return Effect.fail(\n EnvironmentVariableDrift.make({ variableName: name }),\n );\n }\n return Effect.void;\n };\n const checkUnowned = (\n policy: EnvironmentVariablesProps[\"unownedPolicy\"],\n output: EnvironmentVariablesAttributes | undefined,\n desiredNames: ReadonlyArray<string> | undefined,\n observed: ConvexClient.EnvironmentVariables,\n ) => {\n if (policy !== \"error\" || desiredNames === undefined) return Effect.void;\n for (const name of Rec.keys(observed)) {\n if (\n output?.ownedNames.includes(name) !== true &&\n !desiredNames.includes(name)\n )\n return Effect.fail(\n EnvironmentVariableUnowned.make({ variableName: name }),\n );\n }\n return Effect.void;\n };\n const service = {\n diff: Effect.fn(\"EnvironmentVariables.diff\")(function* ({\n olds,\n news,\n output,\n }) {\n const options = optionsForDiff(olds, news);\n if (\n output !== undefined &&\n (options.driftPolicy === \"error\" ||\n options.unownedPolicy === \"error\" ||\n options.adoptMatching === true)\n ) {\n const observed = yield* client.listEnvironmentVariables(\n output.url,\n output.deployKey,\n );\n yield* checkDrift(\n options.driftPolicy,\n output,\n observed,\n options.desiredVariables,\n );\n if (\n options.adoptMatching === true &&\n Predicate.isReadonlyObject(options.desiredVariables) &&\n !Output.isExpr(options.desiredVariables) &&\n !Effect.isEffect(options.desiredVariables)\n ) {\n for (const [name, wanted] of Rec.toEntries(\n options.desiredVariables,\n )) {\n const current = valueAt(observed, name);\n if (\n !output.ownedNames.includes(name) &&\n current !== undefined &&\n (typeof wanted === \"string\" || Redacted.isRedacted(wanted)) &&\n Redacted.value(current) !==\n (typeof wanted === \"string\" ? wanted : Redacted.value(wanted))\n )\n return yield* ownershipConflict(name);\n }\n }\n yield* checkUnowned(\n options.unownedPolicy,\n output,\n options.desiredNames,\n observed,\n );\n }\n if (!isResolved(news) || output === undefined) return;\n if (news.url !== output.url)\n return yield* EnvironmentTargetChange.make({\n url: output.url,\n });\n const desired = definedVariables(news.variables);\n const names = Rec.keys(desired);\n if (\n names.length !== output.ownedNames.length ||\n Arr.some(names, (name) => !output.ownedNames.includes(name))\n )\n return { action: \"update\" };\n const variables = yield* client.listEnvironmentVariables(\n news.url,\n news.deployKey,\n );\n for (const [name, value] of Rec.toEntries(desired)) {\n const observed = valueAt(variables, name);\n if (\n observed === undefined ||\n Redacted.value(observed) !== Redacted.value(redacted(value))\n )\n return { action: \"update\" };\n }\n }),\n read: Effect.fn(\"EnvironmentVariables.read\")(function* ({ olds, output }) {\n const url = output?.url ?? olds.url;\n if (url === undefined || olds.deployKey === undefined) return;\n const observed = yield* client.listEnvironmentVariables(\n url,\n olds.deployKey,\n );\n yield* checkDrift(\n olds.driftPolicy,\n output,\n observed,\n definedVariables(olds.variables),\n );\n yield* checkUnowned(\n olds.unownedPolicy,\n output,\n Rec.keys(definedVariables(olds.variables)),\n observed,\n );\n const ownedNames =\n output?.ownedNames ?? Rec.keys(definedVariables(olds.variables));\n const variables = select(observed, ownedNames);\n if (output !== undefined)\n return { ...output, deployKey: olds.deployKey, variables };\n if (Rec.keys(variables).length === 0) return undefined;\n if (olds.adoptMatching === true) {\n for (const [name, value] of Rec.toEntries(variables)) {\n if (\n Redacted.value(value) !==\n Redacted.value(redacted(olds.variables[name]))\n )\n return yield* ownershipConflict(name);\n }\n return undefined;\n }\n return Unowned({\n url,\n deployKey: olds.deployKey,\n ownedNames,\n variables,\n originals: variables,\n });\n }),\n reconcile: Effect.fn(\"EnvironmentVariables.reconcile\")(function* ({\n fqn,\n instanceId,\n news,\n output,\n }) {\n news = { ...news, variables: definedVariables(news.variables) };\n if (output === undefined) yield* checkpointCreate(fqn, instanceId, news);\n if (output !== undefined && output.url !== news.url)\n return yield* EnvironmentTargetChange.make({\n url: output.url,\n });\n const observed = yield* client.listEnvironmentVariables(\n news.url,\n news.deployKey,\n );\n yield* checkDrift(news.driftPolicy, output, observed, news.variables);\n yield* checkUnowned(\n news.unownedPolicy,\n output,\n Rec.keys(news.variables),\n observed,\n );\n const ownedNames = Rec.keys(news.variables);\n if (\n output === undefined &&\n news.adoptMatching !== true &&\n (yield* shouldAdopt(fqn))\n ) {\n const variables = select(observed, ownedNames);\n output = {\n url: news.url,\n deployKey: news.deployKey,\n ownedNames,\n variables,\n originals: variables,\n };\n yield* checkpointCreate(fqn, instanceId, news, output);\n }\n const previousNames = output?.ownedNames ?? [];\n let originals = output?.originals ?? {};\n for (const name of ownedNames) {\n const current = valueAt(observed, name);\n if (previousNames.includes(name) || current === undefined) continue;\n if (\n news.adoptMatching === true &&\n Redacted.value(current) ===\n Redacted.value(redacted(news.variables[name]))\n ) {\n originals = Rec.set(originals, name, current);\n yield* Effect.logInfo(`Adopted environment variable ${name}`);\n } else {\n return yield* ownershipConflict(name);\n }\n }\n if (output === undefined && news.adoptMatching === true) {\n yield* checkpointCreate(fqn, instanceId, news, {\n url: news.url,\n deployKey: news.deployKey,\n ownedNames,\n variables: select(observed, ownedNames),\n originals,\n } satisfies EnvironmentVariablesAttributes);\n }\n const desired = Rec.fromEntries(\n Arr.map(Rec.toEntries(news.variables), ([name, value]) => [\n name,\n redacted(value),\n ]),\n );\n const changes: Array<{\n name: string;\n value?: Redacted.Redacted<string>;\n }> = [];\n for (const [name, value] of Rec.toEntries(desired)) {\n const current = valueAt(observed, name);\n if (\n current === undefined ||\n Redacted.value(current) !== Redacted.value(value)\n )\n changes.push({ name, value });\n }\n for (const name of previousNames) {\n if (Rec.has(desired, name)) continue;\n const original =\n output !== undefined ? valueAt(output.originals, name) : undefined;\n const current = valueAt(observed, name);\n if (original !== undefined) {\n if (\n current === undefined ||\n Redacted.value(current) !== Redacted.value(original)\n )\n changes.push({ name, value: original });\n } else if (current !== undefined) changes.push({ name });\n }\n if (changes.length > 0)\n yield* client.updateEnvironmentVariables(\n news.url,\n news.deployKey,\n changes,\n );\n return {\n url: news.url,\n deployKey: news.deployKey,\n ownedNames,\n variables: desired,\n originals: select(originals, ownedNames),\n };\n }),\n delete: Effect.fn(\"EnvironmentVariables.delete\")(function* ({\n olds,\n output,\n }) {\n const observed = yield* client\n .listEnvironmentVariables(output.url, output.deployKey)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void));\n if (observed === undefined) return;\n yield* checkDrift(olds.driftPolicy, output, observed, {});\n yield* checkUnowned(\n olds.unownedPolicy,\n output,\n Rec.keys(definedVariables(olds.variables)),\n observed,\n );\n const changes: Array<{\n name: string;\n value?: Redacted.Redacted<string>;\n }> = [];\n for (const name of output.ownedNames) {\n const original = valueAt(output.originals, name);\n const current = valueAt(observed, name);\n if (original !== undefined) {\n if (\n current === undefined ||\n Redacted.value(current) !== Redacted.value(original)\n )\n changes.push({ name, value: original });\n } else if (current !== undefined) changes.push({ name });\n }\n if (changes.length > 0)\n yield* client\n .updateEnvironmentVariables(output.url, output.deployKey, changes)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void));\n }),\n } satisfies Provider.ProviderServiceInput<EnvironmentVariables>;\n return {\n diff: (input) =>\n withSafety(optionsForDiff(input.olds, input.news), service.diff(input)),\n read: (input) => withSafety(input.olds, service.read(input)),\n reconcile: (input) => withSafety(input.news, service.reconcile(input)),\n delete: (input) => withSafety(input.olds, service.delete(input)),\n } satisfies Provider.ProviderServiceInput<EnvironmentVariables>;\n});\n\n/**\n * Under `alchemy dev` variables are managed on the local backend. A backend\n * that is not running keeps its variables in its retained data, so removing\n * them is skipped rather than failing the apply.\n */\nexport const localProvider = Effect.map(\n provider,\n (service) =>\n ({\n ...service,\n delete: (input) =>\n service.delete(input).pipe(\n Effect.catchIf(\n (error) =>\n error._tag === \"ConvexApiError\" &&\n error.code === \"TransportError\",\n () => Effect.void,\n ),\n ),\n }) satisfies Provider.ProviderServiceInput<EnvironmentVariables>,\n);\n\nexport const layer = Provider.effect(EnvironmentVariables, provider);\nexport const localLayer = Provider.effect(\n EnvironmentVariables,\n localProvider,\n).pipe(\n Layer.provide(\n ConvexClient.layer({ mode: \"local\" }).pipe(\n Layer.provide(FetchHttpClient.layer),\n ),\n ),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA+EA,MAAM,uBAAuB,SAC3B,6BACF;AAGA,MAAa,uBACX,OAAO,OACL,IAAI,MAAM,sBAAsB,EAC9B,QACE,QACA,O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BAAgB,KAAK,CACrC,CACF,CACF"}
@@ -0,0 +1,134 @@
1
+ import * as Provider from "alchemy/Provider";
2
+ import { Resource, type ResourceClass } from "alchemy/Resource";
3
+ import * as Effect from "effect/Effect";
4
+ import * as Layer from "effect/Layer";
5
+ import * as Redacted from "effect/Redacted";
6
+ import * as Schema from "effect/Schema";
7
+ import * as ConvexClient from "./ConvexClient.js";
8
+ import type { Providers } from "./Providers.js";
9
+ type Config<A = ConvexClient.CreateLogStreamInput> = A extends {
10
+ readonly logStreamType: infer K;
11
+ } ? {
12
+ readonly kind: K;
13
+ } & Omit<A, "logStreamType"> : never;
14
+ type Keys<A> = A extends unknown ? keyof A : never;
15
+ type StrictUnion<A, All = A> = A extends unknown ? A & {
16
+ readonly [K in Exclude<Keys<All>, keyof A>]?: never;
17
+ } : never;
18
+ type NonEmptySelection<A> = A extends readonly (infer T)[] ? readonly [T, ...T[]] : A;
19
+ type NonEmptyTopics<A> = {
20
+ readonly [K in keyof A]: K extends "topics" ? NonEmptySelection<A[K]> : A[K];
21
+ };
22
+ export type LogStreamProps = StrictUnion<NonEmptyTopics<Extract<Config, {
23
+ readonly kind: "axiom" | "sentry" | "webhook";
24
+ }>>> & {
25
+ readonly deploymentUrl: string;
26
+ readonly deployKey: Redacted.Redacted<string>;
27
+ };
28
+ export interface LogStreamAttributes {
29
+ readonly id: string;
30
+ readonly kind: LogStreamProps["kind"];
31
+ readonly hmacSecret?: Redacted.Redacted<string>;
32
+ }
33
+ export type LogStream = Resource<"Convex.LogStream", LogStreamProps, LogStreamAttributes, never, Providers>;
34
+ export declare const LogStream: ResourceClass<LogStream>;
35
+ declare const LogStreamNotEnabled_base: Schema.Class<LogStreamNotEnabled, Schema.TaggedStruct<"LogStreamNotEnabled", {
36
+ readonly kind: Schema.String;
37
+ readonly message: Schema.String;
38
+ }>, import("effect/Cause").YieldableError & {
39
+ readonly brand: unique symbol;
40
+ }>;
41
+ export declare class LogStreamNotEnabled extends LogStreamNotEnabled_base {
42
+ }
43
+ declare const LogStreamRecoveryRequired_base: Schema.Class<LogStreamRecoveryRequired, Schema.TaggedStruct<"LogStreamRecoveryRequired", {
44
+ readonly kind: Schema.String;
45
+ readonly ids: Schema.$Array<Schema.String>;
46
+ readonly message: Schema.String;
47
+ }>, import("effect/Cause").YieldableError & {
48
+ readonly brand: unique symbol;
49
+ }>;
50
+ export declare class LogStreamRecoveryRequired extends LogStreamRecoveryRequired_base {
51
+ }
52
+ declare const LogStreamDrift_base: Schema.Class<LogStreamDrift, Schema.TaggedStruct<"LogStreamDrift", {
53
+ readonly id: Schema.String;
54
+ readonly kind: Schema.String;
55
+ readonly message: Schema.String;
56
+ }>, import("effect/Cause").YieldableError & {
57
+ readonly brand: unique symbol;
58
+ }>;
59
+ export declare class LogStreamDrift extends LogStreamDrift_base {
60
+ }
61
+ declare const LogStreamInvalidUrl_base: Schema.Class<LogStreamInvalidUrl, Schema.TaggedStruct<"LogStreamInvalidUrl", {
62
+ readonly message: Schema.String;
63
+ }>, import("effect/Cause").YieldableError & {
64
+ readonly brand: unique symbol;
65
+ }>;
66
+ export declare class LogStreamInvalidUrl extends LogStreamInvalidUrl_base {
67
+ }
68
+ declare const LogStreamUrlRequiresRedacted_base: Schema.Class<LogStreamUrlRequiresRedacted, Schema.TaggedStruct<"LogStreamUrlRequiresRedacted", {
69
+ readonly message: Schema.String;
70
+ }>, import("effect/Cause").YieldableError & {
71
+ readonly brand: unique symbol;
72
+ }>;
73
+ export declare class LogStreamUrlRequiresRedacted extends LogStreamUrlRequiresRedacted_base {
74
+ }
75
+ declare const LogStreamEmptyTopics_base: Schema.Class<LogStreamEmptyTopics, Schema.TaggedStruct<"LogStreamEmptyTopics", {
76
+ readonly kind: Schema.String;
77
+ readonly message: Schema.String;
78
+ }>, import("effect/Cause").YieldableError & {
79
+ readonly brand: unique symbol;
80
+ }>;
81
+ export declare class LogStreamEmptyTopics extends LogStreamEmptyTopics_base {
82
+ }
83
+ export declare const provider: Effect.Effect<{
84
+ diff: (args_0: {
85
+ id: string;
86
+ fqn: string;
87
+ instanceId: string;
88
+ olds: LogStreamProps;
89
+ news: import("alchemy").Input<LogStreamProps>;
90
+ oldBindings: import("alchemy").ResourceBinding<never>[];
91
+ newBindings: import("alchemy").Input<import("alchemy").ResourceBinding<never>[]>;
92
+ output: LogStreamAttributes | undefined;
93
+ }) => Effect.Effect<{
94
+ action: "update";
95
+ } | {
96
+ action: "replace";
97
+ } | undefined, LogStreamDrift | LogStreamEmptyTopics | LogStreamInvalidUrl | LogStreamNotEnabled | LogStreamRecoveryRequired | LogStreamUrlRequiresRedacted | import("alchemy/State/State").StateStoreError | ConvexClient.ConvexClientError, never>;
98
+ read: (args_0: {
99
+ id: string;
100
+ fqn: string;
101
+ instanceId: string;
102
+ olds: LogStreamProps;
103
+ output: LogStreamAttributes | undefined;
104
+ previous?: LogStreamAttributes;
105
+ }) => Effect.Effect<{
106
+ hmacSecret?: Redacted.Redacted<string>;
107
+ id: string;
108
+ kind: "axiom" | "sentry" | "webhook";
109
+ } | undefined, LogStreamDrift | LogStreamEmptyTopics | LogStreamInvalidUrl | LogStreamNotEnabled | LogStreamRecoveryRequired | LogStreamUrlRequiresRedacted | ConvexClient.ConvexClientError, never>;
110
+ reconcile: (args_0: {
111
+ id: string;
112
+ fqn: string;
113
+ instanceId: string;
114
+ news: LogStreamProps;
115
+ olds: LogStreamProps | undefined;
116
+ output: LogStreamAttributes | undefined;
117
+ session: import("alchemy/Report").ScopedPlanStatusSession;
118
+ bindings: import("alchemy").ResourceBinding<never>[];
119
+ }) => Effect.Effect<LogStreamAttributes, import("./internal/Lifecycle.js").LifecycleStateError | LogStreamDrift | LogStreamEmptyTopics | LogStreamInvalidUrl | LogStreamNotEnabled | LogStreamRecoveryRequired | LogStreamUrlRequiresRedacted | import("alchemy/State/State").StateStoreError | ConvexClient.ConvexClientError, never>;
120
+ delete: (args_0: {
121
+ id: string;
122
+ fqn: string;
123
+ instanceId: string;
124
+ olds: LogStreamProps;
125
+ output: LogStreamAttributes;
126
+ session: import("alchemy/Report").ScopedPlanStatusSession;
127
+ bindings: import("alchemy").ResourceBinding<never>[];
128
+ force?: boolean;
129
+ }) => Effect.Effect<void, ConvexClient.ConvexApiError | ConvexClient.ConvexConflict | LogStreamRecoveryRequired, never>;
130
+ }, never, ConvexClient.ConvexClient>;
131
+ export declare const layer: Layer.Layer<Provider.Provider<LogStream>, never, ConvexClient.ConvexClient>;
132
+ export declare const localLayer: Layer.Layer<Provider.Provider<LogStream>, never, never>;
133
+ export {};
134
+ //# sourceMappingURL=LogStream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LogStream.d.ts","sources":["../src/LogStream.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EACL,QAAQ,EACR,KAAK,aAAa,EAEnB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAG5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIhD,KAAK,MAAM,CAAC,CAAC,GAAG,YAAY,CAAC,oBAAoB,IAAI,CAAC,SAAS;IAC7D,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;CACjC,GACG;IAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG,IAAI,CAAC,CAAC,EAAE,eAAe,CAAC,GAC/C,KAAK,CAAC;AACV,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC;AACnD,KAAK,WAAW,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,S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