@djangocfg/api 2.1.327 → 2.1.331

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 (170) hide show
  1. package/dist/auth-server.cjs +185 -3471
  2. package/dist/auth-server.cjs.map +1 -1
  3. package/dist/auth-server.mjs +185 -3471
  4. package/dist/auth-server.mjs.map +1 -1
  5. package/dist/auth.cjs +952 -3305
  6. package/dist/auth.cjs.map +1 -1
  7. package/dist/auth.d.cts +35 -35
  8. package/dist/auth.d.ts +35 -35
  9. package/dist/auth.mjs +952 -3305
  10. package/dist/auth.mjs.map +1 -1
  11. package/dist/clients.cjs +90 -3396
  12. package/dist/clients.cjs.map +1 -1
  13. package/dist/clients.d.cts +4 -2508
  14. package/dist/clients.d.ts +4 -2508
  15. package/dist/clients.mjs +90 -3396
  16. package/dist/clients.mjs.map +1 -1
  17. package/dist/index.cjs +985 -3052
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +1544 -1938
  20. package/dist/index.d.ts +1544 -1938
  21. package/dist/index.mjs +985 -3052
  22. package/dist/index.mjs.map +1 -1
  23. package/package.json +2 -2
  24. package/src/_api/generated/{cfg_centrifugo → _cfg_accounts}/api.ts +11 -55
  25. package/src/_api/generated/{cfg_totp → _cfg_accounts}/events.ts +3 -3
  26. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/index.ts +1 -1
  27. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthConnectionsList.ts +5 -6
  28. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthDisconnectCreate.ts +3 -3
  29. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts +3 -3
  30. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthGithubCallbackCreate.ts +3 -3
  31. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthProvidersRetrieve.ts +5 -6
  32. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOtpRequestCreate.ts +3 -3
  33. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOtpVerifyCreate.ts +3 -3
  34. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileAvatarCreate.ts +3 -3
  35. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileDeleteCreate.ts +3 -3
  36. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfilePartialPartialUpdate.ts +3 -3
  37. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfilePartialUpdate.ts +3 -3
  38. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileRetrieve.ts +5 -6
  39. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts +3 -3
  40. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileUpdateUpdate.ts +3 -3
  41. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsTokenRefreshCreate.ts +3 -3
  42. package/src/_api/generated/{cfg_centrifugo → _cfg_accounts}/index.ts +3 -3
  43. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/AccountDeleteResponse.ts +3 -3
  44. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/CentrifugoToken.ts +4 -4
  45. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/CfgUserUpdateRequest.ts +4 -4
  46. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthAuthorizeRequestRequest.ts +2 -2
  47. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthAuthorizeResponse.ts +2 -2
  48. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthCallbackRequestRequest.ts +3 -3
  49. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthConnection.ts +6 -6
  50. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthDisconnectRequestRequest.ts +2 -2
  51. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthError.ts +2 -2
  52. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthProvidersResponse.ts +3 -3
  53. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthTokenResponse.ts +7 -7
  54. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPErrorResponse.ts +2 -2
  55. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPRequestRequest.ts +2 -2
  56. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPRequestResponse.ts +2 -2
  57. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPVerifyRequest.ts +2 -2
  58. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPVerifyResponse.ts +6 -6
  59. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/PatchedCfgUserUpdateRequest.ts +4 -4
  60. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/ProviderEnum.ts +2 -2
  61. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/TokenRefresh.ts +2 -2
  62. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/TokenRefreshRequest.ts +2 -2
  63. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/User.ts +13 -13
  64. package/src/_api/generated/_cfg_accounts/sdk.gen.ts +5 -0
  65. package/src/_api/generated/_cfg_accounts/types.gen.ts +5 -0
  66. package/src/_api/generated/{cfg_totp → _cfg_centrifugo}/api.ts +11 -72
  67. package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/events.ts +3 -3
  68. package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/hooks/index.ts +1 -1
  69. package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +5 -6
  70. package/src/_api/generated/{cfg_accounts → _cfg_centrifugo}/index.ts +3 -3
  71. package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/schemas/ConnectionTokenResponse.ts +4 -4
  72. package/src/_api/generated/_cfg_centrifugo/sdk.gen.ts +5 -0
  73. package/src/_api/generated/_cfg_centrifugo/types.gen.ts +5 -0
  74. package/src/_api/generated/{cfg_accounts → _cfg_totp}/api.ts +11 -78
  75. package/src/_api/generated/{cfg_accounts → _cfg_totp}/events.ts +3 -3
  76. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/index.ts +1 -1
  77. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpBackupCodesRegenerateCreate.ts +3 -3
  78. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpBackupCodesRetrieve.ts +5 -6
  79. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpDevicesDestroy.ts +3 -3
  80. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpDevicesRetrieve.ts +5 -6
  81. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpDisableCreate.ts +3 -3
  82. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpSetupConfirmCreate.ts +3 -3
  83. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpSetupCreate.ts +3 -3
  84. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpVerifyBackupCreate.ts +3 -3
  85. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpVerifyCreate.ts +3 -3
  86. package/src/_api/generated/{cfg_totp → _cfg_totp}/index.ts +3 -3
  87. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/BackupCodesRegenerateRequest.ts +2 -2
  88. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/BackupCodesRegenerateResponse.ts +2 -2
  89. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/BackupCodesStatus.ts +2 -2
  90. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/ConfirmSetupRequest.ts +3 -3
  91. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/ConfirmSetupResponse.ts +3 -3
  92. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/DeviceList.ts +6 -6
  93. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/DeviceListResponse.ts +2 -2
  94. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/DeviceListStatusEnum.ts +2 -2
  95. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/DisableRequest.ts +2 -2
  96. package/src/_api/generated/_cfg_totp/schemas/SetupRequest.ts +11 -0
  97. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/SetupResponse.ts +4 -4
  98. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/TotpVerifyUser.ts +12 -12
  99. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/VerifyBackupRequest.ts +3 -3
  100. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/VerifyRequest.ts +3 -3
  101. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/VerifyResponse.ts +4 -4
  102. package/src/_api/generated/_cfg_totp/sdk.gen.ts +5 -0
  103. package/src/_api/generated/_cfg_totp/types.gen.ts +5 -0
  104. package/src/_api/generated/index.ts +11 -13
  105. package/src/_api/generated/{cfg_accounts/sdk.gen.ts → sdk.gen.ts} +455 -1
  106. package/src/_api/generated/{cfg_accounts/types.gen.ts → types.gen.ts} +607 -77
  107. package/src/auth/context/AccountsContext.tsx +10 -10
  108. package/src/auth/context/AuthContext.tsx +1 -1
  109. package/src/auth/hooks/useDeleteAccount.ts +2 -1
  110. package/src/auth/hooks/useGithubAuth.ts +3 -2
  111. package/src/auth/hooks/useTokenRefresh.ts +2 -1
  112. package/src/auth/hooks/useTwoFactor.ts +4 -3
  113. package/src/auth/hooks/useTwoFactorSetup.ts +3 -2
  114. package/src/auth/hooks/useTwoFactorStatus.ts +4 -3
  115. package/src/auth/middlewares/tokenRefresh.ts +2 -1
  116. package/src/clients.ts +3 -3
  117. package/src/index.ts +22 -5
  118. package/src/server.ts +9 -9
  119. package/src/_api/generated/cfg_centrifugo/client/client.gen.ts +0 -280
  120. package/src/_api/generated/cfg_centrifugo/client/index.ts +0 -25
  121. package/src/_api/generated/cfg_centrifugo/client/types.gen.ts +0 -217
  122. package/src/_api/generated/cfg_centrifugo/client/utils.gen.ts +0 -318
  123. package/src/_api/generated/cfg_centrifugo/client.gen.ts +0 -16
  124. package/src/_api/generated/cfg_centrifugo/core/auth.gen.ts +0 -41
  125. package/src/_api/generated/cfg_centrifugo/core/bodySerializer.gen.ts +0 -82
  126. package/src/_api/generated/cfg_centrifugo/core/params.gen.ts +0 -169
  127. package/src/_api/generated/cfg_centrifugo/core/pathSerializer.gen.ts +0 -171
  128. package/src/_api/generated/cfg_centrifugo/core/queryKeySerializer.gen.ts +0 -117
  129. package/src/_api/generated/cfg_centrifugo/core/serverSentEvents.gen.ts +0 -242
  130. package/src/_api/generated/cfg_centrifugo/core/types.gen.ts +0 -104
  131. package/src/_api/generated/cfg_centrifugo/core/utils.gen.ts +0 -140
  132. package/src/_api/generated/cfg_centrifugo/sdk.gen.ts +0 -64
  133. package/src/_api/generated/cfg_centrifugo/types.gen.ts +0 -61
  134. package/src/_api/generated/cfg_totp/client/client.gen.ts +0 -280
  135. package/src/_api/generated/cfg_totp/client/index.ts +0 -25
  136. package/src/_api/generated/cfg_totp/client/types.gen.ts +0 -217
  137. package/src/_api/generated/cfg_totp/client/utils.gen.ts +0 -318
  138. package/src/_api/generated/cfg_totp/client.gen.ts +0 -16
  139. package/src/_api/generated/cfg_totp/core/auth.gen.ts +0 -41
  140. package/src/_api/generated/cfg_totp/core/bodySerializer.gen.ts +0 -82
  141. package/src/_api/generated/cfg_totp/core/params.gen.ts +0 -169
  142. package/src/_api/generated/cfg_totp/core/pathSerializer.gen.ts +0 -171
  143. package/src/_api/generated/cfg_totp/core/queryKeySerializer.gen.ts +0 -117
  144. package/src/_api/generated/cfg_totp/core/serverSentEvents.gen.ts +0 -242
  145. package/src/_api/generated/cfg_totp/core/types.gen.ts +0 -104
  146. package/src/_api/generated/cfg_totp/core/utils.gen.ts +0 -140
  147. package/src/_api/generated/cfg_totp/schemas/SetupRequest.ts +0 -11
  148. package/src/_api/generated/cfg_totp/sdk.gen.ts +0 -432
  149. package/src/_api/generated/cfg_totp/types.gen.ts +0 -479
  150. /package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/index.ts +0 -0
  151. /package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/schemas/index.ts +0 -0
  152. /package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/index.ts +0 -0
  153. /package/src/_api/generated/{cfg_accounts/client → client}/client.gen.ts +0 -0
  154. /package/src/_api/generated/{cfg_accounts/client → client}/index.ts +0 -0
  155. /package/src/_api/generated/{cfg_accounts/client → client}/types.gen.ts +0 -0
  156. /package/src/_api/generated/{cfg_accounts/client → client}/utils.gen.ts +0 -0
  157. /package/src/_api/generated/{cfg_accounts/client.gen.ts → client.gen.ts} +0 -0
  158. /package/src/_api/generated/{cfg_accounts/core → core}/auth.gen.ts +0 -0
  159. /package/src/_api/generated/{cfg_accounts/core → core}/bodySerializer.gen.ts +0 -0
  160. /package/src/_api/generated/{cfg_accounts/core → core}/params.gen.ts +0 -0
  161. /package/src/_api/generated/{cfg_accounts/core → core}/pathSerializer.gen.ts +0 -0
  162. /package/src/_api/generated/{cfg_accounts/core → core}/queryKeySerializer.gen.ts +0 -0
  163. /package/src/_api/generated/{cfg_accounts/core → core}/serverSentEvents.gen.ts +0 -0
  164. /package/src/_api/generated/{cfg_accounts/core → core}/types.gen.ts +0 -0
  165. /package/src/_api/generated/{cfg_accounts/core → core}/utils.gen.ts +0 -0
  166. /package/src/_api/generated/{_shared → helpers}/errors.ts +0 -0
  167. /package/src/_api/generated/{_shared → helpers}/index.ts +0 -0
  168. /package/src/_api/generated/{_shared → helpers}/logger.ts +0 -0
  169. /package/src/_api/generated/{_shared → helpers}/storage.ts +0 -0
  170. /package/src/_api/generated/{_shared → helpers}/validation-events.ts +0 -0
@@ -1,104 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
-
3
- import type { Auth, AuthToken } from './auth.gen';
4
- import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from './bodySerializer.gen';
5
-
6
- export type HttpMethod =
7
- | 'connect'
8
- | 'delete'
9
- | 'get'
10
- | 'head'
11
- | 'options'
12
- | 'patch'
13
- | 'post'
14
- | 'put'
15
- | 'trace';
16
-
17
- export type Client<
18
- RequestFn = never,
19
- Config = unknown,
20
- MethodFn = never,
21
- BuildUrlFn = never,
22
- SseFn = never,
23
- > = {
24
- /**
25
- * Returns the final request URL.
26
- */
27
- buildUrl: BuildUrlFn;
28
- getConfig: () => Config;
29
- request: RequestFn;
30
- setConfig: (config: Config) => Config;
31
- } & {
32
- [K in HttpMethod]: MethodFn;
33
- } & ([SseFn] extends [never] ? { sse?: never } : { sse: { [K in HttpMethod]: SseFn } });
34
-
35
- export interface Config {
36
- /**
37
- * Auth token or a function returning auth token. The resolved value will be
38
- * added to the request payload as defined by its `security` array.
39
- */
40
- auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
41
- /**
42
- * A function for serializing request body parameter. By default,
43
- * {@link JSON.stringify()} will be used.
44
- */
45
- bodySerializer?: BodySerializer | null;
46
- /**
47
- * An object containing any HTTP headers that you want to pre-populate your
48
- * `Headers` object with.
49
- *
50
- * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
51
- */
52
- headers?:
53
- | RequestInit['headers']
54
- | Record<
55
- string,
56
- string | number | boolean | (string | number | boolean)[] | null | undefined | unknown
57
- >;
58
- /**
59
- * The request method.
60
- *
61
- * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
62
- */
63
- method?: Uppercase<HttpMethod>;
64
- /**
65
- * A function for serializing request query parameters. By default, arrays
66
- * will be exploded in form style, objects will be exploded in deepObject
67
- * style, and reserved characters are percent-encoded.
68
- *
69
- * This method will have no effect if the native `paramsSerializer()` Axios
70
- * API function is used.
71
- *
72
- * {@link https://swagger.io/docs/specification/serialization/#query View examples}
73
- */
74
- querySerializer?: QuerySerializer | QuerySerializerOptions;
75
- /**
76
- * A function validating request data. This is useful if you want to ensure
77
- * the request conforms to the desired shape, so it can be safely sent to
78
- * the server.
79
- */
80
- requestValidator?: (data: unknown) => Promise<unknown>;
81
- /**
82
- * A function transforming response data before it's returned. This is useful
83
- * for post-processing data, e.g., converting ISO strings into Date objects.
84
- */
85
- responseTransformer?: (data: unknown) => Promise<unknown>;
86
- /**
87
- * A function validating response data. This is useful if you want to ensure
88
- * the response conforms to the desired shape, so it can be safely passed to
89
- * the transformers and returned to the user.
90
- */
91
- responseValidator?: (data: unknown) => Promise<unknown>;
92
- }
93
-
94
- type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never]
95
- ? true
96
- : [T] extends [never | undefined]
97
- ? [undefined] extends [T]
98
- ? false
99
- : true
100
- : false;
101
-
102
- export type OmitNever<T extends Record<string, unknown>> = {
103
- [K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true ? never : K]: T[K];
104
- };
@@ -1,140 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
-
3
- import type { BodySerializer, QuerySerializer } from './bodySerializer.gen';
4
- import {
5
- type ArraySeparatorStyle,
6
- serializeArrayParam,
7
- serializeObjectParam,
8
- serializePrimitiveParam,
9
- } from './pathSerializer.gen';
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(
77
- style === 'label' ? `.${value as string}` : (value as string),
78
- );
79
- url = url.replace(match, replaceValue);
80
- }
81
- }
82
- return url;
83
- };
84
-
85
- export const getUrl = ({
86
- baseUrl,
87
- path,
88
- query,
89
- querySerializer,
90
- url: _url,
91
- }: {
92
- baseUrl?: string;
93
- path?: Record<string, unknown>;
94
- query?: Record<string, unknown>;
95
- querySerializer: QuerySerializer;
96
- url: string;
97
- }) => {
98
- const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
99
- let url = (baseUrl ?? '') + pathUrl;
100
- if (path) {
101
- url = defaultPathSerializer({ path, url });
102
- }
103
- let search = query ? querySerializer(query) : '';
104
- if (search.startsWith('?')) {
105
- search = search.substring(1);
106
- }
107
- if (search) {
108
- url += `?${search}`;
109
- }
110
- return url;
111
- };
112
-
113
- export function getValidRequestBody(options: {
114
- body?: unknown;
115
- bodySerializer?: BodySerializer | null;
116
- serializedBody?: unknown;
117
- }) {
118
- const hasBody = options.body !== undefined;
119
- const isSerializedBody = hasBody && options.bodySerializer;
120
-
121
- if (isSerializedBody) {
122
- if ('serializedBody' in options) {
123
- const hasSerializedBody =
124
- options.serializedBody !== undefined && options.serializedBody !== '';
125
-
126
- return hasSerializedBody ? options.serializedBody : null;
127
- }
128
-
129
- // not all clients implement a serializedBody property (i.e., client-axios)
130
- return options.body !== '' ? options.body : null;
131
- }
132
-
133
- // plain/text body
134
- if (hasBody) {
135
- return options.body;
136
- }
137
-
138
- // no body was provided
139
- return undefined;
140
- }
@@ -1,64 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
-
3
- import type { Client, Options as Options2, TDataShape } from './client';
4
- import { client } from './client.gen';
5
- import type { CfgCentrifugoAuthTokenRetrieveData, CfgCentrifugoAuthTokenRetrieveErrors, CfgCentrifugoAuthTokenRetrieveResponses } from './types.gen';
6
-
7
- export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
8
- /**
9
- * You can provide a client instance returned by `createClient()` instead of
10
- * individual options. This might be also useful if you want to implement a
11
- * custom client.
12
- */
13
- client?: Client;
14
- /**
15
- * You can pass arbitrary values through the `meta` object. This can be
16
- * used to access values that aren't defined as part of the SDK function.
17
- */
18
- meta?: Record<string, unknown>;
19
- };
20
-
21
- export class Cfg {
22
- /**
23
- * Get Centrifugo connection token
24
- *
25
- * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
26
- */
27
- public static cfgCentrifugoAuthTokenRetrieve<ThrowOnError extends boolean = false>(options?: Options<CfgCentrifugoAuthTokenRetrieveData, ThrowOnError>) {
28
- return (options?.client ?? client).get<CfgCentrifugoAuthTokenRetrieveResponses, CfgCentrifugoAuthTokenRetrieveErrors, ThrowOnError>({
29
- security: [{ scheme: 'bearer', type: 'http' }],
30
- url: '/cfg/centrifugo/auth/token/',
31
- ...options
32
- });
33
- }
34
- }
35
-
36
- export class Centrifugo {
37
- /**
38
- * Get Centrifugo connection token
39
- *
40
- * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
41
- */
42
- public static cfgCentrifugoAuthTokenRetrieve<ThrowOnError extends boolean = false>(options?: Options<CfgCentrifugoAuthTokenRetrieveData, ThrowOnError>) {
43
- return (options?.client ?? client).get<CfgCentrifugoAuthTokenRetrieveResponses, CfgCentrifugoAuthTokenRetrieveErrors, ThrowOnError>({
44
- security: [{ scheme: 'bearer', type: 'http' }],
45
- url: '/cfg/centrifugo/auth/token/',
46
- ...options
47
- });
48
- }
49
- }
50
-
51
- export class CentrifugoAuth {
52
- /**
53
- * Get Centrifugo connection token
54
- *
55
- * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
56
- */
57
- public static cfgCentrifugoAuthTokenRetrieve<ThrowOnError extends boolean = false>(options?: Options<CfgCentrifugoAuthTokenRetrieveData, ThrowOnError>) {
58
- return (options?.client ?? client).get<CfgCentrifugoAuthTokenRetrieveResponses, CfgCentrifugoAuthTokenRetrieveErrors, ThrowOnError>({
59
- security: [{ scheme: 'bearer', type: 'http' }],
60
- url: '/cfg/centrifugo/auth/token/',
61
- ...options
62
- });
63
- }
64
- }
@@ -1,61 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
-
3
- export type ClientOptions = {
4
- baseUrl: 'http://localhost:8000' | (string & {});
5
- };
6
-
7
- /**
8
- * ConnectionTokenResponse
9
- *
10
- * Response model for Centrifugo connection token.
11
- */
12
- export type ConnectionTokenResponse = {
13
- /**
14
- * Token
15
- *
16
- * JWT token for Centrifugo connection
17
- */
18
- token: string;
19
- /**
20
- * Centrifugo Url
21
- *
22
- * Centrifugo WebSocket URL
23
- */
24
- centrifugo_url: string;
25
- /**
26
- * Expires At
27
- *
28
- * Token expiration time (ISO 8601)
29
- */
30
- expires_at: string;
31
- /**
32
- * Channels
33
- *
34
- * List of allowed channels
35
- */
36
- channels: Array<string>;
37
- };
38
-
39
- export type CfgCentrifugoAuthTokenRetrieveData = {
40
- body?: never;
41
- path?: never;
42
- query?: never;
43
- url: '/cfg/centrifugo/auth/token/';
44
- };
45
-
46
- export type CfgCentrifugoAuthTokenRetrieveErrors = {
47
- /**
48
- * Unauthorized - authentication required
49
- */
50
- 401: unknown;
51
- /**
52
- * Server error
53
- */
54
- 500: unknown;
55
- };
56
-
57
- export type CfgCentrifugoAuthTokenRetrieveResponses = {
58
- 200: ConnectionTokenResponse;
59
- };
60
-
61
- export type CfgCentrifugoAuthTokenRetrieveResponse = CfgCentrifugoAuthTokenRetrieveResponses[keyof CfgCentrifugoAuthTokenRetrieveResponses];
@@ -1,280 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
-
3
- import { createSseClient } from '../core/serverSentEvents.gen';
4
- import type { HttpMethod } from '../core/types.gen';
5
- import { getValidRequestBody } from '../core/utils.gen';
6
- import type { Client, Config, RequestOptions, ResolvedRequestOptions } from './types.gen';
7
- import {
8
- buildUrl,
9
- createConfig,
10
- createInterceptors,
11
- getParseAs,
12
- mergeConfigs,
13
- mergeHeaders,
14
- setAuthParams,
15
- } from './utils.gen';
16
-
17
- type ReqInit = Omit<RequestInit, 'body' | 'headers'> & {
18
- body?: any;
19
- headers: ReturnType<typeof mergeHeaders>;
20
- };
21
-
22
- export const createClient = (config: Config = {}): Client => {
23
- let _config = mergeConfigs(createConfig(), config);
24
-
25
- const getConfig = (): Config => ({ ..._config });
26
-
27
- const setConfig = (config: Config): Config => {
28
- _config = mergeConfigs(_config, config);
29
- return getConfig();
30
- };
31
-
32
- const interceptors = createInterceptors<Request, Response, unknown, ResolvedRequestOptions>();
33
-
34
- const beforeRequest = async <
35
- TData = unknown,
36
- TResponseStyle extends 'data' | 'fields' = 'fields',
37
- ThrowOnError extends boolean = boolean,
38
- Url extends string = string,
39
- >(
40
- options: RequestOptions<TData, TResponseStyle, ThrowOnError, Url>,
41
- ) => {
42
- const opts = {
43
- ..._config,
44
- ...options,
45
- fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
46
- headers: mergeHeaders(_config.headers, options.headers),
47
- serializedBody: undefined as string | undefined,
48
- };
49
-
50
- if (opts.security) {
51
- await setAuthParams({
52
- ...opts,
53
- security: opts.security,
54
- });
55
- }
56
-
57
- if (opts.requestValidator) {
58
- await opts.requestValidator(opts);
59
- }
60
-
61
- if (opts.body !== undefined && opts.bodySerializer) {
62
- opts.serializedBody = opts.bodySerializer(opts.body) as string | undefined;
63
- }
64
-
65
- // remove Content-Type header if body is empty to avoid sending invalid requests
66
- if (opts.body === undefined || opts.serializedBody === '') {
67
- opts.headers.delete('Content-Type');
68
- }
69
-
70
- const resolvedOpts = opts as typeof opts &
71
- ResolvedRequestOptions<TResponseStyle, ThrowOnError, Url>;
72
- const url = buildUrl(resolvedOpts);
73
-
74
- return { opts: resolvedOpts, url };
75
- };
76
-
77
- const request: Client['request'] = async (options) => {
78
- const throwOnError = options.throwOnError ?? _config.throwOnError;
79
- const responseStyle = options.responseStyle ?? _config.responseStyle;
80
-
81
- let request: Request | undefined;
82
- let response: Response | undefined;
83
-
84
- try {
85
- const { opts, url } = await beforeRequest(options);
86
- const requestInit: ReqInit = {
87
- redirect: 'follow',
88
- ...opts,
89
- body: getValidRequestBody(opts),
90
- };
91
-
92
- request = new Request(url, requestInit);
93
-
94
- for (const fn of interceptors.request.fns) {
95
- if (fn) {
96
- request = await fn(request, opts);
97
- }
98
- }
99
-
100
- // fetch must be assigned here, otherwise it would throw the error:
101
- // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
102
- const _fetch = opts.fetch!;
103
-
104
- response = await _fetch(request);
105
-
106
- for (const fn of interceptors.response.fns) {
107
- if (fn) {
108
- response = await fn(response, request, opts);
109
- }
110
- }
111
-
112
- const result = {
113
- request,
114
- response,
115
- };
116
-
117
- if (response.ok) {
118
- const parseAs =
119
- (opts.parseAs === 'auto'
120
- ? getParseAs(response.headers.get('Content-Type'))
121
- : opts.parseAs) ?? 'json';
122
-
123
- if (response.status === 204 || response.headers.get('Content-Length') === '0') {
124
- let emptyData: any;
125
- switch (parseAs) {
126
- case 'arrayBuffer':
127
- case 'blob':
128
- case 'text':
129
- emptyData = await response[parseAs]();
130
- break;
131
- case 'formData':
132
- emptyData = new FormData();
133
- break;
134
- case 'stream':
135
- emptyData = response.body;
136
- break;
137
- case 'json':
138
- default:
139
- emptyData = {};
140
- break;
141
- }
142
- return opts.responseStyle === 'data'
143
- ? emptyData
144
- : {
145
- data: emptyData,
146
- ...result,
147
- };
148
- }
149
-
150
- let data: any;
151
- switch (parseAs) {
152
- case 'arrayBuffer':
153
- case 'blob':
154
- case 'formData':
155
- case 'text':
156
- data = await response[parseAs]();
157
- break;
158
- case 'json': {
159
- // Some servers return 200 with no Content-Length and empty body.
160
- // response.json() would throw; read as text and parse if non-empty.
161
- const text = await response.text();
162
- data = text ? JSON.parse(text) : {};
163
- break;
164
- }
165
- case 'stream':
166
- return opts.responseStyle === 'data'
167
- ? response.body
168
- : {
169
- data: response.body,
170
- ...result,
171
- };
172
- }
173
-
174
- if (parseAs === 'json') {
175
- if (opts.responseValidator) {
176
- await opts.responseValidator(data);
177
- }
178
-
179
- if (opts.responseTransformer) {
180
- data = await opts.responseTransformer(data);
181
- }
182
- }
183
-
184
- return opts.responseStyle === 'data'
185
- ? data
186
- : {
187
- data,
188
- ...result,
189
- };
190
- }
191
-
192
- const textError = await response.text();
193
- let jsonError: unknown;
194
-
195
- try {
196
- jsonError = JSON.parse(textError);
197
- } catch {
198
- // noop
199
- }
200
-
201
- throw jsonError ?? textError;
202
- } catch (error) {
203
- let finalError = error;
204
-
205
- for (const fn of interceptors.error.fns) {
206
- if (fn) {
207
- finalError = await fn(finalError, response, request, options as ResolvedRequestOptions);
208
- }
209
- }
210
-
211
- finalError = finalError || {};
212
-
213
- if (throwOnError) {
214
- throw finalError;
215
- }
216
-
217
- // TODO: we probably want to return error and improve types
218
- return responseStyle === 'data'
219
- ? undefined
220
- : {
221
- error: finalError,
222
- request,
223
- response,
224
- };
225
- }
226
- };
227
-
228
- const makeMethodFn = (method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
229
- request({ ...options, method });
230
-
231
- const makeSseFn = (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => {
232
- const { opts, url } = await beforeRequest(options);
233
- return createSseClient({
234
- ...opts,
235
- body: opts.body as BodyInit | null | undefined,
236
- method,
237
- onRequest: async (url, init) => {
238
- let request = new Request(url, init);
239
- for (const fn of interceptors.request.fns) {
240
- if (fn) {
241
- request = await fn(request, opts);
242
- }
243
- }
244
- return request;
245
- },
246
- serializedBody: getValidRequestBody(opts) as BodyInit | null | undefined,
247
- url,
248
- });
249
- };
250
-
251
- const _buildUrl: Client['buildUrl'] = (options) => buildUrl({ ..._config, ...options });
252
-
253
- return {
254
- buildUrl: _buildUrl,
255
- connect: makeMethodFn('CONNECT'),
256
- delete: makeMethodFn('DELETE'),
257
- get: makeMethodFn('GET'),
258
- getConfig,
259
- head: makeMethodFn('HEAD'),
260
- interceptors,
261
- options: makeMethodFn('OPTIONS'),
262
- patch: makeMethodFn('PATCH'),
263
- post: makeMethodFn('POST'),
264
- put: makeMethodFn('PUT'),
265
- request,
266
- setConfig,
267
- sse: {
268
- connect: makeSseFn('CONNECT'),
269
- delete: makeSseFn('DELETE'),
270
- get: makeSseFn('GET'),
271
- head: makeSseFn('HEAD'),
272
- options: makeSseFn('OPTIONS'),
273
- patch: makeSseFn('PATCH'),
274
- post: makeSseFn('POST'),
275
- put: makeSseFn('PUT'),
276
- trace: makeSseFn('TRACE'),
277
- },
278
- trace: makeMethodFn('TRACE'),
279
- } as Client;
280
- };
@@ -1,25 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
-
3
- export type { Auth } from '../core/auth.gen';
4
- export type { QuerySerializerOptions } from '../core/bodySerializer.gen';
5
- export {
6
- formDataBodySerializer,
7
- jsonBodySerializer,
8
- urlSearchParamsBodySerializer,
9
- } from '../core/bodySerializer.gen';
10
- export { buildClientParams } from '../core/params.gen';
11
- export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen';
12
- export { createClient } from './client.gen';
13
- export type {
14
- Client,
15
- ClientOptions,
16
- Config,
17
- CreateClientConfig,
18
- Options,
19
- RequestOptions,
20
- RequestResult,
21
- ResolvedRequestOptions,
22
- ResponseStyle,
23
- TDataShape,
24
- } from './types.gen';
25
- export { createConfig, mergeHeaders } from './utils.gen';