effect-app 4.0.0-beta.21 → 4.0.0-beta.210
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/CHANGELOG.md +952 -0
- package/dist/Array.d.ts +1 -1
- package/dist/Chunk.d.ts +1 -1
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Config/SecretURL.d.ts +1 -1
- package/dist/Config/SecretURL.d.ts.map +1 -1
- package/dist/Config/SecretURL.js +2 -2
- package/dist/Config/internal/configSecretURL.d.ts +1 -1
- package/dist/Config/internal/configSecretURL.d.ts.map +1 -1
- package/dist/Config.d.ts +7 -0
- package/dist/Config.d.ts.map +1 -0
- package/dist/Config.js +6 -0
- package/dist/ConfigProvider.d.ts +39 -0
- package/dist/ConfigProvider.d.ts.map +1 -0
- package/dist/ConfigProvider.js +42 -0
- package/dist/Context.d.ts +40 -0
- package/dist/Context.d.ts.map +1 -0
- package/dist/Context.js +67 -0
- package/dist/Effect.d.ts +9 -10
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +3 -6
- package/dist/Function.d.ts +1 -1
- package/dist/Function.d.ts.map +1 -1
- package/dist/Inputify.type.d.ts +1 -1
- package/dist/Layer.d.ts +7 -6
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +1 -1
- package/dist/NonEmptySet.d.ts +1 -1
- package/dist/NonEmptySet.d.ts.map +1 -1
- package/dist/Option.d.ts +1 -1
- package/dist/Option.d.ts.map +1 -1
- package/dist/Pure.d.ts +5 -5
- package/dist/Pure.d.ts.map +1 -1
- package/dist/Pure.js +13 -13
- package/dist/Schema/Class.d.ts +66 -20
- package/dist/Schema/Class.d.ts.map +1 -1
- package/dist/Schema/Class.js +189 -22
- package/dist/Schema/FastCheck.d.ts +1 -1
- package/dist/Schema/FastCheck.d.ts.map +1 -1
- package/dist/Schema/Methods.d.ts +1 -1
- package/dist/Schema/SchemaParser.d.ts +5 -0
- package/dist/Schema/SchemaParser.d.ts.map +1 -0
- package/dist/Schema/SchemaParser.js +6 -0
- package/dist/Schema/SpecialJsonSchema.d.ts +33 -0
- package/dist/Schema/SpecialJsonSchema.d.ts.map +1 -0
- package/dist/Schema/SpecialJsonSchema.js +122 -0
- package/dist/Schema/SpecialOpenApi.d.ts +32 -0
- package/dist/Schema/SpecialOpenApi.d.ts.map +1 -0
- package/dist/Schema/SpecialOpenApi.js +123 -0
- package/dist/Schema/brand.d.ts +4 -2
- package/dist/Schema/brand.d.ts.map +1 -1
- package/dist/Schema/brand.js +1 -1
- package/dist/Schema/email.d.ts +1 -1
- package/dist/Schema/email.d.ts.map +1 -1
- package/dist/Schema/email.js +7 -4
- package/dist/Schema/ext.d.ts +117 -45
- package/dist/Schema/ext.d.ts.map +1 -1
- package/dist/Schema/ext.js +131 -42
- package/dist/Schema/moreStrings.d.ts +37 -25
- package/dist/Schema/moreStrings.d.ts.map +1 -1
- package/dist/Schema/moreStrings.js +15 -16
- package/dist/Schema/numbers.d.ts +15 -15
- package/dist/Schema/numbers.d.ts.map +1 -1
- package/dist/Schema/numbers.js +10 -12
- package/dist/Schema/phoneNumber.d.ts +1 -1
- package/dist/Schema/phoneNumber.d.ts.map +1 -1
- package/dist/Schema/phoneNumber.js +6 -3
- package/dist/Schema/schema.d.ts +1 -1
- package/dist/Schema/strings.d.ts +5 -5
- package/dist/Schema/strings.d.ts.map +1 -1
- package/dist/Schema/strings.js +1 -5
- package/dist/Schema.d.ts +147 -15
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +131 -16
- package/dist/Set.d.ts +1 -1
- package/dist/Set.d.ts.map +1 -1
- package/dist/TypeTest.d.ts +1 -1
- package/dist/Types.d.ts +1 -1
- package/dist/Widen.type.d.ts +1 -1
- package/dist/_ext/Array.d.ts +1 -1
- package/dist/_ext/Array.d.ts.map +1 -1
- package/dist/_ext/date.d.ts +1 -1
- package/dist/_ext/misc.d.ts +1 -1
- package/dist/_ext/ord.ext.d.ts +1 -1
- package/dist/_ext/ord.ext.d.ts.map +1 -1
- package/dist/builtin.d.ts +1 -1
- package/dist/builtin.d.ts.map +1 -1
- package/dist/client/InvalidationKeys.d.ts +29 -0
- package/dist/client/InvalidationKeys.d.ts.map +1 -0
- package/dist/client/InvalidationKeys.js +33 -0
- package/dist/client/apiClientFactory.d.ts +20 -32
- package/dist/client/apiClientFactory.d.ts.map +1 -1
- package/dist/client/apiClientFactory.js +95 -32
- package/dist/client/clientFor.d.ts +51 -17
- package/dist/client/clientFor.d.ts.map +1 -1
- package/dist/client/clientFor.js +9 -1
- package/dist/client/errors.d.ts +49 -25
- package/dist/client/errors.d.ts.map +1 -1
- package/dist/client/errors.js +43 -17
- package/dist/client/makeClient.d.ts +481 -33
- package/dist/client/makeClient.d.ts.map +1 -1
- package/dist/client/makeClient.js +66 -24
- package/dist/client.d.ts +2 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -1
- package/dist/faker.d.ts +1 -1
- package/dist/faker.d.ts.map +1 -1
- package/dist/http/Request.d.ts +2 -2
- package/dist/http/Request.d.ts.map +1 -1
- package/dist/http/internal/lib.d.ts +1 -1
- package/dist/http.d.ts +1 -1
- package/dist/ids.d.ts +12 -12
- package/dist/ids.d.ts.map +1 -1
- package/dist/ids.js +3 -2
- package/dist/index.d.ts +5 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -8
- package/dist/logger.d.ts +1 -1
- package/dist/middleware.d.ts +14 -8
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +14 -8
- package/dist/rpc/Invalidation.d.ts +402 -0
- package/dist/rpc/Invalidation.d.ts.map +1 -0
- package/dist/rpc/Invalidation.js +150 -0
- package/dist/rpc/MiddlewareMaker.d.ts +5 -4
- package/dist/rpc/MiddlewareMaker.d.ts.map +1 -1
- package/dist/rpc/MiddlewareMaker.js +57 -37
- package/dist/rpc/RpcContextMap.d.ts +3 -3
- package/dist/rpc/RpcContextMap.d.ts.map +1 -1
- package/dist/rpc/RpcContextMap.js +4 -4
- package/dist/rpc/RpcMiddleware.d.ts +5 -4
- package/dist/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/rpc/RpcMiddleware.js +1 -1
- package/dist/rpc.d.ts +2 -2
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +2 -2
- package/dist/transform.d.ts +1 -1
- package/dist/transform.d.ts.map +1 -1
- package/dist/transform.js +3 -3
- package/dist/utils/effectify.d.ts +1 -1
- package/dist/utils/extend.d.ts +1 -1
- package/dist/utils/extend.d.ts.map +1 -1
- package/dist/utils/gen.d.ts +2 -2
- package/dist/utils/gen.d.ts.map +1 -1
- package/dist/utils/logLevel.d.ts +2 -2
- package/dist/utils/logLevel.d.ts.map +1 -1
- package/dist/utils/logger.d.ts +3 -3
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +3 -3
- package/dist/utils.d.ts +31 -38
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +12 -25
- package/dist/validation/validators.d.ts +1 -1
- package/dist/validation/validators.d.ts.map +1 -1
- package/dist/validation.d.ts +1 -1
- package/dist/validation.d.ts.map +1 -1
- package/package.json +46 -24
- package/src/Config/SecretURL.ts +2 -1
- package/src/Config.ts +14 -0
- package/src/ConfigProvider.ts +48 -0
- package/src/{ServiceMap.ts → Context.ts} +52 -59
- package/src/Effect.ts +12 -14
- package/src/Layer.ts +6 -5
- package/src/Pure.ts +17 -18
- package/src/Schema/Class.ts +268 -62
- package/src/Schema/SchemaParser.ts +12 -0
- package/src/Schema/SpecialJsonSchema.ts +137 -0
- package/src/Schema/SpecialOpenApi.ts +130 -0
- package/src/Schema/brand.ts +21 -1
- package/src/Schema/email.ts +7 -2
- package/src/Schema/ext.ts +204 -72
- package/src/Schema/moreStrings.ts +40 -37
- package/src/Schema/numbers.ts +14 -16
- package/src/Schema/phoneNumber.ts +5 -1
- package/src/Schema/strings.ts +4 -8
- package/src/Schema.ts +314 -20
- package/src/client/InvalidationKeys.ts +50 -0
- package/src/client/apiClientFactory.ts +223 -129
- package/src/client/clientFor.ts +95 -29
- package/src/client/errors.ts +52 -26
- package/src/client/makeClient.ts +572 -71
- package/src/client.ts +1 -0
- package/src/ids.ts +3 -2
- package/src/index.ts +5 -10
- package/src/middleware.ts +13 -9
- package/src/rpc/Invalidation.ts +226 -0
- package/src/rpc/MiddlewareMaker.ts +65 -60
- package/src/rpc/README.md +2 -2
- package/src/rpc/RpcContextMap.ts +6 -5
- package/src/rpc/RpcMiddleware.ts +5 -4
- package/src/rpc.ts +1 -1
- package/src/transform.ts +2 -2
- package/src/utils/gen.ts +1 -1
- package/src/utils/logger.ts +2 -2
- package/src/utils.ts +50 -132
- package/test/dist/rpc.test.d.ts.map +1 -1
- package/test/dist/secretURL.test.d.ts.map +1 -0
- package/test/dist/special.test.d.ts.map +1 -0
- package/test/dist/stream-error.types.d.ts +2 -0
- package/test/dist/stream-error.types.d.ts.map +1 -0
- package/test/dist/stream-error.types.js +27 -0
- package/test/rpc.test.ts +45 -6
- package/test/schema.test.ts +581 -7
- package/test/secretURL.test.ts +157 -0
- package/test/special.test.ts +1023 -0
- package/test/utils.test.ts +6 -6
- package/tsconfig.base.json +3 -4
- package/tsconfig.json +0 -1
- package/tsconfig.json.bak +2 -2
- package/tsconfig.src.json +29 -29
- package/tsconfig.test.json +2 -2
- package/dist/Operations.d.ts +0 -123
- package/dist/Operations.d.ts.map +0 -1
- package/dist/Operations.js +0 -29
- package/dist/ServiceMap.d.ts +0 -44
- package/dist/ServiceMap.d.ts.map +0 -1
- package/dist/ServiceMap.js +0 -91
- package/eslint.config.mjs +0 -26
- package/src/Operations.ts +0 -55
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { Chunk, Config, ConfigProvider, Effect } from "effect"
|
|
2
|
+
import { describe, expect, test } from "vitest"
|
|
3
|
+
import { fromChunk, fromString, isSecretURL, make, secretURL, unsafeWipe, value } from "../src/Config/SecretURL.js"
|
|
4
|
+
|
|
5
|
+
const testUrls = [
|
|
6
|
+
"https://example.com/path?key=secret123",
|
|
7
|
+
"http://user:password@host.com:8080/resource",
|
|
8
|
+
"postgres://admin:p4ssw0rd@db.internal:5432/mydb",
|
|
9
|
+
"redis://default:token@cache.example.com:6379",
|
|
10
|
+
"mongodb+srv://user:pass@cluster.mongodb.net/db",
|
|
11
|
+
"https://api.example.com/v2/endpoint?token=abc&format=json"
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
describe("SecretURL", () => {
|
|
15
|
+
describe("fromString / value roundtrip", () => {
|
|
16
|
+
test.each(testUrls)("preserves %s", (url) => {
|
|
17
|
+
const secret = fromString(url)
|
|
18
|
+
expect(value(secret)).toBe(url)
|
|
19
|
+
})
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
describe("make / value roundtrip", () => {
|
|
23
|
+
test.each(testUrls)("preserves %s via byte array", (url) => {
|
|
24
|
+
const bytes = url.split("").map((c) => c.charCodeAt(0))
|
|
25
|
+
const secret = make(bytes)
|
|
26
|
+
expect(value(secret)).toBe(url)
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
describe("fromChunk / value roundtrip", () => {
|
|
31
|
+
test.each(testUrls)("preserves %s via Chunk", (url) => {
|
|
32
|
+
const chunk = Chunk.fromIterable(url.split(""))
|
|
33
|
+
const secret = fromChunk(chunk)
|
|
34
|
+
expect(value(secret)).toBe(url)
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
describe("toString", () => {
|
|
39
|
+
test("redacts the URL, showing only protocol", () => {
|
|
40
|
+
const secret = fromString("https://example.com/secret")
|
|
41
|
+
expect(String(secret)).toBe("SecretURL(https://<redacted>)")
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
test("shows http protocol", () => {
|
|
45
|
+
const secret = fromString("http://example.com")
|
|
46
|
+
expect(String(secret)).toBe("SecretURL(http://<redacted>)")
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
test("shows unknown for non-URL strings", () => {
|
|
50
|
+
const secret = fromString("not-a-url")
|
|
51
|
+
expect(String(secret)).toBe("SecretURL(unknown://<redacted>)")
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
describe("toJSON", () => {
|
|
56
|
+
test("returns tag and protocol only", () => {
|
|
57
|
+
const secret = fromString("https://example.com/secret")
|
|
58
|
+
expect(JSON.parse(JSON.stringify(secret))).toEqual({ _tag: "SecretURL", protocol: "https" })
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
test("returns unknown protocol for non-URL", () => {
|
|
62
|
+
const secret = fromString("not-a-url")
|
|
63
|
+
expect(JSON.parse(JSON.stringify(secret))).toEqual({ _tag: "SecretURL", protocol: "unknown" })
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
describe("isSecretURL", () => {
|
|
68
|
+
test("returns true for SecretURL", () => {
|
|
69
|
+
const secret = fromString("https://example.com")
|
|
70
|
+
expect(isSecretURL(secret)).toBe(true)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
test("returns false for plain string", () => {
|
|
74
|
+
expect(isSecretURL("https://example.com")).toBe(false)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
test("returns false for plain object", () => {
|
|
78
|
+
expect(isSecretURL({ raw: [1, 2, 3] })).toBe(false)
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
describe("unsafeWipe", () => {
|
|
83
|
+
test("zeroes out raw bytes", () => {
|
|
84
|
+
const secret = fromString("https://example.com")
|
|
85
|
+
unsafeWipe(secret)
|
|
86
|
+
expect(value(secret)).toBe("\0".repeat("https://example.com".length))
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
describe("non-URL strings", () => {
|
|
91
|
+
const nonUrls = [
|
|
92
|
+
"just-a-secret-token",
|
|
93
|
+
"Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.abc",
|
|
94
|
+
"sk-1234567890abcdef",
|
|
95
|
+
"some random string with spaces and symbols!@#$%"
|
|
96
|
+
]
|
|
97
|
+
|
|
98
|
+
test.each(nonUrls)("preserves non-URL value: %s", (input) => {
|
|
99
|
+
const secret = fromString(input)
|
|
100
|
+
expect(value(secret)).toBe(input)
|
|
101
|
+
expect(String(secret)).toBe("SecretURL(unknown://<redacted>)")
|
|
102
|
+
expect(JSON.parse(JSON.stringify(secret))).toEqual({ _tag: "SecretURL", protocol: "unknown" })
|
|
103
|
+
})
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
describe("special characters", () => {
|
|
107
|
+
test("preserves URLs with encoded characters", () => {
|
|
108
|
+
const url = "https://example.com/path?q=hello%20world&name=%C3%A9"
|
|
109
|
+
expect(value(fromString(url))).toBe(url)
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
test("preserves URLs with unicode", () => {
|
|
113
|
+
const url = "https://example.com/café"
|
|
114
|
+
expect(value(fromString(url))).toBe(url)
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
test("preserves URLs with special query params", () => {
|
|
118
|
+
const url = "https://example.com?a=1&b=2&c=foo+bar"
|
|
119
|
+
expect(value(fromString(url))).toBe(url)
|
|
120
|
+
})
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
describe("secretURL config", () => {
|
|
124
|
+
const run = <A>(config: Config.Config<A>, provider: ConfigProvider.ConfigProvider) =>
|
|
125
|
+
Effect.runSync(config.parse(provider))
|
|
126
|
+
|
|
127
|
+
test("reads from env-style ConfigProvider (QUEUE_URL)", () => {
|
|
128
|
+
const url = "https://sqs.us-east-1.amazonaws.com/123456789/my-queue"
|
|
129
|
+
const provider = ConfigProvider.fromEnv({ env: { QUEUE_URL: url } })
|
|
130
|
+
const result = run(secretURL("QUEUE_URL"), provider)
|
|
131
|
+
expect(value(result)).toBe(url)
|
|
132
|
+
expect(String(result)).toBe("SecretURL(https://<redacted>)")
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
test("reads from fromUnknown with nested config ({ queue: { url } })", () => {
|
|
136
|
+
const url = "redis://default:token@cache.example.com:6379"
|
|
137
|
+
const provider = ConfigProvider.fromUnknown({ queue: { url } })
|
|
138
|
+
const config = secretURL("url").pipe(Config.nested("queue"))
|
|
139
|
+
const result = run(config, provider)
|
|
140
|
+
expect(value(result)).toBe(url)
|
|
141
|
+
expect(String(result)).toBe("SecretURL(redis://<redacted>)")
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
test("reads non-URL secret from env", () => {
|
|
145
|
+
const token = "sk-1234567890abcdef"
|
|
146
|
+
const provider = ConfigProvider.fromEnv({ env: { API_KEY: token } })
|
|
147
|
+
const result = run(secretURL("API_KEY"), provider)
|
|
148
|
+
expect(value(result)).toBe(token)
|
|
149
|
+
expect(String(result)).toBe("SecretURL(unknown://<redacted>)")
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
test("rejects empty string", () => {
|
|
153
|
+
const provider = ConfigProvider.fromEnv({ env: { QUEUE_URL: "" } })
|
|
154
|
+
expect(() => run(secretURL("QUEUE_URL"), provider)).toThrow()
|
|
155
|
+
})
|
|
156
|
+
})
|
|
157
|
+
})
|