@adobe/exc-app 1.0.4 → 1.0.7
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/appapi.d.ts +0 -1
- package/appapi.js +0 -1
- package/appapi.js.map +1 -1
- package/coverage/lcov-report/block-navigation.js +79 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sorter.js +170 -0
- package/docs/enums/appapi.appids.md +7 -7
- package/docs/enums/network.standardvariables.md +24 -0
- package/docs/interfaces/network.datadedupconfig.md +32 -0
- package/docs/interfaces/network.dataprefetchcontract.md +129 -0
- package/docs/interfaces/network.fetchcondition.md +27 -0
- package/docs/interfaces/network.graphqlquery.md +2 -0
- package/docs/interfaces/network.networkapi.md +29 -0
- package/docs/interfaces/network.prefetchoptions.md +34 -0
- package/docs/interfaces/network.querydefinition.md +100 -0
- package/docs/interfaces/root.runtimeconfiguration.md +9 -0
- package/docs/interfaces/shell.shellinfo.md +7 -0
- package/docs/modules/network.md +55 -0
- package/network/DataContract.d.ts +35 -0
- package/network/DataContract.js +3 -0
- package/network/DataContract.js.map +1 -0
- package/network/DataPrefetchContract.d.ts +150 -0
- package/network/DataPrefetchContract.js +14 -0
- package/network/DataPrefetchContract.js.map +1 -0
- package/network.d.ts +39 -0
- package/network.js +15 -1
- package/network.js.map +1 -1
- package/package.json +3 -4
- package/sidenav.d.ts +2 -2
- package/tests/network.test.js +10 -0
- package/tests/network.test.js.map +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
**[@adobe/exc-app](../README.md)**
|
|
2
|
+
|
|
3
|
+
> [Globals](../README.md) / [network](../modules/network.md) / QueryDefinition
|
|
4
|
+
|
|
5
|
+
# Interface: QueryDefinition
|
|
6
|
+
|
|
7
|
+
Defines a GraphQL query that will be executed to fetch the data exposed by this contract.
|
|
8
|
+
|
|
9
|
+
## Hierarchy
|
|
10
|
+
|
|
11
|
+
* [GraphQLQuery](network.graphqlquery.md)
|
|
12
|
+
|
|
13
|
+
↳ **QueryDefinition**
|
|
14
|
+
|
|
15
|
+
## Index
|
|
16
|
+
|
|
17
|
+
### Properties
|
|
18
|
+
|
|
19
|
+
* [dataPath](network.querydefinition.md#datapath)
|
|
20
|
+
* [fetchScope](network.querydefinition.md#fetchscope)
|
|
21
|
+
* [ignoreErrorsOnPaths](network.querydefinition.md#ignoreerrorsonpaths)
|
|
22
|
+
* [query](network.querydefinition.md#query)
|
|
23
|
+
* [variables](network.querydefinition.md#variables)
|
|
24
|
+
|
|
25
|
+
## Properties
|
|
26
|
+
|
|
27
|
+
### dataPath
|
|
28
|
+
|
|
29
|
+
• `Optional` **dataPath**: undefined \| string
|
|
30
|
+
|
|
31
|
+
When provided, the data at the certain path will be returned.
|
|
32
|
+
If not provided, the entire GraphQL response will be returned.
|
|
33
|
+
|
|
34
|
+
___
|
|
35
|
+
|
|
36
|
+
### fetchScope
|
|
37
|
+
|
|
38
|
+
• **fetchScope**: [FetchScope](../enums/network.fetchscope.md)
|
|
39
|
+
|
|
40
|
+
Fetch scope. Controls which headers are sent with the query.
|
|
41
|
+
See fetch documentation for more info.
|
|
42
|
+
|
|
43
|
+
___
|
|
44
|
+
|
|
45
|
+
### ignoreErrorsOnPaths
|
|
46
|
+
|
|
47
|
+
• `Optional` **ignoreErrorsOnPaths**: string[]
|
|
48
|
+
|
|
49
|
+
Do not fail (throw) when encountering errors while processing the query if the errors
|
|
50
|
+
happened on certain paths.
|
|
51
|
+
|
|
52
|
+
___
|
|
53
|
+
|
|
54
|
+
### query
|
|
55
|
+
|
|
56
|
+
• **query**: string
|
|
57
|
+
|
|
58
|
+
*Inherited from [GraphQLQuery](network.graphqlquery.md).[query](network.graphqlquery.md#query)*
|
|
59
|
+
|
|
60
|
+
GQL Query.
|
|
61
|
+
|
|
62
|
+
***Example:***
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
{query: `
|
|
66
|
+
query userBehanceQuery($userId: String!, $apiKey: String!) {
|
|
67
|
+
userBehance(userId: $userId, apiKey: $apiKey) {
|
|
68
|
+
images
|
|
69
|
+
}
|
|
70
|
+
}`
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
{query: `
|
|
74
|
+
query userBehanceQuery {
|
|
75
|
+
userBehance(userId: "123@AdobeID", apiKey: "test-app") {
|
|
76
|
+
images
|
|
77
|
+
}
|
|
78
|
+
}`
|
|
79
|
+
};
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
___
|
|
83
|
+
|
|
84
|
+
### variables
|
|
85
|
+
|
|
86
|
+
• `Optional` **variables**: Record<string, any\>
|
|
87
|
+
|
|
88
|
+
*Inherited from [GraphQLQuery](network.graphqlquery.md).[variables](network.graphqlquery.md#variables)*
|
|
89
|
+
|
|
90
|
+
Query specific variables- key value pairs.
|
|
91
|
+
|
|
92
|
+
***Example:***
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
{variables: {
|
|
96
|
+
apiKey: 'test-app',
|
|
97
|
+
userId: '123@AdobeID'
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
```
|
|
@@ -21,6 +21,7 @@ External Runtime Configuration Interface
|
|
|
21
21
|
* [baseFrameUrl](root.runtimeconfiguration.md#baseframeurl)
|
|
22
22
|
* [basePath](root.runtimeconfiguration.md#basepath)
|
|
23
23
|
* [baseUrl](root.runtimeconfiguration.md#baseurl)
|
|
24
|
+
* [cdn](root.runtimeconfiguration.md#cdn)
|
|
24
25
|
* [changedProperties](root.runtimeconfiguration.md#changedproperties)
|
|
25
26
|
* [discovery](root.runtimeconfiguration.md#discovery)
|
|
26
27
|
* [environment](root.runtimeconfiguration.md#environment)
|
|
@@ -117,6 +118,14 @@ Base URL
|
|
|
117
118
|
|
|
118
119
|
___
|
|
119
120
|
|
|
121
|
+
### cdn
|
|
122
|
+
|
|
123
|
+
• **cdn**: string
|
|
124
|
+
|
|
125
|
+
Environment specific CDN string.
|
|
126
|
+
|
|
127
|
+
___
|
|
128
|
+
|
|
120
129
|
### changedProperties
|
|
121
130
|
|
|
122
131
|
• **changedProperties**: keyof [RuntimeConfiguration](root.runtimeconfiguration.md)[]
|
|
@@ -12,12 +12,19 @@
|
|
|
12
12
|
|
|
13
13
|
### Properties
|
|
14
14
|
|
|
15
|
+
* [cdn](shell.shellinfo.md#cdn)
|
|
15
16
|
* [environment](shell.shellinfo.md#environment)
|
|
16
17
|
* [imsEnvironment](shell.shellinfo.md#imsenvironment)
|
|
17
18
|
* [shellInfo](shell.shellinfo.md#shellinfo)
|
|
18
19
|
|
|
19
20
|
## Properties
|
|
20
21
|
|
|
22
|
+
### cdn
|
|
23
|
+
|
|
24
|
+
• **cdn**: string
|
|
25
|
+
|
|
26
|
+
___
|
|
27
|
+
|
|
21
28
|
### environment
|
|
22
29
|
|
|
23
30
|
• **environment**: string
|
package/docs/modules/network.md
CHANGED
|
@@ -50,29 +50,38 @@ const queryResponse = await query({
|
|
|
50
50
|
|
|
51
51
|
* [FetchScope](../enums/network.fetchscope.md)
|
|
52
52
|
* [ROUTING](../enums/network.routing.md)
|
|
53
|
+
* [StandardVariables](../enums/network.standardvariables.md)
|
|
53
54
|
|
|
54
55
|
### Interfaces
|
|
55
56
|
|
|
56
57
|
* [ApolloClientOptions](../interfaces/network.apolloclientoptions.md)
|
|
58
|
+
* [DataDedupConfig](../interfaces/network.datadedupconfig.md)
|
|
59
|
+
* [DataPrefetchContract](../interfaces/network.dataprefetchcontract.md)
|
|
57
60
|
* [DefaultMetaData](../interfaces/network.defaultmetadata.md)
|
|
61
|
+
* [FetchCondition](../interfaces/network.fetchcondition.md)
|
|
58
62
|
* [FetchOptions](../interfaces/network.fetchoptions.md)
|
|
59
63
|
* [GraphQLQuery](../interfaces/network.graphqlquery.md)
|
|
60
64
|
* [NetworkApi](../interfaces/network.networkapi.md)
|
|
65
|
+
* [PrefetchOptions](../interfaces/network.prefetchoptions.md)
|
|
66
|
+
* [QueryDefinition](../interfaces/network.querydefinition.md)
|
|
61
67
|
* [QueryRequest](../interfaces/network.queryrequest.md)
|
|
62
68
|
|
|
63
69
|
### Type aliases
|
|
64
70
|
|
|
65
71
|
* [FetchInit](network.md#fetchinit)
|
|
66
72
|
* [GraphQLRegion](network.md#graphqlregion)
|
|
73
|
+
* [PrefetchResponse](network.md#prefetchresponse)
|
|
67
74
|
|
|
68
75
|
### Variables
|
|
69
76
|
|
|
70
77
|
* [DEFAULT\_STATUS\_CODES\_TO\_RETRY](network.md#default_status_codes_to_retry)
|
|
78
|
+
* [FRESH\_MS](network.md#fresh_ms)
|
|
71
79
|
|
|
72
80
|
### Functions
|
|
73
81
|
|
|
74
82
|
* [fetch](network.md#fetch)
|
|
75
83
|
* [getApolloClient](network.md#getapolloclient)
|
|
84
|
+
* [getPrefetched](network.md#getprefetched)
|
|
76
85
|
* [query](network.md#query)
|
|
77
86
|
|
|
78
87
|
## Type aliases
|
|
@@ -96,6 +105,18 @@ ___
|
|
|
96
105
|
|
|
97
106
|
Ƭ **GraphQLRegion**: \"va7\" \| \"aus5\" \| \"nld2\"
|
|
98
107
|
|
|
108
|
+
___
|
|
109
|
+
|
|
110
|
+
### PrefetchResponse
|
|
111
|
+
|
|
112
|
+
Ƭ **PrefetchResponse**<T\>: [CacheEntry](cache.md#cacheentry)<T\> & { getFresh?: undefined \| () => Promise<[PrefetchResponse](network.md#prefetchresponse)<T\>\> }
|
|
113
|
+
|
|
114
|
+
#### Type parameters:
|
|
115
|
+
|
|
116
|
+
Name |
|
|
117
|
+
------ |
|
|
118
|
+
`T` |
|
|
119
|
+
|
|
99
120
|
## Variables
|
|
100
121
|
|
|
101
122
|
### DEFAULT\_STATUS\_CODES\_TO\_RETRY
|
|
@@ -104,6 +125,12 @@ ___
|
|
|
104
125
|
|
|
105
126
|
Default status codes which imply a transient error and can be retried.
|
|
106
127
|
|
|
128
|
+
___
|
|
129
|
+
|
|
130
|
+
### FRESH\_MS
|
|
131
|
+
|
|
132
|
+
• `Const` **FRESH\_MS**: number = 60 * 1000
|
|
133
|
+
|
|
107
134
|
## Functions
|
|
108
135
|
|
|
109
136
|
### fetch
|
|
@@ -175,6 +202,34 @@ GraphQL query response
|
|
|
175
202
|
|
|
176
203
|
___
|
|
177
204
|
|
|
205
|
+
### getPrefetched
|
|
206
|
+
|
|
207
|
+
▸ **getPrefetched**<T\>(`key`: string, `options?`: [PrefetchOptions](../interfaces/network.prefetchoptions.md)): Promise<[PrefetchResponse](network.md#prefetchresponse)<T\>\>
|
|
208
|
+
|
|
209
|
+
Provides an interface for querying known data.
|
|
210
|
+
Data querying and caching are managed in Unified Shell in advance.
|
|
211
|
+
|
|
212
|
+
This is an experimental feature.
|
|
213
|
+
|
|
214
|
+
#### Type parameters:
|
|
215
|
+
|
|
216
|
+
Name |
|
|
217
|
+
------ |
|
|
218
|
+
`T` |
|
|
219
|
+
|
|
220
|
+
#### Parameters:
|
|
221
|
+
|
|
222
|
+
Name | Type | Description |
|
|
223
|
+
------ | ------ | ------ |
|
|
224
|
+
`key` | string | Data Contract key |
|
|
225
|
+
`options?` | [PrefetchOptions](../interfaces/network.prefetchoptions.md) | Prefetch options |
|
|
226
|
+
|
|
227
|
+
**Returns:** Promise<[PrefetchResponse](network.md#prefetchresponse)<T\>\>
|
|
228
|
+
|
|
229
|
+
Promise for the contract execution response
|
|
230
|
+
|
|
231
|
+
___
|
|
232
|
+
|
|
178
233
|
### query
|
|
179
234
|
|
|
180
235
|
▸ **query**(`input`: [QueryRequest](../interfaces/network.queryrequest.md)): Promise<Response\>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*************************************************************************
|
|
2
|
+
* Copyright 2022 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
|
+
import { CacheExpiry, CacheScope } from '../cache';
|
|
12
|
+
import { FetchScope } from '../network';
|
|
13
|
+
export interface FetchCondition {
|
|
14
|
+
serviceCodes?: string | string[];
|
|
15
|
+
}
|
|
16
|
+
export interface QueryContract<V> {
|
|
17
|
+
fetchScope: FetchScope;
|
|
18
|
+
ignoreErrorsOnPaths?: string[];
|
|
19
|
+
query: string;
|
|
20
|
+
root?: string;
|
|
21
|
+
variables: V;
|
|
22
|
+
}
|
|
23
|
+
interface DataContract<T, V = undefined> {
|
|
24
|
+
defaultValue: T;
|
|
25
|
+
expiry: CacheExpiry;
|
|
26
|
+
fetchWhen?: FetchCondition;
|
|
27
|
+
gql?: QueryContract<V>;
|
|
28
|
+
isSensitive: boolean;
|
|
29
|
+
key: string;
|
|
30
|
+
revalidate: boolean;
|
|
31
|
+
revalidateAfterSec?: number;
|
|
32
|
+
scope: CacheScope;
|
|
33
|
+
shared: boolean;
|
|
34
|
+
}
|
|
35
|
+
export default DataContract;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataContract.js","sourceRoot":"","sources":["DataContract.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/*************************************************************************
|
|
2
|
+
* Copyright 2022 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
|
+
import { CacheExpiry, CacheScope } from '../cache';
|
|
12
|
+
import { FetchScope, GraphQLQuery } from '../network';
|
|
13
|
+
/**
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
* @module network
|
|
16
|
+
*/
|
|
17
|
+
export declare const FRESH_MS: number;
|
|
18
|
+
export declare enum StandardVariables {
|
|
19
|
+
ACP_FD = "acpFulfillableData",
|
|
20
|
+
CACHED_TS = "cached.createdAt"
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Defines the conditions when certain data can be fetched.
|
|
24
|
+
* When conditions are not met, default data will be returned but not cached.
|
|
25
|
+
*/
|
|
26
|
+
export interface FetchCondition {
|
|
27
|
+
/**
|
|
28
|
+
* Service Codes that needs to be present (For the current org) in order to execute the query.
|
|
29
|
+
* This is useful when a query only makes sense if a certain product is provisioned for the current user.
|
|
30
|
+
*/
|
|
31
|
+
serviceCodes?: string | string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Defines a GraphQL query that will be executed to fetch the data exposed by this contract.
|
|
35
|
+
*/
|
|
36
|
+
export interface QueryDefinition extends GraphQLQuery {
|
|
37
|
+
/**
|
|
38
|
+
* When provided, the data at the certain path will be returned.
|
|
39
|
+
* If not provided, the entire GraphQL response will be returned.
|
|
40
|
+
*/
|
|
41
|
+
dataPath?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Fetch scope. Controls which headers are sent with the query.
|
|
44
|
+
* See fetch documentation for more info.
|
|
45
|
+
*/
|
|
46
|
+
fetchScope: FetchScope;
|
|
47
|
+
/**
|
|
48
|
+
* Do not fail (throw) when encountering errors while processing the query if the errors
|
|
49
|
+
* happened on certain paths.
|
|
50
|
+
*/
|
|
51
|
+
ignoreErrorsOnPaths?: string[];
|
|
52
|
+
}
|
|
53
|
+
export interface DataDedupConfig {
|
|
54
|
+
/**
|
|
55
|
+
* An array of elements that needs to be merged and deduped across fresh and cached data.
|
|
56
|
+
*/
|
|
57
|
+
arrayElement: string;
|
|
58
|
+
/**
|
|
59
|
+
* A key that will be used to deduplicate the array element.
|
|
60
|
+
*/
|
|
61
|
+
keyField: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Defines a data contract which will be executed by Unified Shell on behalf ot the requesting application.
|
|
65
|
+
*/
|
|
66
|
+
export default interface DataPrefetchContract<T> {
|
|
67
|
+
/**
|
|
68
|
+
* Default value to return if the data execution is skipped.
|
|
69
|
+
*/
|
|
70
|
+
defaultValue: T;
|
|
71
|
+
/**
|
|
72
|
+
* Cache expiry. Can be one of the set values defined by the Cache API, or a numeric cache ttl (in seconds).
|
|
73
|
+
*/
|
|
74
|
+
expiry: CacheExpiry;
|
|
75
|
+
/**
|
|
76
|
+
* Defines the conditions when certain data can be fetched.
|
|
77
|
+
* When conditions are not met, the default value above will be returned (But not cached).
|
|
78
|
+
*/
|
|
79
|
+
fetchWhen?: FetchCondition;
|
|
80
|
+
/**
|
|
81
|
+
* GraphQL used to fulfill this data contract.
|
|
82
|
+
* Note: Currently GraphQL is the only supported method for data contracts.
|
|
83
|
+
*/
|
|
84
|
+
gql?: QueryDefinition;
|
|
85
|
+
/**
|
|
86
|
+
* Is the data sensitive? (PII or other sensitive data).
|
|
87
|
+
* Sensitive data can only be cached in the browser's session storage
|
|
88
|
+
* Non-sensitive data can be cached in the standard Cache storage.
|
|
89
|
+
*/
|
|
90
|
+
isSensitive: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Unique key associated with this contract.
|
|
93
|
+
* Will be used by the calling application to get access to the data.
|
|
94
|
+
*/
|
|
95
|
+
key: string;
|
|
96
|
+
/**
|
|
97
|
+
* Defines specific behavior for refresh.
|
|
98
|
+
* This is optional, by default refreshing data and fetching new will yield the same results.
|
|
99
|
+
*/
|
|
100
|
+
refreshData?: {
|
|
101
|
+
/**
|
|
102
|
+
* Cached & Fresh Data deduplication and merge configuration.
|
|
103
|
+
*/
|
|
104
|
+
dedup?: DataDedupConfig;
|
|
105
|
+
/**
|
|
106
|
+
* GraphQL query to use for refresh.
|
|
107
|
+
*/
|
|
108
|
+
gql?: QueryDefinition;
|
|
109
|
+
/**
|
|
110
|
+
* An optional array of root level elements that need to be retained from the cached data.
|
|
111
|
+
*/
|
|
112
|
+
keepOriginal?: string[];
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* When true, data will be fetched even when a cache is available.
|
|
116
|
+
* In this case, the query will return the cached data and at the same time fetch fresh data from the network.
|
|
117
|
+
* (stale-while-revalidate strategy)
|
|
118
|
+
*/
|
|
119
|
+
revalidate: {
|
|
120
|
+
/**
|
|
121
|
+
* When true, data will be fetched even when a cache is available.
|
|
122
|
+
* In this case, the query will return the cached data and at the same time fetch fresh data from the network.
|
|
123
|
+
* (stale-while-revalidate strategy)
|
|
124
|
+
*/
|
|
125
|
+
enabled: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* If true, revalidation will be done right away
|
|
128
|
+
* If false, revalidation will be done when the browser is idle
|
|
129
|
+
* (On browsers where requestIdleCallback is supported, otherwise right away)
|
|
130
|
+
* Optional - Defaults to false
|
|
131
|
+
*/
|
|
132
|
+
immediate?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Used in conjunction with revalidate = true. Threshold for revalidating data from the network.
|
|
135
|
+
* When set the query will return the cached data and if the cache is older than the set threshold,
|
|
136
|
+
* fetch fresh data from the network.
|
|
137
|
+
Optional - Defaults to 0 (immediate)
|
|
138
|
+
*/
|
|
139
|
+
revalidateAfterSec?: number;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Cache scope as defined by the Cache API.
|
|
143
|
+
*/
|
|
144
|
+
scope: CacheScope;
|
|
145
|
+
/**
|
|
146
|
+
* If true, this data will be accessible to all experience cloud applications.
|
|
147
|
+
* Otherwise, data will be cached against the requesting application.
|
|
148
|
+
*/
|
|
149
|
+
shared: boolean;
|
|
150
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StandardVariables = exports.FRESH_MS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
* @module network
|
|
7
|
+
*/
|
|
8
|
+
exports.FRESH_MS = 60 * 1000; // One minute.
|
|
9
|
+
var StandardVariables;
|
|
10
|
+
(function (StandardVariables) {
|
|
11
|
+
StandardVariables["ACP_FD"] = "acpFulfillableData";
|
|
12
|
+
StandardVariables["CACHED_TS"] = "cached.createdAt";
|
|
13
|
+
})(StandardVariables = exports.StandardVariables || (exports.StandardVariables = {}));
|
|
14
|
+
//# sourceMappingURL=DataPrefetchContract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataPrefetchContract.js","sourceRoot":"","sources":["DataPrefetchContract.ts"],"names":[],"mappings":";;;AAaA;;;GAGG;AAEU,QAAA,QAAQ,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,cAAc;AAEjD,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,kDAA6B,CAAA;IAC7B,mDAA8B,CAAA;AAChC,CAAC,EAHW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAG5B"}
|
package/network.d.ts
CHANGED
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
* @module network
|
|
53
53
|
*/
|
|
54
54
|
import type { ApolloClient, ApolloLink, InMemoryCache, InMemoryCacheConfig } from '@apollo/client';
|
|
55
|
+
import { CacheEntry } from './cache';
|
|
55
56
|
import type { gql } from 'graphql-tag';
|
|
56
57
|
/**
|
|
57
58
|
* Default status codes which imply a transient error and can be retried.
|
|
@@ -219,6 +220,22 @@ export interface DefaultMetaData {
|
|
|
219
220
|
imsOrg?: string;
|
|
220
221
|
sandbox?: Record<string, any>;
|
|
221
222
|
}
|
|
223
|
+
export declare type PrefetchResponse<T> = CacheEntry<T> & {
|
|
224
|
+
getFresh?: () => Promise<PrefetchResponse<T>>;
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Data prefetch options
|
|
228
|
+
*/
|
|
229
|
+
export interface PrefetchOptions {
|
|
230
|
+
/**
|
|
231
|
+
* Must return recent data - Created after provided time
|
|
232
|
+
*/
|
|
233
|
+
createdAfter?: number;
|
|
234
|
+
/**
|
|
235
|
+
* If returning cached result, revalidate immediatelly.
|
|
236
|
+
*/
|
|
237
|
+
revalidateImmediately?: boolean;
|
|
238
|
+
}
|
|
222
239
|
export declare enum ROUTING {
|
|
223
240
|
/**
|
|
224
241
|
* Route by the AEP region found in the user profile
|
|
@@ -400,6 +417,17 @@ export interface NetworkApi {
|
|
|
400
417
|
* @returns The promise for the response to the fetch operation.
|
|
401
418
|
*/
|
|
402
419
|
fetch(input: RequestInfo, init?: FetchInit): Promise<Response>;
|
|
420
|
+
/**
|
|
421
|
+
* Provides an interface for querying known data.
|
|
422
|
+
* Data querying and caching are managed in Unified Shell in advance.
|
|
423
|
+
*
|
|
424
|
+
* This is an experimental feature.
|
|
425
|
+
* @template T
|
|
426
|
+
* @param key - Data Contract key
|
|
427
|
+
* @param options - Prefetch options
|
|
428
|
+
* @returns Promise for the contract execution response
|
|
429
|
+
*/
|
|
430
|
+
getPrefetched<T>(key: string, options?: PrefetchOptions): Promise<PrefetchResponse<T>>;
|
|
403
431
|
/**
|
|
404
432
|
* Provides an interface for querying resources via GraphqQL.
|
|
405
433
|
* In order to consume query, please make sure the respective query resolver is
|
|
@@ -486,6 +514,17 @@ export interface NetworkApi {
|
|
|
486
514
|
* @returns The promise for the response to the fetch operation.
|
|
487
515
|
*/
|
|
488
516
|
export declare function fetch(input: RequestInfo, init?: FetchInit): Promise<Response>;
|
|
517
|
+
/**
|
|
518
|
+
* Provides an interface for querying known data.
|
|
519
|
+
* Data querying and caching are managed in Unified Shell in advance.
|
|
520
|
+
*
|
|
521
|
+
* This is an experimental feature.
|
|
522
|
+
* @template T
|
|
523
|
+
* @param key - Data Contract key
|
|
524
|
+
* @param options - Prefetch options
|
|
525
|
+
* @returns Promise for the contract execution response
|
|
526
|
+
*/
|
|
527
|
+
export declare function getPrefetched<T>(key: string, options?: PrefetchOptions): Promise<PrefetchResponse<T>>;
|
|
489
528
|
/**
|
|
490
529
|
* Provides an interface for querying resources via GraphqQL.
|
|
491
530
|
* In order to consume query, please make sure the respective query resolver is
|
package/network.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* written permission of Adobe.
|
|
11
11
|
**************************************************************************/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.getApolloClient = exports.query = exports.fetch = exports.FetchScope = exports.ROUTING = exports.DEFAULT_STATUS_CODES_TO_RETRY = void 0;
|
|
13
|
+
exports.getApolloClient = exports.query = exports.getPrefetched = exports.fetch = exports.FetchScope = exports.ROUTING = exports.DEFAULT_STATUS_CODES_TO_RETRY = void 0;
|
|
14
14
|
const Global_1 = require("./src/Global");
|
|
15
15
|
/**
|
|
16
16
|
* Default status codes which imply a transient error and can be retried.
|
|
@@ -102,6 +102,20 @@ function fetch(input, init) {
|
|
|
102
102
|
return Global_1.getImpl('network').fetch(input, init);
|
|
103
103
|
}
|
|
104
104
|
exports.fetch = fetch;
|
|
105
|
+
/**
|
|
106
|
+
* Provides an interface for querying known data.
|
|
107
|
+
* Data querying and caching are managed in Unified Shell in advance.
|
|
108
|
+
*
|
|
109
|
+
* This is an experimental feature.
|
|
110
|
+
* @template T
|
|
111
|
+
* @param key - Data Contract key
|
|
112
|
+
* @param options - Prefetch options
|
|
113
|
+
* @returns Promise for the contract execution response
|
|
114
|
+
*/
|
|
115
|
+
function getPrefetched(key, options) {
|
|
116
|
+
return Global_1.getImpl('network').getPrefetched(key, options);
|
|
117
|
+
}
|
|
118
|
+
exports.getPrefetched = getPrefetched;
|
|
105
119
|
/**
|
|
106
120
|
* Provides an interface for querying resources via GraphqQL.
|
|
107
121
|
* In order to consume query, please make sure the respective query resolver is
|
package/network.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.js","sourceRoot":"","sources":["network.ts"],"names":[],"mappings":";AAAA;;;;;;;;;4EAS4E;;;
|
|
1
|
+
{"version":3,"file":"network.js","sourceRoot":"","sources":["network.ts"],"names":[],"mappings":";AAAA;;;;;;;;;4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AO,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AACrD,CAAC;AAPD,0CAOC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/exc-app",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"source": "index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -26,15 +26,14 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@apollo/client": "3.5.7",
|
|
29
|
-
"graphql": "
|
|
29
|
+
"graphql": "15.5.3",
|
|
30
30
|
"graphql-tag": "2.12.6"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"cross-env": "7.0.3",
|
|
34
|
-
"enzyme": "3.11.0",
|
|
35
34
|
"eslint": "8.1.0",
|
|
36
35
|
"eslint-plugin-header": "3.1.1",
|
|
37
|
-
"eslint-plugin-jsdoc": "
|
|
36
|
+
"eslint-plugin-jsdoc": "36.1.1",
|
|
38
37
|
"eslint-plugin-prettier": "4.0.0",
|
|
39
38
|
"eslint-plugin-rulesdir": "0.2.1",
|
|
40
39
|
"glob": "7.1.7",
|
package/sidenav.d.ts
CHANGED
|
@@ -204,7 +204,7 @@ export interface SidenavApi extends EventEmitter<SidenavInfoEvent> {
|
|
|
204
204
|
*/
|
|
205
205
|
config?: NavConfig;
|
|
206
206
|
/**
|
|
207
|
-
*
|
|
207
|
+
* Boolean representing whether the sidenav drawer is presently open or closed.
|
|
208
208
|
*
|
|
209
209
|
* ***Example:***
|
|
210
210
|
*
|
|
@@ -219,7 +219,7 @@ export interface SidenavApi extends EventEmitter<SidenavInfoEvent> {
|
|
|
219
219
|
*/
|
|
220
220
|
get<T extends keyof SidenavInfo>(type: T): Promise<SidenavInfo[T]>;
|
|
221
221
|
/**
|
|
222
|
-
*
|
|
222
|
+
* Boolean representing whether Sidenav and its button should be rendered at all.
|
|
223
223
|
*
|
|
224
224
|
* ***Example:***
|
|
225
225
|
*
|
package/tests/network.test.js
CHANGED
|
@@ -26,11 +26,13 @@ const network_1 = require("../network");
|
|
|
26
26
|
const Global_1 = __importDefault(require("../src/Global"));
|
|
27
27
|
describe('network.ts', () => {
|
|
28
28
|
const fetchMock = jest.fn();
|
|
29
|
+
const getPrefetchedMock = jest.fn();
|
|
29
30
|
const queryMock = jest.fn();
|
|
30
31
|
const getApolloClientMock = jest.fn();
|
|
31
32
|
const networkMock = {
|
|
32
33
|
fetch: fetchMock,
|
|
33
34
|
getApolloClient: getApolloClientMock,
|
|
35
|
+
getPrefetched: getPrefetchedMock,
|
|
34
36
|
query: queryMock
|
|
35
37
|
};
|
|
36
38
|
beforeAll(() => {
|
|
@@ -47,6 +49,14 @@ describe('network.ts', () => {
|
|
|
47
49
|
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
48
50
|
expect(fetchMock).toHaveBeenCalledWith('url', { auth: 'Header' });
|
|
49
51
|
}));
|
|
52
|
+
test('getPrefetched', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
const res = { status: 'ok' };
|
|
54
|
+
getPrefetchedMock.mockResolvedValue(res);
|
|
55
|
+
const result = yield network_1.getPrefetched('key', { createdAfter: 100 });
|
|
56
|
+
expect(result).toEqual(res);
|
|
57
|
+
expect(getPrefetchedMock).toHaveBeenCalledTimes(1);
|
|
58
|
+
expect(getPrefetchedMock).toHaveBeenCalledWith('key', { createdAfter: 100 });
|
|
59
|
+
}));
|
|
50
60
|
test('query', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
61
|
const res = { status: 'ok' };
|
|
52
62
|
queryMock.mockResolvedValue(res);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.test.js","sourceRoot":"","sources":["network.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;4EAS4E;AAC5E,
|
|
1
|
+
{"version":3,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AiB,CAAC,GAAG,CAAC,CAAC;QAC3C,MAAM,MAAM,GAAG,MAAM,yBAAe,CAAC,EAAC,GAAG,EAAE,IAAI,EAAC,CAAC,CAAC;QAClD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,MAAM,CAAC,mBAAmB,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACrD,MAAM,CAAC,mBAAmB,CAAC,CAAC,oBAAoB,CAAC,EAAC,GAAG,EAAE,IAAI,EAAC,CAAC,CAAC;IAChE,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/version.d.ts
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
* then your use, modification, or distribution of it requires the prior
|
|
9
9
|
* written permission of Adobe.
|
|
10
10
|
**************************************************************************/
|
|
11
|
-
declare const EXC_APP_VERSION = "1.0.
|
|
11
|
+
declare const EXC_APP_VERSION = "1.0.7";
|
|
12
12
|
export default EXC_APP_VERSION;
|
package/version.js
CHANGED
|
@@ -10,6 +10,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
* then your use, modification, or distribution of it requires the prior
|
|
11
11
|
* written permission of Adobe.
|
|
12
12
|
**************************************************************************/
|
|
13
|
-
const EXC_APP_VERSION = '1.0.
|
|
13
|
+
const EXC_APP_VERSION = '1.0.7';
|
|
14
14
|
exports.default = EXC_APP_VERSION;
|
|
15
15
|
//# sourceMappingURL=version.js.map
|