Skip to content

Commit

Permalink
depreciate Secret module in favour of the Redacted module (#3195)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Jul 8, 2024
1 parent 188e23a commit abd56d7
Show file tree
Hide file tree
Showing 15 changed files with 10 additions and 349 deletions.
7 changes: 7 additions & 0 deletions .changeset/young-knives-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"effect": major
"@effect/platform-node-shared": minor
"@effect/cli": minor
---

depreciate Secret module in favour of the Redacted module
11 changes: 0 additions & 11 deletions packages/cli/src/Args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import type { Effect } from "effect/Effect"
import type { Option } from "effect/Option"
import type { Pipeable } from "effect/Pipeable"
import type { Redacted } from "effect/Redacted"
import type { Secret } from "effect/Secret"
import type { CliConfig } from "./CliConfig.js"
import type { HelpDoc } from "./HelpDoc.js"
import * as InternalArgs from "./internal/args.js"
Expand Down Expand Up @@ -387,16 +386,6 @@ export const repeated: <A>(self: Args<A>) => Args<Array<A>> = InternalArgs.repea
*/
export const redacted: (config?: Args.BaseArgsConfig) => Args<Redacted> = InternalArgs.redacted

/**
* Creates a text argument.
*
* Can optionally provide a custom argument name (defaults to `"secret"`).
*
* @since 1.0.0
* @category constructors
*/
export const secret: (config?: Args.BaseArgsConfig) => Args<Secret> = InternalArgs.secret

/**
* Creates a text argument.
*
Expand Down
8 changes: 0 additions & 8 deletions packages/cli/src/Options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import type { HashMap } from "effect/HashMap"
import type { Option } from "effect/Option"
import type { Pipeable } from "effect/Pipeable"
import type { Redacted } from "effect/Redacted"
import type { Secret } from "effect/Secret"
import type { CliConfig } from "./CliConfig.js"
import type { HelpDoc } from "./HelpDoc.js"
import * as InternalOptions from "./internal/options.js"
Expand Down Expand Up @@ -314,13 +313,6 @@ export const none: Options<void> = InternalOptions.none
*/
export const redacted: (name: string) => Options<Redacted> = InternalOptions.redacted

/**
* @since 1.0.0
* @category constructors
* @deprecated
*/
export const secret: (name: string) => Options<Secret> = InternalOptions.secret

/**
* @since 1.0.0
* @category constructors
Expand Down
6 changes: 0 additions & 6 deletions packages/cli/src/internal/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import * as Option from "effect/Option"
import { pipeArguments } from "effect/Pipeable"
import type * as Redacted from "effect/Redacted"
import * as Ref from "effect/Ref"
import type * as Secret from "effect/Secret"
import type * as Args from "../Args.js"
import type * as CliConfig from "../CliConfig.js"
import type * as HelpDoc from "../HelpDoc.js"
Expand Down Expand Up @@ -272,11 +271,6 @@ export const redacted = (
config?: Args.Args.BaseArgsConfig
): Args.Args<Redacted.Redacted> => makeSingle(Option.fromNullable(config?.name), InternalPrimitive.redacted)

/** @internal */
export const secret = (
config?: Args.Args.BaseArgsConfig
): Args.Args<Secret.Secret> => makeSingle(Option.fromNullable(config?.name), InternalPrimitive.secret)

/** @internal */
export const text = (config?: Args.Args.BaseArgsConfig): Args.Args<string> =>
makeSingle(Option.fromNullable(config?.name), InternalPrimitive.text)
Expand Down
5 changes: 0 additions & 5 deletions packages/cli/src/internal/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import * as Order from "effect/Order"
import { pipeArguments } from "effect/Pipeable"
import type * as Redacted from "effect/Redacted"
import * as Ref from "effect/Ref"
import type * as Secret from "effect/Secret"
import type * as CliConfig from "../CliConfig.js"
import type * as HelpDoc from "../HelpDoc.js"
import type * as Options from "../Options.js"
Expand Down Expand Up @@ -380,10 +379,6 @@ export const none: Options.Options<void> = (() => {
export const redacted = (name: string): Options.Options<Redacted.Redacted> =>
makeSingle(name, Arr.empty(), InternalPrimitive.redacted)

/** @internal */
export const secret = (name: string): Options.Options<Secret.Secret> =>
makeSingle(name, Arr.empty(), InternalPrimitive.secret)

/** @internal */
export const text = (name: string): Options.Options<string> => makeSingle(name, Arr.empty(), InternalPrimitive.text)

Expand Down
35 changes: 0 additions & 35 deletions packages/cli/src/internal/primitive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { dual, pipe } from "effect/Function"
import * as Option from "effect/Option"
import { pipeArguments } from "effect/Pipeable"
import * as EffectRedacted from "effect/Redacted"
import * as EffectSecret from "effect/Secret"
import type * as CliConfig from "../CliConfig.js"
import type * as HelpDoc from "../HelpDoc.js"
import type * as Span from "../HelpDoc/Span.js"
Expand Down Expand Up @@ -52,7 +51,6 @@ export type Instruction =
| Float
| Integer
| Path
| Secret
| Redacted
| Text

Expand Down Expand Up @@ -90,9 +88,6 @@ export interface Path extends
/** @internal */
export interface Redacted extends Op<"Redacted", {}> {}

/** @internal */
export interface Secret extends Op<"Secret", {}> {}

/** @internal */
export interface Text extends Op<"Text", {}> {}

Expand Down Expand Up @@ -125,9 +120,6 @@ export const isIntegerType = (self: Instruction): self is Integer => self._tag =
/** @internal */
export const isPathType = (self: Instruction): self is Path => self._tag === "Path"

/** @internal */
export const isSecretType = (self: Instruction): self is Path => self._tag === "Path"

/** @internal */
export const isTextType = (self: Instruction): self is Text => self._tag === "Text"

Expand Down Expand Up @@ -205,13 +197,6 @@ export const redacted: Primitive.Primitive<EffectRedacted.Redacted> = (() => {
return op
})()

/** @internal */
export const secret: Primitive.Primitive<EffectSecret.Secret> = (() => {
const op = Object.create(proto)
op._tag = "Secret"
return op
})()

/** @internal */
export const text: Primitive.Primitive<string> = (() => {
const op = Object.create(proto)
Expand Down Expand Up @@ -283,7 +268,6 @@ const getChoicesInternal = (self: Instruction): Option.Option<string> => {
case "Integer":
case "Path":
case "Redacted":
case "Secret":
case "Text": {
return Option.none()
}
Expand Down Expand Up @@ -346,7 +330,6 @@ const getHelpInternal = (self: Instruction): Span.Span => {
`('${self.pathType}') and path existence ('${self.pathExists}')`
)
}
case "Secret":
case "Redacted": {
return InternalSpan.text("A user-defined piece of text that is confidential.")
}
Expand Down Expand Up @@ -382,9 +365,6 @@ const getTypeNameInternal = (self: Instruction): string => {
case "Redacted": {
return "redacted"
}
case "Secret": {
return "secret"
}
case "Text": {
return "text"
}
Expand Down Expand Up @@ -467,11 +447,6 @@ const validateInternal = (
Effect.map((value) => EffectRedacted.make(value))
)
}
case "Secret": {
return attempt(value, getTypeNameInternal(self), Schema.decodeUnknown(Schema.String)).pipe(
Effect.map((value) => EffectSecret.fromString(value))
)
}
case "Text": {
return attempt(value, getTypeNameInternal(self), Schema.decodeUnknown(Schema.String))
}
Expand Down Expand Up @@ -601,13 +576,6 @@ const wizardInternal = (self: Instruction, help: HelpDoc.HelpDoc): Prompt.Prompt
message: InternalHelpDoc.toAnsiText(message).trimEnd()
})
}
case "Secret": {
const primitiveHelp = InternalHelpDoc.p("Enter some text (value will be redacted)")
const message = InternalHelpDoc.sequence(help, primitiveHelp)
return InternalTextPrompt.hidden({
message: InternalHelpDoc.toAnsiText(message).trimEnd()
})
}
case "Text": {
const primitiveHelp = InternalHelpDoc.p("Enter some text")
const message = InternalHelpDoc.sequence(help, primitiveHelp)
Expand All @@ -631,7 +599,6 @@ export const getBashCompletions = (self: Instruction): string => {
case "DateTime":
case "Float":
case "Integer":
case "Secret":
case "Redacted":
case "Text": {
return "$(compgen -f \"${cur}\")"
Expand Down Expand Up @@ -675,7 +642,6 @@ export const getFishCompletions = (self: Instruction): Array<string> => {
case "Float":
case "Integer":
case "Redacted":
case "Secret":
case "Text": {
return Arr.make("-r", "-f")
}
Expand Down Expand Up @@ -755,7 +721,6 @@ export const getZshCompletions = (self: Instruction): string => {
}
}
case "Redacted":
case "Secret":
case "Text": {
return ""
}
Expand Down
10 changes: 0 additions & 10 deletions packages/effect/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import type * as LogLevel from "./LogLevel.js"
import type * as Option from "./Option.js"
import type { Predicate, Refinement } from "./Predicate.js"
import type * as Redacted from "./Redacted.js"
import type * as Secret from "./Secret.js"
import type * as Types from "./Types.js"

/**
Expand Down Expand Up @@ -334,15 +333,6 @@ export const primitive: <A>(
*/
export const repeat: <A>(self: Config<A>) => Config<Array<A>> = internal.repeat

/**
* Constructs a config for a secret value.
*
* @since 2.0.0
* @category constructors
* @deprecated
*/
export const secret: (name?: string) => Config<Secret.Secret> = internal.secret

/**
* Constructs a config for a redacted value.
*
Expand Down
88 changes: 0 additions & 88 deletions packages/effect/src/Secret.ts

This file was deleted.

6 changes: 0 additions & 6 deletions packages/effect/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -729,12 +729,6 @@ export * as ScopedCache from "./ScopedCache.js"
*/
export * as ScopedRef from "./ScopedRef.js"

/**
* @since 2.0.0
* @deprecated
*/
export * as Secret from "./Secret.js"

/**
* @since 2.0.0
*/
Expand Down
11 changes: 0 additions & 11 deletions packages/effect/src/internal/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ import type * as LogLevel from "../LogLevel.js"
import * as Option from "../Option.js"
import { hasProperty, type Predicate, type Refinement } from "../Predicate.js"
import type * as Redacted from "../Redacted.js"
import type * as Secret from "../Secret.js"
import * as configError from "./configError.js"
import * as core from "./core.js"
import * as defaultServices from "./defaultServices.js"
import * as effectable from "./effectable.js"
import * as OpCodes from "./opCodes/config.js"
import * as redacted_ from "./redacted.js"
import * as InternalSecret from "./secret.js"

const ConfigSymbolKey = "effect/Config"

Expand Down Expand Up @@ -414,15 +412,6 @@ export const repeat = <A>(self: Config.Config<A>): Config.Config<Array<A>> => {
return repeat
}

/** @internal */
export const secret = (name?: string): Config.Config<Secret.Secret> => {
const config = primitive(
"a secret property",
(text) => Either.right(InternalSecret.fromString(text))
)
return name === undefined ? config : nested(config, name)
}

/** @internal */
export const redacted = (name?: string): Config.Config<Redacted.Redacted> => {
const config = primitive(
Expand Down
Loading

0 comments on commit abd56d7

Please sign in to comment.