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

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 (72) hide show
  1. package/CHANGELOG.md +108 -0
  2. package/dist/Operations.d.ts +59 -23
  3. package/dist/Operations.d.ts.map +1 -1
  4. package/dist/Pure.js +1 -1
  5. package/dist/Schema/brand.d.ts +8 -5
  6. package/dist/Schema/brand.d.ts.map +1 -1
  7. package/dist/Schema/brand.js +1 -1
  8. package/dist/Schema/email.d.ts.map +1 -1
  9. package/dist/Schema/email.js +4 -3
  10. package/dist/Schema/ext.d.ts +26 -25
  11. package/dist/Schema/ext.d.ts.map +1 -1
  12. package/dist/Schema/ext.js +13 -20
  13. package/dist/Schema/moreStrings.d.ts +6 -6
  14. package/dist/Schema/moreStrings.d.ts.map +1 -1
  15. package/dist/Schema/moreStrings.js +6 -4
  16. package/dist/Schema/phoneNumber.d.ts.map +1 -1
  17. package/dist/Schema/phoneNumber.js +3 -2
  18. package/dist/Schema.d.ts +18 -49
  19. package/dist/Schema.d.ts.map +1 -1
  20. package/dist/Schema.js +15 -62
  21. package/dist/ServiceMap.d.ts +3 -3
  22. package/dist/ServiceMap.d.ts.map +1 -1
  23. package/dist/ServiceMap.js +1 -1
  24. package/dist/client/apiClientFactory.d.ts.map +1 -1
  25. package/dist/client/apiClientFactory.js +8 -9
  26. package/dist/client/errors.d.ts.map +1 -1
  27. package/dist/client/errors.js +1 -1
  28. package/dist/client/makeClient.d.ts +6 -6
  29. package/dist/client/makeClient.d.ts.map +1 -1
  30. package/dist/client/makeClient.js +3 -14
  31. package/dist/http/Request.d.ts.map +1 -1
  32. package/dist/http/Request.js +5 -5
  33. package/dist/ids.d.ts +6 -6
  34. package/dist/ids.d.ts.map +1 -1
  35. package/dist/ids.js +1 -1
  36. package/dist/index.d.ts +0 -1
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +1 -2
  39. package/dist/rpc/MiddlewareMaker.d.ts +1 -1
  40. package/dist/rpc/MiddlewareMaker.d.ts.map +1 -1
  41. package/dist/rpc/MiddlewareMaker.js +1 -1
  42. package/dist/rpc/RpcMiddleware.d.ts +1 -1
  43. package/dist/rpc/RpcMiddleware.d.ts.map +1 -1
  44. package/dist/utils.d.ts +18 -0
  45. package/dist/utils.d.ts.map +1 -1
  46. package/dist/utils.js +24 -5
  47. package/package.json +3 -7
  48. package/src/Pure.ts +2 -2
  49. package/src/Schema/brand.ts +13 -7
  50. package/src/Schema/email.ts +4 -2
  51. package/src/Schema/ext.ts +46 -38
  52. package/src/Schema/moreStrings.ts +16 -13
  53. package/src/Schema/phoneNumber.ts +3 -1
  54. package/src/Schema.ts +48 -99
  55. package/src/ServiceMap.ts +7 -6
  56. package/src/client/apiClientFactory.ts +12 -15
  57. package/src/client/errors.ts +12 -3
  58. package/src/client/makeClient.ts +6 -19
  59. package/src/http/Request.ts +7 -4
  60. package/src/ids.ts +1 -1
  61. package/src/index.ts +0 -1
  62. package/src/rpc/MiddlewareMaker.ts +2 -1
  63. package/src/rpc/RpcMiddleware.ts +2 -2
  64. package/src/utils.ts +26 -4
  65. package/test/dist/moreStrings.test.d.ts.map +1 -0
  66. package/test/dist/rpc.test.d.ts.map +1 -1
  67. package/test/moreStrings.test.ts +17 -0
  68. package/test/schema.test.ts +32 -1
  69. package/dist/Struct.d.ts +0 -44
  70. package/dist/Struct.d.ts.map +0 -1
  71. package/dist/Struct.js +0 -29
  72. package/src/Struct.ts +0 -54
@@ -43,7 +43,10 @@ export class InvalidStateError extends TaggedError<InvalidStateError>()("Invalid
43
43
  message: S.String
44
44
  }) {
45
45
  constructor(messageOrObject: string | { message: string; cause?: unknown }, disableValidation?: boolean) {
46
- super(typeof messageOrObject === "object" ? messageOrObject : { message: messageOrObject } as any, disableValidation as any)
46
+ super(
47
+ typeof messageOrObject === "object" ? messageOrObject : { message: messageOrObject } as any,
48
+ disableValidation as any
49
+ )
47
50
  }
48
51
  }
49
52
 
@@ -51,7 +54,10 @@ export class ServiceUnavailableError extends TaggedError<ServiceUnavailableError
51
54
  message: S.String
52
55
  }) {
53
56
  constructor(messageOrObject: string | { message: string; cause?: unknown }, disableValidation?: boolean) {
54
- super(typeof messageOrObject === "object" ? messageOrObject : { message: messageOrObject } as any, disableValidation as any)
57
+ super(
58
+ typeof messageOrObject === "object" ? messageOrObject : { message: messageOrObject } as any,
59
+ disableValidation as any
60
+ )
55
61
  }
56
62
  }
57
63
 
@@ -116,7 +122,10 @@ export class OptimisticConcurrencyException extends TaggedError<OptimisticConcur
116
122
  | ({ message: string; cause?: unknown; raw?: unknown }),
117
123
  disableValidation?: boolean
118
124
  ) {
119
- super("message" in args ? args : { message: `Existing ${args.type} ${args.id} record changed` } as any, disableValidation as any)
125
+ super(
126
+ "message" in args ? args : { message: `Existing ${args.type} ${args.id} record changed` } as any,
127
+ disableValidation as any
128
+ )
120
129
  if (!("message" in args)) {
121
130
  this.details = args
122
131
  }
@@ -1,4 +1,4 @@
1
- import { type GetContextConfig, type RequestContextMapTagAny } from "../rpc/RpcContextMap.js"
1
+ import { type GetContextConfig, type GetEffectError, type RequestContextMapTagAny } from "../rpc/RpcContextMap.js"
2
2
  import * as S from "../Schema.js"
3
3
  import { AST } from "../Schema.js"
4
4
 
@@ -44,8 +44,8 @@ export const makeRpcClient = <
44
44
 
45
45
  type MergeError<E> = [GeneralErrors] extends [never] ? SchemaOrFields<E> : S.Union<[SchemaOrFields<E>, GeneralErrors]>
46
46
  type ErrorResult<C> = C extends { error: infer E } ? MergeError<E>
47
- : [GeneralErrors] extends [never] ? S.Void
48
- : GeneralErrors
47
+ : [GeneralErrors] extends [never] ? GetEffectError<RequestContextMap["config"], C>
48
+ : MergeError<GetEffectError<RequestContextMap["config"], C>>
49
49
 
50
50
  function TaggedRequest<_Self>(): {
51
51
  <Tag extends string, Payload extends S.Struct.Fields, C extends ServiceMap>(
@@ -71,7 +71,7 @@ export const makeRpcClient = <
71
71
  <Tag extends string, Payload extends S.Struct.Fields>(
72
72
  tag: Tag,
73
73
  fields: Payload
74
- ): TaggedRequestResult<Tag, Payload, S.Codec<void>, ErrorResult<never>, Record<string, never>>
74
+ ): TaggedRequestResult<Tag, Payload, S.Codec<void>, ErrorResult<{}>, Record<string, never>>
75
75
  } {
76
76
  // TODO: filter errors based on config + take care of inversion
77
77
  const errorSchemas = Object.values(rcs.config).map((_) => _.error)
@@ -92,22 +92,9 @@ export const makeRpcClient = <
92
92
  : S.Struct(config.success)
93
93
  : ForceVoid
94
94
 
95
- const payloadSchema = S.Struct({ _tag: S.tag(tag), ...fields })
96
-
97
- const taggedFields = { _tag: S.tag(tag), ...fields }
98
-
99
- const RequestClass = class {
100
- constructor(payload?: any) {
101
- if (payload) {
102
- Object.assign(this, payload)
103
- }
104
- ;(this as any)._tag = tag
105
- }
106
- }
107
-
108
- Object.assign(RequestClass, payloadSchema, {
95
+ const RequestClass = S.TaggedClass<any>()(tag, fields)
96
+ Object.assign(RequestClass, {
109
97
  _tag: tag,
110
- fields: taggedFields,
111
98
  success: successSchema,
112
99
  error: failureSchema,
113
100
  config
@@ -1,3 +1,4 @@
1
+ import { Option } from "effect"
1
2
  import type { HttpClientResponse } from "effect/unstable/http/HttpClientResponse"
2
3
  import * as Effect from "../Effect.js"
3
4
  import { HttpClient, HttpClientError, HttpClientRequest, HttpHeaders } from "./internal/lib.js"
@@ -24,16 +25,18 @@ export const demandJson = (client: HttpClient.HttpClient) =>
24
25
  .mapRequest(client, (_) => HttpClientRequest.acceptJson(_))
25
26
  .pipe(HttpClient.transform((r, request) =>
26
27
  Effect.tap(r, (response) =>
27
- HttpHeaders
28
- .get(response.headers, "Content-Type")
29
- ?.startsWith("application/json")
28
+ Option
29
+ .exists(
30
+ HttpHeaders.get(response.headers, "Content-Type"),
31
+ (_) => _.startsWith("application/json")
32
+ )
30
33
  ? Effect.void
31
34
  : Effect.fail(
32
35
  new HttpClientError.DecodeError({
33
36
  request,
34
37
  response,
35
38
  description: "not json response: "
36
- + HttpHeaders.get(response.headers, "Content-Type")
39
+ + Option.getOrElse(HttpHeaders.get(response.headers, "Content-Type"), () => "<missing>")
37
40
  })
38
41
  ))
39
42
  ))
package/src/ids.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { brandedStringId, NonEmptyString255, StringId, type StringIdBrand, withDefaultMake, Codec } from "effect-app/Schema"
1
+ import { brandedStringId, type Codec, NonEmptyString255, StringId, type StringIdBrand, withDefaultMake } from "effect-app/Schema"
2
2
  import type { B } from "effect-app/Schema/schema"
3
3
  import type { Simplify } from "effect/Types"
4
4
  import { S } from "./index.js"
package/src/index.ts CHANGED
@@ -23,7 +23,6 @@ export { type NonEmptyArray, type NonEmptyReadonlyArray } from "./Array.js"
23
23
 
24
24
  export * from "effect"
25
25
 
26
- export * as Struct from "./Struct.js"
27
26
  export type * as Types from "./Types.js"
28
27
 
29
28
  export * as SecretURL from "./Config/SecretURL.js"
@@ -14,7 +14,8 @@ import { type AddMiddleware, type AnyDynamic, type RpcDynamic, type RpcMiddlewar
14
14
  import * as RpcMiddlewareX from "./RpcMiddleware.js"
15
15
 
16
16
  // adapter for effect/rpc v3 middleware provides. (in effect-smol (v4), it's just a Service Identifier, no tags.)
17
- type MakeTags<A> = ServiceMap.Service<A, A>
17
+ // hm?
18
+ type MakeTags<A> = A
18
19
 
19
20
  export interface MiddlewareMaker<
20
21
  Self,
@@ -226,8 +226,8 @@ export type ExtractProvides<R extends Rpc.Any, Tag extends string> = R extends
226
226
  Rpc.Rpc<Tag, infer _Payload, infer _Success, infer _Error, infer _Middleware, infer _Requires> ? _Middleware extends {
227
227
  readonly provides: infer _P
228
228
  } ? [_P] extends [never] ? never
229
- : _P extends ServiceMap.Service<infer _I, infer _S> ? _I
230
- : never
229
+ : _P /*_P extends ServiceMap.Service<infer _I, infer _S> ? _I
230
+ : never */
231
231
  : never
232
232
  : never
233
233
 
package/src/utils.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  /* eslint-disable @typescript-eslint/no-unsafe-function-type */
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
3
  /* eslint-disable @typescript-eslint/no-redundant-type-constituents */
4
- import { Effect, Exit, Fiber, Option, Record } from "effect"
4
+ import { Cause, Effect, Exit, Fiber, Option, Record } from "effect"
5
5
  import { dual } from "effect/Function"
6
- import { isFunction } from "effect/Predicate"
6
+ import { isFunction, isObject } from "effect/Predicate"
7
7
  import * as Result from "effect/Result"
8
8
  import type { GetFieldType, NumericDictionary, PropertyPath } from "lodash"
9
9
  import { identity, pipe } from "./Function.js"
@@ -924,8 +924,8 @@ export const runtimeFiberAsPromise = <A, E>(fiber: Fiber.Fiber<A, E>, signal?: A
924
924
  if (Exit.isSuccess(exit)) {
925
925
  resolve(exit.value)
926
926
  } else {
927
- // errors really should be of type Error, so we wrap in FiberFailure just as default Effect
928
- reject(exit.cause)
927
+ // eslint-disable-next-line
928
+ reject(Cause.squash(exit.cause))
929
929
  }
930
930
  })
931
931
  )
@@ -950,3 +950,25 @@ export type UnionToTuples<T, U = T> = [T] extends [never] ? []
950
950
  | [T, ...UnionToTuples<Exclude<U, T>>]
951
951
  | UnionToTuples<Exclude<U, T>>
952
952
  : []
953
+
954
+ const genConstructor = (function*() {}).constructor
955
+
956
+ /**
957
+ * @example
958
+ * ```ts
959
+ * import { Utils } from "effect"
960
+ *
961
+ * function* generatorFn() {
962
+ * yield 1
963
+ * yield 2
964
+ * }
965
+ *
966
+ * console.log(Utils.isGeneratorFunction(generatorFn)) // true
967
+ * console.log(Utils.isGeneratorFunction(() => {})) // false
968
+ * ```
969
+ *
970
+ * @category predicates
971
+ * @since 3.11.0
972
+ */
973
+ export const isGeneratorFunction = (u: unknown): u is (...args: Array<any>) => Generator<any, any, any> =>
974
+ isObject(u) && u.constructor === genConstructor
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moreStrings.test.d.ts","sourceRoot":"","sources":["../moreStrings.test.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"rpc.test.d.ts","sourceRoot":"","sources":["../rpc.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACrF,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;;;;;;;;;;;;;;;;;;;;;;;;AAE7C,qBAAa,iBAAkB,SAAQ,sBAIrC;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIL,qBAAa,KAAM,SAAQ,UAQzB;CAAG"}
1
+ {"version":3,"file":"rpc.test.d.ts","sourceRoot":"","sources":["../rpc.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACrF,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;;;;;;;;;;;;;;;;;;;;;;;;AAE7C,qBAAa,iBAAkB,SAAQ,sBAIrC;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIL,qBAAa,KAAM,SAAQ,UAQzB;CAAG"}
@@ -0,0 +1,17 @@
1
+ import { S } from "effect-app"
2
+ import * as fc from "fast-check"
3
+ import { urlAlphabet } from "nanoid"
4
+ import { test } from "vitest"
5
+
6
+ const nanoidAlphabet = new Set(urlAlphabet)
7
+
8
+ const isNanoId = (value: string) => value.length === 21 && Array.from(value).every((char) => nanoidAlphabet.has(char))
9
+
10
+ test("StringId arbitrary generates nanoid-shaped values", () => {
11
+ fc.assert(
12
+ fc.property(S.toArbitrary(S.StringId), (value) => {
13
+ expect(isNanoId(value)).toBe(true)
14
+ expect(S.is(S.StringId)(value)).toBe(true)
15
+ })
16
+ )
17
+ })
@@ -1,6 +1,6 @@
1
1
  // import { generateFromArbitrary } from "@effect-app/infra/test"
2
2
  import { Array, S } from "effect-app"
3
- import { test } from "vitest"
3
+ import { expect, test } from "vitest"
4
4
 
5
5
  const A = S.Struct({ a: S.NonEmptyString255, email: S.NullOr(S.Email) })
6
6
  test("works", () => {
@@ -23,3 +23,34 @@ test("literal default works", () => {
23
23
  const s2 = S.Struct({ l: l2.withDefault })
24
24
  expect(s2.makeUnsafe({}).l).toBe("b")
25
25
  })
26
+
27
+ test("tagged union derives tag map and tags from v4 literal ast", () => {
28
+ const schema = S.TaggedUnion(
29
+ S.TaggedStruct("A", { a: S.String }),
30
+ S.TaggedStruct("B", { b: S.Number }),
31
+ S.TaggedStruct("C", { c: S.Boolean })
32
+ )
33
+ const caseA = schema.cases["A"]
34
+ const caseB = schema.cases["B"]
35
+ const caseC = schema.cases["C"]
36
+ const isAOrB = schema.isAnyOf(["A", "B"])
37
+
38
+ expect(caseA.fields._tag.ast.literal).toBe("A")
39
+ expect(caseB.fields._tag.ast.literal).toBe("B")
40
+ expect(caseC.fields._tag.ast.literal).toBe("C")
41
+ expect(S.decodeSync(schema.tags)("A")).toBe("A")
42
+ expect(S.decodeSync(schema.tags)("B")).toBe("B")
43
+ expect(S.decodeSync(schema.tags)("C")).toBe("C")
44
+ expect(() => S.decodeUnknownSync(schema.tags)("D")).toThrow()
45
+
46
+ expect(schema.guards.A({ _tag: "A", a: "ok" })).toBe(true)
47
+ expect(schema.guards.A({ _tag: "B", b: 1 })).toBe(false)
48
+ expect(schema.guards.B({ _tag: "B", b: 1 })).toBe(true)
49
+ expect(schema.guards.B({ _tag: "A", a: "ok" })).toBe(false)
50
+ expect(schema.guards.C({ _tag: "C", c: true })).toBe(true)
51
+ expect(schema.guards.C({ _tag: "A", a: "ok" })).toBe(false)
52
+
53
+ expect(isAOrB({ _tag: "A", a: "ok" })).toBe(true)
54
+ expect(isAOrB({ _tag: "B", b: 1 })).toBe(true)
55
+ expect(isAOrB({ _tag: "C", c: true })).toBe(false)
56
+ })
package/dist/Struct.d.ts DELETED
@@ -1,44 +0,0 @@
1
- import type { Types } from "effect";
2
- export * from "effect/Struct";
3
- /**
4
- * Create a new object by picking properties of an existing object.
5
- *
6
- * @example
7
- * import { pick } from "effect/Struct"
8
- * import { pipe } from "effect/Function"
9
- *
10
- * assert.deepStrictEqual(pipe({ a: "a", b: 1, c: true }, pick("a", "b")), { a: "a", b: 1 })
11
- * assert.deepStrictEqual(pick({ a: "a", b: 1, c: true }, "a", "b"), { a: "a", b: 1 })
12
- *
13
- * @since 2.0.0
14
- */
15
- export declare const pick: {
16
- <Keys extends Array<PropertyKey>>(keys: Keys): <S extends {
17
- [K in Keys[number]]?: any;
18
- }>(s: S) => Types.MatchRecord<S, {
19
- [K in Keys[number]]?: S[K];
20
- }, Pick<S, Keys[number]>>;
21
- <S extends object, Keys extends Array<keyof S>>(s: S, keys: Keys): Types.MatchRecord<S, {
22
- [K in Keys[number]]?: S[K];
23
- }, Pick<S, Keys[number]>>;
24
- };
25
- export type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;
26
- /**
27
- * Create a new object by omitting properties of an existing object.
28
- *
29
- * @example
30
- * import { omit } from "effect/Struct"
31
- * import { pipe } from "effect/Function"
32
- *
33
- * assert.deepStrictEqual(pipe({ a: "a", b: 1, c: true }, omit("c")), { a: "a", b: 1 })
34
- * assert.deepStrictEqual(omit({ a: "a", b: 1, c: true }, "c"), { a: "a", b: 1 })
35
- *
36
- * @since 2.0.0
37
- */
38
- export declare const omit: {
39
- <Keys extends Array<PropertyKey>>(keys: Keys): <S extends {
40
- [K in Keys[number]]?: any;
41
- }>(s: S) => DistributiveOmit<S, Keys[number]>;
42
- <S extends object, Keys extends Array<keyof S>>(s: S, keys: Keys): DistributiveOmit<S, Keys[number]>;
43
- };
44
- //# sourceMappingURL=Struct.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Struct.d.ts","sourceRoot":"","sources":["../src/Struct.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAGnC,cAAc,eAAe,CAAA;AAE7B;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,IAAI,EAAE;IACjB,CAAC,IAAI,SAAS,KAAK,CAAC,WAAW,CAAC,EAC9B,IAAI,EAAE,IAAI,GACT,CAAC,CAAC,SAAS;SAAG,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG;KAAE,EACzC,CAAC,EAAE,CAAC,KACD,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE;SAAG,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KAAE,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IAChF,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,EAC5C,CAAC,EAAE,CAAC,EACJ,IAAI,EAAE,IAAI,GACT,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE;SAAG,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KAAE,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;CACjE,CAAA;AAEf,MAAM,MAAM,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,CAAC,SAAS,GAAG,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAC7E,KAAK,CAAA;AAET;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,IAAI,EAAE;IACjB,CAAC,IAAI,SAAS,KAAK,CAAC,WAAW,CAAC,EAC9B,IAAI,EAAE,IAAI,GACT,CAAC,CAAC,SAAS;SAAG,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG;KAAE,EAAE,CAAC,EAAE,CAAC,KAAK,gBAAgB,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;IACvF,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,EAC5C,CAAC,EAAE,CAAC,EACJ,IAAI,EAAE,IAAI,GACT,gBAAgB,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;CAChB,CAAA"}
package/dist/Struct.js DELETED
@@ -1,29 +0,0 @@
1
- import * as Struct from "effect/Struct";
2
- export * from "effect/Struct";
3
- /**
4
- * Create a new object by picking properties of an existing object.
5
- *
6
- * @example
7
- * import { pick } from "effect/Struct"
8
- * import { pipe } from "effect/Function"
9
- *
10
- * assert.deepStrictEqual(pipe({ a: "a", b: 1, c: true }, pick("a", "b")), { a: "a", b: 1 })
11
- * assert.deepStrictEqual(pick({ a: "a", b: 1, c: true }, "a", "b"), { a: "a", b: 1 })
12
- *
13
- * @since 2.0.0
14
- */
15
- export const pick = Struct.pick;
16
- /**
17
- * Create a new object by omitting properties of an existing object.
18
- *
19
- * @example
20
- * import { omit } from "effect/Struct"
21
- * import { pipe } from "effect/Function"
22
- *
23
- * assert.deepStrictEqual(pipe({ a: "a", b: 1, c: true }, omit("c")), { a: "a", b: 1 })
24
- * assert.deepStrictEqual(omit({ a: "a", b: 1, c: true }, "c"), { a: "a", b: 1 })
25
- *
26
- * @since 2.0.0
27
- */
28
- export const omit = Struct.omit;
29
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU3RydWN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL1N0cnVjdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxPQUFPLEtBQUssTUFBTSxNQUFNLGVBQWUsQ0FBQTtBQUV2QyxjQUFjLGVBQWUsQ0FBQTtBQUU3Qjs7Ozs7Ozs7Ozs7R0FXRztBQUNILE1BQU0sQ0FBQyxNQUFNLElBQUksR0FVYixNQUFNLENBQUMsSUFBSSxDQUFBO0FBS2Y7Ozs7Ozs7Ozs7O0dBV0c7QUFDSCxNQUFNLENBQUMsTUFBTSxJQUFJLEdBUWIsTUFBTSxDQUFDLElBQVcsQ0FBQSJ9
package/src/Struct.ts DELETED
@@ -1,54 +0,0 @@
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