@forgerock/davinci-client 0.0.0-beta-20251003204059 → 0.0.0-beta-20251124184351

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 (77) hide show
  1. package/package.json +7 -6
  2. package/dist/src/index.d.ts +0 -3
  3. package/dist/src/index.d.ts.map +0 -1
  4. package/dist/src/index.js +0 -9
  5. package/dist/src/index.js.map +0 -1
  6. package/dist/src/lib/client.store.d.ts +0 -352
  7. package/dist/src/lib/client.store.d.ts.map +0 -1
  8. package/dist/src/lib/client.store.js +0 -306
  9. package/dist/src/lib/client.store.js.map +0 -1
  10. package/dist/src/lib/client.store.utils.d.ts +0 -74
  11. package/dist/src/lib/client.store.utils.d.ts.map +0 -1
  12. package/dist/src/lib/client.store.utils.js +0 -48
  13. package/dist/src/lib/client.store.utils.js.map +0 -1
  14. package/dist/src/lib/client.types.d.ts +0 -21
  15. package/dist/src/lib/client.types.d.ts.map +0 -1
  16. package/dist/src/lib/client.types.js +0 -2
  17. package/dist/src/lib/client.types.js.map +0 -1
  18. package/dist/src/lib/collector.types.d.ts +0 -405
  19. package/dist/src/lib/collector.types.d.ts.map +0 -1
  20. package/dist/src/lib/collector.types.js +0 -8
  21. package/dist/src/lib/collector.types.js.map +0 -1
  22. package/dist/src/lib/collector.utils.d.ts +0 -132
  23. package/dist/src/lib/collector.utils.d.ts.map +0 -1
  24. package/dist/src/lib/collector.utils.js +0 -559
  25. package/dist/src/lib/collector.utils.js.map +0 -1
  26. package/dist/src/lib/config.slice.d.ts +0 -42
  27. package/dist/src/lib/config.slice.d.ts.map +0 -1
  28. package/dist/src/lib/config.slice.js +0 -59
  29. package/dist/src/lib/config.slice.js.map +0 -1
  30. package/dist/src/lib/config.types.d.ts +0 -12
  31. package/dist/src/lib/config.types.d.ts.map +0 -1
  32. package/dist/src/lib/config.types.js +0 -2
  33. package/dist/src/lib/config.types.js.map +0 -1
  34. package/dist/src/lib/davinci.api.d.ts +0 -31
  35. package/dist/src/lib/davinci.api.d.ts.map +0 -1
  36. package/dist/src/lib/davinci.api.js +0 -347
  37. package/dist/src/lib/davinci.api.js.map +0 -1
  38. package/dist/src/lib/davinci.types.d.ts +0 -285
  39. package/dist/src/lib/davinci.types.d.ts.map +0 -1
  40. package/dist/src/lib/davinci.types.js +0 -11
  41. package/dist/src/lib/davinci.types.js.map +0 -1
  42. package/dist/src/lib/davinci.utils.d.ts +0 -22
  43. package/dist/src/lib/davinci.utils.d.ts.map +0 -1
  44. package/dist/src/lib/davinci.utils.js +0 -169
  45. package/dist/src/lib/davinci.utils.js.map +0 -1
  46. package/dist/src/lib/index.d.ts +0 -3
  47. package/dist/src/lib/index.d.ts.map +0 -1
  48. package/dist/src/lib/index.js +0 -9
  49. package/dist/src/lib/index.js.map +0 -1
  50. package/dist/src/lib/node.reducer.d.ts +0 -27
  51. package/dist/src/lib/node.reducer.d.ts.map +0 -1
  52. package/dist/src/lib/node.reducer.js +0 -198
  53. package/dist/src/lib/node.reducer.js.map +0 -1
  54. package/dist/src/lib/node.slice.d.ts +0 -174
  55. package/dist/src/lib/node.slice.d.ts.map +0 -1
  56. package/dist/src/lib/node.slice.js +0 -261
  57. package/dist/src/lib/node.slice.js.map +0 -1
  58. package/dist/src/lib/node.types.d.ts +0 -119
  59. package/dist/src/lib/node.types.d.ts.map +0 -1
  60. package/dist/src/lib/node.types.js +0 -2
  61. package/dist/src/lib/node.types.js.map +0 -1
  62. package/dist/src/lib/node.utils.d.ts +0 -4
  63. package/dist/src/lib/node.utils.d.ts.map +0 -1
  64. package/dist/src/lib/node.utils.js +0 -32
  65. package/dist/src/lib/node.utils.js.map +0 -1
  66. package/dist/src/lib/wellknown.api.d.ts +0 -5
  67. package/dist/src/lib/wellknown.api.d.ts.map +0 -1
  68. package/dist/src/lib/wellknown.api.js +0 -22
  69. package/dist/src/lib/wellknown.api.js.map +0 -1
  70. package/dist/src/lib/wellknown.types.d.ts +0 -38
  71. package/dist/src/lib/wellknown.types.d.ts.map +0 -1
  72. package/dist/src/lib/wellknown.types.js +0 -2
  73. package/dist/src/lib/wellknown.types.js.map +0 -1
  74. package/dist/src/types.d.ts +0 -41
  75. package/dist/src/types.d.ts.map +0 -1
  76. package/dist/src/types.js +0 -7
  77. package/dist/src/types.js.map +0 -1
@@ -1,59 +0,0 @@
1
- /*
2
- * Copyright (c) 2025 Ping Identity Corporation. All rights reserved.
3
- *
4
- * This software may be modified and distributed under the terms
5
- * of the MIT license. See the LICENSE file for details.
6
- */
7
- /**
8
- * Import the createSlice and PayloadAction utilities from Redux Toolkit
9
- * @see https://redux-toolkit.js.org/api/createslice
10
- */
11
- import { createSlice } from '@reduxjs/toolkit';
12
- /**
13
- * @const initialState - The initial state of the configuration slice
14
- * NOTE: The clientId, redirectUri, responseType, and scope are set to empty strings
15
- */
16
- const initialState = {
17
- endpoints: {},
18
- clientId: '',
19
- redirectUri: '',
20
- responseType: '',
21
- scope: '',
22
- };
23
- /**
24
- * @const configSlice - Define the configuration slice for Redux state management
25
- * @see https://redux-toolkit.js.org/api/createslice
26
- */
27
- export const configSlice = createSlice({
28
- name: 'config',
29
- initialState,
30
- reducerPath: 'config',
31
- reducers: {
32
- /**
33
- * @method set - Set the configuration for the DaVinci client
34
- * @param {Object} state - The current state of the slice
35
- * @param {PayloadAction<InternalDaVinciConfig>} action - The action to be dispatched
36
- * @returns {void}
37
- */
38
- set(state, action) {
39
- state.clientId = action.payload.clientId || '';
40
- state.redirectUri = action.payload.redirectUri || `${location.origin}/handle-redirect`;
41
- if ('responseType' in action.payload && action.payload.responseType) {
42
- state.responseType = action.payload.responseType;
43
- }
44
- else {
45
- state.responseType = 'code';
46
- }
47
- state.scope = action.payload.scope || 'openid';
48
- const { authorization_endpoint: authorize, issuer: issuer, introspection_endpoint: introspection, token_endpoint: tokens, userinfo_endpoint: userinfo, } = action.payload.wellknownResponse;
49
- state.endpoints = {
50
- authorize,
51
- issuer,
52
- introspection,
53
- tokens,
54
- userinfo,
55
- };
56
- },
57
- },
58
- });
59
- //# sourceMappingURL=config.slice.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.slice.js","sourceRoot":"","sources":["../../../src/lib/config.slice.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAsB,MAAM,kBAAkB,CAAC;AAQnE;;;GAGG;AACH,MAAM,YAAY,GAAG;IACnB,SAAS,EAAE,EAAe;IAC1B,QAAQ,EAAE,EAAE;IACZ,WAAW,EAAE,EAAE;IACf,YAAY,EAAE,EAAE;IAChB,KAAK,EAAE,EAAE;CACV,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC;IACrC,IAAI,EAAE,QAAQ;IACd,YAAY;IACZ,WAAW,EAAE,QAAQ;IACrB,QAAQ,EAAE;QACR;;;;;WAKG;QACH,GAAG,CAAC,KAAK,EAAE,MAA4C;YACrD,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;YAC/C,KAAK,CAAC,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,IAAI,GAAG,QAAQ,CAAC,MAAM,kBAAkB,CAAC;YACvF,IAAI,cAAc,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;gBACpE,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC;YACnD,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC;YAC9B,CAAC;YAED,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,QAAQ,CAAC;YAE/C,MAAM,EACJ,sBAAsB,EAAE,SAAS,EACjC,MAAM,EAAE,MAAM,EACd,sBAAsB,EAAE,aAAa,EACrC,cAAc,EAAE,MAAM,EACtB,iBAAiB,EAAE,QAAQ,GAC5B,GAAG,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC;YAErC,KAAK,CAAC,SAAS,GAAG;gBAChB,SAAS;gBACT,MAAM;gBACN,aAAa;gBACb,MAAM;gBACN,QAAQ;aACT,CAAC;QACJ,CAAC;KACF;CACF,CAAC,CAAC"}
@@ -1,12 +0,0 @@
1
- /**
2
- * Import LegacyConfigOptions type from the JavaScript SDK
3
- */
4
- import type { AsyncLegacyConfigOptions } from '@forgerock/sdk-types';
5
- import { WellknownResponse } from './wellknown.types.js';
6
- export interface DaVinciConfig extends AsyncLegacyConfigOptions {
7
- responseType?: string;
8
- }
9
- export interface InternalDaVinciConfig extends DaVinciConfig {
10
- wellknownResponse: WellknownResponse;
11
- }
12
- //# sourceMappingURL=config.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.types.d.ts","sourceRoot":"","sources":["../../../src/lib/config.types.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,WAAW,aAAc,SAAQ,wBAAwB;IAC7D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IAC1D,iBAAiB,EAAE,iBAAiB,CAAC;CACtC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=config.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.types.js","sourceRoot":"","sources":["../../../src/lib/config.types.ts"],"names":[],"mappings":""}
@@ -1,31 +0,0 @@
1
- /**
2
- * Import the RTK Query library from Redux Toolkit
3
- * @see https://redux-toolkit.js.org/rtk-query/overview
4
- */
5
- import { FetchArgs, FetchBaseQueryError, FetchBaseQueryMeta } from '@reduxjs/toolkit/query';
6
- import type { OutgoingQueryParams, StartOptions } from './davinci.types.js';
7
- import type { ContinueNode } from './node.types.js';
8
- /**
9
- * @const davinciApi - Define the DaVinci API for Redux state management
10
- * @see https://redux-toolkit.js.org/rtk-query/overview
11
- */
12
- export declare const davinciApi: import("@reduxjs/toolkit/query").Api<import("@reduxjs/toolkit/query").BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError, {}, FetchBaseQueryMeta>, {
13
- /**
14
- * @method flow - method for initiating a new flow with the DaVinci API
15
- */
16
- flow: import("@reduxjs/toolkit/query").MutationDefinition<any, import("@reduxjs/toolkit/query").BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError, {}, FetchBaseQueryMeta>, never, unknown, "davinci", any>;
17
- /**
18
- * @method next - method for initiating the next node in the current flow
19
- */
20
- next: import("@reduxjs/toolkit/query").MutationDefinition<any, import("@reduxjs/toolkit/query").BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError, {}, FetchBaseQueryMeta>, never, unknown, "davinci", any>;
21
- /**
22
- * @method start - method for initiating a DaVinci flow
23
- * @param - needs no arguments, but need to declare types to make it explicit
24
- */
25
- start: import("@reduxjs/toolkit/query").MutationDefinition<StartOptions<OutgoingQueryParams> | undefined, import("@reduxjs/toolkit/query").BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError, {}, FetchBaseQueryMeta>, never, unknown, "davinci", unknown>;
26
- resume: import("@reduxjs/toolkit/query").QueryDefinition<{
27
- serverInfo: ContinueNode["server"];
28
- continueToken: string;
29
- }, import("@reduxjs/toolkit/query").BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError, {}, FetchBaseQueryMeta>, never, unknown, "davinci", unknown>;
30
- }, "davinci", never, typeof import("@reduxjs/toolkit/query").coreModuleName>;
31
- //# sourceMappingURL=davinci.api.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"davinci.api.d.ts","sourceRoot":"","sources":["../../../src/lib/davinci.api.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,OAAO,EAEL,SAAS,EAET,mBAAmB,EACnB,kBAAkB,EAEnB,MAAM,wBAAwB,CAAC;AAiBhC,OAAO,KAAK,EAEV,mBAAmB,EACnB,YAAY,EAEb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAYpD;;;GAGG;AACH,eAAO,MAAM,UAAU;IAYnB;;OAEG;;IAgFH;;OAEG;;IAoFH;;;OAGG;;;oBA+G0C,YAAY,CAAC,QAAQ,CAAC;uBAAiB,MAAM;;4EA2E5F,CAAC"}
@@ -1,347 +0,0 @@
1
- /*
2
- * Copyright (c) 2025 Ping Identity Corporation. All rights reserved.
3
- *
4
- * This software may be modified and distributed under the terms
5
- * of the MIT license. See the LICENSE file for details.
6
- */
7
- /**
8
- * Import the RTK Query library from Redux Toolkit
9
- * @see https://redux-toolkit.js.org/rtk-query/overview
10
- */
11
- import { createApi, fetchBaseQuery, } from '@reduxjs/toolkit/query';
12
- /**
13
- * Import internal modules
14
- */
15
- import { initQuery } from '@forgerock/sdk-request-middleware';
16
- import { createAuthorizeUrl } from '@forgerock/sdk-oidc';
17
- import { handleResponse, transformActionRequest, transformSubmitRequest } from './davinci.utils.js';
18
- /**
19
- * @const davinciApi - Define the DaVinci API for Redux state management
20
- * @see https://redux-toolkit.js.org/rtk-query/overview
21
- */
22
- export const davinciApi = createApi({
23
- reducerPath: 'davinci',
24
- // TODO: implement extraOptions for request interceptors: https://stackoverflow.com/a/77569083 & https://stackoverflow.com/a/65129117
25
- baseQuery: fetchBaseQuery({
26
- prepareHeaders: (headers) => {
27
- headers.set('Accept', 'application/json');
28
- headers.set('x-requested-with', 'ping-sdk');
29
- headers.set('x-requested-platform', 'javascript');
30
- return headers;
31
- },
32
- }),
33
- endpoints: (builder) => ({
34
- /**
35
- * @method flow - method for initiating a new flow with the DaVinci API
36
- */
37
- flow: builder.mutation({
38
- /**
39
- * @method queryFn - This is just a wrapper around the fetch call
40
- */
41
- async queryFn(params, api, __, baseQuery) {
42
- const state = api.getState();
43
- const links = state.node.server._links;
44
- const requestBody = transformActionRequest(state.node, params.action, api.extra.logger);
45
- const { requestMiddleware, logger } = api.extra;
46
- let href = '';
47
- if (links && 'next' in links) {
48
- href = links['next'].href || '';
49
- }
50
- const request = {
51
- // TODO: If we don't have a `next.href`, we should handle this better
52
- url: href,
53
- credentials: 'include',
54
- method: 'POST',
55
- headers: {
56
- 'Content-Type': 'application/json',
57
- interactionId: state.node.server.interactionId,
58
- interactionToken: state.node.server.interactionToken,
59
- },
60
- body: JSON.stringify(requestBody),
61
- };
62
- logger.debug('Davinci API request', request);
63
- const response = initQuery(request, 'flow')
64
- .applyMiddleware(requestMiddleware)
65
- .applyQuery(async (req) => await baseQuery(req));
66
- /**
67
- * Returns the original response from DaVinci,
68
- * this gets transformed in the onQueryStarted method
69
- */
70
- return response;
71
- },
72
- /**
73
- * @method onQueryStarted - method for handling the response from the DaVinci API
74
- *
75
- * The method name below is a bit misleading. It is not just
76
- * called when the query is started, but throughout the lifecycle of
77
- * the API, including when the query is fulfilled. This is because
78
- * the query is started, and then the response is awaited, and then
79
- * the response is processed.
80
- *
81
- * NOTE: The below is repeated for each endpoint, which is not "DRY",
82
- * but doing it inline reduces the typing complexity as all the
83
- * parameters are pre-typed from the library.
84
- */
85
- async onQueryStarted(_, api) {
86
- const logger = api.extra.logger;
87
- let response;
88
- try {
89
- const query = await api.queryFulfilled;
90
- response = query.meta?.response;
91
- }
92
- catch (err) {
93
- const error = err;
94
- /**
95
- * This error is thrown when the query is rejected. We don't
96
- * want to do anything with it for now.
97
- */
98
- response = error.meta?.response;
99
- }
100
- const cacheEntry = api.getCacheEntry();
101
- logger.debug('Davinci API response', cacheEntry);
102
- handleResponse(cacheEntry, api.dispatch, response?.status || 0, logger);
103
- },
104
- }),
105
- /**
106
- * @method next - method for initiating the next node in the current flow
107
- */
108
- next: builder.mutation({
109
- /**
110
- * @method queryFn - This is just a wrapper around the fetch call
111
- */
112
- async queryFn(body, api, __, baseQuery) {
113
- const state = api.getState();
114
- const links = state.node.server._links;
115
- const { requestMiddleware, logger } = api.extra;
116
- let requestBody;
117
- let href = '';
118
- if (links && 'next' in links) {
119
- href = links['next'].href || '';
120
- }
121
- if (!body) {
122
- requestBody = transformSubmitRequest(state.node, logger);
123
- }
124
- else {
125
- requestBody = body;
126
- }
127
- const request = {
128
- url: href,
129
- credentials: 'include',
130
- method: 'POST',
131
- headers: {
132
- 'Content-Type': 'application/json',
133
- interactionId: state.node.server.interactionId,
134
- interactionToken: state.node.server.interactionToken,
135
- },
136
- body: JSON.stringify(requestBody),
137
- };
138
- logger.debug('Davinci API request', request);
139
- const response = initQuery(request, 'next')
140
- .applyMiddleware(requestMiddleware)
141
- .applyQuery(async (req) => await baseQuery(req));
142
- /**
143
- * Returns the original response from DaVinci,
144
- * this gets transformed in the onQueryStarted method
145
- */
146
- return response;
147
- },
148
- /**
149
- * @method onQueryStarted - method for handling the response from the DaVinci API
150
- *
151
- * The method name below is a bit misleading. It is not just
152
- * called when the query is started, but throughout the lifecycle of
153
- * the API, including when the query is fulfilled. This is because
154
- * the query is started, and then the response is awaited, and then
155
- * the response is processed.
156
- *
157
- * NOTE: The below is repeated for each endpoint, which is not "DRY",
158
- * but doing it inline reduces the typing complexity as all the
159
- * parameters are pre-typed from the library.
160
- */
161
- async onQueryStarted(_, api) {
162
- const logger = api.extra.logger;
163
- let response;
164
- try {
165
- const query = await api.queryFulfilled;
166
- response = query.meta?.response;
167
- }
168
- catch (err) {
169
- const error = err;
170
- /**
171
- * This error is thrown when the query is rejected. We don't
172
- * want to do anything with it for now.
173
- */
174
- response = error.meta?.response;
175
- }
176
- const cacheEntry = api.getCacheEntry();
177
- logger.debug('Davinci API response', cacheEntry);
178
- handleResponse(cacheEntry, api.dispatch, response?.status || 0, logger);
179
- },
180
- }),
181
- /**
182
- * @method start - method for initiating a DaVinci flow
183
- * @param - needs no arguments, but need to declare types to make it explicit
184
- */
185
- start: builder.mutation({
186
- /**
187
- * @method queryFn - This is just a wrapper around the fetch call
188
- */
189
- async queryFn(options, api, __, baseQuery) {
190
- const { requestMiddleware, logger } = api.extra;
191
- const state = api.getState();
192
- if (!state) {
193
- return {
194
- error: {
195
- status: 400,
196
- data: 'Store must be initialized before use',
197
- },
198
- };
199
- }
200
- const authorizeEndpoint = state.config.endpoints.authorize;
201
- if (!authorizeEndpoint) {
202
- return { error: { status: 400, data: 'authorizeEndpoint URL must be set' } };
203
- }
204
- try {
205
- const authorizeUrl = await createAuthorizeUrl(authorizeEndpoint, {
206
- clientId: state?.config?.clientId,
207
- login: 'redirect', // TODO: improve this in SDK to be more semantic
208
- redirectUri: state?.config?.redirectUri,
209
- responseType: state?.config?.responseType,
210
- responseMode: 'pi.flow',
211
- scope: state?.config?.scope,
212
- });
213
- const url = new URL(authorizeUrl);
214
- const existingParams = url.searchParams;
215
- if (options?.query) {
216
- Object.entries(options.query).forEach(([key, value]) => {
217
- /**
218
- * We use set here because if we have existing params, we want
219
- * to make sure we override them and not add duplicates
220
- */
221
- existingParams.set(key, String(value));
222
- });
223
- url.search = existingParams.toString();
224
- }
225
- const request = {
226
- url: url.toString(),
227
- credentials: 'include',
228
- method: 'GET',
229
- headers: {
230
- 'Content-Type': 'application/x-www-form-urlencoded',
231
- },
232
- };
233
- logger.debug('Davinci API request', request);
234
- const response = initQuery(request, 'start')
235
- .applyMiddleware(requestMiddleware)
236
- .applyQuery(async (req) => await baseQuery(req));
237
- /**
238
- * Returns the original response from DaVinci,
239
- * this gets transformed in the onQueryStarted method
240
- */
241
- return response;
242
- }
243
- catch (error) {
244
- if (error instanceof Error) {
245
- return { error: { status: 400, data: error.message } };
246
- }
247
- return { error: { status: 400, data: 'An unknown error occurred' } };
248
- }
249
- },
250
- /**
251
- * @method onQueryStarted - method for handling the response from the DaVinci API
252
- *
253
- * The method name below is a bit misleading. It is not just
254
- * called when the query is started, but throughout the lifecycle of
255
- * the API, including when the query is fulfilled. This is because
256
- * the query is started, and then the response is awaited, and then
257
- * the response is processed.
258
- *
259
- * NOTE: The below is repeated for each endpoint, which is not "DRY",
260
- * but doing it inline reduces the typing complexity as all the
261
- * parameters are pre-typed from the library.
262
- */
263
- async onQueryStarted(_, api) {
264
- const logger = api.extra.logger;
265
- let response;
266
- try {
267
- const query = await api.queryFulfilled;
268
- response = query.meta?.response;
269
- }
270
- catch (err) {
271
- const error = err;
272
- /**
273
- * This error is thrown when the query is rejected. We don't
274
- * want to do anything with it for now.
275
- */
276
- response = error.meta?.response;
277
- }
278
- const cacheEntry = api.getCacheEntry();
279
- logger.debug('Davinci API response', cacheEntry);
280
- handleResponse(cacheEntry, api.dispatch, response?.status || 0, logger);
281
- },
282
- }),
283
- resume: builder.query({
284
- async queryFn({ serverInfo, continueToken }, api, _c, baseQuery) {
285
- const { requestMiddleware, logger } = api.extra;
286
- const links = serverInfo._links;
287
- if (!continueToken) {
288
- return {
289
- error: {
290
- data: 'No continue token',
291
- message: 'Resume meant to be called in a social login. Continue token was not found on the url',
292
- status: 200,
293
- },
294
- };
295
- }
296
- if (!links ||
297
- !('continue' in links) ||
298
- !('href' in links['continue']) ||
299
- !links['continue'].href) {
300
- return {
301
- error: {
302
- data: 'No continue url',
303
- message: 'Resume needs a continue url, none was found in storage. Please restart your flow',
304
- status: 200,
305
- },
306
- };
307
- }
308
- const continueUrl = links['continue'].href;
309
- const request = {
310
- url: continueUrl,
311
- credentials: 'include',
312
- method: 'POST',
313
- headers: {
314
- 'Content-Type': 'application/json',
315
- Authorization: `Bearer ${continueToken}`,
316
- },
317
- body: JSON.stringify({}),
318
- };
319
- logger.debug('Davinci API request', request);
320
- const response = initQuery(request, 'resume')
321
- .applyMiddleware(requestMiddleware)
322
- .applyQuery(async (req) => await baseQuery(req));
323
- return response;
324
- },
325
- async onQueryStarted(_, api) {
326
- const logger = api.extra.logger;
327
- let response;
328
- try {
329
- const query = await api.queryFulfilled;
330
- response = query.meta?.response;
331
- }
332
- catch (err) {
333
- const error = err;
334
- /**
335
- * This error is thrown when the query is rejected. We don't
336
- * want to do anything with it for now.
337
- */
338
- response = error.meta?.response;
339
- }
340
- const cacheEntry = api.getCacheEntry();
341
- logger.debug('Davinci API response', cacheEntry);
342
- handleResponse(cacheEntry, api.dispatch, response?.status || 0, logger);
343
- },
344
- }),
345
- }),
346
- });
347
- //# sourceMappingURL=davinci.api.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"davinci.api.js","sourceRoot":"","sources":["../../../src/lib/davinci.api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH;;;GAGG;AACH,OAAO,EACL,SAAS,EAET,cAAc,GAIf,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AA2BpG;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC;IAClC,WAAW,EAAE,SAAS;IACtB,qIAAqI;IACrI,SAAS,EAAE,cAAc,CAAC;QACxB,cAAc,EAAE,CAAC,OAAO,EAAE,EAAE;YAC1B,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;YAC1C,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;YAC5C,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,YAAY,CAAC,CAAC;YAClD,OAAO,OAAO,CAAC;QACjB,CAAC;KACF,CAAC;IACF,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACvB;;WAEG;QACH,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC;YACrB;;eAEG;YACH,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,SAAS;gBACtC,MAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,EAAqC,CAAC;gBAChE,MAAM,KAAK,GAAG,KAAK,CA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