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

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/dist/Backend.d.ts CHANGED
@@ -1,18 +1,23 @@
1
1
  import * as Env from "@confect/core/Env";
2
2
  import * as Manifest from "@confect/core/Manifest";
3
- import type { Input } from "alchemy/Input";
3
+ import type { Input, InputProps } from "alchemy/Input";
4
4
  import * as Output from "alchemy/Output";
5
5
  import * as Effect from "effect/Effect";
6
6
  import * as Redacted from "effect/Redacted";
7
7
  import * as Schema from "effect/Schema";
8
8
  import { Code } from "./Code.js";
9
- import { EnvironmentVariables } from "./EnvironmentVariables.js";
9
+ import { EnvironmentVariables, type EnvironmentVariablesProps } from "./EnvironmentVariables.js";
10
10
  interface CommonProps {
11
11
  readonly deployment: {
12
12
  readonly name: Input<string>;
13
13
  readonly url: Input<string>;
14
14
  };
15
15
  readonly deployKey: Input<Redacted.Redacted<string>>;
16
+ /**
17
+ * Safety options for managed environment values. Defaults to the resource
18
+ * defaults.
19
+ */
20
+ readonly environment?: InputProps<Omit<EnvironmentVariablesProps, "url" | "deployKey" | "variables">>;
16
21
  readonly cwd?: string;
17
22
  }
18
23
  type Environment<M extends Manifest.Manifest> = {
@@ -1 +1 @@
1
- {"version":3,"file":"Backend.d.ts","sources":["../src/Backend.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,mBAAmB,CAAC;AACzC,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,IAAI,EAAE,MAAM,WA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AAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;CACtD;;;;;6CAgFA,CAAC"}
package/dist/Backend.js CHANGED
@@ -192,6 +192,7 @@ const backend = (id, props) => Namespace.push(id, Effect.gen(function* () {
192
192
  ...promoted
193
193
  };
194
194
  const environment = variables === void 0 || props.env === void 0 && props.automatic === void 0 && Rec.keys(variables).length === 0 ? void 0 : yield* EnvironmentVariables("Environment", {
195
+ ...props.environment,
195
196
  url: props.deployment.url,
196
197
  deployKey: props.deployKey,
197
198
  variables
@@ -1 +1 @@
1
- {"version":3,"file":"Backend.js","names":[],"sources":["../src/Backend.ts"],"sourcesContent":["import * as Arr from \"effect/Array\";\nimport * as Env from \"@confect/core/Env\";\nimport * as Manifest from \"@confect/core/Manifest\";\nimport type { Input } from \"alchemy/Input\";\nimport * as Namespace from \"alchemy/Namespace\";\nimport * as Output from \"alchemy/Output\";\nimport * as Effect from \"effect/Effect\";\nimport * as Rec from \"effect/Record\";\nimport * as Redacted from \"effect/Redacted\";\nimport * as Schema from \"effect/Schema\";\nimport * as Result from \"effect/Result\";\nimport { Code } from \"./Code.js\";\nimport { EnvironmentVariables } from \"./EnvironmentVariables.js\";\n\ninterface CommonProps {\n readonly deployment: {\n readonly name: Input<string>;\n readonly url: Input<string>;\n };\n readonly deployKey: Input<Redacted.Redacted<string>>;\n readonly cwd?: string;\n}\n\ntype Environment<M extends Manifest.Manifest> = {\n readonly [K in keyof Manifest.Values<M>]: Input<\n Exclude<Manifest.Values<M>[K], undefined>\n >;\n};\n\ntype MountSettings<M extends Manifest.Manifest> = {\n readonly [K in keyof Manifest.Mounts<M>]: {\n readonly [S in keyof NonNullable<Manifest.Mounts<M>[K]>]: Input<\n Exclude<NonNullable<Manifest.Mounts<M>[K]>[S], undefined>\n >;\n };\n};\n\ntype AutomaticValues<M extends Manifest.Manifest> = {\n readonly [K in keyof Manifest.Automatic<M>]: Input<Manifest.Automatic<M>[K]>;\n};\n\n/**\n * Inputs for a backend deployment. An input Effect or Config may be evaluated\n * several times in plan and again in apply, more often for a provider selector\n * and its settings. It must be free of side effects and return the same value\n * every time. Otherwise, a choice can be written without a setting it\n * requires.\n */\nexport type BackendProps<M extends Manifest.Manifest | undefined = undefined> =\n CommonProps &\n (M extends Manifest.Manifest\n ? { readonly manifest: M } & ({} extends Manifest.Values<M>\n ? { readonly env?: Environment<NoInfer<M>> }\n : { readonly env: Environment<NoInfer<M>> }) &\n ({} extends Manifest.Mounts<M>\n ? { readonly mounts?: MountSettings<NoInfer<M>> }\n : { readonly mounts: MountSettings<NoInfer<M>> }) &\n ({} extends Manifest.Automatic<M>\n ? { readonly automatic?: AutomaticValues<NoInfer<M>> }\n : { readonly automatic: AutomaticValues<NoInfer<M>> })\n : {\n readonly manifest?: never;\n readonly mounts?: never;\n readonly automatic?: never;\n readonly env?: Readonly<\n Record<string, Input<string | Redacted.Redacted<string>>>\n >;\n });\n\n/**\n * Deploy a declared backend with env typed by its generated manifest.\n */\nexport function Backend<\n const M extends Manifest.Manifest,\n const E extends Environment<NoInfer<M>> = Environment<NoInfer<M>>,\n const S extends MountSettings<NoInfer<M>> = MountSettings<NoInfer<M>>,\n>(\n id: string,\n props: BackendProps<M> & {\n readonly env?: E &\n Readonly<Record<Exclude<keyof E, keyof Environment<M>>, never>>;\n readonly mounts?: S &\n Readonly<Record<Exclude<keyof S, keyof M[\"mounts\"]>, never>>;\n },\n): ReturnType<typeof backend>;\nexport function Backend(\n id: string,\n props: BackendProps,\n): ReturnType<typeof backend>;\nexport function Backend(\n id: string,\n props: CommonProps & {\n readonly manifest?: Manifest.Manifest;\n readonly env?: Settings;\n readonly automatic?: Variables;\n readonly mounts?: Readonly<Record<string, Settings>>;\n },\n): ReturnType<typeof backend> {\n return backend(id, props);\n}\n\ntype Settings = Readonly<\n Record<string, Input<string | Redacted.Redacted<string> | Env.ProviderChoice>>\n>;\n\ntype Variables = Readonly<\n Record<string, Input<string | Redacted.Redacted<string>>>\n>;\n\nexport class InvalidAutomaticSetting extends Schema.TaggedError<\n InvalidAutomaticSetting,\n { readonly brand: unique symbol }\n>()(\"InvalidAutomaticSetting\", {\n slot: Schema.String,\n reason: Schema.Literals([\n \"NotAutomatic\",\n \"Missing\",\n \"InvalidValue\",\n \"PlainSecret\",\n ]),\n}) {\n override get message(): string {\n if (this.reason === \"PlainSecret\")\n return `${this.slot} is a plain string. Wrap this secret with Redacted.make before passing it in Backend.automatic.`;\n if (this.reason === \"InvalidValue\")\n return `${this.slot} has a value that does not match its manifest slot. Supply a string of the declared kind in Backend.automatic; secret slots require a Redacted string and literals slots require one of their values.`;\n return this.reason === \"NotAutomatic\"\n ? `${this.slot} is not declared automatic in manifest.env. Supply only automatic slots in Backend.automatic; put application values in Backend.env.`\n : `${this.slot} is declared automatic in manifest.env but has no value. Supply it in Backend.automatic.`;\n }\n}\n\nconst automaticVariables = (\n manifest: Manifest.Manifest,\n supplied: Variables,\n): Result.Result<Variables, InvalidAutomaticSetting> =>\n Result.gen(function* () {\n for (const slot of Rec.keys(supplied)) {\n if (\n !Rec.has(manifest.env, slot) ||\n manifest.env[slot]?.automatic !== true\n )\n return yield* Result.fail(\n InvalidAutomaticSetting.make({ slot, reason: \"NotAutomatic\" }),\n );\n }\n for (const [slot, descriptor] of Rec.toEntries(manifest.env)) {\n if (\n descriptor.automatic === true &&\n missing(Rec.has(supplied, slot) ? supplied[slot] : undefined)\n )\n return yield* Result.fail(\n InvalidAutomaticSetting.make({ slot, reason: \"Missing\" }),\n );\n }\n return supplied;\n });\n\nconst missing = (value: unknown): boolean =>\n value === undefined ||\n value === null ||\n value === \"\" ||\n (Redacted.isRedacted(value) && Redacted.value(value) === \"\");\n\n/**\n * A provider choice validated and encoded with the schema the handler decodes\n * it with, after refusing a choice that names a provider whose required setting\n * is unset. A setting belongs to the selector its tag names.\n */\nconst settleChoice = (\n at: string,\n key: string,\n selector: Env.Descriptor & { readonly kind: \"providers\" },\n slots: Readonly<Record<string, Env.Descriptor>>,\n supplied: Readonly<Record<string, unknown>>,\n value: unknown,\n) =>\n Effect.gen(function* () {\n if (selector.optional && missing(value)) return undefined;\n const invalid = InvalidMountSetting.make({\n mount: at,\n slot: key,\n reason: \"InvalidChoice\",\n });\n const schema = Env.providerChoice(selector.values);\n const choice = yield* Schema.decodeUnknownEffect(Schema.toType(schema))(\n value,\n ).pipe(Effect.mapError(() => invalid));\n const named = Env.chosen(choice);\n for (const [slot, other] of Rec.toEntries(slots)) {\n if (\n other.provider?.selector === key &&\n other.provider.required &&\n named.includes(other.provider.name) &&\n missing(Rec.has(supplied, slot) ? supplied[slot] : undefined)\n )\n return yield* InvalidMountSetting.make({\n mount: at,\n slot,\n reason: \"Missing\",\n });\n }\n return yield* Schema.encodeUnknownEffect(schema)(choice).pipe(\n Effect.mapError(() => invalid),\n );\n });\n\n/**\n * Normalize all accepted Input forms without resolving resource dependencies.\n * Redacted values remain opaque; arrays and choice records retain their shape.\n */\nconst normalize = (value: unknown): unknown => {\n if (Output.isOutput(value)) return value;\n if (Effect.isEffect(value)) {\n // oxlint-disable-next-line effecttsgo/any-unknown-in-error-context -- Input admits Effects with arbitrary errors and requirements; this boundary preserves requirements on the Output and converts failures to defects.\n return value.pipe(Effect.orDie, Output.fromEffect);\n }\n if (value === null || typeof value !== \"object\" || Redacted.isRedacted(value))\n return value;\n if (Arr.isArray(value)) {\n const inputs = Arr.map(value, normalize);\n return Arr.some(inputs, Output.isOutput)\n ? Output.all(...Arr.map(inputs, (input) => Output.asOutput(input)))\n : inputs;\n }\n const entries = Arr.map(\n Rec.toEntries(value),\n ([key, input]) => [key, normalize(input)] as const,\n );\n const assemble = (resolved: ReadonlyArray<unknown>) =>\n Rec.fromEntries(Arr.map(entries, ([key], index) => [key, resolved[index]]));\n const inputs = Arr.map(entries, ([, input]) => input);\n return Arr.some(inputs, Output.isOutput)\n ? Output.map(\n Output.all(...Arr.map(inputs, (input) => Output.asOutput(input))),\n assemble,\n )\n : assemble(inputs);\n};\n\n/**\n * Each supplied slot keeps its input edges. A tagged setting also reads its\n * selector's input, and a selector reads only its own tagged settings.\n */\nconst supplySettings = <E>(\n at: string,\n slots: Readonly<Record<string, Env.Descriptor>>,\n supplied: Readonly<Record<string, unknown>>,\n invalid: (\n slot: string,\n reason: \"Missing\" | \"InvalidValue\" | \"PlainSecret\",\n ) => E,\n) =>\n Effect.gen(function* () {\n const normalized = Rec.map(supplied, normalize);\n const entries: Array<[string, unknown]> = [];\n const settle = (\n key: string,\n descriptor: Env.Descriptor,\n value: unknown,\n choice?: unknown,\n ) =>\n Effect.gen(function* () {\n if (missing(value)) {\n const provider = descriptor.provider;\n const selector =\n provider === undefined ? undefined : slots[provider.selector];\n if (\n provider?.required === true &&\n selector?.kind === \"providers\" &&\n !missing(choice)\n )\n yield* settleChoice(\n at,\n provider.selector,\n selector,\n { [key]: descriptor },\n { [key]: value },\n choice,\n );\n if (!descriptor.optional)\n return yield* Effect.fail(invalid(key, \"Missing\"));\n return undefined;\n }\n if (descriptor.kind === \"secret\" && typeof value === \"string\")\n return yield* Effect.fail(invalid(key, \"PlainSecret\"));\n const valid =\n descriptor.kind === \"secret\"\n ? Redacted.isRedacted(value) &&\n typeof Redacted.value(value) === \"string\"\n : descriptor.kind === \"providers\" ||\n (typeof value === \"string\" &&\n (descriptor.kind !== \"literals\" ||\n descriptor.values.includes(value)));\n if (!valid) return yield* Effect.fail(invalid(key, \"InvalidValue\"));\n return value;\n });\n for (const [key, descriptor] of Rec.toEntries(slots)) {\n const value = Rec.has(normalized, key) ? normalized[key] : undefined;\n const choice =\n descriptor.provider === undefined ||\n !Rec.has(normalized, descriptor.provider.selector)\n ? undefined\n : normalized[descriptor.provider.selector];\n const checked =\n Output.isOutput(value) || Output.isOutput(choice)\n ? Output.all(Output.asOutput(value), Output.asOutput(choice)).pipe(\n Output.mapEffect(([resolved, selected]) =>\n settle(key, descriptor, resolved, selected).pipe(Effect.orDie),\n ),\n )\n : yield* settle(key, descriptor, value, choice);\n if (checked !== undefined) entries.push([key, checked]);\n }\n const settings = Rec.fromEntries(entries);\n for (const [key, descriptor] of Rec.toEntries(slots)) {\n if (descriptor.kind !== \"providers\" || !Rec.has(settings, key)) continue;\n const value = settings[key];\n const tagged = Rec.filter(\n settings,\n (_, slot) => slots[slot]?.provider?.selector === key,\n );\n const check = (\n choice: unknown,\n resolved: Readonly<Record<string, unknown>>,\n ) => settleChoice(at, key, descriptor, slots, resolved, choice);\n const inputs = normalize({ value, tagged });\n settings[key] = Output.isOutput(inputs)\n ? inputs.pipe(\n Output.mapEffect(\n (resolved: {\n readonly value: unknown;\n readonly tagged: Readonly<Record<string, unknown>>;\n }) => check(resolved.value, resolved.tagged).pipe(Effect.orDie),\n ),\n )\n : yield* check(value, tagged);\n }\n return settings as Record<string, Variables[string]>;\n });\n\nexport class InvalidMountSetting extends Schema.TaggedError<\n InvalidMountSetting,\n { readonly brand: unique symbol }\n>()(\"InvalidMountSetting\", {\n mount: Schema.String,\n slot: Schema.optional(Schema.String),\n reason: Schema.Literals([\n \"UnknownMount\",\n \"NotOpen\",\n \"Missing\",\n \"PlainSecret\",\n \"InvalidChoice\",\n \"InvalidValue\",\n ]),\n}) {\n override get message() {\n const at =\n this.slot === undefined ? this.mount : `${this.mount}.${this.slot}`;\n const location = this.mount === \"app\" ? \"Backend.env\" : \"Backend.mounts\";\n const remedy = {\n UnknownMount:\n \"This mount is not listed. Use a mount name from manifest.mounts.\",\n NotOpen:\n \"This slot is not open. Supply only slots listed in this mount's manifest env.\",\n Missing: `This required slot is missing. Supply this required slot in ${location}.`,\n PlainSecret: `This secret is a plain string. Wrap this secret with Redacted.make before passing it in ${location}.`,\n InvalidValue:\n \"This value does not match its manifest slot. Supply a string of the declared kind; secret slots require a Redacted string and literals slots require one of their values.\",\n InvalidChoice:\n \"This provider choice is one the component would refuse. Name one of the providers this selector offers, or a failover or pool of them.\",\n };\n return `${at}: ${remedy[this.reason]}`;\n }\n}\n\n/**\n * Each mount's settings under the deployment variable the manifest names for\n * it, refusing a manifest that does not decode, a mount or slot the manifest\n * does not list as open, a missing required slot, a plain string for a secret\n * and a provider choice the component would refuse.\n */\nexport const mountVariables = (\n input: Manifest.Manifest,\n mounts: Readonly<Record<string, Settings>>,\n): Effect.Effect<\n Record<string, Variables[string]>,\n InvalidMountSetting | Manifest.UnsupportedManifestFormat\n> =>\n Effect.gen(function* () {\n const manifest = yield* Effect.fromResult(\n Manifest.decode(input, \"confect/_generated/manifest.ts\"),\n );\n const variables: Record<string, Variables[string]> = {};\n for (const mount of Rec.keys(mounts)) {\n if (!Rec.has(manifest.mounts, mount))\n return yield* InvalidMountSetting.make({\n mount,\n reason: \"UnknownMount\",\n });\n }\n for (const [mount, entry] of Rec.toEntries(manifest.mounts)) {\n const supplied =\n (Rec.has(mounts, mount) ? mounts[mount] : undefined) ?? {};\n for (const slot of Rec.keys(supplied)) {\n if (!Rec.has(entry.env, slot))\n return yield* InvalidMountSetting.make({\n mount,\n slot,\n reason: \"NotOpen\",\n });\n }\n const settings = yield* supplySettings(\n mount,\n entry.env,\n supplied,\n (slot, reason) => InvalidMountSetting.make({ mount, slot, reason }),\n );\n for (const [slot, value] of Rec.toEntries(settings)) {\n variables[entry.env[slot]!.variable] = value;\n }\n }\n return variables;\n });\n\nconst backend = (\n id: string,\n props: CommonProps & {\n readonly manifest?: Manifest.Manifest;\n readonly env?: Settings;\n readonly automatic?: Variables;\n readonly mounts?: Readonly<Record<string, Settings>>;\n },\n) =>\n Namespace.push(\n id,\n Effect.gen(function* () {\n const manifest =\n props.manifest === undefined\n ? undefined\n : yield* Effect.fromResult(\n Manifest.decode(props.manifest, \"confect/_generated/manifest.ts\"),\n ).pipe(Effect.orDie);\n const promoted =\n manifest === undefined\n ? {}\n : yield* mountVariables(manifest, props.mounts ?? {}).pipe(\n Effect.orDie,\n );\n const automaticInput =\n manifest === undefined\n ? undefined\n : yield* Effect.fromResult(\n automaticVariables(manifest, props.automatic ?? {}),\n ).pipe(Effect.orDie);\n const automatic =\n manifest === undefined || automaticInput === undefined\n ? undefined\n : yield* supplySettings(\n \"app\",\n Rec.filter(manifest.env, (slot) => slot.automatic === true),\n automaticInput,\n (slot, reason) => InvalidAutomaticSetting.make({ slot, reason }),\n ).pipe(Effect.orDie);\n const env =\n manifest === undefined\n ? props.env\n : yield* supplySettings(\n \"app\",\n Rec.filter(manifest.env, (slot) => slot.automatic !== true),\n props.env ?? {},\n (slot, reason) =>\n InvalidMountSetting.make({\n mount: \"app\",\n slot,\n reason,\n }),\n ).pipe(Effect.orDie);\n const variables =\n Rec.keys(promoted).length === 0 && props.automatic === undefined\n ? env\n : { ...env, ...automatic, ...promoted };\n const environment =\n variables === undefined ||\n (props.env === undefined &&\n props.automatic === undefined &&\n Rec.keys(variables).length === 0)\n ? undefined\n : yield* EnvironmentVariables(\"Environment\", {\n url: props.deployment.url,\n deployKey: props.deployKey,\n variables: variables as Variables,\n });\n const code = yield* Code(\"Code\", {\n deployment: {\n name: props.deployment.name,\n url:\n environment !== undefined\n ? Output.map(\n Output.all(environment.variables, environment.url),\n ([, url]) => url,\n )\n : props.deployment.url,\n },\n deployKey: props.deployKey,\n ...(props.cwd === undefined ? {} : { cwd: props.cwd }),\n ...(manifest === undefined ? {} : { manifestDigest: manifest.digest }),\n prepare: { command: \"confect\", args: [\"codegen\"] },\n });\n return { code, environment, name: code.name, url: code.url };\n }),\n );\n"],"mappings":";;;;;;;;;;;;;AAyFA,SAAgB,QACd,IACA,OAM4B;CAC5B,OAAO,QAAQ,IAAI,KAAK;AAC1B;AAUA,IAAa,0BAAb,cAA6C,OAAO,YAGlD,CAAC,CAAC,2BAA2B;CAC7B,MAAM,OAAO;CACb,QAAQ,OAAO,SAAS;EACtB;EACA;EACA;EACA;CACF,CAAC;AACH,CAAC,CAAC,CAAC;CACD,IAAa,UAAkB;EAC7B,IAAI,KAAK,WAAW,eAClB,OAAO,GAAG,KAAK,KAAK;EACtB,IAAI,KAAK,WAAW,gBAClB,OAAO,GAAG,KAAK,KAAK;EACtB,OAAO,KAAK,WAAW,iBACnB,GAAG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,CAAC,IAAI,EAAE,gBAAgB,SAAS,OAAO;EACpE,SAAS;GAAE,SAAS;GAAW,MAAM,CAAC,SAAS;EAAE;CACnD,CAAC;CACD,OAAO;EAAE;EAAM;EAAa,MAAM,KAAK;EAAM,KAAK,KAAK;CAAI;AAC7D,CAAC,CACH"}
1
+ {"version":3,"file":"Backend.js","names":[],"sources":["../src/Backend.ts"],"sourcesContent":["import * as Arr from \"effect/Array\";\nimport * as Env from \"@confect/core/Env\";\nimport * as Manifest from \"@confect/core/Manifest\";\nimport type { Input, InputProps } from \"alchemy/Input\";\nimport * as Namespace from \"alchemy/Namespace\";\nimport * as Output from \"alchemy/Output\";\nimport * as Effect from \"effect/Effect\";\nimport * as Rec from \"effect/Record\";\nimport * as Redacted from \"effect/Redacted\";\nimport * as Schema from \"effect/Schema\";\nimport * as Result from \"effect/Result\";\nimport { Code } from \"./Code.js\";\nimport {\n EnvironmentVariables,\n type EnvironmentVariablesProps,\n} from \"./EnvironmentVariables.js\";\n\ninterface CommonProps {\n readonly deployment: {\n readonly name: Input<string>;\n readonly url: Input<string>;\n };\n readonly deployKey: Input<Redacted.Redacted<string>>;\n /**\n * Safety options for managed environment values. Defaults to the resource\n * defaults.\n */\n readonly environment?: InputProps<\n Omit<EnvironmentVariablesProps, \"url\" | \"deployKey\" | \"variables\">\n >;\n readonly cwd?: string;\n}\n\ntype Environment<M extends Manifest.Manifest> = {\n readonly [K in keyof Manifest.Values<M>]: Input<\n Exclude<Manifest.Values<M>[K], undefined>\n >;\n};\n\ntype MountSettings<M extends Manifest.Manifest> = {\n readonly [K in keyof Manifest.Mounts<M>]: {\n readonly [S in keyof NonNullable<Manifest.Mounts<M>[K]>]: Input<\n Exclude<NonNullable<Manifest.Mounts<M>[K]>[S], undefined>\n >;\n };\n};\n\ntype AutomaticValues<M extends Manifest.Manifest> = {\n readonly [K in keyof Manifest.Automatic<M>]: Input<Manifest.Automatic<M>[K]>;\n};\n\n/**\n * Inputs for a backend deployment. An input Effect or Config may be evaluated\n * several times in plan and again in apply, more often for a provider selector\n * and its settings. It must be free of side effects and return the same value\n * every time. Otherwise, a choice can be written without a setting it\n * requires.\n */\nexport type BackendProps<M extends Manifest.Manifest | undefined = undefined> =\n CommonProps &\n (M extends Manifest.Manifest\n ? { readonly manifest: M } & ({} extends Manifest.Values<M>\n ? { readonly env?: Environment<NoInfer<M>> }\n : { readonly env: Environment<NoInfer<M>> }) &\n ({} extends Manifest.Mounts<M>\n ? { readonly mounts?: MountSettings<NoInfer<M>> }\n : { readonly mounts: MountSettings<NoInfer<M>> }) &\n ({} extends Manifest.Automatic<M>\n ? { readonly automatic?: AutomaticValues<NoInfer<M>> }\n : { readonly automatic: AutomaticValues<NoInfer<M>> })\n : {\n readonly manifest?: never;\n readonly mounts?: never;\n readonly automatic?: never;\n readonly env?: Readonly<\n Record<string, Input<string | Redacted.Redacted<string>>>\n >;\n });\n\n/**\n * Deploy a declared backend with env typed by its generated manifest.\n */\nexport function Backend<\n const M extends Manifest.Manifest,\n const E extends Environment<NoInfer<M>> = Environment<NoInfer<M>>,\n const S extends MountSettings<NoInfer<M>> = MountSettings<NoInfer<M>>,\n>(\n id: string,\n props: BackendProps<M> & {\n readonly env?: E &\n Readonly<Record<Exclude<keyof E, keyof Environment<M>>, never>>;\n readonly mounts?: S &\n Readonly<Record<Exclude<keyof S, keyof M[\"mounts\"]>, never>>;\n },\n): ReturnType<typeof backend>;\nexport function Backend(\n id: string,\n props: BackendProps,\n): ReturnType<typeof backend>;\nexport function Backend(\n id: string,\n props: CommonProps & {\n readonly manifest?: Manifest.Manifest;\n readonly env?: Settings;\n readonly automatic?: Variables;\n readonly mounts?: Readonly<Record<string, Settings>>;\n },\n): ReturnType<typeof backend> {\n return backend(id, props);\n}\n\ntype Settings = Readonly<\n Record<string, Input<string | Redacted.Redacted<string> | Env.ProviderChoice>>\n>;\n\ntype Variables = Readonly<\n Record<string, Input<string | Redacted.Redacted<string>>>\n>;\n\nexport class InvalidAutomaticSetting extends Schema.TaggedError<\n InvalidAutomaticSetting,\n { readonly brand: unique symbol }\n>()(\"InvalidAutomaticSetting\", {\n slot: Schema.String,\n reason: Schema.Literals([\n \"NotAutomatic\",\n \"Missing\",\n \"InvalidValue\",\n \"PlainSecret\",\n ]),\n}) {\n override get message(): string {\n if (this.reason === \"PlainSecret\")\n return `${this.slot} is a plain string. Wrap this secret with Redacted.make before passing it in Backend.automatic.`;\n if (this.reason === \"InvalidValue\")\n return `${this.slot} has a value that does not match its manifest slot. Supply a string of the declared kind in Backend.automatic; secret slots require a Redacted string and literals slots require one of their values.`;\n return this.reason === \"NotAutomatic\"\n ? `${this.slot} is not declared automatic in manifest.env. Supply only automatic slots in Backend.automatic; put application values in Backend.env.`\n : `${this.slot} is declared automatic in manifest.env but has no value. Supply it in Backend.automatic.`;\n }\n}\n\nconst automaticVariables = (\n manifest: Manifest.Manifest,\n supplied: Variables,\n): Result.Result<Variables, InvalidAutomaticSetting> =>\n Result.gen(function* () {\n for (const slot of Rec.keys(supplied)) {\n if (\n !Rec.has(manifest.env, slot) ||\n manifest.env[slot]?.automatic !== true\n )\n return yield* Result.fail(\n InvalidAutomaticSetting.make({ slot, reason: \"NotAutomatic\" }),\n );\n }\n for (const [slot, descriptor] of Rec.toEntries(manifest.env)) {\n if (\n descriptor.automatic === true &&\n missing(Rec.has(supplied, slot) ? supplied[slot] : undefined)\n )\n return yield* Result.fail(\n InvalidAutomaticSetting.make({ slot, reason: \"Missing\" }),\n );\n }\n return supplied;\n });\n\nconst missing = (value: unknown): boolean =>\n value === undefined ||\n value === null ||\n value === \"\" ||\n (Redacted.isRedacted(value) && Redacted.value(value) === \"\");\n\n/**\n * A provider choice validated and encoded with the schema the handler decodes\n * it with, after refusing a choice that names a provider whose required setting\n * is unset. A setting belongs to the selector its tag names.\n */\nconst settleChoice = (\n at: string,\n key: string,\n selector: Env.Descriptor & { readonly kind: \"providers\" },\n slots: Readonly<Record<string, Env.Descriptor>>,\n supplied: Readonly<Record<string, unknown>>,\n value: unknown,\n) =>\n Effect.gen(function* () {\n if (selector.optional && missing(value)) return undefined;\n const invalid = InvalidMountSetting.make({\n mount: at,\n slot: key,\n reason: \"InvalidChoice\",\n });\n const schema = Env.providerChoice(selector.values);\n const choice = yield* Schema.decodeUnknownEffect(Schema.toType(schema))(\n value,\n ).pipe(Effect.mapError(() => invalid));\n const named = Env.chosen(choice);\n for (const [slot, other] of Rec.toEntries(slots)) {\n if (\n other.provider?.selector === key &&\n other.provider.required &&\n named.includes(other.provider.name) &&\n missing(Rec.has(supplied, slot) ? supplied[slot] : undefined)\n )\n return yield* InvalidMountSetting.make({\n mount: at,\n slot,\n reason: \"Missing\",\n });\n }\n return yield* Schema.encodeUnknownEffect(schema)(choice).pipe(\n Effect.mapError(() => invalid),\n );\n });\n\n/**\n * Normalize all accepted Input forms without resolving resource dependencies.\n * Redacted values remain opaque; arrays and choice records retain their shape.\n */\nconst normalize = (value: unknown): unknown => {\n if (Output.isOutput(value)) return value;\n if (Effect.isEffect(value)) {\n // oxlint-disable-next-line effecttsgo/any-unknown-in-error-context -- Input admits Effects with arbitrary errors and requirements; this boundary preserves requirements on the Output and converts failures to defects.\n return value.pipe(Effect.orDie, Output.fromEffect);\n }\n if (value === null || typeof value !== \"object\" || Redacted.isRedacted(value))\n return value;\n if (Arr.isArray(value)) {\n const inputs = Arr.map(value, normalize);\n return Arr.some(inputs, Output.isOutput)\n ? Output.all(...Arr.map(inputs, (input) => Output.asOutput(input)))\n : inputs;\n }\n const entries = Arr.map(\n Rec.toEntries(value),\n ([key, input]) => [key, normalize(input)] as const,\n );\n const assemble = (resolved: ReadonlyArray<unknown>) =>\n Rec.fromEntries(Arr.map(entries, ([key], index) => [key, resolved[index]]));\n const inputs = Arr.map(entries, ([, input]) => input);\n return Arr.some(inputs, Output.isOutput)\n ? Output.map(\n Output.all(...Arr.map(inputs, (input) => Output.asOutput(input))),\n assemble,\n )\n : assemble(inputs);\n};\n\n/**\n * Each supplied slot keeps its input edges. A tagged setting also reads its\n * selector's input, and a selector reads only its own tagged settings.\n */\nconst supplySettings = <E>(\n at: string,\n slots: Readonly<Record<string, Env.Descriptor>>,\n supplied: Readonly<Record<string, unknown>>,\n invalid: (\n slot: string,\n reason: \"Missing\" | \"InvalidValue\" | \"PlainSecret\",\n ) => E,\n) =>\n Effect.gen(function* () {\n const normalized = Rec.map(supplied, normalize);\n const entries: Array<[string, unknown]> = [];\n const settle = (\n key: string,\n descriptor: Env.Descriptor,\n value: unknown,\n choice?: unknown,\n ) =>\n Effect.gen(function* () {\n if (missing(value)) {\n const provider = descriptor.provider;\n const selector =\n provider === undefined ? undefined : slots[provider.selector];\n if (\n provider?.required === true &&\n selector?.kind === \"providers\" &&\n !missing(choice)\n )\n yield* settleChoice(\n at,\n provider.selector,\n selector,\n { [key]: descriptor },\n { [key]: value },\n choice,\n );\n if (!descriptor.optional)\n return yield* Effect.fail(invalid(key, \"Missing\"));\n return undefined;\n }\n if (descriptor.kind === \"secret\" && typeof value === \"string\")\n return yield* Effect.fail(invalid(key, \"PlainSecret\"));\n const valid =\n descriptor.kind === \"secret\"\n ? Redacted.isRedacted(value) &&\n typeof Redacted.value(value) === \"string\"\n : descriptor.kind === \"providers\" ||\n (typeof value === \"string\" &&\n (descriptor.kind !== \"literals\" ||\n descriptor.values.includes(value)));\n if (!valid) return yield* Effect.fail(invalid(key, \"InvalidValue\"));\n return value;\n });\n for (const [key, descriptor] of Rec.toEntries(slots)) {\n const value = Rec.has(normalized, key) ? normalized[key] : undefined;\n const choice =\n descriptor.provider === undefined ||\n !Rec.has(normalized, descriptor.provider.selector)\n ? undefined\n : normalized[descriptor.provider.selector];\n const checked =\n Output.isOutput(value) || Output.isOutput(choice)\n ? Output.all(Output.asOutput(value), Output.asOutput(choice)).pipe(\n Output.mapEffect(([resolved, selected]) =>\n settle(key, descriptor, resolved, selected).pipe(Effect.orDie),\n ),\n )\n : yield* settle(key, descriptor, value, choice);\n if (checked !== undefined) entries.push([key, checked]);\n }\n const settings = Rec.fromEntries(entries);\n for (const [key, descriptor] of Rec.toEntries(slots)) {\n if (descriptor.kind !== \"providers\" || !Rec.has(settings, key)) continue;\n const value = settings[key];\n const tagged = Rec.filter(\n settings,\n (_, slot) => slots[slot]?.provider?.selector === key,\n );\n const check = (\n choice: unknown,\n resolved: Readonly<Record<string, unknown>>,\n ) => settleChoice(at, key, descriptor, slots, resolved, choice);\n const inputs = normalize({ value, tagged });\n settings[key] = Output.isOutput(inputs)\n ? inputs.pipe(\n Output.mapEffect(\n (resolved: {\n readonly value: unknown;\n readonly tagged: Readonly<Record<string, unknown>>;\n }) => check(resolved.value, resolved.tagged).pipe(Effect.orDie),\n ),\n )\n : yield* check(value, tagged);\n }\n return settings as Record<string, Variables[string]>;\n });\n\nexport class InvalidMountSetting extends Schema.TaggedError<\n InvalidMountSetting,\n { readonly brand: unique symbol }\n>()(\"InvalidMountSetting\", {\n mount: Schema.String,\n slot: Schema.optional(Schema.String),\n reason: Schema.Literals([\n \"UnknownMount\",\n \"NotOpen\",\n \"Missing\",\n \"PlainSecret\",\n \"InvalidChoice\",\n \"InvalidValue\",\n ]),\n}) {\n override get message() {\n const at =\n this.slot === undefined ? this.mount : `${this.mount}.${this.slot}`;\n const location = this.mount === \"app\" ? \"Backend.env\" : \"Backend.mounts\";\n const remedy = {\n UnknownMount:\n \"This mount is not listed. Use a mount name from manifest.mounts.\",\n NotOpen:\n \"This slot is not open. Supply only slots listed in this mount's manifest env.\",\n Missing: `This required slot is missing. Supply this required slot in ${location}.`,\n PlainSecret: `This secret is a plain string. Wrap this secret with Redacted.make before passing it in ${location}.`,\n InvalidValue:\n \"This value does not match its manifest slot. Supply a string of the declared kind; secret slots require a Redacted string and literals slots require one of their values.\",\n InvalidChoice:\n \"This provider choice is one the component would refuse. Name one of the providers this selector offers, or a failover or pool of them.\",\n };\n return `${at}: ${remedy[this.reason]}`;\n }\n}\n\n/**\n * Each mount's settings under the deployment variable the manifest names for\n * it, refusing a manifest that does not decode, a mount or slot the manifest\n * does not list as open, a missing required slot, a plain string for a secret\n * and a provider choice the component would refuse.\n */\nexport const mountVariables = (\n input: Manifest.Manifest,\n mounts: Readonly<Record<string, Settings>>,\n): Effect.Effect<\n Record<string, Variables[string]>,\n InvalidMountSetting | Manifest.UnsupportedManifestFormat\n> =>\n Effect.gen(function* () {\n const manifest = yield* Effect.fromResult(\n Manifest.decode(input, \"confect/_generated/manifest.ts\"),\n );\n const variables: Record<string, Variables[string]> = {};\n for (const mount of Rec.keys(mounts)) {\n if (!Rec.has(manifest.mounts, mount))\n return yield* InvalidMountSetting.make({\n mount,\n reason: \"UnknownMount\",\n });\n }\n for (const [mount, entry] of Rec.toEntries(manifest.mounts)) {\n const supplied =\n (Rec.has(mounts, mount) ? mounts[mount] : undefined) ?? {};\n for (const slot of Rec.keys(supplied)) {\n if (!Rec.has(entry.env, slot))\n return yield* InvalidMountSetting.make({\n mount,\n slot,\n reason: \"NotOpen\",\n });\n }\n const settings = yield* supplySettings(\n mount,\n entry.env,\n supplied,\n (slot, reason) => InvalidMountSetting.make({ mount, slot, reason }),\n );\n for (const [slot, value] of Rec.toEntries(settings)) {\n variables[entry.env[slot]!.variable] = value;\n }\n }\n return variables;\n });\n\nconst backend = (\n id: string,\n props: CommonProps & {\n readonly manifest?: Manifest.Manifest;\n readonly env?: Settings;\n readonly automatic?: Variables;\n readonly mounts?: Readonly<Record<string, Settings>>;\n },\n) =>\n Namespace.push(\n id,\n Effect.gen(function* () {\n const manifest =\n props.manifest === undefined\n ? undefined\n : yield* Effect.fromResult(\n Manifest.decode(props.manifest, \"confect/_generated/manifest.ts\"),\n ).pipe(Effect.orDie);\n const promoted =\n manifest === undefined\n ? {}\n : yield* mountVariables(manifest, props.mounts ?? {}).pipe(\n Effect.orDie,\n );\n const automaticInput =\n manifest === undefined\n ? undefined\n : yield* Effect.fromResult(\n automaticVariables(manifest, props.automatic ?? {}),\n ).pipe(Effect.orDie);\n const automatic =\n manifest === undefined || automaticInput === undefined\n ? undefined\n : yield* supplySettings(\n \"app\",\n Rec.filter(manifest.env, (slot) => slot.automatic === true),\n automaticInput,\n (slot, reason) => InvalidAutomaticSetting.make({ slot, reason }),\n ).pipe(Effect.orDie);\n const env =\n manifest === undefined\n ? props.env\n : yield* supplySettings(\n \"app\",\n Rec.filter(manifest.env, (slot) => slot.automatic !== true),\n props.env ?? {},\n (slot, reason) =>\n InvalidMountSetting.make({\n mount: \"app\",\n slot,\n reason,\n }),\n ).pipe(Effect.orDie);\n const variables =\n Rec.keys(promoted).length === 0 && props.automatic === undefined\n ? env\n : { ...env, ...automatic, ...promoted };\n const environment =\n variables === undefined ||\n (props.env === undefined &&\n props.automatic === undefined &&\n Rec.keys(variables).length === 0)\n ? undefined\n : yield* EnvironmentVariables(\"Environment\", {\n ...props.environment,\n url: props.deployment.url,\n deployKey: props.deployKey,\n variables: variables as Variables,\n });\n const code = yield* Code(\"Code\", {\n deployment: {\n name: props.deployment.name,\n url:\n environment !== undefined\n ? Output.map(\n Output.all(environment.variables, environment.url),\n ([, url]) => url,\n )\n : props.deployment.url,\n },\n deployKey: props.deployKey,\n ...(props.cwd === undefined ? {} : { cwd: props.cwd }),\n ...(manifest === undefined ? {} : { manifestDigest: manifest.digest }),\n prepare: { command: \"confect\", args: [\"codegen\"] },\n });\n return { code, environment, name: code.name, url: code.url };\n }),\n );\n"],"mappings":";;;;;;;;;;;;;AAmGA,SAAgB,QACd,IACA,OAM4B;CAC5B,OAAO,QAAQ,IAAI,KAAK;AAC1B;AAUA,IAAa,0BAAb,cAA6C,OAAO,YAGlD,CAAC,CAAC,2BAA2B;CAC7B,MAAM,OAAO;CACb,QAAQ,OAAO,SAAS;EACtB;EACA;EACA;EACA;CACF,CAAC;AACH,CAAC,CAAC,CAAC;CACD,IAAa,UAAkB;EAC7B,IAAI,KAAK,WAAW,eAClB,OAAO,GAAG,KAAK,KAAK;EACtB,IAAI,KAAK,WAAW,gBAClB,OAAO,GAAG,KAAK,KAAK;EACtB,OAAO,KAAK,WAAW,iBACn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,GAAI,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,gBAAgB,SAAS,OAAO;EACpE,SAAS;GAAE,SAAS;GAAW,MAAM,CAAC,SAAS;EAAE;CACnD,CAAC;CACD,OAAO;EAAE;EAAM;EAAa,MAAM,KAAK;EAAM,KAAK,KAAK;CAAI;AAC7D,CAAC,CACH"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@gaganref/confect-alchemy",
3
- "version": "10.6.0-fork.31",
3
+ "version": "10.6.0-fork.32",
4
4
  "dependencies": {
5
5
  "@convex-dev/platform": "^0.1.10"
6
6
  },
7
7
  "peerDependencies": {
8
- "@confect/cli": "npm:@gaganref/confect-cli@10.6.0-fork.31",
9
- "@confect/core": "npm:@gaganref/confect-core@10.6.0-fork.31",
8
+ "@confect/cli": "npm:@gaganref/confect-cli@10.6.0-fork.32",
9
+ "@confect/core": "npm:@gaganref/confect-core@10.6.0-fork.32",
10
10
  "alchemy": ">=2.0.0-beta.85 <2.0.0",
11
11
  "convex": "^1.32.0",
12
12
  "effect": "~4.1.4"
package/src/Backend.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as Arr from "effect/Array";
2
2
  import * as Env from "@confect/core/Env";
3
3
  import * as Manifest from "@confect/core/Manifest";
4
- import type { Input } from "alchemy/Input";
4
+ import type { Input, InputProps } from "alchemy/Input";
5
5
  import * as Namespace from "alchemy/Namespace";
6
6
  import * as Output from "alchemy/Output";
7
7
  import * as Effect from "effect/Effect";
@@ -10,7 +10,10 @@ import * as Redacted from "effect/Redacted";
10
10
  import * as Schema from "effect/Schema";
11
11
  import * as Result from "effect/Result";
12
12
  import { Code } from "./Code.js";
13
- import { EnvironmentVariables } from "./EnvironmentVariables.js";
13
+ import {
14
+ EnvironmentVariables,
15
+ type EnvironmentVariablesProps,
16
+ } from "./EnvironmentVariables.js";
14
17
 
15
18
  interface CommonProps {
16
19
  readonly deployment: {
@@ -18,6 +21,13 @@ interface CommonProps {
18
21
  readonly url: Input<string>;
19
22
  };
20
23
  readonly deployKey: Input<Redacted.Redacted<string>>;
24
+ /**
25
+ * Safety options for managed environment values. Defaults to the resource
26
+ * defaults.
27
+ */
28
+ readonly environment?: InputProps<
29
+ Omit<EnvironmentVariablesProps, "url" | "deployKey" | "variables">
30
+ >;
21
31
  readonly cwd?: string;
22
32
  }
23
33
 
@@ -487,6 +497,7 @@ const backend = (
487
497
  Rec.keys(variables).length === 0)
488
498
  ? undefined
489
499
  : yield* EnvironmentVariables("Environment", {
500
+ ...props.environment,
490
501
  url: props.deployment.url,
491
502
  deployKey: props.deployKey,
492
503
  variables: variables as Variables,