effect-app 4.0.0-beta.21 → 4.0.0-beta.211

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 (219) hide show
  1. package/CHANGELOG.md +954 -0
  2. package/dist/Array.d.ts +1 -1
  3. package/dist/Chunk.d.ts +1 -1
  4. package/dist/Chunk.d.ts.map +1 -1
  5. package/dist/Config/SecretURL.d.ts +1 -1
  6. package/dist/Config/SecretURL.d.ts.map +1 -1
  7. package/dist/Config/SecretURL.js +2 -2
  8. package/dist/Config/internal/configSecretURL.d.ts +1 -1
  9. package/dist/Config/internal/configSecretURL.d.ts.map +1 -1
  10. package/dist/Config.d.ts +7 -0
  11. package/dist/Config.d.ts.map +1 -0
  12. package/dist/Config.js +6 -0
  13. package/dist/ConfigProvider.d.ts +39 -0
  14. package/dist/ConfigProvider.d.ts.map +1 -0
  15. package/dist/ConfigProvider.js +42 -0
  16. package/dist/Context.d.ts +40 -0
  17. package/dist/Context.d.ts.map +1 -0
  18. package/dist/Context.js +67 -0
  19. package/dist/Effect.d.ts +9 -10
  20. package/dist/Effect.d.ts.map +1 -1
  21. package/dist/Effect.js +3 -6
  22. package/dist/Function.d.ts +1 -1
  23. package/dist/Function.d.ts.map +1 -1
  24. package/dist/Inputify.type.d.ts +1 -1
  25. package/dist/Layer.d.ts +7 -6
  26. package/dist/Layer.d.ts.map +1 -1
  27. package/dist/Layer.js +1 -1
  28. package/dist/NonEmptySet.d.ts +1 -1
  29. package/dist/NonEmptySet.d.ts.map +1 -1
  30. package/dist/Option.d.ts +1 -1
  31. package/dist/Option.d.ts.map +1 -1
  32. package/dist/Pure.d.ts +5 -5
  33. package/dist/Pure.d.ts.map +1 -1
  34. package/dist/Pure.js +13 -13
  35. package/dist/Schema/Class.d.ts +66 -20
  36. package/dist/Schema/Class.d.ts.map +1 -1
  37. package/dist/Schema/Class.js +189 -22
  38. package/dist/Schema/FastCheck.d.ts +1 -1
  39. package/dist/Schema/FastCheck.d.ts.map +1 -1
  40. package/dist/Schema/Methods.d.ts +1 -1
  41. package/dist/Schema/SchemaParser.d.ts +5 -0
  42. package/dist/Schema/SchemaParser.d.ts.map +1 -0
  43. package/dist/Schema/SchemaParser.js +6 -0
  44. package/dist/Schema/SpecialJsonSchema.d.ts +33 -0
  45. package/dist/Schema/SpecialJsonSchema.d.ts.map +1 -0
  46. package/dist/Schema/SpecialJsonSchema.js +122 -0
  47. package/dist/Schema/SpecialOpenApi.d.ts +32 -0
  48. package/dist/Schema/SpecialOpenApi.d.ts.map +1 -0
  49. package/dist/Schema/SpecialOpenApi.js +123 -0
  50. package/dist/Schema/brand.d.ts +4 -2
  51. package/dist/Schema/brand.d.ts.map +1 -1
  52. package/dist/Schema/brand.js +1 -1
  53. package/dist/Schema/email.d.ts +1 -1
  54. package/dist/Schema/email.d.ts.map +1 -1
  55. package/dist/Schema/email.js +7 -4
  56. package/dist/Schema/ext.d.ts +117 -45
  57. package/dist/Schema/ext.d.ts.map +1 -1
  58. package/dist/Schema/ext.js +131 -42
  59. package/dist/Schema/moreStrings.d.ts +37 -25
  60. package/dist/Schema/moreStrings.d.ts.map +1 -1
  61. package/dist/Schema/moreStrings.js +15 -16
  62. package/dist/Schema/numbers.d.ts +15 -15
  63. package/dist/Schema/numbers.d.ts.map +1 -1
  64. package/dist/Schema/numbers.js +10 -12
  65. package/dist/Schema/phoneNumber.d.ts +1 -1
  66. package/dist/Schema/phoneNumber.d.ts.map +1 -1
  67. package/dist/Schema/phoneNumber.js +6 -3
  68. package/dist/Schema/schema.d.ts +1 -1
  69. package/dist/Schema/strings.d.ts +5 -5
  70. package/dist/Schema/strings.d.ts.map +1 -1
  71. package/dist/Schema/strings.js +1 -5
  72. package/dist/Schema.d.ts +147 -15
  73. package/dist/Schema.d.ts.map +1 -1
  74. package/dist/Schema.js +131 -16
  75. package/dist/Set.d.ts +1 -1
  76. package/dist/Set.d.ts.map +1 -1
  77. package/dist/TypeTest.d.ts +1 -1
  78. package/dist/Types.d.ts +1 -1
  79. package/dist/Widen.type.d.ts +1 -1
  80. package/dist/_ext/Array.d.ts +1 -1
  81. package/dist/_ext/Array.d.ts.map +1 -1
  82. package/dist/_ext/date.d.ts +1 -1
  83. package/dist/_ext/misc.d.ts +1 -1
  84. package/dist/_ext/ord.ext.d.ts +1 -1
  85. package/dist/_ext/ord.ext.d.ts.map +1 -1
  86. package/dist/builtin.d.ts +1 -1
  87. package/dist/builtin.d.ts.map +1 -1
  88. package/dist/client/InvalidationKeys.d.ts +29 -0
  89. package/dist/client/InvalidationKeys.d.ts.map +1 -0
  90. package/dist/client/InvalidationKeys.js +33 -0
  91. package/dist/client/apiClientFactory.d.ts +20 -32
  92. package/dist/client/apiClientFactory.d.ts.map +1 -1
  93. package/dist/client/apiClientFactory.js +95 -32
  94. package/dist/client/clientFor.d.ts +51 -17
  95. package/dist/client/clientFor.d.ts.map +1 -1
  96. package/dist/client/clientFor.js +9 -1
  97. package/dist/client/errors.d.ts +49 -25
  98. package/dist/client/errors.d.ts.map +1 -1
  99. package/dist/client/errors.js +43 -17
  100. package/dist/client/makeClient.d.ts +481 -33
  101. package/dist/client/makeClient.d.ts.map +1 -1
  102. package/dist/client/makeClient.js +66 -24
  103. package/dist/client.d.ts +2 -1
  104. package/dist/client.d.ts.map +1 -1
  105. package/dist/client.js +2 -1
  106. package/dist/faker.d.ts +1 -1
  107. package/dist/faker.d.ts.map +1 -1
  108. package/dist/http/Request.d.ts +2 -2
  109. package/dist/http/Request.d.ts.map +1 -1
  110. package/dist/http/internal/lib.d.ts +1 -1
  111. package/dist/http.d.ts +1 -1
  112. package/dist/ids.d.ts +12 -12
  113. package/dist/ids.d.ts.map +1 -1
  114. package/dist/ids.js +3 -2
  115. package/dist/index.d.ts +5 -8
  116. package/dist/index.d.ts.map +1 -1
  117. package/dist/index.js +6 -8
  118. package/dist/logger.d.ts +1 -1
  119. package/dist/middleware.d.ts +14 -8
  120. package/dist/middleware.d.ts.map +1 -1
  121. package/dist/middleware.js +14 -8
  122. package/dist/rpc/Invalidation.d.ts +402 -0
  123. package/dist/rpc/Invalidation.d.ts.map +1 -0
  124. package/dist/rpc/Invalidation.js +150 -0
  125. package/dist/rpc/MiddlewareMaker.d.ts +5 -4
  126. package/dist/rpc/MiddlewareMaker.d.ts.map +1 -1
  127. package/dist/rpc/MiddlewareMaker.js +57 -37
  128. package/dist/rpc/RpcContextMap.d.ts +3 -3
  129. package/dist/rpc/RpcContextMap.d.ts.map +1 -1
  130. package/dist/rpc/RpcContextMap.js +4 -4
  131. package/dist/rpc/RpcMiddleware.d.ts +5 -4
  132. package/dist/rpc/RpcMiddleware.d.ts.map +1 -1
  133. package/dist/rpc/RpcMiddleware.js +1 -1
  134. package/dist/rpc.d.ts +2 -2
  135. package/dist/rpc.d.ts.map +1 -1
  136. package/dist/rpc.js +2 -2
  137. package/dist/transform.d.ts +1 -1
  138. package/dist/transform.d.ts.map +1 -1
  139. package/dist/transform.js +3 -3
  140. package/dist/utils/effectify.d.ts +1 -1
  141. package/dist/utils/extend.d.ts +1 -1
  142. package/dist/utils/extend.d.ts.map +1 -1
  143. package/dist/utils/gen.d.ts +2 -2
  144. package/dist/utils/gen.d.ts.map +1 -1
  145. package/dist/utils/logLevel.d.ts +2 -2
  146. package/dist/utils/logLevel.d.ts.map +1 -1
  147. package/dist/utils/logger.d.ts +3 -3
  148. package/dist/utils/logger.d.ts.map +1 -1
  149. package/dist/utils/logger.js +3 -3
  150. package/dist/utils.d.ts +31 -38
  151. package/dist/utils.d.ts.map +1 -1
  152. package/dist/utils.js +12 -25
  153. package/dist/validation/validators.d.ts +1 -1
  154. package/dist/validation/validators.d.ts.map +1 -1
  155. package/dist/validation.d.ts +1 -1
  156. package/dist/validation.d.ts.map +1 -1
  157. package/package.json +46 -24
  158. package/src/Config/SecretURL.ts +2 -1
  159. package/src/Config.ts +14 -0
  160. package/src/ConfigProvider.ts +48 -0
  161. package/src/{ServiceMap.ts → Context.ts} +52 -59
  162. package/src/Effect.ts +12 -14
  163. package/src/Layer.ts +6 -5
  164. package/src/Pure.ts +17 -18
  165. package/src/Schema/Class.ts +268 -62
  166. package/src/Schema/SchemaParser.ts +12 -0
  167. package/src/Schema/SpecialJsonSchema.ts +137 -0
  168. package/src/Schema/SpecialOpenApi.ts +130 -0
  169. package/src/Schema/brand.ts +21 -1
  170. package/src/Schema/email.ts +7 -2
  171. package/src/Schema/ext.ts +204 -72
  172. package/src/Schema/moreStrings.ts +40 -37
  173. package/src/Schema/numbers.ts +14 -16
  174. package/src/Schema/phoneNumber.ts +5 -1
  175. package/src/Schema/strings.ts +4 -8
  176. package/src/Schema.ts +314 -20
  177. package/src/client/InvalidationKeys.ts +50 -0
  178. package/src/client/apiClientFactory.ts +223 -129
  179. package/src/client/clientFor.ts +95 -29
  180. package/src/client/errors.ts +52 -26
  181. package/src/client/makeClient.ts +572 -71
  182. package/src/client.ts +1 -0
  183. package/src/ids.ts +3 -2
  184. package/src/index.ts +5 -10
  185. package/src/middleware.ts +13 -9
  186. package/src/rpc/Invalidation.ts +226 -0
  187. package/src/rpc/MiddlewareMaker.ts +65 -60
  188. package/src/rpc/README.md +2 -2
  189. package/src/rpc/RpcContextMap.ts +6 -5
  190. package/src/rpc/RpcMiddleware.ts +5 -4
  191. package/src/rpc.ts +1 -1
  192. package/src/transform.ts +2 -2
  193. package/src/utils/gen.ts +1 -1
  194. package/src/utils/logger.ts +2 -2
  195. package/src/utils.ts +50 -132
  196. package/test/dist/rpc.test.d.ts.map +1 -1
  197. package/test/dist/secretURL.test.d.ts.map +1 -0
  198. package/test/dist/special.test.d.ts.map +1 -0
  199. package/test/dist/stream-error.types.d.ts +2 -0
  200. package/test/dist/stream-error.types.d.ts.map +1 -0
  201. package/test/dist/stream-error.types.js +27 -0
  202. package/test/rpc.test.ts +45 -6
  203. package/test/schema.test.ts +581 -7
  204. package/test/secretURL.test.ts +157 -0
  205. package/test/special.test.ts +1023 -0
  206. package/test/utils.test.ts +6 -6
  207. package/tsconfig.base.json +3 -4
  208. package/tsconfig.json +0 -1
  209. package/tsconfig.json.bak +2 -2
  210. package/tsconfig.src.json +29 -29
  211. package/tsconfig.test.json +2 -2
  212. package/dist/Operations.d.ts +0 -123
  213. package/dist/Operations.d.ts.map +0 -1
  214. package/dist/Operations.js +0 -29
  215. package/dist/ServiceMap.d.ts +0 -44
  216. package/dist/ServiceMap.d.ts.map +0 -1
  217. package/dist/ServiceMap.js +0 -91
  218. package/eslint.config.mjs +0 -26
  219. 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
+ })