mp-request-handler-sdk 0.3.3 → 0.4.1
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/core/index.js +2 -1
- package/dist/core/requestHandler.d.ts +49 -27
- package/dist/core/requestHandler.d.ts.map +1 -1
- package/dist/core/requestHandler.js +192 -1
- package/dist/hooks/index.js +2 -1
- package/dist/hooks/useRequestHandler.js +26 -1
- package/dist/index.js +5 -1
- package/dist/types/index.js +1 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/parser.js +6 -1
- package/package.json +4 -9
- package/scripts/postinstall.js +0 -36
package/dist/core/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
// Core SDK functionality
|
|
2
|
+
export { IAMRequest } from './requestHandler';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
type TLoginChannels = 'userqr' | 'password' | 'phoneotp' | 'numchallenge';
|
|
2
|
-
type TRolePayloadObj = {
|
|
1
|
+
export type TLoginChannels = 'userqr' | 'password' | 'phoneotp' | 'numchallenge';
|
|
2
|
+
export type TRolePayloadObj = {
|
|
3
3
|
role: string;
|
|
4
4
|
role_namespace: string;
|
|
5
5
|
role_uuid: string;
|
|
@@ -16,7 +16,7 @@ export interface IIAMResponse {
|
|
|
16
16
|
error: null | string;
|
|
17
17
|
requestID: string;
|
|
18
18
|
}
|
|
19
|
-
interface ICreateProjectUserPayload {
|
|
19
|
+
export interface ICreateProjectUserPayload {
|
|
20
20
|
username: string;
|
|
21
21
|
display_name?: string;
|
|
22
22
|
channels: TLoginChannels[];
|
|
@@ -26,22 +26,22 @@ interface ICreateProjectUserPayload {
|
|
|
26
26
|
};
|
|
27
27
|
role?: string;
|
|
28
28
|
}
|
|
29
|
-
interface IUpdateProjectUserPayload {
|
|
29
|
+
export interface IUpdateProjectUserPayload {
|
|
30
30
|
user_code: string;
|
|
31
31
|
username?: string;
|
|
32
32
|
display_name?: string;
|
|
33
33
|
is_active?: boolean;
|
|
34
34
|
}
|
|
35
|
-
type TProjectUserListPayload = {
|
|
35
|
+
export type TProjectUserListPayload = {
|
|
36
36
|
page: number;
|
|
37
37
|
per_page: number;
|
|
38
38
|
search: string;
|
|
39
39
|
is_active: boolean | undefined;
|
|
40
40
|
};
|
|
41
|
-
type TGetProjectUserDetailsPayload = {
|
|
41
|
+
export type TGetProjectUserDetailsPayload = {
|
|
42
42
|
user_code: string;
|
|
43
43
|
};
|
|
44
|
-
interface ICreateChannelPayload {
|
|
44
|
+
export interface ICreateChannelPayload {
|
|
45
45
|
user_code: string;
|
|
46
46
|
channels: TLoginChannels[];
|
|
47
47
|
details: {
|
|
@@ -49,7 +49,7 @@ interface ICreateChannelPayload {
|
|
|
49
49
|
password?: string;
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
-
interface IRemoveChannelPayload {
|
|
52
|
+
export interface IRemoveChannelPayload {
|
|
53
53
|
user_code: string;
|
|
54
54
|
channels: string[];
|
|
55
55
|
details: {
|
|
@@ -57,13 +57,13 @@ interface IRemoveChannelPayload {
|
|
|
57
57
|
phone_number?: string;
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
interface IRegenerateCredPayload {
|
|
60
|
+
export interface IRegenerateCredPayload {
|
|
61
61
|
user_code: string;
|
|
62
62
|
channel_code: string;
|
|
63
63
|
whitelisted_ips?: string[];
|
|
64
64
|
expires_at?: string;
|
|
65
65
|
}
|
|
66
|
-
interface IManageProjectChannelsPayload {
|
|
66
|
+
export interface IManageProjectChannelsPayload {
|
|
67
67
|
userCode: string;
|
|
68
68
|
selectedChannels: TLoginChannels[];
|
|
69
69
|
originalChannels: TLoginChannels[];
|
|
@@ -73,7 +73,7 @@ interface IManageProjectChannelsPayload {
|
|
|
73
73
|
originalPhone?: string;
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
interface ICreateAccessUserPayload {
|
|
76
|
+
export interface ICreateAccessUserPayload {
|
|
77
77
|
resourceNamespace: string;
|
|
78
78
|
resource: string;
|
|
79
79
|
resourceType: string;
|
|
@@ -88,11 +88,11 @@ interface ICreateAccessUserPayload {
|
|
|
88
88
|
value: string | string[];
|
|
89
89
|
}[];
|
|
90
90
|
}
|
|
91
|
-
interface IGetRelationPayload {
|
|
91
|
+
export interface IGetRelationPayload {
|
|
92
92
|
principal: string;
|
|
93
93
|
resource: string;
|
|
94
94
|
}
|
|
95
|
-
interface IUpdateRelationPayload {
|
|
95
|
+
export interface IUpdateRelationPayload {
|
|
96
96
|
resourceNamespace: string;
|
|
97
97
|
resource: string;
|
|
98
98
|
resourceType: string;
|
|
@@ -102,12 +102,12 @@ interface IUpdateRelationPayload {
|
|
|
102
102
|
principalName: string;
|
|
103
103
|
principal: string;
|
|
104
104
|
}
|
|
105
|
-
type TUserAccessListPayload = {
|
|
105
|
+
export type TUserAccessListPayload = {
|
|
106
106
|
search: string;
|
|
107
107
|
per_page: number;
|
|
108
108
|
page: number;
|
|
109
109
|
};
|
|
110
|
-
type TServiceAccountCreatePayload = {
|
|
110
|
+
export type TServiceAccountCreatePayload = {
|
|
111
111
|
username: string;
|
|
112
112
|
display_name?: string;
|
|
113
113
|
channels: ['apijwt'];
|
|
@@ -117,52 +117,63 @@ type TServiceAccountCreatePayload = {
|
|
|
117
117
|
expires_at?: string;
|
|
118
118
|
};
|
|
119
119
|
};
|
|
120
|
-
type TGetApiUserPayload = {
|
|
120
|
+
export type TGetApiUserPayload = {
|
|
121
121
|
user_code: string;
|
|
122
122
|
};
|
|
123
|
-
type TUpdateApiUserPayload = {
|
|
123
|
+
export type TUpdateApiUserPayload = {
|
|
124
124
|
user_code: string;
|
|
125
125
|
display_name: string;
|
|
126
126
|
is_active: boolean;
|
|
127
127
|
};
|
|
128
|
-
type TGetQuotaPayload = Record<string, unknown>;
|
|
129
|
-
type TGetGroupPayload = {
|
|
128
|
+
export type TGetQuotaPayload = Record<string, unknown>;
|
|
129
|
+
export type TGetGroupPayload = {
|
|
130
130
|
search: string;
|
|
131
131
|
page: number;
|
|
132
132
|
limit: number;
|
|
133
133
|
};
|
|
134
|
-
type TGroupCreatePayload = {
|
|
134
|
+
export type TGroupCreatePayload = {
|
|
135
135
|
groupName: string;
|
|
136
136
|
};
|
|
137
|
-
type TGroupUpdatePayload = {
|
|
137
|
+
export type TGroupUpdatePayload = {
|
|
138
138
|
groupCode: string;
|
|
139
139
|
groupName?: string;
|
|
140
140
|
isActive: boolean;
|
|
141
141
|
};
|
|
142
|
-
type TGroupDetailsPayload = {
|
|
142
|
+
export type TGroupDetailsPayload = {
|
|
143
143
|
groupCode: string;
|
|
144
144
|
};
|
|
145
|
-
type TAddGroupMemberPayload = {
|
|
145
|
+
export type TAddGroupMemberPayload = {
|
|
146
146
|
groupCode: string;
|
|
147
147
|
member_name: string;
|
|
148
148
|
};
|
|
149
|
-
type TRemoveGroupMemberPayload = {
|
|
149
|
+
export type TRemoveGroupMemberPayload = {
|
|
150
150
|
groupCode: string;
|
|
151
151
|
members: string[];
|
|
152
152
|
};
|
|
153
|
-
type TGetRolesPayload = {
|
|
153
|
+
export type TGetRolesPayload = {
|
|
154
154
|
namespace_code?: string;
|
|
155
155
|
search?: string;
|
|
156
156
|
page?: number;
|
|
157
157
|
per_page?: number;
|
|
158
158
|
};
|
|
159
|
-
type TGetRolePermissionsPayload = {
|
|
159
|
+
export type TGetRolePermissionsPayload = {
|
|
160
160
|
role_uuid: string;
|
|
161
161
|
page: number;
|
|
162
162
|
per_page: number;
|
|
163
163
|
search: string;
|
|
164
164
|
};
|
|
165
|
-
interface
|
|
165
|
+
export interface IGetLabelValuesPayload {
|
|
166
|
+
keys: string[];
|
|
167
|
+
}
|
|
168
|
+
export interface IGetLabelValuesResponse {
|
|
169
|
+
success: boolean;
|
|
170
|
+
error: string | null;
|
|
171
|
+
data: {
|
|
172
|
+
key: string;
|
|
173
|
+
value: boolean | null;
|
|
174
|
+
}[];
|
|
175
|
+
}
|
|
176
|
+
export interface IAMActionMap {
|
|
166
177
|
createProjectUser: ICreateProjectUserPayload;
|
|
167
178
|
updateProjectUser: IUpdateProjectUserPayload;
|
|
168
179
|
getProjectUserList: TProjectUserListPayload;
|
|
@@ -189,6 +200,7 @@ interface IAMActionMap {
|
|
|
189
200
|
createAccessUser: ICreateAccessUserPayload;
|
|
190
201
|
getRelation: IGetRelationPayload;
|
|
191
202
|
updateRelation: IUpdateRelationPayload;
|
|
203
|
+
getLabelValues: IGetLabelValuesPayload;
|
|
192
204
|
}
|
|
193
205
|
declare global {
|
|
194
206
|
interface Window {
|
|
@@ -241,6 +253,9 @@ declare global {
|
|
|
241
253
|
* - **Quota Actions:**
|
|
242
254
|
* - `getQuota` - Get project quota information
|
|
243
255
|
*
|
|
256
|
+
* - **Label Values Actions:**
|
|
257
|
+
* - `getLabelValues` - Get label values for specified keys
|
|
258
|
+
*
|
|
244
259
|
* @param payload - The payload specific to the action type. TypeScript will autocomplete the correct structure based on your selected action.
|
|
245
260
|
*
|
|
246
261
|
* @param project - Optional project code (e.g., 'PRJ1455'). When provided, will be added to request headers.
|
|
@@ -296,6 +311,13 @@ declare global {
|
|
|
296
311
|
* }, 'PRJ1455');
|
|
297
312
|
* ```
|
|
298
313
|
*
|
|
314
|
+
* @example Getting label values
|
|
315
|
+
* ```typescript
|
|
316
|
+
* const result = await IAMRequest('getLabelValues', {
|
|
317
|
+
* keys: ['feature_flag_1', 'feature_flag_2', 'setting_enabled']
|
|
318
|
+
* }, 'PRJ1455');
|
|
319
|
+
* ```
|
|
320
|
+
*
|
|
299
321
|
* @see Partner Platform documentation: https://docs.noon.partners
|
|
300
322
|
* @see For detailed payload structures, TypeScript autocomplete will guide you based on your selected action
|
|
301
323
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestHandler.d.ts","sourceRoot":"","sources":["../../src/core/requestHandler.ts"],"names":[],"mappings":"AAOA,
|
|
1
|
+
{"version":3,"file":"requestHandler.d.ts","sourceRoot":"","sources":["../../src/core/requestHandler.ts"],"names":[],"mappings":"A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,KAAK,IAAI,CAAC;KAChG;CACJ;AAwFD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiHG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,MAAM,YAAY,EACnD,YAAY,CAAC,EACb,SAAS,YAAY,CAAC,CAAC,CAAC,EACxB,UAAU,MAAM,KACjB,OAAO,CAAC,OAAO,CAA4D,CAAC;AAE/E,eAAe,UAAU,CAAC"}
|
|
@@ -1 +1,192 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable camelcase */
|
|
2
|
+
// Type definitions for IAM actions and payloads
|
|
3
|
+
// @noon/iam-request-handler package
|
|
4
|
+
class IAMRequestHandler {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.pendingRequests = new Map();
|
|
7
|
+
this.isReady = false;
|
|
8
|
+
this.init();
|
|
9
|
+
}
|
|
10
|
+
init() {
|
|
11
|
+
// Listen for responses
|
|
12
|
+
window.addEventListener('IAMResponse', (event) => {
|
|
13
|
+
const customEvent = event;
|
|
14
|
+
const { data, error, requestID, success } = customEvent.detail;
|
|
15
|
+
const pending = this.pendingRequests.get(requestID);
|
|
16
|
+
if (pending) {
|
|
17
|
+
this.pendingRequests.delete(requestID);
|
|
18
|
+
if (success) {
|
|
19
|
+
pending.resolve(data);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
pending.reject(new Error(error || 'IAM request failed'));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
// Check if window.IAMRequest is available
|
|
27
|
+
this.checkReady();
|
|
28
|
+
}
|
|
29
|
+
checkReady() {
|
|
30
|
+
if (typeof window.IAMRequest === 'function') {
|
|
31
|
+
this.isReady = true;
|
|
32
|
+
this.flushQueue();
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// Poll until IAMRequest is available
|
|
36
|
+
setTimeout(() => this.checkReady(), 100);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
flushQueue() {
|
|
40
|
+
// All requests in pendingRequests are already sent via request()
|
|
41
|
+
// This just marks as ready for future requests
|
|
42
|
+
}
|
|
43
|
+
request(actiontype, payload, project) {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
// Generate unique request ID
|
|
46
|
+
const requestID = `iam_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
47
|
+
// Store the promise handlers
|
|
48
|
+
this.pendingRequests.set(requestID, { resolve, reject });
|
|
49
|
+
// Set timeout
|
|
50
|
+
setTimeout(() => {
|
|
51
|
+
if (this.pendingRequests.has(requestID)) {
|
|
52
|
+
this.pendingRequests.delete(requestID);
|
|
53
|
+
reject(new Error('IAM request timeout'));
|
|
54
|
+
}
|
|
55
|
+
}, 10000);
|
|
56
|
+
// Send request immediately if ready, otherwise wait
|
|
57
|
+
if (this.isReady && window.IAMRequest) {
|
|
58
|
+
window.IAMRequest(actiontype, payload, requestID, project);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// Queue and send when ready
|
|
62
|
+
const checkAndSend = () => {
|
|
63
|
+
if (this.isReady && window.IAMRequest) {
|
|
64
|
+
window.IAMRequest(actiontype, payload, requestID, project);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
setTimeout(checkAndSend, 100);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
checkAndSend();
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Export for client apps
|
|
76
|
+
const iamRequestHandler = new IAMRequestHandler();
|
|
77
|
+
/**
|
|
78
|
+
* Send an IAM request to manage users, roles, and access control
|
|
79
|
+
*
|
|
80
|
+
* @param actiontype - The type of IAM action to perform. Available actions:
|
|
81
|
+
* - **Project User Actions:**
|
|
82
|
+
* - `createProjectUser` - Create a new project user with authentication channels
|
|
83
|
+
* - `updateProjectUser` - Update an existing project user's information
|
|
84
|
+
* - `getProjectUserList` - Get a list of project users
|
|
85
|
+
* - `getProjectUserDetails` - Get details for a specific project user
|
|
86
|
+
*
|
|
87
|
+
* - **Channel Management Actions:**
|
|
88
|
+
* - `createChannel` - Create a new authentication channel for a user
|
|
89
|
+
* - `removeChannel` - Remove an authentication channel from a user
|
|
90
|
+
* - `regenerateCred` - Regenerate credentials for a user's authentication channel
|
|
91
|
+
* - `manageProjectChannels` - Manage multiple authentication channels at once
|
|
92
|
+
*
|
|
93
|
+
* - **Access Control Actions:**
|
|
94
|
+
* - `createAccessUser` - Grant access to a user by assigning roles to a resource
|
|
95
|
+
* - `getRelation` - Get relation details between a principal (user) and a resource
|
|
96
|
+
* - `updateRelation` - Update relation between principal and resource
|
|
97
|
+
*
|
|
98
|
+
* - **API User (Service Account) Actions:**
|
|
99
|
+
* - `createApiUser` - Create a new service account
|
|
100
|
+
* - `getApiUser` - Get details for a specific service account
|
|
101
|
+
* - `updateApiUser` - Update a service account
|
|
102
|
+
* - `getApiUserList` - Get a list of service accounts
|
|
103
|
+
*
|
|
104
|
+
* - **Group Management Actions:**
|
|
105
|
+
* - `getGroupList` - Get a list of groups
|
|
106
|
+
* - `groupCreate` - Create a new group
|
|
107
|
+
* - `updateGroup` - Update group details
|
|
108
|
+
* - `getGroupDetails` - Get details for a specific group
|
|
109
|
+
* - `addGroupMember` - Add a member to a group
|
|
110
|
+
* - `removeGroupMember` - Remove member(s) from a group
|
|
111
|
+
*
|
|
112
|
+
* - **Role & Permission Actions:**
|
|
113
|
+
* - `getRoles` - Get available roles
|
|
114
|
+
* - `getRolePermissions` - Get permissions for a specific role
|
|
115
|
+
* - `getRoleHierarchy` - Get the role hierarchy
|
|
116
|
+
*
|
|
117
|
+
* - **User Access Actions:**
|
|
118
|
+
* - `getUserAccessList` - Get list of user access entries
|
|
119
|
+
*
|
|
120
|
+
* - **Quota Actions:**
|
|
121
|
+
* - `getQuota` - Get project quota information
|
|
122
|
+
*
|
|
123
|
+
* - **Label Values Actions:**
|
|
124
|
+
* - `getLabelValues` - Get label values for specified keys
|
|
125
|
+
*
|
|
126
|
+
* @param payload - The payload specific to the action type. TypeScript will autocomplete the correct structure based on your selected action.
|
|
127
|
+
*
|
|
128
|
+
* @param project - Optional project code (e.g., 'PRJ1455'). When provided, will be added to request headers.
|
|
129
|
+
*
|
|
130
|
+
* @returns Promise that resolves with the API response data
|
|
131
|
+
*
|
|
132
|
+
* @example Creating a project user
|
|
133
|
+
* ```typescript
|
|
134
|
+
* const result = await IAMRequest('createProjectUser', {
|
|
135
|
+
* username: 'john.doe@noon.com',
|
|
136
|
+
* display_name: 'John Doe',
|
|
137
|
+
* channels: ['password'],
|
|
138
|
+
* channel_details: { password: 'secure123' }
|
|
139
|
+
* }, 'PRJ1455');
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @example Granting access to a user
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const result = await IAMRequest('createAccessUser', {
|
|
145
|
+
* resourceNamespace: 'platform',
|
|
146
|
+
* resource: 'PRJ1455',
|
|
147
|
+
* resourceType: 'project',
|
|
148
|
+
* rolesAdd: [{
|
|
149
|
+
* role: 'platform.project.viewer',
|
|
150
|
+
* role_namespace: 'platform',
|
|
151
|
+
* role_uuid: 'fb7475ad-6e66-419f-930c-29e68e0cb825'
|
|
152
|
+
* }],
|
|
153
|
+
* principalName: 'user@noon.com',
|
|
154
|
+
* principal: 'USR12345'
|
|
155
|
+
* }, 'PRJ1455');
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @example Managing user channels
|
|
159
|
+
* ```typescript
|
|
160
|
+
* const result = await IAMRequest('manageProjectChannels', {
|
|
161
|
+
* userCode: 'USR12345',
|
|
162
|
+
* selectedChannels: ['password', 'phoneotp'],
|
|
163
|
+
* originalChannels: ['password'],
|
|
164
|
+
* channelDetails: {
|
|
165
|
+
* phoneNumber: '+971501234567',
|
|
166
|
+
* password: 'newpass123'
|
|
167
|
+
* }
|
|
168
|
+
* }, 'PRJ1455');
|
|
169
|
+
* ```
|
|
170
|
+
*
|
|
171
|
+
* @example Getting role information
|
|
172
|
+
* ```typescript
|
|
173
|
+
* const result = await IAMRequest('getRoles', {
|
|
174
|
+
* namespace_code: 'platform',
|
|
175
|
+
* search: 'viewer',
|
|
176
|
+
* page: 1,
|
|
177
|
+
* per_page: 20
|
|
178
|
+
* }, 'PRJ1455');
|
|
179
|
+
* ```
|
|
180
|
+
*
|
|
181
|
+
* @example Getting label values
|
|
182
|
+
* ```typescript
|
|
183
|
+
* const result = await IAMRequest('getLabelValues', {
|
|
184
|
+
* keys: ['feature_flag_1', 'feature_flag_2', 'setting_enabled']
|
|
185
|
+
* }, 'PRJ1455');
|
|
186
|
+
* ```
|
|
187
|
+
*
|
|
188
|
+
* @see Partner Platform documentation: https://docs.noon.partners
|
|
189
|
+
* @see For detailed payload structures, TypeScript autocomplete will guide you based on your selected action
|
|
190
|
+
*/
|
|
191
|
+
export const IAMRequest = (actiontype, payload, project) => iamRequestHandler.request(actiontype, payload, project);
|
|
192
|
+
export default IAMRequest;
|
package/dist/hooks/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
// React hooks for SDK
|
|
2
|
+
export { useRequestHandler } from './useRequestHandler';
|
|
@@ -1 +1,26 @@
|
|
|
1
|
-
import{useCallback,
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { IAMRequest } from '../core/requestHandler';
|
|
3
|
+
/**
|
|
4
|
+
* React hook for using IAMRequest
|
|
5
|
+
*/
|
|
6
|
+
export function useRequestHandler() {
|
|
7
|
+
const [loading, setLoading] = useState(false);
|
|
8
|
+
const [error, setError] = useState(null);
|
|
9
|
+
const request = useCallback(async (action, payload) => {
|
|
10
|
+
setLoading(true);
|
|
11
|
+
setError(null);
|
|
12
|
+
try {
|
|
13
|
+
const response = await IAMRequest(action, payload);
|
|
14
|
+
return response;
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
18
|
+
setError(error);
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
finally {
|
|
22
|
+
setLoading(false);
|
|
23
|
+
}
|
|
24
|
+
}, []);
|
|
25
|
+
return { request, loading, error };
|
|
26
|
+
}
|
package/dist/index.js
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export {};
|
package/dist/utils/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
// Utility functions
|
|
2
|
+
export { parseResponse } from './parser';
|
package/dist/utils/parser.js
CHANGED
package/package.json
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mp-request-handler-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Frontend SDK for request handling",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
|
-
"dist"
|
|
9
|
-
"scripts"
|
|
8
|
+
"dist"
|
|
10
9
|
],
|
|
11
10
|
"scripts": {
|
|
12
11
|
"build": "tsc",
|
|
13
|
-
"minify": "find dist -name '*.js' -type f -exec terser {} -o {} -c -m \\;",
|
|
14
|
-
"build:minified": "tsc && yarn minify",
|
|
15
12
|
"dev": "tsc --watch",
|
|
16
13
|
"test": "jest",
|
|
17
14
|
"lint": "eslint src --ext .ts,.tsx",
|
|
18
|
-
"pack": "yarn build
|
|
19
|
-
"pack:tgz": "yarn build
|
|
20
|
-
"postinstall": "node scripts/postinstall.js"
|
|
15
|
+
"pack": "yarn build && npm pack --pack-destination ../../dist",
|
|
16
|
+
"pack:tgz": "yarn build && mkdir -p ../../dist && npm pack --pack-destination ../../dist"
|
|
21
17
|
},
|
|
22
18
|
"keywords": [
|
|
23
19
|
"sdk",
|
|
@@ -41,7 +37,6 @@
|
|
|
41
37
|
"@typescript-eslint/parser": "^5.0.0",
|
|
42
38
|
"eslint": "^8.0.0",
|
|
43
39
|
"jest": "^29.5.0",
|
|
44
|
-
"terser": "^5.44.1",
|
|
45
40
|
"typescript": "^5.0.0"
|
|
46
41
|
},
|
|
47
42
|
"peerDependencies": {
|
package/scripts/postinstall.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const colors = {
|
|
4
|
-
reset: '\x1b[0m',
|
|
5
|
-
bright: '\x1b[1m',
|
|
6
|
-
cyan: '\x1b[36m',
|
|
7
|
-
green: '\x1b[32m',
|
|
8
|
-
yellow: '\x1b[33m',
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const { bright, cyan, green, reset, yellow } = colors;
|
|
12
|
-
|
|
13
|
-
const box = `
|
|
14
|
-
${cyan}╔════════════════════════════════════════════════════════════════╗${reset}
|
|
15
|
-
${cyan}║${reset} ${cyan}║${reset}
|
|
16
|
-
${cyan}║${reset} ${bright}MP Request Handler SDK${reset} - Installation Complete! ${cyan}║${reset}
|
|
17
|
-
${cyan}║${reset} ${cyan}║${reset}
|
|
18
|
-
${cyan}╠════════════════════════════════════════════════════════════════╣${reset}
|
|
19
|
-
${cyan}║${reset} ${cyan}║${reset}
|
|
20
|
-
${cyan}║${reset} 📖 ${green}Documentation:${reset} ${cyan}║${reset}
|
|
21
|
-
${cyan}║${reset} https://docs.noonstg.partners/identity/IAMEndpoints ${cyan}║${reset}
|
|
22
|
-
${cyan}║${reset} ${cyan}║${reset}
|
|
23
|
-
${cyan}║${reset} 🚀 ${green}Quick Start Example:${reset} ${cyan}║${reset}
|
|
24
|
-
${cyan}║${reset} ${cyan}║${reset}
|
|
25
|
-
${cyan}║${reset} ${yellow}import { IAMRequest } from '@mp-request-handler/sdk'; ${reset} ${cyan}║${reset}
|
|
26
|
-
${cyan}║${reset} ${cyan}║${reset}
|
|
27
|
-
${cyan}║${reset} ${yellow}const response = await IAMRequest(${reset} ${cyan}║${reset}
|
|
28
|
-
${cyan}║${reset} ${yellow}'createProjectUser',${reset} ${cyan}║${reset}
|
|
29
|
-
${cyan}║${reset} ${yellow}{ username: 'user@example.com', ... },${reset} ${cyan}║${reset}
|
|
30
|
-
${cyan}║${reset} ${yellow}'PRJ1455'${reset} ${cyan}║${reset}
|
|
31
|
-
${cyan}║${reset} ${yellow});${reset} ${cyan}║${reset}
|
|
32
|
-
${cyan}║${reset} ${cyan}║${reset}
|
|
33
|
-
${cyan}╚════════════════════════════════════════════════════════════════╝${reset}
|
|
34
|
-
`;
|
|
35
|
-
|
|
36
|
-
console.log(box);
|