@touhidrahman/restauth-sdk 1.0.3 → 1.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/index.cjs.js CHANGED
@@ -1,250 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  // This file is auto-generated by @hey-api/openapi-ts
4
- const serializeFormDataPair = (data, key, value) => {
5
- if (typeof value === 'string' || value instanceof Blob) {
6
- data.append(key, value);
7
- } else if (value instanceof Date) {
8
- data.append(key, value.toISOString());
9
- } else {
10
- data.append(key, JSON.stringify(value));
11
- }
12
- };
13
- const serializeUrlSearchParamsPair = (data, key, value) => {
14
- if (typeof value === 'string') {
15
- data.append(key, value);
16
- } else {
17
- data.append(key, JSON.stringify(value));
18
- }
19
- };
20
- const formDataBodySerializer = {
21
- bodySerializer: body => {
22
- const data = new FormData();
23
- Object.entries(body).forEach(([key, value]) => {
24
- if (value === undefined || value === null) {
25
- return;
26
- }
27
- if (Array.isArray(value)) {
28
- value.forEach(v => serializeFormDataPair(data, key, v));
29
- } else {
30
- serializeFormDataPair(data, key, value);
31
- }
32
- });
33
- return data;
34
- }
35
- };
36
4
  const jsonBodySerializer = {
37
5
  bodySerializer: body => JSON.stringify(body, (_key, value) => typeof value === 'bigint' ? value.toString() : value)
38
6
  };
39
- const urlSearchParamsBodySerializer = {
40
- bodySerializer: body => {
41
- const data = new URLSearchParams();
42
- Object.entries(body).forEach(([key, value]) => {
43
- if (value === undefined || value === null) {
44
- return;
45
- }
46
- if (Array.isArray(value)) {
47
- value.forEach(v => serializeUrlSearchParamsPair(data, key, v));
48
- } else {
49
- serializeUrlSearchParamsPair(data, key, value);
50
- }
51
- });
52
- return data.toString();
53
- }
54
- };
55
-
56
- // This file is auto-generated by @hey-api/openapi-ts
57
- const extraPrefixesMap = {
58
- $body_: 'body',
59
- $headers_: 'headers',
60
- $path_: 'path',
61
- $query_: 'query'
62
- };
63
- const extraPrefixes = Object.entries(extraPrefixesMap);
64
- function buildKeyMap(fields, map) {
65
- if (!map) {
66
- map = new Map();
67
- }
68
- for (const config of fields) {
69
- if ('in' in config) {
70
- if (config.key) {
71
- map.set(config.key, {
72
- in: config.in,
73
- map: config.map
74
- });
75
- }
76
- } else if ('key' in config) {
77
- map.set(config.key, {
78
- map: config.map
79
- });
80
- } else if (config.args) {
81
- buildKeyMap(config.args, map);
82
- }
83
- }
84
- return map;
85
- }
86
- function stripEmptySlots(params) {
87
- for (const [slot, value] of Object.entries(params)) {
88
- if (slot === 'body') continue;
89
- if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) {
90
- delete params[slot];
91
- }
92
- }
93
- }
94
- function buildClientParams(args, fields) {
95
- const params = {
96
- headers: Object.create(null),
97
- path: Object.create(null),
98
- query: Object.create(null)
99
- };
100
- const map = buildKeyMap(fields);
101
- function writeSlot(slot, key, value) {
102
- let record = params[slot];
103
- if (record === undefined) {
104
- record = Object.create(null);
105
- params[slot] = record;
106
- }
107
- record[key] = value;
108
- }
109
- let config;
110
- for (const [index, arg] of args.entries()) {
111
- if (fields[index]) {
112
- config = fields[index];
113
- }
114
- if (!config) {
115
- continue;
116
- }
117
- if ('in' in config) {
118
- if (config.key) {
119
- const field = map.get(config.key);
120
- const name = field.map || config.key;
121
- if (field.in) {
122
- writeSlot(field.in, name, arg);
123
- }
124
- } else {
125
- params.body = arg;
126
- }
127
- } else {
128
- for (const [key, value] of Object.entries(arg ?? {})) {
129
- const field = map.get(key);
130
- if (field) {
131
- if (field.in) {
132
- const name = field.map || key;
133
- writeSlot(field.in, name, value);
134
- } else {
135
- params[field.map] = value;
136
- }
137
- } else {
138
- const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
139
- if (extra) {
140
- const [prefix, slot] = extra;
141
- writeSlot(slot, key.slice(prefix.length), value);
142
- } else if ('allowExtra' in config && config.allowExtra) {
143
- for (const [slot, allowed] of Object.entries(config.allowExtra)) {
144
- if (allowed) {
145
- writeSlot(slot, key, value);
146
- break;
147
- }
148
- }
149
- }
150
- }
151
- }
152
- }
153
- }
154
- stripEmptySlots(params);
155
- return params;
156
- }
157
-
158
- // This file is auto-generated by @hey-api/openapi-ts
159
- /**
160
- * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
161
- */
162
- const queryKeyJsonReplacer = (_key, value) => {
163
- if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
164
- return undefined;
165
- }
166
- if (typeof value === 'bigint') {
167
- return value.toString();
168
- }
169
- if (value instanceof Date) {
170
- return value.toISOString();
171
- }
172
- return value;
173
- };
174
- /**
175
- * Safely stringifies a value and parses it back into a JsonValue.
176
- */
177
- const stringifyToJsonValue = input => {
178
- try {
179
- const json = JSON.stringify(input, queryKeyJsonReplacer);
180
- if (json === undefined) {
181
- return undefined;
182
- }
183
- return JSON.parse(json);
184
- } catch {
185
- return undefined;
186
- }
187
- };
188
- /**
189
- * Detects plain objects (including objects with a null prototype).
190
- */
191
- const isPlainObject = value => {
192
- if (value === null || typeof value !== 'object') {
193
- return false;
194
- }
195
- const prototype = Object.getPrototypeOf(value);
196
- return prototype === Object.prototype || prototype === null;
197
- };
198
- /**
199
- * Turns URLSearchParams into a sorted JSON object for deterministic keys.
200
- */
201
- const serializeSearchParams = params => {
202
- const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b));
203
- const result = {};
204
- for (const [key, value] of entries) {
205
- const existing = result[key];
206
- if (existing === undefined) {
207
- result[key] = value;
208
- continue;
209
- }
210
- if (Array.isArray(existing)) {
211
- existing.push(value);
212
- } else {
213
- result[key] = [existing, value];
214
- }
215
- }
216
- return result;
217
- };
218
- /**
219
- * Normalizes any accepted value into a JSON-friendly shape for query keys.
220
- */
221
- const serializeQueryKeyValue = value => {
222
- if (value === null) {
223
- return null;
224
- }
225
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
226
- return value;
227
- }
228
- if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
229
- return undefined;
230
- }
231
- if (typeof value === 'bigint') {
232
- return value.toString();
233
- }
234
- if (value instanceof Date) {
235
- return value.toISOString();
236
- }
237
- if (Array.isArray(value)) {
238
- return stringifyToJsonValue(value);
239
- }
240
- if (typeof URLSearchParams !== 'undefined' && value instanceof URLSearchParams) {
241
- return serializeSearchParams(value);
242
- }
243
- if (isPlainObject(value)) {
244
- return stringifyToJsonValue(value);
245
- }
246
- return undefined;
247
- };
248
7
 
249
8
  // This file is auto-generated by @hey-api/openapi-ts
250
9
  function createSseClient({
@@ -3019,9 +2778,7 @@ const putOrganizationsByOrganizationIdZonesByIdChangeId = options => (options.cl
3019
2778
  }
3020
2779
  });
3021
2780
 
3022
- exports.buildClientParams = buildClientParams;
3023
- exports.createClient = createClient;
3024
- exports.createConfig = createConfig;
2781
+ exports.client = client;
3025
2782
  exports.deleteGroupsByGroupIdUsersByUserId = deleteGroupsByGroupIdUsersByUserId;
3026
2783
  exports.deleteGroupsById = deleteGroupsById;
3027
2784
  exports.deleteInvitesById = deleteInvitesById;
@@ -3040,7 +2797,6 @@ exports.deleteSecretKeysById = deleteSecretKeysById;
3040
2797
  exports.deleteUsers = deleteUsers;
3041
2798
  exports.deleteUsersById = deleteUsersById;
3042
2799
  exports.deleteUsersByIdMembershipsByMembershipId = deleteUsersByIdMembershipsByMembershipId;
3043
- exports.formDataBodySerializer = formDataBodySerializer;
3044
2800
  exports.get = get;
3045
2801
  exports.getGroups = getGroups;
3046
2802
  exports.getGroupsById = getGroupsById;
@@ -3087,8 +2843,6 @@ exports.getUsersCustomInactive = getUsersCustomInactive;
3087
2843
  exports.getUsersCustomUnverified = getUsersCustomUnverified;
3088
2844
  exports.getUsersMe = getUsersMe;
3089
2845
  exports.getV1ListErrorCodes = getV1ListErrorCodes;
3090
- exports.jsonBodySerializer = jsonBodySerializer;
3091
- exports.mergeHeaders = mergeHeaders;
3092
2846
  exports.postAdminLogin = postAdminLogin;
3093
2847
  exports.postAdminNewToken = postAdminNewToken;
3094
2848
  exports.postGroups = postGroups;
@@ -3137,5 +2891,3 @@ exports.putRolesById = putRolesById;
3137
2891
  exports.putRolesByIdChangeId = putRolesByIdChangeId;
3138
2892
  exports.putUsersById = putUsersById;
3139
2893
  exports.putUsersByIdChangeId = putUsersByIdChangeId;
3140
- exports.serializeQueryKeyValue = serializeQueryKeyValue;
3141
- exports.urlSearchParamsBodySerializer = urlSearchParamsBodySerializer;
package/index.esm.js CHANGED
@@ -1,248 +1,7 @@
1
1
  // This file is auto-generated by @hey-api/openapi-ts
2
- const serializeFormDataPair = (data, key, value) => {
3
- if (typeof value === 'string' || value instanceof Blob) {
4
- data.append(key, value);
5
- } else if (value instanceof Date) {
6
- data.append(key, value.toISOString());
7
- } else {
8
- data.append(key, JSON.stringify(value));
9
- }
10
- };
11
- const serializeUrlSearchParamsPair = (data, key, value) => {
12
- if (typeof value === 'string') {
13
- data.append(key, value);
14
- } else {
15
- data.append(key, JSON.stringify(value));
16
- }
17
- };
18
- const formDataBodySerializer = {
19
- bodySerializer: body => {
20
- const data = new FormData();
21
- Object.entries(body).forEach(([key, value]) => {
22
- if (value === undefined || value === null) {
23
- return;
24
- }
25
- if (Array.isArray(value)) {
26
- value.forEach(v => serializeFormDataPair(data, key, v));
27
- } else {
28
- serializeFormDataPair(data, key, value);
29
- }
30
- });
31
- return data;
32
- }
33
- };
34
2
  const jsonBodySerializer = {
35
3
  bodySerializer: body => JSON.stringify(body, (_key, value) => typeof value === 'bigint' ? value.toString() : value)
36
4
  };
37
- const urlSearchParamsBodySerializer = {
38
- bodySerializer: body => {
39
- const data = new URLSearchParams();
40
- Object.entries(body).forEach(([key, value]) => {
41
- if (value === undefined || value === null) {
42
- return;
43
- }
44
- if (Array.isArray(value)) {
45
- value.forEach(v => serializeUrlSearchParamsPair(data, key, v));
46
- } else {
47
- serializeUrlSearchParamsPair(data, key, value);
48
- }
49
- });
50
- return data.toString();
51
- }
52
- };
53
-
54
- // This file is auto-generated by @hey-api/openapi-ts
55
- const extraPrefixesMap = {
56
- $body_: 'body',
57
- $headers_: 'headers',
58
- $path_: 'path',
59
- $query_: 'query'
60
- };
61
- const extraPrefixes = Object.entries(extraPrefixesMap);
62
- function buildKeyMap(fields, map) {
63
- if (!map) {
64
- map = new Map();
65
- }
66
- for (const config of fields) {
67
- if ('in' in config) {
68
- if (config.key) {
69
- map.set(config.key, {
70
- in: config.in,
71
- map: config.map
72
- });
73
- }
74
- } else if ('key' in config) {
75
- map.set(config.key, {
76
- map: config.map
77
- });
78
- } else if (config.args) {
79
- buildKeyMap(config.args, map);
80
- }
81
- }
82
- return map;
83
- }
84
- function stripEmptySlots(params) {
85
- for (const [slot, value] of Object.entries(params)) {
86
- if (slot === 'body') continue;
87
- if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) {
88
- delete params[slot];
89
- }
90
- }
91
- }
92
- function buildClientParams(args, fields) {
93
- const params = {
94
- headers: Object.create(null),
95
- path: Object.create(null),
96
- query: Object.create(null)
97
- };
98
- const map = buildKeyMap(fields);
99
- function writeSlot(slot, key, value) {
100
- let record = params[slot];
101
- if (record === undefined) {
102
- record = Object.create(null);
103
- params[slot] = record;
104
- }
105
- record[key] = value;
106
- }
107
- let config;
108
- for (const [index, arg] of args.entries()) {
109
- if (fields[index]) {
110
- config = fields[index];
111
- }
112
- if (!config) {
113
- continue;
114
- }
115
- if ('in' in config) {
116
- if (config.key) {
117
- const field = map.get(config.key);
118
- const name = field.map || config.key;
119
- if (field.in) {
120
- writeSlot(field.in, name, arg);
121
- }
122
- } else {
123
- params.body = arg;
124
- }
125
- } else {
126
- for (const [key, value] of Object.entries(arg ?? {})) {
127
- const field = map.get(key);
128
- if (field) {
129
- if (field.in) {
130
- const name = field.map || key;
131
- writeSlot(field.in, name, value);
132
- } else {
133
- params[field.map] = value;
134
- }
135
- } else {
136
- const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
137
- if (extra) {
138
- const [prefix, slot] = extra;
139
- writeSlot(slot, key.slice(prefix.length), value);
140
- } else if ('allowExtra' in config && config.allowExtra) {
141
- for (const [slot, allowed] of Object.entries(config.allowExtra)) {
142
- if (allowed) {
143
- writeSlot(slot, key, value);
144
- break;
145
- }
146
- }
147
- }
148
- }
149
- }
150
- }
151
- }
152
- stripEmptySlots(params);
153
- return params;
154
- }
155
-
156
- // This file is auto-generated by @hey-api/openapi-ts
157
- /**
158
- * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
159
- */
160
- const queryKeyJsonReplacer = (_key, value) => {
161
- if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
162
- return undefined;
163
- }
164
- if (typeof value === 'bigint') {
165
- return value.toString();
166
- }
167
- if (value instanceof Date) {
168
- return value.toISOString();
169
- }
170
- return value;
171
- };
172
- /**
173
- * Safely stringifies a value and parses it back into a JsonValue.
174
- */
175
- const stringifyToJsonValue = input => {
176
- try {
177
- const json = JSON.stringify(input, queryKeyJsonReplacer);
178
- if (json === undefined) {
179
- return undefined;
180
- }
181
- return JSON.parse(json);
182
- } catch {
183
- return undefined;
184
- }
185
- };
186
- /**
187
- * Detects plain objects (including objects with a null prototype).
188
- */
189
- const isPlainObject = value => {
190
- if (value === null || typeof value !== 'object') {
191
- return false;
192
- }
193
- const prototype = Object.getPrototypeOf(value);
194
- return prototype === Object.prototype || prototype === null;
195
- };
196
- /**
197
- * Turns URLSearchParams into a sorted JSON object for deterministic keys.
198
- */
199
- const serializeSearchParams = params => {
200
- const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b));
201
- const result = {};
202
- for (const [key, value] of entries) {
203
- const existing = result[key];
204
- if (existing === undefined) {
205
- result[key] = value;
206
- continue;
207
- }
208
- if (Array.isArray(existing)) {
209
- existing.push(value);
210
- } else {
211
- result[key] = [existing, value];
212
- }
213
- }
214
- return result;
215
- };
216
- /**
217
- * Normalizes any accepted value into a JSON-friendly shape for query keys.
218
- */
219
- const serializeQueryKeyValue = value => {
220
- if (value === null) {
221
- return null;
222
- }
223
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
224
- return value;
225
- }
226
- if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
227
- return undefined;
228
- }
229
- if (typeof value === 'bigint') {
230
- return value.toString();
231
- }
232
- if (value instanceof Date) {
233
- return value.toISOString();
234
- }
235
- if (Array.isArray(value)) {
236
- return stringifyToJsonValue(value);
237
- }
238
- if (typeof URLSearchParams !== 'undefined' && value instanceof URLSearchParams) {
239
- return serializeSearchParams(value);
240
- }
241
- if (isPlainObject(value)) {
242
- return stringifyToJsonValue(value);
243
- }
244
- return undefined;
245
- };
246
5
 
247
6
  // This file is auto-generated by @hey-api/openapi-ts
248
7
  function createSseClient({
@@ -3017,4 +2776,4 @@ const putOrganizationsByOrganizationIdZonesByIdChangeId = options => (options.cl
3017
2776
  }
3018
2777
  });
3019
2778
 
3020
- export { buildClientParams, createClient, createConfig, deleteGroupsByGroupIdUsersByUserId, deleteGroupsById, deleteInvitesById, deleteMemberships, deleteMembershipsById, deleteMembershipsByIdBranch, deleteMembershipsByIdZone, deleteOrganizationsById, deleteOrganizationsByOrganizationIdBranchesById, deleteOrganizationsByOrganizationIdZonesById, deletePermissionsById, deleteProjectsByProjectId, deleteRolesById, deleteRolesByIdPermissions, deleteSecretKeysById, deleteUsers, deleteUsersById, deleteUsersByIdMembershipsByMembershipId, formDataBodySerializer, get, getGroups, getGroupsById, getGroupsByIdPermissions, getGroupsByIdUsers, getGroupsMy, getInvites, getInvitesById, getMemberships, getMembershipsBranchById, getMembershipsById, getMembershipsByIdPermissions, getMembershipsMy, getMembershipsZoneByZoneId, getOrganizations, getOrganizationsById, getOrganizationsByOrganizationIdBranches, getOrganizationsByOrganizationIdBranchesById, getOrganizationsByOrganizationIdBranchesMy, getOrganizationsByOrganizationIdCreator, getOrganizationsByOrganizationIdMembers, getOrganizationsByOrganizationIdZones, getOrganizationsByOrganizationIdZonesById, getOrganizationsByOrganizationIdZonesMy, getOrganizationsByOwnerByUserId, getOrganizationsByUserByUserId, getPermissions, getPermissionsById, getProjects, getProjectsByProjectId, getRoles, getRolesById, getRolesByIdPermissions, getRolesByIdUsers, getSecretKeys, getSecretKeysById, getUserPasswords, getUsers, getUsersById, getUsersByIdIdentifiers, getUsersCustomActive, getUsersCustomBanned, getUsersCustomInactive, getUsersCustomUnverified, getUsersMe, getV1ListErrorCodes, jsonBodySerializer, mergeHeaders, postAdminLogin, postAdminNewToken, postGroups, postGroupsByIdPermissions, postInvites, postMemberships, postMembershipsByIdBranch, postMembershipsByIdZone, postOrganizations, postOrganizationsByOrganizationIdBranches, postOrganizationsByOrganizationIdZones, postPermissions, postProjects, postRoles, postRolesByIdPermissions, postSecretKeys, postUserPasswordsUpsert, postUsers, postUsersByIdIdentifierAdd, postUsersByIdIdentifierDelete, postUsersByIdNewVerificationToken, postUsersByIdPasswordChange, postUsersLogin, postUsersLoginSwitch, postUsersLogout, postUsersPasswordForgot, postUsersPasswordResetByToken, postUsersRegister, postUsersToken, postUsersVerifyByToken, putGroupsById, putGroupsByIdChangeId, putInvitesById, putInvitesByIdChangeId, putMembershipsByIdChangeId, putOrganizationsById, putOrganizationsByIdChangeId, putOrganizationsByOrganizationIdBranchesById, putOrganizationsByOrganizationIdBranchesByIdChangeId, putOrganizationsByOrganizationIdZonesById, putOrganizationsByOrganizationIdZonesByIdChangeId, putPermissionsById, putProjectsByProjectId, putProjectsByProjectIdChangeId, putRolesById, putRolesByIdChangeId, putUsersById, putUsersByIdChangeId, serializeQueryKeyValue, urlSearchParamsBodySerializer };
2779
+ export { client, deleteGroupsByGroupIdUsersByUserId, deleteGroupsById, deleteInvitesById, deleteMemberships, deleteMembershipsById, deleteMembershipsByIdBranch, deleteMembershipsByIdZone, deleteOrganizationsById, deleteOrganizationsByOrganizationIdBranchesById, deleteOrganizationsByOrganizationIdZonesById, deletePermissionsById, deleteProjectsByProjectId, deleteRolesById, deleteRolesByIdPermissions, deleteSecretKeysById, deleteUsers, deleteUsersById, deleteUsersByIdMembershipsByMembershipId, get, getGroups, getGroupsById, getGroupsByIdPermissions, getGroupsByIdUsers, getGroupsMy, getInvites, getInvitesById, getMemberships, getMembershipsBranchById, getMembershipsById, getMembershipsByIdPermissions, getMembershipsMy, getMembershipsZoneByZoneId, getOrganizations, getOrganizationsById, getOrganizationsByOrganizationIdBranches, getOrganizationsByOrganizationIdBranchesById, getOrganizationsByOrganizationIdBranchesMy, getOrganizationsByOrganizationIdCreator, getOrganizationsByOrganizationIdMembers, getOrganizationsByOrganizationIdZones, getOrganizationsByOrganizationIdZonesById, getOrganizationsByOrganizationIdZonesMy, getOrganizationsByOwnerByUserId, getOrganizationsByUserByUserId, getPermissions, getPermissionsById, getProjects, getProjectsByProjectId, getRoles, getRolesById, getRolesByIdPermissions, getRolesByIdUsers, getSecretKeys, getSecretKeysById, getUserPasswords, getUsers, getUsersById, getUsersByIdIdentifiers, getUsersCustomActive, getUsersCustomBanned, getUsersCustomInactive, getUsersCustomUnverified, getUsersMe, getV1ListErrorCodes, postAdminLogin, postAdminNewToken, postGroups, postGroupsByIdPermissions, postInvites, postMemberships, postMembershipsByIdBranch, postMembershipsByIdZone, postOrganizations, postOrganizationsByOrganizationIdBranches, postOrganizationsByOrganizationIdZones, postPermissions, postProjects, postRoles, postRolesByIdPermissions, postSecretKeys, postUserPasswordsUpsert, postUsers, postUsersByIdIdentifierAdd, postUsersByIdIdentifierDelete, postUsersByIdNewVerificationToken, postUsersByIdPasswordChange, postUsersLogin, postUsersLoginSwitch, postUsersLogout, postUsersPasswordForgot, postUsersPasswordResetByToken, postUsersRegister, postUsersToken, postUsersVerifyByToken, putGroupsById, putGroupsByIdChangeId, putInvitesById, putInvitesByIdChangeId, putMembershipsByIdChangeId, putOrganizationsById, putOrganizationsByIdChangeId, putOrganizationsByOrganizationIdBranchesById, putOrganizationsByOrganizationIdBranchesByIdChangeId, putOrganizationsByOrganizationIdZonesById, putOrganizationsByOrganizationIdZonesByIdChangeId, putPermissionsById, putProjectsByProjectId, putProjectsByProjectIdChangeId, putRolesById, putRolesByIdChangeId, putUsersById, putUsersByIdChangeId };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@touhidrahman/restauth-sdk",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,2 @@
1
+ import type { Client, Config } from './types.gen';
2
+ export declare const createClient: (config?: Config) => Client;
@@ -0,0 +1,10 @@
1
+ export type { Auth } from '../core/auth.gen';
2
+ export type { QuerySerializerOptions } from '../core/bodySerializer.gen';
3
+ export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, } from '../core/bodySerializer.gen';
4
+ export { buildClientParams } from '../core/params.gen';
5
+ export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen';
6
+ export type { ServerSentEventsResult } from '../core/serverSentEvents.gen';
7
+ export type { ClientMeta } from '../core/types.gen';
8
+ export { createClient } from './client.gen';
9
+ export type { Client, ClientOptions, Config, CreateClientConfig, Options, RequestOptions, RequestResult, ResolvedRequestOptions, ResponseStyle, TDataShape, } from './types.gen';
10
+ export { createConfig, mergeHeaders } from './utils.gen';
@@ -0,0 +1,120 @@
1
+ import type { Auth } from '../core/auth.gen';
2
+ import type { ServerSentEventsOptions, ServerSentEventsResult } from '../core/serverSentEvents.gen';
3
+ import type { Client as CoreClient, Config as CoreConfig } from '../core/types.gen';
4
+ import type { Middleware } from './utils.gen';
5
+ export type ResponseStyle = 'data' | 'fields';
6
+ export interface Config<T extends ClientOptions = ClientOptions> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, CoreConfig {
7
+ /**
8
+ * Base URL for all requests made by this client.
9
+ */
10
+ baseUrl?: T['baseUrl'];
11
+ /**
12
+ * Fetch API implementation. You can use this option to provide a custom
13
+ * fetch instance.
14
+ *
15
+ * @default globalThis.fetch
16
+ */
17
+ fetch?: typeof fetch;
18
+ /**
19
+ * Please don't use the Fetch client for Next.js applications. The `next`
20
+ * options won't have any effect.
21
+ *
22
+ * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
23
+ */
24
+ next?: never;
25
+ /**
26
+ * Return the response data parsed in a specified format. By default, `auto`
27
+ * will infer the appropriate method from the `Content-Type` response header.
28
+ * You can override this behavior with any of the {@link Body} methods.
29
+ * Select `stream` if you don't want to parse response data at all.
30
+ *
31
+ * @default 'auto'
32
+ */
33
+ parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
34
+ /**
35
+ * Should we return only data or multiple fields (data, error, response, etc.)?
36
+ *
37
+ * @default 'fields'
38
+ */
39
+ responseStyle?: ResponseStyle;
40
+ /**
41
+ * Throw an error instead of returning it in the response?
42
+ *
43
+ * @default false
44
+ */
45
+ throwOnError?: T['throwOnError'];
46
+ }
47
+ export interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
48
+ responseStyle: TResponseStyle;
49
+ throwOnError: ThrowOnError;
50
+ }>, Pick<ServerSentEventsOptions<TData>, 'onRequest' | 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
51
+ /**
52
+ * Any body that you want to add to your request.
53
+ *
54
+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
55
+ */
56
+ body?: unknown;
57
+ path?: Record<string, unknown>;
58
+ query?: Record<string, unknown>;
59
+ /**
60
+ * Security mechanism(s) to use for the request.
61
+ */
62
+ security?: ReadonlyArray<Auth>;
63
+ url: Url;
64
+ }
65
+ export interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
66
+ headers: Headers;
67
+ serializedBody?: string;
68
+ }
69
+ export type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = 'fields'> = ThrowOnError extends true ? Promise<TResponseStyle extends 'data' ? TData extends Record<string, unknown> ? TData[keyof TData] : TData : {
70
+ data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
71
+ request: Request;
72
+ response: Response;
73
+ }> : Promise<TResponseStyle extends 'data' ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined : ({
74
+ data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
75
+ error: undefined;
76
+ } | {
77
+ data: undefined;
78
+ error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
79
+ }) & {
80
+ /** request may be undefined, because error may be from building the request object itself */
81
+ request?: Request;
82
+ /** response may be undefined, because error may be from building the request object itself or from a network error */
83
+ response?: Response;
84
+ }>;
85
+ export interface ClientOptions {
86
+ baseUrl?: string;
87
+ responseStyle?: ResponseStyle;
88
+ throwOnError?: boolean;
89
+ }
90
+ type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
91
+ type SseFn = <TData = unknown, _TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData>>;
92
+ type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
93
+ type BuildUrlFn = <TData extends {
94
+ body?: unknown;
95
+ path?: Record<string, unknown>;
96
+ query?: Record<string, unknown>;
97
+ url: string;
98
+ }>(options: TData & Options<TData>) => string;
99
+ export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
100
+ interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
101
+ };
102
+ /**
103
+ * The `createClientConfig()` function will be called on client initialization
104
+ * and the returned object will become the client's initial configuration.
105
+ *
106
+ * You may want to initialize your client this way instead of calling
107
+ * `setConfig()`. This is useful for example if you're using Next.js
108
+ * to ensure your client always has the correct values.
109
+ */
110
+ export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
111
+ export interface TDataShape {
112
+ body?: unknown;
113
+ headers?: unknown;
114
+ path?: unknown;
115
+ query?: unknown;
116
+ url: string;
117
+ }
118
+ type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
119
+ export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = 'fields'> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
120
+ export {};