@saeeol/sdk 7.3.2 → 7.3.4

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 (39) hide show
  1. package/package.json +11 -35
  2. package/src/client.ts +64 -0
  3. package/src/gen/client/client.gen.ts +215 -0
  4. package/src/gen/client/index.ts +25 -0
  5. package/src/gen/client/types.gen.ts +222 -0
  6. package/src/gen/client/utils.gen.ts +287 -0
  7. package/src/gen/client.gen.ts +22 -0
  8. package/src/gen/core/auth.gen.ts +41 -0
  9. package/src/gen/core/bodySerializer.gen.ts +74 -0
  10. package/src/gen/core/params.gen.ts +144 -0
  11. package/src/gen/core/pathSerializer.gen.ts +167 -0
  12. package/src/gen/core/queryKeySerializer.gen.ts +111 -0
  13. package/src/gen/core/serverSentEvents.gen.ts +210 -0
  14. package/src/gen/core/types.gen.ts +91 -0
  15. package/src/gen/core/utils.gen.ts +109 -0
  16. package/src/gen/sdk.gen.ts +1197 -0
  17. package/src/gen/types.gen.ts +3905 -0
  18. package/src/index.ts +21 -0
  19. package/src/process.ts +31 -0
  20. package/src/server.ts +165 -0
  21. package/src/v2/client.ts +97 -0
  22. package/src/v2/data.ts +32 -0
  23. package/src/v2/gen/client/client.gen.ts +285 -0
  24. package/src/v2/gen/client/index.ts +25 -0
  25. package/src/v2/gen/client/types.gen.ts +202 -0
  26. package/src/v2/gen/client/utils.gen.ts +289 -0
  27. package/src/v2/gen/client.gen.ts +18 -0
  28. package/src/v2/gen/core/auth.gen.ts +41 -0
  29. package/src/v2/gen/core/bodySerializer.gen.ts +82 -0
  30. package/src/v2/gen/core/params.gen.ts +169 -0
  31. package/src/v2/gen/core/pathSerializer.gen.ts +167 -0
  32. package/src/v2/gen/core/queryKeySerializer.gen.ts +111 -0
  33. package/src/v2/gen/core/serverSentEvents.gen.ts +239 -0
  34. package/src/v2/gen/core/types.gen.ts +86 -0
  35. package/src/v2/gen/core/utils.gen.ts +137 -0
  36. package/src/v2/gen/sdk.gen.ts +6316 -0
  37. package/src/v2/gen/types.gen.ts +7495 -0
  38. package/src/v2/index.ts +23 -0
  39. package/src/v2/server.ts +163 -0
@@ -0,0 +1,86 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+
3
+ import type { Auth, AuthToken } from "./auth.gen.js"
4
+ import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from "./bodySerializer.gen.js"
5
+
6
+ export type HttpMethod = "connect" | "delete" | "get" | "head" | "options" | "patch" | "post" | "put" | "trace"
7
+
8
+ export type Client<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
9
+ /**
10
+ * Returns the final request URL.
11
+ */
12
+ buildUrl: BuildUrlFn
13
+ getConfig: () => Config
14
+ request: RequestFn
15
+ setConfig: (config: Config) => Config
16
+ } & {
17
+ [K in HttpMethod]: MethodFn
18
+ } & ([SseFn] extends [never] ? { sse?: never } : { sse: { [K in HttpMethod]: SseFn } })
19
+
20
+ export interface Config {
21
+ /**
22
+ * Auth token or a function returning auth token. The resolved value will be
23
+ * added to the request payload as defined by its `security` array.
24
+ */
25
+ auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken
26
+ /**
27
+ * A function for serializing request body parameter. By default,
28
+ * {@link JSON.stringify()} will be used.
29
+ */
30
+ bodySerializer?: BodySerializer | null
31
+ /**
32
+ * An object containing any HTTP headers that you want to pre-populate your
33
+ * `Headers` object with.
34
+ *
35
+ * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
36
+ */
37
+ headers?:
38
+ | RequestInit["headers"]
39
+ | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>
40
+ /**
41
+ * The request method.
42
+ *
43
+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
44
+ */
45
+ method?: Uppercase<HttpMethod>
46
+ /**
47
+ * A function for serializing request query parameters. By default, arrays
48
+ * will be exploded in form style, objects will be exploded in deepObject
49
+ * style, and reserved characters are percent-encoded.
50
+ *
51
+ * This method will have no effect if the native `paramsSerializer()` Axios
52
+ * API function is used.
53
+ *
54
+ * {@link https://swagger.io/docs/specification/serialization/#query View examples}
55
+ */
56
+ querySerializer?: QuerySerializer | QuerySerializerOptions
57
+ /**
58
+ * A function validating request data. This is useful if you want to ensure
59
+ * the request conforms to the desired shape, so it can be safely sent to
60
+ * the server.
61
+ */
62
+ requestValidator?: (data: unknown) => Promise<unknown>
63
+ /**
64
+ * A function transforming response data before it's returned. This is useful
65
+ * for post-processing data, e.g. converting ISO strings into Date objects.
66
+ */
67
+ responseTransformer?: (data: unknown) => Promise<unknown>
68
+ /**
69
+ * A function validating response data. This is useful if you want to ensure
70
+ * the response conforms to the desired shape, so it can be safely passed to
71
+ * the transformers and returned to the user.
72
+ */
73
+ responseValidator?: (data: unknown) => Promise<unknown>
74
+ }
75
+
76
+ type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never]
77
+ ? true
78
+ : [T] extends [never | undefined]
79
+ ? [undefined] extends [T]
80
+ ? false
81
+ : true
82
+ : false
83
+
84
+ export type OmitNever<T extends Record<string, unknown>> = {
85
+ [K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true ? never : K]: T[K]
86
+ }
@@ -0,0 +1,137 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+
3
+ import type { BodySerializer, QuerySerializer } from "./bodySerializer.gen.js"
4
+ import {
5
+ type ArraySeparatorStyle,
6
+ serializeArrayParam,
7
+ serializeObjectParam,
8
+ serializePrimitiveParam,
9
+ } from "./pathSerializer.gen.js"
10
+
11
+ export interface PathSerializer {
12
+ path: Record<string, unknown>
13
+ url: string
14
+ }
15
+
16
+ export const PATH_PARAM_RE = /\{[^{}]+\}/g
17
+
18
+ export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
19
+ let url = _url
20
+ const matches = _url.match(PATH_PARAM_RE)
21
+ if (matches) {
22
+ for (const match of matches) {
23
+ let explode = false
24
+ let name = match.substring(1, match.length - 1)
25
+ let style: ArraySeparatorStyle = "simple"
26
+
27
+ if (name.endsWith("*")) {
28
+ explode = true
29
+ name = name.substring(0, name.length - 1)
30
+ }
31
+
32
+ if (name.startsWith(".")) {
33
+ name = name.substring(1)
34
+ style = "label"
35
+ } else if (name.startsWith(";")) {
36
+ name = name.substring(1)
37
+ style = "matrix"
38
+ }
39
+
40
+ const value = path[name]
41
+
42
+ if (value === undefined || value === null) {
43
+ continue
44
+ }
45
+
46
+ if (Array.isArray(value)) {
47
+ url = url.replace(match, serializeArrayParam({ explode, name, style, value }))
48
+ continue
49
+ }
50
+
51
+ if (typeof value === "object") {
52
+ url = url.replace(
53
+ match,
54
+ serializeObjectParam({
55
+ explode,
56
+ name,
57
+ style,
58
+ value: value as Record<string, unknown>,
59
+ valueOnly: true,
60
+ }),
61
+ )
62
+ continue
63
+ }
64
+
65
+ if (style === "matrix") {
66
+ url = url.replace(
67
+ match,
68
+ `;${serializePrimitiveParam({
69
+ name,
70
+ value: value as string,
71
+ })}`,
72
+ )
73
+ continue
74
+ }
75
+
76
+ const replaceValue = encodeURIComponent(style === "label" ? `.${value as string}` : (value as string))
77
+ url = url.replace(match, replaceValue)
78
+ }
79
+ }
80
+ return url
81
+ }
82
+
83
+ export const getUrl = ({
84
+ baseUrl,
85
+ path,
86
+ query,
87
+ querySerializer,
88
+ url: _url,
89
+ }: {
90
+ baseUrl?: string
91
+ path?: Record<string, unknown>
92
+ query?: Record<string, unknown>
93
+ querySerializer: QuerySerializer
94
+ url: string
95
+ }) => {
96
+ const pathUrl = _url.startsWith("/") ? _url : `/${_url}`
97
+ let url = (baseUrl ?? "") + pathUrl
98
+ if (path) {
99
+ url = defaultPathSerializer({ path, url })
100
+ }
101
+ let search = query ? querySerializer(query) : ""
102
+ if (search.startsWith("?")) {
103
+ search = search.substring(1)
104
+ }
105
+ if (search) {
106
+ url += `?${search}`
107
+ }
108
+ return url
109
+ }
110
+
111
+ export function getValidRequestBody(options: {
112
+ body?: unknown
113
+ bodySerializer?: BodySerializer | null
114
+ serializedBody?: unknown
115
+ }) {
116
+ const hasBody = options.body !== undefined
117
+ const isSerializedBody = hasBody && options.bodySerializer
118
+
119
+ if (isSerializedBody) {
120
+ if ("serializedBody" in options) {
121
+ const hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !== ""
122
+
123
+ return hasSerializedBody ? options.serializedBody : null
124
+ }
125
+
126
+ // not all clients implement a serializedBody property (i.e. client-axios)
127
+ return options.body !== "" ? options.body : null
128
+ }
129
+
130
+ // plain/text body
131
+ if (hasBody) {
132
+ return options.body
133
+ }
134
+
135
+ // no body was provided
136
+ return undefined
137
+ }