Added autoSnakeCaseNames
to MapService
This commit is contained in:
parent
333ba32dff
commit
56e1fc62d0
5 changed files with 106 additions and 85 deletions
|
@ -317,13 +317,6 @@
|
|||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="recase">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/recase-1.0.0+1/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="shelf">
|
||||
<value>
|
||||
<list>
|
||||
|
@ -498,7 +491,6 @@
|
|||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/pub_semver-1.3.2/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/quiver_hashcode-1.0.0/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/random_string-0.0.1/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/recase-1.0.0+1/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/shelf-0.7.2/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/shelf_packages_handler-1.0.3/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/shelf_static-0.2.7/lib" />
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="7b89ff1e-1260-4dcf-9c3d-345de0471ea1" name="Default" comment="Response no longer closes if `serialize` is called with an empty string">
|
||||
<list default="true" id="7b89ff1e-1260-4dcf-9c3d-345de0471ea1" name="Default" comment="">
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/libraries/Dart_Packages.xml" afterPath="$PROJECT_DIR$/.idea/libraries/Dart_Packages.xml" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/CHANGELOG.md" afterPath="$PROJECT_DIR$/CHANGELOG.md" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/src/http/response_context.dart" afterPath="$PROJECT_DIR$/lib/src/http/response_context.dart" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/src/http/map_service.dart" afterPath="$PROJECT_DIR$/lib/src/http/map_service.dart" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/pubspec.yaml" afterPath="$PROJECT_DIR$/pubspec.yaml" />
|
||||
</list>
|
||||
<ignored path="$PROJECT_DIR$/.tmp/" />
|
||||
|
@ -49,27 +49,42 @@
|
|||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="CHANGELOG.md" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||
<file leaf-file-name="map_service.dart" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/http/map_service.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="245">
|
||||
<caret line="94" column="46" lean-forward="true" selection-start-line="94" selection-start-column="46" selection-end-line="94" selection-end-column="46" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="README.md" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/README.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor relative-caret-position="30">
|
||||
<caret line="2" column="13" lean-forward="false" selection-start-line="2" selection-start-column="13" selection-end-line="2" selection-end-column="13" />
|
||||
<folding />
|
||||
<first_editor relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding>
|
||||
<marker date="1506049250000" expanded="true" signature="588:776" ph="{...}" />
|
||||
</folding>
|
||||
</first_editor>
|
||||
<second_editor />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="map_service.dart" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/http/map_service.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="15">
|
||||
<caret line="24" column="0" lean-forward="false" selection-start-line="24" selection-start-column="0" selection-end-line="24" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
<file leaf-file-name="CHANGELOG.md" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor relative-caret-position="45">
|
||||
<caret line="3" column="45" lean-forward="false" selection-start-line="3" selection-start-column="45" selection-end-line="3" selection-end-column="45" />
|
||||
<folding />
|
||||
</first_editor>
|
||||
<second_editor />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -132,19 +147,6 @@
|
|||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="all.dart" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/test/all.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="165">
|
||||
<caret line="31" column="33" lean-forward="false" selection-start-line="31" selection-start-column="33" selection-end-line="31" selection-end-column="33" />
|
||||
<folding>
|
||||
<element signature="e#0#38#0" expanded="true" />
|
||||
<marker date="1511894754000" expanded="true" signature="1709:1766" ph="{...}" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
|
@ -156,8 +158,6 @@
|
|||
</component>
|
||||
<component name="FindInProjectRecents">
|
||||
<findStrings>
|
||||
<find>sendRes</find>
|
||||
<find>handleRequ</find>
|
||||
<find>sendRespon</find>
|
||||
<find>inject(</find>
|
||||
<find>sendRe</find>
|
||||
|
@ -186,6 +186,8 @@
|
|||
<find>cache</find>
|
||||
<find>errorHan</find>
|
||||
<find>addStre</find>
|
||||
<find>((cre)|(upd))atedAt</find>
|
||||
<find>'((cre)|(upd))atedAt'</find>
|
||||
</findStrings>
|
||||
<replaceStrings>
|
||||
<replace>_isClosed</replace>
|
||||
|
@ -206,6 +208,7 @@
|
|||
<replace>cookie</replace>
|
||||
<replace>req.path</replace>
|
||||
<replace>req.path`</replace>
|
||||
<replace>autoSnakeCaseNames == false ? $0 : '$1ated_at'</replace>
|
||||
</replaceStrings>
|
||||
<dirStrings>
|
||||
<dir>C:\Users\thosa\Source\Angel\framework\lib</dir>
|
||||
|
@ -278,10 +281,10 @@
|
|||
<option value="$PROJECT_DIR$/test/extension_test.dart" />
|
||||
<option value="$PROJECT_DIR$/test/all.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/http/service.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/http/map_service.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/http/server.dart" />
|
||||
<option value="$PROJECT_DIR$/pubspec.yaml" />
|
||||
<option value="$PROJECT_DIR$/lib/src/http/response_context.dart" />
|
||||
<option value="$PROJECT_DIR$/pubspec.yaml" />
|
||||
<option value="$PROJECT_DIR$/lib/src/http/map_service.dart" />
|
||||
<option value="$PROJECT_DIR$/CHANGELOG.md" />
|
||||
</list>
|
||||
</option>
|
||||
|
@ -370,7 +373,7 @@
|
|||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager" selected="Dart Test.All Tests (PRODUCTION)">
|
||||
<component name="RunManager" selected="Dart Test.All Tests">
|
||||
<configuration name="Chained routes in routing_test.dart" type="DartTestRunConfigurationType" factoryName="Dart Test" nameIsGenerated="true">
|
||||
<option name="filePath" value="$PROJECT_DIR$/test/routing_test.dart" />
|
||||
<option name="scope" value="GROUP_OR_TEST_BY_NAME" />
|
||||
|
@ -672,7 +675,7 @@
|
|||
<workItem from="1513103483207" duration="18000" />
|
||||
<workItem from="1513103506825" duration="139000" />
|
||||
<workItem from="1517332581856" duration="858000" />
|
||||
<workItem from="1517973177718" duration="223000" />
|
||||
<workItem from="1517973177718" duration="692000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Re-designed exception">
|
||||
<created>1481237183504</created>
|
||||
|
@ -1003,11 +1006,18 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1513103639013</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="48" />
|
||||
<task id="LOCAL-00048" summary="Response no longer closes if `serialize` is called with an empty string">
|
||||
<created>1517973412941</created>
|
||||
<option name="number" value="00048" />
|
||||
<option name="presentableId" value="LOCAL-00048" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1517973412941</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="49" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TestHistory">
|
||||
<history-entry file="All_Tests - 2017.12.12 at 13h 32m 53s.xml">
|
||||
<history-entry file="All_Tests - 2018.02.06 at 22h 24m 09s.xml">
|
||||
<configuration name="All Tests" configurationId="DartTestRunConfigurationType" />
|
||||
</history-entry>
|
||||
<history-entry file="All_Tests_(PRODUCTION) - 2017.11.28 at 13h 12m 52s.xml">
|
||||
|
@ -1039,7 +1049,7 @@
|
|||
</history-entry>
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="118259000" />
|
||||
<option name="totallyTimeSpent" value="118728000" />
|
||||
</component>
|
||||
<component name="TodoView">
|
||||
<todo-panel id="selected-file">
|
||||
|
@ -1074,7 +1084,7 @@
|
|||
<window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32905984" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4002849" sideWeight="0.4964476" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.4002849" sideWeight="0.4964476" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.48005697" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.2023166" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Theme Preview" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
|
@ -1097,7 +1107,7 @@
|
|||
<option name="myLimit" value="2678400000" />
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="1.0.6+2" />
|
||||
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
|
||||
<MESSAGE value="Added RequestContext.accepts" />
|
||||
<MESSAGE value="Swapped to angel_model" />
|
||||
<MESSAGE value="1.0.7+2" />
|
||||
|
@ -1122,7 +1132,8 @@
|
|||
<MESSAGE value="Patched _matchesId, bump to 1.1.0+1" />
|
||||
<MESSAGE value="Patched handleAngelHttpException, bump to 1.1.0+2" />
|
||||
<MESSAGE value="Patched ResponseContext#isOpen, bump to 1.1.0+3" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Patched ResponseContext#isOpen, bump to 1.1.0+3" />
|
||||
<MESSAGE value="Response no longer closes if `serialize` is called with an empty string" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Response no longer closes if `serialize` is called with an empty string" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager />
|
||||
|
@ -1281,16 +1292,6 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/README.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor relative-caret-position="210">
|
||||
<caret line="14" column="24" lean-forward="false" selection-start-line="14" selection-start-column="24" selection-end-line="14" selection-end-column="24" />
|
||||
</first_editor>
|
||||
<second_editor />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/di_test.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="30">
|
||||
|
@ -1460,14 +1461,6 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="105">
|
||||
<caret line="7" column="13" lean-forward="true" selection-start-line="7" selection-start-column="13" selection-end-line="7" selection-end-column="13" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/http/server.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1481">
|
||||
|
@ -1478,16 +1471,6 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/http/map_service.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="15">
|
||||
<caret line="24" column="0" lean-forward="false" selection-start-line="24" selection-start-column="0" selection-end-line="24" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/http/response_context.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="371">
|
||||
|
@ -1496,11 +1479,42 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="315">
|
||||
<caret line="21" column="23" lean-forward="false" selection-start-line="21" selection-start-column="23" selection-end-line="21" selection-end-column="23" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/http/map_service.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="245">
|
||||
<caret line="94" column="46" lean-forward="true" selection-start-line="94" selection-start-column="46" selection-end-line="94" selection-end-column="46" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/README.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding>
|
||||
<marker date="1506049250000" expanded="true" signature="588:776" ph="{...}" />
|
||||
</folding>
|
||||
</first_editor>
|
||||
<second_editor />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor relative-caret-position="30">
|
||||
<caret line="2" column="13" lean-forward="false" selection-start-line="2" selection-start-column="13" selection-end-line="2" selection-end-column="13" />
|
||||
<first_editor relative-caret-position="45">
|
||||
<caret line="3" column="45" lean-forward="false" selection-start-line="3" selection-start-column="45" selection-end-line="3" selection-end-column="45" />
|
||||
<folding />
|
||||
</first_editor>
|
||||
<second_editor />
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# 1.1.1
|
||||
* `ResponseContext` no longer automatically closes if `serializer` returns an
|
||||
empty string.
|
||||
* Added `autoSnakeCaseNames` to `MapService`.
|
||||
|
||||
# 1.1.0+3
|
||||
* Modified `ResponseContext#isOpen` to also return `false` if streaming is being used.
|
||||
|
|
|
@ -15,14 +15,24 @@ class MapService extends Service {
|
|||
/// If set to `true` (default), then the service will manage an `id` string and `createdAt` and `updatedAt` fields.
|
||||
final bool autoIdAndDateFields;
|
||||
|
||||
/// If set to `true` (default), then the keys `created_at` and `updated_at` will automatically be snake_cased.
|
||||
final bool autoSnakeCaseNames;
|
||||
|
||||
final List<Map<String, dynamic>> items = [];
|
||||
|
||||
MapService(
|
||||
{this.allowRemoveAll: false,
|
||||
this.allowQuery: true,
|
||||
this.autoIdAndDateFields: true})
|
||||
this.autoIdAndDateFields: true,
|
||||
this.autoSnakeCaseNames: true})
|
||||
: super();
|
||||
|
||||
String get createdAtKey =>
|
||||
autoSnakeCaseNames == false ? 'createdAt' : 'created_at';
|
||||
|
||||
String get updatedAtKey =>
|
||||
autoSnakeCaseNames == false ? 'updatedAt' : 'updated_at';
|
||||
|
||||
bool Function(Map) _matchesId(id) {
|
||||
return (Map item) {
|
||||
if (item['id'] == null)
|
||||
|
@ -72,8 +82,8 @@ class MapService extends Service {
|
|||
if (autoIdAndDateFields == true) {
|
||||
result
|
||||
..['id'] = items.length.toString()
|
||||
..['createdAt'] = now
|
||||
..['updatedAt'] = now;
|
||||
..[autoSnakeCaseNames == false ? 'createdAt' : 'created_at'] = now
|
||||
..[autoSnakeCaseNames == false ? 'updatedAt' : 'updated_at'] = now;
|
||||
}
|
||||
items.add(result);
|
||||
return result;
|
||||
|
@ -90,7 +100,10 @@ class MapService extends Service {
|
|||
var item = await read(id);
|
||||
var result = item..addAll(data);
|
||||
|
||||
if (autoIdAndDateFields == true) result..['updatedAt'] = new DateTime.now();
|
||||
if (autoIdAndDateFields == true)
|
||||
result
|
||||
..[autoSnakeCaseNames == false ? 'updatedAt' : 'updated_at'] =
|
||||
new DateTime.now();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -112,8 +125,10 @@ class MapService extends Service {
|
|||
if (autoIdAndDateFields == true) {
|
||||
result
|
||||
..['id'] = id?.toString()
|
||||
..['createdAt'] = old['createdAt']
|
||||
..['updatedAt'] = new DateTime.now();
|
||||
..[autoSnakeCaseNames == false ? 'createdAt' : 'created_at'] =
|
||||
old[autoSnakeCaseNames == false ? 'createdAt' : 'created_at']
|
||||
..[autoSnakeCaseNames == false ? 'updatedAt' : 'updated_at'] =
|
||||
new DateTime.now();
|
||||
}
|
||||
items.add(result);
|
||||
return result;
|
||||
|
|
|
@ -20,7 +20,6 @@ dependencies:
|
|||
mime: ^0.9.3
|
||||
pool: ^1.0.0
|
||||
random_string: ^0.0.1
|
||||
recase: ^1.0.0
|
||||
tuple: ^1.0.0
|
||||
dev_dependencies:
|
||||
mock_request: ^1.0.0
|
||||
|
|
Loading…
Reference in a new issue