@forgerock/sdk-request-middleware 1.3.0 → 2.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @forgerock/sdk-request-middleware
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#502](https://github.com/ForgeRock/ping-javascript-sdk/pull/502) [`9ad4062`](https://github.com/ForgeRock/ping-javascript-sdk/commit/9ad406268dd568d8d6f6447a07b656e317a9da8d) Thanks [@ryanbas21](https://github.com/ryanbas21)! - releasing version 2 of the ping javascript sdk
8
+
9
+ ### Patch Changes
10
+
11
+ - [#526](https://github.com/ForgeRock/ping-javascript-sdk/pull/526) [`5a9ea40`](https://github.com/ForgeRock/ping-javascript-sdk/commit/5a9ea4079af4698f2d7df4bb5e7b40261aece15c) Thanks [@ancheetah](https://github.com/ancheetah)! - Update READMES. Fix types and comments.
12
+
3
13
  ## 1.3.0
4
14
 
5
15
  ## 1.2.0
package/README.md CHANGED
@@ -50,11 +50,12 @@ const requestMiddleware = [
50
50
  const fetchArgs = { url: 'https://api.example.com/resource' };
51
51
 
52
52
  // Initialize a query and apply middleware
53
- const response = await initQuery(fetchArgs, 'start')
53
+ const response = await initQuery(fetchArgs, 'authorize')
54
54
  .applyMiddleware(requestMiddleware)
55
- .applyQuery(async (args) => {
55
+ .applyQuery(async (request) => {
56
56
  // Your fetch implementation here
57
- return fetch(args.url, args);
57
+ const response = await fetch(request.url, request);
58
+ return { data: await response.json() };
58
59
  });
59
60
  ```
60
61
 
@@ -85,7 +86,7 @@ const authMiddleware = [
85
86
  ];
86
87
 
87
88
  // Use the middleware with specific action type
88
- const response = await initQuery(fetchArgs, 'login')
89
+ const response = await initQuery(fetchArgs, 'start')
89
90
  .applyMiddleware(authMiddleware)
90
91
  .applyQuery(queryCallback);
91
92
  ```
@@ -121,21 +122,51 @@ Executes the request with the provided callback function.
121
122
 
122
123
  **Parameters:**
123
124
 
124
- - `callback`: A function that takes the modified request and returns a Promise with the API response
125
+ - `callback`: An async function that takes the modified `FetchArgs` (with `url` as a string) and returns a Promise that resolves to a `QueryReturnValue`
125
126
 
126
127
  **Returns:**
127
- A Promise with the result of the callback function
128
+ A Promise that resolves to a `QueryReturnValue<unknown, FetchBaseQueryError, FetchBaseQueryMeta>`
128
129
 
129
- ### RequestMiddleware Type
130
+ ### RequestMiddleware Types
130
131
 
131
132
  ```typescript
132
- type RequestMiddleware<Type, Payload> = (
133
+ type RequestMiddleware<Type extends ActionTypes = ActionTypes, Payload = unknown> = (
133
134
  req: ModifiedFetchArgs,
134
135
  action: Action<Type, Payload>,
135
136
  next: () => ModifiedFetchArgs,
136
137
  ) => void;
137
138
  ```
138
139
 
140
+ The `endpoint` parameter for `initQuery` accepts an action type which maps to the type of request you want to intercept.
141
+
142
+ ```typescript
143
+ const actionTypes = {
144
+ // Journey
145
+ begin: 'JOURNEY_START',
146
+ continue: 'JOURNEY_NEXT',
147
+ terminate: 'JOURNEY_TERMINATE',
148
+
149
+ // DaVinci
150
+ start: 'DAVINCI_START',
151
+ next: 'DAVINCI_NEXT',
152
+ flow: 'DAVINCI_FLOW',
153
+ success: 'DAVINCI_SUCCESS',
154
+ error: 'DAVINCI_ERROR',
155
+ failure: 'DAVINCI_FAILURE',
156
+ resume: 'DAVINCI_RESUME',
157
+
158
+ // OIDC
159
+ authorize: 'AUTHORIZE',
160
+ tokenExchange: 'TOKEN_EXCHANGE',
161
+ revoke: 'REVOKE',
162
+ userInfo: 'USER_INFO',
163
+ endSession: 'END_SESSION',
164
+ } as const;
165
+
166
+ type ActionTypes = (typeof actionTypes)[keyof typeof actionTypes];
167
+ type EndpointTypes = keyof typeof actionTypes;
168
+ ```
169
+
139
170
  ## Building
140
171
 
141
172
  Run `nx build sdk-request-middleware` to build the library.
@@ -116,7 +116,7 @@
116
116
  <div class='footer quiet pad2 space-top1 center small'>
117
117
  Code coverage generated by
118
118
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
119
- at 2025-11-24T21:08:53.840Z
119
+ at 2026-03-19T17:04:15.856Z
120
120
  </div>
121
121
  <script src="prettify.js"></script>
122
122
  <script>
@@ -101,7 +101,7 @@
101
101
  <div class='footer quiet pad2 space-top1 center small'>
102
102
  Code coverage generated by
103
103
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
104
- at 2025-11-24T21:08:53.840Z
104
+ at 2026-03-19T17:04:15.856Z
105
105
  </div>
106
106
  <script src="../prettify.js"></script>
107
107
  <script>
@@ -79,7 +79,7 @@
79
79
  <div class='footer quiet pad2 space-top1 center small'>
80
80
  Code coverage generated by
81
81
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
82
- at 2025-11-24T21:08:53.840Z
82
+ at 2026-03-19T17:04:15.856Z
83
83
  </div>
84
84
  <script src="../prettify.js"></script>
85
85
  <script>
@@ -131,7 +131,7 @@
131
131
  <div class='footer quiet pad2 space-top1 center small'>
132
132
  Code coverage generated by
133
133
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
134
- at 2025-11-24T21:08:53.840Z
134
+ at 2026-03-19T17:04:15.856Z
135
135
  </div>
136
136
  <script src="../../prettify.js"></script>
137
137
  <script>
@@ -166,7 +166,7 @@ export type EndpointTypes = keyof typeof actionTypes;
166
166
  <div class='footer quiet pad2 space-top1 center small'>
167
167
  Code coverage generated by
168
168
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
169
- at 2025-11-24T21:08:53.840Z
169
+ at 2026-03-19T17:04:15.856Z
170
170
  </div>
171
171
  <script src="../../prettify.js"></script>
172
172
  <script>
@@ -355,7 +355,7 @@ export function initQuery(
355
355
  <div class='footer quiet pad2 space-top1 center small'>
356
356
  Code coverage generated by
357
357
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
358
- at 2025-11-24T21:08:53.840Z
358
+ at 2026-03-19T17:04:15.856Z
359
359
  </div>
360
360
  <script src="../../prettify.js"></script>
361
361
  <script>
@@ -205,7 +205,7 @@ export interface RequestObj {
205
205
  <div class='footer quiet pad2 space-top1 center small'>
206
206
  Code coverage generated by
207
207
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
208
- at 2025-11-24T21:08:53.840Z
208
+ at 2026-03-19T17:04:15.856Z
209
209
  </div>
210
210
  <script src="../../prettify.js"></script>
211
211
  <script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forgerock/sdk-request-middleware",
3
- "version": "1.3.0",
3
+ "version": "2.0.0",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",