@adobe/exc-app 0.2.46 → 1.0.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/RuntimeConfiguration.d.ts +4 -0
- package/appapi.d.ts +1 -1
- package/appapi.js +1 -1
- package/appapi.js.map +1 -1
- package/build/preBuild.js +14 -0
- package/capabilityapi.d.ts +4 -2
- package/capabilityapi.js +4 -2
- package/capabilityapi.js.map +1 -1
- package/docs/README.md +1 -0
- package/docs/enums/appapi.appids.md +21 -7
- package/docs/enums/capabilityapi.capabilityids.md +28 -0
- package/docs/enums/capabilityapi.capabilitynames.md +28 -0
- package/docs/enums/network.routing.md +21 -1
- package/docs/interfaces/ims.activeproductcontext.md +13 -0
- package/docs/interfaces/ims.imsprofile.md +130 -0
- package/docs/interfaces/ims.productcontext.md +141 -0
- package/docs/interfaces/ims.projectedproductcontext.md +21 -0
- package/docs/interfaces/network.queryrequest.md +20 -0
- package/docs/interfaces/root.poller.md +56 -0
- package/docs/interfaces/root.pollerhandle.md +21 -0
- package/docs/interfaces/root.pollingconfiguration.md +28 -0
- package/docs/interfaces/root.runtimeconfiguration.md +10 -1
- package/docs/interfaces/root.useractivityemitter.md +110 -0
- package/docs/interfaces/root.useractivitymonitor.md +151 -0
- package/docs/interfaces/user.userapi.md +1 -1
- package/docs/modules/ims.md +14 -0
- package/docs/modules/network.md +7 -0
- package/docs/modules/root.md +5 -0
- package/docs/modules/settings.md +8 -57
- package/docs/modules/user.md +14 -0
- package/index.js +7 -0
- package/index.js.map +1 -1
- package/internal.d.ts +9 -0
- package/internal.js +3 -0
- package/internal.js.map +1 -1
- package/network.d.ts +17 -1
- package/network.js +11 -0
- package/network.js.map +1 -1
- package/package.json +6 -7
- package/src/Global.d.ts +3 -1
- package/src/Global.js.map +1 -1
- package/tests/index.test.js +5 -0
- package/tests/index.test.js.map +1 -1
- package/tests/version.test.d.ts +1 -0
- package/tests/version.test.js +23 -0
- package/tests/version.test.js.map +1 -0
- package/{settings/SettingsLevel.ts → version.d.ts} +2 -20
- package/{metrics/Level.ts → version.js} +6 -20
- package/version.js.map +1 -0
- package/RuntimeConfiguration.ts +0 -272
- package/appapi.ts +0 -140
- package/capabilityapi.ts +0 -162
- package/coverage/lcov-report/block-navigation.js +0 -79
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sorter.js +0 -170
- package/helpcenter.ts +0 -253
- package/ims/ImsProfile.ts +0 -57
- package/index.ts +0 -76
- package/internal.ts +0 -102
- package/metrics/Analytics.ts +0 -55
- package/metrics/Application.ts +0 -24
- package/metrics/Configuration.ts +0 -33
- package/metrics/Events.ts +0 -28
- package/metrics/History.ts +0 -36
- package/metrics/Metric.ts +0 -52
- package/metrics/Metrics.ts +0 -129
- package/metrics/RecordType.ts +0 -139
- package/metrics/User.ts +0 -30
- package/metrics.ts +0 -94
- package/network.ts +0 -554
- package/nps.ts +0 -83
- package/orgswitcher.ts +0 -109
- package/page.ts +0 -497
- package/permissions.ts +0 -103
- package/pulse.ts +0 -198
- package/session.ts +0 -116
- package/settings.ts +0 -147
- package/shell.ts +0 -107
- package/sidebar.ts +0 -208
- package/sidenav.ts +0 -287
- package/src/EventEmitter.ts +0 -44
- package/src/Global.ts +0 -109
- package/src/Runtime.ts +0 -23
- package/tests/MockRuntime.ts +0 -28
- package/tests/appapi.test.ts +0 -78
- package/tests/capabilityapi.test.ts +0 -55
- package/tests/helpCenter.test.ts +0 -80
- package/tests/index.test.ts +0 -50
- package/tests/metrics.test.ts +0 -34
- package/tests/nps.test.ts +0 -37
- package/tests/page.test.ts +0 -110
- package/tests/permissions.test.ts +0 -96
- package/tests/pulse.test.ts +0 -37
- package/tests/shell.test.ts +0 -89
- package/tests/sidenav.test.ts +0 -91
- package/tests/topbar.test.ts +0 -85
- package/tests/user.test.ts +0 -129
- package/tests/userprofile.test.ts +0 -31
- package/topbar.ts +0 -288
- package/user.ts +0 -235
- package/userprofile.ts +0 -93
package/network.ts
DELETED
|
@@ -1,554 +0,0 @@
|
|
|
1
|
-
/*************************************************************************
|
|
2
|
-
* Copyright 2020 Adobe
|
|
3
|
-
* All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* NOTICE: Adobe permits you to use, modify, and distribute this file in
|
|
6
|
-
* accordance with the terms of the Adobe license agreement accompanying
|
|
7
|
-
* it. If you have received this file from a source other than Adobe,
|
|
8
|
-
* then your use, modification, or distribution of it requires the prior
|
|
9
|
-
* written permission of Adobe.
|
|
10
|
-
**************************************************************************/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* APIs that simplify code to make authenticated network requests for resources, execute GraphQL
|
|
14
|
-
* queries, etc..
|
|
15
|
-
*
|
|
16
|
-
* ***Import:***
|
|
17
|
-
*
|
|
18
|
-
* ```typescript
|
|
19
|
-
* import {fetch, query} from '@adobe/exc-app/network';
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* ***Default export:***
|
|
23
|
-
*
|
|
24
|
-
* [NetworkApi](../interfaces/network.networkapi.md)
|
|
25
|
-
*
|
|
26
|
-
* ***Usage:***
|
|
27
|
-
*
|
|
28
|
-
* ```typescript
|
|
29
|
-
* import {fetch, query} from '@adobe/exc-app/network';
|
|
30
|
-
*
|
|
31
|
-
* // Performs a window.fetch call with Authorization and x-api-key headers set
|
|
32
|
-
* const fetchResponse = await fetch('https://localhost', {auth: 'Header', method: 'GET'});
|
|
33
|
-
*
|
|
34
|
-
* // Executes a query for resources to the ExC GraphQL service
|
|
35
|
-
* const queryResponse = await query({
|
|
36
|
-
* data: {
|
|
37
|
-
* query: `
|
|
38
|
-
* query userBehanceQuery($userId: String!, $apiKey: String!) {
|
|
39
|
-
* userBehance(userId: $userId, apiKey: $apiKey) {
|
|
40
|
-
* images
|
|
41
|
-
* }
|
|
42
|
-
* }`,
|
|
43
|
-
* variables: {
|
|
44
|
-
* apiKey: 'test-app',
|
|
45
|
-
* userId: '123@AdobeID'
|
|
46
|
-
* }
|
|
47
|
-
* },
|
|
48
|
-
* operationName: 'BehanceAvatar'
|
|
49
|
-
* });
|
|
50
|
-
*
|
|
51
|
-
* ```
|
|
52
|
-
* @packageDocumentation
|
|
53
|
-
* @module network
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
import type {ApolloClient, ApolloLink, InMemoryCache, InMemoryCacheConfig} from '@apollo/client';
|
|
57
|
-
import {getImpl} from './src/Global';
|
|
58
|
-
import type {gql} from 'graphql-tag';
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Default status codes which imply a transient error and can be retried.
|
|
62
|
-
*/
|
|
63
|
-
export const DEFAULT_STATUS_CODES_TO_RETRY = [429, 502, 503, 504];
|
|
64
|
-
|
|
65
|
-
export interface FetchOptions {
|
|
66
|
-
/**
|
|
67
|
-
* A boolean value indicating whether to add Authentication token, API Key to the request.
|
|
68
|
-
*/
|
|
69
|
-
auth?: 'Header' | 'Body';
|
|
70
|
-
/**
|
|
71
|
-
* Number indicating how many fetch attempts should be made using exponential backoff.
|
|
72
|
-
*/
|
|
73
|
-
maxRetries?: number;
|
|
74
|
-
metadata?: DefaultMetaData;
|
|
75
|
-
/**
|
|
76
|
-
* HTTP Status Codes which will prompt a retry. If not provided only network failures
|
|
77
|
-
* will prompt a retry.
|
|
78
|
-
*/
|
|
79
|
-
statusCodesToRetry?: number[];
|
|
80
|
-
/**
|
|
81
|
-
* Specify the headers to be added to the request
|
|
82
|
-
*/
|
|
83
|
-
scope?: FetchScope
|
|
84
|
-
/**
|
|
85
|
-
* Number in ms indicating the maximum amount of time taken by the the fetch request plus any
|
|
86
|
-
* exponential backoff retry requests before aborting.
|
|
87
|
-
*/
|
|
88
|
-
totalFetchTime?: number;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* User Sandbox Interface
|
|
93
|
-
*/
|
|
94
|
-
interface Sandbox {
|
|
95
|
-
/**
|
|
96
|
-
* Whether it is the default sandbox
|
|
97
|
-
*/
|
|
98
|
-
isDefault: boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Sandbox ID
|
|
101
|
-
*/
|
|
102
|
-
name: string;
|
|
103
|
-
/**
|
|
104
|
-
* Region
|
|
105
|
-
*/
|
|
106
|
-
region: string;
|
|
107
|
-
/**
|
|
108
|
-
* Current state
|
|
109
|
-
*/
|
|
110
|
-
state: string;
|
|
111
|
-
/**
|
|
112
|
-
* Sandbox Display Title
|
|
113
|
-
*/
|
|
114
|
-
title: string;
|
|
115
|
-
/**
|
|
116
|
-
* Environment type
|
|
117
|
-
*/
|
|
118
|
-
type: string;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* @ignore
|
|
123
|
-
*/
|
|
124
|
-
export interface Configuration {
|
|
125
|
-
/**
|
|
126
|
-
* Unified Shell API Gateway URL
|
|
127
|
-
*/
|
|
128
|
-
apiGatewayUrl: string;
|
|
129
|
-
/**
|
|
130
|
-
* appId from solution route config
|
|
131
|
-
*/
|
|
132
|
-
appId: string;
|
|
133
|
-
/**
|
|
134
|
-
* Get Authentication token
|
|
135
|
-
*/
|
|
136
|
-
getTokenInfo: () => Promise<{token: string}>;
|
|
137
|
-
/**
|
|
138
|
-
* IMS Client ID
|
|
139
|
-
*/
|
|
140
|
-
imsClientId: string;
|
|
141
|
-
/**
|
|
142
|
-
* metricsAppId from solution route config
|
|
143
|
-
*/
|
|
144
|
-
metricsAppId?: string;
|
|
145
|
-
/**
|
|
146
|
-
* @deprecated tenantAppId from solution route config
|
|
147
|
-
*/
|
|
148
|
-
tenantAppId?: string;
|
|
149
|
-
/**
|
|
150
|
-
* IMS org id
|
|
151
|
-
*/
|
|
152
|
-
imsOrg?: string;
|
|
153
|
-
/**
|
|
154
|
-
* Current sandbox object
|
|
155
|
-
*/
|
|
156
|
-
sandbox?: Sandbox;
|
|
157
|
-
/**
|
|
158
|
-
* Adobe IO gateway URL used as a fallback in GQL call
|
|
159
|
-
*/
|
|
160
|
-
ioGatewayUrl?: string;
|
|
161
|
-
/**
|
|
162
|
-
* Map of Adobe IO region specific endpoints.
|
|
163
|
-
*/
|
|
164
|
-
ioRegionSpecificMap?: Record<string, string>;
|
|
165
|
-
/**
|
|
166
|
-
* Clients can pass in their local GQL endpoint
|
|
167
|
-
*/
|
|
168
|
-
gqlEndpoint?: string;
|
|
169
|
-
/**
|
|
170
|
-
* XQL gateway used for AEP specific queries
|
|
171
|
-
*/
|
|
172
|
-
xqlGatewayUrl?: string;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* GQL Query containing graphql query and variables.
|
|
177
|
-
*/
|
|
178
|
-
export interface GraphQLQuery {
|
|
179
|
-
/**
|
|
180
|
-
* GQL Query.
|
|
181
|
-
*
|
|
182
|
-
* ***Example:***
|
|
183
|
-
*
|
|
184
|
-
* ```typescript
|
|
185
|
-
* {query: `
|
|
186
|
-
* query userBehanceQuery($userId: String!, $apiKey: String!) {
|
|
187
|
-
* userBehance(userId: $userId, apiKey: $apiKey) {
|
|
188
|
-
* images
|
|
189
|
-
* }
|
|
190
|
-
* }`
|
|
191
|
-
* };
|
|
192
|
-
*
|
|
193
|
-
* {query: `
|
|
194
|
-
* query userBehanceQuery {
|
|
195
|
-
* userBehance(userId: "123@AdobeID", apiKey: "test-app") {
|
|
196
|
-
* images
|
|
197
|
-
* }
|
|
198
|
-
* }`
|
|
199
|
-
* };
|
|
200
|
-
* ```
|
|
201
|
-
*/
|
|
202
|
-
query: string;
|
|
203
|
-
/**
|
|
204
|
-
* Query specific variables- key value pairs.
|
|
205
|
-
*
|
|
206
|
-
* ***Example:***
|
|
207
|
-
*
|
|
208
|
-
* ```typescript
|
|
209
|
-
* {variables: {
|
|
210
|
-
* apiKey: 'test-app',
|
|
211
|
-
* userId: '123@AdobeID'
|
|
212
|
-
* }
|
|
213
|
-
* };
|
|
214
|
-
* ```
|
|
215
|
-
*/
|
|
216
|
-
variables?: Record<string, any>;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* SPA's can pass in the metadata to override the default values
|
|
221
|
-
*/
|
|
222
|
-
export interface DefaultMetaData {
|
|
223
|
-
imsClientId? : string;
|
|
224
|
-
token? : string;
|
|
225
|
-
imsOrg? : string;
|
|
226
|
-
sandbox?: Record<string, any>;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export enum ROUTING {
|
|
230
|
-
AEP_PROFILE_BASED
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Query request interface.
|
|
235
|
-
*/
|
|
236
|
-
export interface QueryRequest {
|
|
237
|
-
/**
|
|
238
|
-
* Overwrite config.appId until federation is out. This allow scenario where sharing components that are linked to their own tenants.
|
|
239
|
-
*/
|
|
240
|
-
appId?: string;
|
|
241
|
-
/**
|
|
242
|
-
* Data containing single or multiple GQL queries.
|
|
243
|
-
*
|
|
244
|
-
* ***Example:***
|
|
245
|
-
*
|
|
246
|
-
* ```typescript
|
|
247
|
-
* {data: {
|
|
248
|
-
* query: `
|
|
249
|
-
* query userBehanceQuery($userId: String!, $apiKey: String!) {
|
|
250
|
-
* userBehance(userId: $userId, apiKey: $apiKey) {
|
|
251
|
-
* images
|
|
252
|
-
* }
|
|
253
|
-
* }`,
|
|
254
|
-
* variables: {
|
|
255
|
-
* userId: '123@AdobeID',
|
|
256
|
-
* apiKey: 'test-app'
|
|
257
|
-
* }
|
|
258
|
-
* }
|
|
259
|
-
* };
|
|
260
|
-
* ```
|
|
261
|
-
*/
|
|
262
|
-
data: GraphQLQuery | Array<GraphQLQuery>;
|
|
263
|
-
/**
|
|
264
|
-
* Set the Accept-Language HTTP header in the request. Defaults to '*' (any language).
|
|
265
|
-
*
|
|
266
|
-
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language for more details.
|
|
267
|
-
*
|
|
268
|
-
*/
|
|
269
|
-
acceptLanguage?: string;
|
|
270
|
-
/**
|
|
271
|
-
* Query ID- To analyze a query's metrics & performance.
|
|
272
|
-
*
|
|
273
|
-
* ***Example:***
|
|
274
|
-
*
|
|
275
|
-
* ```typescript
|
|
276
|
-
* {operationName: 'BehanceAvatar'}
|
|
277
|
-
* ```
|
|
278
|
-
*/
|
|
279
|
-
operationName?: string;
|
|
280
|
-
/**
|
|
281
|
-
* Number indicating how many fetch attempts should be made using exponential backoff.
|
|
282
|
-
*/
|
|
283
|
-
maxRetries?: number;
|
|
284
|
-
/**
|
|
285
|
-
* default metadata should be given when you want to override the default metadata which will be passed with every request
|
|
286
|
-
*/
|
|
287
|
-
metadata?: DefaultMetaData;
|
|
288
|
-
/**
|
|
289
|
-
* passed as true if someone wants to call the region specific endpoints directly.
|
|
290
|
-
*/
|
|
291
|
-
regionEnabled?: boolean;
|
|
292
|
-
/**
|
|
293
|
-
* Enable profile based routing
|
|
294
|
-
*/
|
|
295
|
-
routing?: ROUTING;
|
|
296
|
-
/**
|
|
297
|
-
* Pass enum to set headers according to the requirements
|
|
298
|
-
*/
|
|
299
|
-
scope?: FetchScope;
|
|
300
|
-
/**
|
|
301
|
-
* HTTP Status Codes which will prompt a retry. If not provided only network failures
|
|
302
|
-
* will prompt a retry.
|
|
303
|
-
*/
|
|
304
|
-
statusCodesToRetry?: number[];
|
|
305
|
-
/**
|
|
306
|
-
* Number in ms indicating the maximum amount of time taken by the request plus any exponential backoff
|
|
307
|
-
* requests before aborting.
|
|
308
|
-
*/
|
|
309
|
-
totalFetchTime?: number;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* This parameter will be used to specify what headers are automatically added to the API call.
|
|
314
|
-
*/
|
|
315
|
-
export enum FetchScope {
|
|
316
|
-
/**
|
|
317
|
-
* ***none: Minimal scope***
|
|
318
|
-
* No headers are added. Use case: Non authenticated calls.
|
|
319
|
-
*/
|
|
320
|
-
NONE='NONE',
|
|
321
|
-
/**
|
|
322
|
-
* *** auth: Authentication only. Only auth headers will be added: ***
|
|
323
|
-
* authentication: Bearer <TOKEN>
|
|
324
|
-
* x-api-key: exc_app or custom ID provided by SPA configuration
|
|
325
|
-
*/
|
|
326
|
-
AUTH='AUTH',
|
|
327
|
-
/**
|
|
328
|
-
* *** org: Authentication + IMS Org. ***
|
|
329
|
-
* authentication: Bearer <TOKEN>
|
|
330
|
-
* x-api-key: exc_app or custom ID provided by SPA configuration
|
|
331
|
-
* x-gw-ims-org-id: <IMS ORG ID>
|
|
332
|
-
*/
|
|
333
|
-
ORG='ORG',
|
|
334
|
-
/**
|
|
335
|
-
* *** sandbox: Authentication +IMS Org + PALM Sandboxes. ***
|
|
336
|
-
* authentication: Bearer <TOKEN>
|
|
337
|
-
* x-api-key: exc_app or custom ID provided by SPA configuration
|
|
338
|
-
* x-gw-ims-org-id: <IMS ORG ID>
|
|
339
|
-
* x-sandbox-name: <SANDBOX NAME>
|
|
340
|
-
*/
|
|
341
|
-
SANDBOX='SANDBOX',
|
|
342
|
-
/**
|
|
343
|
-
* *** sandbox-plus: additional headers required with sandbox . ***
|
|
344
|
-
* authentication: Bearer <TOKEN>
|
|
345
|
-
* x-api-key: exc_app or custom ID provided by SPA configuration
|
|
346
|
-
* x-gw-ims-org-id: <IMS ORG ID>
|
|
347
|
-
* x-sandbox-name: <SANDBOX NAME>
|
|
348
|
-
* x-sandbox-type: <SANDBOX TYPE>
|
|
349
|
-
* x-sandbox-default: <SANDBOX DEFAULT>
|
|
350
|
-
*/
|
|
351
|
-
SANDBOX_PLUS='SANDBOX_PLUS'
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* Defines the object containing any custom settings that you want to apply to the request. You can
|
|
356
|
-
* also additionally specify the 'auth' parameter to automatically set the Authentication, API key in Headers/Query params.
|
|
357
|
-
*
|
|
358
|
-
* ***Example:***
|
|
359
|
-
*
|
|
360
|
-
* `{auth: 'Header', body: 'xyz', headers: {'Content-Type': 'text/plain'}, method: 'POST'}` or
|
|
361
|
-
* `{auth: 'Header', method: 'GET'}` or
|
|
362
|
-
* `{method: 'GET'}`
|
|
363
|
-
*/
|
|
364
|
-
export type FetchInit = RequestInit & FetchOptions;
|
|
365
|
-
|
|
366
|
-
export interface ApolloClientOptions {
|
|
367
|
-
connectToDevTools?: boolean;
|
|
368
|
-
inputApolloLink?: ApolloLink;
|
|
369
|
-
cacheOptions?: InMemoryCacheConfig;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
export interface NetworkApi {
|
|
373
|
-
/**
|
|
374
|
-
* Provides an interface for fetching resources powered by the global 'fetch' API.
|
|
375
|
-
*
|
|
376
|
-
* ***Example:***
|
|
377
|
-
*
|
|
378
|
-
* ```typescript
|
|
379
|
-
* // performs a window.fetch call
|
|
380
|
-
* let response = await fetch('https://example.com/api/ping');
|
|
381
|
-
*
|
|
382
|
-
* // performs a window.fetch call with Authorization and x-api-key headers set
|
|
383
|
-
* response = await fetch('https://localhost', {auth: 'Header', method: 'GET'});
|
|
384
|
-
*
|
|
385
|
-
* // performs a window.fetch call with user_token and client_id query parameters added to the URL
|
|
386
|
-
* const request = new Request('https://localhost', {
|
|
387
|
-
* body: JSON.stringify({k: 'v'}),
|
|
388
|
-
* headers: new Headers(),
|
|
389
|
-
* method: 'POST'
|
|
390
|
-
* });
|
|
391
|
-
* response = await fetch(request, {auth: 'Header'});
|
|
392
|
-
* ```
|
|
393
|
-
* @param input The resource that you wish to fetch. It can either be the URL of the resource
|
|
394
|
-
* you want to fetch or a Request object.
|
|
395
|
-
* @param init An object containing any custom settings that you want to apply to the request.
|
|
396
|
-
* @returns The promise for the response to the fetch operation.
|
|
397
|
-
*/
|
|
398
|
-
fetch(input: RequestInfo, init?: FetchInit): Promise<Response>;
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
* Provides an interface for querying resources via GraphqQL.
|
|
402
|
-
* In order to consume query, please make sure the respective query resolver is
|
|
403
|
-
* available in the GraphQL Service.
|
|
404
|
-
*
|
|
405
|
-
* ***Example:***
|
|
406
|
-
*
|
|
407
|
-
* ```typescript
|
|
408
|
-
* const BEHANCE_QUERY = `
|
|
409
|
-
* query userBehanceQuery($userId: String!, $apiKey: String!) {
|
|
410
|
-
* userBehance(userId: $userId, apiKey: $apiKey) {
|
|
411
|
-
* images
|
|
412
|
-
* }
|
|
413
|
-
* }`;
|
|
414
|
-
*
|
|
415
|
-
* // queries the respective resource via GraphQL and returns HTTP Response {ok: true, status: 200, ...}
|
|
416
|
-
* query({data: {query: BEHANCE_QUERY, variables: {
|
|
417
|
-
* userId: '123@AdobeID',
|
|
418
|
-
* apiKey: 'test-app',
|
|
419
|
-
* }}, operationName: 'BehanceAvatar'});
|
|
420
|
-
*
|
|
421
|
-
* // queries the respective resource via GraphQL and returns HTTP Response {ok: true, status: 200, ...}
|
|
422
|
-
* query({data: {query: `
|
|
423
|
-
* query userBehanceQuery {
|
|
424
|
-
* userBehance(userId: "123@AdobeID", apiKey: "test-app") {
|
|
425
|
-
* images
|
|
426
|
-
* }
|
|
427
|
-
* }`
|
|
428
|
-
* }});
|
|
429
|
-
* ```
|
|
430
|
-
* @param request Query request containing desired GQL Query.
|
|
431
|
-
* @returns The promise for the response to the query operation.
|
|
432
|
-
*/
|
|
433
|
-
query(request: QueryRequest): Promise<Response>;
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
* Provides an interface for querying resources via GraphqQL using ApolloClient
|
|
437
|
-
* ***Example***
|
|
438
|
-
* ```typescript
|
|
439
|
-
* const apolloClientModule = await getApolloClient();
|
|
440
|
-
* const apolloClient = apolloClientModule.apolloClient;
|
|
441
|
-
* const gql = apolloClientModule.gql;
|
|
442
|
-
* const result = await apolloClient.query({
|
|
443
|
-
* query: gql`query user {
|
|
444
|
-
* id
|
|
445
|
-
* name
|
|
446
|
-
* }`,
|
|
447
|
-
* variables : {}
|
|
448
|
-
* });
|
|
449
|
-
* console.log(result.data);
|
|
450
|
-
* ```
|
|
451
|
-
* @param options Configuration to create ApolloClient instance
|
|
452
|
-
*
|
|
453
|
-
* @returns GraphQL query response
|
|
454
|
-
*
|
|
455
|
-
*/
|
|
456
|
-
getApolloClient(options?:ApolloClientOptions): Promise<{
|
|
457
|
-
apolloClient: ApolloClient<InMemoryCache>;
|
|
458
|
-
gql: typeof gql;
|
|
459
|
-
}>;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
/**
|
|
463
|
-
* Provides an interface for fetching resources powered by the global 'fetch' API.
|
|
464
|
-
*
|
|
465
|
-
* ***Example:***
|
|
466
|
-
*
|
|
467
|
-
* ```typescript
|
|
468
|
-
* // performs a window.fetch call
|
|
469
|
-
* let response = await fetch('https://example.com/api/ping');
|
|
470
|
-
*
|
|
471
|
-
* // performs a window.fetch call with Authorization and x-api-key headers set
|
|
472
|
-
* response = await fetch('https://localhost', {auth: 'Header', method: 'GET'});
|
|
473
|
-
*
|
|
474
|
-
* // performs a window.fetch call with user_token and client_id query parameters added to the URL
|
|
475
|
-
* const request = new Request('https://localhost', {
|
|
476
|
-
* body: JSON.stringify({k: 'v'}),
|
|
477
|
-
* headers: new Headers(),
|
|
478
|
-
* method: 'POST'
|
|
479
|
-
* });
|
|
480
|
-
* response = await fetch(request, {auth: 'Header'});
|
|
481
|
-
* ```
|
|
482
|
-
* @param input The resource that you wish to fetch. It can either be the URL of the resource you
|
|
483
|
-
* want to fetch or a Request object.
|
|
484
|
-
* @param init An object containing any custom settings that you want to apply to the request.
|
|
485
|
-
* @returns The promise for the response to the fetch operation.
|
|
486
|
-
*/
|
|
487
|
-
export function fetch(input: RequestInfo, init?: FetchInit): Promise<Response> {
|
|
488
|
-
return getImpl('network').fetch(input, init);
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
/**
|
|
492
|
-
* Provides an interface for querying resources via GraphqQL.
|
|
493
|
-
* In order to consume query, please make sure the respective query resolver is
|
|
494
|
-
* available in the GraphQL Service.
|
|
495
|
-
* ***Example:***
|
|
496
|
-
*
|
|
497
|
-
* ```typescript
|
|
498
|
-
* const BEHANCE_QUERY = `
|
|
499
|
-
* query userBehanceQuery($userId: String!, $apiKey: String!) {
|
|
500
|
-
* userBehance(userId: $userId, apiKey: $apiKey) {
|
|
501
|
-
* images
|
|
502
|
-
* }
|
|
503
|
-
* }`;
|
|
504
|
-
*
|
|
505
|
-
* // queries the respective resource via GraphQL and returns HTTP Response {ok: true, status: 200, ...}
|
|
506
|
-
* query({data: {query: BEHANCE_QUERY, variables: {
|
|
507
|
-
* userId: '123@AdobeID',
|
|
508
|
-
* apiKey: 'test-app',
|
|
509
|
-
* }}, operationName: 'BehanceAvatar'});
|
|
510
|
-
*
|
|
511
|
-
* // queries the respective resource via GraphQL and returns HTTP Response {ok: true, status: 200, ...}
|
|
512
|
-
* query({data: {query: `
|
|
513
|
-
* query userBehanceQuery {
|
|
514
|
-
* userBehance(userId: "123@AdobeID", apiKey: "test-app") {
|
|
515
|
-
* images
|
|
516
|
-
* }
|
|
517
|
-
* }`
|
|
518
|
-
* }});
|
|
519
|
-
* ```
|
|
520
|
-
* @param input Query request containing desired GQL Query.
|
|
521
|
-
* @returns The promise for the response to the query operation.
|
|
522
|
-
*/
|
|
523
|
-
export function query(input: QueryRequest): Promise<Response> {
|
|
524
|
-
return getImpl('network').query(input);
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
/**
|
|
528
|
-
* Provides an interface for querying resources via GraphqQL using ApolloClient
|
|
529
|
-
* ***Example***
|
|
530
|
-
* ```typescript
|
|
531
|
-
* const apolloClientModule = await getApolloClient();
|
|
532
|
-
* const apolloClient = apolloClientModule.apolloClient;
|
|
533
|
-
* const gql = apolloClientModule.gql;
|
|
534
|
-
* const result = await apolloClient.query({
|
|
535
|
-
* query: gql`query user {
|
|
536
|
-
* id
|
|
537
|
-
* name
|
|
538
|
-
* }`,
|
|
539
|
-
* variables : {}
|
|
540
|
-
* });
|
|
541
|
-
* console.log(result.data);
|
|
542
|
-
* ```
|
|
543
|
-
* @param options Configuration to create ApolloClient instance
|
|
544
|
-
* @returns GraphQL query response
|
|
545
|
-
*
|
|
546
|
-
*/
|
|
547
|
-
export function getApolloClient(
|
|
548
|
-
options?: ApolloClientOptions
|
|
549
|
-
): Promise<{
|
|
550
|
-
apolloClient: ApolloClient<InMemoryCache>;
|
|
551
|
-
gql: typeof gql;
|
|
552
|
-
}> {
|
|
553
|
-
return getImpl('network').getApolloClient(options);
|
|
554
|
-
}
|
package/nps.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/*************************************************************************
|
|
2
|
-
* Copyright 2020 Adobe
|
|
3
|
-
* All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* NOTICE: Adobe permits you to use, modify, and distribute this file in
|
|
6
|
-
* accordance with the terms of the Adobe license agreement accompanying
|
|
7
|
-
* it. If you have received this file from a source other than Adobe,
|
|
8
|
-
* then your use, modification, or distribution of it requires the prior
|
|
9
|
-
* written permission of Adobe.
|
|
10
|
-
**************************************************************************/
|
|
11
|
-
/**
|
|
12
|
-
* APIs that let solutions interact with the NPS (Net Promoter Score) widget component, the interface for recording user experience within a specific solution.
|
|
13
|
-
*
|
|
14
|
-
* ***Import:***
|
|
15
|
-
*
|
|
16
|
-
* ```typescript
|
|
17
|
-
* import nps from '@adobe/exc-app/nps';
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* ***Default export:***
|
|
21
|
-
*
|
|
22
|
-
* [NpsApi](../interfaces/nps.npsapi.md#interface-npsapi)
|
|
23
|
-
*
|
|
24
|
-
* ***Usage:***
|
|
25
|
-
*
|
|
26
|
-
* ```typescript
|
|
27
|
-
* import nps from '@adobe/exc-app/nps';
|
|
28
|
-
*
|
|
29
|
-
* nps.config = {
|
|
30
|
-
* enabled: true,
|
|
31
|
-
* sampling: 20,
|
|
32
|
-
* showToAdobeUsers: false
|
|
33
|
-
* };
|
|
34
|
-
* ```
|
|
35
|
-
* @packageDocumentation
|
|
36
|
-
* @module nps
|
|
37
|
-
*/
|
|
38
|
-
import {connect} from './src/Global';
|
|
39
|
-
|
|
40
|
-
export interface NpsApiProperties {
|
|
41
|
-
/**
|
|
42
|
-
* An object of nps configuration attributes for solution.
|
|
43
|
-
* By default the NPS widget is disabled. In order to enable NPS for a solution, the enabled key in the solution configuration should be set to true.
|
|
44
|
-
* NPS configuration also contains a sampling key which describes the percentage of users that will see the NPS widget.
|
|
45
|
-
* Whether NPS will be shown to Adobe users depends of the value of 'showToAdobeUsers' key. It is set to true by default.
|
|
46
|
-
*/
|
|
47
|
-
config: {
|
|
48
|
-
/**
|
|
49
|
-
* Flag that enables nps for solution.
|
|
50
|
-
*/
|
|
51
|
-
readonly enabled?: boolean;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Number that shows percent of user logins that can show nps.
|
|
55
|
-
*/
|
|
56
|
-
readonly sampling?: number;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Flag that enables showing nps survey to adobe users.
|
|
60
|
-
*/
|
|
61
|
-
readonly showToAdobeUsers?: boolean;
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Defines Nps widget APIs available to solutions.
|
|
67
|
-
*/
|
|
68
|
-
export interface Nps extends NpsApiProperties {
|
|
69
|
-
/**
|
|
70
|
-
* Triggers calculations to evaluate whether to display NPS survey to the user
|
|
71
|
-
* and then render the NPS widget if so.
|
|
72
|
-
*
|
|
73
|
-
* ```typescript
|
|
74
|
-
* nps.triggerNps();
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
triggerNps(): void;
|
|
78
|
-
}
|
|
79
|
-
const nps = connect('nps', [
|
|
80
|
-
['config'],
|
|
81
|
-
['triggerNps', true]
|
|
82
|
-
]);
|
|
83
|
-
export default nps;
|