make-service 4.0.1 → 4.1.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/dist/index.d.mts CHANGED
@@ -1,7 +1,32 @@
1
- import { StandardSchemaV1 } from '@standard-schema/spec';
2
-
3
1
  declare const HTTP_METHODS: readonly ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD", "CONNECT"];
4
2
 
3
+ /** A minimal subset of the Standard Schema specification used internally */
4
+ interface StandardSchema<Input = unknown, Output = Input> {
5
+ readonly '~standard': StandardSchema.Props<Input, Output>;
6
+ }
7
+ declare namespace StandardSchema {
8
+ interface Props<Input = unknown, Output = Input> {
9
+ readonly version: 1;
10
+ readonly vendor: string;
11
+ readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
12
+ }
13
+ type Result<Output> = SuccessResult<Output> | FailureResult;
14
+ interface SuccessResult<Output> {
15
+ readonly value: Output;
16
+ readonly issues?: undefined;
17
+ }
18
+ interface FailureResult {
19
+ readonly issues: readonly Issue[];
20
+ }
21
+ interface Issue {
22
+ readonly message: string;
23
+ readonly path?: readonly (PropertyKey | PathSegment)[];
24
+ }
25
+ interface PathSegment {
26
+ readonly key: PropertyKey;
27
+ }
28
+ }
29
+
5
30
  type JSONValue = string | number | boolean | Date | {
6
31
  [x: string]: JSONValue | undefined | null;
7
32
  } | Array<JSONValue | undefined | null>;
@@ -27,8 +52,8 @@ type BaseOptions = {
27
52
  responseTransformer?: ResponseTransformer;
28
53
  };
29
54
  type HTTPMethod = (typeof HTTP_METHODS)[number];
30
- type TypedResponseJson = <Input = unknown, Output = Input>(schema?: StandardSchemaV1<Input, Output>) => Promise<Output>;
31
- type TypedResponseText = <Input extends string = string, Output = Input>(schema?: StandardSchemaV1<Input, Output>) => Promise<Output>;
55
+ type TypedResponseJson = <Input = unknown, Output = Input>(schema?: StandardSchema<Input, Output>) => Promise<Output>;
56
+ type TypedResponseText = <Input extends string = string, Output = Input>(schema?: StandardSchema<Input, Output>) => Promise<Output>;
32
57
  type GetJson = (response: Response) => TypedResponseJson;
33
58
  type GetText = (response: Response) => TypedResponseText;
34
59
  type Prettify<T> = {
@@ -143,8 +168,8 @@ declare function typeOf(t: unknown): "array" | "arraybuffer" | "bigint" | "blob"
143
168
  * Error thrown when the response cannot be parsed.
144
169
  */
145
170
  declare class ParseResponseError extends Error {
146
- issues: readonly StandardSchemaV1.Issue[];
147
- constructor(message: string, issues: readonly StandardSchemaV1.Issue[]);
171
+ issues: readonly StandardSchema.Issue[];
172
+ constructor(message: string, issues: readonly StandardSchema.Issue[]);
148
173
  }
149
174
 
150
- export { type BaseOptions, type EnhancedRequestInit, type GetJson, type GetText, type HTTPMethod, type JSONValue, ParseResponseError, type PathParams, type RequestTransformer, type ResponseTransformer, type SearchParams, type ServiceRequestInit, type TypedResponse, type TypedResponseJson, type TypedResponseText, addQueryToURL, enhancedFetch, ensureStringBody, makeFetcher, makeGetApiURL, makeService, mergeHeaders, replaceURLParams, typeOf, typedResponse };
175
+ export { type BaseOptions, type EnhancedRequestInit, type GetJson, type GetText, type HTTPMethod, type JSONValue, ParseResponseError, type PathParams, type RequestTransformer, type ResponseTransformer, type SearchParams, type ServiceRequestInit, StandardSchema, type TypedResponse, type TypedResponseJson, type TypedResponseText, addQueryToURL, enhancedFetch, ensureStringBody, makeFetcher, makeGetApiURL, makeService, mergeHeaders, replaceURLParams, typeOf, typedResponse };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,32 @@
1
- import { StandardSchemaV1 } from '@standard-schema/spec';
2
-
3
1
  declare const HTTP_METHODS: readonly ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD", "CONNECT"];
4
2
 
3
+ /** A minimal subset of the Standard Schema specification used internally */
4
+ interface StandardSchema<Input = unknown, Output = Input> {
5
+ readonly '~standard': StandardSchema.Props<Input, Output>;
6
+ }
7
+ declare namespace StandardSchema {
8
+ interface Props<Input = unknown, Output = Input> {
9
+ readonly version: 1;
10
+ readonly vendor: string;
11
+ readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
12
+ }
13
+ type Result<Output> = SuccessResult<Output> | FailureResult;
14
+ interface SuccessResult<Output> {
15
+ readonly value: Output;
16
+ readonly issues?: undefined;
17
+ }
18
+ interface FailureResult {
19
+ readonly issues: readonly Issue[];
20
+ }
21
+ interface Issue {
22
+ readonly message: string;
23
+ readonly path?: readonly (PropertyKey | PathSegment)[];
24
+ }
25
+ interface PathSegment {
26
+ readonly key: PropertyKey;
27
+ }
28
+ }
29
+
5
30
  type JSONValue = string | number | boolean | Date | {
6
31
  [x: string]: JSONValue | undefined | null;
7
32
  } | Array<JSONValue | undefined | null>;
@@ -27,8 +52,8 @@ type BaseOptions = {
27
52
  responseTransformer?: ResponseTransformer;
28
53
  };
29
54
  type HTTPMethod = (typeof HTTP_METHODS)[number];
30
- type TypedResponseJson = <Input = unknown, Output = Input>(schema?: StandardSchemaV1<Input, Output>) => Promise<Output>;
31
- type TypedResponseText = <Input extends string = string, Output = Input>(schema?: StandardSchemaV1<Input, Output>) => Promise<Output>;
55
+ type TypedResponseJson = <Input = unknown, Output = Input>(schema?: StandardSchema<Input, Output>) => Promise<Output>;
56
+ type TypedResponseText = <Input extends string = string, Output = Input>(schema?: StandardSchema<Input, Output>) => Promise<Output>;
32
57
  type GetJson = (response: Response) => TypedResponseJson;
33
58
  type GetText = (response: Response) => TypedResponseText;
34
59
  type Prettify<T> = {
@@ -143,8 +168,8 @@ declare function typeOf(t: unknown): "array" | "arraybuffer" | "bigint" | "blob"
143
168
  * Error thrown when the response cannot be parsed.
144
169
  */
145
170
  declare class ParseResponseError extends Error {
146
- issues: readonly StandardSchemaV1.Issue[];
147
- constructor(message: string, issues: readonly StandardSchemaV1.Issue[]);
171
+ issues: readonly StandardSchema.Issue[];
172
+ constructor(message: string, issues: readonly StandardSchema.Issue[]);
148
173
  }
149
174
 
150
- export { type BaseOptions, type EnhancedRequestInit, type GetJson, type GetText, type HTTPMethod, type JSONValue, ParseResponseError, type PathParams, type RequestTransformer, type ResponseTransformer, type SearchParams, type ServiceRequestInit, type TypedResponse, type TypedResponseJson, type TypedResponseText, addQueryToURL, enhancedFetch, ensureStringBody, makeFetcher, makeGetApiURL, makeService, mergeHeaders, replaceURLParams, typeOf, typedResponse };
175
+ export { type BaseOptions, type EnhancedRequestInit, type GetJson, type GetText, type HTTPMethod, type JSONValue, ParseResponseError, type PathParams, type RequestTransformer, type ResponseTransformer, type SearchParams, type ServiceRequestInit, StandardSchema, type TypedResponse, type TypedResponseJson, type TypedResponseText, addQueryToURL, enhancedFetch, ensureStringBody, makeFetcher, makeGetApiURL, makeService, mergeHeaders, replaceURLParams, typeOf, typedResponse };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "make-service",
3
- "version": "4.0.1",
3
+ "version": "4.1.0",
4
4
  "description": "Some utilities to extend the 'fetch' API to better interact with external APIs.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -33,7 +33,6 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@biomejs/biome": "^2.0.0",
36
- "@standard-schema/spec": "^1.0.0",
37
36
  "@types/node": "^24.0.3",
38
37
  "arktype": "^2.1.20",
39
38
  "jsdom": "^26.1.0",
@@ -43,6 +42,7 @@
43
42
  "vitest": "latest",
44
43
  "zod": "3.25.67"
45
44
  },
45
+ "peerDependencies": {},
46
46
  "files": [
47
47
  "README.md",
48
48
  "./dist/*"