@cratis/arc.react 18.5.0 → 18.7.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/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/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/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/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/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/tsconfig.tsbuildinfo +1 -1
- package/global.d.ts +11 -0
- package/identity/for_IdentityProvider/when_refreshing_identity.ts +4 -3
- package/package.json +2 -2
- package/queries/for_useObservableQuery/when_creating_instance.ts +2 -2
- 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
|
@@ -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,CA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../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"}
|
|
@@ -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,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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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ObservableQueryFor, QueryResult, ObservableQuerySubscription, OnNextResult } from '@cratis/arc/queries';
|
|
2
|
+
import { ParameterDescriptor } from '@cratis/arc/reflection';
|
|
3
|
+
export interface FakeObservableQueryResult {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
export type SubscribeCallback = OnNextResult<QueryResult<FakeObservableQueryResult[]>>;
|
|
8
|
+
export declare class FakeObservableQuery extends ObservableQueryFor<FakeObservableQueryResult[]> {
|
|
9
|
+
readonly route = "/api/fake-observable-query";
|
|
10
|
+
readonly parameterDescriptors: ParameterDescriptor[];
|
|
11
|
+
get requiredRequestParameters(): string[];
|
|
12
|
+
defaultValue: FakeObservableQueryResult[];
|
|
13
|
+
constructor();
|
|
14
|
+
static subscribeCallbacks: SubscribeCallback[];
|
|
15
|
+
static subscriptionReturned: ObservableQuerySubscription<FakeObservableQueryResult[]>;
|
|
16
|
+
subscribe(callback: SubscribeCallback, args?: object): ObservableQuerySubscription<FakeObservableQueryResult[]>;
|
|
17
|
+
static reset(): void;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=FakeObservableQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FakeObservableQuery.d.ts","sourceRoot":"","sources":["../../../../queries/for_useObservableQuery/FakeObservableQuery.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,2BAA2B,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACjH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,WAAW,yBAAyB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,iBAAiB,GAAG,YAAY,CAAC,WAAW,CAAC,yBAAyB,EAAE,CAAC,CAAC,CAAC;AAEvF,qBAAa,mBAAoB,SAAQ,kBAAkB,CAAC,yBAAyB,EAAE,CAAC;IACpF,QAAQ,CAAC,KAAK,gCAAgC;IAC9C,QAAQ,CAAC,oBAAoB,EAAE,mBAAmB,EAAE,CAAM;IAE1D,IAAI,yBAAyB,IAAI,MAAM,EAAE,CAExC;IAED,YAAY,EAAE,yBAAyB,EAAE,CAAM;;IAM/C,MAAM,CAAC,kBAAkB,EAAE,iBAAiB,EAAE,CAAM;IACpD,MAAM,CAAC,oBAAoB,EAAE,2BAA2B,CAAC,yBAAyB,EAAE,CAAC,CAAC;IAGtF,SAAS,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,2BAA2B,CAAC,yBAAyB,EAAE,CAAC;IAQ/G,MAAM,CAAC,KAAK;CAGf"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ObservableQueryFor } from '@cratis/arc/queries';
|
|
2
|
+
export class FakeObservableQuery extends ObservableQueryFor {
|
|
3
|
+
route = '/api/fake-observable-query';
|
|
4
|
+
parameterDescriptors = [];
|
|
5
|
+
get requiredRequestParameters() {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
defaultValue = [];
|
|
9
|
+
constructor() {
|
|
10
|
+
super(Object, true);
|
|
11
|
+
}
|
|
12
|
+
static subscribeCallbacks = [];
|
|
13
|
+
static subscriptionReturned;
|
|
14
|
+
subscribe(callback, args) {
|
|
15
|
+
FakeObservableQuery.subscribeCallbacks.push(callback);
|
|
16
|
+
FakeObservableQuery.subscriptionReturned = {
|
|
17
|
+
unsubscribe: () => { }
|
|
18
|
+
};
|
|
19
|
+
return FakeObservableQuery.subscriptionReturned;
|
|
20
|
+
}
|
|
21
|
+
static reset() {
|
|
22
|
+
FakeObservableQuery.subscribeCallbacks = [];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=FakeObservableQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FakeObservableQuery.js","sourceRoot":"","sources":["../../../../queries/for_useObservableQuery/FakeObservableQuery.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAA0D,MAAM,qBAAqB,CAAC;AAUjH,MAAM,OAAO,mBAAoB,SAAQ,kBAA+C;IAC3E,KAAK,GAAG,4BAA4B,CAAC;IACrC,oBAAoB,GAA0B,EAAE,CAAC;IAE1D,IAAI,yBAAyB;QACzB,OAAO,EAAE,CAAC;IACd,CAAC;IAED,YAAY,GAAgC,EAAE,CAAC;IAE/C;QACI,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACxB,CAAC;IAED,MAAM,CAAC,kBAAkB,GAAwB,EAAE,CAAC;IACpD,MAAM,CAAC,oBAAoB,CAA2D;IAGtF,SAAS,CAAC,QAA2B,EAAE,IAAa;QAChD,mBAAmB,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtD,mBAAmB,CAAC,oBAAoB,GAAG;YACvC,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;SAC+C,CAAC;QACzE,OAAO,mBAAmB,CAAC,oBAAoB,CAAC;IACpD,CAAC;IAED,MAAM,CAAC,KAAK;QACR,mBAAmB,CAAC,kBAAkB,GAAG,EAAE,CAAC;IAChD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_creating_instance.d.ts","sourceRoot":"","sources":["../../../../queries/for_useObservableQuery/when_creating_instance.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, act } from '@testing-library/react';
|
|
3
|
+
import { useObservableQuery } from '../useObservableQuery';
|
|
4
|
+
import { FakeObservableQuery } from './FakeObservableQuery';
|
|
5
|
+
import { ArcContext } from '../../ArcContext';
|
|
6
|
+
import { QueryResult } from '@cratis/arc/queries';
|
|
7
|
+
describe('when creating instance', () => {
|
|
8
|
+
let capturedIsPerformingInitial = null;
|
|
9
|
+
let capturedIsPerformingAfterResponse = null;
|
|
10
|
+
let renderCount = 0;
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
FakeObservableQuery.reset();
|
|
13
|
+
capturedIsPerformingInitial = null;
|
|
14
|
+
capturedIsPerformingAfterResponse = null;
|
|
15
|
+
renderCount = 0;
|
|
16
|
+
});
|
|
17
|
+
const config = {
|
|
18
|
+
microservice: 'test-microservice',
|
|
19
|
+
apiBasePath: '/api',
|
|
20
|
+
origin: 'https://example.com',
|
|
21
|
+
};
|
|
22
|
+
it('should have isPerforming true initially before receiving data', async () => {
|
|
23
|
+
const TestComponent = () => {
|
|
24
|
+
const [result] = useObservableQuery(FakeObservableQuery);
|
|
25
|
+
renderCount++;
|
|
26
|
+
if (renderCount === 1) {
|
|
27
|
+
capturedIsPerformingInitial = result.isPerforming;
|
|
28
|
+
}
|
|
29
|
+
return React.createElement('div', null, 'Test');
|
|
30
|
+
};
|
|
31
|
+
render(React.createElement(ArcContext.Provider, { value: config }, React.createElement(TestComponent)));
|
|
32
|
+
capturedIsPerformingInitial.should.be.true;
|
|
33
|
+
});
|
|
34
|
+
it('should have isPerforming false after receiving data', async () => {
|
|
35
|
+
const TestComponent = () => {
|
|
36
|
+
const [result] = useObservableQuery(FakeObservableQuery);
|
|
37
|
+
renderCount++;
|
|
38
|
+
if (renderCount === 1) {
|
|
39
|
+
capturedIsPerformingInitial = result.isPerforming;
|
|
40
|
+
}
|
|
41
|
+
else if (renderCount === 2) {
|
|
42
|
+
capturedIsPerformingAfterResponse = result.isPerforming;
|
|
43
|
+
}
|
|
44
|
+
return React.createElement('div', null, 'Test');
|
|
45
|
+
};
|
|
46
|
+
render(React.createElement(ArcContext.Provider, { value: config }, React.createElement(TestComponent)));
|
|
47
|
+
const callback = FakeObservableQuery.subscribeCallbacks[0];
|
|
48
|
+
callback.should.not.be.undefined;
|
|
49
|
+
await act(async () => {
|
|
50
|
+
callback(new QueryResult({
|
|
51
|
+
data: [{ id: '1', name: 'Test' }],
|
|
52
|
+
isSuccess: true,
|
|
53
|
+
isAuthorized: true,
|
|
54
|
+
isValid: true,
|
|
55
|
+
hasExceptions: false,
|
|
56
|
+
validationResults: [],
|
|
57
|
+
exceptionMessages: [],
|
|
58
|
+
exceptionStackTrace: '',
|
|
59
|
+
paging: { page: 0, size: 0, totalItems: 0, totalPages: 0 }
|
|
60
|
+
}, Array, true));
|
|
61
|
+
});
|
|
62
|
+
capturedIsPerformingInitial.should.be.true;
|
|
63
|
+
capturedIsPerformingAfterResponse.should.be.false;
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=when_creating_instance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_creating_instance.js","sourceRoot":"","sources":["../../../../queries/for_useObservableQuery/when_creating_instance.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAoB,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIlD,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACpC,IAAI,2BAA2B,GAAmB,IAAI,CAAC;IACvD,IAAI,iCAAiC,GAAmB,IAAI,CAAC;IAC7D,IAAI,WAAW,GAAG,CAAC,CAAC;IAEpB,UAAU,CAAC,GAAG,EAAE;QACZ,mBAAmB,CAAC,KAAK,EAAE,CAAC;QAC5B,2BAA2B,GAAG,IAAI,CAAC;QACnC,iCAAiC,GAAG,IAAI,CAAC;QACzC,WAAW,GAAG,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAqB;QAC7B,YAAY,EAAE,mBAAmB;QACjC,WAAW,EAAE,MAAM;QACnB,MAAM,EAAE,qBAAqB;KAChC,CAAC;IAEF,EAAE,CAAC,+DAA+D,EAAE,KAAK,IAAI,EAAE;QAC3E,MAAM,aAAa,GAAG,GAAG,EAAE;YACvB,MAAM,CAAC,MAAM,CAAC,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;YACzD,WAAW,EAAE,CAAC;YAEd,IAAI,WAAW,KAAK,CAAC,EAAE,CAAC;gBACpB,2BAA2B,GAAG,MAAM,CAAC,YAAY,CAAC;YACtD,CAAC;YAED,OAAO,KAAK,CAA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MAAM,EAAE,CAAC;gBACjC,SAAS,EAAE,IAAI;gBACf,YAAY,EAAE,IAAI;gBAClB,OAAO,EAAE,IAAI;gBACb,aAAa,EAAE,KAAK;gBACpB,iBAAiB,EAAE,EAAE;gBACrB,iBAAiB,EAAE,EAAE;gBACrB,mBAAmB,EAAE,EAAE;gBACvB,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE;aAC7D,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;QAEH,2BAA4B,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;QAC5C,iCAAkC,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC;IACvD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { QueryFor } from '@cratis/arc/queries';
|
|
2
|
+
import { ParameterDescriptor } from '@cratis/arc/reflection';
|
|
3
|
+
export interface FakeQueryResult {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class FakeQuery extends QueryFor<FakeQueryResult[]> {
|
|
8
|
+
readonly route = "/api/fake-query";
|
|
9
|
+
readonly parameterDescriptors: ParameterDescriptor[];
|
|
10
|
+
get requiredRequestParameters(): string[];
|
|
11
|
+
defaultValue: FakeQueryResult[];
|
|
12
|
+
constructor();
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=FakeQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FakeQuery.d.ts","sourceRoot":"","sources":["../../../../queries/for_useQuery/FakeQuery.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,WAAW,eAAe;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,SAAU,SAAQ,QAAQ,CAAC,eAAe,EAAE,CAAC;IACtD,QAAQ,CAAC,KAAK,qBAAqB;IACnC,QAAQ,CAAC,oBAAoB,EAAE,mBAAmB,EAAE,CAAM;IAE1D,IAAI,yBAAyB,IAAI,MAAM,EAAE,CAExC;IAED,YAAY,EAAE,eAAe,EAAE,CAAM;;CAKxC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { QueryFor } from '@cratis/arc/queries';
|
|
2
|
+
export class FakeQuery extends QueryFor {
|
|
3
|
+
route = '/api/fake-query';
|
|
4
|
+
parameterDescriptors = [];
|
|
5
|
+
get requiredRequestParameters() {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
defaultValue = [];
|
|
9
|
+
constructor() {
|
|
10
|
+
super(Object, true);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=FakeQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FakeQuery.js","sourceRoot":"","sources":["../../../../queries/for_useQuery/FakeQuery.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAQ/C,MAAM,OAAO,SAAU,SAAQ,QAA2B;IAC7C,KAAK,GAAG,iBAAiB,CAAC;IAC1B,oBAAoB,GAA0B,EAAE,CAAC;IAE1D,IAAI,yBAAyB;QACzB,OAAO,EAAE,CAAC;IACd,CAAC;IAED,YAAY,GAAsB,EAAE,CAAC;IAErC;QACI,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACxB,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_creating_instance.d.ts","sourceRoot":"","sources":["../../../../queries/for_useQuery/when_creating_instance.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { useQuery } from '../useQuery';
|
|
4
|
+
import { FakeQuery } from './FakeQuery';
|
|
5
|
+
import { ArcContext } from '../../ArcContext';
|
|
6
|
+
import { createFetchHelper } from '@cratis/arc/helpers/fetchHelper';
|
|
7
|
+
describe('when creating instance', () => {
|
|
8
|
+
let fetchStub;
|
|
9
|
+
let fetchHelper;
|
|
10
|
+
let queryInstance = null;
|
|
11
|
+
const captureInstance = (instance) => {
|
|
12
|
+
queryInstance = instance;
|
|
13
|
+
};
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
fetchHelper = createFetchHelper();
|
|
16
|
+
fetchStub = fetchHelper.stubFetch();
|
|
17
|
+
fetchStub.resolves({
|
|
18
|
+
json: async () => ({ data: [], isSuccess: true, isAuthorized: true, isValid: true, hasExceptions: false, validationResults: [], exceptionMessages: [], exceptionStackTrace: '' })
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
fetchHelper.restore();
|
|
23
|
+
});
|
|
24
|
+
const config = {
|
|
25
|
+
microservice: 'test-microservice',
|
|
26
|
+
apiBasePath: '/api',
|
|
27
|
+
origin: 'https://example.com',
|
|
28
|
+
httpHeadersCallback: () => ({ 'X-Custom-Header': 'custom-value' })
|
|
29
|
+
};
|
|
30
|
+
class SpyQuery extends FakeQuery {
|
|
31
|
+
constructor() {
|
|
32
|
+
super();
|
|
33
|
+
captureInstance(this);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
render(React.createElement(ArcContext.Provider, { value: config }, React.createElement(() => {
|
|
37
|
+
useQuery(SpyQuery);
|
|
38
|
+
return React.createElement('div', null, 'Test');
|
|
39
|
+
})));
|
|
40
|
+
it('should set microservice from context', () => (queryInstance._microservice).should.equal('test-microservice'));
|
|
41
|
+
it('should set api base path from context', () => (queryInstance._apiBasePath).should.equal('/api'));
|
|
42
|
+
it('should set origin from context', () => (queryInstance._origin).should.equal('https://example.com'));
|
|
43
|
+
it('should set http headers callback from context', () => {
|
|
44
|
+
const headers = queryInstance._httpHeadersCallback();
|
|
45
|
+
headers.should.deep.equal({ 'X-Custom-Header': 'custom-value' });
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=when_creating_instance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_creating_instance.js","sourceRoot":"","sources":["../../../../queries/for_useQuery/when_creating_instance.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAoB,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAIpE,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACpC,IAAI,SAA0B,CAAC;IAC/B,IAAI,WAAsE,CAAC;IAC3E,IAAI,aAAa,GAAqB,IAAI,CAAC;IAE3C,MAAM,eAAe,GAAG,CAAC,QAAmB,EAAE,EAAE;QAC5C,aAAa,GAAG,QAAQ,CAAC;IAC7B,CAAC,CAAC;IAEF,UAAU,CAAC,GAAG,EAAE;QACZ,WAAW,GAAG,iBAAiB,EAAE,CAAC;QAClC,SAAS,GAAG,WAAW,CAAC,SAAS,EAAE,CAAC;QACpC,SAAS,CAAC,QAAQ,CAAC;YACf,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,iBAAiB,EAAE,EAAE,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,+CAA+C,EAAE,GAAG,EAAE;QACrD,MAAM,OAAO,GAAI,aAAqB,CAAC,oBAAoB,EAAE,CAAC;QAC9D,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_sorting.d.ts","sourceRoot":"","sources":["../../../../queries/for_useQuery/when_creating_instance_with_sorting.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { useQuery } from '../useQuery';
|
|
4
|
+
import { FakeQuery } from './FakeQuery';
|
|
5
|
+
import { ArcContext } from '../../ArcContext';
|
|
6
|
+
import { Sorting } from '@cratis/arc/queries';
|
|
7
|
+
import { createFetchHelper } from '@cratis/arc/helpers/fetchHelper';
|
|
8
|
+
describe('when creating instance with sorting', () => {
|
|
9
|
+
let fetchHelper;
|
|
10
|
+
let queryInstance = null;
|
|
11
|
+
const captureInstance = (instance) => {
|
|
12
|
+
queryInstance = instance;
|
|
13
|
+
};
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
fetchHelper = createFetchHelper();
|
|
16
|
+
const fetchStub = fetchHelper.stubFetch();
|
|
17
|
+
fetchStub.resolves({
|
|
18
|
+
json: async () => ({ data: [], isSuccess: true, isAuthorized: true, isValid: true, hasExceptions: false, validationResults: [], exceptionMessages: [], exceptionStackTrace: '' })
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
fetchHelper.restore();
|
|
23
|
+
});
|
|
24
|
+
const config = {
|
|
25
|
+
microservice: 'test-microservice'
|
|
26
|
+
};
|
|
27
|
+
const sorting = new Sorting('name', 1);
|
|
28
|
+
class SpyQuery extends FakeQuery {
|
|
29
|
+
constructor() {
|
|
30
|
+
super();
|
|
31
|
+
captureInstance(this);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
render(React.createElement(ArcContext.Provider, { value: config }, React.createElement(() => {
|
|
35
|
+
useQuery(SpyQuery, undefined, sorting);
|
|
36
|
+
return React.createElement('div', null, 'Test');
|
|
37
|
+
})));
|
|
38
|
+
it('should set sorting on the query', () => queryInstance.sorting.should.equal(sorting));
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=when_creating_instance_with_sorting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_creating_instance_with_sorting.js","sourceRoot":"","sources":["../../../../queries/for_useQuery/when_creating_instance_with_sorting.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAoB,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;IACjD,IAAI,WAAsE,CAAC;IAC3E,IAAI,aAAa,GAAqB,IAAI,CAAC;IAE3C,MAAM,eAAe,GAAG,CAAC,QAAmB,EAAE,EAAE;QAC5C,aAAa,GAAG,QAAQ,CAAC;IAC7B,CAAC,CAAC;IAEF,UAAU,CAAC,GAAG,EAAE;QACZ,WAAW,GAAG,iBAAiB,EAAE,CAAC;QAClC,MAAM,SAAS,GAAG,WAAW,CAAC,SAAS,EAAE,CAAC;QAC1C,SAAS,CAAC,QAAQ,CAAC;YACf,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,iBAAiB,EAAE,EAAE,EAAE,iBAAiB,EAAE,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAAE,CAAC;SACxK,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACX,WAAW,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAqB;QAC7B,YAAY,EAAE,mBAAmB;KACpC,CAAC;IAEF,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAEvC,MAAM,QAAS,SAAQ,SAAS;QAC5B;YACI,KAAK,EAAE,CAAC;YACR,eAAe,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;KACJ;IAED,MAAM,CACF,KAAK,CAAC,aAAa,CACf,UAAU,CAAC,QAAQ,EACnB,EAAE,KAAK,EAAE,MAAM,EAAE,EACjB,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE;QACrB,QAAQ,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACvC,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC,CAAC,CACL,CACJ,CAAC;IAEF,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE,CAAC,aAAc,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAC9F,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_creating_instance_without_optional_context_values.d.ts","sourceRoot":"","sources":["../../../../queries/for_useQuery/when_creating_instance_without_optional_context_values.ts"],"names":[],"mappings":""}
|