effect-app 4.0.0-beta.24 → 4.0.0-beta.241

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