effect-app 2.39.0 → 2.40.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.
- package/CHANGELOG.md +14 -0
- package/dist/_ext/Array.d.ts.map +1 -1
- package/dist/_ext/Array.js +7 -4
- package/dist/client/apiClientFactory.d.ts +16 -16
- package/package.json +7 -7
- package/src/_ext/Array.ts +16 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @effect-app/prelude
|
|
2
2
|
|
|
3
|
+
## 2.40.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8cb33d5: update packages
|
|
8
|
+
|
|
9
|
+
## 2.39.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- d3b05cb: update packages
|
|
14
|
+
- 4627c7b: improve: optimise getFirstById.
|
|
15
|
+
- 1e1f32b: housekeeping: update packages
|
|
16
|
+
|
|
3
17
|
## 2.39.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/dist/_ext/Array.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Array.d.ts","sourceRoot":"","sources":["../../src/_ext/Array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAS,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"Array.d.ts","sourceRoot":"","sources":["../../src/_ext/Array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAS,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAgBnD,wBAAgB,cAAc,CAAC,CAAC,MACtB,KAAK,CAAC,EAAE,SAAS,MAAM,CAAC,EAAE,IAAI,SAAS,MAAM,EAAE,OAAO,EAAE,EAAE,MAAM,IAAI,MAE1E,GAAG,QAAQ,CAAC,CAAC,CAAC,EACd,IAAI,CAAC,CAAC,EAAE,CAAC,kDAEZ;AAED,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS;IAAE,EAAE,EAAE,OAAO,CAAA;CAAE,QAAQ,IAAI,SAAS,MAAM,EAAE,MAAM,IAAI,kFAChE,CAAA;AAEjC,wBAAgB,YAAY,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,OAAO,CAAA;CAAE,EAAE,IAAI,SAAS,MAAM,EACzE,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EACd,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EACX,IAAI,EAAE,IAAI,gDAGX"}
|
package/dist/_ext/Array.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { Chunk, Effect, Equal } from "effect-app";
|
|
2
2
|
import { NotFoundError } from "../client/errors.js";
|
|
3
|
-
|
|
4
|
-
return
|
|
3
|
+
function getFirstBy(a, idKey, id, type) {
|
|
4
|
+
return Chunk
|
|
5
5
|
.fromIterable(a)
|
|
6
6
|
.pipe(Chunk.findFirst((_) => Equal.equals(_[idKey], id)), Effect.mapError(() => new NotFoundError({ type, id })));
|
|
7
7
|
}
|
|
8
|
+
export function makeGetFirstBy() {
|
|
9
|
+
return (idKey, type) => (a, id) => getFirstBy(a, idKey, id, type);
|
|
10
|
+
}
|
|
8
11
|
export const makeGetFirstById = () => (type) => makeGetFirstBy()("id", type);
|
|
9
12
|
export function getFirstById(a, id, type) {
|
|
10
|
-
return
|
|
13
|
+
return getFirstBy(a, "id", id, type);
|
|
11
14
|
}
|
|
12
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQXJyYXkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvX2V4dC9BcnJheS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsS0FBSyxFQUFFLE1BQU0sRUFBRSxLQUFLLEVBQUUsTUFBTSxZQUFZLENBQUE7QUFDakQsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLHFCQUFxQixDQUFBO0FBRW5ELFNBQVMsVUFBVSxDQUNqQixDQUFjLEVBQ2QsS0FBYyxFQUNkLEVBQW1CLEVBQ25CLElBQVU7SUFFVixPQUFPLEtBQUs7U0FDVCxZQUFZLENBQUMsQ0FBQyxDQUFDO1NBQ2YsSUFBSSxDQUNILEtBQUssQ0FBQyxTQUFTLENBQUMsQ0FBQyxDQUFDLEVBQUUsRUFBRSxDQUFDLEtBQUssQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLEtBQUssQ0FBQyxFQUFFLEVBQUUsQ0FBQyxDQUFDLEVBQ2xELE1BQU0sQ0FBQyxRQUFRLENBQUMsR0FBRyxFQUFFLENBQUMsSUFBSSxhQUFhLENBQU8sRUFBRSxJQUFJLEVBQUUsRUFBRSxFQUFFLENBQUMsQ0FBQyxDQUM3RCxDQUFBO0FBQ0wsQ0FBQztBQUVELE1BQU0sVUFBVSxjQUFjO0lBQzVCLE9BQU8sQ0FBZ0QsS0FBUyxFQUFFLElBQVUsRUFBRSxFQUFFLENBQ2hGLENBQ0UsQ0FBYyxFQUNkLEVBQVMsRUFDVCxFQUFFLENBQUMsVUFBVSxDQUFDLENBQUMsRUFBRSxLQUFLLEVBQUUsRUFBRSxFQUFFLElBQUksQ0FBQyxDQUFBO0FBQ3JDLENBQUM7QUFFRCxNQUFNLENBQUMsTUFBTSxnQkFBZ0IsR0FBRyxHQUE4QixFQUFFLENBQUMsQ0FBc0IsSUFBVSxFQUFFLEVBQUUsQ0FDbkcsY0FBYyxFQUFLLENBQUMsSUFBSSxFQUFFLElBQUksQ0FBQyxDQUFBO0FBRWpDLE1BQU0sVUFBVSxZQUFZLENBQzFCLENBQWMsRUFDZCxFQUFXLEVBQ1gsSUFBVTtJQUVWLE9BQU8sVUFBVSxDQUFDLENBQUMsRUFBRSxJQUFJLEVBQUUsRUFBRSxFQUFFLElBQUksQ0FBQyxDQUFBO0FBQ3RDLENBQUMifQ==
|
|
@@ -23,28 +23,28 @@ type RpcHandlers<M extends Requests> = {
|
|
|
23
23
|
};
|
|
24
24
|
export declare const getMeta: <M extends Requests>(resource: M) => M["meta"];
|
|
25
25
|
export declare const makeRpcGroup: <M extends Requests>(resource: M) => RpcGroup.RpcGroup<RpcHandlers<{ [K in keyof M as M[K] extends Req ? K : never]: M[K] extends Req ? M[K] : never; }>[keyof { [K in keyof M as M[K] extends Req ? K : never]: M[K] extends Req ? M[K] : never; }]>;
|
|
26
|
-
declare const ApiClientFactory_base: (abstract new (service: (requestLevelLayers: Layer.Layer<never, never, never>, options?: ClientForOptions) => <M extends Requests>(models: M) => Effect<Omit<M, "meta"> extends infer T extends Requests ? { [K in keyof T]: (Exclude<keyof S.Schema.Type<Omit<M, "meta">[K]>, "_tag" | typeof import("effect/Request").RequestTypeId
|
|
26
|
+
declare const ApiClientFactory_base: (abstract new (service: (requestLevelLayers: Layer.Layer<never, never, never>, options?: ClientForOptions) => <M extends Requests>(models: M) => Effect<Omit<M, "meta"> extends infer T extends Requests ? { [K in keyof T]: (Exclude<keyof S.Schema.Type<Omit<M, "meta">[K]>, typeof S.symbolSerializable | typeof S.symbolWithResult | "_tag" | typeof import("effect/Request").RequestTypeId> extends never ? true : false) extends true ? import("./clientFor.js").RequestHandler<S.Schema.Type<Omit<M, "meta">[K]["success"]>, S.Schema.Type<Omit<M, "meta">[K]["failure"]>, never, Omit<M, "meta">[K]> & {
|
|
27
27
|
raw: import("./clientFor.js").RequestHandler<S.Schema.Type<Omit<M, "meta">[K]["success"]>, S.Schema.Type<Omit<M, "meta">[K]["failure"]>, never, Omit<M, "meta">[K]>;
|
|
28
|
-
} : import("./clientFor.js").RequestHandlerWithInput<Omit<S.Schema.Type<Omit<M, "meta">[K]>, "_tag" | typeof import("effect/Request").RequestTypeId
|
|
29
|
-
raw: import("./clientFor.js").RequestHandlerWithInput<Omit<S.Schema.Type<Omit<M, "meta">[K]>, "_tag" | typeof import("effect/Request").RequestTypeId
|
|
30
|
-
}; } : never>) => Readonly<(requestLevelLayers: Layer.Layer<never, never, never>, options?: ClientForOptions) => <M extends Requests>(models: M) => Effect<Omit<M, "meta"> extends infer T extends Requests ? { [K in keyof T]: (Exclude<keyof S.Schema.Type<Omit<M, "meta">[K]>, "_tag" | typeof import("effect/Request").RequestTypeId
|
|
28
|
+
} : import("./clientFor.js").RequestHandlerWithInput<Omit<S.Schema.Type<Omit<M, "meta">[K]>, typeof S.symbolSerializable | typeof S.symbolWithResult | "_tag" | typeof import("effect/Request").RequestTypeId>, S.Schema.Type<Omit<M, "meta">[K]["success"]>, S.Schema.Type<Omit<M, "meta">[K]["failure"]>, never, Omit<M, "meta">[K]> & {
|
|
29
|
+
raw: import("./clientFor.js").RequestHandlerWithInput<Omit<S.Schema.Type<Omit<M, "meta">[K]>, typeof S.symbolSerializable | typeof S.symbolWithResult | "_tag" | typeof import("effect/Request").RequestTypeId>, S.Schema.Encoded<Omit<M, "meta">[K]["success"]>, S.Schema.Type<Omit<M, "meta">[K]["failure"]>, never, Omit<M, "meta">[K]>;
|
|
30
|
+
}; } : never>) => Readonly<(requestLevelLayers: Layer.Layer<never, never, never>, options?: ClientForOptions) => <M extends Requests>(models: M) => Effect<Omit<M, "meta"> extends infer T extends Requests ? { [K in keyof T]: (Exclude<keyof S.Schema.Type<Omit<M, "meta">[K]>, typeof S.symbolSerializable | typeof S.symbolWithResult | "_tag" | typeof import("effect/Request").RequestTypeId> extends never ? true : false) extends true ? import("./clientFor.js").RequestHandler<S.Schema.Type<Omit<M, "meta">[K]["success"]>, S.Schema.Type<Omit<M, "meta">[K]["failure"]>, never, Omit<M, "meta">[K]> & {
|
|
31
31
|
raw: import("./clientFor.js").RequestHandler<S.Schema.Type<Omit<M, "meta">[K]["success"]>, S.Schema.Type<Omit<M, "meta">[K]["failure"]>, never, Omit<M, "meta">[K]>;
|
|
32
|
-
} : import("./clientFor.js").RequestHandlerWithInput<Omit<S.Schema.Type<Omit<M, "meta">[K]>, "_tag" | typeof import("effect/Request").RequestTypeId
|
|
33
|
-
raw: import("./clientFor.js").RequestHandlerWithInput<Omit<S.Schema.Type<Omit<M, "meta">[K]>, "_tag" | typeof import("effect/Request").RequestTypeId
|
|
34
|
-
}; } : never>> & Context.TagClassShape<"ApiClientFactory", (requestLevelLayers: Layer.Layer<never, never, never>, options?: ClientForOptions) => <M extends Requests>(models: M) => Effect<Omit<M, "meta"> extends infer T extends Requests ? { [K in keyof T]: (Exclude<keyof S.Schema.Type<Omit<M, "meta">[K]>, "_tag" | typeof import("effect/Request").RequestTypeId
|
|
32
|
+
} : import("./clientFor.js").RequestHandlerWithInput<Omit<S.Schema.Type<Omit<M, "meta">[K]>, typeof S.symbolSerializable | typeof S.symbolWithResult | "_tag" | typeof import("effect/Request").RequestTypeId>, S.Schema.Type<Omit<M, "meta">[K]["success"]>, S.Schema.Type<Omit<M, "meta">[K]["failure"]>, never, Omit<M, "meta">[K]> & {
|
|
33
|
+
raw: import("./clientFor.js").RequestHandlerWithInput<Omit<S.Schema.Type<Omit<M, "meta">[K]>, typeof S.symbolSerializable | typeof S.symbolWithResult | "_tag" | typeof import("effect/Request").RequestTypeId>, S.Schema.Encoded<Omit<M, "meta">[K]["success"]>, S.Schema.Type<Omit<M, "meta">[K]["failure"]>, never, Omit<M, "meta">[K]>;
|
|
34
|
+
}; } : never>> & Context.TagClassShape<"ApiClientFactory", (requestLevelLayers: Layer.Layer<never, never, never>, options?: ClientForOptions) => <M extends Requests>(models: M) => Effect<Omit<M, "meta"> extends infer T extends Requests ? { [K in keyof T]: (Exclude<keyof S.Schema.Type<Omit<M, "meta">[K]>, typeof S.symbolSerializable | typeof S.symbolWithResult | "_tag" | typeof import("effect/Request").RequestTypeId> extends never ? true : false) extends true ? import("./clientFor.js").RequestHandler<S.Schema.Type<Omit<M, "meta">[K]["success"]>, S.Schema.Type<Omit<M, "meta">[K]["failure"]>, never, Omit<M, "meta">[K]> & {
|
|
35
35
|
raw: import("./clientFor.js").RequestHandler<S.Schema.Type<Omit<M, "meta">[K]["success"]>, S.Schema.Type<Omit<M, "meta">[K]["failure"]>, never, Omit<M, "meta">[K]>;
|
|
36
|
-
} : import("./clientFor.js").RequestHandlerWithInput<Omit<S.Schema.Type<Omit<M, "meta">[K]>, "_tag" | typeof import("effect/Request").RequestTypeId
|
|
37
|
-
raw: import("./clientFor.js").RequestHandlerWithInput<Omit<S.Schema.Type<Omit<M, "meta">[K]>, "_tag" | typeof import("effect/Request").RequestTypeId
|
|
36
|
+
} : import("./clientFor.js").RequestHandlerWithInput<Omit<S.Schema.Type<Omit<M, "meta">[K]>, typeof S.symbolSerializable | typeof S.symbolWithResult | "_tag" | typeof import("effect/Request").RequestTypeId>, S.Schema.Type<Omit<M, "meta">[K]["success"]>, S.Schema.Type<Omit<M, "meta">[K]["failure"]>, never, Omit<M, "meta">[K]> & {
|
|
37
|
+
raw: import("./clientFor.js").RequestHandlerWithInput<Omit<S.Schema.Type<Omit<M, "meta">[K]>, typeof S.symbolSerializable | typeof S.symbolWithResult | "_tag" | typeof import("effect/Request").RequestTypeId>, S.Schema.Encoded<Omit<M, "meta">[K]["success"]>, S.Schema.Type<Omit<M, "meta">[K]["failure"]>, never, Omit<M, "meta">[K]>;
|
|
38
38
|
}; } : never>>) & {
|
|
39
39
|
toLayer: <E, R>(eff: Effect.Effect<Omit<ApiClientFactory, keyof Context.TagClassShape<any, any>>, E, R>) => Layer.Layer<ApiClientFactory, E, R>;
|
|
40
40
|
toLayerScoped: <E, R>(eff: Effect.Effect<Omit<ApiClientFactory, keyof Context.TagClassShape<any, any>>, E, R>) => Layer.Layer<ApiClientFactory, E, Exclude<R, import("effect/Scope").Scope>>;
|
|
41
41
|
of: (service: Omit<ApiClientFactory, keyof Context.TagClassShape<any, any>>) => ApiClientFactory;
|
|
42
42
|
} & Context.Tag<ApiClientFactory, ApiClientFactory> & {} & {
|
|
43
|
-
use: <X>(body: (_: (requestLevelLayers: Layer.Layer<never, never, never>, options?: ClientForOptions) => <M extends Requests>(models: M) => Effect<Omit<M, "meta"> extends infer T extends Requests ? { [K in keyof T]: (Exclude<keyof S.Schema.Type<Omit<M, "meta">[K]>, "_tag" | typeof import("effect/Request").RequestTypeId
|
|
43
|
+
use: <X>(body: (_: (requestLevelLayers: Layer.Layer<never, never, never>, options?: ClientForOptions) => <M extends Requests>(models: M) => Effect<Omit<M, "meta"> extends infer T extends Requests ? { [K in keyof T]: (Exclude<keyof S.Schema.Type<Omit<M, "meta">[K]>, typeof S.symbolSerializable | typeof S.symbolWithResult | "_tag" | typeof import("effect/Request").RequestTypeId> extends never ? true : false) extends true ? import("./clientFor.js").RequestHandler<S.Schema.Type<Omit<M, "meta">[K]["success"]>, S.Schema.Type<Omit<M, "meta">[K]["failure"]>, never, Omit<M, "meta">[K]> & {
|
|
44
44
|
raw: import("./clientFor.js").RequestHandler<S.Schema.Type<Omit<M, "meta">[K]["success"]>, S.Schema.Type<Omit<M, "meta">[K]["failure"]>, never, Omit<M, "meta">[K]>;
|
|
45
|
-
} : import("./clientFor.js").RequestHandlerWithInput<Omit<S.Schema.Type<Omit<M, "meta">[K]>, "_tag" | typeof import("effect/Request").RequestTypeId
|
|
46
|
-
raw: import("./clientFor.js").RequestHandlerWithInput<Omit<S.Schema.Type<Omit<M, "meta">[K]>, "_tag" | typeof import("effect/Request").RequestTypeId
|
|
47
|
-
}; } : never>) => X) => X extends Effect.Effect<infer A, infer E, infer R> ? Effect.Effect<A, E,
|
|
45
|
+
} : import("./clientFor.js").RequestHandlerWithInput<Omit<S.Schema.Type<Omit<M, "meta">[K]>, typeof S.symbolSerializable | typeof S.symbolWithResult | "_tag" | typeof import("effect/Request").RequestTypeId>, S.Schema.Type<Omit<M, "meta">[K]["success"]>, S.Schema.Type<Omit<M, "meta">[K]["failure"]>, never, Omit<M, "meta">[K]> & {
|
|
46
|
+
raw: import("./clientFor.js").RequestHandlerWithInput<Omit<S.Schema.Type<Omit<M, "meta">[K]>, typeof S.symbolSerializable | typeof S.symbolWithResult | "_tag" | typeof import("effect/Request").RequestTypeId>, S.Schema.Encoded<Omit<M, "meta">[K]["success"]>, S.Schema.Type<Omit<M, "meta">[K]["failure"]>, never, Omit<M, "meta">[K]>;
|
|
47
|
+
}; } : never>) => X) => X extends Effect.Effect<infer A, infer E, infer R> ? Effect.Effect<A, E, R | ApiClientFactory> : Effect.Effect<X, never, ApiClientFactory>;
|
|
48
48
|
};
|
|
49
49
|
/**
|
|
50
50
|
* Used to create clients for resource modules.
|
|
@@ -52,10 +52,10 @@ declare const ApiClientFactory_base: (abstract new (service: (requestLevelLayers
|
|
|
52
52
|
export declare class ApiClientFactory extends ApiClientFactory_base {
|
|
53
53
|
static readonly layer: (config: ApiConfig) => Layer.Layer<ApiClientFactory, never, HttpClient.HttpClient>;
|
|
54
54
|
static readonly layerFromConfig: Layer.Layer<ApiClientFactory, import("effect/ConfigError").ConfigError, HttpClient.HttpClient>;
|
|
55
|
-
static readonly makeFor: (requestLevelLayers: Layer.Layer<never, never, never>, options?: ClientForOptions) => <M extends Requests>(resource: M) => Effect.Effect<Omit<M, "meta"> extends infer T extends Requests ? { [K in keyof T]: (Exclude<keyof S.Schema.Type<Omit<M, "meta">[K]>, "_tag" | typeof import("effect/Request").RequestTypeId
|
|
55
|
+
static readonly makeFor: (requestLevelLayers: Layer.Layer<never, never, never>, options?: ClientForOptions) => <M extends Requests>(resource: M) => Effect.Effect<Omit<M, "meta"> extends infer T extends Requests ? { [K in keyof T]: (Exclude<keyof S.Schema.Type<Omit<M, "meta">[K]>, typeof S.symbolSerializable | typeof S.symbolWithResult | "_tag" | typeof import("effect/Request").RequestTypeId> extends never ? true : false) extends true ? import("./clientFor.js").RequestHandler<S.Schema.Type<Omit<M, "meta">[K]["success"]>, S.Schema.Type<Omit<M, "meta">[K]["failure"]>, never, Omit<M, "meta">[K]> & {
|
|
56
56
|
raw: import("./clientFor.js").RequestHandler<S.Schema.Type<Omit<M, "meta">[K]["success"]>, S.Schema.Type<Omit<M, "meta">[K]["failure"]>, never, Omit<M, "meta">[K]>;
|
|
57
|
-
} : import("./clientFor.js").RequestHandlerWithInput<Omit<S.Schema.Type<Omit<M, "meta">[K]>, "_tag" | typeof import("effect/Request").RequestTypeId
|
|
58
|
-
raw: import("./clientFor.js").RequestHandlerWithInput<Omit<S.Schema.Type<Omit<M, "meta">[K]>, "_tag" | typeof import("effect/Request").RequestTypeId
|
|
57
|
+
} : import("./clientFor.js").RequestHandlerWithInput<Omit<S.Schema.Type<Omit<M, "meta">[K]>, typeof S.symbolSerializable | typeof S.symbolWithResult | "_tag" | typeof import("effect/Request").RequestTypeId>, S.Schema.Type<Omit<M, "meta">[K]["success"]>, S.Schema.Type<Omit<M, "meta">[K]["failure"]>, never, Omit<M, "meta">[K]> & {
|
|
58
|
+
raw: import("./clientFor.js").RequestHandlerWithInput<Omit<S.Schema.Type<Omit<M, "meta">[K]>, typeof S.symbolSerializable | typeof S.symbolWithResult | "_tag" | typeof import("effect/Request").RequestTypeId>, S.Schema.Encoded<Omit<M, "meta">[K]["success"]>, S.Schema.Type<Omit<M, "meta">[K]["failure"]>, never, Omit<M, "meta">[K]>;
|
|
59
59
|
}; } : never, never, ApiClientFactory>;
|
|
60
60
|
}
|
|
61
61
|
export {};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "effect-app",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.40.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@effect/rpc": "^0.
|
|
7
|
+
"@effect/rpc": "^0.56.2",
|
|
8
8
|
"@effect/rpc-http": "^0.52.4",
|
|
9
9
|
"@tsconfig/strictest": "^2.0.5",
|
|
10
10
|
"date-fns": "^4.1.0",
|
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@faker-js/faker": "^8.4.1",
|
|
21
|
-
"@types/node": "~22.14.
|
|
21
|
+
"@types/node": "~22.14.1",
|
|
22
22
|
"@types/uuid": "^10.0.0",
|
|
23
|
-
"@types/validator": "^13.
|
|
23
|
+
"@types/validator": "^13.15.0",
|
|
24
24
|
"fast-check": "~4.1.1",
|
|
25
25
|
"typescript": "^5.8.3",
|
|
26
|
-
"vitest": "^3.1.
|
|
26
|
+
"vitest": "^3.1.2"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@effect/platform": "^0.80.
|
|
30
|
-
"effect": "^3.14.
|
|
29
|
+
"@effect/platform": "^0.80.14",
|
|
30
|
+
"effect": "^3.14.14"
|
|
31
31
|
},
|
|
32
32
|
"typesVersions": {
|
|
33
33
|
"*": {
|
package/src/_ext/Array.ts
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { Chunk, Effect, Equal } from "effect-app"
|
|
2
2
|
import { NotFoundError } from "../client/errors.js"
|
|
3
3
|
|
|
4
|
+
function getFirstBy<A, Type extends string>(
|
|
5
|
+
a: Iterable<A>,
|
|
6
|
+
idKey: keyof A,
|
|
7
|
+
id: A[typeof idKey],
|
|
8
|
+
type: Type
|
|
9
|
+
) {
|
|
10
|
+
return Chunk
|
|
11
|
+
.fromIterable(a)
|
|
12
|
+
.pipe(
|
|
13
|
+
Chunk.findFirst((_) => Equal.equals(_[idKey], id)),
|
|
14
|
+
Effect.mapError(() => new NotFoundError<Type>({ type, id }))
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
4
18
|
export function makeGetFirstBy<A>() {
|
|
5
19
|
return <const Id extends keyof A, Type extends string>(idKey: Id, type: Type) =>
|
|
6
20
|
(
|
|
7
21
|
a: Iterable<A>,
|
|
8
22
|
id: A[Id]
|
|
9
|
-
) =>
|
|
10
|
-
Chunk
|
|
11
|
-
.fromIterable(a)
|
|
12
|
-
.pipe(
|
|
13
|
-
Chunk.findFirst((_) => Equal.equals(_[idKey], id)),
|
|
14
|
-
Effect.mapError(() => new NotFoundError<Type>({ type, id }))
|
|
15
|
-
)
|
|
23
|
+
) => getFirstBy(a, idKey, id, type)
|
|
16
24
|
}
|
|
17
25
|
|
|
18
26
|
export const makeGetFirstById = <A extends { id: unknown }>() => <Type extends string>(type: Type) =>
|
|
@@ -23,5 +31,5 @@ export function getFirstById<A extends { id: unknown }, Type extends string>(
|
|
|
23
31
|
id: A["id"],
|
|
24
32
|
type: Type
|
|
25
33
|
) {
|
|
26
|
-
return
|
|
34
|
+
return getFirstBy(a, "id", id, type)
|
|
27
35
|
}
|