@cratis/arc.react 18.7.20 → 18.7.21
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/commands/for_useCommand/when_creating_instance_with_initial_values.ts +3 -1
- package/dist/cjs/identity/IdentityProvider.d.ts.map +1 -1
- package/dist/cjs/identity/IdentityProvider.js +25 -9
- package/dist/cjs/identity/IdentityProvider.js.map +1 -1
- package/dist/cjs/identity/for_IdentityProvider/given/an_identity_provider.d.ts +26 -0
- package/dist/cjs/identity/for_IdentityProvider/given/an_identity_provider.d.ts.map +1 -0
- package/dist/cjs/identity/for_IdentityProvider/when_initial_fetch_fails.d.ts +2 -0
- package/dist/cjs/identity/for_IdentityProvider/when_initial_fetch_fails.d.ts.map +1 -0
- package/dist/cjs/identity/for_IdentityProvider/when_initial_fetch_succeeds.d.ts +2 -0
- package/dist/cjs/identity/for_IdentityProvider/when_initial_fetch_succeeds.d.ts.map +1 -0
- package/dist/cjs/identity/for_IdentityProvider/when_refresh_is_called/after_initial_failure.d.ts +2 -0
- package/dist/cjs/identity/for_IdentityProvider/when_refresh_is_called/after_initial_failure.d.ts.map +1 -0
- package/dist/cjs/identity/for_IdentityProvider/when_refresh_is_called/and_fails.d.ts +2 -0
- package/dist/cjs/identity/for_IdentityProvider/when_refresh_is_called/and_fails.d.ts.map +1 -0
- package/dist/cjs/identity/for_IdentityProvider/when_refresh_is_called/and_succeeds.d.ts +2 -0
- package/dist/cjs/identity/for_IdentityProvider/when_refresh_is_called/and_succeeds.d.ts.map +1 -0
- package/dist/esm/commands/for_useCommand/when_creating_instance_with_initial_values.js +3 -1
- package/dist/esm/commands/for_useCommand/when_creating_instance_with_initial_values.js.map +1 -1
- package/dist/esm/identity/IdentityProvider.d.ts.map +1 -1
- package/dist/esm/identity/IdentityProvider.js +25 -9
- package/dist/esm/identity/IdentityProvider.js.map +1 -1
- package/dist/esm/identity/for_IdentityProvider/given/an_identity_provider.d.ts +26 -0
- package/dist/esm/identity/for_IdentityProvider/given/an_identity_provider.d.ts.map +1 -0
- package/dist/esm/identity/for_IdentityProvider/given/an_identity_provider.js +75 -0
- package/dist/esm/identity/for_IdentityProvider/given/an_identity_provider.js.map +1 -0
- package/dist/esm/identity/for_IdentityProvider/when_initial_fetch_fails.d.ts +2 -0
- package/dist/esm/identity/for_IdentityProvider/when_initial_fetch_fails.d.ts.map +1 -0
- package/dist/esm/identity/for_IdentityProvider/when_initial_fetch_fails.js +27 -0
- package/dist/esm/identity/for_IdentityProvider/when_initial_fetch_fails.js.map +1 -0
- package/dist/esm/identity/for_IdentityProvider/when_initial_fetch_succeeds.d.ts +2 -0
- package/dist/esm/identity/for_IdentityProvider/when_initial_fetch_succeeds.d.ts.map +1 -0
- package/dist/esm/identity/for_IdentityProvider/when_initial_fetch_succeeds.js +21 -0
- package/dist/esm/identity/for_IdentityProvider/when_initial_fetch_succeeds.js.map +1 -0
- package/dist/esm/identity/for_IdentityProvider/when_refresh_is_called/after_initial_failure.d.ts +2 -0
- package/dist/esm/identity/for_IdentityProvider/when_refresh_is_called/after_initial_failure.d.ts.map +1 -0
- package/dist/esm/identity/for_IdentityProvider/when_refresh_is_called/after_initial_failure.js +19 -0
- package/dist/esm/identity/for_IdentityProvider/when_refresh_is_called/after_initial_failure.js.map +1 -0
- package/dist/esm/identity/for_IdentityProvider/when_refresh_is_called/and_fails.d.ts +2 -0
- package/dist/esm/identity/for_IdentityProvider/when_refresh_is_called/and_fails.d.ts.map +1 -0
- package/dist/esm/identity/for_IdentityProvider/when_refresh_is_called/and_fails.js +14 -0
- package/dist/esm/identity/for_IdentityProvider/when_refresh_is_called/and_fails.js.map +1 -0
- package/dist/esm/identity/for_IdentityProvider/when_refresh_is_called/and_succeeds.d.ts +2 -0
- package/dist/esm/identity/for_IdentityProvider/when_refresh_is_called/and_succeeds.d.ts.map +1 -0
- package/dist/esm/identity/for_IdentityProvider/when_refresh_is_called/and_succeeds.js +17 -0
- package/dist/esm/identity/for_IdentityProvider/when_refresh_is_called/and_succeeds.js.map +1 -0
- package/dist/esm/identity/for_IdentityProvider/when_refreshing_identity.js +15 -45
- package/dist/esm/identity/for_IdentityProvider/when_refreshing_identity.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/identity/IdentityProvider.tsx +28 -9
- package/identity/for_IdentityProvider/given/an_identity_provider.ts +103 -0
- package/identity/for_IdentityProvider/when_initial_fetch_fails.ts +35 -0
- package/identity/for_IdentityProvider/when_initial_fetch_succeeds.ts +29 -0
- package/identity/for_IdentityProvider/when_refresh_is_called/after_initial_failure.ts +29 -0
- package/identity/for_IdentityProvider/when_refresh_is_called/and_fails.ts +23 -0
- package/identity/for_IdentityProvider/when_refresh_is_called/and_succeeds.ts +30 -0
- package/identity/for_IdentityProvider/when_refreshing_identity.ts +17 -51
- package/package.json +2 -2
|
@@ -22,7 +22,9 @@ describe('when creating instance with initial values', () => {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
const config: ArcConfiguration = {
|
|
25
|
-
microservice: 'test-microservice'
|
|
25
|
+
microservice: 'test-microservice',
|
|
26
|
+
apiBasePath: '/api',
|
|
27
|
+
origin: 'https://example.com'
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
render(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentityProvider.d.ts","sourceRoot":"","sources":["../../../identity/IdentityProvider.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAe7C,KAAK,oBAAoB,GAAG;IACxB,QAAQ,EAAE,SAAS,CAAC;IACpB,kBAAkB,CAAC,EAAE,WAAW,CAAC;CACpC,CAAC;AAMF,eAAO,MAAM,uBAAuB,qCAAiE,CAAC;AAEtG,MAAM,WAAW,qBAAqB;IAClC,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IACvC,mBAAmB,CAAC,EAAE,cAAc,CAAC;IACrC,WAAW,CAAC,EAAE,WAAW,CAAA;CAC5B;AAED,eAAO,MAAM,gBAAgB,GAAI,OAAO,qBAAqB,
|
|
1
|
+
{"version":3,"file":"IdentityProvider.d.ts","sourceRoot":"","sources":["../../../identity/IdentityProvider.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAe7C,KAAK,oBAAoB,GAAG;IACxB,QAAQ,EAAE,SAAS,CAAC;IACpB,kBAAkB,CAAC,EAAE,WAAW,CAAC;CACpC,CAAC;AAMF,eAAO,MAAM,uBAAuB,qCAAiE,CAAC;AAEtG,MAAM,WAAW,qBAAqB;IAClC,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IACvC,mBAAmB,CAAC,EAAE,cAAc,CAAC;IACrC,WAAW,CAAC,EAAE,WAAW,CAAA;CAC5B;AAED,eAAO,MAAM,gBAAgB,GAAI,OAAO,qBAAqB,4CA4D5D,CAAC"}
|
|
@@ -22,13 +22,22 @@ const defaultContextValue = {
|
|
|
22
22
|
const IdentityProviderContext = React.createContext(defaultContextValue);
|
|
23
23
|
const IdentityProvider = (props) => {
|
|
24
24
|
const arc = React.useContext(ArcContext.ArcContext);
|
|
25
|
-
const
|
|
25
|
+
const fetchIdentity = () => {
|
|
26
|
+
return identity.IdentityProvider.getCurrent(props.detailsType).then(identity => {
|
|
27
|
+
const wrappedIdentity = wrapRefresh(identity);
|
|
28
|
+
setContext({
|
|
29
|
+
identity: wrappedIdentity,
|
|
30
|
+
detailsConstructor: props.detailsType
|
|
31
|
+
});
|
|
32
|
+
return wrappedIdentity;
|
|
33
|
+
});
|
|
34
|
+
};
|
|
26
35
|
const wrapRefresh = (identity) => {
|
|
27
36
|
const originalRefresh = identity.refresh.bind(identity);
|
|
28
37
|
return {
|
|
29
38
|
...identity,
|
|
30
39
|
refresh: () => {
|
|
31
|
-
return new Promise(resolve => {
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
32
41
|
originalRefresh().then(newIdentity => {
|
|
33
42
|
const wrappedIdentity = wrapRefresh(newIdentity);
|
|
34
43
|
setContext({
|
|
@@ -36,21 +45,28 @@ const IdentityProvider = (props) => {
|
|
|
36
45
|
detailsConstructor: props.detailsType
|
|
37
46
|
});
|
|
38
47
|
resolve(wrappedIdentity);
|
|
39
|
-
});
|
|
48
|
+
}).catch(reject);
|
|
40
49
|
});
|
|
41
50
|
}
|
|
42
51
|
};
|
|
43
52
|
};
|
|
53
|
+
const initialIdentity = {
|
|
54
|
+
id: '',
|
|
55
|
+
name: '',
|
|
56
|
+
details: {},
|
|
57
|
+
isSet: false,
|
|
58
|
+
refresh: () => fetchIdentity()
|
|
59
|
+
};
|
|
60
|
+
const [context, setContext] = React.useState({
|
|
61
|
+
identity: wrapRefresh(initialIdentity),
|
|
62
|
+
detailsConstructor: props.detailsType
|
|
63
|
+
});
|
|
44
64
|
React.useEffect(() => {
|
|
45
65
|
identity.IdentityProvider.setHttpHeadersCallback(props.httpHeadersCallback);
|
|
46
66
|
identity.IdentityProvider.setApiBasePath(arc.apiBasePath ?? '');
|
|
47
67
|
identity.IdentityProvider.setOrigin(arc.origin ?? '');
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
setContext({
|
|
51
|
-
identity: wrappedIdentity,
|
|
52
|
-
detailsConstructor: props.detailsType
|
|
53
|
-
});
|
|
68
|
+
fetchIdentity().catch(error => {
|
|
69
|
+
console.error('Failed to fetch initial identity:', error);
|
|
54
70
|
});
|
|
55
71
|
}, []);
|
|
56
72
|
return (jsxRuntime.jsx(IdentityProviderContext.Provider, { value: context, children: props.children }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentityProvider.js","sources":["../../../identity/IdentityProvider.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport React from 'react';\nimport { useState, useEffect, useContext } from 'react';\nimport { Constructor } from '@cratis/fundamentals';\nimport { IIdentity } from '@cratis/arc/identity';\nimport { IdentityProvider as RootIdentityProvider } from '@cratis/arc/identity';\nimport { GetHttpHeaders } from '@cratis/arc';\nimport { ArcContext } from '../ArcContext';\n\nconst defaultIdentityContext: IIdentity = {\n id: '',\n name: '',\n details: {},\n isSet: false,\n refresh: () => {\n return new Promise((resolve, reject) => {\n reject('Not implemented');\n });\n }\n};\n\ntype IdentityContextValue = {\n identity: IIdentity;\n detailsConstructor?: Constructor;\n};\n\nconst defaultContextValue: IdentityContextValue = {\n identity: defaultIdentityContext\n};\n\nexport const IdentityProviderContext = React.createContext<IdentityContextValue>(defaultContextValue);\n\nexport interface IdentityProviderProps {\n children?: JSX.Element | JSX.Element[],\n httpHeadersCallback?: GetHttpHeaders,\n detailsType?: Constructor\n}\n\nexport const IdentityProvider = (props: IdentityProviderProps) => {\n const arc = useContext(ArcContext);\n const
|
|
1
|
+
{"version":3,"file":"IdentityProvider.js","sources":["../../../identity/IdentityProvider.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport React from 'react';\nimport { useState, useEffect, useContext } from 'react';\nimport { Constructor } from '@cratis/fundamentals';\nimport { IIdentity } from '@cratis/arc/identity';\nimport { IdentityProvider as RootIdentityProvider } from '@cratis/arc/identity';\nimport { GetHttpHeaders } from '@cratis/arc';\nimport { ArcContext } from '../ArcContext';\n\nconst defaultIdentityContext: IIdentity = {\n id: '',\n name: '',\n details: {},\n isSet: false,\n refresh: () => {\n return new Promise((resolve, reject) => {\n reject('Not implemented');\n });\n }\n};\n\ntype IdentityContextValue = {\n identity: IIdentity;\n detailsConstructor?: Constructor;\n};\n\nconst defaultContextValue: IdentityContextValue = {\n identity: defaultIdentityContext\n};\n\nexport const IdentityProviderContext = React.createContext<IdentityContextValue>(defaultContextValue);\n\nexport interface IdentityProviderProps {\n children?: JSX.Element | JSX.Element[],\n httpHeadersCallback?: GetHttpHeaders,\n detailsType?: Constructor\n}\n\nexport const IdentityProvider = (props: IdentityProviderProps) => {\n const arc = useContext(ArcContext);\n \n const fetchIdentity = (): Promise<IIdentity> => {\n return RootIdentityProvider.getCurrent(props.detailsType).then(identity => {\n const wrappedIdentity = wrapRefresh(identity);\n setContext({\n identity: wrappedIdentity,\n detailsConstructor: props.detailsType\n });\n return wrappedIdentity;\n });\n };\n\n const wrapRefresh = (identity: IIdentity): IIdentity => {\n const originalRefresh = identity.refresh.bind(identity);\n return {\n ...identity,\n refresh: () => {\n return new Promise<IIdentity>((resolve, reject) => {\n originalRefresh().then(newIdentity => {\n const wrappedIdentity = wrapRefresh(newIdentity);\n setContext({\n identity: wrappedIdentity,\n detailsConstructor: props.detailsType\n });\n resolve(wrappedIdentity);\n }).catch(reject);\n });\n }\n };\n };\n\n const initialIdentity: IIdentity = {\n id: '',\n name: '',\n details: {},\n isSet: false,\n refresh: () => fetchIdentity()\n };\n\n const [context, setContext] = useState<IdentityContextValue>({\n identity: wrapRefresh(initialIdentity),\n detailsConstructor: props.detailsType\n });\n\n useEffect(() => {\n RootIdentityProvider.setHttpHeadersCallback(props.httpHeadersCallback!);\n RootIdentityProvider.setApiBasePath(arc.apiBasePath ?? '');\n RootIdentityProvider.setOrigin(arc.origin ?? '');\n fetchIdentity().catch(error => {\n console.error('Failed to fetch initial identity:', error);\n });\n }, []);\n\n return (\n <IdentityProviderContext.Provider value={context}>\n {props.children}\n </IdentityProviderContext.Provider>\n );\n};\n"],"names":["useContext","ArcContext","RootIdentityProvider","useState","useEff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2
|
+
import { RenderResult } from '@testing-library/react';
|
|
3
|
+
import sinon from 'sinon';
|
|
4
|
+
import { IIdentity } from '@cratis/arc/identity';
|
|
5
|
+
import { createFetchHelper } from '@cratis/arc/helpers/fetchHelper';
|
|
6
|
+
import { Constructor } from '@cratis/fundamentals';
|
|
7
|
+
export declare class an_identity_provider {
|
|
8
|
+
capturedIdentity: IIdentity | null;
|
|
9
|
+
renderCount: number;
|
|
10
|
+
renderResult: RenderResult;
|
|
11
|
+
originalApiBasePath: string;
|
|
12
|
+
originalOrigin: string;
|
|
13
|
+
private originalConsoleError?;
|
|
14
|
+
fetchHelper: ReturnType<typeof createFetchHelper>;
|
|
15
|
+
fetchStub: sinon.SinonStub;
|
|
16
|
+
constructor();
|
|
17
|
+
setupSuccessfulIdentityFetch(id: string, name: string, details?: object): void;
|
|
18
|
+
setupFailedIdentityFetch(): void;
|
|
19
|
+
createTestComponent(): () => React.DetailedReactHTMLElement<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
20
|
+
renderProvider(detailsType?: Constructor): void;
|
|
21
|
+
waitForAsyncUpdates(): Promise<void>;
|
|
22
|
+
suppressConsoleErrors(): void;
|
|
23
|
+
restoreConsole(): void;
|
|
24
|
+
cleanup(): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=an_identity_provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"an_identity_provider.d.ts","sourceRoot":"","sources":["../../../../../identity/for_IdentityProvider/given/an_identity_provider.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAU,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,qBAAa,oBAAoB;IAC7B,gBAAgB,EAAE,SAAS,GAAG,IAAI,CAAQ;IAC1C,WAAW,SAAK;IAChB,YAAY,EAAG,YAAY,CAAC;IAC5B,mBAAmB,SAAM;IACzB,cAAc,SAAM;IACpB,OAAO,CAAC,oBAAoB,CAAC,CAAuB;IACpD,WAAW,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAClD,SAAS,EAAG,KAAK,CAAC,SAAS,CAAC;;IAY5B,4BAA4B,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,MAAW;IAO3E,wBAAwB;IAKxB,mBAAmB;IAQnB,cAAc,CAAC,WAAW,CAAC,EAAE,WAAW;IAqBlC,mBAAmB;IAIzB,qBAAqB;IAOrB,cAAc;IAOd,OAAO;CASV"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_initial_fetch_fails.d.ts","sourceRoot":"","sources":["../../../../identity/for_IdentityProvider/when_initial_fetch_fails.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_initial_fetch_succeeds.d.ts","sourceRoot":"","sources":["../../../../identity/for_IdentityProvider/when_initial_fetch_succeeds.ts"],"names":[],"mappings":""}
|
package/dist/cjs/identity/for_IdentityProvider/when_refresh_is_called/after_initial_failure.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"after_initial_failure.d.ts","sourceRoot":"","sources":["../../../../../identity/for_IdentityProvider/when_refresh_is_called/after_initial_failure.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"and_fails.d.ts","sourceRoot":"","sources":["../../../../../identity/for_IdentityProvider/when_refresh_is_called/and_fails.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"and_succeeds.d.ts","sourceRoot":"","sources":["../../../../../identity/for_IdentityProvider/when_refresh_is_called/and_succeeds.ts"],"names":[],"mappings":""}
|
|
@@ -15,7 +15,9 @@ describe('when creating instance with initial values', () => {
|
|
|
15
15
|
return React.createElement('div', null, 'Test');
|
|
16
16
|
};
|
|
17
17
|
const config = {
|
|
18
|
-
microservice: 'test-microservice'
|
|
18
|
+
microservice: 'test-microservice',
|
|
19
|
+
apiBasePath: '/api',
|
|
20
|
+
origin: 'https://example.com'
|
|
19
21
|
};
|
|
20
22
|
render(React.createElement(ArcContext.Provider, { value: config }, React.createElement(TestComponent)));
|
|
21
23
|
it('should set someProperty from initial values', () => capturedCommand.someProperty.should.equal('initial-value'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"when_creating_instance_with_initial_values.js","sourceRoot":"","sources":["../../../../commands/for_useCommand/when_creating_instance_with_initial_values.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAsB,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,UAAU,EAAoB,MAAM,kBAAkB,CAAC;AAEhE,QAAQ,CAAC,4CAA4C,EAAE,GAAG,EAAE;IACxD,IAAI,eAAe,GAAuB,IAAI,CAAC;IAE/C,MAAM,aAAa,GAAuB;QACtC,YAAY,EAAE,eAAe;QAC7B,eAAe,EAAE,EAAE;KACtB,CAAC;IAEF,MAAM,aAAa,GAAG,GAAG,EAAE;QACvB,MAAM,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QACzD,eAAe,GAAG,OAAO,CAAC;QAC1B,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC,CAAC;IAEF,MAAM,MAAM,GAAqB;QAC7B,YAAY,EAAE,mBAAmB;
|
|
1
|
+
{"version":3,"file":"when_creating_instance_with_initial_values.js","sourceRoot":"","sources":["../../../../commands/for_useCommand/when_creating_instance_with_initial_values.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAsB,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,UAAU,EAAoB,MAAM,kBAAkB,CAAC;AAEhE,QAAQ,CAAC,4CAA4C,EAAE,GAAG,EAAE;IACxD,IAAI,eAAe,GAAuB,IAAI,CAAC;IAE/C,MAAM,aAAa,GAAuB;QACtC,YAAY,EAAE,eAAe;QAC7B,eAAe,EAAE,EAAE;KACtB,CAAC;IAEF,MAAM,aAAa,GAAG,GAAG,EAAE;QACvB,MAAM,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QACzD,eAAe,GAAG,OAAO,CAAC;QAC1B,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC,CAAC;IAEF,MAAM,MAAM,GAAqB;QAC7B,YAAY,EAAE,mBAAmB;QACjC,WAAW,EAAE,MAAM;QACnB,MAAM,EAAE,qBAAqB;KAChC,CAAC;IAEF,MAAM,CACF,KAAK,CAAC,aAAa,CACf,UAAU,CAAC,QAAQ,EACnB,EAAE,KAAK,EAAE,MAAM,EAAE,EACjB,KAAK,CAAC,aAAa,CAAC,aAAa,CAAC,CACrC,CACJ,CAAC;IAEF,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE,CAAC,eAAgB,CAAC,YAAa,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;IACtH,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE,CAAC,eAAgB,CAAC,eAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;AACnH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentityProvider.d.ts","sourceRoot":"","sources":["../../../identity/IdentityProvider.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAe7C,KAAK,oBAAoB,GAAG;IACxB,QAAQ,EAAE,SAAS,CAAC;IACpB,kBAAkB,CAAC,EAAE,WAAW,CAAC;CACpC,CAAC;AAMF,eAAO,MAAM,uBAAuB,qCAAiE,CAAC;AAEtG,MAAM,WAAW,qBAAqB;IAClC,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IACvC,mBAAmB,CAAC,EAAE,cAAc,CAAC;IACrC,WAAW,CAAC,EAAE,WAAW,CAAA;CAC5B;AAED,eAAO,MAAM,gBAAgB,GAAI,OAAO,qBAAqB,
|
|
1
|
+
{"version":3,"file":"IdentityProvider.d.ts","sourceRoot":"","sources":["../../../identity/IdentityProvider.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAe7C,KAAK,oBAAoB,GAAG;IACxB,QAAQ,EAAE,SAAS,CAAC;IACpB,kBAAkB,CAAC,EAAE,WAAW,CAAC;CACpC,CAAC;AAMF,eAAO,MAAM,uBAAuB,qCAAiE,CAAC;AAEtG,MAAM,WAAW,qBAAqB;IAClC,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IACvC,mBAAmB,CAAC,EAAE,cAAc,CAAC;IACrC,WAAW,CAAC,EAAE,WAAW,CAAA;CAC5B;AAED,eAAO,MAAM,gBAAgB,GAAI,OAAO,qBAAqB,4CA4D5D,CAAC"}
|
|
@@ -20,13 +20,22 @@ const defaultContextValue = {
|
|
|
20
20
|
const IdentityProviderContext = React__default.createContext(defaultContextValue);
|
|
21
21
|
const IdentityProvider = (props) => {
|
|
22
22
|
const arc = useContext(ArcContext);
|
|
23
|
-
const
|
|
23
|
+
const fetchIdentity = () => {
|
|
24
|
+
return IdentityProvider$1.getCurrent(props.detailsType).then(identity => {
|
|
25
|
+
const wrappedIdentity = wrapRefresh(identity);
|
|
26
|
+
setContext({
|
|
27
|
+
identity: wrappedIdentity,
|
|
28
|
+
detailsConstructor: props.detailsType
|
|
29
|
+
});
|
|
30
|
+
return wrappedIdentity;
|
|
31
|
+
});
|
|
32
|
+
};
|
|
24
33
|
const wrapRefresh = (identity) => {
|
|
25
34
|
const originalRefresh = identity.refresh.bind(identity);
|
|
26
35
|
return {
|
|
27
36
|
...identity,
|
|
28
37
|
refresh: () => {
|
|
29
|
-
return new Promise(resolve => {
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
30
39
|
originalRefresh().then(newIdentity => {
|
|
31
40
|
const wrappedIdentity = wrapRefresh(newIdentity);
|
|
32
41
|
setContext({
|
|
@@ -34,21 +43,28 @@ const IdentityProvider = (props) => {
|
|
|
34
43
|
detailsConstructor: props.detailsType
|
|
35
44
|
});
|
|
36
45
|
resolve(wrappedIdentity);
|
|
37
|
-
});
|
|
46
|
+
}).catch(reject);
|
|
38
47
|
});
|
|
39
48
|
}
|
|
40
49
|
};
|
|
41
50
|
};
|
|
51
|
+
const initialIdentity = {
|
|
52
|
+
id: '',
|
|
53
|
+
name: '',
|
|
54
|
+
details: {},
|
|
55
|
+
isSet: false,
|
|
56
|
+
refresh: () => fetchIdentity()
|
|
57
|
+
};
|
|
58
|
+
const [context, setContext] = useState({
|
|
59
|
+
identity: wrapRefresh(initialIdentity),
|
|
60
|
+
detailsConstructor: props.detailsType
|
|
61
|
+
});
|
|
42
62
|
useEffect(() => {
|
|
43
63
|
IdentityProvider$1.setHttpHeadersCallback(props.httpHeadersCallback);
|
|
44
64
|
IdentityProvider$1.setApiBasePath(arc.apiBasePath ?? '');
|
|
45
65
|
IdentityProvider$1.setOrigin(arc.origin ?? '');
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
setContext({
|
|
49
|
-
identity: wrappedIdentity,
|
|
50
|
-
detailsConstructor: props.detailsType
|
|
51
|
-
});
|
|
66
|
+
fetchIdentity().catch(error => {
|
|
67
|
+
console.error('Failed to fetch initial identity:', error);
|
|
52
68
|
});
|
|
53
69
|
}, []);
|
|
54
70
|
return (jsx(IdentityProviderContext.Provider, { value: context, children: props.children }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentityProvider.js","sources":["../../../identity/IdentityProvider.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport React from 'react';\nimport { useState, useEffect, useContext } from 'react';\nimport { Constructor } from '@cratis/fundamentals';\nimport { IIdentity } from '@cratis/arc/identity';\nimport { IdentityProvider as RootIdentityProvider } from '@cratis/arc/identity';\nimport { GetHttpHeaders } from '@cratis/arc';\nimport { ArcContext } from '../ArcContext';\n\nconst defaultIdentityContext: IIdentity = {\n id: '',\n name: '',\n details: {},\n isSet: false,\n refresh: () => {\n return new Promise((resolve, reject) => {\n reject('Not implemented');\n });\n }\n};\n\ntype IdentityContextValue = {\n identity: IIdentity;\n detailsConstructor?: Constructor;\n};\n\nconst defaultContextValue: IdentityContextValue = {\n identity: defaultIdentityContext\n};\n\nexport const IdentityProviderContext = React.createContext<IdentityContextValue>(defaultContextValue);\n\nexport interface IdentityProviderProps {\n children?: JSX.Element | JSX.Element[],\n httpHeadersCallback?: GetHttpHeaders,\n detailsType?: Constructor\n}\n\nexport const IdentityProvider = (props: IdentityProviderProps) => {\n const arc = useContext(ArcContext);\n const
|
|
1
|
+
{"version":3,"file":"IdentityProvider.js","sources":["../../../identity/IdentityProvider.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport React from 'react';\nimport { useState, useEffect, useContext } from 'react';\nimport { Constructor } from '@cratis/fundamentals';\nimport { IIdentity } from '@cratis/arc/identity';\nimport { IdentityProvider as RootIdentityProvider } from '@cratis/arc/identity';\nimport { GetHttpHeaders } from '@cratis/arc';\nimport { ArcContext } from '../ArcContext';\n\nconst defaultIdentityContext: IIdentity = {\n id: '',\n name: '',\n details: {},\n isSet: false,\n refresh: () => {\n return new Promise((resolve, reject) => {\n reject('Not implemented');\n });\n }\n};\n\ntype IdentityContextValue = {\n identity: IIdentity;\n detailsConstructor?: Constructor;\n};\n\nconst defaultContextValue: IdentityContextValue = {\n identity: defaultIdentityContext\n};\n\nexport const IdentityProviderContext = React.createContext<IdentityContextValue>(defaultContextValue);\n\nexport interface IdentityProviderProps {\n children?: JSX.Element | JSX.Element[],\n httpHeadersCallback?: GetHttpHeaders,\n detailsType?: Constructor\n}\n\nexport const IdentityProvider = (props: IdentityProviderProps) => {\n const arc = useContext(ArcContext);\n \n const fetchIdentity = (): Promise<IIdentity> => {\n return RootIdentityProvider.getCurrent(props.detailsType).then(identity => {\n const wrappedIdentity = wrapRefresh(identity);\n setContext({\n identity: wrappedIdentity,\n detailsConstructor: props.detailsType\n });\n return wrappedIdentity;\n });\n };\n\n const wrapRefresh = (identity: IIdentity): IIdentity => {\n const originalRefresh = identity.refresh.bind(identity);\n return {\n ...identity,\n refresh: () => {\n return new Promise<IIdentity>((resolve, reject) => {\n originalRefresh().then(newIdentity => {\n const wrappedIdentity = wrapRefresh(newIdentity);\n setContext({\n identity: wrappedIdentity,\n detailsConstructor: props.detailsType\n });\n resolve(wrappedIdentity);\n }).catch(reject);\n });\n }\n };\n };\n\n const initialIdentity: IIdentity = {\n id: '',\n name: '',\n details: {},\n isSet: false,\n refresh: () => fetchIdentity()\n };\n\n const [context, setContext] = useState<IdentityContextValue>({\n identity: wrapRefresh(initialIdentity),\n detailsConstructor: props.detailsType\n });\n\n useEffect(() => {\n RootIdentityProvider.setHttpHeadersCallback(props.httpHeadersCallback!);\n RootIdentityProvider.setApiBasePath(arc.apiBasePath ?? '');\n RootIdentityProvider.setOrigin(arc.origin ?? '');\n fetchIdentity().catch(error => {\n console.error('Failed to fetch initial identity:', error);\n });\n }, []);\n\n return (\n <IdentityProviderContext.Provider value={context}>\n {props.children}\n </IdentityProviderContext.Provider>\n );\n};\n"],"names":["React","RootIdentityProvider","_jsx"],"mappings":";;;;;AAWA,MAAM,sBAAsB,GAAc;AACtC,IAAA,EAAE,EAAE,EAAE;AACN,IAAA,IAAI,EAAE,EAAE;AACR,IAAA,OAAO,EAAE,EAAE;AACX,IAAA,KAAK,EAAE,KAAK;IACZ,OAAO,EAAE,MAAK;QACV,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAI;YACnC,MAAM,CAAC,iBAAiB,CAAC;AAC7B,QAAA,CAAC,CAAC;IACN;CACH;AAOD,MAAM,mBAAmB,GAAyB;AAC9C,IAAA,QAAQ,EAAE;CACb;AAEM,MAAM,uBAAuB,GAAGA,cAAK,CAAC,aAAa,CAAuB,mBAAmB;AAQ7F,MAAM,gBAAgB,GAAG,CAAC,KAA4B,KAAI;AAC7D,IAAA,MAAM,GAAG,GAAG,UAAU,CAAC,UAAU,CAAC;IAElC,MAAM,aAAa,GAAG,MAAyB;AAC3C,QAAA,OAAOC,kBAAoB,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAG;AACtE,YAAA,MAAM,eAAe,GAAG,WAA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C,mBAAoB,CAAC;QACvEA,kBAAoB,CAAC,cAAc,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC;QAC1DA,kBAAoB,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC;AAChD,QAAA,aAAa,EAAE,CAAC,KAAK,CAAC,KAAK,IAAG;AAC1B,YAAA,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,KAAK,CAAC;AAC7D,QAAA,CAAC,CAAC;IACN,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,QACIC,GAAA,CAAC,uBAAuB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,OAAO,YAC3C,KAAK,CAAC,QAAQ,EAAA,CACgB;AAE3C;;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RenderResult } from '@testing-library/react';
|
|
3
|
+
import sinon from 'sinon';
|
|
4
|
+
import { IIdentity } from '@cratis/arc/identity';
|
|
5
|
+
import { createFetchHelper } from '@cratis/arc/helpers/fetchHelper';
|
|
6
|
+
import { Constructor } from '@cratis/fundamentals';
|
|
7
|
+
export declare class an_identity_provider {
|
|
8
|
+
capturedIdentity: IIdentity | null;
|
|
9
|
+
renderCount: number;
|
|
10
|
+
renderResult: RenderResult;
|
|
11
|
+
originalApiBasePath: string;
|
|
12
|
+
originalOrigin: string;
|
|
13
|
+
private originalConsoleError?;
|
|
14
|
+
fetchHelper: ReturnType<typeof createFetchHelper>;
|
|
15
|
+
fetchStub: sinon.SinonStub;
|
|
16
|
+
constructor();
|
|
17
|
+
setupSuccessfulIdentityFetch(id: string, name: string, details?: object): void;
|
|
18
|
+
setupFailedIdentityFetch(): void;
|
|
19
|
+
createTestComponent(): () => React.DetailedReactHTMLElement<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
20
|
+
renderProvider(detailsType?: Constructor): void;
|
|
21
|
+
waitForAsyncUpdates(): Promise<void>;
|
|
22
|
+
suppressConsoleErrors(): void;
|
|
23
|
+
restoreConsole(): void;
|
|
24
|
+
cleanup(): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=an_identity_provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"an_identity_provider.d.ts","sourceRoot":"","sources":["../../../../../identity/for_IdentityProvider/given/an_identity_provider.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAU,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,qBAAa,oBAAoB;IAC7B,gBAAgB,EAAE,SAAS,GAAG,IAAI,CAAQ;IAC1C,WAAW,SAAK;IAChB,YAAY,EAAG,YAAY,CAAC;IAC5B,mBAAmB,SAAM;IACzB,cAAc,SAAM;IACpB,OAAO,CAAC,oBAAoB,CAAC,CAAuB;IACpD,WAAW,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAClD,SAAS,EAAG,KAAK,CAAC,SAAS,CAAC;;IAY5B,4BAA4B,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,MAAW;IAO3E,wBAAwB;IAKxB,mBAAmB;IAQnB,cAAc,CAAC,WAAW,CAAC,EAAE,WAAW;IAqBlC,mBAAmB;IAIzB,qBAAqB;IAOrB,cAAc;IAOd,OAAO;CASV"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { IdentityProvider } from '../../IdentityProvider';
|
|
4
|
+
import { useIdentity } from '../../useIdentity';
|
|
5
|
+
import { ArcContext } from '../../../ArcContext';
|
|
6
|
+
import { IdentityProvider as RootIdentityProvider } from '@cratis/arc/identity';
|
|
7
|
+
import { createFetchHelper } from '@cratis/arc/helpers/fetchHelper';
|
|
8
|
+
export class an_identity_provider {
|
|
9
|
+
capturedIdentity = null;
|
|
10
|
+
renderCount = 0;
|
|
11
|
+
renderResult;
|
|
12
|
+
originalApiBasePath = '';
|
|
13
|
+
originalOrigin = '';
|
|
14
|
+
originalConsoleError;
|
|
15
|
+
fetchHelper;
|
|
16
|
+
fetchStub;
|
|
17
|
+
constructor() {
|
|
18
|
+
this.originalApiBasePath = RootIdentityProvider.apiBasePath;
|
|
19
|
+
this.originalOrigin = RootIdentityProvider.origin;
|
|
20
|
+
RootIdentityProvider.setOrigin('https://example.com');
|
|
21
|
+
RootIdentityProvider.setApiBasePath('https://example.com/api');
|
|
22
|
+
this.fetchHelper = createFetchHelper();
|
|
23
|
+
}
|
|
24
|
+
setupSuccessfulIdentityFetch(id, name, details = {}) {
|
|
25
|
+
this.fetchStub = this.fetchHelper.stubFetch();
|
|
26
|
+
this.fetchStub.resolves({
|
|
27
|
+
json: async () => ({ id, name, details })
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
setupFailedIdentityFetch() {
|
|
31
|
+
this.fetchStub = this.fetchHelper.stubFetch();
|
|
32
|
+
this.fetchStub.rejects(new Error('Failed to fetch'));
|
|
33
|
+
}
|
|
34
|
+
createTestComponent() {
|
|
35
|
+
return () => {
|
|
36
|
+
this.renderCount++;
|
|
37
|
+
this.capturedIdentity = useIdentity();
|
|
38
|
+
return React.createElement('div', null, 'Test');
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
renderProvider(detailsType) {
|
|
42
|
+
const arcContext = {
|
|
43
|
+
microservice: 'test-microservice',
|
|
44
|
+
apiBasePath: '/api',
|
|
45
|
+
origin: 'http://localhost'
|
|
46
|
+
};
|
|
47
|
+
const TestComponent = this.createTestComponent();
|
|
48
|
+
this.renderResult = render(React.createElement(ArcContext.Provider, { value: arcContext }, React.createElement(IdentityProvider, { detailsType }, React.createElement(TestComponent))));
|
|
49
|
+
}
|
|
50
|
+
async waitForAsyncUpdates() {
|
|
51
|
+
await new Promise(resolve => setTimeout(resolve, 200));
|
|
52
|
+
}
|
|
53
|
+
suppressConsoleErrors() {
|
|
54
|
+
if (!this.originalConsoleError) {
|
|
55
|
+
this.originalConsoleError = console.error;
|
|
56
|
+
console.error = () => { };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
restoreConsole() {
|
|
60
|
+
if (this.originalConsoleError) {
|
|
61
|
+
console.error = this.originalConsoleError;
|
|
62
|
+
this.originalConsoleError = undefined;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
cleanup() {
|
|
66
|
+
this.restoreConsole();
|
|
67
|
+
this.fetchHelper.restore();
|
|
68
|
+
RootIdentityProvider.setApiBasePath(this.originalApiBasePath);
|
|
69
|
+
RootIdentityProvider.setOrigin(this.originalOrigin);
|
|
70
|
+
if (this.renderResult) {
|
|
71
|
+
this.renderResult.unmount();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=an_identity_provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"an_identity_provider.js","sourceRoot":"","sources":["../../../../../identity/for_IdentityProvider/given/an_identity_provider.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAgB,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;A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I,CAAC,YAAY,EAAE,CAAC;YACpB,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAChC,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_initial_fetch_fails.d.ts","sourceRoot":"","sources":["../../../../identity/for_IdentityProvider/when_initial_fetch_fails.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { given } from '../../given';
|
|
2
|
+
import { an_identity_provider } from './given/an_identity_provider';
|
|
3
|
+
describe('when initial fetch fails', given(an_identity_provider, context => {
|
|
4
|
+
let identityId;
|
|
5
|
+
let identityName;
|
|
6
|
+
let isSet;
|
|
7
|
+
let hasRefreshMethod;
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
context.setupFailedIdentityFetch();
|
|
10
|
+
context.suppressConsoleErrors();
|
|
11
|
+
context.renderProvider();
|
|
12
|
+
await context.waitForAsyncUpdates();
|
|
13
|
+
identityId = context.capturedIdentity.id;
|
|
14
|
+
identityName = context.capturedIdentity.name;
|
|
15
|
+
isSet = context.capturedIdentity.isSet;
|
|
16
|
+
hasRefreshMethod = typeof context.capturedIdentity.refresh === 'function';
|
|
17
|
+
});
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
context.restoreConsole();
|
|
20
|
+
context.cleanup();
|
|
21
|
+
});
|
|
22
|
+
it('should have empty identity id', () => identityId.should.equal(''));
|
|
23
|
+
it('should have empty identity name', () => identityName.should.equal(''));
|
|
24
|
+
it('should mark identity as not set', () => isSet.should.be.false);
|
|
25
|
+
it('should still have refresh method available', () => hasRefreshMethod.should.be.true);
|
|
26
|
+
}));
|
|
27
|
+
//# sourceMappingURL=when_initial_fetch_fails.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_initial_fetch_fails.js","sourceRoot":"","sources":["../../../../identity/for_IdentityProvider/when_initial_fetch_fails.ts"],"names":[],"mappings":"AAGA,OAAO,EAA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E,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AAC5F,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_initial_fetch_succeeds.d.ts","sourceRoot":"","sources":["../../../../identity/for_IdentityProvider/when_initial_fetch_succeeds.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { given } from '../../given';
|
|
2
|
+
import { an_identity_provider } from './given/an_identity_provider';
|
|
3
|
+
describe('when initial fetch succeeds', given(an_identity_provider, context => {
|
|
4
|
+
let identityId;
|
|
5
|
+
let identityName;
|
|
6
|
+
let isSet;
|
|
7
|
+
beforeEach(async () => {
|
|
8
|
+
context.setupSuccessfulIdentityFetch('user-123', 'John Doe', { role: 'admin' });
|
|
9
|
+
context.renderProvider();
|
|
10
|
+
await context.waitForAsyncUpdates();
|
|
11
|
+
identityId = context.capturedIdentity.id;
|
|
12
|
+
identityName = context.capturedIdentity.name;
|
|
13
|
+
isSet = context.capturedIdentity.isSet;
|
|
14
|
+
});
|
|
15
|
+
afterEach(() => context.cleanup());
|
|
16
|
+
it('should set identity id', () => identityId.should.equal('user-123'));
|
|
17
|
+
it('should set identity name', () => identityName.should.equal('John Doe'));
|
|
18
|
+
it('should mark identity as set', () => isSet.should.be.true);
|
|
19
|
+
it('should have refresh method', () => context.capturedIdentity.refresh.should.be.a('function'));
|
|
20
|
+
}));
|
|
21
|
+
//# sourceMappingURL=when_initial_fetch_succeeds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_initial_fetch_succeeds.js","sourceRoot":"","sources":["../../../../identity/for_IdentityProvider/when_initial_fetch_succeeds.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,QAAQ,CAAC,6BAA6B,E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":"after_initial_failure.d.ts","sourceRoot":"","sources":["../../../../../identity/for_IdentityProvider/when_refresh_is_called/after_initial_failure.ts"],"names":[],"mappings":""}
|
package/dist/esm/identity/for_IdentityProvider/when_refresh_is_called/after_initial_failure.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { given } from '../../../given';
|
|
2
|
+
import { an_identity_provider } from '../given/an_identity_provider';
|
|
3
|
+
describe('when refresh is called after initial failure', given(an_identity_provider, context => {
|
|
4
|
+
beforeEach(async () => {
|
|
5
|
+
context.setupFailedIdentityFetch();
|
|
6
|
+
context.suppressConsoleErrors();
|
|
7
|
+
context.renderProvider();
|
|
8
|
+
await context.waitForAsyncUpdates();
|
|
9
|
+
});
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
context.restoreConsole();
|
|
12
|
+
context.cleanup();
|
|
13
|
+
});
|
|
14
|
+
it('should have empty identity id', () => context.capturedIdentity.id.should.equal(''));
|
|
15
|
+
it('should have empty identity name', () => context.capturedIdentity.name.should.equal(''));
|
|
16
|
+
it('should mark identity as not set', () => context.capturedIdentity.isSet.should.be.false);
|
|
17
|
+
it('should have refresh method available for retry', () => (typeof context.capturedIdentity.refresh).should.equal('function'));
|
|
18
|
+
}));
|
|
19
|
+
//# sourceMappingURL=after_initial_failure.js.map
|
package/dist/esm/identity/for_IdentityProvider/when_refresh_is_called/after_initial_failure.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"after_initial_failure.js","sourceRoot":"","sources":["../../../../../identity/for_IdentityProvider/when_refresh_is_called/after_initial_failure.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,QAAQ,CAAC,8CAA8C,EAAE,KAAK,CAAC,oBAAoB,EAAE,OAAO,CAAC,EAAE;IAC3F,UAAU,CAAC,KAAK,IAAI,EAAE;QAClB,OAAO,CAAC,wBAAwB,EAAE,CAAC;QAGnC,OAAO,CAAC,qBAAqB,EAAE,CAAC;QAEhC,OAAO,CAAC,cAAc,EAAE,CAAC;QACzB,MAAM,OAAO,CAAC,mBAAmB,EAAE,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACX,OAAO,CAAC,cAAc,EAAE,CAAC;QACzB,OAAO,CAAC,OAAO,EAAE,CAAC;IACtB,CAAC,CAAC,CAAC;IAIH,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,gBAAiB,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IACzF,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,gBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7F,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,gBAAiB,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IAC7F,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO,OAAO,CAAC,gBAAiB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AACpI,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"and_fails.d.ts","sourceRoot":"","sources":["../../../../../identity/for_IdentityProvider/when_refresh_is_called/and_fails.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { given } from '../../../given';
|
|
2
|
+
import { an_identity_provider } from '../given/an_identity_provider';
|
|
3
|
+
describe('when refresh is called and fails', given(an_identity_provider, context => {
|
|
4
|
+
let identityId;
|
|
5
|
+
beforeEach(async () => {
|
|
6
|
+
context.setupSuccessfulIdentityFetch('initial-id', 'Initial User', {});
|
|
7
|
+
context.renderProvider();
|
|
8
|
+
await context.waitForAsyncUpdates();
|
|
9
|
+
identityId = context.capturedIdentity.id;
|
|
10
|
+
});
|
|
11
|
+
afterEach(() => context.cleanup());
|
|
12
|
+
it('should load identity from cookie', () => identityId.should.equal('initial-id'));
|
|
13
|
+
}));
|
|
14
|
+
//# sourceMappingURL=and_fails.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"and_fails.js","sourceRoot":"","sources":["../../../../../identity/for_IdentityProvider/when_refresh_is_called/and_fails.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,QAAQ,CAAC,kCAAkC,EAAE,KAAK,CAAC,oBAAoB,EAAE,OAAO,CAAC,EAAE;IAC/E,IAAI,UAAkB,CAAC;IAEvB,UAAU,CAAC,KAAK,IAAI,EAAE;QAClB,OAAO,CAAC,4BAA4B,CAAC,YAAY,EAAE,cAAc,EAAE,EAAE,CAAC,CAAC;QAEvE,OAAO,CAAC,cAAc,EAAE,CAAC;QACzB,MAAM,OAAO,CAAC,mBAAmB,EAAE,CAAC;QAEpC,UAAU,GAAG,OAAO,CAAC,gBAAiB,CAAC,EAAE,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAGnC,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;AACxF,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"and_succeeds.d.ts","sourceRoot":"","sources":["../../../../../identity/for_IdentityProvider/when_refresh_is_called/and_succeeds.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { given } from '../../../given';
|
|
2
|
+
import { an_identity_provider } from '../given/an_identity_provider';
|
|
3
|
+
describe('when refresh is called and succeeds', given(an_identity_provider, context => {
|
|
4
|
+
let newId;
|
|
5
|
+
let newName;
|
|
6
|
+
beforeEach(async () => {
|
|
7
|
+
context.setupSuccessfulIdentityFetch('initial-id', 'Initial User', { role: 'user' });
|
|
8
|
+
context.renderProvider();
|
|
9
|
+
await context.waitForAsyncUpdates();
|
|
10
|
+
newId = context.capturedIdentity.id;
|
|
11
|
+
newName = context.capturedIdentity.name;
|
|
12
|
+
});
|
|
13
|
+
afterEach(() => context.cleanup());
|
|
14
|
+
it('should load initial identity', () => newId.should.equal('initial-id'));
|
|
15
|
+
it('should have identity name', () => newName.should.equal('Initial User'));
|
|
16
|
+
}));
|
|
17
|
+
//# sourceMappingURL=and_succeeds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"and_succeeds.js","sourceRoot":"","sources":["../../../../../identity/for_IdentityProvider/when_refresh_is_called/and_succeeds.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,QAAQ,CAAC,qCAAqC,EAAE,KAAK,CAAC,oBAAoB,EAAE,OAAO,CAAC,EAAE;IAClF,IAAI,KAAa,CAAC;IAClB,IAAI,OAAe,CAAC;IAEpB,UAAU,CAAC,KAAK,IAAI,EAAE;QAClB,OAAO,CAAC,4BAA4B,CAAC,YAAY,EAAE,cAAc,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QAErF,OAAO,CAAC,cAAc,EAAE,CAAC;QACzB,MAAM,OAAO,CAAC,mBAAmB,EAAE,CAAC;QAMpC,KAAK,GAAG,OAAO,CAAC,gBAAiB,CAAC,EAAE,CAAC;QACrC,OAAO,GAAG,OAAO,CAAC,gBAAiB,CAAC,IAAI,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAGnC,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;IAC3E,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;AAChF,CAAC,CAAC,CAAC,CAAC"}
|