effect-app 1.32.0 → 2.0.0

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 (310) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/_cjs/Array.cjs +132 -0
  3. package/_cjs/Array.cjs.map +1 -0
  4. package/_cjs/Chunk.cjs +128 -0
  5. package/_cjs/Chunk.cjs.map +1 -0
  6. package/_cjs/Config/SecretURL.cjs +3 -3
  7. package/_cjs/Config/SecretURL.cjs.map +1 -1
  8. package/_cjs/Config/internal/configSecretURL.cjs +2 -2
  9. package/_cjs/Config/internal/configSecretURL.cjs.map +1 -1
  10. package/_cjs/Context.cjs +243 -0
  11. package/_cjs/Context.cjs.map +1 -0
  12. package/_cjs/Dictionary.cjs +522 -0
  13. package/_cjs/Dictionary.cjs.map +1 -0
  14. package/_cjs/Effect.cjs +202 -0
  15. package/_cjs/Effect.cjs.map +1 -0
  16. package/_cjs/Function.cjs +107 -0
  17. package/_cjs/Function.cjs.map +1 -0
  18. package/_cjs/NonEmptySet.cjs +26 -0
  19. package/_cjs/NonEmptySet.cjs.map +1 -0
  20. package/_cjs/NonEmptySetAspects.cjs +17 -0
  21. package/_cjs/NonEmptySetAspects.cjs.map +1 -0
  22. package/_cjs/NonEmptySetBase.cjs +82 -0
  23. package/_cjs/NonEmptySetBase.cjs.map +1 -0
  24. package/_cjs/Object.cjs +24 -0
  25. package/_cjs/Object.cjs.map +1 -0
  26. package/_cjs/Operations.cjs +1 -1
  27. package/_cjs/Option.cjs +88 -0
  28. package/_cjs/Option.cjs.map +1 -0
  29. package/_cjs/Prelude.cjs +51 -0
  30. package/_cjs/Prelude.cjs.map +1 -0
  31. package/_cjs/Prelude.code.cjs +51 -0
  32. package/_cjs/Prelude.code.cjs.map +1 -0
  33. package/_cjs/Pure.cjs +39 -36
  34. package/_cjs/Pure.cjs.map +1 -1
  35. package/_cjs/Schema/Class.cjs +61 -0
  36. package/_cjs/Schema/Class.cjs.map +1 -0
  37. package/_cjs/Schema/FastCheck.cjs +39 -0
  38. package/_cjs/Schema/FastCheck.cjs.map +1 -0
  39. package/_cjs/Schema/Methods.cjs +6 -0
  40. package/_cjs/Schema/Methods.cjs.map +1 -0
  41. package/_cjs/Schema/brand.cjs +17 -0
  42. package/_cjs/Schema/brand.cjs.map +1 -0
  43. package/_cjs/Schema/email.cjs +20 -0
  44. package/_cjs/Schema/email.cjs.map +1 -0
  45. package/_cjs/Schema/ext.cjs +174 -0
  46. package/_cjs/Schema/ext.cjs.map +1 -0
  47. package/_cjs/Schema/moreStrings.cjs +124 -0
  48. package/_cjs/Schema/moreStrings.cjs.map +1 -0
  49. package/_cjs/Schema/numbers.cjs +52 -0
  50. package/_cjs/Schema/numbers.cjs.map +1 -0
  51. package/_cjs/Schema/phoneNumber.cjs +22 -0
  52. package/_cjs/Schema/phoneNumber.cjs.map +1 -0
  53. package/_cjs/Schema/schema.cjs +15 -0
  54. package/_cjs/Schema/schema.cjs.map +1 -0
  55. package/_cjs/Schema/strings.cjs +32 -0
  56. package/_cjs/Schema/strings.cjs.map +1 -0
  57. package/_cjs/Schema.cjs +334 -0
  58. package/_cjs/Schema.cjs.map +1 -0
  59. package/_cjs/Set.cjs +567 -0
  60. package/_cjs/Set.cjs.map +1 -0
  61. package/_cjs/Struct.cjs +51 -0
  62. package/_cjs/Struct.cjs.map +1 -0
  63. package/_cjs/Tag.cjs +25 -0
  64. package/_cjs/Tag.cjs.map +1 -0
  65. package/_cjs/Unify.cjs +40 -0
  66. package/_cjs/Unify.cjs.map +1 -0
  67. package/_cjs/_ext/misc.cjs +16 -16
  68. package/_cjs/_ext/misc.cjs.map +1 -1
  69. package/_cjs/_ext/ord.ext.cjs +52 -0
  70. package/_cjs/_ext/ord.ext.cjs.map +1 -0
  71. package/_cjs/builtin.cjs +6 -0
  72. package/_cjs/builtin.cjs.map +1 -0
  73. package/_cjs/client/clientFor.cjs +5 -3
  74. package/_cjs/client/clientFor.cjs.map +1 -1
  75. package/_cjs/client/config.cjs +4 -4
  76. package/_cjs/client/config.cjs.map +1 -1
  77. package/_cjs/client/errors.cjs +9 -9
  78. package/_cjs/client/errors.cjs.map +1 -1
  79. package/_cjs/http/http-client.cjs +35 -0
  80. package/_cjs/http/http-client.cjs.map +1 -0
  81. package/_cjs/ids.cjs +5 -5
  82. package/_cjs/ids.cjs.map +1 -1
  83. package/_cjs/index.cjs +1 -1
  84. package/_cjs/lib.cjs +178 -9
  85. package/_cjs/lib.cjs.map +1 -1
  86. package/_cjs/logger.cjs +1 -1
  87. package/_cjs/transform.cjs +45 -0
  88. package/_cjs/transform.cjs.map +1 -0
  89. package/_cjs/utils/effectify.cjs +25 -0
  90. package/_cjs/utils/effectify.cjs.map +1 -0
  91. package/_cjs/utils/extend.cjs +17 -0
  92. package/_cjs/utils/extend.cjs.map +1 -0
  93. package/_cjs/utils/logger.cjs +23 -0
  94. package/_cjs/utils/logger.cjs.map +1 -0
  95. package/_cjs/utils.cjs +431 -4
  96. package/_cjs/utils.cjs.map +1 -1
  97. package/_cjs/validation/validators.cjs +32 -0
  98. package/_cjs/validation/validators.cjs.map +1 -0
  99. package/_cjs/validation.cjs +45 -0
  100. package/_cjs/validation.cjs.map +1 -0
  101. package/dist/Array.d.ts +64 -0
  102. package/dist/Array.d.ts.map +1 -0
  103. package/dist/Array.js +89 -0
  104. package/dist/Chunk.d.ts +68 -0
  105. package/dist/Chunk.d.ts.map +1 -0
  106. package/dist/Chunk.js +93 -0
  107. package/dist/Config/SecretURL.d.ts +3 -3
  108. package/dist/Config/SecretURL.d.ts.map +1 -1
  109. package/dist/Config/SecretURL.js +2 -2
  110. package/dist/Config/internal/configSecretURL.js +2 -2
  111. package/dist/Context.d.ts +55 -0
  112. package/dist/Context.d.ts.map +1 -0
  113. package/dist/Context.js +204 -0
  114. package/dist/Dictionary.d.ts +260 -0
  115. package/dist/Dictionary.d.ts.map +1 -0
  116. package/dist/Dictionary.js +448 -0
  117. package/dist/Effect.d.ts +115 -0
  118. package/dist/Effect.d.ts.map +1 -0
  119. package/dist/Effect.js +153 -0
  120. package/dist/Function.d.ts +72 -0
  121. package/dist/Function.d.ts.map +1 -0
  122. package/dist/Function.js +71 -0
  123. package/dist/Inputify.type.d.ts +1 -1
  124. package/dist/Inputify.type.d.ts.map +1 -1
  125. package/dist/NonEmptySet.d.ts +3 -0
  126. package/dist/NonEmptySet.d.ts.map +1 -0
  127. package/dist/NonEmptySet.js +3 -0
  128. package/dist/NonEmptySetAspects.d.ts +2 -0
  129. package/dist/NonEmptySetAspects.d.ts.map +1 -0
  130. package/dist/NonEmptySetAspects.js +2 -0
  131. package/dist/NonEmptySetBase.d.ts +39 -0
  132. package/dist/NonEmptySetBase.d.ts.map +1 -0
  133. package/dist/NonEmptySetBase.js +63 -0
  134. package/dist/Object.d.ts +7 -0
  135. package/dist/Object.d.ts.map +1 -0
  136. package/dist/Object.js +7 -0
  137. package/dist/Operations.d.ts +2 -2
  138. package/dist/Operations.js +1 -1
  139. package/dist/Option.d.ts +39 -0
  140. package/dist/Option.d.ts.map +1 -0
  141. package/dist/Option.js +55 -0
  142. package/dist/Prelude.code.d.ts +24 -0
  143. package/dist/Prelude.code.d.ts.map +1 -0
  144. package/dist/Prelude.code.js +23 -0
  145. package/dist/Prelude.d.ts +163 -0
  146. package/dist/Prelude.d.ts.map +1 -0
  147. package/dist/Prelude.js +23 -0
  148. package/dist/Pure.d.ts +13 -12
  149. package/dist/Pure.d.ts.map +1 -1
  150. package/dist/Pure.js +18 -17
  151. package/dist/Schema/Class.d.ts +45 -0
  152. package/dist/Schema/Class.d.ts.map +1 -0
  153. package/dist/Schema/Class.js +50 -0
  154. package/dist/Schema/FastCheck.d.ts +10 -0
  155. package/dist/Schema/FastCheck.d.ts.map +1 -0
  156. package/dist/Schema/FastCheck.js +12 -0
  157. package/dist/Schema/Methods.d.ts +6 -0
  158. package/dist/Schema/Methods.d.ts.map +1 -0
  159. package/dist/Schema/Methods.js +2 -0
  160. package/dist/Schema/brand.d.ts +35 -0
  161. package/dist/Schema/brand.d.ts.map +1 -0
  162. package/dist/Schema/brand.js +7 -0
  163. package/dist/Schema/email.d.ts +9 -0
  164. package/dist/Schema/email.d.ts.map +1 -0
  165. package/dist/Schema/email.js +12 -0
  166. package/dist/Schema/ext.d.ts +89 -0
  167. package/dist/Schema/ext.d.ts.map +1 -0
  168. package/dist/Schema/ext.js +111 -0
  169. package/dist/Schema/moreStrings.d.ts +109 -0
  170. package/dist/Schema/moreStrings.d.ts.map +1 -0
  171. package/dist/Schema/moreStrings.js +108 -0
  172. package/dist/Schema/numbers.d.ts +46 -0
  173. package/dist/Schema/numbers.d.ts.map +1 -0
  174. package/dist/Schema/numbers.js +28 -0
  175. package/dist/Schema/phoneNumber.d.ts +9 -0
  176. package/dist/Schema/phoneNumber.d.ts.map +1 -0
  177. package/dist/Schema/phoneNumber.js +14 -0
  178. package/dist/Schema/schema.d.ts +6 -0
  179. package/dist/Schema/schema.d.ts.map +1 -0
  180. package/dist/Schema/schema.js +5 -0
  181. package/dist/Schema/strings.d.ts +19 -0
  182. package/dist/Schema/strings.d.ts.map +1 -0
  183. package/dist/Schema/strings.js +32 -0
  184. package/dist/{schema.d.ts → Schema.d.ts} +25 -9
  185. package/dist/Schema.d.ts.map +1 -0
  186. package/dist/Schema.js +89 -0
  187. package/dist/Set.d.ts +221 -0
  188. package/dist/Set.d.ts.map +1 -0
  189. package/dist/Set.js +516 -0
  190. package/dist/Struct.d.ts +44 -0
  191. package/dist/Struct.d.ts.map +1 -0
  192. package/dist/Struct.js +29 -0
  193. package/dist/Tag.d.ts +9 -0
  194. package/dist/Tag.d.ts.map +1 -0
  195. package/dist/Tag.js +18 -0
  196. package/dist/Unify.d.ts +43 -0
  197. package/dist/Unify.d.ts.map +1 -0
  198. package/dist/Unify.js +31 -0
  199. package/dist/Widen.type.d.ts +1 -1
  200. package/dist/Widen.type.d.ts.map +1 -1
  201. package/dist/_ext/misc.d.ts +11 -11
  202. package/dist/_ext/misc.d.ts.map +1 -1
  203. package/dist/_ext/misc.js +8 -8
  204. package/dist/_ext/ord.ext.d.ts +23 -0
  205. package/dist/_ext/ord.ext.d.ts.map +1 -0
  206. package/dist/_ext/ord.ext.js +44 -0
  207. package/dist/builtin.d.ts +51 -0
  208. package/dist/builtin.d.ts.map +1 -0
  209. package/dist/builtin.js +2 -0
  210. package/dist/client/clientFor.d.ts +1 -1
  211. package/dist/client/clientFor.d.ts.map +1 -1
  212. package/dist/client/clientFor.js +2 -2
  213. package/dist/client/config.d.ts +1 -1
  214. package/dist/client/config.d.ts.map +1 -1
  215. package/dist/client/config.js +2 -2
  216. package/dist/client/errors.js +1 -1
  217. package/dist/http/http-client.d.ts +43 -0
  218. package/dist/http/http-client.d.ts.map +1 -0
  219. package/dist/http/http-client.js +30 -0
  220. package/dist/ids.d.ts +3 -3
  221. package/dist/ids.d.ts.map +1 -1
  222. package/dist/ids.js +2 -2
  223. package/dist/index.d.ts +1 -1
  224. package/dist/index.d.ts.map +1 -1
  225. package/dist/index.js +2 -2
  226. package/dist/lib.d.ts +22 -4
  227. package/dist/lib.d.ts.map +1 -1
  228. package/dist/lib.js +20 -5
  229. package/dist/logger.d.ts.map +1 -1
  230. package/dist/logger.js +2 -2
  231. package/dist/transform.d.ts +12 -0
  232. package/dist/transform.d.ts.map +1 -0
  233. package/dist/transform.js +39 -0
  234. package/dist/utils/effectify.d.ts +210 -0
  235. package/dist/utils/effectify.d.ts.map +1 -0
  236. package/dist/utils/effectify.js +19 -0
  237. package/dist/utils/extend.d.ts +3 -0
  238. package/dist/utils/extend.d.ts.map +1 -0
  239. package/dist/utils/extend.js +9 -0
  240. package/dist/utils/logger.d.ts +12 -0
  241. package/dist/utils/logger.d.ts.map +1 -0
  242. package/dist/utils/logger.js +15 -0
  243. package/dist/utils.d.ts +192 -1
  244. package/dist/utils.d.ts.map +1 -1
  245. package/dist/utils.js +332 -2
  246. package/dist/validation/validators.d.ts +11 -0
  247. package/dist/validation/validators.d.ts.map +1 -0
  248. package/dist/validation/validators.js +26 -0
  249. package/dist/validation.d.ts +13 -0
  250. package/dist/validation.d.ts.map +1 -0
  251. package/dist/validation.js +14 -0
  252. package/package.json +360 -9
  253. package/src/Array.ts +127 -0
  254. package/src/Chunk.ts +112 -0
  255. package/src/Config/SecretURL.ts +3 -3
  256. package/src/Config/internal/configSecretURL.ts +1 -1
  257. package/src/Context.ts +293 -0
  258. package/src/Dictionary.ts +669 -0
  259. package/src/Effect.ts +265 -0
  260. package/src/Function.ts +175 -0
  261. package/src/Inputify.type.ts +1 -1
  262. package/src/NonEmptySet.ts +3 -0
  263. package/src/NonEmptySetAspects.ts +1 -0
  264. package/src/NonEmptySetBase.ts +109 -0
  265. package/src/Object.ts +19 -0
  266. package/src/Operations.ts +1 -1
  267. package/src/Option.ts +82 -0
  268. package/src/Prelude.code.ts +26 -0
  269. package/src/Prelude.ts +220 -0
  270. package/src/Pure.ts +37 -30
  271. package/src/Schema/Class.ts +225 -0
  272. package/src/Schema/FastCheck.ts +23 -0
  273. package/src/Schema/Methods.ts +8 -0
  274. package/src/Schema/brand.ts +50 -0
  275. package/src/Schema/email.ts +22 -0
  276. package/src/Schema/ext.ts +273 -0
  277. package/src/Schema/moreStrings.ts +260 -0
  278. package/src/Schema/numbers.ts +83 -0
  279. package/src/Schema/phoneNumber.ts +24 -0
  280. package/src/Schema/schema.ts +6 -0
  281. package/src/Schema/strings.ts +60 -0
  282. package/src/{schema.ts → Schema.ts} +52 -20
  283. package/src/Set.ts +674 -0
  284. package/src/Struct.ts +54 -0
  285. package/src/Tag.ts +20 -0
  286. package/src/Unify.ts +56 -0
  287. package/src/Widen.type.ts +1 -1
  288. package/src/_ext/misc.ts +22 -22
  289. package/src/_ext/ord.ext.ts +49 -0
  290. package/src/builtin.ts +64 -0
  291. package/src/client/clientFor.ts +1 -1
  292. package/src/client/config.ts +1 -1
  293. package/src/client/errors.ts +1 -1
  294. package/src/http/http-client.ts +73 -0
  295. package/src/ids.ts +3 -3
  296. package/src/index.ts +1 -1
  297. package/src/lib.ts +88 -4
  298. package/src/logger.ts +1 -1
  299. package/src/transform.ts +80 -0
  300. package/src/utils/effectify.ts +259 -0
  301. package/src/utils/extend.ts +9 -0
  302. package/src/utils/logger.ts +24 -0
  303. package/src/utils.ts +805 -1
  304. package/src/validation/validators.ts +32 -0
  305. package/src/validation.ts +18 -0
  306. package/tsconfig.src.json +1 -5
  307. package/_cjs/schema.cjs +0 -110
  308. package/_cjs/schema.cjs.map +0 -1
  309. package/dist/schema.d.ts.map +0 -1
  310. package/dist/schema.js +0 -73
package/src/Struct.ts ADDED
@@ -0,0 +1,54 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import type { Types } from "effect"
3
+ import * as Struct from "effect/Struct"
4
+
5
+ export * from "effect/Struct"
6
+
7
+ /**
8
+ * Create a new object by picking properties of an existing object.
9
+ *
10
+ * @example
11
+ * import { pick } from "effect/Struct"
12
+ * import { pipe } from "effect/Function"
13
+ *
14
+ * assert.deepStrictEqual(pipe({ a: "a", b: 1, c: true }, pick("a", "b")), { a: "a", b: 1 })
15
+ * assert.deepStrictEqual(pick({ a: "a", b: 1, c: true }, "a", "b"), { a: "a", b: 1 })
16
+ *
17
+ * @since 2.0.0
18
+ */
19
+ export const pick: {
20
+ <Keys extends Array<PropertyKey>>(
21
+ ...keys: Keys
22
+ ): <S extends { [K in Keys[number]]?: any }>(
23
+ s: S
24
+ ) => Types.MatchRecord<S, { [K in Keys[number]]?: S[K] }, Pick<S, Keys[number]>>
25
+ <S extends object, Keys extends Array<keyof S>>(
26
+ s: S,
27
+ ...keys: Keys
28
+ ): Types.MatchRecord<S, { [K in Keys[number]]?: S[K] }, Pick<S, Keys[number]>>
29
+ } = Struct.pick
30
+
31
+ export type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K>
32
+ : never
33
+
34
+ /**
35
+ * Create a new object by omitting properties of an existing object.
36
+ *
37
+ * @example
38
+ * import { omit } from "effect/Struct"
39
+ * import { pipe } from "effect/Function"
40
+ *
41
+ * assert.deepStrictEqual(pipe({ a: "a", b: 1, c: true }, omit("c")), { a: "a", b: 1 })
42
+ * assert.deepStrictEqual(omit({ a: "a", b: 1, c: true }, "c"), { a: "a", b: 1 })
43
+ *
44
+ * @since 2.0.0
45
+ */
46
+ export const omit: {
47
+ <Keys extends Array<PropertyKey>>(
48
+ ...keys: Keys
49
+ ): <S extends { [K in Keys[number]]?: any }>(s: S) => DistributiveOmit<S, Keys[number]>
50
+ <S extends object, Keys extends Array<keyof S>>(
51
+ s: S,
52
+ ...keys: Keys
53
+ ): DistributiveOmit<S, Keys[number]>
54
+ } = Struct.omit as any
package/src/Tag.ts ADDED
@@ -0,0 +1,20 @@
1
+ // /**
2
+ // * @tsplus fluent effect/data/Context/Tag withEffect_
3
+ // */
4
+ // export function accessM_<T, I, R, E, A>(self: Tag<T, I>, f: (x: T) => Effect<R, E, A>) {
5
+ // return Effect.serviceWithEffect(self)(f)
6
+ // }
7
+
8
+ import { Layer } from "effect"
9
+
10
+ // /**
11
+ // * @tsplus fluent effect/data/Context/Tag with_
12
+ // */
13
+ // export function access_<T, I, B>(self: Tag<T, I>, f: (x: T) => B) {
14
+ // return Effect.serviceWith(self)(f)
15
+ // }
16
+
17
+ /**
18
+ * @tsplus fluent effect/data/Context/Tag makeLayer
19
+ */
20
+ export const makeLayer = Layer.succeed
package/src/Unify.ts ADDED
@@ -0,0 +1,56 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ // TODO: Add effect cause/exit etc
3
+
4
+ import type { Chunk, Either, Option } from "effect"
5
+ import type { Effect, EffectTypeId } from "effect/Effect"
6
+
7
+ /**
8
+ * @tsplus unify effect/io/Effect
9
+ */
10
+ export function unifyEffect<X extends { readonly [EffectTypeId]: Effect.VarianceStruct<any, any, any> }>(
11
+ self: X
12
+ ): Effect<
13
+ [X] extends [{ readonly [EffectTypeId]: { _A: (_: never) => infer A } }] ? A : never,
14
+ [X] extends [{ readonly [EffectTypeId]: { _E: (_: never) => infer E } }] ? E : never,
15
+ [X] extends [{ readonly [EffectTypeId]: { _R: (_: never) => infer R } }] ? R : never
16
+ > {
17
+ return self as any
18
+ }
19
+
20
+ /**
21
+ * @tsplus unify effect/data/Chunk
22
+ */
23
+ export function unifyChunk<X extends Chunk.Chunk<any>>(
24
+ self: X
25
+ ): Chunk.Chunk<[X] extends [Chunk.Chunk<infer A>] ? A : never> {
26
+ return self
27
+ }
28
+
29
+ /**
30
+ * @tsplus unify effect/data/Either
31
+ * @tsplus unify effect/data/Either.Left
32
+ * @tsplus unify effect/data/Either.Right
33
+ */
34
+ export function unifyEither<X extends Either.Either<any, any>>(
35
+ self: X
36
+ ): Either.Either<
37
+ X extends Either.Right<any, infer AX> ? AX : X extends Either.Left<any, infer AX> ? AX : never,
38
+ X extends Either.Left<infer EX, any> ? EX : X extends Either.Right<infer EX, any> ? EX : never
39
+ > {
40
+ return self
41
+ }
42
+
43
+ /**
44
+ * @tsplus unify effect/data/Option
45
+ * @tsplus unify effect/data/Option.Some
46
+ * @tsplus unify effect/data/Option.None
47
+ */
48
+ export function unifyOption<X extends Option.Option<any>>(
49
+ self: X
50
+ ): Option.Option<
51
+ X extends Option.Some<infer A> ? A
52
+ : X extends Option.None<infer A> ? A
53
+ : never
54
+ > {
55
+ return self
56
+ }
package/src/Widen.type.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import type { BuiltInObject } from "@effect-app/core/utils"
2
+ import type { BuiltInObject } from "effect-app/utils"
3
3
 
4
4
  type AllKeys<T> = T extends any ? keyof T : never
5
5
 
package/src/_ext/misc.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { Effect, Either, Option, type Scope } from "@effect-app/core"
2
- import type { LazyArg } from "@effect-app/core/Function"
1
+ import { Effect, Either, Option, type Scope } from "effect"
2
+ import type { LazyArg } from "effect-app/Function"
3
3
 
4
- export type _R<T extends Effect<any, any, any>> = [T] extends [
5
- Effect<any, any, infer R>
4
+ export type _R<T extends Effect.Effect<any, any, any>> = [T] extends [
5
+ Effect.Effect<any, any, infer R>
6
6
  ] ? R
7
7
  : never
8
8
 
9
- export type _E<T extends Effect<any, any, any>> = [T] extends [
10
- Effect<any, infer E, any>
9
+ export type _E<T extends Effect.Effect<any, any, any>> = [T] extends [
10
+ Effect.Effect<any, infer E, any>
11
11
  ] ? E
12
12
  : never
13
13
 
@@ -15,9 +15,9 @@ export type _E<T extends Effect<any, any, any>> = [T] extends [
15
15
  * @tsplus fluent effect/data/Option encaseInEffect
16
16
  */
17
17
  export function encaseMaybeInEffect_<E, A>(
18
- o: Option<A>,
18
+ o: Option.Option<A>,
19
19
  onError: LazyArg<E>
20
- ): Effect<A, E> {
20
+ ): Effect.Effect<A, E> {
21
21
  return Option.match(o, { onNone: () => Effect.fail(onError()), onSome: Effect.succeed })
22
22
  }
23
23
 
@@ -25,7 +25,7 @@ export function encaseMaybeInEffect_<E, A>(
25
25
  * @tsplus fluent effect/data/Option encaseInEither
26
26
  */
27
27
  export function encaseMaybeEither_<E, A>(
28
- o: Option<A>,
28
+ o: Option.Option<A>,
29
29
  onError: LazyArg<E>
30
30
  ): Either.Either<A, E> {
31
31
  return Option.match(o, { onNone: () => Either.left(onError()), onSome: Either.right })
@@ -35,7 +35,7 @@ export function encaseMaybeEither_<E, A>(
35
35
  * @tsplus getter effect/io/Effect toNullable
36
36
  */
37
37
  export function toNullable<R, E, A>(
38
- self: Effect<Option<A>, E, R>
38
+ self: Effect.Effect<Option.Option<A>, E, R>
39
39
  ) {
40
40
  return Effect.map(self, (_) => Option.getOrNull(_))
41
41
  }
@@ -44,9 +44,9 @@ export function toNullable<R, E, A>(
44
44
  * @tsplus fluent effect/io/Effect scope
45
45
  */
46
46
  export function scope<R, E, A, R2, E2, A2>(
47
- scopedEffect: Effect<A, E, R | Scope>,
48
- effect: Effect<A2, E2, R2>
49
- ): Effect<A2, E | E2, Exclude<R | R2, Scope>> {
47
+ scopedEffect: Effect.Effect<A, E, R | Scope.Scope>,
48
+ effect: Effect.Effect<A2, E2, R2>
49
+ ): Effect.Effect<A2, E | E2, Exclude<R | R2, Scope.Scope>> {
50
50
  return Effect.zipRight(scopedEffect, effect).pipe(Effect.scoped)
51
51
  }
52
52
 
@@ -54,9 +54,9 @@ export function scope<R, E, A, R2, E2, A2>(
54
54
  * @tsplus fluent effect/io/Effect flatMapScoped
55
55
  */
56
56
  export function flatMapScoped<R, E, A, R2, E2, A2>(
57
- scopedEffect: Effect<A, E, R | Scope>,
58
- effect: (a: A) => Effect<A2, E2, R2>
59
- ): Effect<A2, E | E2, Exclude<R | R2, Scope>> {
57
+ scopedEffect: Effect.Effect<A, E, R | Scope.Scope>,
58
+ effect: (a: A) => Effect.Effect<A2, E2, R2>
59
+ ): Effect.Effect<A2, E | E2, Exclude<R | R2, Scope.Scope>> {
60
60
  return scopedEffect.pipe(Effect.flatMap(effect), Effect.scoped)
61
61
  }
62
62
 
@@ -64,9 +64,9 @@ export function flatMapScoped<R, E, A, R2, E2, A2>(
64
64
  // * @tsplus fluent effect/io/Effect withScoped
65
65
  // */
66
66
  // export function withScoped<R, E, A, R2, E2, A2>(
67
- // effect: Effect<R2, E2, A2>,
68
- // scopedEffect: Effect<R | Scope, E, A>
69
- // ): Effect<Exclude<R | R2, Scope>, E | E2, A2> {
67
+ // effect: Effect.Effect<R2, E2, A2>,
68
+ // scopedEffect: Effect.Effect<R | Scope.Scope, E, A>
69
+ // ): Effect.Effect<Exclude<R | R2, Scope.Scope>, E | E2, A2> {
70
70
  // return scopedEffect.zipRight(effect).scoped
71
71
  // }
72
72
 
@@ -74,8 +74,8 @@ export function flatMapScoped<R, E, A, R2, E2, A2>(
74
74
  // * @tsplus fluent effect/io/Effect withScoped
75
75
  // */
76
76
  // export function withScopedFlatMap<R, E, A, R2, E2, A2>(
77
- // effect: (a: A) => Effect<R2, E2, A2>,
78
- // scopedEffect: Effect<R | Scope, E, A>
79
- // ): Effect<Exclude<R | R2, Scope>, E | E2, A2> {
77
+ // effect: (a: A) => Effect.Effect<R2, E2, A2>,
78
+ // scopedEffect: Effect.Effect<R | Scope.Scope, E, A>
79
+ // ): Effect.Effect<Exclude<R | R2, Scope.Scope>, E | E2, A2> {
80
80
  // return scopedEffect.flatMap(effect).scoped
81
81
  // }
@@ -0,0 +1,49 @@
1
+ import { Chunk } from "effect"
2
+ import type { Equivalence } from "effect"
3
+
4
+ /**
5
+ * @tsplus getter Generator toArray
6
+ */
7
+ export function toArray<A>(
8
+ gen: Generator<A, void, unknown>
9
+ ) {
10
+ return Array.from(gen)
11
+ }
12
+
13
+ /**
14
+ * Remove duplicates from an array, keeping the first occurrence of an element.
15
+ *
16
+ * @tsplus static effect/data/Chunk.Ops uniq
17
+ * @tsplus pipeable effect/data/Chunk uniq
18
+ */
19
+ export function uniq<A>(E: Equivalence.Equivalence<A>) {
20
+ return (self: Chunk.Chunk<A>): Chunk.Chunk<A> => {
21
+ let out = Chunk.fromIterable<A>([])
22
+ for (let i = 0; i < self.length; i++) {
23
+ const a = Chunk.unsafeGet(self, i)
24
+ if (!elem(E, a)(out)) {
25
+ out = Chunk.append(out, a)
26
+ }
27
+ }
28
+ return self.length === out.length ? self : out
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Test if a value is a member of an array. Takes a `Equivalence.Equivalence<A>` as a single
34
+ * argument which returns the function to use to search for a value of type `A`
35
+ * in an array of type `Chunk.Chunk<A>`.
36
+ *
37
+ * @tsplus static effect/data/Chunk.Ops elem2
38
+ * @tsplus pipeable effect/data/Chunk elem2
39
+ */
40
+ export function elem<A>(E: Equivalence.Equivalence<A>, value: A) {
41
+ return (self: Chunk.Chunk<A>): boolean => {
42
+ for (let i = 0; i < self.length; i++) {
43
+ if (E(Chunk.unsafeGet(self, i), value)) {
44
+ return true
45
+ }
46
+ }
47
+ return false
48
+ }
49
+ }
package/src/builtin.ts ADDED
@@ -0,0 +1,64 @@
1
+ import type { NonEmptyArray, NonEmptyReadonlyArray } from "effect/Array"
2
+
3
+ declare global {
4
+ interface String {
5
+ /**
6
+ * Split a string into substrings using the specified separator and return them as an array.
7
+ * @param splitter An object that can split a string.
8
+ * @param limit A value used to limit the number of elements returned in the array.
9
+ */
10
+ split(splitter: { [Symbol.split](string: string, limit?: number): string[] }, limit?: number): [string, ...string[]]
11
+
12
+ /**
13
+ * Split a string into substrings using the specified separator and return them as an array.
14
+ * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned.
15
+ * @param limit A value used to limit the number of elements returned in the array.
16
+ */
17
+ split(separator: string | RegExp, limit?: number): [string, ...string[]]
18
+ }
19
+
20
+ interface JSON {
21
+ /**
22
+ * Converts a JavaScript Object Notation (JSON) string into an object.
23
+ * @param text A valid JSON string.
24
+ * @param reviver A function that transforms the results. This function is called for each member of the object.
25
+ * If a member contains nested objects, the nested objects are transformed before the parent object is.
26
+ */
27
+ parse(text: string, reviver?: (this: any, key: string, value: any) => any): unknown
28
+ }
29
+
30
+ interface Body {
31
+ json(): Promise<unknown>
32
+ }
33
+
34
+ interface Array<T> {
35
+ map<A, B>(
36
+ this: NonEmptyArray<A>,
37
+ map: (a: A, index: number) => B
38
+ ): NonEmptyArray<B>
39
+ }
40
+ interface ReadonlyArray<T> {
41
+ // Subsequent property declarations must have the same type. Property 'length' must be of type 'number', but here has type 'NonNegativeInt'.
42
+ // readonly length: NonNegativeInt
43
+
44
+ map<A, B>(
45
+ this: NonEmptyReadonlyArray<A>,
46
+ map: (a: A, index: number) => B
47
+ ): NonEmptyReadonlyArray<B>
48
+ }
49
+ }
50
+
51
+ declare module "effect/Option" {
52
+ export interface None<out A> {
53
+ get value(): A | undefined
54
+ }
55
+ }
56
+
57
+ declare module "effect/Either" {
58
+ export interface Left<out L, out R> {
59
+ get right(): R | undefined
60
+ }
61
+ export interface Right<out L, out R> {
62
+ get left(): L | undefined
63
+ }
64
+ }
@@ -5,7 +5,6 @@ import { RpcResolver } from "@effect/rpc"
5
5
  import { HttpRpcResolver } from "@effect/rpc-http"
6
6
  import type { RpcRouter } from "@effect/rpc/RpcRouter"
7
7
  import { Record } from "effect"
8
- import { S } from "effect-app"
9
8
  import { ApiConfig } from "effect-app/client"
10
9
  import { HttpClient, HttpClientRequest } from "effect-app/http"
11
10
  import { typedKeysOf } from "effect-app/utils"
@@ -14,6 +13,7 @@ import type { Path } from "path-parser"
14
13
  import qs from "query-string"
15
14
  import type { Schema } from "../lib.js"
16
15
  import { Effect, flow, HashMap, Layer, Option, Predicate, Struct } from "../lib.js"
16
+ import * as S from "../Schema.js"
17
17
 
18
18
  export function makePathWithQuery(
19
19
  path: Path,
@@ -1,4 +1,4 @@
1
- import { Context, Effect, type HashMap, Layer, type Option } from "@effect-app/core"
1
+ import { Context, Effect, type HashMap, Layer, type Option } from "../lib.js"
2
2
 
3
3
  export interface ApiConfig {
4
4
  apiUrl: string
@@ -1,4 +1,4 @@
1
- import { TaggedError } from "effect-app/schema"
1
+ import { TaggedError } from "effect-app/Schema"
2
2
  import { makeFiberFailure } from "effect/Runtime"
3
3
  import { Cause, S } from "../lib.js"
4
4
 
@@ -0,0 +1,73 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+
3
+ import type { Option } from "../Option.js"
4
+
5
+ export const Method = {
6
+ GET: null,
7
+ POST: null,
8
+ PUT: null,
9
+ DELETE: null,
10
+ PATCH: null
11
+ }
12
+ export type Method = keyof typeof Method
13
+
14
+ /** @deprecated use @effect/platform */
15
+ export type Headers = Record<string, string>
16
+
17
+ /** @deprecated use @effect/platform */
18
+ export interface Response<Body> {
19
+ body: Option<Body>
20
+ headers: Headers
21
+ status: number
22
+ }
23
+
24
+ /** @deprecated use @effect/platform */
25
+ export const HttpErrorReason = {
26
+ Request: "HttpErrorRequest",
27
+ Response: "HttpErrorResponse"
28
+ } as const
29
+
30
+ /** @deprecated use @effect/platform */
31
+ export type HttpErrorReason = typeof HttpErrorReason
32
+
33
+ /** @deprecated use @effect/platform */
34
+ export interface HttpResponseError<ErrorBody> {
35
+ _tag: HttpErrorReason["Response"]
36
+ response: Response<ErrorBody>
37
+ }
38
+
39
+ /** @deprecated use @effect/platform */
40
+ export function isHttpResponseError(
41
+ u: unknown
42
+ ): u is HttpResponseError<unknown> {
43
+ return (
44
+ typeof u === "object"
45
+ && u !== null
46
+ && (u as any)["_tag"] === HttpErrorReason.Response
47
+ )
48
+ }
49
+
50
+ /** @deprecated use @effect/platform */
51
+ export interface HttpRequestError {
52
+ _tag: HttpErrorReason["Request"]
53
+ error: Error
54
+ }
55
+
56
+ /** @deprecated use @effect/platform */
57
+ export function isHttpRequestError(u: unknown): u is HttpRequestError {
58
+ return (
59
+ typeof u === "object"
60
+ && u !== null
61
+ && (u as any)["_tag"] === HttpErrorReason.Request
62
+ )
63
+ }
64
+
65
+ /** @deprecated use @effect/platform */
66
+ export function isHttpError(u: unknown): u is HttpError<unknown> {
67
+ return isHttpRequestError(u) || isHttpResponseError(u)
68
+ }
69
+
70
+ /** @deprecated use @effect/platform */
71
+ export type HttpError<ErrorBody> =
72
+ | HttpRequestError
73
+ | HttpResponseError<ErrorBody>
package/src/ids.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { B } from "@effect-app/core/Schema/schema"
2
- import { brandedStringId, NonEmptyString255, StringId, withDefaultMake } from "effect-app/schema"
3
- import type { Schema, StringIdBrand } from "effect-app/schema"
1
+ import { brandedStringId, NonEmptyString255, StringId, withDefaultMake } from "effect-app/Schema"
2
+ import type { Schema, StringIdBrand } from "effect-app/Schema"
3
+ import type { B } from "effect-app/Schema/schema"
4
4
  import type { Simplify } from "effect/Types"
5
5
  import { S } from "./index.js"
6
6
  import { extendM } from "./utils.js"
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- import "@effect-app/core/builtin"
1
+ import "./builtin.js"
2
2
 
3
3
  export * from "./lib.js"
package/src/lib.ts CHANGED
@@ -1,4 +1,88 @@
1
- export * from "@effect-app/core"
2
- export { copy } from "@effect-app/core/utils"
3
- export * as SecretURL from "effect-app/Config/SecretURL"
4
- export * as S from "effect-app/schema"
1
+ import type { YieldWrap } from "effect/Utils"
2
+ import { Effect } from "./Prelude.js"
3
+
4
+ export * as Fnc from "./Function.js"
5
+ export * as Record from "./Object.js"
6
+ export * as Utils from "./utils.js"
7
+
8
+ export * from "effect"
9
+
10
+ // we cannot export types colliding with namespaces from .ts files, only from .d.ts files with custom .js trick, applied in effect-app
11
+ // for app land, it may make sense to create an app/prelude?
12
+ export * from "./Prelude.js"
13
+
14
+ export {
15
+ Array,
16
+ Cause,
17
+ Chunk,
18
+ Config,
19
+ Context,
20
+ Duration,
21
+ Effect,
22
+ Either,
23
+ Equal,
24
+ Equivalence,
25
+ Exit,
26
+ FiberRef,
27
+ HashMap,
28
+ Layer,
29
+ Option,
30
+ Order,
31
+ Ref,
32
+ Schema,
33
+ Scope
34
+ } from "./Prelude.js"
35
+
36
+ export * as Struct from "./Struct.js"
37
+
38
+ export * as SecretURL from "./Config/SecretURL.js"
39
+ export * as S from "./Schema.js"
40
+ export { copy } from "./utils.js"
41
+
42
+ // Simply Effect! https://github.com/kasperpeulen/simply-effect
43
+ type InferE<Eff extends YieldWrap<Effect<any, any, any>>> = [
44
+ Eff
45
+ ] extends [never] ? never
46
+ : [Eff] extends [YieldWrap<Effect<infer _A, infer E, infer _R>>] ? E
47
+ : never
48
+ type InferR<Eff extends YieldWrap<Effect<any, any, any>>> = [
49
+ Eff
50
+ ] extends [never] ? never
51
+ : [Eff] extends [YieldWrap<Effect<infer _A, infer _E, infer R>>] ? R
52
+ : never
53
+
54
+ export function effect<
55
+ Eff extends YieldWrap<Effect<any, any, any>>,
56
+ AEff
57
+ >(
58
+ f: () => Generator<Eff, AEff, never>
59
+ ): Effect<AEff, InferE<Eff>, InferR<Eff>>
60
+ export function effect<
61
+ Eff extends YieldWrap<Effect<any, any, any>>,
62
+ AEff,
63
+ Args extends any[]
64
+ >(
65
+ f: (...args: Args) => Generator<Eff, AEff, never>
66
+ ): (...args: Args) => Effect<AEff, InferE<Eff>, InferR<Eff>>
67
+ export function effect<
68
+ Self,
69
+ Eff extends YieldWrap<Effect<any, any, any>>,
70
+ AEff
71
+ >(
72
+ self: Self,
73
+ f: (this: Self) => Generator<Eff, AEff, never>
74
+ ): Effect<AEff, InferE<Eff>, InferR<Eff>>
75
+ export function effect<
76
+ Eff extends YieldWrap<Effect<any, any, any>>,
77
+ AEff,
78
+ Args extends any[],
79
+ Self
80
+ >(
81
+ self: Self,
82
+ f: (this: Self, ...args: Args) => Generator<Eff, AEff, never>
83
+ ): (...args: Args) => Effect<AEff, InferE<Eff>, InferR<Eff>>
84
+ export function effect() {
85
+ const f = arguments.length === 1 ? arguments[0] : arguments[1].bind(arguments[0])
86
+ if (f.length === 0) return Effect.gen(f)
87
+ return (...args: any) => Effect.gen(() => f(...args))
88
+ }
package/src/logger.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { makeLog } from "@effect-app/core/utils/logger"
1
+ import { makeLog } from "effect-app/utils/logger"
2
2
 
3
3
  export const PreludeLogger = makeLog("effect-app", "info")
@@ -0,0 +1,80 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { Option } from "effect"
3
+ import type { NonEmptyReadonlyArray } from "effect/Array"
4
+ import type { Misc, Union } from "ts-toolbelt"
5
+ import type * as SET from "./Set.js"
6
+
7
+ // type SomeObject = {
8
+ // 0: Option<string>
9
+ // a: {
10
+ // b: Option<string>
11
+ // g: Option<Option<string>>
12
+ // h: Option<{ i: Option<boolean> }>
13
+ // }
14
+ // c: { d: Array<Option<{ e: Option<boolean> }>> }
15
+ // }
16
+ // type test0 = Transform<SomeObject>
17
+ // type test1 = Transform<SomeObject[]>
18
+
19
+ type OptOf<A> = Union.Exclude<
20
+ A extends Option.Some<infer X> ? X | null : A,
21
+ Option.None<any>
22
+ >
23
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
+
25
+ export type TransformRoot<O> = O extends Option.Option<any> ? Transform<OptOf<O>>
26
+ : Transform<O>
27
+ export type Transform<O> = O extends Misc.BuiltIn | Misc.Primitive ? O
28
+ : {
29
+ [K in keyof O]: OptOf<O[K]> extends infer X ? X extends (infer Y)[] ? OptOf<Transform<Y>>[]
30
+ : X extends NonEmptyReadonlyArray<infer Y> ? NonEmptyReadonlyArray<OptOf<Transform<Y>>>
31
+ : X extends SET.Set<infer Y> ? SET.Set<OptOf<Transform<Y>>>
32
+ : X extends readonly (infer Y)[] ? readonly OptOf<Transform<Y>>[]
33
+ : Transform<X>
34
+ : never
35
+ }
36
+
37
+ export const encodeOptsAsNullable = <T>(root: T): TransformRoot<T> => encodeOptsAsNullable_(root, new Map())
38
+
39
+ const encodeOptsAsNullable_ = (value: any, cacheMap: Map<any, any>): any => {
40
+ const cacheEntry = cacheMap.get(value)
41
+ if (cacheEntry) {
42
+ return cacheEntry
43
+ }
44
+
45
+ if (Array.isArray(value)) {
46
+ const newAr: typeof value = []
47
+ cacheMap.set(value, newAr)
48
+ value.forEach((x) => newAr.push(encodeOptsAsNullable_(x, cacheMap)))
49
+ return newAr
50
+ }
51
+
52
+ if (
53
+ value instanceof Date
54
+ || value instanceof Function
55
+ || value instanceof Promise
56
+ ) {
57
+ return value
58
+ }
59
+
60
+ if (value instanceof Set) {
61
+ const newValue = [...value]
62
+ cacheMap.set(value, newValue)
63
+ return newValue
64
+ }
65
+
66
+ if (value instanceof Object) {
67
+ if (value._tag === "Some" || value._tag === "None") {
68
+ const v = value as Option.Option<unknown>
69
+ return encodeOptsAsNullable_(Option.getOrNull(v), cacheMap)
70
+ }
71
+ const newObj = {} as Record<string, any>
72
+ cacheMap.set(value, newObj)
73
+
74
+ Object.keys(value).forEach((key) => {
75
+ newObj[key] = encodeOptsAsNullable_(value[key], cacheMap)
76
+ })
77
+ return newObj
78
+ }
79
+ return value
80
+ }