@common-stack/client-core 0.6.1-alpha.3 → 3.0.1-alpha.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/lib/__tests__/dataIdFromObject.test.d.ts +1 -1
- package/lib/__tests__/test-feature.d.ts +13 -0
- package/lib/connector/abstract-connector.d.ts +86 -0
- package/lib/connector/abstract-connector.js +235 -0
- package/lib/connector/abstract-connector.js.map +1 -0
- package/lib/connector/index.d.ts +1 -2
- package/lib/helpers/apollo-client-test-helper.d.ts +3 -6
- package/lib/helpers/apollo-client-test-helper.js +5 -40
- package/lib/helpers/apollo-client-test-helper.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/interfaces/connector.d.ts +261 -0
- package/lib/interfaces/epic.d.ts +15 -0
- package/lib/interfaces/index.d.ts +1 -3
- package/package.json +3 -3
- package/lib/connector/apollo-client-feature.d.ts +0 -20
- package/lib/connector/apollo-client-feature.js +0 -87
- package/lib/connector/apollo-client-feature.js.map +0 -1
- package/lib/connector/base-client-feature.d.ts +0 -26
- package/lib/connector/base-client-feature.js +0 -54
- package/lib/connector/base-client-feature.js.map +0 -1
- package/lib/interfaces/apollo-client-feature.d.ts +0 -121
- package/lib/interfaces/base-client-feature.d.ts +0 -57
- package/lib/interfaces/client-feature.d.ts +0 -66
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import 'jest';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AbstractFeature } from '../connector';
|
|
2
|
+
export declare class TestFeature extends AbstractFeature {
|
|
3
|
+
getConfiguredMenus: () => {};
|
|
4
|
+
getDataRoot: () => {};
|
|
5
|
+
getConfiguredRoutes: () => {};
|
|
6
|
+
getMenus: () => {};
|
|
7
|
+
getRoutes: () => {};
|
|
8
|
+
getWrappedRoot: () => {};
|
|
9
|
+
navItems: () => {};
|
|
10
|
+
navItemRight: () => {};
|
|
11
|
+
navItemsRight: () => {};
|
|
12
|
+
registerLanguages: () => {};
|
|
13
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { IdGetterObj } from '@apollo/client/core';
|
|
2
|
+
import { ErrorLink } from '@apollo/client/link/error';
|
|
3
|
+
import { ReducersMapObject } from 'redux';
|
|
4
|
+
import { interfaces } from 'inversify';
|
|
5
|
+
import { IFeature, IModuleShape, IClientStateConfig, IClientState } from '../interfaces';
|
|
6
|
+
export declare const featureCatalog: {};
|
|
7
|
+
export declare abstract class AbstractFeature implements IFeature {
|
|
8
|
+
link: any;
|
|
9
|
+
envalidConfig: any[];
|
|
10
|
+
errorLink: ErrorLink[];
|
|
11
|
+
createFetch: any;
|
|
12
|
+
connectionParam: any;
|
|
13
|
+
epic: any;
|
|
14
|
+
reducer: ReducersMapObject[];
|
|
15
|
+
reduxContext: any;
|
|
16
|
+
clientStateParams?: IClientStateConfig[];
|
|
17
|
+
sidebarSegments: any[];
|
|
18
|
+
routerFactory: any;
|
|
19
|
+
route: any;
|
|
20
|
+
navItem: any;
|
|
21
|
+
navItemRight: any;
|
|
22
|
+
rootComponentFactory: any[];
|
|
23
|
+
dataRootComponent: any[];
|
|
24
|
+
createFetchOptions: any[];
|
|
25
|
+
stylesInsert: any[];
|
|
26
|
+
scriptsInsert: any[];
|
|
27
|
+
catalogInfo: any[];
|
|
28
|
+
languagesFuncs: any[];
|
|
29
|
+
data: any[];
|
|
30
|
+
dataIdFromObject: {
|
|
31
|
+
[key: string]: (value: any) => string;
|
|
32
|
+
}[];
|
|
33
|
+
createContainerFunc: Function[];
|
|
34
|
+
createServiceFunc: Function[];
|
|
35
|
+
leftMainPanelItems: any;
|
|
36
|
+
middleMainPanelItems: any;
|
|
37
|
+
middleMainPanelItemsProps: any;
|
|
38
|
+
leftFooterItems: any;
|
|
39
|
+
rightFooterItems: any;
|
|
40
|
+
middleLowerPanelItems: any;
|
|
41
|
+
reduxPersistTransforms: any[];
|
|
42
|
+
private isContainerLoaded;
|
|
43
|
+
private services;
|
|
44
|
+
private _container;
|
|
45
|
+
/**
|
|
46
|
+
* Constructs Client feature module representation, that folds all the feature modules
|
|
47
|
+
* into a single module represented by this instance.
|
|
48
|
+
* @param feature
|
|
49
|
+
* @param features
|
|
50
|
+
*/
|
|
51
|
+
constructor(feature?: IModuleShape, ...features: IModuleShape[]);
|
|
52
|
+
get envalidConfigs(): any;
|
|
53
|
+
private get container();
|
|
54
|
+
get epics(): any;
|
|
55
|
+
getRouter(withRoot?: boolean, rootComponent?: any): any;
|
|
56
|
+
abstract getRoutes(searchPath?: RegExp): any;
|
|
57
|
+
abstract get navItems(): any;
|
|
58
|
+
abstract get navItemsRight(): any;
|
|
59
|
+
get reducers(): any;
|
|
60
|
+
createContainers(options: any): interfaces.Container;
|
|
61
|
+
createService(options: any, updateOptions: any): any;
|
|
62
|
+
getStateParams(args?: {
|
|
63
|
+
resolverContex?: any;
|
|
64
|
+
container?: interfaces.Container;
|
|
65
|
+
requestResponsePair?: {
|
|
66
|
+
req: Record<string, any>;
|
|
67
|
+
res: Record<string, any>;
|
|
68
|
+
};
|
|
69
|
+
}): IClientState;
|
|
70
|
+
get connectionParams(): any;
|
|
71
|
+
get stylesInserts(): any[];
|
|
72
|
+
get scriptsInserts(): any[];
|
|
73
|
+
get leftMainPanel(): any;
|
|
74
|
+
get middleMainPanel(): any;
|
|
75
|
+
get leftFooter(): any;
|
|
76
|
+
get rightFooter(): any;
|
|
77
|
+
get middleLowerPanel(): any;
|
|
78
|
+
get reduxPersistStateTransformers(): any[];
|
|
79
|
+
getDataIdFromObject(result: {
|
|
80
|
+
[key: string]: string | number;
|
|
81
|
+
__typename?: string;
|
|
82
|
+
} | IdGetterObj): any;
|
|
83
|
+
abstract getWrappedRoot(root: any, req: any): any;
|
|
84
|
+
abstract getDataRoot(root: any): any;
|
|
85
|
+
abstract registerLanguages(monaco: any): any;
|
|
86
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import*as React from'react';import {merge,without,union,map,castArray}from'lodash';import {Container}from'inversify';/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/* eslint-disable no-nested-ternary */
|
|
3
|
+
/* eslint-disable no-use-before-define */
|
|
4
|
+
const combine = (features, extractor) => without(union(...map(features, (res) => castArray(extractor(res)))), undefined);
|
|
5
|
+
const featureCatalog = {};
|
|
6
|
+
class AbstractFeature {
|
|
7
|
+
/**
|
|
8
|
+
* Constructs Client feature module representation, that folds all the feature modules
|
|
9
|
+
* into a single module represented by this instance.
|
|
10
|
+
* @param feature
|
|
11
|
+
* @param features
|
|
12
|
+
*/
|
|
13
|
+
constructor(feature,
|
|
14
|
+
// tslint:disable:trailing-comma
|
|
15
|
+
...features) {
|
|
16
|
+
// Connectivity
|
|
17
|
+
this.link = combine(arguments, (arg) => arg.link);
|
|
18
|
+
this.errorLink = combine(arguments, (arg) => arg.errorLink);
|
|
19
|
+
this.createFetch = combine(arguments, (arg) => arg.createFetch)
|
|
20
|
+
.slice(-1)
|
|
21
|
+
.pop();
|
|
22
|
+
this.connectionParam = combine(arguments, (arg) => arg.connectionParam);
|
|
23
|
+
// State management
|
|
24
|
+
this.reducer = combine(arguments, (arg) => arg.reducer);
|
|
25
|
+
// Client side schema for apollo-link-state
|
|
26
|
+
this.clientStateParams = combine(arguments, (arg) => arg.clientStateParams);
|
|
27
|
+
// Envalid config
|
|
28
|
+
this.envalidConfig = combine(arguments, (arg) => arg.envalidConfig);
|
|
29
|
+
// Epic actions
|
|
30
|
+
this.epic = combine(arguments, (arg) => arg.epic);
|
|
31
|
+
this.sidebarSegments = combine(arguments, (arg) => arg.sidebarSegments);
|
|
32
|
+
this.leftMainPanelItems = combine(arguments, (arg) => arg.leftMainPanelItems);
|
|
33
|
+
this.middleMainPanelItems = combine(arguments, (arg) => arg.middleMainPanelItems);
|
|
34
|
+
this.middleMainPanelItemsProps = combine(arguments, (arg) => arg.middleMainPanelItemsProps);
|
|
35
|
+
this.leftFooterItems = combine(arguments, (arg) => arg.leftFooterItems);
|
|
36
|
+
this.rightFooterItems = combine(arguments, (arg) => arg.rightFooterItems);
|
|
37
|
+
this.middleLowerPanelItems = combine(arguments, (arg) => arg.middleLowerPanelItems);
|
|
38
|
+
this.dataIdFromObject = combine(arguments, (arg) => arg.dataIdFromObject);
|
|
39
|
+
this.navItem = combine(arguments, (arg) => arg.navItem);
|
|
40
|
+
this.navItemRight = combine(arguments, (arg) => arg.navItemRight);
|
|
41
|
+
// UI provider-components
|
|
42
|
+
this.rootComponentFactory = combine(arguments, (arg) => arg.rootComponentFactory);
|
|
43
|
+
this.dataRootComponent = combine(arguments, (arg) => arg.dataRootComponent);
|
|
44
|
+
// UI provider-components
|
|
45
|
+
this.languagesFuncs = combine(arguments, (arg) => arg.languagesFuncs);
|
|
46
|
+
// container
|
|
47
|
+
this.createContainerFunc = combine(arguments, (arg) => arg.createContainerFunc);
|
|
48
|
+
// services
|
|
49
|
+
this.createServiceFunc = combine(arguments, (arg) => arg.createServiceFunc);
|
|
50
|
+
// TODO: Use React Helmet for those. Low level DOM manipulation
|
|
51
|
+
this.stylesInsert = combine(arguments, (arg) => arg.stylesInsert);
|
|
52
|
+
this.scriptsInsert = combine(arguments, (arg) => arg.scriptsInsert);
|
|
53
|
+
this.reduxPersistTransforms = combine(arguments, (arg) => arg.reduxPersistTransforms);
|
|
54
|
+
// Shared modules data
|
|
55
|
+
this.data = combine([{}].concat(Array.from(arguments)), (arg) => arg.data).reduce((acc, el) => [Object.assign(Object.assign({}, acc[0]), el)], [{}]);
|
|
56
|
+
}
|
|
57
|
+
get envalidConfigs() {
|
|
58
|
+
return this.envalidConfig.reduce((prev, config) => {
|
|
59
|
+
for (const key in config) {
|
|
60
|
+
if (prev[key]) {
|
|
61
|
+
if (prev[key].required) {
|
|
62
|
+
config[key].required = prev[key].required;
|
|
63
|
+
}
|
|
64
|
+
if (prev[key].devRequired) {
|
|
65
|
+
config[key].devRequired = prev[key].devRequired;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return Object.assign(Object.assign({}, prev), config);
|
|
69
|
+
}
|
|
70
|
+
}, {});
|
|
71
|
+
}
|
|
72
|
+
get container() {
|
|
73
|
+
if (!this._container) {
|
|
74
|
+
this._container = new Container();
|
|
75
|
+
}
|
|
76
|
+
return this._container;
|
|
77
|
+
}
|
|
78
|
+
get epics() {
|
|
79
|
+
return this.epic;
|
|
80
|
+
}
|
|
81
|
+
getRouter(withRoot, rootComponent) {
|
|
82
|
+
return this.routerFactory(this.getRoutes());
|
|
83
|
+
}
|
|
84
|
+
get reducers() {
|
|
85
|
+
return merge({}, ...(this.reducer || []));
|
|
86
|
+
}
|
|
87
|
+
createContainers(options) {
|
|
88
|
+
// only create once
|
|
89
|
+
if (this.isContainerLoaded) {
|
|
90
|
+
return this.container;
|
|
91
|
+
}
|
|
92
|
+
this.createContainerFunc.map((createModule) => {
|
|
93
|
+
this.container.load(createModule(options));
|
|
94
|
+
});
|
|
95
|
+
this.isContainerLoaded = true;
|
|
96
|
+
return this.container;
|
|
97
|
+
}
|
|
98
|
+
createService(options, updateOptions) {
|
|
99
|
+
// only create once
|
|
100
|
+
if (this.services) {
|
|
101
|
+
return this.services;
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
if (!this.isContainerLoaded) {
|
|
105
|
+
this.createContainers(options);
|
|
106
|
+
}
|
|
107
|
+
this.services = merge({}, ...this.createServiceFunc.map((serviceFunc) => serviceFunc(this.container)));
|
|
108
|
+
return this.services;
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
throw err;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
getStateParams(args = {}) {
|
|
115
|
+
const cn = args.container || this.container;
|
|
116
|
+
const { requestResponsePair } = args;
|
|
117
|
+
return this.clientStateParams.reduce((acc, curr) => {
|
|
118
|
+
const defs = curr.typeDefs ? (Array.isArray(curr.typeDefs) ? curr.typeDefs : [curr.typeDefs]) : [];
|
|
119
|
+
const preLinksAccumulator = acc.preLinks || [];
|
|
120
|
+
const attemptFuncAccumulator = acc.retryLinkAttemptFuncs || [];
|
|
121
|
+
const connectionParamsFuncAccumulator = acc.connectionParams || [];
|
|
122
|
+
const callbackBackFuncAccumulator = acc.connectionCallbackFuncs || [];
|
|
123
|
+
const attemptDefaults = acc.defaults || [];
|
|
124
|
+
const schema = defs
|
|
125
|
+
.map((typeDef) => {
|
|
126
|
+
if (typeof typeDef === 'string') {
|
|
127
|
+
return typeDef;
|
|
128
|
+
}
|
|
129
|
+
console.warn(`Not supported AST format `, typeDef);
|
|
130
|
+
})
|
|
131
|
+
.map((str) => str.trim())
|
|
132
|
+
.join('\n');
|
|
133
|
+
const typeDefs = acc.typeDefs ? acc.typeDefs.concat('\n', schema) : schema;
|
|
134
|
+
const defaults = curr.defaults ? attemptDefaults.concat(curr.defaults) : attemptDefaults;
|
|
135
|
+
const resolvers = merge(acc.resolvers, consoldidatedResolvers(curr.resolvers, args.resolverContex));
|
|
136
|
+
const possibleTypes = merge(acc.possibleTypes, curr.possibleTypes);
|
|
137
|
+
const typePolicies = merge(acc.typePolicies, curr.typePolicies);
|
|
138
|
+
const retryLinkAttemptFuncs = curr.retryLinkAttemptFuncs
|
|
139
|
+
? attemptFuncAccumulator.concat(curr.retryLinkAttemptFuncs || [])
|
|
140
|
+
: attemptFuncAccumulator;
|
|
141
|
+
const preLinks = preLinksAccumulator.concat((curr.preLinkFuncs || []).map((linkF) => linkF(cn, requestResponsePair)) || []);
|
|
142
|
+
const connectionParams = curr.connectionParam
|
|
143
|
+
? connectionParamsFuncAccumulator.concat(consoldidatedConnection(curr.connectionParam, cn))
|
|
144
|
+
: connectionParamsFuncAccumulator;
|
|
145
|
+
const connectionCallbackFuncs = curr.connectionCallbackFunc
|
|
146
|
+
? callbackBackFuncAccumulator.concat(curr.connectionCallbackFunc(cn) || [])
|
|
147
|
+
: callbackBackFuncAccumulator;
|
|
148
|
+
return {
|
|
149
|
+
defaults,
|
|
150
|
+
resolvers,
|
|
151
|
+
typeDefs,
|
|
152
|
+
possibleTypes,
|
|
153
|
+
retryLinkAttemptFuncs,
|
|
154
|
+
preLinks,
|
|
155
|
+
typePolicies,
|
|
156
|
+
connectionParams,
|
|
157
|
+
connectionCallbackFuncs,
|
|
158
|
+
};
|
|
159
|
+
}, {});
|
|
160
|
+
}
|
|
161
|
+
get connectionParams() {
|
|
162
|
+
return this.connectionParam;
|
|
163
|
+
}
|
|
164
|
+
get stylesInserts() {
|
|
165
|
+
return this.stylesInsert;
|
|
166
|
+
}
|
|
167
|
+
get scriptsInserts() {
|
|
168
|
+
return this.scriptsInsert;
|
|
169
|
+
}
|
|
170
|
+
get leftMainPanel() {
|
|
171
|
+
return merge({}, ...(this.leftMainPanelItems || []));
|
|
172
|
+
}
|
|
173
|
+
get middleMainPanel() {
|
|
174
|
+
const panelObj = merge({}, ...(this.middleMainPanelItems || []));
|
|
175
|
+
const withProps = {};
|
|
176
|
+
Object.keys(panelObj).forEach((key) => {
|
|
177
|
+
const props = this.middleMainPanelItemsProps.filter((el) => !!el[key]);
|
|
178
|
+
let mergedProps = [];
|
|
179
|
+
props.forEach((el) => {
|
|
180
|
+
const insideEl = el[key];
|
|
181
|
+
Object.keys(insideEl).forEach((item) => {
|
|
182
|
+
if (mergedProps[item]) {
|
|
183
|
+
mergedProps[item] = [...mergedProps[item], ...insideEl[item]];
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
mergedProps = Object.assign(Object.assign({}, mergedProps), { [item]: insideEl[item] });
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
return (withProps[key] = React.cloneElement(panelObj[key], mergedProps));
|
|
191
|
+
});
|
|
192
|
+
return withProps;
|
|
193
|
+
}
|
|
194
|
+
get leftFooter() {
|
|
195
|
+
return this.leftFooterItems;
|
|
196
|
+
}
|
|
197
|
+
get rightFooter() {
|
|
198
|
+
return this.rightFooterItems;
|
|
199
|
+
}
|
|
200
|
+
get middleLowerPanel() {
|
|
201
|
+
return merge({}, ...(this.middleLowerPanelItems || []));
|
|
202
|
+
}
|
|
203
|
+
get reduxPersistStateTransformers() {
|
|
204
|
+
return this.reduxPersistTransforms;
|
|
205
|
+
}
|
|
206
|
+
getDataIdFromObject(result) {
|
|
207
|
+
const dataIdFromObject = merge({}, ...this.dataIdFromObject);
|
|
208
|
+
if (dataIdFromObject[result.__typename]) {
|
|
209
|
+
return dataIdFromObject[result.__typename](result);
|
|
210
|
+
}
|
|
211
|
+
return result.id || result._id;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function consoldidatedResolvers(resolvers, context) {
|
|
215
|
+
let finalResolvers;
|
|
216
|
+
if (Array.isArray(resolvers)) {
|
|
217
|
+
const resolverObject = resolvers.map((resolver) => typeof resolver === 'function' ? resolver(context) : resolver);
|
|
218
|
+
finalResolvers = merge({}, ...resolverObject);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
finalResolvers = typeof resolvers === 'function' ? resolvers(context) : resolvers;
|
|
222
|
+
}
|
|
223
|
+
return finalResolvers;
|
|
224
|
+
}
|
|
225
|
+
async function consoldidatedConnection(connectionParams, context) {
|
|
226
|
+
let finalConnectionParams;
|
|
227
|
+
if (Array.isArray(connectionParams)) {
|
|
228
|
+
throw new Error('Array is not supported for ConnectionParams');
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
finalConnectionParams =
|
|
232
|
+
typeof connectionParams === 'function' ? await connectionParams(context) : connectionParams;
|
|
233
|
+
}
|
|
234
|
+
return finalConnectionParams;
|
|
235
|
+
}export{AbstractFeature,featureCatalog};//# sourceMappingURL=abstract-connector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-connector.js","sources":["../../src/connector/abstract-connector.ts"],"sourcesContent":[null],"names":[],"mappings":"qHAAA;AACA;AACA;AAgBA,MAAM,OAAO,GAAG,CAAC,QAAQ,EAAE,SAAS,KAChC,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,GAAG,KAAK,S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U,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;AACrF,KAAA;AAED,IAAA,OAAO,cAAc,CAAC;AAC1B,CAAC;AAED,eAAe,uBAAuB,CAAC,gBAA2C,EAAE,OAAO,EAAA;AACvF,IAAA,IAAI,qBAAqB,CAAC;AAC1B,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE;AACjC,QAAA,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;AAClE,KAAA;AAAM,SAAA;QACH,qBAAqB;AACjB,YAAA,OAAO,gBAAgB,KAAK,UAAU,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,GAAG,gBAAgB,CAAC;AACnG,KAAA;AAED,IAAA,OAAO,qBAAqB,CAAC;AACjC"}
|
package/lib/connector/index.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './base-client-feature';
|
|
1
|
+
export * from './abstract-connector';
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { ApolloClient } from '@apollo/client/core';
|
|
2
2
|
import { interfaces } from 'inversify';
|
|
3
|
-
import {
|
|
4
|
-
export declare const onAppCreate: (modules: ApolloClientFeature, entryModule: NodeModule) => Promise<void>;
|
|
3
|
+
import { IFeature } from '../interfaces';
|
|
5
4
|
/**
|
|
6
5
|
* Helper method to produce ApolloClient and Services from the feeded Feature Module.
|
|
7
6
|
* @param modules
|
|
8
7
|
*/
|
|
9
|
-
export declare const apolloClientHelper: (modules:
|
|
8
|
+
export declare const apolloClientHelper: (modules: IFeature) => {
|
|
10
9
|
client: ApolloClient<any>;
|
|
11
10
|
dataIdFromObject: (result: any) => any;
|
|
12
|
-
services:
|
|
13
|
-
[key: string]: unknown;
|
|
14
|
-
};
|
|
11
|
+
services: any;
|
|
15
12
|
container: interfaces.Container;
|
|
16
13
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {ApolloClient}from'@apollo/client/core';import {InMemoryCache}from'@apollo/client/cache';import {
|
|
1
|
+
import {ApolloClient}from'@apollo/client/core';import {InMemoryCache}from'@apollo/client/cache';import {logger}from'@cdm-logger/client';import {ClientTypes}from'@common-stack/core';class UtilityClass {
|
|
2
2
|
constructor(modules) {
|
|
3
3
|
this.modules = modules;
|
|
4
4
|
}
|
|
@@ -6,41 +6,6 @@ import {ApolloClient}from'@apollo/client/core';import {InMemoryCache}from'@apoll
|
|
|
6
6
|
return this.modules.getDataIdFromObject(storeObj);
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
const onAppCreate = async (modules, entryModule) => {
|
|
10
|
-
const clientState = modules.getStateParams({ resolverContex: () => modules.createService({}, {}) });
|
|
11
|
-
const dataIdFromObject = (result) => modules.getDataIdFromObject(result);
|
|
12
|
-
const cache = new InMemoryCache({
|
|
13
|
-
dataIdFromObject,
|
|
14
|
-
possibleTypes: clientState.possibleTypes,
|
|
15
|
-
});
|
|
16
|
-
const schema = ``;
|
|
17
|
-
const params = {
|
|
18
|
-
cache,
|
|
19
|
-
queryDeduplication: true,
|
|
20
|
-
typeDefs: schema.concat(clientState.typeDefs),
|
|
21
|
-
resolvers: clientState.resolvers,
|
|
22
|
-
};
|
|
23
|
-
const client = new ApolloClient(params);
|
|
24
|
-
clientState.defaults.map((x) => {
|
|
25
|
-
if (x.type === 'query') {
|
|
26
|
-
cache.writeQuery(x);
|
|
27
|
-
}
|
|
28
|
-
else if (x.type === 'fragment') {
|
|
29
|
-
cache.writeFragment(x);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
const utility = new UtilityClass(modules);
|
|
33
|
-
// additional bindings to container
|
|
34
|
-
const additionalContainerFunc = () => new ContainerModule((bind) => {
|
|
35
|
-
bind(ClientTypes.Logger).toConstantValue(logger);
|
|
36
|
-
bind(ClientTypes.UtilityClass).toConstantValue(utility);
|
|
37
|
-
bind(ClientTypes.ApolloClient).toConstantValue(client);
|
|
38
|
-
bind(ClientTypes.InMemoryCache).toConstantValue(cache);
|
|
39
|
-
});
|
|
40
|
-
modules.loadContainers({}, [additionalContainerFunc]);
|
|
41
|
-
const services = modules.createService({});
|
|
42
|
-
client.container = services;
|
|
43
|
-
};
|
|
44
9
|
/**
|
|
45
10
|
* Helper method to produce ApolloClient and Services from the feeded Feature Module.
|
|
46
11
|
* @param modules
|
|
@@ -50,7 +15,7 @@ const apolloClientHelper = (modules) => {
|
|
|
50
15
|
const dataIdFromObject = (result) => modules.getDataIdFromObject(result);
|
|
51
16
|
const cache = new InMemoryCache({
|
|
52
17
|
dataIdFromObject,
|
|
53
|
-
possibleTypes: clientState.possibleTypes
|
|
18
|
+
possibleTypes: clientState.possibleTypes
|
|
54
19
|
});
|
|
55
20
|
const schema = ``;
|
|
56
21
|
const params = {
|
|
@@ -60,7 +25,7 @@ const apolloClientHelper = (modules) => {
|
|
|
60
25
|
resolvers: clientState.resolvers,
|
|
61
26
|
};
|
|
62
27
|
const client = new ApolloClient(params);
|
|
63
|
-
clientState.defaults.map(
|
|
28
|
+
clientState.defaults.map(x => {
|
|
64
29
|
if (x.type === 'query') {
|
|
65
30
|
cache.writeQuery(x);
|
|
66
31
|
}
|
|
@@ -70,7 +35,7 @@ const apolloClientHelper = (modules) => {
|
|
|
70
35
|
});
|
|
71
36
|
const utility = new UtilityClass(modules);
|
|
72
37
|
// additional bindings to container
|
|
73
|
-
const container = modules.
|
|
38
|
+
const container = modules.createContainers({});
|
|
74
39
|
container.bind(ClientTypes.Logger).toConstantValue(logger);
|
|
75
40
|
container.bind(ClientTypes.UtilityClass).toConstantValue(utility);
|
|
76
41
|
container.bind(ClientTypes.ApolloClient).toConstantValue(client);
|
|
@@ -83,4 +48,4 @@ const apolloClientHelper = (modules) => {
|
|
|
83
48
|
services,
|
|
84
49
|
container,
|
|
85
50
|
};
|
|
86
|
-
};export{apolloClientHelper
|
|
51
|
+
};export{apolloClientHelper};//# sourceMappingURL=apollo-client-test-helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apollo-client-test-helper.js","sources":["../../src/helpers/apollo-client-test-helper.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"apollo-client-test-helper.js","sources":["../../src/helpers/apollo-client-test-helper.ts"],"sourcesContent":[null],"names":[],"mappings":"qLAOA,MAAM,YAAY,CAAA;AACd,IAAA,WAAA,CAAoB,OAAO,EAAA;QAAP,IAAO,CAAA,OAAA,GAAP,OAAO,CAAA;KAC1B;AACM,IAAA,WAAW,CAAC,QAAQ,EAAA;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;KACrD;AACJ,CAAA;AAGD;;;AAGG;AACU,MAAA,kBAAkB,GAAG,CAAC,OAAiB,KAAI;IACpD,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;AAEpG,IAAA,MAAM,gBAAgB,GAAG,CAAC,MAAM,KAAK,OAAO,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;AACzE,IAAA,MAAM,KAAK,GAAG,IAAI,aAAa,CAAC;QAC5B,gBAAgB;QAChB,aAAa,EAAE,WAAW,CAAC,aAAa;AAC3C,KAAA,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,CAAA,CAAE,CAAC;AAElB,IAAA,MAAM,MAAM,GAA6B;QACrC,KAAK;AACL,QAAA,kBAAkB,EAAE,IAAI;QACxB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAS,WAAW,CAAC,QAAQ,CAAC;QACrD,SAAS,EAAE,WAAW,CAAC,SAAgB;KAC1C,CAAC;AACF,IAAA,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;AACxC,IAAA,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAG;AACzB,QAAA,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE;AACpB,YAAA,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACvB,SAAA;AAAM,aAAA,IAAI,CAAC,CAAC,IAAI,KAAK,UAAU,EAAE;AAC9B,YAAA,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;AAC1B,SAAA;AACL,KAAC,CAAC,CAAC;AAEH,IAAA,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;;IAG1C,MAAM,SAAS,GAAyB,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;AACrE,IAAA,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;AAC3D,IAAA,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AAClE,IAAA,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;AACjE,IAAA,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC9C,IAAA,MAAc,CAAC,SAAS,GAAG,QAAQ,CAAC;IAGrC,OAAO;QACH,MAAM;QACN,gBAAgB;QAChB,QAAQ;QACR,SAAS;KACZ,CAAA;AACL"}
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{logger}from'./logger/logger.js';export{
|
|
1
|
+
export{logger}from'./logger/logger.js';export{AbstractFeature,featureCatalog}from'./connector/abstract-connector.js';export{REDUX_PERSIST_KEY}from'./constants/constants.js';export{apolloClientHelper}from'./helpers/apollo-client-test-helper.js';export{ClientTypes,ElectronTypes}from'@common-stack/core';//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { Resolvers, IdGetterObj, PossibleTypesMap, TypePolicies, Operation, ApolloLink } from '@apollo/client/core';
|
|
2
|
+
import { interfaces } from 'inversify';
|
|
3
|
+
import { Cache } from '@apollo/client/cache';
|
|
4
|
+
import { ReducersMapObject } from 'redux';
|
|
5
|
+
import { ErrorLink } from '@apollo/client/link/error';
|
|
6
|
+
type ConnectionParams = {
|
|
7
|
+
[paramName: string]: any;
|
|
8
|
+
};
|
|
9
|
+
export type ResolverType = Resolvers | Resolvers[] | ((service: any) => Resolvers) | ((service: any) => Resolvers)[] | ((service: any) => any) | ((service: any) => any)[];
|
|
10
|
+
export type ApolloLinkFunc = (container: interfaces.Container, req?: any, requestResponsePair?: {
|
|
11
|
+
req: Record<string, any>;
|
|
12
|
+
res: Record<string, any>;
|
|
13
|
+
}) => ApolloLink;
|
|
14
|
+
export type ApolloConnectionParamFunc = ((container: interfaces.Container) => ConnectionParams) | ConnectionParams;
|
|
15
|
+
export type IWSConnectionCallbackFunc = (webSocket: any, error: Error[], result?: any) => void | Promise<void>;
|
|
16
|
+
export type ApolloWSConnectionCallbackFunc = (container: interfaces.Container) => IWSConnectionCallbackFunc;
|
|
17
|
+
type IRetryLinkAttemptFuncs = (count: number, operation: Operation, error: any) => boolean | Promise<boolean>;
|
|
18
|
+
type IClientStateQueryDefault<T, V> = {
|
|
19
|
+
type: 'query';
|
|
20
|
+
} & Cache.WriteQueryOptions<T, V>;
|
|
21
|
+
type IClientStateFragmentDefault<T, V> = {
|
|
22
|
+
type: 'fragment';
|
|
23
|
+
} & Cache.WriteFragmentOptions<T, V>;
|
|
24
|
+
export type IClientStateDefault<T = unknown, V = unknown> = IClientStateFragmentDefault<T, V> | IClientStateQueryDefault<T, V>;
|
|
25
|
+
export interface IClientStateConfig {
|
|
26
|
+
resolvers?: ResolverType;
|
|
27
|
+
defaults?: IClientStateDefault[];
|
|
28
|
+
typeDefs?: string | string[];
|
|
29
|
+
possibleTypes?: PossibleTypesMap;
|
|
30
|
+
typePolicies?: TypePolicies;
|
|
31
|
+
retryLinkAttemptFuncs?: IRetryLinkAttemptFuncs;
|
|
32
|
+
/**
|
|
33
|
+
* @param preLinkFuncs all `apollo-link` that need to be composed before the network link. Should be a function.
|
|
34
|
+
* @inheritdoc https://www.apollographql.com/docs/react/api/link/introduction/
|
|
35
|
+
*/
|
|
36
|
+
preLinkFuncs?: ApolloLinkFunc[];
|
|
37
|
+
/**
|
|
38
|
+
* @param connectionParam To provide connectionParam to `WebSocketLink`. It takes a single `Object` or a `Function`.
|
|
39
|
+
* @inheritdoc https://www.apollographql.com/docs/react/api/link/apollo-link-ws/
|
|
40
|
+
*/
|
|
41
|
+
connectionParam?: ApolloConnectionParamFunc;
|
|
42
|
+
/**
|
|
43
|
+
* @param connectionCallback Accept only one function for all modules.
|
|
44
|
+
* @inheritdoc
|
|
45
|
+
*/
|
|
46
|
+
connectionCallbackFunc?: ApolloWSConnectionCallbackFunc;
|
|
47
|
+
}
|
|
48
|
+
export interface IClientState {
|
|
49
|
+
container?: interfaces.Container;
|
|
50
|
+
resolvers?: Resolvers;
|
|
51
|
+
defaults: IClientStateDefault[];
|
|
52
|
+
typeDefs?: string | string[];
|
|
53
|
+
possibleTypes?: PossibleTypesMap;
|
|
54
|
+
retryLinkAttemptFuncs?: IRetryLinkAttemptFuncs[];
|
|
55
|
+
typePolicies?: TypePolicies;
|
|
56
|
+
preLinks: ApolloLink[];
|
|
57
|
+
connectionParams: ConnectionParams[];
|
|
58
|
+
connectionCallbackFuncs?: IWSConnectionCallbackFunc[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* ModuleShape have optional configuration to be implemented by all the feature modules
|
|
62
|
+
* in the application.
|
|
63
|
+
*/
|
|
64
|
+
export interface IModuleShape {
|
|
65
|
+
/**
|
|
66
|
+
* @param envalidConfig envalid validators
|
|
67
|
+
*/
|
|
68
|
+
readonly envalidConfig?: any;
|
|
69
|
+
/**
|
|
70
|
+
* @param link all `apollo-link` that need to be composed.
|
|
71
|
+
* @inheritdoc https://github.com/apollographql/apollo-link
|
|
72
|
+
* @deprecated use ClientStateParms.preLinkFuncs
|
|
73
|
+
*/
|
|
74
|
+
readonly link?: any;
|
|
75
|
+
/**
|
|
76
|
+
* @param errorLink compose all errorLink
|
|
77
|
+
* @inheritdoc https://github.com/apollographql/apollo-link/tree/master/packages/apollo-link-error
|
|
78
|
+
*/
|
|
79
|
+
readonly errorLink?: ErrorLink | ErrorLink[];
|
|
80
|
+
readonly createFetch?: any;
|
|
81
|
+
/**
|
|
82
|
+
* @param connectionParam method that called when a client connects to the socket.
|
|
83
|
+
* @inheritdoc https://github.com/apollographql/subscriptions-transport-ws#constructorurl-options-connectioncallback
|
|
84
|
+
* @deprecated use clientStateParams
|
|
85
|
+
*/
|
|
86
|
+
readonly connectionParam?: any;
|
|
87
|
+
/**
|
|
88
|
+
* @param epic all `epics` that need to be composed.
|
|
89
|
+
* @inheritdoc https://redux-observable.js.org/docs/basics/Epics.html
|
|
90
|
+
*/
|
|
91
|
+
readonly epic?: any;
|
|
92
|
+
/**
|
|
93
|
+
* @param reducer Redux reducers list
|
|
94
|
+
*/
|
|
95
|
+
readonly reducer?: ReducersMapObject | ReducersMapObject[];
|
|
96
|
+
/**
|
|
97
|
+
* @param clientStateParams Client side configuration of `apollo-client`
|
|
98
|
+
* @inheritdoc https://github.com/apollographql/apollo-client/tree/2d65da133c156f6d808e64aee7e7fd5f7cc71d7f
|
|
99
|
+
*/
|
|
100
|
+
readonly clientStateParams?: IClientStateConfig | IClientStateConfig[];
|
|
101
|
+
/**
|
|
102
|
+
* @param dataIdFromObject A function that returns an object identifier given an particular result
|
|
103
|
+
* object.
|
|
104
|
+
* @inheritdoc https://github.com/apollographql/apollo-client/tree/ed66999bac40226abfeada8d6c83b454636bb4b0/packages/apollo-cache-inmemory#configuration
|
|
105
|
+
*/
|
|
106
|
+
readonly dataIdFromObject?: {
|
|
107
|
+
[key: string]: (value: any) => string;
|
|
108
|
+
} | {
|
|
109
|
+
[key: string]: (value: any) => string;
|
|
110
|
+
}[] | IdGetterObj;
|
|
111
|
+
/**
|
|
112
|
+
* @param createContainerFunc Synchronous Container Modules of inversify.
|
|
113
|
+
* @inheritdoc https://github.com/inversify/InversifyJS/blob/master/wiki/container_modules.md
|
|
114
|
+
*/
|
|
115
|
+
readonly createContainerFunc?: Function | Function[];
|
|
116
|
+
/**
|
|
117
|
+
* @param createServiceFunc Services
|
|
118
|
+
*/
|
|
119
|
+
readonly createServiceFunc?: Function | Function[];
|
|
120
|
+
readonly sidebarSegments?: any;
|
|
121
|
+
readonly routerFactory?: any;
|
|
122
|
+
/**
|
|
123
|
+
* @param route Route list
|
|
124
|
+
*/
|
|
125
|
+
readonly route?: any;
|
|
126
|
+
/**
|
|
127
|
+
* @param navItem Top left navigation links
|
|
128
|
+
*/
|
|
129
|
+
readonly navItem?: any;
|
|
130
|
+
/**
|
|
131
|
+
* @param navItemRightTop right navigation links
|
|
132
|
+
*/
|
|
133
|
+
readonly navItemRight?: any;
|
|
134
|
+
/**
|
|
135
|
+
* @param rootComponentFactory Root component factory list
|
|
136
|
+
*/
|
|
137
|
+
readonly rootComponentFactory?: any;
|
|
138
|
+
/**
|
|
139
|
+
* @param dataRootComponent Data root React elements list (data root elements wraps data fetching react subtree root)
|
|
140
|
+
*/
|
|
141
|
+
readonly dataRootComponent?: any;
|
|
142
|
+
readonly createFetchOptions?: any;
|
|
143
|
+
/**
|
|
144
|
+
* @param stylesInsert URL list to 3rd party css scripts
|
|
145
|
+
*/
|
|
146
|
+
readonly stylesInsert?: any;
|
|
147
|
+
/**
|
|
148
|
+
* @param scriptsInsert URL list to 3rd party js scripts
|
|
149
|
+
*/
|
|
150
|
+
readonly scriptsInsert?: any;
|
|
151
|
+
/**
|
|
152
|
+
* @deprecated
|
|
153
|
+
*/
|
|
154
|
+
readonly catalogInfo?: any;
|
|
155
|
+
/**
|
|
156
|
+
* @deprecated
|
|
157
|
+
*/
|
|
158
|
+
readonly languagesFuncs?: any;
|
|
159
|
+
/**
|
|
160
|
+
* @param leftMainPanelItems Components that will be placed left panel.
|
|
161
|
+
*/
|
|
162
|
+
readonly leftMainPanelItems?: any;
|
|
163
|
+
/**
|
|
164
|
+
* @param middleMainPanelItems Components that will be placed middle center panel
|
|
165
|
+
*/
|
|
166
|
+
readonly middleMainPanelItems?: any;
|
|
167
|
+
/**
|
|
168
|
+
* @param middleMainPanelItemsProps Props of the component that will be placed middle center panel
|
|
169
|
+
*/
|
|
170
|
+
readonly middleMainPanelItemsProps?: any;
|
|
171
|
+
/**
|
|
172
|
+
* @param leftFooterItems Components that will be placed left footer panel
|
|
173
|
+
*/
|
|
174
|
+
readonly leftFooterItems?: any;
|
|
175
|
+
/**
|
|
176
|
+
* @param rightFooterItems Components that will be placed right footer panel
|
|
177
|
+
*/
|
|
178
|
+
readonly rightFooterItems?: any;
|
|
179
|
+
/**
|
|
180
|
+
* @param middleLowerPanelItems Components that will be placed below middle panel
|
|
181
|
+
*/
|
|
182
|
+
readonly middleLowerPanelItems?: any;
|
|
183
|
+
readonly reduxPersistTransforms?: any[];
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Feature module methods
|
|
187
|
+
*/
|
|
188
|
+
export interface IFeature extends IModuleShape {
|
|
189
|
+
readonly data: any[];
|
|
190
|
+
/**
|
|
191
|
+
* @returns envalidConfig of all features
|
|
192
|
+
*/
|
|
193
|
+
readonly envalidConfigs: any[];
|
|
194
|
+
/**
|
|
195
|
+
* @returns Redux-Observable Epics
|
|
196
|
+
*/
|
|
197
|
+
readonly epics: any;
|
|
198
|
+
readonly getRouter: any;
|
|
199
|
+
/**
|
|
200
|
+
* @returns client-side React route components list
|
|
201
|
+
*/
|
|
202
|
+
readonly getRoutes: any;
|
|
203
|
+
/**
|
|
204
|
+
* @returns client-side top left navbar link component list
|
|
205
|
+
*/
|
|
206
|
+
readonly navItems: any;
|
|
207
|
+
/**
|
|
208
|
+
* @returns client-side top right navbar link component list
|
|
209
|
+
*/
|
|
210
|
+
readonly navItemsRight: any;
|
|
211
|
+
/**
|
|
212
|
+
* @returns Redux reducers
|
|
213
|
+
*/
|
|
214
|
+
readonly reducers: any;
|
|
215
|
+
readonly connectionParams: any;
|
|
216
|
+
/**
|
|
217
|
+
* @returns URL list to 3rd party css styles
|
|
218
|
+
*/
|
|
219
|
+
readonly stylesInserts: any;
|
|
220
|
+
/**
|
|
221
|
+
* @returns URL list to 3rd party js styles
|
|
222
|
+
*/
|
|
223
|
+
readonly scriptsInserts: any;
|
|
224
|
+
readonly leftMainPanel: any;
|
|
225
|
+
readonly middleMainPanel: any;
|
|
226
|
+
readonly leftFooter: any;
|
|
227
|
+
readonly rightFooter: any;
|
|
228
|
+
readonly middleLowerPanel: any;
|
|
229
|
+
readonly dataIdFromObject: any;
|
|
230
|
+
/**
|
|
231
|
+
* @param args Options to pass to each Container Module
|
|
232
|
+
* @returns Created container and binds all the container modules
|
|
233
|
+
*/
|
|
234
|
+
createContainers(args: any): any;
|
|
235
|
+
createService(options: any, updateOptions: any): any;
|
|
236
|
+
/**
|
|
237
|
+
* @param args Provide resolverContext which can be passed to all resolver functions.
|
|
238
|
+
* @returns IClientState
|
|
239
|
+
*/
|
|
240
|
+
getStateParams(args?: {
|
|
241
|
+
resolverContex?: any;
|
|
242
|
+
}): IClientState;
|
|
243
|
+
getDataIdFromObject(result: {
|
|
244
|
+
[key: string]: string | number;
|
|
245
|
+
__typename?: string;
|
|
246
|
+
} | IdGetterObj): any;
|
|
247
|
+
/**
|
|
248
|
+
* @arguments root React tree root component
|
|
249
|
+
* @arguments req Http Request
|
|
250
|
+
* @returns React tree root component wrapped up by root components exposed by this module
|
|
251
|
+
*/
|
|
252
|
+
getWrappedRoot(root: any, req?: any): any;
|
|
253
|
+
/**
|
|
254
|
+
* @param root React tree data root component (first React root components which is used for fetching data)
|
|
255
|
+
*
|
|
256
|
+
* @returns React tree data root component wrapped up by data root components exposed by this module
|
|
257
|
+
*/
|
|
258
|
+
getDataRoot(root: any): any;
|
|
259
|
+
registerLanguages(monaco: any): void;
|
|
260
|
+
}
|
|
261
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CdmLogger } from '@cdm-logger/core';
|
|
2
|
+
import { ApolloClient } from '@apollo/client';
|
|
3
|
+
import { interfaces } from 'inversify';
|
|
4
|
+
export interface EpicDependencies<S = unknown> {
|
|
5
|
+
apolloClient: ApolloClient<any>;
|
|
6
|
+
routes: any;
|
|
7
|
+
logger: CdmLogger.ILogger;
|
|
8
|
+
services?: {
|
|
9
|
+
[key: string]: S;
|
|
10
|
+
};
|
|
11
|
+
config?: {
|
|
12
|
+
loadRoot: boolean;
|
|
13
|
+
};
|
|
14
|
+
container: interfaces.Container;
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/client-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "3.0.1-alpha.0",
|
|
4
4
|
"description": "common core for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"watch": "yarn build:lib:watch"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@common-stack/core": "0.
|
|
22
|
+
"@common-stack/core": "3.0.1-alpha.0"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"typescript": {
|
|
32
32
|
"definition": "lib/index.d.ts"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "2c5be38e54fcffe218106da86a39bf5c253e504d"
|
|
35
35
|
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ErrorLink } from '@apollo/client/link/error';
|
|
2
|
-
import { IdGetterObj } from '@apollo/client';
|
|
3
|
-
import { IApolloClientFeature, IApolloClientFeatureShape, IClientState, IClientStateConfig } from '../interfaces';
|
|
4
|
-
import { BaseClientFeature } from './base-client-feature';
|
|
5
|
-
declare class ApolloClientFeature extends BaseClientFeature implements IApolloClientFeature {
|
|
6
|
-
readonly clientStateParams?: IClientStateConfig[];
|
|
7
|
-
readonly dataIdFromObject?: {
|
|
8
|
-
[key: string]: (value?: any) => string;
|
|
9
|
-
}[];
|
|
10
|
-
readonly errorLink?: ErrorLink[];
|
|
11
|
-
constructor(...modules: IApolloClientFeatureShape[]);
|
|
12
|
-
getStateParams(args?: {
|
|
13
|
-
resolverContex?: any;
|
|
14
|
-
}): IClientState;
|
|
15
|
-
getDataIdFromObject(result: {
|
|
16
|
-
[key: string]: string | number;
|
|
17
|
-
__typename?: string;
|
|
18
|
-
} | IdGetterObj): any;
|
|
19
|
-
}
|
|
20
|
-
export { ApolloClientFeature };
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import {foldTo}from'fractal-objects';import {merge,without,union,map,castArray}from'lodash';import {BaseClientFeature}from'./base-client-feature.js';const combine = (features, extractor) => without(union(...map(features, res => castArray(extractor(res)))), undefined);
|
|
2
|
-
function consoldidatedResolvers(resolvers, context) {
|
|
3
|
-
let finalResolvers;
|
|
4
|
-
if (Array.isArray(resolvers)) {
|
|
5
|
-
const resolverObject = resolvers.map((resolver) => {
|
|
6
|
-
return typeof resolver === 'function' ? resolver(context) : resolver;
|
|
7
|
-
});
|
|
8
|
-
finalResolvers = merge({}, ...resolverObject);
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
finalResolvers = typeof resolvers === 'function' ? resolvers(context) : resolvers;
|
|
12
|
-
}
|
|
13
|
-
return finalResolvers;
|
|
14
|
-
}
|
|
15
|
-
async function consoldidatedConnection(connectionParams, context) {
|
|
16
|
-
let finalConnectionParams;
|
|
17
|
-
if (Array.isArray(connectionParams)) {
|
|
18
|
-
throw new Error('Array is not supported for ConnectionParams');
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
finalConnectionParams =
|
|
22
|
-
typeof connectionParams === 'function' ? await connectionParams(context) : connectionParams;
|
|
23
|
-
}
|
|
24
|
-
return finalConnectionParams;
|
|
25
|
-
}
|
|
26
|
-
class ApolloClientFeature extends BaseClientFeature {
|
|
27
|
-
constructor(...modules) {
|
|
28
|
-
super(...modules);
|
|
29
|
-
foldTo(this, modules);
|
|
30
|
-
this.clientStateParams = combine(arguments, (arg) => arg.clientStateParamsIn);
|
|
31
|
-
this.dataIdFromObject = combine(arguments, (arg) => arg.dataIdFromObjectIn);
|
|
32
|
-
}
|
|
33
|
-
getStateParams(args = {}) {
|
|
34
|
-
const cn = this.container;
|
|
35
|
-
return ((this === null || this === void 0 ? void 0 : this.clientStateParams) || []).reduce(function (acc, curr) {
|
|
36
|
-
const defs = curr.typeDefs ? (Array.isArray(curr.typeDefs) ? curr.typeDefs : [curr.typeDefs]) : [];
|
|
37
|
-
const preLinksAccumulator = acc.preLinks || [];
|
|
38
|
-
const attemptFuncAccumulator = acc.retryLinkAttemptFuncs || [];
|
|
39
|
-
const connectionParamsFuncAccumulator = acc.connectionParams || [];
|
|
40
|
-
const callbackBackFuncAccumulator = acc.connectionCallbackFuncs || [];
|
|
41
|
-
const attemptDefaults = acc.defaults || [];
|
|
42
|
-
const schema = defs
|
|
43
|
-
.map((typeDef) => {
|
|
44
|
-
if (typeof typeDef === 'string') {
|
|
45
|
-
return typeDef;
|
|
46
|
-
}
|
|
47
|
-
console.warn(`Not supported AST format `, typeDef);
|
|
48
|
-
})
|
|
49
|
-
.map((str) => str.trim())
|
|
50
|
-
.join('\n');
|
|
51
|
-
const typeDefs = acc.typeDefs ? acc.typeDefs.concat('\n', schema) : schema;
|
|
52
|
-
const defaults = curr.defaults ? attemptDefaults.concat(curr.defaults) : attemptDefaults;
|
|
53
|
-
const resolvers = merge(acc.resolvers, consoldidatedResolvers(curr.resolvers, args.resolverContex));
|
|
54
|
-
const possibleTypes = merge(acc.possibleTypes, curr.possibleTypes);
|
|
55
|
-
const typePolicies = merge(acc.typePolicies, curr.typePolicies);
|
|
56
|
-
const retryLinkAttemptFuncs = curr.retryLinkAttemptFuncs
|
|
57
|
-
? attemptFuncAccumulator.concat(curr.retryLinkAttemptFuncs || [])
|
|
58
|
-
: attemptFuncAccumulator;
|
|
59
|
-
const preLinks = preLinksAccumulator.concat((curr.preLinkFuncs || []).map((linkF) => linkF(cn)) || []);
|
|
60
|
-
const connectionParams = curr.connectionParam
|
|
61
|
-
? connectionParamsFuncAccumulator.concat(consoldidatedConnection(curr.connectionParam, cn))
|
|
62
|
-
: connectionParamsFuncAccumulator;
|
|
63
|
-
const connectionCallbackFuncs = curr.connectionCallbackFunc
|
|
64
|
-
? callbackBackFuncAccumulator.concat(curr.connectionCallbackFunc(cn) || [])
|
|
65
|
-
: callbackBackFuncAccumulator;
|
|
66
|
-
return {
|
|
67
|
-
defaults,
|
|
68
|
-
resolvers,
|
|
69
|
-
typeDefs,
|
|
70
|
-
possibleTypes,
|
|
71
|
-
retryLinkAttemptFuncs,
|
|
72
|
-
preLinks,
|
|
73
|
-
typePolicies,
|
|
74
|
-
connectionParams,
|
|
75
|
-
connectionCallbackFuncs,
|
|
76
|
-
};
|
|
77
|
-
}, {});
|
|
78
|
-
}
|
|
79
|
-
getDataIdFromObject(result) {
|
|
80
|
-
console.log('--THIS', this);
|
|
81
|
-
const dataIdFromObject = merge({}, ...this.dataIdFromObject);
|
|
82
|
-
if (dataIdFromObject[result.__typename]) {
|
|
83
|
-
return dataIdFromObject[result.__typename](result);
|
|
84
|
-
}
|
|
85
|
-
return result.id || result._id;
|
|
86
|
-
}
|
|
87
|
-
}export{ApolloClientFeature};//# sourceMappingURL=apollo-client-feature.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apollo-client-feature.js","sources":["../../src/connector/apollo-client-feature.ts"],"sourcesContent":[null],"names":[],"mappings":"qJAeA,MAAM,OAAO,GAAG,CA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zC,kBAAE,+BAA+B,CAAC,MAAM,CAAC,uBAAuB,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;kBACzF,+BAA+B,CAAC;AACtC,YAAA,MAAM,uBAAuB,GAAG,IAAI,CAAC,sBAAsB;AACvD,kBAAE,2BAA2B,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;kBACzE,2BAA2B,CAAC;YAClC,OAAO;gBACH,QAAQ;gBACR,SAAS;gBACT,QAAQ;gBACR,aAAa;gBACb,qBAAqB;gBACrB,QAAQ;gBACR,YAAY;gBACZ,gBAAgB;gBAChB,uBAAuB;aAC1B,CAAC;SACL,EAAE,EAAkB,CAAC,CAAC;KAC1B;AACM,IAAA,mBAAmB,CAAC,MAA6E,EAAA;AACpG,QAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;QAC3B,MAAM,gBAAgB,GAAG,KAAK,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAC;AAC7D,QAAA,IAAI,gBAAgB,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;YACrC,OAAO,gBAAgB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AACtD,SAAA;AACD,QAAA,OAAO,MAAM,CAAC,EAAE,IAAK,MAAc,CAAC,GAAG,CAAC;KAC3C;AACJ"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ReducersMapObject } from 'redux';
|
|
2
|
-
import { interfaces } from 'inversify';
|
|
3
|
-
import { CommonFeature, ContainerFunc } from '@common-stack/core';
|
|
4
|
-
import { IBaseClientFeature, IBaseClientFeatureShape } from '../interfaces';
|
|
5
|
-
export declare class BaseClientFeature extends CommonFeature implements IBaseClientFeature {
|
|
6
|
-
readonly createFetchIn?: any[];
|
|
7
|
-
readonly epicIn?: any[];
|
|
8
|
-
readonly reducerIn?: ReducersMapObject[];
|
|
9
|
-
readonly createFetchOptionsIn?: any[];
|
|
10
|
-
readonly reduxPersistTransformsIn?: any[];
|
|
11
|
-
private _isContainerLoaded;
|
|
12
|
-
/**
|
|
13
|
-
* Constructs Client feature module representation, that folds all the feature modules
|
|
14
|
-
* into a single module represented by this instance.
|
|
15
|
-
* @param feature
|
|
16
|
-
* @param features
|
|
17
|
-
*/
|
|
18
|
-
constructor(...modules: IBaseClientFeatureShape[]);
|
|
19
|
-
get epics(): any[];
|
|
20
|
-
get reducers(): any;
|
|
21
|
-
get reduxPersistStateTransformers(): any[];
|
|
22
|
-
loadContainers(options: any, additionalContainerFunc?: ContainerFunc[]): interfaces.Container;
|
|
23
|
-
createService(options: any, updateOptions?: any): {
|
|
24
|
-
[key: string]: unknown;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import {merge}from'lodash';import {foldTo}from'fractal-objects';import {CommonFeature}from'@common-stack/core';class BaseClientFeature extends CommonFeature {
|
|
2
|
-
/**
|
|
3
|
-
* Constructs Client feature module representation, that folds all the feature modules
|
|
4
|
-
* into a single module represented by this instance.
|
|
5
|
-
* @param feature
|
|
6
|
-
* @param features
|
|
7
|
-
*/
|
|
8
|
-
constructor(...modules) {
|
|
9
|
-
super(...modules);
|
|
10
|
-
this._isContainerLoaded = false;
|
|
11
|
-
foldTo(this, modules);
|
|
12
|
-
}
|
|
13
|
-
get epics() {
|
|
14
|
-
return this.epicIn;
|
|
15
|
-
}
|
|
16
|
-
get reducers() {
|
|
17
|
-
return merge({}, ...(this.reducerIn || []));
|
|
18
|
-
}
|
|
19
|
-
get reduxPersistStateTransformers() {
|
|
20
|
-
return this.reduxPersistTransformsIn;
|
|
21
|
-
}
|
|
22
|
-
loadContainers(options, additionalContainerFunc) {
|
|
23
|
-
// only create once
|
|
24
|
-
if (this._isContainerLoaded) {
|
|
25
|
-
return this._container;
|
|
26
|
-
}
|
|
27
|
-
this.createContainerFuncIn.map(createModule => {
|
|
28
|
-
this._container.load(createModule(options));
|
|
29
|
-
});
|
|
30
|
-
if (additionalContainerFunc) {
|
|
31
|
-
additionalContainerFunc.map(additionalModule => {
|
|
32
|
-
this._container.load(additionalModule(options));
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
this._isContainerLoaded = true;
|
|
36
|
-
return this._container;
|
|
37
|
-
}
|
|
38
|
-
createService(options, updateOptions) {
|
|
39
|
-
// only create once
|
|
40
|
-
if (this.services) {
|
|
41
|
-
return this.services;
|
|
42
|
-
}
|
|
43
|
-
try {
|
|
44
|
-
if (!this._isContainerLoaded) {
|
|
45
|
-
this.loadContainers(options);
|
|
46
|
-
}
|
|
47
|
-
this._services = merge({}, ...this.createServiceFuncIn.map(serviceFunc => serviceFunc(this._container)));
|
|
48
|
-
return this.services;
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
throw err;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}export{BaseClientFeature};//# sourceMappingURL=base-client-feature.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base-client-feature.js","sources":["../../src/connector/base-client-feature.ts"],"sourcesContent":[null],"names":[],"mappings":"+GAOM,MAAO,iBAAkB,SAAQ,aAAa,CAAA;AAQhD;;;;;AAKG;AACH,IAAA,WAAA,CAAY,GAAG,OAAkC,EAAA;AAC7C,QAAA,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC;QARd,IAAkB,CAAA,kBAAA,GAAG,KAAK,CAAC;AAS/B,QAAA,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KACzB;AAED,IAAA,IAAW,KAAK,GAAA;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;KACtB;AAED,IAAA,IAAI,QAAQ,GAAA;AACR,QAAA,OAAO,KAAK,CAAC,EAAE,EAAE,IAAI,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC;KAC/C;AAED,IAAA,IAAI,6BAA6B,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
|
1
|
-
import { Cache } from '@apollo/client/cache';
|
|
2
|
-
import { interfaces } from 'inversify';
|
|
3
|
-
import { ConnectionParams } from 'subscriptions-transport-ws';
|
|
4
|
-
import { Resolvers, IdGetterObj, PossibleTypesMap, TypePolicies, Operation, ApolloLink } from '@apollo/client';
|
|
5
|
-
import { ErrorLink } from '@apollo/client/link/error';
|
|
6
|
-
import { IBaseClientFeatureShape } from './base-client-feature';
|
|
7
|
-
export declare type ResolverType = Resolvers | Resolvers[] | ((service: any) => Resolvers) | ((service: any) => Resolvers)[] | ((service: any) => any) | ((service: any) => any)[];
|
|
8
|
-
export declare type ApolloLinkFunc = (container: interfaces.Container) => ApolloLink;
|
|
9
|
-
export declare type ApolloConnectionParamFunc = ((container: interfaces.Container) => ConnectionParams | Promise<ConnectionParams>) | ConnectionParams;
|
|
10
|
-
export declare type IWSConnectionCallbackFunc = (webSocket: any, error: Error[], result?: any) => void | Promise<void>;
|
|
11
|
-
export declare type ApolloWSConnectionCallbackFunc = (container: interfaces.Container) => IWSConnectionCallbackFunc;
|
|
12
|
-
declare type IRetryLinkAttemptFuncs = (count: number, operation: Operation, error: any) => boolean | Promise<boolean>;
|
|
13
|
-
declare type IClientStateQueryDefault<T, V> = {
|
|
14
|
-
type: 'query';
|
|
15
|
-
} & Cache.WriteQueryOptions<T, V>;
|
|
16
|
-
declare type IClientStateFragmentDefault<T, V> = {
|
|
17
|
-
type: 'fragment';
|
|
18
|
-
} & Cache.WriteFragmentOptions<T, V>;
|
|
19
|
-
export declare type IClientStateDefault<T = unknown, V = unknown> = IClientStateFragmentDefault<T, V> | IClientStateQueryDefault<T, V>;
|
|
20
|
-
export interface IClientStateConfig {
|
|
21
|
-
/**
|
|
22
|
-
* @param: resolvers
|
|
23
|
-
* @description Apollo Link State client-state resolvers
|
|
24
|
-
*/
|
|
25
|
-
resolvers?: ResolverType;
|
|
26
|
-
defaults?: IClientStateDefault[];
|
|
27
|
-
/**
|
|
28
|
-
* @param typeDefs
|
|
29
|
-
* @description Client side Schema
|
|
30
|
-
* @inheritdoc https://www.apollographql.com/docs/react/api/link/apollo-link-schema
|
|
31
|
-
*/
|
|
32
|
-
typeDefs?: string | string[];
|
|
33
|
-
/**
|
|
34
|
-
* @param possibleTypes
|
|
35
|
-
* @description Include this object to define polymorphic relationships between schema's types.
|
|
36
|
-
* @inheritdoc https://www.apollographql.com/docs/react/caching/cache-configuration/#possibletypes
|
|
37
|
-
*/
|
|
38
|
-
possibleTypes?: PossibleTypesMap;
|
|
39
|
-
/**
|
|
40
|
-
* @param typePolicies
|
|
41
|
-
* @description Include this object to customize the cache's behavior on a type-by-type basis.
|
|
42
|
-
* @inheritdoc https://www.apollographql.com/docs/react/caching/cache-configuration/#typepolicies
|
|
43
|
-
*/
|
|
44
|
-
typePolicies?: TypePolicies;
|
|
45
|
-
/**
|
|
46
|
-
* @param retryLinkAttemptFuncs
|
|
47
|
-
* @description Attempt an operation multiple times if it return true
|
|
48
|
-
* @inheritdoc https://www.apollographql.com/docs/react/api/link/apollo-link-retry
|
|
49
|
-
*/
|
|
50
|
-
retryLinkAttemptFuncs?: IRetryLinkAttemptFuncs;
|
|
51
|
-
/**
|
|
52
|
-
* @param preLinkFuncs all `apollo-link` that need to be composed before the network link. Should be a function.
|
|
53
|
-
* @inheritdoc https://www.apollographql.com/docs/react/api/link/introduction/
|
|
54
|
-
*/
|
|
55
|
-
preLinkFuncs?: ApolloLinkFunc[];
|
|
56
|
-
/**
|
|
57
|
-
* @param connectionParam To provide connectionParam to `WebSocketLink`. It takes a single `Object` or a `Function`.
|
|
58
|
-
* @inheritdoc https://www.apollographql.com/docs/react/api/link/apollo-link-ws/
|
|
59
|
-
*/
|
|
60
|
-
connectionParam?: ApolloConnectionParamFunc;
|
|
61
|
-
/**
|
|
62
|
-
* @param connectionCallback Callback that called after the first init websocket message. Accept only one function for all modules.
|
|
63
|
-
* @inheritdoc https://github.com/apollographql/subscriptions-transport-ws/blob/51270cc7dbaf09c7b9aa67368f1de58148c7d334/README.md
|
|
64
|
-
* @deprecated
|
|
65
|
-
*/
|
|
66
|
-
connectionCallbackFunc?: ApolloWSConnectionCallbackFunc;
|
|
67
|
-
}
|
|
68
|
-
export interface IClientState {
|
|
69
|
-
resolvers?: Resolvers;
|
|
70
|
-
defaults: IClientStateDefault[];
|
|
71
|
-
typeDefs?: string | string[];
|
|
72
|
-
possibleTypes?: PossibleTypesMap;
|
|
73
|
-
retryLinkAttemptFuncs?: IRetryLinkAttemptFuncs[];
|
|
74
|
-
typePolicies?: TypePolicies;
|
|
75
|
-
preLinks: ApolloLink[];
|
|
76
|
-
connectionParams: ConnectionParams[];
|
|
77
|
-
connectionCallbackFuncs?: IWSConnectionCallbackFunc[];
|
|
78
|
-
}
|
|
79
|
-
export interface IApolloClientFeatureShape extends IBaseClientFeatureShape {
|
|
80
|
-
/**
|
|
81
|
-
* @param errorLink compose all errorLink
|
|
82
|
-
* @inheritdoc https://github.com/apollographql/apollo-link/tree/master/packages/apollo-link-error
|
|
83
|
-
*/
|
|
84
|
-
errorLinkIn?: ErrorLink[];
|
|
85
|
-
/**
|
|
86
|
-
* @param clientStateParams Client side configuration of `apollo-client`
|
|
87
|
-
* @inheritdoc https://github.com/apollographql/apollo-client/tree/2d65da133c156f6d808e64aee7e7fd5f7cc71d7f
|
|
88
|
-
*/
|
|
89
|
-
clientStateParamsIn?: IClientStateConfig[];
|
|
90
|
-
/**
|
|
91
|
-
* @param dataIdFromObject To support customize cache IDs
|
|
92
|
-
* @inheritdoc https://www.apollographql.com/docs/react/caching/cache-configuration/#dataidfromobject
|
|
93
|
-
*/
|
|
94
|
-
dataIdFromObjectIn?: {
|
|
95
|
-
[key: string]: (value?: any) => string;
|
|
96
|
-
}[];
|
|
97
|
-
}
|
|
98
|
-
export interface IApolloClientFeature extends IApolloClientFeatureShape {
|
|
99
|
-
readonly clientStateParamsIn?: IClientStateConfig[];
|
|
100
|
-
readonly dataIdFromObjectIn?: {
|
|
101
|
-
[key: string]: (value?: any) => string;
|
|
102
|
-
}[];
|
|
103
|
-
readonly errorLinkIn?: ErrorLink[];
|
|
104
|
-
/**
|
|
105
|
-
* @param args Provide resolverContext which can be passed to all resolver functions.
|
|
106
|
-
* Load the containers and create services before executing it.
|
|
107
|
-
* @returns IClientState
|
|
108
|
-
*/
|
|
109
|
-
getStateParams(args?: {
|
|
110
|
-
resolverContex?: any;
|
|
111
|
-
}): IClientState;
|
|
112
|
-
/**
|
|
113
|
-
* @name getDataIdFromObject
|
|
114
|
-
* @param result returns a unique customize identifier to be used when normalizing the data in the store
|
|
115
|
-
*/
|
|
116
|
-
getDataIdFromObject(result: {
|
|
117
|
-
[key: string]: string | number;
|
|
118
|
-
__typename?: string;
|
|
119
|
-
} | IdGetterObj): any;
|
|
120
|
-
}
|
|
121
|
-
export {};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { ContainerFunc, ICommonFeatureShape } from '@common-stack/core';
|
|
2
|
-
import { ReducersMapObject } from 'redux';
|
|
3
|
-
/**
|
|
4
|
-
* Common Module interface for React and React Native feature modules
|
|
5
|
-
*/
|
|
6
|
-
export interface IBaseClientFeatureShape extends ICommonFeatureShape {
|
|
7
|
-
createFetchIn?: any;
|
|
8
|
-
/**
|
|
9
|
-
* @param epic all `epics` that need to be composed.
|
|
10
|
-
* @inheritdoc https://redux-observable.js.org/docs/basics/Epics.html
|
|
11
|
-
*/
|
|
12
|
-
epicIn?: any;
|
|
13
|
-
/**
|
|
14
|
-
* @param reducer Redux reducers list
|
|
15
|
-
*/
|
|
16
|
-
reducerIn?: ReducersMapObject | ReducersMapObject[];
|
|
17
|
-
createFetchOptionsIn?: any;
|
|
18
|
-
/**
|
|
19
|
-
* @param reduxPersistTransforms Transforms to customize the state object that gets persisted and rehydrated.
|
|
20
|
-
* @inheritdoc https://github.com/rt2zz/redux-persist#transforms
|
|
21
|
-
*/
|
|
22
|
-
reduxPersistTransformsIn?: any[];
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Feature module methods
|
|
26
|
-
*/
|
|
27
|
-
export interface IBaseClientFeature extends IBaseClientFeatureShape {
|
|
28
|
-
readonly createFetchIn?: any;
|
|
29
|
-
readonly epicIn?: any;
|
|
30
|
-
readonly reducerIn?: ReducersMapObject[];
|
|
31
|
-
readonly createFetchOptionsIn?: any;
|
|
32
|
-
readonly reduxPersistTransformsIn?: any[];
|
|
33
|
-
/**
|
|
34
|
-
* @returns Redux-Observable Epics
|
|
35
|
-
*/
|
|
36
|
-
readonly epics: any;
|
|
37
|
-
/**
|
|
38
|
-
* @returns Redux reducers
|
|
39
|
-
*/
|
|
40
|
-
readonly reducers: any;
|
|
41
|
-
/**
|
|
42
|
-
* @returns redix persist transforms
|
|
43
|
-
*/
|
|
44
|
-
readonly reduxPersistStateTransformers: any;
|
|
45
|
-
/**
|
|
46
|
-
* Run loadContainers only once when the app start
|
|
47
|
-
* @param args Options to pass to each Container Module
|
|
48
|
-
* @returns loads container and binds all the container modules
|
|
49
|
-
*/
|
|
50
|
-
loadContainers(args: any, additionalContainers?: ContainerFunc[]): any;
|
|
51
|
-
/**
|
|
52
|
-
* Run create services only once when the app start
|
|
53
|
-
* @param options
|
|
54
|
-
* @param updateOptions
|
|
55
|
-
*/
|
|
56
|
-
createService(options: any, updateOptions?: any): any;
|
|
57
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { IBaseClientFeatureShape } from './base-client-feature';
|
|
2
|
-
export interface IClientFeatureShape extends IBaseClientFeatureShape {
|
|
3
|
-
sidebarSegmentsIn?: any[];
|
|
4
|
-
routerFactoryIn?: any[];
|
|
5
|
-
/**
|
|
6
|
-
* @param route Route list
|
|
7
|
-
*/
|
|
8
|
-
routeIn?: any[];
|
|
9
|
-
/**
|
|
10
|
-
* @param stylesInsert URL list to 3rd party css scripts
|
|
11
|
-
*/
|
|
12
|
-
stylesIn?: any[];
|
|
13
|
-
/**
|
|
14
|
-
* @param scriptsInsert URL list to 3rd party js scripts
|
|
15
|
-
*/
|
|
16
|
-
scriptsIn?: any[];
|
|
17
|
-
/**
|
|
18
|
-
* @param rootComponentFactory Root component factory list
|
|
19
|
-
*/
|
|
20
|
-
rootComponentFactoryIn?: any[];
|
|
21
|
-
/**
|
|
22
|
-
* @param dataRootComponent Data root React elements list (data root elements wraps data fetching react subtree root)
|
|
23
|
-
*/
|
|
24
|
-
dataRootComponentIn?: any[];
|
|
25
|
-
/**
|
|
26
|
-
* @param navItem Top left navigation links
|
|
27
|
-
*/
|
|
28
|
-
navItemIn?: any[];
|
|
29
|
-
/**
|
|
30
|
-
* @param navItemRightTop right navigation links
|
|
31
|
-
*/
|
|
32
|
-
navItemRightIn?: any[];
|
|
33
|
-
}
|
|
34
|
-
export interface IClientFeature extends IClientFeatureShape {
|
|
35
|
-
readonly sidebarSegmentsIn?: any[];
|
|
36
|
-
readonly routerFactoryIn?: any[];
|
|
37
|
-
readonly routeIn?: any[];
|
|
38
|
-
readonly stylesIn?: any[];
|
|
39
|
-
readonly scriptsIn?: any[];
|
|
40
|
-
readonly rootComponentFactoryIn?: any[];
|
|
41
|
-
readonly dataRootComponentIn?: any[];
|
|
42
|
-
readonly navItemIn?: any[];
|
|
43
|
-
readonly navItemRightIn?: any[];
|
|
44
|
-
/**
|
|
45
|
-
* @returns client-side top left navbar link component list
|
|
46
|
-
*/
|
|
47
|
-
readonly navItems: any;
|
|
48
|
-
/**
|
|
49
|
-
* @returns client-side top right navbar link component list
|
|
50
|
-
*/
|
|
51
|
-
readonly navItemsRight: any;
|
|
52
|
-
/**
|
|
53
|
-
* @returns URL list to 3rd party css styles
|
|
54
|
-
*/
|
|
55
|
-
readonly stylesInserts: any;
|
|
56
|
-
/**
|
|
57
|
-
* @returns URL list to 3rd party js styles
|
|
58
|
-
*/
|
|
59
|
-
readonly scriptsInserts: any;
|
|
60
|
-
/**
|
|
61
|
-
* @arguments root React tree root component
|
|
62
|
-
* @arguments req Http Request
|
|
63
|
-
* @returns React tree root component wrapped up by root components exposed by this module
|
|
64
|
-
*/
|
|
65
|
-
getWrappedRoot(root: any, req?: any): any;
|
|
66
|
-
}
|