@zayne-labs/callapi 1.7.1 → 1.7.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Ikedigwe Ebube
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,5 +1,3 @@
1
- import { StandardSchemaV1 } from '@standard-schema/spec';
2
-
3
1
  type ValueOrFunctionResult<TValue> = TValue | (() => TValue);
4
2
  /**
5
3
  * Bearer Or Token authentication
@@ -56,6 +54,9 @@ type AnyNumber = number & {
56
54
  z_placeholder?: never;
57
55
  };
58
56
  type AnyFunction<TResult = unknown> = (...args: any) => TResult;
57
+ type Prettify<TObject> = NonNullable<unknown> & {
58
+ [Key in keyof TObject]: TObject[Key];
59
+ };
59
60
  type UnmaskType<TValue> = {
60
61
  _: TValue;
61
62
  }["_"];
@@ -64,6 +65,105 @@ type CommonRequestHeaders = "Access-Control-Allow-Credentials" | "Access-Control
64
65
  type CommonAuthorizationHeaders = `${"Basic" | "Bearer" | "Token"} ${string}`;
65
66
  type CommonContentTypes = "application/epub+zip" | "application/gzip" | "application/json" | "application/ld+json" | "application/octet-stream" | "application/ogg" | "application/pdf" | "application/rtf" | "application/vnd.ms-fontobject" | "application/wasm" | "application/xhtml+xml" | "application/xml" | "application/zip" | "audio/aac" | "audio/mpeg" | "audio/ogg" | "audio/opus" | "audio/webm" | "audio/x-midi" | "font/otf" | "font/ttf" | "font/woff" | "font/woff2" | "image/avif" | "image/bmp" | "image/gif" | "image/jpeg" | "image/png" | "image/svg+xml" | "image/tiff" | "image/webp" | "image/x-icon" | "model/gltf-binary" | "model/gltf+json" | "text/calendar" | "text/css" | "text/csv" | "text/html" | "text/javascript" | "text/plain" | "video/3gpp" | "video/3gpp2" | "video/av1" | "video/mp2t" | "video/mp4" | "video/mpeg" | "video/ogg" | "video/webm" | "video/x-msvideo" | AnyString;
66
67
 
68
+ /**
69
+ * The Standard Schema interface.
70
+ * @see https://github.com/standard-schema/standard-schema
71
+ */
72
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
73
+ /**
74
+ * The Standard Schema properties.
75
+ */
76
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
77
+ }
78
+ declare namespace StandardSchemaV1 {
79
+ /**
80
+ * The Standard Schema properties interface.
81
+ */
82
+ interface Props<Input = unknown, Output = Input> {
83
+ /**
84
+ * Inferred types associated with the schema.
85
+ */
86
+ readonly types?: Types<Input, Output> | undefined;
87
+ /**
88
+ * Validates unknown input values.
89
+ */
90
+ readonly validate: (value: unknown) => Promise<Result<Output>> | Result<Output>;
91
+ /**
92
+ * The vendor name of the schema library.
93
+ */
94
+ readonly vendor: string;
95
+ /**
96
+ * The version number of the standard.
97
+ */
98
+ readonly version: 1;
99
+ }
100
+ /**
101
+ * The result interface of the validate function.
102
+ */
103
+ type Result<Output> = FailureResult | SuccessResult<Output>;
104
+ /**
105
+ * The result interface if validation succeeds.
106
+ */
107
+ interface SuccessResult<Output> {
108
+ /**
109
+ * The non-existent issues.
110
+ */
111
+ readonly issues?: undefined;
112
+ /**
113
+ * The typed output value.
114
+ */
115
+ readonly value: Output;
116
+ }
117
+ /**
118
+ * The result interface if validation fails.
119
+ */
120
+ interface FailureResult {
121
+ /**
122
+ * The issues of failed validation.
123
+ */
124
+ readonly issues: readonly Issue[];
125
+ }
126
+ /**
127
+ * The issue interface of the failure output.
128
+ */
129
+ interface Issue {
130
+ /**
131
+ * The error message of the issue.
132
+ */
133
+ readonly message: string;
134
+ /**
135
+ * The path of the issue, if any.
136
+ */
137
+ readonly path?: ReadonlyArray<PathSegment | PropertyKey> | undefined;
138
+ }
139
+ /**
140
+ * The path segment interface of the issue.
141
+ */
142
+ interface PathSegment {
143
+ /**
144
+ * The key representing a path segment.
145
+ */
146
+ readonly key: PropertyKey;
147
+ }
148
+ /**
149
+ * The Standard Schema types interface.
150
+ */
151
+ interface Types<Input = unknown, Output = Input> {
152
+ /** The input type of the schema. */
153
+ readonly input: Input;
154
+ /** The output type of the schema. */
155
+ readonly output: Output;
156
+ }
157
+ /**
158
+ * Infers the input type of a Standard Schema.
159
+ */
160
+ type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
161
+ /**
162
+ * Infers the output type of a Standard Schema.
163
+ */
164
+ type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
165
+ }
166
+
67
167
  interface CallApiSchemas {
68
168
  /**
69
169
  * The schema to use for validating the request body.
@@ -280,9 +380,9 @@ declare const definePlugin: <TPlugin extends CallApiPlugin | AnyFunction<CallApi
280
380
  type Plugins<TPluginArray extends CallApiPlugin[]> = TPluginArray;
281
381
 
282
382
  type ModifiedRequestInit = RequestInit & {
283
- duplex?: "full" | "half" | "none";
383
+ duplex?: "half";
284
384
  };
285
- declare const fetchSpecificKeys: ("body" | "cache" | "credentials" | "headers" | "integrity" | "keepalive" | "method" | "mode" | "priority" | "redirect" | "referrer" | "referrerPolicy" | "signal" | "window" | "duplex")[];
385
+ declare const fetchSpecificKeys: (keyof RequestInit | "duplex")[];
286
386
  declare const getDefaultOptions: () => {
287
387
  baseURL: string;
288
388
  bodySerializer: {
@@ -374,7 +474,7 @@ type ResultModeOption<TErrorData, TResultMode extends ResultModeUnion> = TErrorD
374
474
  };
375
475
 
376
476
  type FetchSpecificKeysUnion = Exclude<(typeof fetchSpecificKeys)[number], "body" | "headers" | "method">;
377
- type CallApiRequestOptions<TSchemas extends CallApiSchemas = DefaultMoreOptions> = BodyOption<TSchemas> & HeadersOption<TSchemas> & MethodOption<TSchemas> & Pick<ModifiedRequestInit, FetchSpecificKeysUnion>;
477
+ type CallApiRequestOptions<TSchemas extends CallApiSchemas = DefaultMoreOptions> = Prettify<BodyOption<TSchemas> & HeadersOption<TSchemas> & MethodOption<TSchemas> & Pick<ModifiedRequestInit, FetchSpecificKeysUnion>>;
378
478
  type CallApiRequestOptionsForHooks<TSchemas extends CallApiSchemas = DefaultMoreOptions> = Omit<CallApiRequestOptions<TSchemas>, "headers"> & {
379
479
  headers?: Record<string, string | undefined>;
380
480
  };
@@ -486,7 +586,7 @@ type ExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, TResult
486
586
  mergedHooksExecutionMode?: "parallel" | "sequential";
487
587
  /**
488
588
  * - Controls what order in which the merged hooks execute
489
- * @default "mainHooksLast"
589
+ * @default "mainHooksAfterPlugins"
490
590
  */
491
591
  mergedHooksExecutionOrder?: "mainHooksAfterPlugins" | "mainHooksBeforePlugins";
492
592
  /**