@cratis/arc.react 18.4.3 → 18.6.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/commands/for_CommandScopeImplementation/FakeCommand.ts +25 -26
- package/commands/for_CommandScopeImplementation/when_property_changes_on_added_command.ts +2 -2
- package/dist/cjs/commands/for_CommandScopeImplementation/FakeCommand.d.ts +23 -0
- package/dist/cjs/commands/for_CommandScopeImplementation/FakeCommand.d.ts.map +1 -0
- package/dist/cjs/commands/for_CommandScopeImplementation/when_executing_with_three_commands_were_two_having_changes.d.ts +2 -0
- package/dist/cjs/commands/for_CommandScopeImplementation/when_executing_with_three_commands_were_two_having_changes.d.ts.map +1 -0
- package/dist/cjs/commands/for_CommandScopeImplementation/when_none_of_the_added_commands_has_changes.d.ts +2 -0
- package/dist/cjs/commands/for_CommandScopeImplementation/when_none_of_the_added_commands_has_changes.d.ts.map +1 -0
- package/dist/cjs/commands/for_CommandScopeImplementation/when_one_of_the_added_commands_has_changes.d.ts +2 -0
- package/dist/cjs/commands/for_CommandScopeImplementation/when_one_of_the_added_commands_has_changes.d.ts.map +1 -0
- package/dist/cjs/commands/for_CommandScopeImplementation/when_property_changes_on_added_command.d.ts +2 -0
- package/dist/cjs/commands/for_CommandScopeImplementation/when_property_changes_on_added_command.d.ts.map +1 -0
- package/dist/cjs/commands/for_CommandScopeImplementation/when_reverting_with_three_commands_were_two_having_changes.d.ts +2 -0
- package/dist/cjs/commands/for_CommandScopeImplementation/when_reverting_with_three_commands_were_two_having_changes.d.ts.map +1 -0
- package/dist/cjs/commands/for_CommandScopeImplementation/when_there_are_no_commands.d.ts +2 -0
- package/dist/cjs/commands/for_CommandScopeImplementation/when_there_are_no_commands.d.ts.map +1 -0
- package/dist/cjs/commands/for_useCommand/FakeCommand.d.ts +17 -0
- package/dist/cjs/commands/for_useCommand/FakeCommand.d.ts.map +1 -0
- package/dist/cjs/commands/for_useCommand/when_creating_instance.d.ts +2 -0
- package/dist/cjs/commands/for_useCommand/when_creating_instance.d.ts.map +1 -0
- package/dist/cjs/commands/for_useCommand/when_creating_instance_with_initial_values.d.ts +2 -0
- package/dist/cjs/commands/for_useCommand/when_creating_instance_with_initial_values.d.ts.map +1 -0
- package/dist/cjs/commands/for_useCommand/when_creating_instance_without_optional_context_values.d.ts +2 -0
- package/dist/cjs/commands/for_useCommand/when_creating_instance_without_optional_context_values.d.ts.map +1 -0
- package/dist/cjs/identity/IdentityProvider.d.ts +8 -1
- package/dist/cjs/identity/IdentityProvider.d.ts.map +1 -1
- package/dist/cjs/identity/IdentityProvider.js +14 -5
- package/dist/cjs/identity/IdentityProvider.js.map +1 -1
- package/dist/cjs/identity/for_IdentityProvider/when_refreshing_identity.d.ts +2 -0
- package/dist/cjs/identity/for_IdentityProvider/when_refreshing_identity.d.ts.map +1 -0
- package/dist/cjs/identity/useIdentity.d.ts +2 -0
- package/dist/cjs/identity/useIdentity.d.ts.map +1 -1
- package/dist/cjs/identity/useIdentity.js +8 -5
- package/dist/cjs/identity/useIdentity.js.map +1 -1
- package/dist/cjs/queries/for_useObservableQuery/FakeObservableQuery.d.ts +19 -0
- package/dist/cjs/queries/for_useObservableQuery/FakeObservableQuery.d.ts.map +1 -0
- package/dist/cjs/queries/for_useObservableQuery/when_creating_instance.d.ts +2 -0
- package/dist/cjs/queries/for_useObservableQuery/when_creating_instance.d.ts.map +1 -0
- package/dist/cjs/queries/for_useQuery/FakeQuery.d.ts +14 -0
- package/dist/cjs/queries/for_useQuery/FakeQuery.d.ts.map +1 -0
- package/dist/cjs/queries/for_useQuery/when_creating_instance.d.ts +2 -0
- package/dist/cjs/queries/for_useQuery/when_creating_instance.d.ts.map +1 -0
- package/dist/cjs/queries/for_useQuery/when_creating_instance_with_sorting.d.ts +2 -0
- package/dist/cjs/queries/for_useQuery/when_creating_instance_with_sorting.d.ts.map +1 -0
- package/dist/cjs/queries/for_useQuery/when_creating_instance_without_optional_context_values.d.ts +2 -0
- package/dist/cjs/queries/for_useQuery/when_creating_instance_without_optional_context_values.d.ts.map +1 -0
- package/dist/cjs/queries/for_useQueryWithPaging/when_creating_instance_with_paging.d.ts +2 -0
- package/dist/cjs/queries/for_useQueryWithPaging/when_creating_instance_with_paging.d.ts.map +1 -0
- package/dist/cjs/queries/useObservableQuery.js +1 -1
- package/dist/cjs/queries/useObservableQuery.js.map +1 -1
- package/dist/esm/commands/for_CommandScopeImplementation/FakeCommand.d.ts +23 -0
- package/dist/esm/commands/for_CommandScopeImplementation/FakeCommand.d.ts.map +1 -0
- package/dist/esm/commands/for_CommandScopeImplementation/FakeCommand.js +49 -0
- package/dist/esm/commands/for_CommandScopeImplementation/FakeCommand.js.map +1 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_executing_with_three_commands_were_two_having_changes.d.ts +2 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_executing_with_three_commands_were_two_having_changes.d.ts.map +1 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_executing_with_three_commands_were_two_having_changes.js +17 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_executing_with_three_commands_were_two_having_changes.js.map +1 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_none_of_the_added_commands_has_changes.d.ts +2 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_none_of_the_added_commands_has_changes.d.ts.map +1 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_none_of_the_added_commands_has_changes.js +13 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_none_of_the_added_commands_has_changes.js.map +1 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_one_of_the_added_commands_has_changes.d.ts +2 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_one_of_the_added_commands_has_changes.d.ts.map +1 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_one_of_the_added_commands_has_changes.js +13 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_one_of_the_added_commands_has_changes.js.map +1 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_property_changes_on_added_command.d.ts +2 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_property_changes_on_added_command.d.ts.map +1 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_property_changes_on_added_command.js +18 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_property_changes_on_added_command.js.map +1 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_reverting_with_three_commands_were_two_having_changes.d.ts +2 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_reverting_with_three_commands_were_two_having_changes.d.ts.map +1 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_reverting_with_three_commands_were_two_having_changes.js +17 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_reverting_with_three_commands_were_two_having_changes.js.map +1 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_there_are_no_commands.d.ts +2 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_there_are_no_commands.d.ts.map +1 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_there_are_no_commands.js +6 -0
- package/dist/esm/commands/for_CommandScopeImplementation/when_there_are_no_commands.js.map +1 -0
- package/dist/esm/commands/for_useCommand/FakeCommand.d.ts +17 -0
- package/dist/esm/commands/for_useCommand/FakeCommand.d.ts.map +1 -0
- package/dist/esm/commands/for_useCommand/FakeCommand.js +18 -0
- package/dist/esm/commands/for_useCommand/FakeCommand.js.map +1 -0
- package/dist/esm/commands/for_useCommand/when_creating_instance.d.ts +2 -0
- package/dist/esm/commands/for_useCommand/when_creating_instance.d.ts.map +1 -0
- package/dist/esm/commands/for_useCommand/when_creating_instance.js +28 -0
- package/dist/esm/commands/for_useCommand/when_creating_instance.js.map +1 -0
- package/dist/esm/commands/for_useCommand/when_creating_instance_with_initial_values.d.ts +2 -0
- package/dist/esm/commands/for_useCommand/when_creating_instance_with_initial_values.d.ts.map +1 -0
- package/dist/esm/commands/for_useCommand/when_creating_instance_with_initial_values.js +24 -0
- package/dist/esm/commands/for_useCommand/when_creating_instance_with_initial_values.js.map +1 -0
- package/dist/esm/commands/for_useCommand/when_creating_instance_without_optional_context_values.d.ts +2 -0
- package/dist/esm/commands/for_useCommand/when_creating_instance_without_optional_context_values.d.ts.map +1 -0
- package/dist/esm/commands/for_useCommand/when_creating_instance_without_optional_context_values.js +24 -0
- package/dist/esm/commands/for_useCommand/when_creating_instance_without_optional_context_values.js.map +1 -0
- package/dist/esm/for_Bindings/given/bindings_context.d.ts +4 -0
- package/dist/esm/for_Bindings/given/bindings_context.d.ts.map +1 -0
- package/dist/esm/for_Bindings/given/bindings_context.js +5 -0
- package/dist/esm/for_Bindings/given/bindings_context.js.map +1 -0
- package/dist/esm/for_Bindings/when_initializing_bindings.d.ts +2 -0
- package/dist/esm/for_Bindings/when_initializing_bindings.d.ts.map +1 -0
- package/dist/esm/for_Bindings/when_initializing_bindings.js +24 -0
- package/dist/esm/for_Bindings/when_initializing_bindings.js.map +1 -0
- package/dist/esm/for_Bindings/when_initializing_bindings_without_optional_parameters.d.ts +2 -0
- package/dist/esm/for_Bindings/when_initializing_bindings_without_optional_parameters.d.ts.map +1 -0
- package/dist/esm/for_Bindings/when_initializing_bindings_without_optional_parameters.js +24 -0
- package/dist/esm/for_Bindings/when_initializing_bindings_without_optional_parameters.js.map +1 -0
- package/dist/esm/identity/IdentityProvider.d.ts +8 -1
- package/dist/esm/identity/IdentityProvider.d.ts.map +1 -1
- package/dist/esm/identity/IdentityProvider.js +14 -5
- package/dist/esm/identity/IdentityProvider.js.map +1 -1
- package/dist/esm/identity/for_IdentityProvider/when_refreshing_identity.d.ts +2 -0
- package/dist/esm/identity/for_IdentityProvider/when_refreshing_identity.d.ts.map +1 -0
- package/dist/esm/identity/for_IdentityProvider/when_refreshing_identity.js +47 -0
- package/dist/esm/identity/for_IdentityProvider/when_refreshing_identity.js.map +1 -0
- package/dist/esm/identity/useIdentity.d.ts +2 -0
- package/dist/esm/identity/useIdentity.d.ts.map +1 -1
- package/dist/esm/identity/useIdentity.js +8 -5
- package/dist/esm/identity/useIdentity.js.map +1 -1
- package/dist/esm/queries/for_useObservableQuery/FakeObservableQuery.d.ts +19 -0
- package/dist/esm/queries/for_useObservableQuery/FakeObservableQuery.d.ts.map +1 -0
- package/dist/esm/queries/for_useObservableQuery/FakeObservableQuery.js +25 -0
- package/dist/esm/queries/for_useObservableQuery/FakeObservableQuery.js.map +1 -0
- package/dist/esm/queries/for_useObservableQuery/when_creating_instance.d.ts +2 -0
- package/dist/esm/queries/for_useObservableQuery/when_creating_instance.d.ts.map +1 -0
- package/dist/esm/queries/for_useObservableQuery/when_creating_instance.js +66 -0
- package/dist/esm/queries/for_useObservableQuery/when_creating_instance.js.map +1 -0
- package/dist/esm/queries/for_useQuery/FakeQuery.d.ts +14 -0
- package/dist/esm/queries/for_useQuery/FakeQuery.d.ts.map +1 -0
- package/dist/esm/queries/for_useQuery/FakeQuery.js +13 -0
- package/dist/esm/queries/for_useQuery/FakeQuery.js.map +1 -0
- package/dist/esm/queries/for_useQuery/when_creating_instance.d.ts +2 -0
- package/dist/esm/queries/for_useQuery/when_creating_instance.d.ts.map +1 -0
- package/dist/esm/queries/for_useQuery/when_creating_instance.js +48 -0
- package/dist/esm/queries/for_useQuery/when_creating_instance.js.map +1 -0
- package/dist/esm/queries/for_useQuery/when_creating_instance_with_sorting.d.ts +2 -0
- package/dist/esm/queries/for_useQuery/when_creating_instance_with_sorting.d.ts.map +1 -0
- package/dist/esm/queries/for_useQuery/when_creating_instance_with_sorting.js +40 -0
- package/dist/esm/queries/for_useQuery/when_creating_instance_with_sorting.js.map +1 -0
- package/dist/esm/queries/for_useQuery/when_creating_instance_without_optional_context_values.d.ts +2 -0
- package/dist/esm/queries/for_useQuery/when_creating_instance_without_optional_context_values.d.ts.map +1 -0
- package/dist/esm/queries/for_useQuery/when_creating_instance_without_optional_context_values.js +44 -0
- package/dist/esm/queries/for_useQuery/when_creating_instance_without_optional_context_values.js.map +1 -0
- package/dist/esm/queries/for_useQueryWithPaging/when_creating_instance_with_paging.d.ts +2 -0
- package/dist/esm/queries/for_useQueryWithPaging/when_creating_instance_with_paging.d.ts.map +1 -0
- package/dist/esm/queries/for_useQueryWithPaging/when_creating_instance_with_paging.js +51 -0
- package/dist/esm/queries/for_useQueryWithPaging/when_creating_instance_with_paging.js.map +1 -0
- package/dist/esm/queries/useObservableQuery.js +1 -1
- package/dist/esm/queries/useObservableQuery.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/global.d.ts +11 -0
- package/identity/IdentityProvider.tsx +23 -6
- package/identity/for_IdentityProvider/when_refreshing_identity.ts +4 -3
- package/identity/useIdentity.ts +29 -5
- package/package.json +2 -2
- package/queries/for_useObservableQuery/FakeObservableQuery.ts +43 -0
- package/queries/for_useObservableQuery/when_creating_instance.ts +97 -0
- package/queries/for_useQuery/when_creating_instance.ts +6 -2
- package/queries/for_useQuery/when_creating_instance_with_sorting.ts +6 -4
- package/queries/for_useQuery/when_creating_instance_without_optional_context_values.ts +6 -2
- package/queries/for_useQueryWithPaging/when_creating_instance_with_paging.ts +6 -2
- package/queries/useObservableQuery.ts +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CommandScopeImplementation } from '../CommandScopeImplementation';
|
|
2
|
+
import { FakeCommand } from './FakeCommand';
|
|
3
|
+
describe('when executing with three commands were two having changes', async () => {
|
|
4
|
+
const scope = new CommandScopeImplementation(() => { });
|
|
5
|
+
const firstCommand = new FakeCommand(true);
|
|
6
|
+
const secondCommand = new FakeCommand(false);
|
|
7
|
+
const thirdCommand = new FakeCommand(true);
|
|
8
|
+
scope.addCommand(firstCommand);
|
|
9
|
+
scope.addCommand(secondCommand);
|
|
10
|
+
scope.addCommand(thirdCommand);
|
|
11
|
+
await scope.execute();
|
|
12
|
+
it('should call execute on first command', () => firstCommand.execute.called.should.be.true);
|
|
13
|
+
it('should not call execute on second command', () => secondCommand.execute.called.should.be.false);
|
|
14
|
+
it('should call execute on third command', () => thirdCommand.execute.called.should.be.true);
|
|
15
|
+
it('should not have any changes', () => scope.hasChanges.should.be.false);
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=when_executing_with_three_commands_were_two_having_changes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_executing_with_three_commands_were_two_having_changes.js","sourceRoot":"","sources":["../../../../commands/for_CommandScopeImplementation/when_executing_with_three_commands_were_two_having_changes.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,QAAQ,CAAC,4DAA4D,EAAE,KAAK,IAAI,EAAE;IAC9E,MAAM,KAAK,GAAG,IAAI,0BAA0B,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAEvD,MAAM,YAAY,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,aAAa,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,YAAY,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;IAE3C,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAC/B,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAChC,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAE/B,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;IAEtB,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE,CAAE,YAAY,CAAC,OAAqB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAC5G,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE,CAAE,aAAa,CAAC,OAAqB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IACnH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE,CAAE,YAAY,CAAC,OAAqB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAC5G,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_none_of_the_added_commands_has_changes.d.ts","sourceRoot":"","sources":["../../../../commands/for_CommandScopeImplementation/when_none_of_the_added_commands_has_changes.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CommandScopeImplementation } from '../CommandScopeImplementation';
|
|
2
|
+
import { FakeCommand } from './FakeCommand';
|
|
3
|
+
describe('when none of the added commands has changes', () => {
|
|
4
|
+
const scope = new CommandScopeImplementation(() => { });
|
|
5
|
+
const firstCommand = new FakeCommand(false);
|
|
6
|
+
const secondCommand = new FakeCommand(false);
|
|
7
|
+
const thirdCommand = new FakeCommand(false);
|
|
8
|
+
scope.addCommand(firstCommand);
|
|
9
|
+
scope.addCommand(secondCommand);
|
|
10
|
+
scope.addCommand(thirdCommand);
|
|
11
|
+
it('should not have changes', () => scope.hasChanges.should.be.false);
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=when_none_of_the_added_commands_has_changes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_none_of_the_added_commands_has_changes.js","sourceRoot":"","sources":["../../../../commands/for_CommandScopeImplementation/when_none_of_the_added_commands_has_changes.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,QAAQ,CAAC,6CAA6C,EAAE,GAAG,EAAE;IACzD,MAAM,KAAK,GAAG,IAAI,0BAA0B,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAEvD,MAAM,YAAY,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,aAAa,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,YAAY,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC;IAE5C,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAC/B,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAChC,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAE/B,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AAC1E,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_one_of_the_added_commands_has_changes.d.ts","sourceRoot":"","sources":["../../../../commands/for_CommandScopeImplementation/when_one_of_the_added_commands_has_changes.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CommandScopeImplementation } from '../CommandScopeImplementation';
|
|
2
|
+
import { FakeCommand } from './FakeCommand';
|
|
3
|
+
describe('when one of the added commands has changes', () => {
|
|
4
|
+
const scope = new CommandScopeImplementation(() => { });
|
|
5
|
+
const firstCommand = new FakeCommand(false);
|
|
6
|
+
const secondCommand = new FakeCommand(true);
|
|
7
|
+
const thirdCommand = new FakeCommand(false);
|
|
8
|
+
scope.addCommand(firstCommand);
|
|
9
|
+
scope.addCommand(secondCommand);
|
|
10
|
+
scope.addCommand(thirdCommand);
|
|
11
|
+
it('should have changes', () => scope.hasChanges.should.be.true);
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=when_one_of_the_added_commands_has_changes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_one_of_the_added_commands_has_changes.js","sourceRoot":"","sources":["../../../../commands/for_CommandScopeImplementation/when_one_of_the_added_commands_has_changes.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,QAAQ,CAAC,4CAA4C,EAAE,GAAG,EAAE;IACxD,MAAM,KAAK,GAAG,IAAI,0BAA0B,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAEvD,MAAM,YAAY,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,aAAa,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,YAAY,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC;IAE5C,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAC/B,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAChC,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAE/B,EAAE,CAAC,qBAAqB,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AACrE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_property_changes_on_added_command.d.ts","sourceRoot":"","sources":["../../../../commands/for_CommandScopeImplementation/when_property_changes_on_added_command.ts"],"names":[],"mappings":""}
|
package/dist/esm/commands/for_CommandScopeImplementation/when_property_changes_on_added_command.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import sinon from 'sinon';
|
|
2
|
+
import { CommandScopeImplementation } from '../CommandScopeImplementation';
|
|
3
|
+
import { FakeCommand } from './FakeCommand';
|
|
4
|
+
describe('when property changes on added command', () => {
|
|
5
|
+
const setHasChanges = sinon.stub();
|
|
6
|
+
const scope = new CommandScopeImplementation(setHasChanges);
|
|
7
|
+
let callbackToCall;
|
|
8
|
+
let thisArgForCallback = {};
|
|
9
|
+
const command = new FakeCommand(true);
|
|
10
|
+
command.onPropertyChanged.callsFake((callback, thisArg) => {
|
|
11
|
+
callbackToCall = callback;
|
|
12
|
+
thisArgForCallback = thisArg;
|
|
13
|
+
});
|
|
14
|
+
scope.addCommand(command);
|
|
15
|
+
callbackToCall.call(thisArgForCallback, '');
|
|
16
|
+
it('should call set has changes', () => setHasChanges.called.should.be.true);
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=when_property_changes_on_added_command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_property_changes_on_added_command.js","sourceRoot":"","sources":["../../../../commands/for_CommandScopeImplementation/when_property_changes_on_added_command.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,QAAQ,CAAC,wCAAwC,EAAE,GAAG,EAAE;IACpD,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IACnC,MAAM,KAAK,GAAG,IAAI,0BAA0B,CAAC,aAAa,CAAC,CAAC;IAC5D,IAAI,cAA+B,CAAC;IACpC,IAAI,kBAAkB,GAAW,EAAE,CAAC;IAEpC,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;IACtC,OAAO,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,QAAyB,EAAE,OAAe,EAAQ,EAAE;QACrF,cAAc,GAAG,QAAQ,CAAC;QAC1B,kBAAkB,GAAG,OAAO,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAE1B,cAAe,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;IAE7C,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AACjF,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_reverting_with_three_commands_were_two_having_changes.d.ts","sourceRoot":"","sources":["../../../../commands/for_CommandScopeImplementation/when_reverting_with_three_commands_were_two_having_changes.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CommandScopeImplementation } from '../CommandScopeImplementation';
|
|
2
|
+
import { FakeCommand } from './FakeCommand';
|
|
3
|
+
describe('when reverting with three commands were two having changes', () => {
|
|
4
|
+
const scope = new CommandScopeImplementation(() => { });
|
|
5
|
+
const firstCommand = new FakeCommand(true);
|
|
6
|
+
const secondCommand = new FakeCommand(false);
|
|
7
|
+
const thirdCommand = new FakeCommand(true);
|
|
8
|
+
scope.addCommand(firstCommand);
|
|
9
|
+
scope.addCommand(secondCommand);
|
|
10
|
+
scope.addCommand(thirdCommand);
|
|
11
|
+
scope.revertChanges();
|
|
12
|
+
it('should call revert on first command', () => firstCommand.revertChanges.called.should.be.true);
|
|
13
|
+
it('should call revert on second command', () => secondCommand.revertChanges.called.should.be.true);
|
|
14
|
+
it('should call revert on third command', () => thirdCommand.revertChanges.called.should.be.true);
|
|
15
|
+
it('should not have any changes', () => scope.hasChanges.should.be.false);
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=when_reverting_with_three_commands_were_two_having_changes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_reverting_with_three_commands_were_two_having_changes.js","sourceRoot":"","sources":["../../../../commands/for_CommandScopeImplementation/when_reverting_with_three_commands_were_two_having_changes.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,QAAQ,CAAC,4DAA4D,EAAE,GAAG,EAAE;IACxE,MAAM,KAAK,GAAG,IAAI,0BAA0B,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAEvD,MAAM,YAAY,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,aAAa,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,YAAY,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;IAE3C,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAC/B,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAChC,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAE/B,KAAK,CAAC,aAAa,EAAE,CAAC;IAEtB,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE,CAAE,YAAY,CAAC,aAA2B,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACjH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE,CAAE,aAAa,CAAC,aAA2B,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACnH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE,CAAE,YAAY,CAAC,aAA2B,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACjH,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_there_are_no_commands.d.ts","sourceRoot":"","sources":["../../../../commands/for_CommandScopeImplementation/when_there_are_no_commands.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CommandScopeImplementation } from '../CommandScopeImplementation';
|
|
2
|
+
describe('when there are no commands', () => {
|
|
3
|
+
const scope = new CommandScopeImplementation(() => { });
|
|
4
|
+
it('should have no changes', () => scope.hasChanges.should.be.false);
|
|
5
|
+
});
|
|
6
|
+
//# sourceMappingURL=when_there_are_no_commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_there_are_no_commands.js","sourceRoot":"","sources":["../../../../commands/for_CommandScopeImplementation/when_there_are_no_commands.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IACxC,MAAM,KAAK,GAAG,IAAI,0BAA0B,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAEvD,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AACzE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Command, CommandValidator } from '@cratis/arc/commands';
|
|
2
|
+
import { PropertyDescriptor } from '@cratis/arc/reflection';
|
|
3
|
+
export interface FakeCommandContent {
|
|
4
|
+
someProperty?: string;
|
|
5
|
+
anotherProperty?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class FakeCommand extends Command<FakeCommandContent> {
|
|
8
|
+
readonly route = "/api/fake-command";
|
|
9
|
+
readonly validation: CommandValidator;
|
|
10
|
+
readonly propertyDescriptors: PropertyDescriptor[];
|
|
11
|
+
someProperty?: string;
|
|
12
|
+
anotherProperty?: number;
|
|
13
|
+
get requestParameters(): string[];
|
|
14
|
+
get properties(): string[];
|
|
15
|
+
constructor();
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=FakeCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FakeCommand.d.ts","sourceRoot":"","sources":["../../../../commands/for_useCommand/FakeCommand.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,MAAM,WAAW,kBAAkB;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,qBAAa,WAAY,SAAQ,OAAO,CAAC,kBAAkB,CAAC;IACxD,QAAQ,CAAC,KAAK,uBAAuB;IACrC,QAAQ,CAAC,UAAU,EAAS,gBAAgB,CAAC;IAC7C,QAAQ,CAAC,mBAAmB,EAAE,kBAAkB,EAAE,CAAM;IAExD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,IAAI,iBAAiB,IAAI,MAAM,EAAE,CAEhC;IAED,IAAI,UAAU,IAAI,MAAM,EAAE,CAEzB;;CAKJ"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Command } from '@cratis/arc/commands';
|
|
2
|
+
export class FakeCommand extends Command {
|
|
3
|
+
route = '/api/fake-command';
|
|
4
|
+
validation = {};
|
|
5
|
+
propertyDescriptors = [];
|
|
6
|
+
someProperty;
|
|
7
|
+
anotherProperty;
|
|
8
|
+
get requestParameters() {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
get properties() {
|
|
12
|
+
return ['someProperty', 'anotherProperty'];
|
|
13
|
+
}
|
|
14
|
+
constructor() {
|
|
15
|
+
super(Object, false);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=FakeCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FakeCommand.js","sourceRoot":"","sources":["../../../../commands/for_useCommand/FakeCommand.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAoB,MAAM,sBAAsB,CAAC;AAQjE,MAAM,OAAO,WAAY,SAAQ,OAA2B;IAC/C,KAAK,GAAG,mBAAmB,CAAC;IAC5B,UAAU,GAAG,EAAsB,CAAC;IACpC,mBAAmB,GAAyB,EAAE,CAAC;IAExD,YAAY,CAAU;IACtB,eAAe,CAAU;IAEzB,IAAI,iBAAiB;QACjB,OAAO,EAAE,CAAC;IACd,CAAC;IAED,IAAI,UAAU;QACV,OAAO,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC;IAC/C,CAAC;IAED;QACI,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACzB,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_creating_instance.d.ts","sourceRoot":"","sources":["../../../../commands/for_useCommand/when_creating_instance.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { useCommand } from '../useCommand';
|
|
4
|
+
import { FakeCommand } from './FakeCommand';
|
|
5
|
+
import { ArcContext } from '../../ArcContext';
|
|
6
|
+
describe('when creating instance', () => {
|
|
7
|
+
let capturedCommand = null;
|
|
8
|
+
const TestComponent = () => {
|
|
9
|
+
const [command] = useCommand(FakeCommand);
|
|
10
|
+
capturedCommand = command;
|
|
11
|
+
return React.createElement('div', null, 'Test');
|
|
12
|
+
};
|
|
13
|
+
const config = {
|
|
14
|
+
microservice: 'test-microservice',
|
|
15
|
+
apiBasePath: '/api',
|
|
16
|
+
origin: 'https://example.com',
|
|
17
|
+
httpHeadersCallback: () => ({ 'X-Custom-Header': 'custom-value' })
|
|
18
|
+
};
|
|
19
|
+
render(React.createElement(ArcContext.Provider, { value: config }, React.createElement(TestComponent)));
|
|
20
|
+
it('should set microservice from context', () => capturedCommand['_microservice'].should.equal('test-microservice'));
|
|
21
|
+
it('should set api base path from context', () => capturedCommand['_apiBasePath'].should.equal('/api'));
|
|
22
|
+
it('should set origin from context', () => capturedCommand['_origin'].should.equal('https://example.com'));
|
|
23
|
+
it('should set http headers callback from context', () => {
|
|
24
|
+
const headers = capturedCommand['_httpHeadersCallback']();
|
|
25
|
+
headers.should.deep.equal({ 'X-Custom-Header': 'custom-value' });
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=when_creating_instance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_creating_instance.js","sourceRoot":"","sources":["../../../../commands/for_useCommand/when_creating_instance.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,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAoB,MAAM,kBAAkB,CAAC;AAEhE,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACpC,IAAI,eAAe,GAAuB,IAAI,CAAC;IAE/C,MAAM,aAAa,GAAG,GAAG,EAAE;QACvB,MAAM,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;QAC1C,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;QAC7B,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAC;KACrE,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,sCAAsC,EAAE,GAAG,EAAE,CAAC,eAAgB,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC;IACtH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE,CAAC,eAAgB,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACzG,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE,CAAC,eAAgB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAC5G,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACrD,MAAM,OAAO,GAAG,eAAgB,CAAC,sBAAsB,CAAC,EAAE,CAAC;QAC3D,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_creating_instance_with_initial_values.d.ts","sourceRoot":"","sources":["../../../../commands/for_useCommand/when_creating_instance_with_initial_values.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { useCommand } from '../useCommand';
|
|
4
|
+
import { FakeCommand } from './FakeCommand';
|
|
5
|
+
import { ArcContext } from '../../ArcContext';
|
|
6
|
+
describe('when creating instance with initial values', () => {
|
|
7
|
+
let capturedCommand = null;
|
|
8
|
+
const initialValues = {
|
|
9
|
+
someProperty: 'initial-value',
|
|
10
|
+
anotherProperty: 42
|
|
11
|
+
};
|
|
12
|
+
const TestComponent = () => {
|
|
13
|
+
const [command] = useCommand(FakeCommand, initialValues);
|
|
14
|
+
capturedCommand = command;
|
|
15
|
+
return React.createElement('div', null, 'Test');
|
|
16
|
+
};
|
|
17
|
+
const config = {
|
|
18
|
+
microservice: 'test-microservice'
|
|
19
|
+
};
|
|
20
|
+
render(React.createElement(ArcContext.Provider, { value: config }, React.createElement(TestComponent)));
|
|
21
|
+
it('should set someProperty from initial values', () => capturedCommand.someProperty.should.equal('initial-value'));
|
|
22
|
+
it('should set anotherProperty from initial values', () => capturedCommand.anotherProperty.should.equal(42));
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=when_creating_instance_with_initial_values.js.map
|
|
@@ -0,0 +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;KACpC,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_creating_instance_without_optional_context_values.d.ts","sourceRoot":"","sources":["../../../../commands/for_useCommand/when_creating_instance_without_optional_context_values.ts"],"names":[],"mappings":""}
|
package/dist/esm/commands/for_useCommand/when_creating_instance_without_optional_context_values.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { useCommand } from '../useCommand';
|
|
4
|
+
import { FakeCommand } from './FakeCommand';
|
|
5
|
+
import { ArcContext } from '../../ArcContext';
|
|
6
|
+
describe('when creating instance without optional context values', () => {
|
|
7
|
+
let capturedCommand = null;
|
|
8
|
+
const TestComponent = () => {
|
|
9
|
+
const [command] = useCommand(FakeCommand);
|
|
10
|
+
capturedCommand = command;
|
|
11
|
+
return React.createElement('div', null, 'Test');
|
|
12
|
+
};
|
|
13
|
+
const config = {
|
|
14
|
+
microservice: 'test-microservice'
|
|
15
|
+
};
|
|
16
|
+
render(React.createElement(ArcContext.Provider, { value: config }, React.createElement(TestComponent)));
|
|
17
|
+
it('should set api base path to empty string', () => capturedCommand['_apiBasePath'].should.equal(''));
|
|
18
|
+
it('should set origin to empty string', () => capturedCommand['_origin'].should.equal(''));
|
|
19
|
+
it('should set http headers callback to return empty object', () => {
|
|
20
|
+
const headers = capturedCommand['_httpHeadersCallback']();
|
|
21
|
+
headers.should.deep.equal({});
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=when_creating_instance_without_optional_context_values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_creating_instance_without_optional_context_values.js","sourceRoot":"","sources":["../../../../commands/for_useCommand/when_creating_instance_without_optional_context_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,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAoB,MAAM,kBAAkB,CAAC;AAEhE,QAAQ,CAAC,wDAAwD,EAAE,GAAG,EAAE;IACpE,IAAI,eAAe,GAAuB,IAAI,CAAC;IAE/C,MAAM,aAAa,GAAG,GAAG,EAAE;QACvB,MAAM,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;QAC1C,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;KACpC,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,0CAA0C,EAAE,GAAG,EAAE,CAAC,eAAgB,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IACxG,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE,CAAC,eAAgB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5F,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QAC/D,MAAM,OAAO,GAAG,eAAgB,CAAC,sBAAsB,CAAC,EAAE,CAAC;QAC3D,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings_context.d.ts","sourceRoot":"","sources":["../../../../for_Bindings/given/bindings_context.ts"],"names":[],"mappings":"AAGA,qBAAa,gBAAgB;;CAI5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings_context.js","sourceRoot":"","sources":["../../../../for_Bindings/given/bindings_context.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,gBAAgB;IACzB;IAEA,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_initializing_bindings.d.ts","sourceRoot":"","sources":["../../../for_Bindings/when_initializing_bindings.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Bindings } from '../Bindings';
|
|
2
|
+
import { Globals } from "@cratis/arc";
|
|
3
|
+
import { bindings_context } from "./given/bindings_context";
|
|
4
|
+
import { given } from '../given';
|
|
5
|
+
describe('when initializing bindings', given(bindings_context, () => {
|
|
6
|
+
let originalMicroservice;
|
|
7
|
+
let originalApiBasePath;
|
|
8
|
+
let originalOrigin;
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
originalMicroservice = Globals.microservice;
|
|
11
|
+
originalApiBasePath = Globals.apiBasePath;
|
|
12
|
+
originalOrigin = Globals.origin;
|
|
13
|
+
Bindings.initialize('test-microservice', '/test/api', 'http://test.com');
|
|
14
|
+
});
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
Globals.microservice = originalMicroservice;
|
|
17
|
+
Globals.apiBasePath = originalApiBasePath;
|
|
18
|
+
Globals.origin = originalOrigin;
|
|
19
|
+
});
|
|
20
|
+
it('should set globals microservice', () => Globals.microservice.should.equal('test-microservice'));
|
|
21
|
+
it('should set globals api base path', () => Globals.apiBasePath.should.equal('/test/api'));
|
|
22
|
+
it('should set globals origin', () => Globals.origin.should.equal('http://test.com'));
|
|
23
|
+
}));
|
|
24
|
+
//# sourceMappingURL=when_initializing_bindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_initializing_bindings.js","sourceRoot":"","sources":["../../../for_Bindings/when_initializing_bindings.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,QAAQ,CAAC,4BAA4B,EAAE,KAAK,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAChE,IAAI,oBAA4B,CAAC;IACjC,IAAI,mBAA2B,CAAC;IAChC,IAAI,cAAsB,CAAC;IAE3B,UAAU,CAAC,GAAG,EAAE;QACZ,oBAAoB,GAAG,OAAO,CAAC,YAAY,CAAC;QAC5C,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC;QAC1C,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;QAEhC,QAAQ,CAAC,UAAU,CAAC,mBAAmB,EAAE,WAAW,EAAE,iBAAiB,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACX,OAAO,CAAC,YAAY,GAAG,oBAAoB,CAAC;QAC5C,OAAO,CAAC,WAAW,GAAG,mBAAmB,CAAC;QAC1C,OAAO,CAAC,MAAM,GAAG,cAAc,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC;IACpG,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IAC5F,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAC1F,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_initializing_bindings_without_optional_parameters.d.ts","sourceRoot":"","sources":["../../../for_Bindings/when_initializing_bindings_without_optional_parameters.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Bindings } from '../Bindings';
|
|
2
|
+
import { Globals } from "@cratis/arc";
|
|
3
|
+
import { bindings_context } from "./given/bindings_context";
|
|
4
|
+
import { given } from '../given';
|
|
5
|
+
describe('when initializing bindings without optional parameters', given(bindings_context, () => {
|
|
6
|
+
let originalMicroservice;
|
|
7
|
+
let originalApiBasePath;
|
|
8
|
+
let originalOrigin;
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
originalMicroservice = Globals.microservice;
|
|
11
|
+
originalApiBasePath = Globals.apiBasePath;
|
|
12
|
+
originalOrigin = Globals.origin;
|
|
13
|
+
Bindings.initialize('test-microservice');
|
|
14
|
+
});
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
Globals.microservice = originalMicroservice;
|
|
17
|
+
Globals.apiBasePath = originalApiBasePath;
|
|
18
|
+
Globals.origin = originalOrigin;
|
|
19
|
+
});
|
|
20
|
+
it('should set globals microservice', () => Globals.microservice.should.equal('test-microservice'));
|
|
21
|
+
it('should set globals api base path to empty string', () => Globals.apiBasePath.should.equal(''));
|
|
22
|
+
it('should set globals origin to empty string', () => Globals.origin.should.equal(''));
|
|
23
|
+
}));
|
|
24
|
+
//# sourceMappingURL=when_initializing_bindings_without_optional_parameters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_initializing_bindings_without_optional_parameters.js","sourceRoot":"","sources":["../../../for_Bindings/when_initializing_bindings_without_optional_parameters.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,QAAQ,CAAC,wDAAwD,EAAE,KAAK,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC5F,IAAI,oBAA4B,CAAC;IACjC,IAAI,mBAA2B,CAAC;IAChC,IAAI,cAAsB,CAAC;IAE3B,UAAU,CAAC,GAAG,EAAE;QACZ,oBAAoB,GAAG,OAAO,CAAC,YAAY,CAAC;QAC5C,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC;QAC1C,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;QAEhC,QAAQ,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACX,OAAO,CAAC,YAAY,GAAG,oBAAoB,CAAC;QAC5C,OAAO,CAAC,WAAW,GAAG,mBAAmB,CAAC;QAC1C,OAAO,CAAC,MAAM,GAAG,cAAc,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC;IACpG,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IACnG,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;AAC3F,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { Constructor } from '@cratis/fundamentals';
|
|
2
3
|
import { IIdentity } from '@cratis/arc/identity';
|
|
3
4
|
import { GetHttpHeaders } from '@cratis/arc';
|
|
4
|
-
|
|
5
|
+
type IdentityContextValue = {
|
|
6
|
+
identity: IIdentity;
|
|
7
|
+
detailsConstructor?: Constructor;
|
|
8
|
+
};
|
|
9
|
+
export declare const IdentityProviderContext: React.Context<IdentityContextValue>;
|
|
5
10
|
export interface IdentityProviderProps {
|
|
6
11
|
children?: JSX.Element | JSX.Element[];
|
|
7
12
|
httpHeadersCallback?: GetHttpHeaders;
|
|
13
|
+
detailsType?: Constructor;
|
|
8
14
|
}
|
|
9
15
|
export declare const IdentityProvider: (props: IdentityProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export {};
|
|
10
17
|
//# sourceMappingURL=IdentityProvider.d.ts.map
|
|
@@ -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,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAe7C,eAAO,MAAM,uBAAuB,
|
|
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,4CAyC5D,CAAC"}
|
|
@@ -14,10 +14,13 @@ const defaultIdentityContext = {
|
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
-
const
|
|
17
|
+
const defaultContextValue = {
|
|
18
|
+
identity: defaultIdentityContext
|
|
19
|
+
};
|
|
20
|
+
const IdentityProviderContext = React__default.createContext(defaultContextValue);
|
|
18
21
|
const IdentityProvider = (props) => {
|
|
19
22
|
const arc = useContext(ArcContext);
|
|
20
|
-
const [context, setContext] = useState(
|
|
23
|
+
const [context, setContext] = useState(defaultContextValue);
|
|
21
24
|
const wrapRefresh = (identity) => {
|
|
22
25
|
const originalRefresh = identity.refresh.bind(identity);
|
|
23
26
|
return {
|
|
@@ -26,7 +29,10 @@ const IdentityProvider = (props) => {
|
|
|
26
29
|
return new Promise(resolve => {
|
|
27
30
|
originalRefresh().then(newIdentity => {
|
|
28
31
|
const wrappedIdentity = wrapRefresh(newIdentity);
|
|
29
|
-
setContext(
|
|
32
|
+
setContext({
|
|
33
|
+
identity: wrappedIdentity,
|
|
34
|
+
detailsConstructor: props.detailsType
|
|
35
|
+
});
|
|
30
36
|
resolve(wrappedIdentity);
|
|
31
37
|
});
|
|
32
38
|
});
|
|
@@ -37,9 +43,12 @@ const IdentityProvider = (props) => {
|
|
|
37
43
|
IdentityProvider$1.setHttpHeadersCallback(props.httpHeadersCallback);
|
|
38
44
|
IdentityProvider$1.setApiBasePath(arc.apiBasePath ?? '');
|
|
39
45
|
IdentityProvider$1.setOrigin(arc.origin ?? '');
|
|
40
|
-
IdentityProvider$1.getCurrent().then(identity => {
|
|
46
|
+
IdentityProvider$1.getCurrent(props.detailsType).then(identity => {
|
|
41
47
|
const wrappedIdentity = wrapRefresh(identity);
|
|
42
|
-
setContext(
|
|
48
|
+
setContext({
|
|
49
|
+
identity: wrappedIdentity,
|
|
50
|
+
detailsConstructor: props.detailsType
|
|
51
|
+
});
|
|
43
52
|
});
|
|
44
53
|
}, []);
|
|
45
54
|
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 { 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\nexport const IdentityProviderContext = React.createContext<
|
|
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 [context, setContext] = useState<IdentityContextValue>(defaultContextValue);\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 => {\n originalRefresh().then(newIdentity => {\n const wrappedIdentity = wrapRefresh(newIdentity);\n setContext({\n identity: wrappedIdentity,\n detailsConstructor: props.detailsType\n });\n resolve(wrappedIdentity);\n });\n });\n }\n };\n };\n\n useEffect(() => {\n RootIdentityProvider.setHttpHeadersCallback(props.httpHeadersCallback!);\n RootIdentityProvider.setApiBasePath(arc.apiBasePath ?? '');\n RootIdentityProvider.setOrigin(arc.origin ?? '');\n RootIdentityProvider.getCurrent(props.detailsType).then(identity => {\n const wrappedIdentity = wrapRefresh(identity);\n setContext({\n identity: wrappedIdentity,\n detailsConstructor: props.detailsType\n });\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;IAClC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAuB,mBAAmB,CAAC;AAEjF,IAAA,MAAM,WAAW,GAAG,CAAC,QAAmB,KAAe;QACnD,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;QACvD,OAAO;AACH,YAAA,GAAG,QAAQ;YACX,OAAO,EAAE,MAAK;AACV,gBAAA,OAAO,IAAI,OAAO,CAAY,OAAO,IAAG;AACpC,oBAAA,eAAe,EAAE,CAAC,IAAI,CAAC,WAAW,IAAG;AACjC,wBAAA,MAAM,eAAe,GAAG,WAAW,CAAC,WAAW,CAAC;AAChD,wBAAA,UAAU,CAAC;AACP,4BAAA,QAAQ,EAAE,eAAe;4BACzB,kBAAkB,EAAE,KAAK,CAAC;AAC7B,yBAAA,CAAC;wBACF,OAAO,CAAC,eAAe,CAAC;AAC5B,oBAAA,CAAC,CAAC;AACN,gBAAA,CAAC,CAAC;YACN;SACH;AACL,IAAA,CAAC;IAED,SAAS,CAAC,MAAK;AACX,QAAAC,kBAAoB,CAAC,sBAAsB,CAAC,KAAK,CAAC,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,QAAAA,kBAAoB,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAG;AAC/D,YAAA,MAAM,eAAe,GAAG,WAAW,CAAC,QAAQ,CAAC;AAC7C,YAAA,UAAU,CAAC;AACP,gBAAA,QAAQ,EAAE,eAAe;gBACzB,kBAAkB,EAAE,KAAK,CAAC;AAC7B,aAAA,CAAC;AACN,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 @@
|
|
|
1
|
+
{"version":3,"file":"when_refreshing_identity.d.ts","sourceRoot":"","sources":["../../../../identity/for_IdentityProvider/when_refreshing_identity.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { IdentityProvider } from '../IdentityProvider';
|
|
4
|
+
import { useIdentity } from '../useIdentity';
|
|
5
|
+
import { createFetchHelper } from '@cratis/arc/helpers/fetchHelper';
|
|
6
|
+
describe('when refreshing identity', async () => {
|
|
7
|
+
let capturedIdentity = null;
|
|
8
|
+
let renderCount = 0;
|
|
9
|
+
let initialRenderCount = 0;
|
|
10
|
+
let reRendered = false;
|
|
11
|
+
let newId = '';
|
|
12
|
+
let newName = '';
|
|
13
|
+
const TestComponent = () => {
|
|
14
|
+
renderCount++;
|
|
15
|
+
capturedIdentity = useIdentity();
|
|
16
|
+
return React.createElement('div', null, 'Test');
|
|
17
|
+
};
|
|
18
|
+
const fetchHelper = createFetchHelper();
|
|
19
|
+
const mockFetch = fetchHelper.stubFetch();
|
|
20
|
+
mockFetch.onFirstCall().resolves({
|
|
21
|
+
json: async () => ({
|
|
22
|
+
id: 'initial-id',
|
|
23
|
+
name: 'Initial User',
|
|
24
|
+
details: { role: 'user' }
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
mockFetch.onSecondCall().resolves({
|
|
28
|
+
json: async () => ({
|
|
29
|
+
id: 'new-id',
|
|
30
|
+
name: 'Updated User',
|
|
31
|
+
details: { role: 'admin' }
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
render(React.createElement(IdentityProvider, null, React.createElement(TestComponent)));
|
|
35
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
36
|
+
initialRenderCount = renderCount;
|
|
37
|
+
await capturedIdentity.refresh();
|
|
38
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
39
|
+
reRendered = renderCount > initialRenderCount;
|
|
40
|
+
newId = capturedIdentity.id;
|
|
41
|
+
newName = capturedIdentity.name;
|
|
42
|
+
it('should trigger re-render', () => reRendered.should.be.true);
|
|
43
|
+
it('should have new id', () => newId.should.equal('new-id'));
|
|
44
|
+
it('should have new name', () => newName.should.equal('Updated User'));
|
|
45
|
+
fetchHelper.restore();
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=when_refreshing_identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_refreshing_identity.js","sourceRoot":"","sources":["../../../../identity/for_IdentityProvider/when_refreshing_identity.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,QAAQ,CAAC,0BAA0B,EAAE,KAAK,IAAI,EAAE;IAC5C,IAAI,gBAAgB,GAAqB,IAAI,CAAC;IAC9C,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,kBAAkB,GAAG,CAAC,CAAC;IAC3B,IAAI,UAAU,GAAG,KAAK,CAAC;IACvB,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,MAAM,aAAa,GAAG,GAAG,EAAE;QACvB,WAAW,EAAE,CAAC;QACd,gBAAgB,GAAG,WAAW,EAAE,CAAC;QACjC,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,iBAAiB,EAAE,CAAC;IACxC,MAAM,SAAS,GAAG,WAAW,CAAC,SAAS,EAAE,CAAC;IAC1C,SAAS,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC;QAC7B,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;YACf,EAAE,EAAE,YAAY;YAChB,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;SAC5B,CAAC;KACO,CAAC,CAAC;IACf,SAAS,CAAC,YAAY,EAAE,CAAC,QAAQ,CAAC;QAC9B,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;YACf,EAAE,EAAE,QAAQ;YACZ,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;SAC7B,CAAC;KACO,CAAC,CAAC;IAEf,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,gBAAgB,EAAE,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAExF,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IAEvD,kBAAkB,GAAG,WAAW,CAAC;IAEjC,MAAM,gBAAiB,CAAC,OAAO,EAAE,CAAC;IAClC,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IAEvD,UAAU,GAAG,WAAW,GAAG,kBAAkB,CAAC;IAC9C,KAAK,GAAG,gBAAiB,CAAC,EAAE,CAAC;IAC7B,OAAO,GAAG,gBAAiB,CAAC,IAAI,CAAC;IAEjC,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAChE,EAAE,CAAC,oBAAoB,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC7D,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;IAEvE,WAAW,CAAC,OAAO,EAAE,CAAC;AAC1B,CAAC,CAAC,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Constructor } from '@cratis/fundamentals';
|
|
1
2
|
import { IIdentity } from '@cratis/arc/identity';
|
|
2
3
|
export declare function useIdentity<TDetails = object>(defaultDetails?: TDetails | undefined | null): IIdentity<TDetails>;
|
|
4
|
+
export declare function useIdentity<TDetails = object>(type: Constructor<TDetails>, defaultDetails?: TDetails | undefined | null): IIdentity<TDetails>;
|
|
3
5
|
//# sourceMappingURL=useIdentity.d.ts.map
|