effect-app 4.0.0 → 4.0.2

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 (83) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/Array.d.ts +0 -17
  3. package/dist/Array.d.ts.map +1 -1
  4. package/dist/Array.js +2 -26
  5. package/dist/Chunk.d.ts +3 -27
  6. package/dist/Chunk.d.ts.map +1 -1
  7. package/dist/Chunk.js +4 -39
  8. package/dist/DateTime.d.ts +33 -0
  9. package/dist/DateTime.d.ts.map +1 -0
  10. package/dist/DateTime.js +18 -0
  11. package/dist/Effect.d.ts +0 -11
  12. package/dist/Effect.d.ts.map +1 -1
  13. package/dist/Effect.js +3 -18
  14. package/dist/Function.d.ts +0 -4
  15. package/dist/Function.d.ts.map +1 -1
  16. package/dist/Function.js +1 -7
  17. package/dist/Model/Repository/internal/internal.d.ts.map +1 -1
  18. package/dist/Model/Repository/internal/internal.js +4 -5
  19. package/dist/Model/dsl.d.ts +4 -3
  20. package/dist/Model/dsl.d.ts.map +1 -1
  21. package/dist/Model/dsl.js +6 -4
  22. package/dist/Model/query/new-kid-interpreter.d.ts.map +1 -1
  23. package/dist/Model/query/new-kid-interpreter.js +5 -6
  24. package/dist/Option.d.ts +0 -2
  25. package/dist/Option.d.ts.map +1 -1
  26. package/dist/Option.js +1 -7
  27. package/dist/Pure.d.ts +4 -4
  28. package/dist/Pure.d.ts.map +1 -1
  29. package/dist/Pure.js +16 -16
  30. package/dist/Schema/ext.d.ts +0 -21
  31. package/dist/Schema/ext.d.ts.map +1 -1
  32. package/dist/Schema/ext.js +4 -10
  33. package/dist/Schema.d.ts +1 -1
  34. package/dist/Schema.d.ts.map +1 -1
  35. package/dist/Schema.js +2 -2
  36. package/dist/Set.d.ts.map +1 -1
  37. package/dist/Set.js +6 -5
  38. package/dist/client/apiClientFactory.d.ts.map +1 -1
  39. package/dist/client/apiClientFactory.js +7 -6
  40. package/dist/migration/nativeEffect.d.ts +21 -0
  41. package/dist/migration/nativeEffect.d.ts.map +1 -0
  42. package/dist/migration/nativeEffect.js +598 -0
  43. package/dist/utils.d.ts +0 -6
  44. package/dist/utils.d.ts.map +1 -1
  45. package/dist/utils.js +1 -13
  46. package/dist/waitingGate.d.ts +38 -0
  47. package/dist/waitingGate.d.ts.map +1 -0
  48. package/dist/waitingGate.js +63 -0
  49. package/dist/withToast.d.ts.map +1 -1
  50. package/dist/withToast.js +42 -3
  51. package/package.json +2 -3
  52. package/src/Array.ts +4 -36
  53. package/src/Chunk.ts +4 -53
  54. package/src/DateTime.ts +473 -0
  55. package/src/Effect.ts +3 -22
  56. package/src/Function.ts +0 -7
  57. package/src/Model/Repository/internal/internal.ts +3 -4
  58. package/src/Model/dsl.ts +5 -4
  59. package/src/Model/query/new-kid-interpreter.ts +4 -5
  60. package/src/Option.ts +1 -8
  61. package/src/Pure.ts +15 -15
  62. package/src/Schema/ext.ts +3 -10
  63. package/src/Schema.ts +1 -1
  64. package/src/Set.ts +5 -4
  65. package/src/client/apiClientFactory.ts +8 -7
  66. package/src/migration/nativeEffect.ts +645 -0
  67. package/src/utils.ts +0 -17
  68. package/src/waitingGate.ts +82 -0
  69. package/src/withToast.ts +51 -5
  70. package/test/dateTimeLocal.test.ts +55 -0
  71. package/test/dist/dateTimeLocal.test.d.ts.map +1 -0
  72. package/test/dist/nativeEffectMigration.test.d.ts.map +1 -0
  73. package/test/dist/waitingGate.test.d.ts.map +1 -0
  74. package/test/nativeEffectMigration.test.ts +77 -0
  75. package/test/waitingGate.test.ts +64 -0
  76. package/dist/_ext/date.d.ts +0 -15
  77. package/dist/_ext/date.d.ts.map +0 -1
  78. package/dist/_ext/date.js +0 -16
  79. package/dist/_ext/misc.d.ts +0 -17
  80. package/dist/_ext/misc.d.ts.map +0 -1
  81. package/dist/_ext/misc.js +0 -19
  82. package/src/_ext/date.ts +0 -27
  83. package/src/_ext/misc.ts +0 -49
package/src/Pure.ts CHANGED
@@ -3,8 +3,8 @@ import * as Chunk from "effect/Chunk"
3
3
  import * as Effect from "effect/Effect"
4
4
  import * as Layer from "effect/Layer"
5
5
  import * as Result from "effect/Result"
6
+ import * as Tuple from "effect/Tuple"
6
7
  import * as Context from "./Context.ts"
7
- import { tuple } from "./Function.ts"
8
8
 
9
9
  const S1 = Symbol()
10
10
  const S2 = Symbol()
@@ -159,10 +159,10 @@ export function runAll<R, E, A, W3, S1, S3, S4 extends S1>(
159
159
  )
160
160
  .pipe(
161
161
  Effect.map(
162
- ({ log, state }) => tuple(log, Result.succeed(tuple(state, x)))
162
+ ({ log, state }) => Tuple.make(log, Result.succeed(Tuple.make(state, x)))
163
163
  )
164
164
  ))
165
- .pipe(Effect.catch((err: any) => tagg.useSync((env) => tuple(env.env.log, Result.fail(err)))))
165
+ .pipe(Effect.catch((err: any) => tagg.useSync((env) => Tuple.make(env.env.log, Result.fail(err)))))
166
166
  return Effect.provide(a, Layer.succeed(tagg, { env: makePureEnv<W3, S3, S4>(s) as any }) as any) as any
167
167
  }
168
168
 
@@ -170,7 +170,7 @@ export function runResult<R, E, A, W3, S1, S3, S4 extends S1>(
170
170
  self: Effect.Effect<A, E, FixEnv<R, W3, S1, S3>>,
171
171
  s: S4
172
172
  ) {
173
- return Effect.map(runAll(self, s), ([log, r]) => tuple(log, Result.map(r, ([s]) => s)))
173
+ return Effect.map(runAll(self, s), ([log, r]) => Tuple.make(log, Result.map(r, ([s]) => s)))
174
174
  }
175
175
 
176
176
  export function runTerm<R, E, A, W3, S1, S3, S4 extends S1>(
@@ -179,7 +179,7 @@ export function runTerm<R, E, A, W3, S1, S3, S4 extends S1>(
179
179
  ) {
180
180
  return Effect.flatMap(
181
181
  runAll(self, s),
182
- ([evts, r]) => Effect.map(Effect.fromResult(r), ([s3, a]) => tuple(s3, Chunk.toArray(evts), a))
182
+ ([evts, r]) => Effect.map(Effect.fromResult(r), ([s3, a]) => Tuple.make(s3, Chunk.toArray(evts), a))
183
183
  )
184
184
  }
185
185
 
@@ -187,14 +187,14 @@ export function runTermDiscard<R, E, A, W3, S1, S3, S4 extends S1>(
187
187
  self: Effect.Effect<A, E, FixEnv<R, W3, S1, S3>>,
188
188
  s: S4
189
189
  ) {
190
- return Effect.map(runTerm(self, s), ([s3, w3]) => tuple(s3, w3))
190
+ return Effect.map(runTerm(self, s), ([s3, w3]) => Tuple.make(s3, w3))
191
191
  }
192
192
 
193
193
  export function runA<R, E, A, W3, S1, S3, S4 extends S1>(
194
194
  self: Effect.Effect<A, E, FixEnv<R, W3, S1, S3>>,
195
195
  s: S4
196
196
  ) {
197
- return Effect.map(runAll(self, s), ([log, r]) => tuple(log, Result.map(r, ([, a]) => a)))
197
+ return Effect.map(runAll(self, s), ([log, r]) => Tuple.make(log, Result.map(r, ([, a]) => a)))
198
198
  }
199
199
 
200
200
  export function modify<S2, A, S3>(
@@ -224,14 +224,14 @@ export function modifyM<W, R, E, A, S2, S3>(
224
224
  export function updateWith<S2, S3>(upd: (s: S2) => S3) {
225
225
  return modify((_: S2) => {
226
226
  const r = upd(_)
227
- return tuple(r, r)
227
+ return Tuple.make(r, r)
228
228
  })
229
229
  }
230
230
 
231
231
  export function updateWithEffect<W, R, E, S2, S3>(
232
232
  upd: (s: S2, log: (evt: W) => PureLogT<W>) => Effect.Effect<S3, E, FixEnv<R, W, S2, S3>>
233
233
  ): Effect.Effect<S3, E, FixEnv<R, W, S2, S3>> {
234
- return modifyM((_: S2) => Effect.map(upd(_, log), (_) => tuple(_, _)))
234
+ return modifyM((_: S2) => Effect.map(upd(_, log), (_) => Tuple.make(_, _)))
235
235
  }
236
236
 
237
237
  export type FixEnv<R, W, S, S2> =
@@ -301,11 +301,11 @@ export type FixEnv<R, W, S, S2> =
301
301
  // }
302
302
 
303
303
  // function update<S3>(upd: (s: S2) => S3) {
304
- // return modify(_ => tuple(upd(_), void 0 as void))
304
+ // return modify(_ => Tuple.make(upd(_), void 0 as void))
305
305
  // }
306
306
 
307
307
  // function updateM<R, E, S3>(upd: (s: S2) => Effect.Effect<R, E, S3>) {
308
- // return modifyM(_ => upd(_).map(_ => tuple(_, void 0 as void)))
308
+ // return modifyM(_ => upd(_).map(_ => Tuple.make(_, void 0 as void)))
309
309
  // }
310
310
 
311
311
  // const accessLog = Effect.serviceWithEffect(tag, _ => _.env.log.get)
@@ -321,12 +321,12 @@ export type FixEnv<R, W, S, S2> =
321
321
  // ).map(
322
322
  // (
323
323
  // { log, state }
324
- // ) => tuple(log, Either.right(tuple(state, x)) as Either.Either<E, readonly [S3, A]>)
324
+ // ) => Tuple.make(log, Either.right(Tuple.make(state, x)) as Either.Either<E, readonly [S3, A]>)
325
325
  // )
326
326
  // ).catchAll(
327
327
  // err =>
328
328
  // accessLog.map(log =>
329
- // tuple(log, Either.left(err) as Either.Either<E, readonly [S3, A]>)
329
+ // Tuple.make(log, Either.left(err) as Either.Either<E, readonly [S3, A]>)
330
330
  // )
331
331
  // ).provideService(tag, { env: makePureEnv<W3, S3, S4>(s) as any }) as any
332
332
  // }
@@ -335,14 +335,14 @@ export type FixEnv<R, W, S, S2> =
335
335
  // self: Effect.Effect<FixEnv<R, W3, S1, S3>, E, A>,
336
336
  // s: S4
337
337
  // ) {
338
- // return runAll(self, s).map(([log, r]) => tuple(log, r.map(([s]) => s)))
338
+ // return runAll(self, s).map(([log, r]) => Tuple.make(log, r.map(([s]) => s)))
339
339
  // }
340
340
 
341
341
  // function runA<R, E, A, W3, S1, S3, S4 extends S1>(
342
342
  // self: Effect.Effect<FixEnv<R, W3, S1, S3>, E, A>,
343
343
  // s: S4
344
344
  // ) {
345
- // return runAll(self, s).map(([log, r]) => tuple(log, r.map(([, a]) => a)))
345
+ // return runAll(self, s).map(([log, r]) => Tuple.make(log, r.map(([, a]) => a)))
346
346
  // }
347
347
 
348
348
  // return {
package/src/Schema/ext.ts CHANGED
@@ -43,7 +43,7 @@ import * as Struct from "effect/Struct"
43
43
  import { type NonEmptyReadonlyArray } from "../Array.ts"
44
44
  import * as Context from "../Context.ts"
45
45
  import * as SchemaAST from "../SchemaAST.ts"
46
- import { extendM, typedKeysOf } from "../utils.ts"
46
+ import { extendM } from "../utils.ts"
47
47
  import { type AST } from "./schema.ts"
48
48
 
49
49
  type ProvidedCodec<Self extends S.Top, R> = S.Codec<
@@ -134,13 +134,6 @@ const dateHelpers = (s: S.Date) => ({
134
134
  /** Like the default Schema `Date` (Encoded is `Date`) with default helpers. */
135
135
  export const Date = extendM(S.Date, dateHelpers)
136
136
 
137
- /**
138
- * Alias of {@link Date}. Core `Schema.Date` already rejects invalid Dates.
139
- *
140
- * @deprecated Use {@link Date}.
141
- */
142
- export const DateValid = Date
143
-
144
137
  /** Like the default Schema `Boolean` but with default helpers. */
145
138
  export const Boolean = Object.assign(S.Boolean, {
146
139
  /**
@@ -522,7 +515,7 @@ export function makeOptional<NER extends S.Struct.Fields>(
522
515
  ): {
523
516
  [K in keyof NER]: NER[K] extends S.Top ? ReturnType<typeof S.optional<NER[K] & S.Top>> : any
524
517
  } {
525
- return typedKeysOf(t).reduce((prev, cur) => {
518
+ return Struct.keys(t).reduce((prev, cur) => {
526
519
  prev[cur] = S.optional(t[cur] as any)
527
520
  return prev
528
521
  }, {} as any)
@@ -601,7 +594,7 @@ export function makeExactOptional<NER extends S.Struct.Fields>(
601
594
  [K in keyof NER]: NER[K] extends S.Top ? DropConstructorDefault<ReturnType<typeof S.optionalKey<NER[K] & S.Top>>>
602
595
  : any
603
596
  } {
604
- return typedKeysOf(t).reduce((prev, cur) => {
597
+ return Struct.keys(t).reduce((prev, cur) => {
605
598
  prev[cur] = dropConstructorDefault(S.optionalKey(t[cur] as any))
606
599
  return prev
607
600
  }, {} as any)
package/src/Schema.ts CHANGED
@@ -115,7 +115,7 @@ export * from "./Schema/Class.ts"
115
115
  export { Class, ErrorClass, Opaque, OpaqueErrorFacadeClass, OpaqueFacade, OpaqueShape, OpaqueType, TaggedClass, TaggedErrorClass } from "./Schema/Class.ts"
116
116
 
117
117
  export { fromBrand, nominal } from "./Schema/brand.ts"
118
- export { Array, Boolean, Date, DateFromString, DateValid, Finite, Literals, NullOr, Number, ReadonlyMap, ReadonlySet } from "./Schema/ext.ts"
118
+ export { Array, Boolean, Date, DateFromString, Finite, Literals, NullOr, Number, ReadonlyMap, ReadonlySet } from "./Schema/ext.ts"
119
119
  export { Int, NonNegativeInt } from "./Schema/numbers.ts"
120
120
 
121
121
  export * from "./Schema/email.ts"
package/src/Set.ts CHANGED
@@ -6,7 +6,8 @@ import * as Option from "effect/Option"
6
6
  import type * as Order from "effect/Order"
7
7
  import { not } from "effect/Predicate"
8
8
  import type * as Result from "effect/Result"
9
- import { identity, pipe, type Predicate, type Refinement, tuple } from "./Function.ts"
9
+ import * as Tuple from "effect/Tuple"
10
+ import { identity, pipe, type Predicate, type Refinement } from "./Function.ts"
10
11
 
11
12
  export function find_<A, B extends A>(
12
13
  as: ReadonlySet<A>,
@@ -309,7 +310,7 @@ export function partition_<A>(
309
310
  left.add(value)
310
311
  }
311
312
  }
312
- return tuple(left, right)
313
+ return Tuple.make(left, right)
313
314
  }
314
315
 
315
316
  /**
@@ -375,7 +376,7 @@ export function partitionMap_<B, C>(
375
376
  break
376
377
  }
377
378
  }
378
- return tuple(left, right)
379
+ return Tuple.make(left, right)
379
380
  }
380
381
  }
381
382
 
@@ -552,7 +553,7 @@ export function separate<E, A>(
552
553
  break
553
554
  }
554
555
  })
555
- return tuple(left, right)
556
+ return Tuple.make(left, right)
556
557
  }
557
558
  }
558
559
 
@@ -4,6 +4,7 @@ import * as Layer from "effect/Layer"
4
4
  import * as ManagedRuntime from "effect/ManagedRuntime"
5
5
  import * as Option from "effect/Option"
6
6
  import * as Predicate from "effect/Predicate"
7
+ import * as Record from "effect/Record"
7
8
  import { Rpc, RpcClient, RpcGroup, RpcSerialization } from "effect/rpc"
8
9
  import * as Schema from "effect/Schema"
9
10
  import * as Stream from "effect/Stream"
@@ -15,7 +16,6 @@ import * as Effect from "../Effect.ts"
15
16
  import { HttpClient, HttpClientRequest } from "../http.ts"
16
17
  import { Invalidation } from "../rpc.ts"
17
18
  import type * as S from "../Schema.ts"
18
- import { typedKeysOf, typedValuesOf } from "../utils.ts"
19
19
  import type { Client, ClientForOptions, ExtractModuleName, RequestsAny } from "./clientFor.ts"
20
20
  import { InvalidationKeysFromServer } from "./InvalidationKeys.ts"
21
21
 
@@ -94,7 +94,7 @@ const getFiltered = <M extends RequestsAny>(resource: M) => {
94
94
  [K in keyof M as M[K] extends Req ? K : never]: M[K] extends Req ? M[K] : never
95
95
  }
96
96
  // TODO: Record.filter
97
- const filtered = typedKeysOf(resource).reduce((acc, cur) => {
97
+ const filtered = Struct.keys(resource).reduce((acc, cur) => {
98
98
  if (
99
99
  Predicate.isObjectKeyword(resource[cur])
100
100
  && (resource[cur].success)
@@ -110,7 +110,7 @@ const getFiltered = <M extends RequestsAny>(resource: M) => {
110
110
  export const getMeta = <M extends RequestsAny>(
111
111
  resource: M
112
112
  ): { moduleName: ExtractModuleName<M>; middleware?: unknown } => {
113
- const first = typedValuesOf(getFiltered(resource))[0]
113
+ const first = Record.values(getFiltered(resource))[0]
114
114
  if (first && "moduleName" in first) return { moduleName: first.moduleName, middleware: (first as any).middleware }
115
115
  throw new Error("No moduleName on requests!")
116
116
  }
@@ -125,7 +125,7 @@ export const makeRpcGroupFromRequestsAndModuleName = <M extends RequestsAny, con
125
125
  type newM = typeof filtered
126
126
  const baseRpcs = RpcGroup
127
127
  .make(
128
- ...typedValuesOf(filtered).map((_) => {
128
+ ...Record.values(filtered).map((_) => {
129
129
  const r = _ as any
130
130
  const isStream = r.stream
131
131
  const isCommand = r.type === "command"
@@ -262,13 +262,14 @@ const makeApiClientFactory = Effect
262
262
 
263
263
  return {
264
264
  mr,
265
- client: typedKeysOf(filtered)
265
+ client: Struct
266
+ .keys(filtered)
266
267
  .reduce((prev, cur) => {
267
268
  const h = filtered[cur]!
268
269
 
269
270
  const Request = h
270
271
 
271
- const id = `${meta.moduleName}.${cur as string}`
272
+ const id = `${meta.moduleName}.${cur}`
272
273
  .replaceAll(".js", "")
273
274
 
274
275
  const requestMeta = {
@@ -281,7 +282,7 @@ const makeApiClientFactory = Effect
281
282
  }
282
283
 
283
284
  const requestNameLayer = Layer.succeed(RequestName, {
284
- requestName: cur as string,
285
+ requestName: cur,
285
286
  moduleName: meta.moduleName
286
287
  })
287
288