breeze-client 2.2.1-cjs → 2.2.2
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/adapter-ajax-angularjs/{breeze-client-adapter-ajax-angularjs.d.ts → index.d.ts} +1 -0
- package/adapter-ajax-fetch/{breeze-client-adapter-ajax-fetch.d.ts → index.d.ts} +1 -0
- package/adapter-ajax-httpclient/{breeze-client-adapter-ajax-httpclient.d.ts → index.d.ts} +1 -0
- package/adapter-ajax-jquery/{breeze-client-adapter-ajax-jquery.d.ts → index.d.ts} +1 -0
- package/adapter-ajax-post/{breeze-client-adapter-ajax-post.d.ts → index.d.ts} +1 -0
- package/adapter-data-service-odata/{breeze-client-adapter-data-service-odata.d.ts → index.d.ts} +1 -0
- package/adapter-data-service-webapi/{breeze-client-adapter-data-service-webapi.d.ts → index.d.ts} +1 -0
- package/adapter-model-library-backing-store/{breeze-client-adapter-model-library-backing-store.d.ts → index.d.ts} +1 -0
- package/adapter-model-library-ko/{breeze-client-adapter-model-library-ko.d.ts → index.d.ts} +1 -0
- package/adapter-uri-builder-json/{breeze-client-adapter-uri-builder-json.d.ts → index.d.ts} +1 -0
- package/adapter-uri-builder-odata/{breeze-client-adapter-uri-builder-odata.d.ts → index.d.ts} +1 -0
- package/esm2022/adapter-ajax-angularjs/adapter-ajax-angularjs.mjs +135 -0
- package/esm2022/adapter-ajax-angularjs/adapter-core.mjs +49 -0
- package/esm2022/adapter-ajax-angularjs/breeze-client-adapter-ajax-angularjs.mjs +5 -0
- package/esm2022/adapter-ajax-fetch/adapter-ajax-fetch.mjs +135 -0
- package/esm2022/adapter-ajax-fetch/adapter-core.mjs +49 -0
- package/esm2022/adapter-ajax-fetch/breeze-client-adapter-ajax-fetch.mjs +5 -0
- package/esm2022/adapter-ajax-httpclient/adapter-ajax-httpclient.mjs +139 -0
- package/esm2022/adapter-ajax-httpclient/adapter-core.mjs +49 -0
- package/esm2022/adapter-ajax-httpclient/breeze-client-adapter-ajax-httpclient.mjs +5 -0
- package/esm2022/adapter-ajax-jquery/adapter-ajax-jquery.mjs +107 -0
- package/esm2022/adapter-ajax-jquery/breeze-client-adapter-ajax-jquery.mjs +5 -0
- package/esm2022/adapter-ajax-post/adapter-ajax-post.mjs +77 -0
- package/esm2022/adapter-ajax-post/breeze-client-adapter-ajax-post.mjs +5 -0
- package/esm2022/adapter-data-service-odata/adapter-core.mjs +49 -0
- package/{esm5/adapter-data-service-odata/adapter-data-service-odata.js → esm2022/adapter-data-service-odata/adapter-data-service-odata.mjs} +138 -147
- package/esm2022/adapter-data-service-odata/breeze-client-adapter-data-service-odata.mjs +5 -0
- package/esm2022/adapter-data-service-webapi/adapter-data-service-webapi.mjs +100 -0
- package/esm2022/adapter-data-service-webapi/breeze-client-adapter-data-service-webapi.mjs +5 -0
- package/esm2022/adapter-model-library-backing-store/adapter-model-library-backing-store.mjs +269 -0
- package/esm2022/adapter-model-library-backing-store/breeze-client-adapter-model-library-backing-store.mjs +5 -0
- package/esm2022/adapter-model-library-ko/adapter-model-library-ko.mjs +241 -0
- package/esm2022/adapter-model-library-ko/breeze-client-adapter-model-library-ko.mjs +5 -0
- package/esm2022/adapter-uri-builder-json/adapter-core.mjs +49 -0
- package/esm2022/adapter-uri-builder-json/adapter-uri-builder-json.mjs +37 -0
- package/esm2022/adapter-uri-builder-json/breeze-client-adapter-uri-builder-json.mjs +5 -0
- package/esm2022/adapter-uri-builder-odata/adapter-core.mjs +49 -0
- package/esm2022/adapter-uri-builder-odata/adapter-uri-builder-odata.mjs +191 -0
- package/esm2022/adapter-uri-builder-odata/breeze-client-adapter-uri-builder-odata.mjs +5 -0
- package/esm2022/breeze-client.mjs +5 -0
- package/esm2022/index.mjs +2 -0
- package/esm2022/mixin-get-entity-graph/breeze-client-mixin-get-entity-graph.mjs +5 -0
- package/esm2022/mixin-get-entity-graph/mixin-get-entity-graph.mjs +269 -0
- package/esm2022/mixin-save-queuing/breeze-client-mixin-save-queuing.mjs +5 -0
- package/esm2022/mixin-save-queuing/mixin-save-queuing.mjs +421 -0
- package/esm2022/src/abstract-data-service-adapter.mjs +325 -0
- package/esm2022/src/array.mjs +4 -0
- package/esm2022/src/assert-param.mjs +330 -0
- package/esm2022/src/breeze.mjs +85 -0
- package/esm2022/src/complex-array.mjs +117 -0
- package/esm2022/src/config.mjs +232 -0
- package/esm2022/src/core.mjs +712 -0
- package/esm2022/src/csdl-metadata-parser.mjs +385 -0
- package/esm2022/src/data-service.mjs +221 -0
- package/esm2022/src/data-type.mjs +510 -0
- package/esm2022/src/default-property-interceptor.mjs +460 -0
- package/{esm2015/src/entity-action.js → esm2022/src/entity-action.mjs} +25 -25
- package/esm2022/src/entity-aspect.mjs +897 -0
- package/esm2022/src/entity-group.mjs +192 -0
- package/esm2022/src/entity-key.mjs +125 -0
- package/esm2022/src/entity-manager.mjs +2163 -0
- package/esm2022/src/entity-metadata.mjs +2242 -0
- package/esm2022/src/entity-query.mjs +1024 -0
- package/esm2022/src/entity-state.mjs +107 -0
- package/esm2022/src/enum.mjs +143 -0
- package/esm2022/src/event.mjs +264 -0
- package/esm2022/src/interface-registry.mjs +39 -0
- package/esm2022/src/key-generator.mjs +110 -0
- package/esm2022/src/local-query-comparison-options.mjs +65 -0
- package/esm2022/src/mapping-context.mjs +411 -0
- package/esm2022/src/naming-convention.mjs +92 -0
- package/esm2022/src/observable-array.mjs +183 -0
- package/esm2022/src/predicate.mjs +1259 -0
- package/esm2022/src/primitive-array.mjs +85 -0
- package/esm2022/src/query-options.mjs +152 -0
- package/esm2022/src/relation-array.mjs +173 -0
- package/esm2022/src/save-options.mjs +41 -0
- package/esm2022/src/unattached-children-map.mjs +56 -0
- package/esm2022/src/validate.mjs +995 -0
- package/esm2022/src/validation-options.mjs +64 -0
- package/{fesm2015/breeze-client-adapter-ajax-angularjs.js → fesm2022/breeze-client-adapter-ajax-angularjs.mjs} +6 -1
- package/fesm2022/breeze-client-adapter-ajax-angularjs.mjs.map +1 -0
- package/{fesm2015/breeze-client-adapter-ajax-fetch.js → fesm2022/breeze-client-adapter-ajax-fetch.mjs} +9 -4
- package/fesm2022/breeze-client-adapter-ajax-fetch.mjs.map +1 -0
- package/{fesm2015/breeze-client-adapter-ajax-httpclient.js → fesm2022/breeze-client-adapter-ajax-httpclient.mjs} +6 -4
- package/fesm2022/breeze-client-adapter-ajax-httpclient.mjs.map +1 -0
- package/{fesm2015/breeze-client-adapter-ajax-jquery.js → fesm2022/breeze-client-adapter-ajax-jquery.mjs} +6 -2
- package/fesm2022/breeze-client-adapter-ajax-jquery.mjs.map +1 -0
- package/{fesm2015/breeze-client-adapter-ajax-post.js → fesm2022/breeze-client-adapter-ajax-post.mjs} +1 -1
- package/fesm2022/breeze-client-adapter-ajax-post.mjs.map +1 -0
- package/{fesm2015/breeze-client-adapter-data-service-odata.js → fesm2022/breeze-client-adapter-data-service-odata.mjs} +68 -69
- package/fesm2022/breeze-client-adapter-data-service-odata.mjs.map +1 -0
- package/{fesm2015/breeze-client-adapter-data-service-webapi.js → fesm2022/breeze-client-adapter-data-service-webapi.mjs} +30 -30
- package/fesm2022/breeze-client-adapter-data-service-webapi.mjs.map +1 -0
- package/{fesm2015/breeze-client-adapter-model-library-backing-store.js → fesm2022/breeze-client-adapter-model-library-backing-store.mjs} +14 -13
- package/fesm2022/breeze-client-adapter-model-library-backing-store.mjs.map +1 -0
- package/{fesm2015/breeze-client-adapter-model-library-ko.js → fesm2022/breeze-client-adapter-model-library-ko.mjs} +14 -13
- package/fesm2022/breeze-client-adapter-model-library-ko.mjs.map +1 -0
- package/{fesm2015/breeze-client-adapter-uri-builder-json.js → fesm2022/breeze-client-adapter-uri-builder-json.mjs} +9 -8
- package/fesm2022/breeze-client-adapter-uri-builder-json.mjs.map +1 -0
- package/{fesm2015/breeze-client-adapter-uri-builder-odata.js → fesm2022/breeze-client-adapter-uri-builder-odata.mjs} +86 -86
- package/fesm2022/breeze-client-adapter-uri-builder-odata.mjs.map +1 -0
- package/{fesm2015/breeze-client-mixin-get-entity-graph.js → fesm2022/breeze-client-mixin-get-entity-graph.mjs} +1 -1
- package/fesm2022/breeze-client-mixin-get-entity-graph.mjs.map +1 -0
- package/{fesm2015/breeze-client-mixin-save-queuing.js → fesm2022/breeze-client-mixin-save-queuing.mjs} +23 -2
- package/fesm2022/breeze-client-mixin-save-queuing.mjs.map +1 -0
- package/{fesm2015/breeze-client.js → fesm2022/breeze-client.mjs} +1933 -1538
- package/fesm2022/breeze-client.mjs.map +1 -0
- package/mixin-get-entity-graph/{breeze-client-mixin-get-entity-graph.d.ts → index.d.ts} +1 -0
- package/mixin-save-queuing/{breeze-client-mixin-save-queuing.d.ts → index.d.ts} +1 -0
- package/package.json +94 -12
- package/src/config.d.ts +1 -1
- package/src/core.d.ts +1 -1
- package/src/entity-aspect.d.ts +1 -1
- package/src/entity-metadata.d.ts +8 -6
- package/src/entity-query.d.ts +1 -1
- package/adapter-ajax-angularjs/breeze-client-adapter-ajax-angularjs.metadata.json +0 -1
- package/adapter-ajax-angularjs/package.json +0 -13
- package/adapter-ajax-fetch/breeze-client-adapter-ajax-fetch.metadata.json +0 -1
- package/adapter-ajax-fetch/package.json +0 -13
- package/adapter-ajax-httpclient/breeze-client-adapter-ajax-httpclient.metadata.json +0 -1
- package/adapter-ajax-httpclient/package.json +0 -13
- package/adapter-ajax-jquery/breeze-client-adapter-ajax-jquery.metadata.json +0 -1
- package/adapter-ajax-jquery/package.json +0 -13
- package/adapter-ajax-post/breeze-client-adapter-ajax-post.metadata.json +0 -1
- package/adapter-ajax-post/package.json +0 -13
- package/adapter-data-service-odata/breeze-client-adapter-data-service-odata.metadata.json +0 -1
- package/adapter-data-service-odata/package.json +0 -13
- package/adapter-data-service-webapi/breeze-client-adapter-data-service-webapi.metadata.json +0 -1
- package/adapter-data-service-webapi/package.json +0 -13
- package/adapter-model-library-backing-store/breeze-client-adapter-model-library-backing-store.metadata.json +0 -1
- package/adapter-model-library-backing-store/package.json +0 -13
- package/adapter-model-library-ko/breeze-client-adapter-model-library-ko.metadata.json +0 -1
- package/adapter-model-library-ko/package.json +0 -13
- package/adapter-uri-builder-json/breeze-client-adapter-uri-builder-json.metadata.json +0 -1
- package/adapter-uri-builder-json/package.json +0 -13
- package/adapter-uri-builder-odata/breeze-client-adapter-uri-builder-odata.metadata.json +0 -1
- package/adapter-uri-builder-odata/package.json +0 -13
- package/breeze-client.d.ts +0 -8
- package/breeze-client.metadata.json +0 -1
- package/bundles/breeze-client-adapter-ajax-angularjs.umd.js +0 -190
- package/bundles/breeze-client-adapter-ajax-angularjs.umd.js.map +0 -1
- package/bundles/breeze-client-adapter-ajax-angularjs.umd.min.js +0 -2
- package/bundles/breeze-client-adapter-ajax-angularjs.umd.min.js.map +0 -1
- package/bundles/breeze-client-adapter-ajax-fetch.umd.js +0 -190
- package/bundles/breeze-client-adapter-ajax-fetch.umd.js.map +0 -1
- package/bundles/breeze-client-adapter-ajax-fetch.umd.min.js +0 -2
- package/bundles/breeze-client-adapter-ajax-fetch.umd.min.js.map +0 -1
- package/bundles/breeze-client-adapter-ajax-httpclient.umd.js +0 -195
- package/bundles/breeze-client-adapter-ajax-httpclient.umd.js.map +0 -1
- package/bundles/breeze-client-adapter-ajax-httpclient.umd.min.js +0 -2
- package/bundles/breeze-client-adapter-ajax-httpclient.umd.min.js.map +0 -1
- package/bundles/breeze-client-adapter-ajax-jquery.umd.js +0 -115
- package/bundles/breeze-client-adapter-ajax-jquery.umd.js.map +0 -1
- package/bundles/breeze-client-adapter-ajax-jquery.umd.min.js +0 -2
- package/bundles/breeze-client-adapter-ajax-jquery.umd.min.js.map +0 -1
- package/bundles/breeze-client-adapter-ajax-post.umd.js +0 -92
- package/bundles/breeze-client-adapter-ajax-post.umd.js.map +0 -1
- package/bundles/breeze-client-adapter-ajax-post.umd.min.js +0 -2
- package/bundles/breeze-client-adapter-ajax-post.umd.min.js.map +0 -1
- package/bundles/breeze-client-adapter-data-service-odata.umd.js +0 -747
- package/bundles/breeze-client-adapter-data-service-odata.umd.js.map +0 -1
- package/bundles/breeze-client-adapter-data-service-odata.umd.min.js +0 -16
- package/bundles/breeze-client-adapter-data-service-odata.umd.min.js.map +0 -1
- package/bundles/breeze-client-adapter-data-service-webapi.umd.js +0 -333
- package/bundles/breeze-client-adapter-data-service-webapi.umd.js.map +0 -1
- package/bundles/breeze-client-adapter-data-service-webapi.umd.min.js +0 -16
- package/bundles/breeze-client-adapter-data-service-webapi.umd.min.js.map +0 -1
- package/bundles/breeze-client-adapter-model-library-backing-store.umd.js +0 -280
- package/bundles/breeze-client-adapter-model-library-backing-store.umd.js.map +0 -1
- package/bundles/breeze-client-adapter-model-library-backing-store.umd.min.js +0 -2
- package/bundles/breeze-client-adapter-model-library-backing-store.umd.min.js.map +0 -1
- package/bundles/breeze-client-adapter-model-library-ko.umd.js +0 -252
- package/bundles/breeze-client-adapter-model-library-ko.umd.js.map +0 -1
- package/bundles/breeze-client-adapter-model-library-ko.umd.min.js +0 -2
- package/bundles/breeze-client-adapter-model-library-ko.umd.min.js.map +0 -1
- package/bundles/breeze-client-adapter-uri-builder-json.umd.js +0 -96
- package/bundles/breeze-client-adapter-uri-builder-json.umd.js.map +0 -1
- package/bundles/breeze-client-adapter-uri-builder-json.umd.min.js +0 -2
- package/bundles/breeze-client-adapter-uri-builder-json.umd.min.js.map +0 -1
- package/bundles/breeze-client-adapter-uri-builder-odata.umd.js +0 -262
- package/bundles/breeze-client-adapter-uri-builder-odata.umd.js.map +0 -1
- package/bundles/breeze-client-adapter-uri-builder-odata.umd.min.js +0 -2
- package/bundles/breeze-client-adapter-uri-builder-odata.umd.min.js.map +0 -1
- package/bundles/breeze-client-mixin-get-entity-graph.umd.js +0 -258
- package/bundles/breeze-client-mixin-get-entity-graph.umd.js.map +0 -1
- package/bundles/breeze-client-mixin-get-entity-graph.umd.min.js +0 -2
- package/bundles/breeze-client-mixin-get-entity-graph.umd.min.js.map +0 -1
- package/bundles/breeze-client-mixin-save-queuing.umd.js +0 -579
- package/bundles/breeze-client-mixin-save-queuing.umd.js.map +0 -1
- package/bundles/breeze-client-mixin-save-queuing.umd.min.js +0 -16
- package/bundles/breeze-client-mixin-save-queuing.umd.min.js.map +0 -1
- package/bundles/breeze-client.umd.js +0 -14234
- package/bundles/breeze-client.umd.js.map +0 -1
- package/bundles/breeze-client.umd.min.js +0 -16
- package/bundles/breeze-client.umd.min.js.map +0 -1
- package/esm2015/adapter-ajax-angularjs/adapter-ajax-angularjs.js +0 -130
- package/esm2015/adapter-ajax-angularjs/adapter-core.js +0 -49
- package/esm2015/adapter-ajax-angularjs/breeze-client-adapter-ajax-angularjs.js +0 -5
- package/esm2015/adapter-ajax-fetch/adapter-ajax-fetch.js +0 -130
- package/esm2015/adapter-ajax-fetch/adapter-core.js +0 -49
- package/esm2015/adapter-ajax-fetch/breeze-client-adapter-ajax-fetch.js +0 -5
- package/esm2015/adapter-ajax-httpclient/adapter-ajax-httpclient.js +0 -137
- package/esm2015/adapter-ajax-httpclient/adapter-core.js +0 -49
- package/esm2015/adapter-ajax-httpclient/breeze-client-adapter-ajax-httpclient.js +0 -5
- package/esm2015/adapter-ajax-jquery/adapter-ajax-jquery.js +0 -103
- package/esm2015/adapter-ajax-jquery/breeze-client-adapter-ajax-jquery.js +0 -5
- package/esm2015/adapter-ajax-post/adapter-ajax-post.js +0 -77
- package/esm2015/adapter-ajax-post/breeze-client-adapter-ajax-post.js +0 -5
- package/esm2015/adapter-data-service-odata/adapter-core.js +0 -49
- package/esm2015/adapter-data-service-odata/adapter-data-service-odata.js +0 -463
- package/esm2015/adapter-data-service-odata/breeze-client-adapter-data-service-odata.js +0 -5
- package/esm2015/adapter-data-service-webapi/adapter-data-service-webapi.js +0 -100
- package/esm2015/adapter-data-service-webapi/breeze-client-adapter-data-service-webapi.js +0 -5
- package/esm2015/adapter-model-library-backing-store/adapter-model-library-backing-store.js +0 -268
- package/esm2015/adapter-model-library-backing-store/breeze-client-adapter-model-library-backing-store.js +0 -5
- package/esm2015/adapter-model-library-ko/adapter-model-library-ko.js +0 -240
- package/esm2015/adapter-model-library-ko/breeze-client-adapter-model-library-ko.js +0 -5
- package/esm2015/adapter-uri-builder-json/adapter-core.js +0 -49
- package/esm2015/adapter-uri-builder-json/adapter-uri-builder-json.js +0 -36
- package/esm2015/adapter-uri-builder-json/breeze-client-adapter-uri-builder-json.js +0 -5
- package/esm2015/adapter-uri-builder-odata/adapter-core.js +0 -49
- package/esm2015/adapter-uri-builder-odata/adapter-uri-builder-odata.js +0 -192
- package/esm2015/adapter-uri-builder-odata/breeze-client-adapter-uri-builder-odata.js +0 -5
- package/esm2015/breeze-client.js +0 -9
- package/esm2015/index.js +0 -2
- package/esm2015/mixin-get-entity-graph/breeze-client-mixin-get-entity-graph.js +0 -5
- package/esm2015/mixin-get-entity-graph/mixin-get-entity-graph.js +0 -269
- package/esm2015/mixin-save-queuing/breeze-client-mixin-save-queuing.js +0 -5
- package/esm2015/mixin-save-queuing/mixin-save-queuing.js +0 -400
- package/esm2015/src/abstract-data-service-adapter.js +0 -327
- package/esm2015/src/array.js +0 -4
- package/esm2015/src/assert-param.js +0 -312
- package/esm2015/src/breeze.js +0 -85
- package/esm2015/src/complex-array.js +0 -119
- package/esm2015/src/config.js +0 -223
- package/esm2015/src/core.js +0 -714
- package/esm2015/src/csdl-metadata-parser.js +0 -385
- package/esm2015/src/data-service.js +0 -203
- package/esm2015/src/data-type.js +0 -506
- package/esm2015/src/default-property-interceptor.js +0 -460
- package/esm2015/src/entity-aspect.js +0 -804
- package/esm2015/src/entity-group.js +0 -187
- package/esm2015/src/entity-key.js +0 -116
- package/esm2015/src/entity-manager.js +0 -2094
- package/esm2015/src/entity-metadata.js +0 -2109
- package/esm2015/src/entity-query.js +0 -1015
- package/esm2015/src/entity-state.js +0 -107
- package/esm2015/src/enum.js +0 -141
- package/esm2015/src/event.js +0 -256
- package/esm2015/src/interface-registry.js +0 -41
- package/esm2015/src/key-generator.js +0 -108
- package/esm2015/src/local-query-comparison-options.js +0 -65
- package/esm2015/src/mapping-context.js +0 -411
- package/esm2015/src/naming-convention.js +0 -88
- package/esm2015/src/observable-array.js +0 -185
- package/esm2015/src/predicate.js +0 -1242
- package/esm2015/src/primitive-array.js +0 -87
- package/esm2015/src/query-options.js +0 -152
- package/esm2015/src/relation-array.js +0 -175
- package/esm2015/src/save-options.js +0 -41
- package/esm2015/src/unattached-children-map.js +0 -58
- package/esm2015/src/validate.js +0 -991
- package/esm2015/src/validation-options.js +0 -64
- package/esm5/adapter-ajax-angularjs/adapter-ajax-angularjs.js +0 -132
- package/esm5/adapter-ajax-angularjs/adapter-core.js +0 -49
- package/esm5/adapter-ajax-angularjs/breeze-client-adapter-ajax-angularjs.js +0 -5
- package/esm5/adapter-ajax-fetch/adapter-ajax-fetch.js +0 -132
- package/esm5/adapter-ajax-fetch/adapter-core.js +0 -49
- package/esm5/adapter-ajax-fetch/breeze-client-adapter-ajax-fetch.js +0 -5
- package/esm5/adapter-ajax-httpclient/adapter-ajax-httpclient.js +0 -139
- package/esm5/adapter-ajax-httpclient/adapter-core.js +0 -49
- package/esm5/adapter-ajax-httpclient/breeze-client-adapter-ajax-httpclient.js +0 -5
- package/esm5/adapter-ajax-jquery/adapter-ajax-jquery.js +0 -105
- package/esm5/adapter-ajax-jquery/breeze-client-adapter-ajax-jquery.js +0 -5
- package/esm5/adapter-ajax-post/adapter-ajax-post.js +0 -81
- package/esm5/adapter-ajax-post/breeze-client-adapter-ajax-post.js +0 -5
- package/esm5/adapter-data-service-odata/adapter-core.js +0 -49
- package/esm5/adapter-data-service-odata/breeze-client-adapter-data-service-odata.js +0 -5
- package/esm5/adapter-data-service-webapi/adapter-data-service-webapi.js +0 -105
- package/esm5/adapter-data-service-webapi/breeze-client-adapter-data-service-webapi.js +0 -5
- package/esm5/adapter-model-library-backing-store/adapter-model-library-backing-store.js +0 -270
- package/esm5/adapter-model-library-backing-store/breeze-client-adapter-model-library-backing-store.js +0 -5
- package/esm5/adapter-model-library-ko/adapter-model-library-ko.js +0 -242
- package/esm5/adapter-model-library-ko/breeze-client-adapter-model-library-ko.js +0 -5
- package/esm5/adapter-uri-builder-json/adapter-core.js +0 -49
- package/esm5/adapter-uri-builder-json/adapter-uri-builder-json.js +0 -38
- package/esm5/adapter-uri-builder-json/breeze-client-adapter-uri-builder-json.js +0 -5
- package/esm5/adapter-uri-builder-odata/adapter-core.js +0 -49
- package/esm5/adapter-uri-builder-odata/adapter-uri-builder-odata.js +0 -197
- package/esm5/adapter-uri-builder-odata/breeze-client-adapter-uri-builder-odata.js +0 -5
- package/esm5/breeze-client.js +0 -9
- package/esm5/index.js +0 -2
- package/esm5/mixin-get-entity-graph/breeze-client-mixin-get-entity-graph.js +0 -5
- package/esm5/mixin-get-entity-graph/mixin-get-entity-graph.js +0 -269
- package/esm5/mixin-save-queuing/breeze-client-mixin-save-queuing.js +0 -5
- package/esm5/mixin-save-queuing/mixin-save-queuing.js +0 -412
- package/esm5/src/abstract-data-service-adapter.js +0 -333
- package/esm5/src/array.js +0 -4
- package/esm5/src/assert-param.js +0 -317
- package/esm5/src/breeze.js +0 -85
- package/esm5/src/complex-array.js +0 -119
- package/esm5/src/config.js +0 -228
- package/esm5/src/core.js +0 -722
- package/esm5/src/csdl-metadata-parser.js +0 -385
- package/esm5/src/data-service.js +0 -207
- package/esm5/src/data-type.js +0 -513
- package/esm5/src/default-property-interceptor.js +0 -460
- package/esm5/src/entity-action.js +0 -52
- package/esm5/src/entity-aspect.js +0 -810
- package/esm5/src/entity-group.js +0 -189
- package/esm5/src/entity-key.js +0 -118
- package/esm5/src/entity-manager.js +0 -2112
- package/esm5/src/entity-metadata.js +0 -2144
- package/esm5/src/entity-query.js +0 -1042
- package/esm5/src/entity-state.js +0 -114
- package/esm5/src/enum.js +0 -144
- package/esm5/src/event.js +0 -259
- package/esm5/src/interface-registry.js +0 -43
- package/esm5/src/key-generator.js +0 -111
- package/esm5/src/local-query-comparison-options.js +0 -67
- package/esm5/src/mapping-context.js +0 -413
- package/esm5/src/naming-convention.js +0 -90
- package/esm5/src/observable-array.js +0 -201
- package/esm5/src/predicate.js +0 -1307
- package/esm5/src/primitive-array.js +0 -87
- package/esm5/src/query-options.js +0 -167
- package/esm5/src/relation-array.js +0 -175
- package/esm5/src/save-options.js +0 -43
- package/esm5/src/unattached-children-map.js +0 -60
- package/esm5/src/validate.js +0 -996
- package/esm5/src/validation-options.js +0 -66
- package/fesm2015/breeze-client-adapter-ajax-angularjs.js.map +0 -1
- package/fesm2015/breeze-client-adapter-ajax-fetch.js.map +0 -1
- package/fesm2015/breeze-client-adapter-ajax-httpclient.js.map +0 -1
- package/fesm2015/breeze-client-adapter-ajax-jquery.js.map +0 -1
- package/fesm2015/breeze-client-adapter-ajax-post.js.map +0 -1
- package/fesm2015/breeze-client-adapter-data-service-odata.js.map +0 -1
- package/fesm2015/breeze-client-adapter-data-service-webapi.js.map +0 -1
- package/fesm2015/breeze-client-adapter-model-library-backing-store.js.map +0 -1
- package/fesm2015/breeze-client-adapter-model-library-ko.js.map +0 -1
- package/fesm2015/breeze-client-adapter-uri-builder-json.js.map +0 -1
- package/fesm2015/breeze-client-adapter-uri-builder-odata.js.map +0 -1
- package/fesm2015/breeze-client-mixin-get-entity-graph.js.map +0 -1
- package/fesm2015/breeze-client-mixin-save-queuing.js.map +0 -1
- package/fesm2015/breeze-client.js.map +0 -1
- package/fesm5/breeze-client-adapter-ajax-angularjs.js +0 -186
- package/fesm5/breeze-client-adapter-ajax-angularjs.js.map +0 -1
- package/fesm5/breeze-client-adapter-ajax-fetch.js +0 -186
- package/fesm5/breeze-client-adapter-ajax-fetch.js.map +0 -1
- package/fesm5/breeze-client-adapter-ajax-httpclient.js +0 -193
- package/fesm5/breeze-client-adapter-ajax-httpclient.js.map +0 -1
- package/fesm5/breeze-client-adapter-ajax-jquery.js +0 -111
- package/fesm5/breeze-client-adapter-ajax-jquery.js.map +0 -1
- package/fesm5/breeze-client-adapter-ajax-post.js +0 -86
- package/fesm5/breeze-client-adapter-ajax-post.js.map +0 -1
- package/fesm5/breeze-client-adapter-data-service-odata.js +0 -523
- package/fesm5/breeze-client-adapter-data-service-odata.js.map +0 -1
- package/fesm5/breeze-client-adapter-data-service-webapi.js +0 -111
- package/fesm5/breeze-client-adapter-data-service-webapi.js.map +0 -1
- package/fesm5/breeze-client-adapter-model-library-backing-store.js +0 -276
- package/fesm5/breeze-client-adapter-model-library-backing-store.js.map +0 -1
- package/fesm5/breeze-client-adapter-model-library-ko.js +0 -248
- package/fesm5/breeze-client-adapter-model-library-ko.js.map +0 -1
- package/fesm5/breeze-client-adapter-uri-builder-json.js +0 -92
- package/fesm5/breeze-client-adapter-uri-builder-json.js.map +0 -1
- package/fesm5/breeze-client-adapter-uri-builder-odata.js +0 -250
- package/fesm5/breeze-client-adapter-uri-builder-odata.js.map +0 -1
- package/fesm5/breeze-client-mixin-get-entity-graph.js +0 -254
- package/fesm5/breeze-client-mixin-get-entity-graph.js.map +0 -1
- package/fesm5/breeze-client-mixin-save-queuing.js +0 -356
- package/fesm5/breeze-client-mixin-save-queuing.js.map +0 -1
- package/fesm5/breeze-client.js +0 -13956
- package/fesm5/breeze-client.js.map +0 -1
- package/mixin-get-entity-graph/breeze-client-mixin-get-entity-graph.metadata.json +0 -1
- package/mixin-get-entity-graph/package.json +0 -13
- package/mixin-save-queuing/breeze-client-mixin-save-queuing.metadata.json +0 -1
- package/mixin-save-queuing/package.json +0 -13
|
@@ -47,6 +47,8 @@ Note that we have Error['x'] = ... in some places in the code to prevent Terser
|
|
|
47
47
|
@dynamic
|
|
48
48
|
*/
|
|
49
49
|
class BreezeEnum {
|
|
50
|
+
/** @hidden @internal */
|
|
51
|
+
static _resolvedNamesAndSymbols;
|
|
50
52
|
/** */
|
|
51
53
|
constructor(propertiesObj) {
|
|
52
54
|
if (propertiesObj) {
|
|
@@ -142,15 +144,14 @@ class BreezeEnum {
|
|
|
142
144
|
/** See if this comment will make it into .d.ts */
|
|
143
145
|
let hasOwnProperty = uncurry(Object.prototype.hasOwnProperty);
|
|
144
146
|
let arraySlice = uncurry(Array.prototype.slice);
|
|
145
|
-
|
|
147
|
+
let isES5Supported = function () {
|
|
146
148
|
try {
|
|
147
149
|
return !!(Object.getPrototypeOf && Object.defineProperty({}, 'x', {}));
|
|
148
150
|
}
|
|
149
151
|
catch (e) {
|
|
150
152
|
return false;
|
|
151
153
|
}
|
|
152
|
-
};
|
|
153
|
-
let isES5Supported = ɵ0();
|
|
154
|
+
}();
|
|
154
155
|
// iterate over object
|
|
155
156
|
function objectForEach(obj, kvFn) {
|
|
156
157
|
for (let key in obj) {
|
|
@@ -731,7 +732,7 @@ function isNumeric(n) {
|
|
|
731
732
|
}
|
|
732
733
|
// end of is Functions
|
|
733
734
|
// string functions
|
|
734
|
-
function stringStartsWith(str, prefix) {
|
|
735
|
+
function stringStartsWith$1(str, prefix) {
|
|
735
736
|
// returns true for empty string or null prefix
|
|
736
737
|
if ((!str))
|
|
737
738
|
return false;
|
|
@@ -739,7 +740,7 @@ function stringStartsWith(str, prefix) {
|
|
|
739
740
|
return true;
|
|
740
741
|
return str.indexOf(prefix, 0) === 0;
|
|
741
742
|
}
|
|
742
|
-
function stringEndsWith(str, suffix) {
|
|
743
|
+
function stringEndsWith$1(str, suffix) {
|
|
743
744
|
// returns true for empty string or null suffix
|
|
744
745
|
if ((!str))
|
|
745
746
|
return false;
|
|
@@ -829,8 +830,8 @@ const core = {
|
|
|
829
830
|
isNumeric: isNumeric,
|
|
830
831
|
identity: identity,
|
|
831
832
|
noop: noop,
|
|
832
|
-
stringStartsWith: stringStartsWith,
|
|
833
|
-
stringEndsWith: stringEndsWith,
|
|
833
|
+
stringStartsWith: stringStartsWith$1,
|
|
834
|
+
stringEndsWith: stringEndsWith$1,
|
|
834
835
|
formatString: formatString,
|
|
835
836
|
titleCase: titleCaseSpace,
|
|
836
837
|
toJson: toJson,
|
|
@@ -853,19 +854,23 @@ function isPrimitive(obj: any) {
|
|
|
853
854
|
|
|
854
855
|
/** @hidden @internal */
|
|
855
856
|
class Param {
|
|
857
|
+
// The %1 parameter
|
|
858
|
+
// is required
|
|
859
|
+
// must be a %2
|
|
860
|
+
// must be an instance of %2
|
|
861
|
+
// must be an instance of the %2 enumeration
|
|
862
|
+
// must have a %2 property
|
|
863
|
+
// must be an array where each element
|
|
864
|
+
// is optional or
|
|
865
|
+
v;
|
|
866
|
+
name;
|
|
867
|
+
defaultValue;
|
|
868
|
+
parent;
|
|
869
|
+
/** @hidden @internal */
|
|
870
|
+
_context;
|
|
871
|
+
/** @hidden @internal */
|
|
872
|
+
_contexts;
|
|
856
873
|
constructor(v, name) {
|
|
857
|
-
/** @hidden @internal */
|
|
858
|
-
this._applyOne = function (instance) {
|
|
859
|
-
if (this.v !== undefined) {
|
|
860
|
-
instance[this.name] = this.v;
|
|
861
|
-
}
|
|
862
|
-
else {
|
|
863
|
-
if (this.defaultValue !== undefined) {
|
|
864
|
-
instance[this.name] = this.defaultValue;
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
};
|
|
868
|
-
this.MESSAGE_PREFIX = "The '%1' parameter ";
|
|
869
874
|
this.v = v;
|
|
870
875
|
this.name = name;
|
|
871
876
|
this._contexts = [null];
|
|
@@ -1011,6 +1016,18 @@ class Param {
|
|
|
1011
1016
|
}
|
|
1012
1017
|
}
|
|
1013
1018
|
}
|
|
1019
|
+
/** @hidden @internal */
|
|
1020
|
+
_applyOne = function (instance) {
|
|
1021
|
+
if (this.v !== undefined) {
|
|
1022
|
+
instance[this.name] = this.v;
|
|
1023
|
+
}
|
|
1024
|
+
else {
|
|
1025
|
+
if (this.defaultValue !== undefined) {
|
|
1026
|
+
instance[this.name] = this.defaultValue;
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
};
|
|
1030
|
+
MESSAGE_PREFIX = "The '%1' parameter ";
|
|
1014
1031
|
}
|
|
1015
1032
|
/** @hidden @internal */
|
|
1016
1033
|
let assertParam = function (v, name) {
|
|
@@ -1139,6 +1156,8 @@ function throwConfigError(instance, message) {
|
|
|
1139
1156
|
throw new Error(core.formatString("Error configuring an instance of '%1'. %2", (instance && instance._$typeName) || "object", message));
|
|
1140
1157
|
}
|
|
1141
1158
|
class ConfigParam {
|
|
1159
|
+
config;
|
|
1160
|
+
params;
|
|
1142
1161
|
constructor(config) {
|
|
1143
1162
|
if (typeof (config) !== "object") {
|
|
1144
1163
|
throw new Error("Configuration parameter should be an object, instead it is a: " + typeof (config));
|
|
@@ -1194,6 +1213,18 @@ Class to support basic event publication and subscription semantics.
|
|
|
1194
1213
|
@dynamic
|
|
1195
1214
|
**/
|
|
1196
1215
|
class BreezeEvent {
|
|
1216
|
+
/** @hidden @internal */
|
|
1217
|
+
static __eventNameMap = {};
|
|
1218
|
+
/** @hidden @internal */
|
|
1219
|
+
static __nextUnsubKey = 1;
|
|
1220
|
+
/** The name of this Event */
|
|
1221
|
+
name;
|
|
1222
|
+
/** The object doing the publication. i.e. the object to which this event is attached. */
|
|
1223
|
+
publisher;
|
|
1224
|
+
/** @hidden @internal */
|
|
1225
|
+
_subscribers;
|
|
1226
|
+
/** @hidden @internal */
|
|
1227
|
+
_defaultErrorCallback;
|
|
1197
1228
|
/**
|
|
1198
1229
|
Constructor for an Event
|
|
1199
1230
|
> salaryEvent = new BreezeEvent("salaryEvent", person);
|
|
@@ -1203,36 +1234,6 @@ class BreezeEvent {
|
|
|
1203
1234
|
If omitted then subscriber notification failures will be ignored.
|
|
1204
1235
|
**/
|
|
1205
1236
|
constructor(name, publisher, defaultErrorCallback) {
|
|
1206
|
-
/**
|
|
1207
|
-
Unsubscribe from this event.
|
|
1208
|
-
> // Assume order is a preexisting 'order' entity
|
|
1209
|
-
> let token = order.entityAspect.propertyChanged.subscribe(function (pcEvent) {
|
|
1210
|
-
> // do something
|
|
1211
|
-
> });
|
|
1212
|
-
> // sometime later
|
|
1213
|
-
> order.entityAspect.propertyChanged.unsubscribe(token);
|
|
1214
|
-
@param unsubKey - The value returned from the 'subscribe' method may be used to unsubscribe here.
|
|
1215
|
-
@return Whether unsubscription occured. This will return false if already unsubscribed or if the key simply
|
|
1216
|
-
cannot be found.
|
|
1217
|
-
**/
|
|
1218
|
-
this.unsubscribe = function (unsubKey) {
|
|
1219
|
-
if (!this._subscribers)
|
|
1220
|
-
return false;
|
|
1221
|
-
let subs = this._subscribers;
|
|
1222
|
-
let ix = core.arrayIndexOf(subs, function (s) {
|
|
1223
|
-
return s.unsubKey === unsubKey;
|
|
1224
|
-
});
|
|
1225
|
-
if (ix !== -1) {
|
|
1226
|
-
subs.splice(ix, 1);
|
|
1227
|
-
if (subs.length === 0) {
|
|
1228
|
-
this._subscribers = null;
|
|
1229
|
-
}
|
|
1230
|
-
return true;
|
|
1231
|
-
}
|
|
1232
|
-
else {
|
|
1233
|
-
return false;
|
|
1234
|
-
}
|
|
1235
|
-
};
|
|
1236
1237
|
assertParam(name, "eventName").isNonEmptyString().check();
|
|
1237
1238
|
assertParam(publisher, "publisher").isObject().check();
|
|
1238
1239
|
this.name = name;
|
|
@@ -1317,6 +1318,36 @@ class BreezeEvent {
|
|
|
1317
1318
|
++BreezeEvent.__nextUnsubKey;
|
|
1318
1319
|
return unsubKey;
|
|
1319
1320
|
}
|
|
1321
|
+
/**
|
|
1322
|
+
Unsubscribe from this event.
|
|
1323
|
+
> // Assume order is a preexisting 'order' entity
|
|
1324
|
+
> let token = order.entityAspect.propertyChanged.subscribe(function (pcEvent) {
|
|
1325
|
+
> // do something
|
|
1326
|
+
> });
|
|
1327
|
+
> // sometime later
|
|
1328
|
+
> order.entityAspect.propertyChanged.unsubscribe(token);
|
|
1329
|
+
@param unsubKey - The value returned from the 'subscribe' method may be used to unsubscribe here.
|
|
1330
|
+
@return Whether unsubscription occured. This will return false if already unsubscribed or if the key simply
|
|
1331
|
+
cannot be found.
|
|
1332
|
+
**/
|
|
1333
|
+
unsubscribe = function (unsubKey) {
|
|
1334
|
+
if (!this._subscribers)
|
|
1335
|
+
return false;
|
|
1336
|
+
let subs = this._subscribers;
|
|
1337
|
+
let ix = core.arrayIndexOf(subs, function (s) {
|
|
1338
|
+
return s.unsubKey === unsubKey;
|
|
1339
|
+
});
|
|
1340
|
+
if (ix !== -1) {
|
|
1341
|
+
subs.splice(ix, 1);
|
|
1342
|
+
if (subs.length === 0) {
|
|
1343
|
+
this._subscribers = null;
|
|
1344
|
+
}
|
|
1345
|
+
return true;
|
|
1346
|
+
}
|
|
1347
|
+
else {
|
|
1348
|
+
return false;
|
|
1349
|
+
}
|
|
1350
|
+
};
|
|
1320
1351
|
/** remove all subscribers */
|
|
1321
1352
|
clear() {
|
|
1322
1353
|
this._subscribers = null;
|
|
@@ -1381,42 +1412,42 @@ class BreezeEvent {
|
|
|
1381
1412
|
// return ctor._isEnabled(getFullEventName(eventName), obj);
|
|
1382
1413
|
return BreezeEvent._isEnabled(eventName, 3);
|
|
1383
1414
|
}
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
let isEnabled = null;
|
|
1392
|
-
let ob = obj;
|
|
1393
|
-
let eventMap = ob._$eventMap;
|
|
1394
|
-
if (eventMap) {
|
|
1395
|
-
isEnabled = eventMap[eventName];
|
|
1396
|
-
}
|
|
1397
|
-
if (isEnabled != null) {
|
|
1398
|
-
if (typeof isEnabled === 'function') {
|
|
1399
|
-
return !!isEnabled(obj);
|
|
1400
|
-
}
|
|
1401
|
-
else {
|
|
1402
|
-
return !!isEnabled;
|
|
1415
|
+
/** @hidden @internal */
|
|
1416
|
+
static _isEnabled = function (eventName, obj) {
|
|
1417
|
+
let isEnabled = null;
|
|
1418
|
+
let ob = obj;
|
|
1419
|
+
let eventMap = ob._$eventMap;
|
|
1420
|
+
if (eventMap) {
|
|
1421
|
+
isEnabled = eventMap[eventName];
|
|
1403
1422
|
}
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1423
|
+
if (isEnabled != null) {
|
|
1424
|
+
if (typeof isEnabled === 'function') {
|
|
1425
|
+
return !!isEnabled(obj);
|
|
1426
|
+
}
|
|
1427
|
+
else {
|
|
1428
|
+
return !!isEnabled;
|
|
1429
|
+
}
|
|
1409
1430
|
}
|
|
1410
1431
|
else {
|
|
1411
|
-
|
|
1412
|
-
|
|
1432
|
+
let parent = ob._getEventParent && ob._getEventParent();
|
|
1433
|
+
if (parent) {
|
|
1434
|
+
return !!this._isEnabled(eventName, parent);
|
|
1435
|
+
}
|
|
1436
|
+
else {
|
|
1437
|
+
// default if not explicitly disabled.
|
|
1438
|
+
return true;
|
|
1439
|
+
}
|
|
1413
1440
|
}
|
|
1414
|
-
}
|
|
1415
|
-
}
|
|
1441
|
+
};
|
|
1442
|
+
}
|
|
1416
1443
|
// legacy support - deliberately not typed
|
|
1417
1444
|
core.Event = BreezeEvent;
|
|
1418
1445
|
|
|
1419
1446
|
class InterfaceDef {
|
|
1447
|
+
name;
|
|
1448
|
+
defaultInstance;
|
|
1449
|
+
/** @hidden @internal */
|
|
1450
|
+
_implMap;
|
|
1420
1451
|
constructor(name) {
|
|
1421
1452
|
this.name = name;
|
|
1422
1453
|
this.defaultInstance = undefined;
|
|
@@ -1442,18 +1473,23 @@ class InterfaceDef {
|
|
|
1442
1473
|
}
|
|
1443
1474
|
}
|
|
1444
1475
|
class BreezeConfig {
|
|
1476
|
+
functionRegistry = {};
|
|
1477
|
+
typeRegistry = {};
|
|
1478
|
+
objectRegistry = {};
|
|
1479
|
+
interfaceInitialized;
|
|
1480
|
+
stringifyPad = '';
|
|
1481
|
+
/** whether to prohibit eval() and Function() in breeze code */
|
|
1482
|
+
noEval;
|
|
1483
|
+
/** @hidden @internal */
|
|
1484
|
+
_interfaceRegistry; // will be set in adapter-interfaces. untyped here to avoid circularity issues.
|
|
1445
1485
|
constructor() {
|
|
1446
|
-
this.functionRegistry = {};
|
|
1447
|
-
this.typeRegistry = {};
|
|
1448
|
-
this.objectRegistry = {};
|
|
1449
|
-
this.stringifyPad = '';
|
|
1450
1486
|
this.interfaceInitialized = new BreezeEvent("interfaceInitialized", this);
|
|
1451
1487
|
if (this.noEval === undefined) {
|
|
1452
1488
|
try {
|
|
1453
1489
|
Error['x'] = Function('');
|
|
1454
1490
|
this.noEval = false; // eval succeeded
|
|
1455
1491
|
}
|
|
1456
|
-
catch
|
|
1492
|
+
catch {
|
|
1457
1493
|
this.noEval = true; // eval failed, probably due to CSP
|
|
1458
1494
|
}
|
|
1459
1495
|
}
|
|
@@ -1668,7 +1704,7 @@ class DataService {
|
|
|
1668
1704
|
@param config - A configuration object.
|
|
1669
1705
|
**/
|
|
1670
1706
|
constructor(config) {
|
|
1671
|
-
updateWithConfig(this, config);
|
|
1707
|
+
updateWithConfig$1(this, config);
|
|
1672
1708
|
}
|
|
1673
1709
|
/**
|
|
1674
1710
|
Returns a copy of this DataService with the specified properties applied.
|
|
@@ -1678,7 +1714,7 @@ class DataService {
|
|
|
1678
1714
|
if (!config)
|
|
1679
1715
|
return this;
|
|
1680
1716
|
let result = new DataService(this);
|
|
1681
|
-
return updateWithConfig(result, config);
|
|
1717
|
+
return updateWithConfig$1(result, config);
|
|
1682
1718
|
}
|
|
1683
1719
|
static resolve(dataServices) {
|
|
1684
1720
|
// final defaults
|
|
@@ -1749,7 +1785,7 @@ class DataService {
|
|
|
1749
1785
|
}
|
|
1750
1786
|
}
|
|
1751
1787
|
DataService.prototype._$typeName = "DataService";
|
|
1752
|
-
function updateWithConfig(obj, dsConfig) {
|
|
1788
|
+
function updateWithConfig$1(obj, dsConfig) {
|
|
1753
1789
|
if (dsConfig) {
|
|
1754
1790
|
assertConfig(dsConfig)
|
|
1755
1791
|
.whereParam("serviceName").isOptional()
|
|
@@ -1770,6 +1806,24 @@ A JsonResultsAdapter instance is used to provide custom extraction and parsing l
|
|
|
1770
1806
|
This facility makes it possible for breeze to talk to virtually any web service and return objects that will be first class 'breeze' citizens.
|
|
1771
1807
|
**/
|
|
1772
1808
|
class JsonResultsAdapter {
|
|
1809
|
+
/** @hidden @internal */
|
|
1810
|
+
_$typeName; // actually put on prototype.
|
|
1811
|
+
/** The name of this adapter. This name is used to uniquely identify and locate this instance when an 'exported' JsonResultsAdapter is later imported. */
|
|
1812
|
+
name;
|
|
1813
|
+
/** A Function that is called once per query operation to extract the 'payload' from any json received over the wire.
|
|
1814
|
+
This method has a default implementation which simply returns the "results" property from any json returned as a result of executing the query. */
|
|
1815
|
+
extractResults; // TODO - refine
|
|
1816
|
+
/** A function that is called once per save operation to extract the entities from any json received over the wire. Must return an array.
|
|
1817
|
+
This method has a default implementation which simply returns the "entities" property from any json returned as a result of executing the save. */
|
|
1818
|
+
extractSaveResults;
|
|
1819
|
+
/** A function that is called once per save operation to extract the key mappings from any json received over the wire. Must return an array.
|
|
1820
|
+
This method has a default implementation which simply returns the "keyMappings" property from any json returned as a result of executing the save. */
|
|
1821
|
+
extractKeyMappings;
|
|
1822
|
+
/** A function that is called once per save operation to extract any deleted keys from any json received over the wire. Must return an array.
|
|
1823
|
+
This method has a default implementation which is to simply returns the "deletedKeys" property from any json returned as a result of executing the save. */
|
|
1824
|
+
extractDeletedKeys; // TODO: refine
|
|
1825
|
+
/** A visitor method that will be called on each node of the returned payload. */
|
|
1826
|
+
visitNode;
|
|
1773
1827
|
/**
|
|
1774
1828
|
JsonResultsAdapter constructor
|
|
1775
1829
|
|
|
@@ -1842,17 +1896,16 @@ const INT32_MIN = -2147483648;
|
|
|
1842
1896
|
const INT32_MAX = 2147483647;
|
|
1843
1897
|
const BYTE_MIN = 0;
|
|
1844
1898
|
const BYTE_MAX = 255;
|
|
1845
|
-
const ɵ0$1 = function (context) {
|
|
1846
|
-
if (context.property) {
|
|
1847
|
-
return context.property.resolveProperty("displayName") || context.propertyName || context.property.name;
|
|
1848
|
-
}
|
|
1849
|
-
else {
|
|
1850
|
-
return "Value";
|
|
1851
|
-
}
|
|
1852
|
-
};
|
|
1853
1899
|
// add common props and methods for every validator 'context' here.
|
|
1854
1900
|
let rootContext = {
|
|
1855
|
-
displayName:
|
|
1901
|
+
displayName: function (context) {
|
|
1902
|
+
if (context.property) {
|
|
1903
|
+
return context.property.resolveProperty("displayName") || context.propertyName || context.property.name;
|
|
1904
|
+
}
|
|
1905
|
+
else {
|
|
1906
|
+
return "Value";
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1856
1909
|
};
|
|
1857
1910
|
/**
|
|
1858
1911
|
Instances of the Validator class provide the logic to validate another object and provide a description of any errors
|
|
@@ -2138,491 +2191,491 @@ class Validator {
|
|
|
2138
2191
|
static registerFactory(validatorFactory, name) {
|
|
2139
2192
|
config.registerFunction(validatorFactory, "Validator." + name);
|
|
2140
2193
|
}
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2194
|
+
/**
|
|
2195
|
+
Map of standard error message templates keyed by validator name.
|
|
2196
|
+
You can add to or modify this object to customize the template used for any validation error message.
|
|
2197
|
+
@example
|
|
2198
|
+
// v is this function is the value to be validated, in this case a "country" string.
|
|
2199
|
+
var valFn = function (v) {
|
|
2200
|
+
if (v == null) return true;
|
|
2201
|
+
return (core.stringStartsWith(v, "US"));
|
|
2202
|
+
};
|
|
2203
|
+
var countryValidator = new Validator("countryIsUS", valFn, { displayName: "Country" });
|
|
2204
|
+
Validator.messageTemplates.countryIsUS = "'%displayName%' must start with 'US'";
|
|
2205
|
+
// This will have a similar effect to this
|
|
2206
|
+
var countryValidator = new Validator("countryIsUS", valFn, {
|
|
2207
|
+
displayName: "Country",
|
|
2208
|
+
messageTemplate: "'%displayName%' must start with 'US'"
|
|
2209
|
+
});
|
|
2210
|
+
@property messageTemplates {Object}
|
|
2211
|
+
@static
|
|
2212
|
+
**/
|
|
2213
|
+
static messageTemplates = {
|
|
2214
|
+
bool: "'%displayName%' must be a 'true' or 'false' value",
|
|
2215
|
+
creditCard: "The %displayName% is not a valid credit card number",
|
|
2216
|
+
date: "'%displayName%' must be a date",
|
|
2217
|
+
duration: "'%displayName%' must be a ISO8601 duration string, such as 'P3H24M60S'",
|
|
2218
|
+
emailAddress: "The %displayName% '%value%' is not a valid email address",
|
|
2219
|
+
guid: "'%displayName%' must be a GUID",
|
|
2220
|
+
integer: "'%displayName%' must be an integer",
|
|
2221
|
+
integerRange: "'%displayName%' must be an integer between the values of %minValue% and %maxValue%",
|
|
2222
|
+
maxLength: "'%displayName%' must be a string with %maxLength% characters or less",
|
|
2223
|
+
number: "'%displayName%' must be a number",
|
|
2224
|
+
phone: "The %displayName% '%value%' is not a valid phone number",
|
|
2225
|
+
regularExpression: "The %displayName% '%value%' does not match '%expression%'",
|
|
2226
|
+
required: "'%displayName%' is required",
|
|
2227
|
+
string: "'%displayName%' must be a string",
|
|
2228
|
+
stringLength: "'%displayName%' must be a string with between %minLength% and %maxLength% characters",
|
|
2229
|
+
url: "The %displayName% '%value%' is not a valid url"
|
|
2150
2230
|
};
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
@
|
|
2190
|
-
@
|
|
2191
|
-
@param context {
|
|
2192
|
-
@
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
if (typeof v === "string") {
|
|
2198
|
-
if (ctx && ctx.allowEmptyStrings)
|
|
2231
|
+
/**
|
|
2232
|
+
Returns a standard 'required value' Validator
|
|
2233
|
+
@example
|
|
2234
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2235
|
+
var custType = em1.metadataStore.getEntityType("Customer");
|
|
2236
|
+
var regionProperty - custType.getProperty("Region");
|
|
2237
|
+
// Makes "Region" on Customer a required property.
|
|
2238
|
+
regionProperty.validators.push(Validator.required());
|
|
2239
|
+
// or to allow empty strings
|
|
2240
|
+
regionProperty.validators.push(Validator.required({ allowEmptyStrings: true }););
|
|
2241
|
+
@method required
|
|
2242
|
+
@static
|
|
2243
|
+
@param context {Object}
|
|
2244
|
+
@param [context.allowEmptyStrings] {Boolean} If this parameter is omitted or false then empty strings do NOT pass validation.
|
|
2245
|
+
@return {Validator} A new Validator
|
|
2246
|
+
**/
|
|
2247
|
+
static required = function (context) {
|
|
2248
|
+
let valFn = function (v, ctx) {
|
|
2249
|
+
if (typeof v === "string") {
|
|
2250
|
+
if (ctx && ctx.allowEmptyStrings)
|
|
2251
|
+
return true;
|
|
2252
|
+
return v.length > 0;
|
|
2253
|
+
}
|
|
2254
|
+
else {
|
|
2255
|
+
return v != null;
|
|
2256
|
+
}
|
|
2257
|
+
};
|
|
2258
|
+
return new Validator("required", valFn, context);
|
|
2259
|
+
};
|
|
2260
|
+
/**
|
|
2261
|
+
Returns a standard maximum string length Validator; the maximum length must be specified
|
|
2262
|
+
@example
|
|
2263
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2264
|
+
var custType = em1.metadataStore.getEntityType("Customer");
|
|
2265
|
+
var regionProperty - custType.getProperty("Region");
|
|
2266
|
+
// Validates that the value of the Region property on Customer will be less than or equal to 5 characters.
|
|
2267
|
+
regionProperty.validators.push(Validator.maxLength( {maxLength: 5}));
|
|
2268
|
+
@method maxLength
|
|
2269
|
+
@static
|
|
2270
|
+
@param context {Object}
|
|
2271
|
+
@param context.maxLength {Integer}
|
|
2272
|
+
@return {Validator} A new Validator
|
|
2273
|
+
**/
|
|
2274
|
+
static maxLength = function (context) {
|
|
2275
|
+
let valFn = function (v, ctx) {
|
|
2276
|
+
if (v == null)
|
|
2199
2277
|
return true;
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2278
|
+
if (typeof (v) !== "string")
|
|
2279
|
+
return false;
|
|
2280
|
+
return v.length <= ctx.maxLength;
|
|
2281
|
+
};
|
|
2282
|
+
return new Validator("maxLength", valFn, context);
|
|
2205
2283
|
};
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
@
|
|
2217
|
-
@
|
|
2218
|
-
@param context {
|
|
2219
|
-
@param context.
|
|
2220
|
-
@return {Validator} A new Validator
|
|
2221
|
-
**/
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2284
|
+
/**
|
|
2285
|
+
Returns a standard string length Validator; both minimum and maximum lengths must be specified.
|
|
2286
|
+
@example
|
|
2287
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2288
|
+
var custType = em1.metadataStore.getEntityType("Customer");
|
|
2289
|
+
var regionProperty - custType.getProperty("Region");
|
|
2290
|
+
// Validates that the value of the Region property on Customer will be
|
|
2291
|
+
// between 2 and 5 characters
|
|
2292
|
+
regionProperty.validators.push(Validator.stringLength( {minLength: 2, maxLength: 5});
|
|
2293
|
+
@method stringLength
|
|
2294
|
+
@static
|
|
2295
|
+
@param context {Object}
|
|
2296
|
+
@param context.maxLength {Integer}
|
|
2297
|
+
@param context.minLength {Integer}
|
|
2298
|
+
@return {Validator} A new Validator
|
|
2299
|
+
**/
|
|
2300
|
+
static stringLength = function (context) {
|
|
2301
|
+
let valFn = function (v, ctx) {
|
|
2302
|
+
if (v == null)
|
|
2303
|
+
return true;
|
|
2304
|
+
if (typeof (v) !== "string")
|
|
2305
|
+
return false;
|
|
2306
|
+
if (ctx.minLength != null && v.length < ctx.minLength)
|
|
2307
|
+
return false;
|
|
2308
|
+
if (ctx.maxLength != null && v.length > ctx.maxLength)
|
|
2309
|
+
return false;
|
|
2225
2310
|
return true;
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
return v.length <= ctx.maxLength;
|
|
2311
|
+
};
|
|
2312
|
+
return new Validator("stringLength", valFn, context);
|
|
2229
2313
|
};
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
let valFn = function (v, ctx) {
|
|
2250
|
-
if (v == null)
|
|
2251
|
-
return true;
|
|
2252
|
-
if (typeof (v) !== "string")
|
|
2253
|
-
return false;
|
|
2254
|
-
if (ctx.minLength != null && v.length < ctx.minLength)
|
|
2255
|
-
return false;
|
|
2256
|
-
if (ctx.maxLength != null && v.length > ctx.maxLength)
|
|
2257
|
-
return false;
|
|
2258
|
-
return true;
|
|
2314
|
+
/**
|
|
2315
|
+
Returns a standard string dataType Validator.
|
|
2316
|
+
@example
|
|
2317
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2318
|
+
var custType = em1.metadataStore.getEntityType("Customer");
|
|
2319
|
+
var regionProperty - custType.getProperty("Region");
|
|
2320
|
+
// Validates that the value of the Region property on Customer is a string.
|
|
2321
|
+
regionProperty.validators.push(Validator.string());
|
|
2322
|
+
@method string
|
|
2323
|
+
@static
|
|
2324
|
+
@return {Validator} A new Validator
|
|
2325
|
+
**/
|
|
2326
|
+
static string = function () {
|
|
2327
|
+
let valFn = function (v) {
|
|
2328
|
+
if (v == null)
|
|
2329
|
+
return true;
|
|
2330
|
+
return (typeof v === "string");
|
|
2331
|
+
};
|
|
2332
|
+
return new Validator("string", valFn);
|
|
2259
2333
|
};
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
@
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
return (
|
|
2334
|
+
/**
|
|
2335
|
+
Returns a Guid data type Validator.
|
|
2336
|
+
@example
|
|
2337
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2338
|
+
var custType = em1.metadataStore.getEntityType("Customer");
|
|
2339
|
+
var customerIdProperty - custType.getProperty("CustomerID");
|
|
2340
|
+
// Validates that the value of the CustomerID property on Customer is a Guid.
|
|
2341
|
+
customerIdProperty.validators.push(Validator.guid());
|
|
2342
|
+
@method guid
|
|
2343
|
+
@static
|
|
2344
|
+
@return {Validator} A new Validator
|
|
2345
|
+
**/
|
|
2346
|
+
static guid = function () {
|
|
2347
|
+
let valFn = function (v) {
|
|
2348
|
+
if (v == null)
|
|
2349
|
+
return true;
|
|
2350
|
+
return core.isGuid(v);
|
|
2351
|
+
};
|
|
2352
|
+
return new Validator("guid", valFn);
|
|
2279
2353
|
};
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
@
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
return
|
|
2354
|
+
/**
|
|
2355
|
+
Returns a ISO 8601 duration string Validator.
|
|
2356
|
+
@example
|
|
2357
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2358
|
+
var eventType = em1.metadataStore.getEntityType("Event");
|
|
2359
|
+
var elapsedTimeProperty - eventType.getProperty("ElapsedTime");
|
|
2360
|
+
// Validates that the value of the ElapsedTime property on Customer is a duration.
|
|
2361
|
+
elapsedTimeProperty.validators.push(Validator.duration());
|
|
2362
|
+
@method duration
|
|
2363
|
+
@static
|
|
2364
|
+
@return {Validator} A new Validator
|
|
2365
|
+
**/
|
|
2366
|
+
static duration = function () {
|
|
2367
|
+
let valFn = function (v) {
|
|
2368
|
+
if (v == null)
|
|
2369
|
+
return true;
|
|
2370
|
+
return core.isDuration(v);
|
|
2371
|
+
};
|
|
2372
|
+
return new Validator("duration", valFn);
|
|
2299
2373
|
};
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
@
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2374
|
+
/**
|
|
2375
|
+
Returns a standard numeric data type Validator.
|
|
2376
|
+
@example
|
|
2377
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2378
|
+
var orderType = em1.metadataStore.getEntityType("Order");
|
|
2379
|
+
var freightProperty - orderType.getProperty("Freight");
|
|
2380
|
+
// Validates that the value of the Freight property on Order is a number.
|
|
2381
|
+
freightProperty.validators.push(Validator.number());
|
|
2382
|
+
@method number
|
|
2383
|
+
@static
|
|
2384
|
+
@return {Validator} A new Validator
|
|
2385
|
+
**/
|
|
2386
|
+
// TODO: may need to have seperate logic for single.
|
|
2387
|
+
static number = function (context) {
|
|
2388
|
+
let valFn = function (v, ctx) {
|
|
2389
|
+
if (v == null)
|
|
2390
|
+
return true;
|
|
2391
|
+
if (typeof v === "string" && ctx && ctx.allowString) {
|
|
2392
|
+
v = parseFloat(v);
|
|
2393
|
+
}
|
|
2394
|
+
return (typeof v === "number" && !isNaN(v));
|
|
2395
|
+
};
|
|
2396
|
+
return new Validator("number", valFn, context);
|
|
2319
2397
|
};
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
/**
|
|
2323
|
-
Returns a standard
|
|
2324
|
-
@example
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
@method
|
|
2331
|
-
@static
|
|
2332
|
-
@return {Validator} A new Validator
|
|
2333
|
-
**/
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2398
|
+
static double = Validator.number;
|
|
2399
|
+
static single = Validator.number;
|
|
2400
|
+
/**
|
|
2401
|
+
Returns a standard large integer data type - 64 bit - Validator.
|
|
2402
|
+
@example
|
|
2403
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2404
|
+
var orderType = em1.metadataStore.getEntityType("Order");
|
|
2405
|
+
var freightProperty - orderType.getProperty("Freight");
|
|
2406
|
+
// Validates that the value of the Freight property on Order is within the range of a 64 bit integer.
|
|
2407
|
+
freightProperty.validators.push(Validator.int64());
|
|
2408
|
+
@method int64
|
|
2409
|
+
@static
|
|
2410
|
+
@return {Validator} A new Validator
|
|
2411
|
+
**/
|
|
2412
|
+
static integer = function (context) {
|
|
2413
|
+
let valFn = function (v, ctx) {
|
|
2414
|
+
if (v == null)
|
|
2415
|
+
return true;
|
|
2416
|
+
if (typeof v === "string" && ctx && ctx.allowString) {
|
|
2417
|
+
v = parseInt(v, 10);
|
|
2418
|
+
}
|
|
2419
|
+
return (typeof v === "number") && (!isNaN(v)) && Math.floor(v) === v;
|
|
2420
|
+
};
|
|
2421
|
+
return new Validator("integer", valFn, context);
|
|
2343
2422
|
};
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
@return {Validator} A new Validator
|
|
2359
|
-
**/
|
|
2360
|
-
Validator.integer = function (context) {
|
|
2361
|
-
let valFn = function (v, ctx) {
|
|
2362
|
-
if (v == null)
|
|
2363
|
-
return true;
|
|
2364
|
-
if (typeof v === "string" && ctx && ctx.allowString) {
|
|
2365
|
-
v = parseInt(v, 10);
|
|
2366
|
-
}
|
|
2367
|
-
return (typeof v === "number") && (!isNaN(v)) && Math.floor(v) === v;
|
|
2423
|
+
static int64 = Validator.integer;
|
|
2424
|
+
/**
|
|
2425
|
+
Returns a standard 32 bit integer data type Validator.
|
|
2426
|
+
@example
|
|
2427
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2428
|
+
var orderType = em1.metadataStore.getEntityType("Order");
|
|
2429
|
+
var freightProperty - orderType.getProperty("Freight");
|
|
2430
|
+
freightProperty.validators.push(Validator.int32());
|
|
2431
|
+
@method int32
|
|
2432
|
+
@static
|
|
2433
|
+
@return {Validator} A new Validator
|
|
2434
|
+
**/
|
|
2435
|
+
static int32 = function (context) {
|
|
2436
|
+
return intRangeValidatorCtor("int32", INT32_MIN, INT32_MAX, context)();
|
|
2368
2437
|
};
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
@
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
Validator.int32 = function (context) {
|
|
2384
|
-
return intRangeValidatorCtor("int32", INT32_MIN, INT32_MAX, context)();
|
|
2385
|
-
};
|
|
2386
|
-
/**
|
|
2387
|
-
Returns a standard 16 bit integer data type Validator.
|
|
2388
|
-
@example
|
|
2389
|
-
// Assume em1 is a preexisting EntityManager.
|
|
2390
|
-
var orderType = em1.metadataStore.getEntityType("Order");
|
|
2391
|
-
var freightProperty - orderType.getProperty("Freight");
|
|
2392
|
-
// Validates that the value of the Freight property on Order is within the range of a 16 bit integer.
|
|
2393
|
-
freightProperty.validators.push(Validator.int16());
|
|
2394
|
-
@method int16
|
|
2395
|
-
@static
|
|
2396
|
-
@return {Validator} A new Validator
|
|
2397
|
-
**/
|
|
2398
|
-
Validator.int16 = function (context) {
|
|
2399
|
-
return intRangeValidatorCtor("int16", INT16_MIN, INT16_MAX, context)();
|
|
2400
|
-
};
|
|
2401
|
-
/**
|
|
2402
|
-
Returns a standard byte data type Validator. (This is a integer between 0 and 255 inclusive for js purposes).
|
|
2403
|
-
@example
|
|
2404
|
-
// Assume em1 is a preexisting EntityManager.
|
|
2405
|
-
var orderType = em1.metadataStore.getEntityType("Order");
|
|
2406
|
-
var freightProperty - orderType.getProperty("Freight");
|
|
2407
|
-
// Validates that the value of the Freight property on Order is within the range of a 16 bit integer.
|
|
2408
|
-
// Probably not a very good validation to place on the Freight property.
|
|
2409
|
-
regionProperty.validators.push(Validator.byte());
|
|
2410
|
-
@method byte
|
|
2411
|
-
@static
|
|
2412
|
-
@return {Validator} A new Validator
|
|
2413
|
-
**/
|
|
2414
|
-
Validator.byte = function (context) {
|
|
2415
|
-
return intRangeValidatorCtor("byte", BYTE_MIN, BYTE_MAX, context)();
|
|
2416
|
-
};
|
|
2417
|
-
/**
|
|
2418
|
-
Returns a standard boolean data type Validator.
|
|
2419
|
-
@example
|
|
2420
|
-
// Assume em1 is a preexisting EntityManager.
|
|
2421
|
-
var productType = em1.metadataStore.getEntityType("Product");
|
|
2422
|
-
var discontinuedProperty - productType.getProperty("Discontinued");
|
|
2423
|
-
// Validates that the value of the Discontinued property on Product is a boolean
|
|
2424
|
-
discontinuedProperty.validators.push(Validator.bool());
|
|
2425
|
-
@method bool
|
|
2426
|
-
@static
|
|
2427
|
-
@return {Validator} A new Validator
|
|
2428
|
-
**/
|
|
2429
|
-
Validator.bool = function () {
|
|
2430
|
-
let valFn = function (v) {
|
|
2431
|
-
if (v == null)
|
|
2432
|
-
return true;
|
|
2433
|
-
return (v === true) || (v === false);
|
|
2438
|
+
/**
|
|
2439
|
+
Returns a standard 16 bit integer data type Validator.
|
|
2440
|
+
@example
|
|
2441
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2442
|
+
var orderType = em1.metadataStore.getEntityType("Order");
|
|
2443
|
+
var freightProperty - orderType.getProperty("Freight");
|
|
2444
|
+
// Validates that the value of the Freight property on Order is within the range of a 16 bit integer.
|
|
2445
|
+
freightProperty.validators.push(Validator.int16());
|
|
2446
|
+
@method int16
|
|
2447
|
+
@static
|
|
2448
|
+
@return {Validator} A new Validator
|
|
2449
|
+
**/
|
|
2450
|
+
static int16 = function (context) {
|
|
2451
|
+
return intRangeValidatorCtor("int16", INT16_MIN, INT16_MAX, context)();
|
|
2434
2452
|
};
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2453
|
+
/**
|
|
2454
|
+
Returns a standard byte data type Validator. (This is a integer between 0 and 255 inclusive for js purposes).
|
|
2455
|
+
@example
|
|
2456
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2457
|
+
var orderType = em1.metadataStore.getEntityType("Order");
|
|
2458
|
+
var freightProperty - orderType.getProperty("Freight");
|
|
2459
|
+
// Validates that the value of the Freight property on Order is within the range of a 16 bit integer.
|
|
2460
|
+
// Probably not a very good validation to place on the Freight property.
|
|
2461
|
+
regionProperty.validators.push(Validator.byte());
|
|
2462
|
+
@method byte
|
|
2463
|
+
@static
|
|
2464
|
+
@return {Validator} A new Validator
|
|
2465
|
+
**/
|
|
2466
|
+
static byte = function (context) {
|
|
2467
|
+
return intRangeValidatorCtor("byte", BYTE_MIN, BYTE_MAX, context)();
|
|
2440
2468
|
};
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2469
|
+
/**
|
|
2470
|
+
Returns a standard boolean data type Validator.
|
|
2471
|
+
@example
|
|
2472
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2473
|
+
var productType = em1.metadataStore.getEntityType("Product");
|
|
2474
|
+
var discontinuedProperty - productType.getProperty("Discontinued");
|
|
2475
|
+
// Validates that the value of the Discontinued property on Product is a boolean
|
|
2476
|
+
discontinuedProperty.validators.push(Validator.bool());
|
|
2477
|
+
@method bool
|
|
2478
|
+
@static
|
|
2479
|
+
@return {Validator} A new Validator
|
|
2480
|
+
**/
|
|
2481
|
+
static bool = function () {
|
|
2482
|
+
let valFn = function (v) {
|
|
2483
|
+
if (v == null)
|
|
2484
|
+
return true;
|
|
2485
|
+
return (v === true) || (v === false);
|
|
2486
|
+
};
|
|
2487
|
+
return new Validator("bool", valFn);
|
|
2488
|
+
};
|
|
2489
|
+
static none = function () {
|
|
2490
|
+
let valFn = function (v) {
|
|
2459
2491
|
return true;
|
|
2460
|
-
|
|
2492
|
+
};
|
|
2493
|
+
return new Validator("none", valFn);
|
|
2494
|
+
};
|
|
2495
|
+
/**
|
|
2496
|
+
Returns a standard date data type Validator.
|
|
2497
|
+
@example
|
|
2498
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2499
|
+
var orderType = em1.metadataStore.getEntityType("Order");
|
|
2500
|
+
var orderDateProperty - orderType.getProperty("OrderDate");
|
|
2501
|
+
// Validates that the value of the OrderDate property on Order is a date
|
|
2502
|
+
// Probably not a very good validation to place on the Freight property.
|
|
2503
|
+
orderDateProperty.validators.push(Validator.date());
|
|
2504
|
+
@method date
|
|
2505
|
+
@static
|
|
2506
|
+
@return {Validator} A new Validator
|
|
2507
|
+
**/
|
|
2508
|
+
static date = function () {
|
|
2509
|
+
let valFn = function (v) {
|
|
2510
|
+
if (v == null)
|
|
2511
|
+
return true;
|
|
2512
|
+
if (typeof v === "string") {
|
|
2513
|
+
try {
|
|
2514
|
+
return !isNaN(Date.parse(v));
|
|
2515
|
+
// old code
|
|
2516
|
+
// return __isDate(new Date(v));
|
|
2517
|
+
}
|
|
2518
|
+
catch (e) {
|
|
2519
|
+
return false;
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
else {
|
|
2523
|
+
return core.isDate(v);
|
|
2524
|
+
}
|
|
2525
|
+
};
|
|
2526
|
+
return new Validator("date", valFn);
|
|
2527
|
+
};
|
|
2528
|
+
/**
|
|
2529
|
+
Returns a credit card number validator
|
|
2530
|
+
Performs a luhn algorithm checksum test for plausability
|
|
2531
|
+
catches simple mistakes; only service knows for sure
|
|
2532
|
+
@example
|
|
2533
|
+
// Assume em is a preexisting EntityManager.
|
|
2534
|
+
var personType = em.metadataStore.getEntityType("Person");
|
|
2535
|
+
var creditCardProperty = personType.getProperty("creditCard");
|
|
2536
|
+
// Validates that the value of the Person.creditCard property is credit card.
|
|
2537
|
+
creditCardProperty.validators.push(Validator.creditCard());
|
|
2538
|
+
@method creditCard
|
|
2539
|
+
@static
|
|
2540
|
+
@param [context] {Object} optional parameters to pass through to validation constructor
|
|
2541
|
+
@return {Validator} A new Validator
|
|
2542
|
+
**/
|
|
2543
|
+
static creditCard = function (context) {
|
|
2544
|
+
function valFn(v) {
|
|
2545
|
+
if (v == null || v === '')
|
|
2546
|
+
return true;
|
|
2547
|
+
if (typeof (v) !== 'string')
|
|
2548
|
+
return false;
|
|
2549
|
+
v = v.replace(/(\-|\s)/g, ""); // remove dashes and spaces
|
|
2550
|
+
if (!v || /\D/.test(v))
|
|
2551
|
+
return false; // all digits, not empty
|
|
2552
|
+
return luhn(v);
|
|
2553
|
+
}
|
|
2554
|
+
return new Validator('creditCard', valFn, context);
|
|
2555
|
+
};
|
|
2556
|
+
/**
|
|
2557
|
+
Returns a regular expression validator; the expression must be specified
|
|
2558
|
+
@example
|
|
2559
|
+
// Add validator to a property. Assume em is a preexisting EntityManager.
|
|
2560
|
+
var customerType = em.metadataStore.getEntityType("Customer");
|
|
2561
|
+
var regionProperty = customerType.getProperty("Region");
|
|
2562
|
+
// Validates that the value of Customer.Region is 2 char uppercase alpha.
|
|
2563
|
+
regionProperty.validators.push(Validator.regularExpression( {expression: '^[A-Z]{2}$'} );
|
|
2564
|
+
@method regularExpression
|
|
2565
|
+
@static
|
|
2566
|
+
@param context {Object}
|
|
2567
|
+
@param context.expression {String} String form of the regular expression to apply
|
|
2568
|
+
@return {Validator} A new Validator
|
|
2569
|
+
**/
|
|
2570
|
+
static regularExpression = function (context) {
|
|
2571
|
+
function valFn(v, ctx) {
|
|
2572
|
+
// do not invalidate if empty; use a separate required test
|
|
2573
|
+
if (v == null || v === '')
|
|
2574
|
+
return true;
|
|
2575
|
+
if (typeof (v) !== 'string')
|
|
2576
|
+
return false;
|
|
2461
2577
|
try {
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
// return __isDate(new Date(v));
|
|
2578
|
+
let re = new RegExp(ctx.expression);
|
|
2579
|
+
return re.test(v);
|
|
2465
2580
|
}
|
|
2466
2581
|
catch (e) {
|
|
2467
|
-
|
|
2582
|
+
throw new Error('Missing or invalid expression parameter to regExp validator');
|
|
2468
2583
|
}
|
|
2469
2584
|
}
|
|
2470
|
-
|
|
2471
|
-
return core.isDate(v);
|
|
2472
|
-
}
|
|
2585
|
+
return new Validator('regularExpression', valFn, context);
|
|
2473
2586
|
};
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
}
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
@
|
|
2513
|
-
@
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
@
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
// Assume em is a preexisting EntityManager.
|
|
2567
|
-
var customerType = em.metadataStore.getEntityType("Customer");
|
|
2568
|
-
var phoneProperty = customerType.getProperty("phone");
|
|
2569
|
-
// Validates that the value of the Customer.phone property is phone.
|
|
2570
|
-
phoneProperty.validators.push(Validator.phone());
|
|
2571
|
-
@method phone
|
|
2572
|
-
@static
|
|
2573
|
-
@param [context] {Object} optional parameters to pass through to validation constructor
|
|
2574
|
-
@return {Validator} A new Validator
|
|
2575
|
-
**/
|
|
2576
|
-
Validator.phone = function (context) {
|
|
2577
|
-
// See https://github.com/srkirkland/DataAnnotationsExtensions/blob/master/DataAnnotationsExtensions/Expressions.cs
|
|
2578
|
-
let rePhone = /^((\+|(0(\d+)?[-/.\s]?))[1-9]\d{0,2}[-/.\s]?)?((\(\d{1,6}\)|\d{1,6})[-/.\s]?)?(\d+[-/.\s]?)+\d+$/;
|
|
2579
|
-
return makeRegExpValidator('phone', rePhone, null, context);
|
|
2580
|
-
};
|
|
2581
|
-
/**
|
|
2582
|
-
Returns the URL (protocol required) validator
|
|
2583
|
-
@example
|
|
2584
|
-
// Assume em is a preexisting EntityManager.
|
|
2585
|
-
var personType = em.metadataStore.getEntityType("Person");
|
|
2586
|
-
var websiteProperty = personType.getProperty("website");
|
|
2587
|
-
// Validates that the value of the Person.website property is a URL.
|
|
2588
|
-
websiteProperty.validators.push(Validator.url());
|
|
2589
|
-
@method url
|
|
2590
|
-
@static
|
|
2591
|
-
@param [context] {Object} optional parameters to pass through to validation constructor
|
|
2592
|
-
@return {Validator} A new Validator
|
|
2593
|
-
**/
|
|
2594
|
-
Validator.url = function (context) {
|
|
2595
|
-
//See https://github.com/srkirkland/DataAnnotationsExtensions/blob/master/DataAnnotationsExtensions/UrlAttribute.cs
|
|
2596
|
-
let reUrlProtocolRequired = /^(https?|ftp):\/\/(((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-fA-F]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|([a-zA-Z][\-a-zA-Z0-9]*)|((([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-fA-F]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-fA-F]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-fA-F]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-fA-F]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/;
|
|
2597
|
-
return makeRegExpValidator('url', reUrlProtocolRequired, null, context);
|
|
2598
|
-
};
|
|
2599
|
-
/**
|
|
2600
|
-
Creates a regular expression validator with a fixed expression.
|
|
2601
|
-
Many of the stock validators are built with this factory method.
|
|
2602
|
-
Their expressions are often derived from
|
|
2603
|
-
https://github.com/srkirkland/DataAnnotationsExtensions/blob/master/DataAnnotationsExtensions
|
|
2604
|
-
You can try many of them at http://dataannotationsextensions.org/
|
|
2605
|
-
@example
|
|
2606
|
-
// Make a zipcode validator
|
|
2607
|
-
function zipValidator = Validator.makeRegExpValidator(
|
|
2608
|
-
"zipVal,
|
|
2609
|
-
/^\d{5}([\-]\d{4})?$/,
|
|
2610
|
-
"The %displayName% '%value%' is not a valid U.S. zipcode");
|
|
2611
|
-
// Register it.
|
|
2612
|
-
Validator.register(zipValidator);
|
|
2613
|
-
// Add it to a data property. Assume em is a preexisting EntityManager.
|
|
2614
|
-
var custType = em.metadataStore.getEntityType("Customer");
|
|
2615
|
-
var zipProperty = custType.getProperty("PostalCode");
|
|
2616
|
-
zipProperty.validators.push(zipValidator);
|
|
2617
|
-
@method makeRegExpValidator
|
|
2618
|
-
@static
|
|
2619
|
-
@param validatorName {String} name of this validator
|
|
2620
|
-
@param expression {String | RegExp} regular expression to apply
|
|
2621
|
-
@param [defaultMessage] {String} default message for failed validations
|
|
2622
|
-
@param [context] {Object} optional parameters to pass through to validation constructor
|
|
2623
|
-
@return {Validator} A new Validator
|
|
2624
|
-
**/
|
|
2625
|
-
Validator.makeRegExpValidator = makeRegExpValidator;
|
|
2587
|
+
/**
|
|
2588
|
+
Returns the email address validator
|
|
2589
|
+
@example
|
|
2590
|
+
// Assume em is a preexisting EntityManager.
|
|
2591
|
+
var personType = em.metadataStore.getEntityType("Person");
|
|
2592
|
+
var emailProperty = personType.getProperty("email");
|
|
2593
|
+
// Validates that the value of the Person.email property is an email address.
|
|
2594
|
+
emailProperty.validators.push(Validator.emailAddress());
|
|
2595
|
+
@method emailAddress
|
|
2596
|
+
@static
|
|
2597
|
+
@param [context] {Object} optional parameters to pass through to validation constructor
|
|
2598
|
+
@return {Validator} A new Validator
|
|
2599
|
+
**/
|
|
2600
|
+
static emailAddress = function (context) {
|
|
2601
|
+
// See https://github.com/srkirkland/DataAnnotationsExtensions/blob/master/DataAnnotationsExtensions/EmailAttribute.cs
|
|
2602
|
+
let reEmailAddress = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i;
|
|
2603
|
+
return makeRegExpValidator('emailAddress', reEmailAddress, null, context);
|
|
2604
|
+
};
|
|
2605
|
+
/**
|
|
2606
|
+
Returns the phone validator
|
|
2607
|
+
Provides basic assertions on the format and will help to eliminate most nonsense input
|
|
2608
|
+
Matches:
|
|
2609
|
+
International dialing prefix: {{}, +, 0, 0000} (with or without a trailing break character, if not '+': [-/. ])
|
|
2610
|
+
> ((\+)|(0(\d+)?[-/.\s]))
|
|
2611
|
+
Country code: {{}, 1, ..., 999} (with or without a trailing break character: [-/. ])
|
|
2612
|
+
> [1-9]\d{,2}[-/.\s]?
|
|
2613
|
+
Area code: {(0), ..., (000000), 0, ..., 000000} (with or without a trailing break character: [-/. ])
|
|
2614
|
+
> ((\(\d{1,6}\)|\d{1,6})[-/.\s]?)?
|
|
2615
|
+
Local: {0, ...}+ (with or without a trailing break character: [-/. ])
|
|
2616
|
+
> (\d+[-/.\s]?)+\d+
|
|
2617
|
+
@example
|
|
2618
|
+
// Assume em is a preexisting EntityManager.
|
|
2619
|
+
var customerType = em.metadataStore.getEntityType("Customer");
|
|
2620
|
+
var phoneProperty = customerType.getProperty("phone");
|
|
2621
|
+
// Validates that the value of the Customer.phone property is phone.
|
|
2622
|
+
phoneProperty.validators.push(Validator.phone());
|
|
2623
|
+
@method phone
|
|
2624
|
+
@static
|
|
2625
|
+
@param [context] {Object} optional parameters to pass through to validation constructor
|
|
2626
|
+
@return {Validator} A new Validator
|
|
2627
|
+
**/
|
|
2628
|
+
static phone = function (context) {
|
|
2629
|
+
// See https://github.com/srkirkland/DataAnnotationsExtensions/blob/master/DataAnnotationsExtensions/Expressions.cs
|
|
2630
|
+
let rePhone = /^((\+|(0(\d+)?[-/.\s]?))[1-9]\d{0,2}[-/.\s]?)?((\(\d{1,6}\)|\d{1,6})[-/.\s]?)?(\d+[-/.\s]?)+\d+$/;
|
|
2631
|
+
return makeRegExpValidator('phone', rePhone, null, context);
|
|
2632
|
+
};
|
|
2633
|
+
/**
|
|
2634
|
+
Returns the URL (protocol required) validator
|
|
2635
|
+
@example
|
|
2636
|
+
// Assume em is a preexisting EntityManager.
|
|
2637
|
+
var personType = em.metadataStore.getEntityType("Person");
|
|
2638
|
+
var websiteProperty = personType.getProperty("website");
|
|
2639
|
+
// Validates that the value of the Person.website property is a URL.
|
|
2640
|
+
websiteProperty.validators.push(Validator.url());
|
|
2641
|
+
@method url
|
|
2642
|
+
@static
|
|
2643
|
+
@param [context] {Object} optional parameters to pass through to validation constructor
|
|
2644
|
+
@return {Validator} A new Validator
|
|
2645
|
+
**/
|
|
2646
|
+
static url = function (context) {
|
|
2647
|
+
//See https://github.com/srkirkland/DataAnnotationsExtensions/blob/master/DataAnnotationsExtensions/UrlAttribute.cs
|
|
2648
|
+
let reUrlProtocolRequired = /^(https?|ftp):\/\/(((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-fA-F]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|([a-zA-Z][\-a-zA-Z0-9]*)|((([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-fA-F]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-fA-F]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-fA-F]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-fA-F]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/;
|
|
2649
|
+
return makeRegExpValidator('url', reUrlProtocolRequired, null, context);
|
|
2650
|
+
};
|
|
2651
|
+
/**
|
|
2652
|
+
Creates a regular expression validator with a fixed expression.
|
|
2653
|
+
Many of the stock validators are built with this factory method.
|
|
2654
|
+
Their expressions are often derived from
|
|
2655
|
+
https://github.com/srkirkland/DataAnnotationsExtensions/blob/master/DataAnnotationsExtensions
|
|
2656
|
+
You can try many of them at http://dataannotationsextensions.org/
|
|
2657
|
+
@example
|
|
2658
|
+
// Make a zipcode validator
|
|
2659
|
+
function zipValidator = Validator.makeRegExpValidator(
|
|
2660
|
+
"zipVal,
|
|
2661
|
+
/^\d{5}([\-]\d{4})?$/,
|
|
2662
|
+
"The %displayName% '%value%' is not a valid U.S. zipcode");
|
|
2663
|
+
// Register it.
|
|
2664
|
+
Validator.register(zipValidator);
|
|
2665
|
+
// Add it to a data property. Assume em is a preexisting EntityManager.
|
|
2666
|
+
var custType = em.metadataStore.getEntityType("Customer");
|
|
2667
|
+
var zipProperty = custType.getProperty("PostalCode");
|
|
2668
|
+
zipProperty.validators.push(zipValidator);
|
|
2669
|
+
@method makeRegExpValidator
|
|
2670
|
+
@static
|
|
2671
|
+
@param validatorName {String} name of this validator
|
|
2672
|
+
@param expression {String | RegExp} regular expression to apply
|
|
2673
|
+
@param [defaultMessage] {String} default message for failed validations
|
|
2674
|
+
@param [context] {Object} optional parameters to pass through to validation constructor
|
|
2675
|
+
@return {Validator} A new Validator
|
|
2676
|
+
**/
|
|
2677
|
+
static makeRegExpValidator = makeRegExpValidator;
|
|
2678
|
+
}
|
|
2626
2679
|
Validator.prototype._$typeName = "Validator";
|
|
2627
2680
|
// register all validators
|
|
2628
2681
|
Error['x'] = core.objectForEach(Validator, function (key, value) {
|
|
@@ -2709,7 +2762,14 @@ function makeRegExpValidator(validatorName, expression, defaultMessage, context)
|
|
|
2709
2762
|
};
|
|
2710
2763
|
return new Validator(validatorName, valFn, context);
|
|
2711
2764
|
}
|
|
2712
|
-
|
|
2765
|
+
// http://rosettacode.org/wiki/Luhn_test_of_credit_card_numbers#JavaScript
|
|
2766
|
+
// function luhn(a: string, b: number, c: number, d: number, e: number) {
|
|
2767
|
+
// for (d = +a[b = a.length - 1], e = 0; b--; ) {
|
|
2768
|
+
// c = +a[b], d += ++e % 2 ? 2 * c % 10 + (c > 4) : c;
|
|
2769
|
+
// }
|
|
2770
|
+
// return !(d % 10);
|
|
2771
|
+
// };
|
|
2772
|
+
let luhn = (function () {
|
|
2713
2773
|
let luhnArr = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9];
|
|
2714
2774
|
return function (str) {
|
|
2715
2775
|
let counter = 0;
|
|
@@ -2724,15 +2784,7 @@ const ɵ1 = function () {
|
|
|
2724
2784
|
}
|
|
2725
2785
|
return (counter % 10 === 0);
|
|
2726
2786
|
};
|
|
2727
|
-
};
|
|
2728
|
-
// http://rosettacode.org/wiki/Luhn_test_of_credit_card_numbers#JavaScript
|
|
2729
|
-
// function luhn(a: string, b: number, c: number, d: number, e: number) {
|
|
2730
|
-
// for (d = +a[b = a.length - 1], e = 0; b--; ) {
|
|
2731
|
-
// c = +a[b], d += ++e % 2 ? 2 * c % 10 + (c > 4) : c;
|
|
2732
|
-
// }
|
|
2733
|
-
// return !(d % 10);
|
|
2734
|
-
// };
|
|
2735
|
-
let luhn = (ɵ1)();
|
|
2787
|
+
})();
|
|
2736
2788
|
/**
|
|
2737
2789
|
A ValidationError is used to describe a failed validation.
|
|
2738
2790
|
|
|
@@ -2748,6 +2800,13 @@ Constructs a new ValidationError
|
|
|
2748
2800
|
@param [key] {String} An optional key used to define a key for this error. One will be created automatically if not provided here.
|
|
2749
2801
|
**/
|
|
2750
2802
|
class ValidationError {
|
|
2803
|
+
validator;
|
|
2804
|
+
key;
|
|
2805
|
+
context;
|
|
2806
|
+
errorMessage;
|
|
2807
|
+
property; // IProperty
|
|
2808
|
+
propertyName;
|
|
2809
|
+
isServerError;
|
|
2751
2810
|
constructor(validator, context, errorMessage, key) {
|
|
2752
2811
|
// Error is with isInstanceOf(Validator)
|
|
2753
2812
|
assertParam(validator, "validator").isOptional().isInstanceOf(Validator).check();
|
|
@@ -2829,6 +2888,131 @@ DataType is an 'Enum' containing all of the supported data types.
|
|
|
2829
2888
|
@dynamic
|
|
2830
2889
|
**/
|
|
2831
2890
|
class DataType extends BreezeEnum {
|
|
2891
|
+
static parseDateFromServer = (value) => DataType.parseDateAsUTC(value);
|
|
2892
|
+
// same effect as above but doesn't give right TSDOC.
|
|
2893
|
+
// static parseDateFromServer = DataType.parseDateAsUTC;
|
|
2894
|
+
/** @hidden @internal */
|
|
2895
|
+
static constants;
|
|
2896
|
+
static String = new DataType({
|
|
2897
|
+
defaultValue: "",
|
|
2898
|
+
parse: coerceToString,
|
|
2899
|
+
fmtOData: fmtString,
|
|
2900
|
+
getNext: getNextString
|
|
2901
|
+
});
|
|
2902
|
+
static Int64 = new DataType({
|
|
2903
|
+
defaultValue: 0,
|
|
2904
|
+
isNumeric: true,
|
|
2905
|
+
isInteger: true,
|
|
2906
|
+
quoteJsonOData: true,
|
|
2907
|
+
parse: coerceToInt,
|
|
2908
|
+
fmtOData: makeFloatFmt("L"),
|
|
2909
|
+
getNext: getNextNumber
|
|
2910
|
+
});
|
|
2911
|
+
static Int32 = new DataType({
|
|
2912
|
+
defaultValue: 0,
|
|
2913
|
+
isNumeric: true,
|
|
2914
|
+
isInteger: true,
|
|
2915
|
+
parse: coerceToInt,
|
|
2916
|
+
fmtOData: fmtInt,
|
|
2917
|
+
getNext: getNextNumber
|
|
2918
|
+
});
|
|
2919
|
+
static Int16 = new DataType({
|
|
2920
|
+
defaultValue: 0,
|
|
2921
|
+
isNumeric: true,
|
|
2922
|
+
isInteger: true,
|
|
2923
|
+
parse: coerceToInt,
|
|
2924
|
+
fmtOData: fmtInt,
|
|
2925
|
+
getNext: getNextNumber
|
|
2926
|
+
});
|
|
2927
|
+
static Byte = new DataType({
|
|
2928
|
+
defaultValue: 0,
|
|
2929
|
+
isNumeric: true,
|
|
2930
|
+
isInteger: true,
|
|
2931
|
+
parse: coerceToInt,
|
|
2932
|
+
fmtOData: fmtInt
|
|
2933
|
+
});
|
|
2934
|
+
static Decimal = new DataType({
|
|
2935
|
+
defaultValue: 0,
|
|
2936
|
+
isNumeric: true,
|
|
2937
|
+
quoteJsonOData: true,
|
|
2938
|
+
isFloat: true,
|
|
2939
|
+
parse: coerceToFloat,
|
|
2940
|
+
fmtOData: makeFloatFmt("m"),
|
|
2941
|
+
getNext: getNextNumber
|
|
2942
|
+
});
|
|
2943
|
+
static Double = new DataType({
|
|
2944
|
+
defaultValue: 0,
|
|
2945
|
+
isNumeric: true,
|
|
2946
|
+
isFloat: true,
|
|
2947
|
+
parse: coerceToFloat,
|
|
2948
|
+
fmtOData: makeFloatFmt("d"),
|
|
2949
|
+
getNext: getNextNumber
|
|
2950
|
+
});
|
|
2951
|
+
static Single = new DataType({
|
|
2952
|
+
defaultValue: 0,
|
|
2953
|
+
isNumeric: true,
|
|
2954
|
+
isFloat: true,
|
|
2955
|
+
parse: coerceToFloat,
|
|
2956
|
+
fmtOData: makeFloatFmt("f"),
|
|
2957
|
+
getNext: getNextNumber
|
|
2958
|
+
});
|
|
2959
|
+
static DateOnly = new DataType({
|
|
2960
|
+
defaultValue: new Date(1900, 0, 1),
|
|
2961
|
+
isDate: true,
|
|
2962
|
+
parse: coerceToDateOnly,
|
|
2963
|
+
parseRawValue: parseRawDateOnly,
|
|
2964
|
+
normalize: function (value) { return value && value.getTime && (new Date(value.getYear(), value.getMonth(), value.getDate())).getTime(); },
|
|
2965
|
+
fmtOData: fmtDateOnly,
|
|
2966
|
+
getNext: getNextDateTime,
|
|
2967
|
+
getConcurrencyValue: getConcurrencyDateTime
|
|
2968
|
+
});
|
|
2969
|
+
static DateTime = new DataType({
|
|
2970
|
+
defaultValue: new Date(1900, 0, 1),
|
|
2971
|
+
isDate: true,
|
|
2972
|
+
parse: coerceToDate,
|
|
2973
|
+
parseRawValue: parseRawDate,
|
|
2974
|
+
normalize: function (value) { return value && value.getTime && value.getTime(); },
|
|
2975
|
+
fmtOData: fmtDateTime,
|
|
2976
|
+
getNext: getNextDateTime,
|
|
2977
|
+
getConcurrencyValue: getConcurrencyDateTime
|
|
2978
|
+
});
|
|
2979
|
+
static DateTimeOffset = new DataType({
|
|
2980
|
+
defaultValue: new Date(1900, 0, 1),
|
|
2981
|
+
isDate: true,
|
|
2982
|
+
parse: coerceToDate,
|
|
2983
|
+
parseRawValue: parseRawDate,
|
|
2984
|
+
normalize: function (value) { return value && value.getTime && value.getTime(); },
|
|
2985
|
+
fmtOData: fmtDateTimeOffset,
|
|
2986
|
+
getNext: getNextDateTime,
|
|
2987
|
+
getConcurrencyValue: getConcurrencyDateTime
|
|
2988
|
+
});
|
|
2989
|
+
static Time = new DataType({
|
|
2990
|
+
defaultValue: "PT0S",
|
|
2991
|
+
fmtOData: fmtTime,
|
|
2992
|
+
parseRawValue: DataType.parseTimeFromServer
|
|
2993
|
+
});
|
|
2994
|
+
static Boolean = new DataType({
|
|
2995
|
+
defaultValue: false,
|
|
2996
|
+
parse: coerceToBool,
|
|
2997
|
+
fmtOData: fmtBoolean
|
|
2998
|
+
});
|
|
2999
|
+
static Guid = new DataType({
|
|
3000
|
+
defaultValue: "00000000-0000-0000-0000-000000000000",
|
|
3001
|
+
parse: coerceToGuid,
|
|
3002
|
+
fmtOData: fmtGuid,
|
|
3003
|
+
getNext: getNextGuid,
|
|
3004
|
+
parseRawValue: function (val) { return val.toLowerCase(); },
|
|
3005
|
+
getConcurrencyValue: core.getUuid
|
|
3006
|
+
});
|
|
3007
|
+
static Binary = new DataType({
|
|
3008
|
+
defaultValue: null,
|
|
3009
|
+
fmtOData: fmtBinary,
|
|
3010
|
+
parseRawValue: parseRawBinary
|
|
3011
|
+
});
|
|
3012
|
+
static Undefined = new DataType({
|
|
3013
|
+
defaultValue: undefined,
|
|
3014
|
+
fmtOData: fmtUndefined
|
|
3015
|
+
});
|
|
2832
3016
|
static getComparableFn(dataType) {
|
|
2833
3017
|
if (dataType && dataType.normalize) {
|
|
2834
3018
|
return dataType.normalize;
|
|
@@ -2949,127 +3133,6 @@ class DataType extends BreezeEnum {
|
|
|
2949
3133
|
};
|
|
2950
3134
|
}
|
|
2951
3135
|
}
|
|
2952
|
-
DataType.parseDateFromServer = (value) => DataType.parseDateAsUTC(value);
|
|
2953
|
-
DataType.String = new DataType({
|
|
2954
|
-
defaultValue: "",
|
|
2955
|
-
parse: coerceToString,
|
|
2956
|
-
fmtOData: fmtString,
|
|
2957
|
-
getNext: getNextString
|
|
2958
|
-
});
|
|
2959
|
-
DataType.Int64 = new DataType({
|
|
2960
|
-
defaultValue: 0,
|
|
2961
|
-
isNumeric: true,
|
|
2962
|
-
isInteger: true,
|
|
2963
|
-
quoteJsonOData: true,
|
|
2964
|
-
parse: coerceToInt,
|
|
2965
|
-
fmtOData: makeFloatFmt("L"),
|
|
2966
|
-
getNext: getNextNumber
|
|
2967
|
-
});
|
|
2968
|
-
DataType.Int32 = new DataType({
|
|
2969
|
-
defaultValue: 0,
|
|
2970
|
-
isNumeric: true,
|
|
2971
|
-
isInteger: true,
|
|
2972
|
-
parse: coerceToInt,
|
|
2973
|
-
fmtOData: fmtInt,
|
|
2974
|
-
getNext: getNextNumber
|
|
2975
|
-
});
|
|
2976
|
-
DataType.Int16 = new DataType({
|
|
2977
|
-
defaultValue: 0,
|
|
2978
|
-
isNumeric: true,
|
|
2979
|
-
isInteger: true,
|
|
2980
|
-
parse: coerceToInt,
|
|
2981
|
-
fmtOData: fmtInt,
|
|
2982
|
-
getNext: getNextNumber
|
|
2983
|
-
});
|
|
2984
|
-
DataType.Byte = new DataType({
|
|
2985
|
-
defaultValue: 0,
|
|
2986
|
-
isNumeric: true,
|
|
2987
|
-
isInteger: true,
|
|
2988
|
-
parse: coerceToInt,
|
|
2989
|
-
fmtOData: fmtInt
|
|
2990
|
-
});
|
|
2991
|
-
DataType.Decimal = new DataType({
|
|
2992
|
-
defaultValue: 0,
|
|
2993
|
-
isNumeric: true,
|
|
2994
|
-
quoteJsonOData: true,
|
|
2995
|
-
isFloat: true,
|
|
2996
|
-
parse: coerceToFloat,
|
|
2997
|
-
fmtOData: makeFloatFmt("m"),
|
|
2998
|
-
getNext: getNextNumber
|
|
2999
|
-
});
|
|
3000
|
-
DataType.Double = new DataType({
|
|
3001
|
-
defaultValue: 0,
|
|
3002
|
-
isNumeric: true,
|
|
3003
|
-
isFloat: true,
|
|
3004
|
-
parse: coerceToFloat,
|
|
3005
|
-
fmtOData: makeFloatFmt("d"),
|
|
3006
|
-
getNext: getNextNumber
|
|
3007
|
-
});
|
|
3008
|
-
DataType.Single = new DataType({
|
|
3009
|
-
defaultValue: 0,
|
|
3010
|
-
isNumeric: true,
|
|
3011
|
-
isFloat: true,
|
|
3012
|
-
parse: coerceToFloat,
|
|
3013
|
-
fmtOData: makeFloatFmt("f"),
|
|
3014
|
-
getNext: getNextNumber
|
|
3015
|
-
});
|
|
3016
|
-
DataType.DateOnly = new DataType({
|
|
3017
|
-
defaultValue: new Date(1900, 0, 1),
|
|
3018
|
-
isDate: true,
|
|
3019
|
-
parse: coerceToDateOnly,
|
|
3020
|
-
parseRawValue: parseRawDateOnly,
|
|
3021
|
-
normalize: function (value) { return value && value.getTime && (new Date(value.getYear(), value.getMonth(), value.getDate())).getTime(); },
|
|
3022
|
-
fmtOData: fmtDateOnly,
|
|
3023
|
-
getNext: getNextDateTime,
|
|
3024
|
-
getConcurrencyValue: getConcurrencyDateTime
|
|
3025
|
-
});
|
|
3026
|
-
DataType.DateTime = new DataType({
|
|
3027
|
-
defaultValue: new Date(1900, 0, 1),
|
|
3028
|
-
isDate: true,
|
|
3029
|
-
parse: coerceToDate,
|
|
3030
|
-
parseRawValue: parseRawDate,
|
|
3031
|
-
normalize: function (value) { return value && value.getTime && value.getTime(); },
|
|
3032
|
-
fmtOData: fmtDateTime,
|
|
3033
|
-
getNext: getNextDateTime,
|
|
3034
|
-
getConcurrencyValue: getConcurrencyDateTime
|
|
3035
|
-
});
|
|
3036
|
-
DataType.DateTimeOffset = new DataType({
|
|
3037
|
-
defaultValue: new Date(1900, 0, 1),
|
|
3038
|
-
isDate: true,
|
|
3039
|
-
parse: coerceToDate,
|
|
3040
|
-
parseRawValue: parseRawDate,
|
|
3041
|
-
normalize: function (value) { return value && value.getTime && value.getTime(); },
|
|
3042
|
-
fmtOData: fmtDateTimeOffset,
|
|
3043
|
-
getNext: getNextDateTime,
|
|
3044
|
-
getConcurrencyValue: getConcurrencyDateTime
|
|
3045
|
-
});
|
|
3046
|
-
DataType.Time = new DataType({
|
|
3047
|
-
defaultValue: "PT0S",
|
|
3048
|
-
fmtOData: fmtTime,
|
|
3049
|
-
parseRawValue: DataType.parseTimeFromServer
|
|
3050
|
-
});
|
|
3051
|
-
DataType.Boolean = new DataType({
|
|
3052
|
-
defaultValue: false,
|
|
3053
|
-
parse: coerceToBool,
|
|
3054
|
-
fmtOData: fmtBoolean
|
|
3055
|
-
});
|
|
3056
|
-
DataType.Guid = new DataType({
|
|
3057
|
-
defaultValue: "00000000-0000-0000-0000-000000000000",
|
|
3058
|
-
parse: coerceToGuid,
|
|
3059
|
-
fmtOData: fmtGuid,
|
|
3060
|
-
getNext: getNextGuid,
|
|
3061
|
-
parseRawValue: function (val) { return val.toLowerCase(); },
|
|
3062
|
-
getConcurrencyValue: core.getUuid
|
|
3063
|
-
});
|
|
3064
|
-
DataType.Binary = new DataType({
|
|
3065
|
-
defaultValue: null,
|
|
3066
|
-
fmtOData: fmtBinary,
|
|
3067
|
-
parseRawValue: parseRawBinary
|
|
3068
|
-
});
|
|
3069
|
-
DataType.Undefined = new DataType({
|
|
3070
|
-
defaultValue: undefined,
|
|
3071
|
-
fmtOData: fmtUndefined
|
|
3072
|
-
});
|
|
3073
3136
|
DataType.prototype._$typeName = "DataType";
|
|
3074
3137
|
Error['x'] = DataType._resetConstants();
|
|
3075
3138
|
Error['x'] = DataType.resolveSymbols();
|
|
@@ -3330,6 +3393,16 @@ function parseRawBinary(val) {
|
|
|
3330
3393
|
EntityState is an 'Enum' containing all of the valid states for an 'Entity'.
|
|
3331
3394
|
**/
|
|
3332
3395
|
class EntityState extends BreezeEnum {
|
|
3396
|
+
/** The 'Unchanged' state. **/
|
|
3397
|
+
static Unchanged = new EntityState();
|
|
3398
|
+
/** The 'Added' state. **/
|
|
3399
|
+
static Added = new EntityState();
|
|
3400
|
+
/** The 'Modified' state. **/
|
|
3401
|
+
static Modified = new EntityState();
|
|
3402
|
+
/** The 'Deleted' state. **/
|
|
3403
|
+
static Deleted = new EntityState();
|
|
3404
|
+
/** The 'Detached' state. **/
|
|
3405
|
+
static Detached = new EntityState();
|
|
3333
3406
|
/**
|
|
3334
3407
|
Returns whether an entityState instance is EntityState.Unchanged.
|
|
3335
3408
|
> var es = anEntity.entityAspect.entityState;
|
|
@@ -3419,16 +3492,6 @@ class EntityState extends BreezeEnum {
|
|
|
3419
3492
|
this === EntityState.Deleted;
|
|
3420
3493
|
}
|
|
3421
3494
|
}
|
|
3422
|
-
/** The 'Unchanged' state. **/
|
|
3423
|
-
EntityState.Unchanged = new EntityState();
|
|
3424
|
-
/** The 'Added' state. **/
|
|
3425
|
-
EntityState.Added = new EntityState();
|
|
3426
|
-
/** The 'Modified' state. **/
|
|
3427
|
-
EntityState.Modified = new EntityState();
|
|
3428
|
-
/** The 'Deleted' state. **/
|
|
3429
|
-
EntityState.Deleted = new EntityState();
|
|
3430
|
-
/** The 'Detached' state. **/
|
|
3431
|
-
EntityState.Detached = new EntityState();
|
|
3432
3495
|
EntityState.prototype._$typeName = "EntityState";
|
|
3433
3496
|
Error['x'] = EntityState.resolveSymbols();
|
|
3434
3497
|
|
|
@@ -3436,6 +3499,30 @@ Error['x'] = EntityState.resolveSymbols();
|
|
|
3436
3499
|
|
|
3437
3500
|
*/
|
|
3438
3501
|
class EntityAction extends BreezeEnum {
|
|
3502
|
+
/** Entity was attached via an AttachEntity call. */
|
|
3503
|
+
static Attach = new EntityAction({ _isAttach: true });
|
|
3504
|
+
/** Entity was attached as a result of a query. */
|
|
3505
|
+
static AttachOnQuery = new EntityAction({ _isAttach: true });
|
|
3506
|
+
/** Entity was attached as a result of an import. */
|
|
3507
|
+
static AttachOnImport = new EntityAction({ _isAttach: true });
|
|
3508
|
+
/** Entity was detached */
|
|
3509
|
+
static Detach = new EntityAction({ _isDetach: true });
|
|
3510
|
+
/** Properties on the entity were merged as a result of a query. */
|
|
3511
|
+
static MergeOnQuery = new EntityAction({ _isModification: true });
|
|
3512
|
+
/** Properties on the entity were merged as a result of an import. */
|
|
3513
|
+
static MergeOnImport = new EntityAction({ _isModification: true });
|
|
3514
|
+
/** Properties on the entity were merged as a result of a save */
|
|
3515
|
+
static MergeOnSave = new EntityAction({ _isModification: true });
|
|
3516
|
+
/** A property on the entity was changed. */
|
|
3517
|
+
static PropertyChange = new EntityAction({ _isModification: true });
|
|
3518
|
+
/** The EntityState of the entity was changed. */
|
|
3519
|
+
static EntityStateChange = new EntityAction();
|
|
3520
|
+
/** AcceptChanges was called on the entity, or its entityState was set to Unmodified. */
|
|
3521
|
+
static AcceptChanges = new EntityAction();
|
|
3522
|
+
/** RejectChanges was called on the entity. */
|
|
3523
|
+
static RejectChanges = new EntityAction({ _isModification: true });
|
|
3524
|
+
/** The EntityManager was cleared. All entities detached. */
|
|
3525
|
+
static Clear = new EntityAction({ _isDetach: true });
|
|
3439
3526
|
/** Is this an 'attach' operation? ( Attach, AttachOnQuery or AttachOnImport) */
|
|
3440
3527
|
isAttach() {
|
|
3441
3528
|
return !!this._isAttach;
|
|
@@ -3449,30 +3536,6 @@ class EntityAction extends BreezeEnum {
|
|
|
3449
3536
|
return !!this._isModification;
|
|
3450
3537
|
}
|
|
3451
3538
|
}
|
|
3452
|
-
/** Entity was attached via an AttachEntity call. */
|
|
3453
|
-
EntityAction.Attach = new EntityAction({ _isAttach: true });
|
|
3454
|
-
/** Entity was attached as a result of a query. */
|
|
3455
|
-
EntityAction.AttachOnQuery = new EntityAction({ _isAttach: true });
|
|
3456
|
-
/** Entity was attached as a result of an import. */
|
|
3457
|
-
EntityAction.AttachOnImport = new EntityAction({ _isAttach: true });
|
|
3458
|
-
/** Entity was detached */
|
|
3459
|
-
EntityAction.Detach = new EntityAction({ _isDetach: true });
|
|
3460
|
-
/** Properties on the entity were merged as a result of a query. */
|
|
3461
|
-
EntityAction.MergeOnQuery = new EntityAction({ _isModification: true });
|
|
3462
|
-
/** Properties on the entity were merged as a result of an import. */
|
|
3463
|
-
EntityAction.MergeOnImport = new EntityAction({ _isModification: true });
|
|
3464
|
-
/** Properties on the entity were merged as a result of a save */
|
|
3465
|
-
EntityAction.MergeOnSave = new EntityAction({ _isModification: true });
|
|
3466
|
-
/** A property on the entity was changed. */
|
|
3467
|
-
EntityAction.PropertyChange = new EntityAction({ _isModification: true });
|
|
3468
|
-
/** The EntityState of the entity was changed. */
|
|
3469
|
-
EntityAction.EntityStateChange = new EntityAction();
|
|
3470
|
-
/** AcceptChanges was called on the entity, or its entityState was set to Unmodified. */
|
|
3471
|
-
EntityAction.AcceptChanges = new EntityAction();
|
|
3472
|
-
/** RejectChanges was called on the entity. */
|
|
3473
|
-
EntityAction.RejectChanges = new EntityAction({ _isModification: true });
|
|
3474
|
-
/** The EntityManager was cleared. All entities detached. */
|
|
3475
|
-
EntityAction.Clear = new EntityAction({ _isDetach: true });
|
|
3476
3539
|
EntityAction.prototype._$typeName = "EntityAction";
|
|
3477
3540
|
Error['x'] = EntityAction.resolveSymbols();
|
|
3478
3541
|
|
|
@@ -3482,6 +3545,17 @@ An EntityKey is an object that represents the unique identity of an entity. Ent
|
|
|
3482
3545
|
|
|
3483
3546
|
**/
|
|
3484
3547
|
class EntityKey {
|
|
3548
|
+
/** @hidden @internal */
|
|
3549
|
+
static ENTITY_KEY_DELIMITER = ":::";
|
|
3550
|
+
/** The 'EntityType' that this is a key for. __Read Only__ */
|
|
3551
|
+
entityType;
|
|
3552
|
+
/** An array of the values for this key. This will usually only have a single element,
|
|
3553
|
+
unless the entity type has a multipart key. __Read Only__ */
|
|
3554
|
+
values;
|
|
3555
|
+
/** @hidden @internal */
|
|
3556
|
+
_keyInGroup;
|
|
3557
|
+
/** @hidden @internal */
|
|
3558
|
+
_subtypes;
|
|
3485
3559
|
/**
|
|
3486
3560
|
Constructs a new EntityKey. Each entity within an EntityManager will have a unique EntityKey.
|
|
3487
3561
|
> // assume em1 is an EntityManager containing a number of existing entities.
|
|
@@ -3584,8 +3658,6 @@ class EntityKey {
|
|
|
3584
3658
|
return keyValues.join(EntityKey.ENTITY_KEY_DELIMITER);
|
|
3585
3659
|
}
|
|
3586
3660
|
}
|
|
3587
|
-
/** @hidden @internal */
|
|
3588
|
-
EntityKey.ENTITY_KEY_DELIMITER = ":::";
|
|
3589
3661
|
EntityKey.prototype._$typeName = "EntityKey";
|
|
3590
3662
|
|
|
3591
3663
|
/**
|
|
@@ -3595,53 +3667,61 @@ MergeStrategy is an 'Enum' that determines how entities are merged into an Entit
|
|
|
3595
3667
|
@static
|
|
3596
3668
|
**/
|
|
3597
3669
|
class MergeStrategy extends BreezeEnum {
|
|
3670
|
+
/**
|
|
3671
|
+
MergeStrategy.PreserveChanges updates the cached entity with the incoming values unless the cached entity is in a changed
|
|
3672
|
+
state (added, modified, deleted) in which case the incoming values are ignored. The updated cached entity’s EntityState will
|
|
3673
|
+
remain [[EntityState.Unchanged]] unless you’re importing entities in which case the new EntityState will
|
|
3674
|
+
be that of the imported entities.
|
|
3675
|
+
**/
|
|
3676
|
+
static PreserveChanges = new MergeStrategy();
|
|
3677
|
+
/**
|
|
3678
|
+
MergeStrategy.OverwriteChanges always updates the cached entity with incoming values even if the entity is in
|
|
3679
|
+
a changed state (added, modified, deleted). After the merge, the pending changes are lost.
|
|
3680
|
+
The new EntityState will be [[EntityState/Unchanged]] unless you’re importing entities
|
|
3681
|
+
in which case the new EntityState will be that of the imported entities.
|
|
3682
|
+
**/
|
|
3683
|
+
static OverwriteChanges = new MergeStrategy();
|
|
3684
|
+
/**
|
|
3685
|
+
SkipMerge is used to ignore incoming values. Adds the incoming entity to the cache only if there is no cached entity with the same key.
|
|
3686
|
+
This is the fastest merge strategy but your existing cached data will remain “stale”.
|
|
3687
|
+
**/
|
|
3688
|
+
static SkipMerge = new MergeStrategy();
|
|
3689
|
+
/**
|
|
3690
|
+
Disallowed is used to throw an exception if there is an incoming entity with the same key as an entity already in the cache.
|
|
3691
|
+
Use this strategy when you want to be sure that the incoming entity is not already in cache.
|
|
3692
|
+
This is the default strategy for EntityManager.attachEntity.
|
|
3693
|
+
**/
|
|
3694
|
+
static Disallowed = new MergeStrategy();
|
|
3598
3695
|
}
|
|
3599
|
-
/**
|
|
3600
|
-
MergeStrategy.PreserveChanges updates the cached entity with the incoming values unless the cached entity is in a changed
|
|
3601
|
-
state (added, modified, deleted) in which case the incoming values are ignored. The updated cached entity’s EntityState will
|
|
3602
|
-
remain [[EntityState.Unchanged]] unless you’re importing entities in which case the new EntityState will
|
|
3603
|
-
be that of the imported entities.
|
|
3604
|
-
**/
|
|
3605
|
-
MergeStrategy.PreserveChanges = new MergeStrategy();
|
|
3606
|
-
/**
|
|
3607
|
-
MergeStrategy.OverwriteChanges always updates the cached entity with incoming values even if the entity is in
|
|
3608
|
-
a changed state (added, modified, deleted). After the merge, the pending changes are lost.
|
|
3609
|
-
The new EntityState will be [[EntityState/Unchanged]] unless you’re importing entities
|
|
3610
|
-
in which case the new EntityState will be that of the imported entities.
|
|
3611
|
-
**/
|
|
3612
|
-
MergeStrategy.OverwriteChanges = new MergeStrategy();
|
|
3613
|
-
/**
|
|
3614
|
-
SkipMerge is used to ignore incoming values. Adds the incoming entity to the cache only if there is no cached entity with the same key.
|
|
3615
|
-
This is the fastest merge strategy but your existing cached data will remain “stale”.
|
|
3616
|
-
**/
|
|
3617
|
-
MergeStrategy.SkipMerge = new MergeStrategy();
|
|
3618
|
-
/**
|
|
3619
|
-
Disallowed is used to throw an exception if there is an incoming entity with the same key as an entity already in the cache.
|
|
3620
|
-
Use this strategy when you want to be sure that the incoming entity is not already in cache.
|
|
3621
|
-
This is the default strategy for EntityManager.attachEntity.
|
|
3622
|
-
**/
|
|
3623
|
-
MergeStrategy.Disallowed = new MergeStrategy();
|
|
3624
3696
|
MergeStrategy.prototype._$typeName = "MergeStrategy";
|
|
3625
3697
|
Error['x'] = MergeStrategy.resolveSymbols();
|
|
3626
3698
|
/**
|
|
3627
3699
|
FetchStrategy is an 'Enum' that determines how and where entities are retrieved from as a result of a query.
|
|
3628
3700
|
**/
|
|
3629
3701
|
class FetchStrategy extends BreezeEnum {
|
|
3702
|
+
/**
|
|
3703
|
+
FromServer is used to tell the query to execute the query against a remote data source on the server.
|
|
3704
|
+
**/
|
|
3705
|
+
static FromServer = new FetchStrategy();
|
|
3706
|
+
/**
|
|
3707
|
+
FromLocalCache is used to tell the query to execute the query against a local EntityManager instead of going to a remote server.
|
|
3708
|
+
**/
|
|
3709
|
+
static FromLocalCache = new FetchStrategy();
|
|
3630
3710
|
}
|
|
3631
|
-
/**
|
|
3632
|
-
FromServer is used to tell the query to execute the query against a remote data source on the server.
|
|
3633
|
-
**/
|
|
3634
|
-
FetchStrategy.FromServer = new FetchStrategy();
|
|
3635
|
-
/**
|
|
3636
|
-
FromLocalCache is used to tell the query to execute the query against a local EntityManager instead of going to a remote server.
|
|
3637
|
-
**/
|
|
3638
|
-
FetchStrategy.FromLocalCache = new FetchStrategy();
|
|
3639
3711
|
FetchStrategy.prototype._$typeName = "FetchStrategy";
|
|
3640
3712
|
Error['x'] = FetchStrategy.resolveSymbols();
|
|
3641
3713
|
/**
|
|
3642
3714
|
A QueryOptions instance is used to specify the 'options' under which a query will occur.
|
|
3643
3715
|
**/
|
|
3644
3716
|
class QueryOptions {
|
|
3717
|
+
/**
|
|
3718
|
+
The default instance for use whenever QueryOptions are not specified.
|
|
3719
|
+
**/
|
|
3720
|
+
static defaultInstance = new QueryOptions({
|
|
3721
|
+
fetchStrategy: FetchStrategy.FromServer,
|
|
3722
|
+
mergeStrategy: MergeStrategy.PreserveChanges,
|
|
3723
|
+
includeDeleted: false
|
|
3724
|
+
});
|
|
3645
3725
|
/**
|
|
3646
3726
|
QueryOptions constructor
|
|
3647
3727
|
> var newQo = new QueryOptions( { mergeStrategy: MergeStrategy.OverwriteChanges });
|
|
@@ -3727,14 +3807,6 @@ class QueryOptions {
|
|
|
3727
3807
|
return obj;
|
|
3728
3808
|
}
|
|
3729
3809
|
}
|
|
3730
|
-
/**
|
|
3731
|
-
The default instance for use whenever QueryOptions are not specified.
|
|
3732
|
-
**/
|
|
3733
|
-
QueryOptions.defaultInstance = new QueryOptions({
|
|
3734
|
-
fetchStrategy: FetchStrategy.FromServer,
|
|
3735
|
-
mergeStrategy: MergeStrategy.PreserveChanges,
|
|
3736
|
-
includeDeleted: false
|
|
3737
|
-
});
|
|
3738
3810
|
QueryOptions.prototype._$typeName = "QueryOptions";
|
|
3739
3811
|
|
|
3740
3812
|
/**
|
|
@@ -4131,6 +4203,7 @@ function updateAliasMap(aliasMap, opStr, op) {
|
|
|
4131
4203
|
@hidden @internal
|
|
4132
4204
|
*/
|
|
4133
4205
|
class PassthruPredicate extends Predicate {
|
|
4206
|
+
value;
|
|
4134
4207
|
constructor(value) {
|
|
4135
4208
|
super();
|
|
4136
4209
|
this.value = value;
|
|
@@ -4142,6 +4215,7 @@ Error['x'] = PassthruPredicate.prototype._initialize('passthruPredicate');
|
|
|
4142
4215
|
@hidden
|
|
4143
4216
|
*/
|
|
4144
4217
|
class UnaryPredicate extends Predicate {
|
|
4218
|
+
pred;
|
|
4145
4219
|
constructor(op, ...args) {
|
|
4146
4220
|
super();
|
|
4147
4221
|
this.op = this._resolveOp(op);
|
|
@@ -4159,6 +4233,10 @@ Error['x'] = UnaryPredicate.prototype._initialize('unaryPredicate', {
|
|
|
4159
4233
|
@hidden
|
|
4160
4234
|
*/
|
|
4161
4235
|
class BinaryPredicate extends Predicate {
|
|
4236
|
+
expr1Source;
|
|
4237
|
+
expr2Source;
|
|
4238
|
+
expr1;
|
|
4239
|
+
expr2;
|
|
4162
4240
|
constructor(op, expr1, expr2) {
|
|
4163
4241
|
super();
|
|
4164
4242
|
// 5 public props op, expr1Source, expr2Source, expr1, expr2
|
|
@@ -4227,6 +4305,7 @@ Error['x'] = BinaryPredicate.prototype._initialize('binaryPredicate', {
|
|
|
4227
4305
|
@hidden
|
|
4228
4306
|
*/
|
|
4229
4307
|
class AndOrPredicate extends Predicate {
|
|
4308
|
+
preds;
|
|
4230
4309
|
constructor(op, preds) {
|
|
4231
4310
|
super();
|
|
4232
4311
|
this.op = this._resolveOp(op);
|
|
@@ -4262,6 +4341,10 @@ Error['x'] = AndOrPredicate.prototype._initialize("andOrPredicate", {
|
|
|
4262
4341
|
@hidden
|
|
4263
4342
|
*/
|
|
4264
4343
|
class AnyAllPredicate extends Predicate {
|
|
4344
|
+
/** @internal */
|
|
4345
|
+
expr;
|
|
4346
|
+
exprSource;
|
|
4347
|
+
pred;
|
|
4265
4348
|
// 4 public props: op, exprSource, expr, pred
|
|
4266
4349
|
constructor(op, expr, pred) {
|
|
4267
4350
|
super();
|
|
@@ -4285,6 +4368,9 @@ Error['x'] = AnyAllPredicate.prototype._initialize("anyAllPredicate", {
|
|
|
4285
4368
|
});
|
|
4286
4369
|
/** @hidden */
|
|
4287
4370
|
class PredicateExpression {
|
|
4371
|
+
visitorMethodName;
|
|
4372
|
+
visit; // TODO
|
|
4373
|
+
dataType;
|
|
4288
4374
|
constructor(visitorMethodName) {
|
|
4289
4375
|
this.visitorMethodName = visitorMethodName;
|
|
4290
4376
|
// give expressions the Predicate prototype method
|
|
@@ -4300,6 +4386,8 @@ class PredicateExpression {
|
|
|
4300
4386
|
@hidden
|
|
4301
4387
|
*/
|
|
4302
4388
|
class LitExpr extends PredicateExpression {
|
|
4389
|
+
value;
|
|
4390
|
+
hasExplicitDataType;
|
|
4303
4391
|
// 2 public props: value, dataType
|
|
4304
4392
|
constructor(value, dataType, hasExplicitDataType) {
|
|
4305
4393
|
super("litExpr");
|
|
@@ -4348,6 +4436,7 @@ function resolveDataType(dataType) {
|
|
|
4348
4436
|
@hidden
|
|
4349
4437
|
*/
|
|
4350
4438
|
class PropExpr extends PredicateExpression {
|
|
4439
|
+
propertyPath;
|
|
4351
4440
|
// two public props: propertyPath, dateType
|
|
4352
4441
|
constructor(propertyPath) {
|
|
4353
4442
|
super('propExpr');
|
|
@@ -4381,6 +4470,9 @@ class PropExpr extends PredicateExpression {
|
|
|
4381
4470
|
@hidden @dynamic
|
|
4382
4471
|
*/
|
|
4383
4472
|
class FnExpr extends PredicateExpression {
|
|
4473
|
+
fnName;
|
|
4474
|
+
exprs;
|
|
4475
|
+
localFn; // TODO:
|
|
4384
4476
|
constructor(fnName, exprs) {
|
|
4385
4477
|
super('fnExpr');
|
|
4386
4478
|
// 4 public props: fnName, exprs, localFn, dataType
|
|
@@ -4404,109 +4496,109 @@ class FnExpr extends PredicateExpression {
|
|
|
4404
4496
|
expr._validate(entityType, usesNameOnServer);
|
|
4405
4497
|
});
|
|
4406
4498
|
}
|
|
4499
|
+
static _funcMap = {
|
|
4500
|
+
toupper: {
|
|
4501
|
+
fn: function (source) {
|
|
4502
|
+
return source.toUpperCase();
|
|
4503
|
+
}, dataType: DataType.String
|
|
4504
|
+
},
|
|
4505
|
+
tolower: {
|
|
4506
|
+
fn: function (source) {
|
|
4507
|
+
return source.toLowerCase();
|
|
4508
|
+
}, dataType: DataType.String
|
|
4509
|
+
},
|
|
4510
|
+
substring: {
|
|
4511
|
+
fn: function (source, pos, length) {
|
|
4512
|
+
return source.substring(pos, length);
|
|
4513
|
+
}, dataType: DataType.String
|
|
4514
|
+
},
|
|
4515
|
+
substringof: {
|
|
4516
|
+
fn: function (find, source) {
|
|
4517
|
+
return source.indexOf(find) >= 0;
|
|
4518
|
+
}, dataType: DataType.Boolean
|
|
4519
|
+
},
|
|
4520
|
+
length: {
|
|
4521
|
+
fn: function (source) {
|
|
4522
|
+
return source.length;
|
|
4523
|
+
}, dataType: DataType.Int32
|
|
4524
|
+
},
|
|
4525
|
+
trim: {
|
|
4526
|
+
fn: function (source) {
|
|
4527
|
+
return source.trim();
|
|
4528
|
+
}, dataType: DataType.String
|
|
4529
|
+
},
|
|
4530
|
+
concat: {
|
|
4531
|
+
fn: function (s1, s2) {
|
|
4532
|
+
return s1.concat(s2);
|
|
4533
|
+
}, dataType: DataType.String
|
|
4534
|
+
},
|
|
4535
|
+
replace: {
|
|
4536
|
+
fn: function (source, find, replace) {
|
|
4537
|
+
return source.replace(find, replace);
|
|
4538
|
+
}, dataType: DataType.String
|
|
4539
|
+
},
|
|
4540
|
+
startswith: {
|
|
4541
|
+
fn: function (source, find) {
|
|
4542
|
+
return core.stringStartsWith(source, find);
|
|
4543
|
+
}, dataType: DataType.Boolean
|
|
4544
|
+
},
|
|
4545
|
+
endswith: {
|
|
4546
|
+
fn: function (source, find) {
|
|
4547
|
+
return core.stringEndsWith(source, find);
|
|
4548
|
+
}, dataType: DataType.Boolean
|
|
4549
|
+
},
|
|
4550
|
+
indexof: {
|
|
4551
|
+
fn: function (source, find) {
|
|
4552
|
+
return source.indexOf(find);
|
|
4553
|
+
}, dataType: DataType.Int32
|
|
4554
|
+
},
|
|
4555
|
+
round: {
|
|
4556
|
+
fn: function (source) {
|
|
4557
|
+
return Math.round(source);
|
|
4558
|
+
}, dataType: DataType.Int32
|
|
4559
|
+
},
|
|
4560
|
+
ceiling: {
|
|
4561
|
+
fn: function (source) {
|
|
4562
|
+
return Math.ceil(source);
|
|
4563
|
+
}, dataType: DataType.Int32
|
|
4564
|
+
},
|
|
4565
|
+
floor: {
|
|
4566
|
+
fn: function (source) {
|
|
4567
|
+
return Math.floor(source);
|
|
4568
|
+
}, dataType: DataType.Int32
|
|
4569
|
+
},
|
|
4570
|
+
second: {
|
|
4571
|
+
fn: function (source) {
|
|
4572
|
+
return source.getSeconds();
|
|
4573
|
+
}, dataType: DataType.Int32
|
|
4574
|
+
},
|
|
4575
|
+
minute: {
|
|
4576
|
+
fn: function (source) {
|
|
4577
|
+
return source.getMinutes();
|
|
4578
|
+
}, dataType: DataType.Int32
|
|
4579
|
+
},
|
|
4580
|
+
hour: {
|
|
4581
|
+
fn: function (source) {
|
|
4582
|
+
return source.getHours();
|
|
4583
|
+
}, dataType: DataType.Int32
|
|
4584
|
+
},
|
|
4585
|
+
day: {
|
|
4586
|
+
fn: function (source) {
|
|
4587
|
+
return source.getDate();
|
|
4588
|
+
}, dataType: DataType.Int32
|
|
4589
|
+
},
|
|
4590
|
+
month: {
|
|
4591
|
+
fn: function (source) {
|
|
4592
|
+
return source.getMonth() + 1;
|
|
4593
|
+
}, dataType: DataType.Int32
|
|
4594
|
+
},
|
|
4595
|
+
year: {
|
|
4596
|
+
fn: function (source) {
|
|
4597
|
+
return source.getFullYear();
|
|
4598
|
+
}, dataType: DataType.Int32
|
|
4599
|
+
}
|
|
4600
|
+
};
|
|
4407
4601
|
}
|
|
4408
|
-
FnExpr._funcMap = {
|
|
4409
|
-
toupper: {
|
|
4410
|
-
fn: function (source) {
|
|
4411
|
-
return source.toUpperCase();
|
|
4412
|
-
}, dataType: DataType.String
|
|
4413
|
-
},
|
|
4414
|
-
tolower: {
|
|
4415
|
-
fn: function (source) {
|
|
4416
|
-
return source.toLowerCase();
|
|
4417
|
-
}, dataType: DataType.String
|
|
4418
|
-
},
|
|
4419
|
-
substring: {
|
|
4420
|
-
fn: function (source, pos, length) {
|
|
4421
|
-
return source.substring(pos, length);
|
|
4422
|
-
}, dataType: DataType.String
|
|
4423
|
-
},
|
|
4424
|
-
substringof: {
|
|
4425
|
-
fn: function (find, source) {
|
|
4426
|
-
return source.indexOf(find) >= 0;
|
|
4427
|
-
}, dataType: DataType.Boolean
|
|
4428
|
-
},
|
|
4429
|
-
length: {
|
|
4430
|
-
fn: function (source) {
|
|
4431
|
-
return source.length;
|
|
4432
|
-
}, dataType: DataType.Int32
|
|
4433
|
-
},
|
|
4434
|
-
trim: {
|
|
4435
|
-
fn: function (source) {
|
|
4436
|
-
return source.trim();
|
|
4437
|
-
}, dataType: DataType.String
|
|
4438
|
-
},
|
|
4439
|
-
concat: {
|
|
4440
|
-
fn: function (s1, s2) {
|
|
4441
|
-
return s1.concat(s2);
|
|
4442
|
-
}, dataType: DataType.String
|
|
4443
|
-
},
|
|
4444
|
-
replace: {
|
|
4445
|
-
fn: function (source, find, replace) {
|
|
4446
|
-
return source.replace(find, replace);
|
|
4447
|
-
}, dataType: DataType.String
|
|
4448
|
-
},
|
|
4449
|
-
startswith: {
|
|
4450
|
-
fn: function (source, find) {
|
|
4451
|
-
return core.stringStartsWith(source, find);
|
|
4452
|
-
}, dataType: DataType.Boolean
|
|
4453
|
-
},
|
|
4454
|
-
endswith: {
|
|
4455
|
-
fn: function (source, find) {
|
|
4456
|
-
return core.stringEndsWith(source, find);
|
|
4457
|
-
}, dataType: DataType.Boolean
|
|
4458
|
-
},
|
|
4459
|
-
indexof: {
|
|
4460
|
-
fn: function (source, find) {
|
|
4461
|
-
return source.indexOf(find);
|
|
4462
|
-
}, dataType: DataType.Int32
|
|
4463
|
-
},
|
|
4464
|
-
round: {
|
|
4465
|
-
fn: function (source) {
|
|
4466
|
-
return Math.round(source);
|
|
4467
|
-
}, dataType: DataType.Int32
|
|
4468
|
-
},
|
|
4469
|
-
ceiling: {
|
|
4470
|
-
fn: function (source) {
|
|
4471
|
-
return Math.ceil(source);
|
|
4472
|
-
}, dataType: DataType.Int32
|
|
4473
|
-
},
|
|
4474
|
-
floor: {
|
|
4475
|
-
fn: function (source) {
|
|
4476
|
-
return Math.floor(source);
|
|
4477
|
-
}, dataType: DataType.Int32
|
|
4478
|
-
},
|
|
4479
|
-
second: {
|
|
4480
|
-
fn: function (source) {
|
|
4481
|
-
return source.getSeconds();
|
|
4482
|
-
}, dataType: DataType.Int32
|
|
4483
|
-
},
|
|
4484
|
-
minute: {
|
|
4485
|
-
fn: function (source) {
|
|
4486
|
-
return source.getMinutes();
|
|
4487
|
-
}, dataType: DataType.Int32
|
|
4488
|
-
},
|
|
4489
|
-
hour: {
|
|
4490
|
-
fn: function (source) {
|
|
4491
|
-
return source.getHours();
|
|
4492
|
-
}, dataType: DataType.Int32
|
|
4493
|
-
},
|
|
4494
|
-
day: {
|
|
4495
|
-
fn: function (source) {
|
|
4496
|
-
return source.getDate();
|
|
4497
|
-
}, dataType: DataType.Int32
|
|
4498
|
-
},
|
|
4499
|
-
month: {
|
|
4500
|
-
fn: function (source) {
|
|
4501
|
-
return source.getMonth() + 1;
|
|
4502
|
-
}, dataType: DataType.Int32
|
|
4503
|
-
},
|
|
4504
|
-
year: {
|
|
4505
|
-
fn: function (source) {
|
|
4506
|
-
return source.getFullYear();
|
|
4507
|
-
}, dataType: DataType.Int32
|
|
4508
|
-
}
|
|
4509
|
-
};
|
|
4510
4602
|
// TODO: add dataTypes for the args next - will help to infer other dataTypes.
|
|
4511
4603
|
let RX_IDENTIFIER = /^[a-z_][\w.$]*$/i;
|
|
4512
4604
|
// comma delimited expressions ignoring commas inside of both single and double quotes.
|
|
@@ -4636,104 +4728,103 @@ function parseFnExpr(source, parts, tokens, exprContext) {
|
|
|
4636
4728
|
throw e;
|
|
4637
4729
|
}
|
|
4638
4730
|
}
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
}
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
return
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4731
|
+
// toFunctionVisitor
|
|
4732
|
+
let toFunctionVisitor = {
|
|
4733
|
+
isExtended: false,
|
|
4734
|
+
passthruPredicate: function () {
|
|
4735
|
+
throw new Error("Cannot execute an PassthruPredicate expression against the local cache: " + this.value);
|
|
4736
|
+
},
|
|
4737
|
+
unaryPredicate: function (context) {
|
|
4738
|
+
let predFn = this.pred.visit(context);
|
|
4739
|
+
switch (this.op.key) {
|
|
4740
|
+
case "not":
|
|
4741
|
+
return function (entity) {
|
|
4742
|
+
return !predFn(entity);
|
|
4743
|
+
};
|
|
4744
|
+
default:
|
|
4745
|
+
throw new Error("Invalid unary operator:" + this.op.key);
|
|
4746
|
+
}
|
|
4747
|
+
},
|
|
4748
|
+
binaryPredicate: function (context) {
|
|
4749
|
+
let expr1Fn = this.expr1.visit(context);
|
|
4750
|
+
let expr2Fn = this.expr2.visit(context);
|
|
4751
|
+
let dataType = this.expr1.dataType || this.expr2.dataType;
|
|
4752
|
+
let lqco = context.entityType.metadataStore.localQueryComparisonOptions;
|
|
4753
|
+
let predFn = getBinaryPredicateFn(this, dataType, lqco);
|
|
4754
|
+
if (predFn == null) {
|
|
4755
|
+
throw new Error("Invalid binaryPredicate operator:" + this.op.key);
|
|
4756
|
+
}
|
|
4757
|
+
return function (entity) {
|
|
4758
|
+
return predFn(expr1Fn(entity), expr2Fn(entity));
|
|
4759
|
+
};
|
|
4760
|
+
},
|
|
4761
|
+
andOrPredicate: function (context) {
|
|
4762
|
+
let predFns = this.preds.map((pred) => {
|
|
4763
|
+
return pred.visit(context);
|
|
4764
|
+
});
|
|
4765
|
+
switch (this.op.key) {
|
|
4766
|
+
case "and":
|
|
4767
|
+
return function (entity) {
|
|
4768
|
+
let result = predFns.reduce(function (prev, cur) {
|
|
4769
|
+
return prev && cur(entity);
|
|
4770
|
+
}, true);
|
|
4771
|
+
return result;
|
|
4772
|
+
};
|
|
4773
|
+
case "or":
|
|
4774
|
+
return function (entity) {
|
|
4775
|
+
let result = predFns.reduce(function (prev, cur) {
|
|
4776
|
+
return prev || cur(entity);
|
|
4777
|
+
}, false);
|
|
4778
|
+
return result;
|
|
4779
|
+
};
|
|
4780
|
+
default:
|
|
4781
|
+
throw new Error("Invalid boolean operator:" + this.op.key);
|
|
4782
|
+
}
|
|
4783
|
+
},
|
|
4784
|
+
anyAllPredicate: function (context) {
|
|
4785
|
+
let exprFn = this.expr.visit(context);
|
|
4786
|
+
let newContext = core.extend({}, context);
|
|
4787
|
+
newContext.entityType = this.expr.dataType;
|
|
4788
|
+
let predFn = this.pred.visit(newContext);
|
|
4789
|
+
let anyAllPredFn = getAnyAllPredicateFn(this.op);
|
|
4790
|
+
return function (entity) {
|
|
4791
|
+
return anyAllPredFn(exprFn(entity), predFn);
|
|
4792
|
+
};
|
|
4793
|
+
},
|
|
4794
|
+
litExpr: function () {
|
|
4795
|
+
let value = this.value;
|
|
4796
|
+
return function (entity) {
|
|
4797
|
+
return value;
|
|
4798
|
+
};
|
|
4799
|
+
},
|
|
4800
|
+
propExpr: function () {
|
|
4801
|
+
let propertyPath = this.propertyPath;
|
|
4802
|
+
let properties = propertyPath.split('.');
|
|
4803
|
+
if (properties.length === 1) {
|
|
4669
4804
|
return function (entity) {
|
|
4670
|
-
|
|
4671
|
-
return prev && cur(entity);
|
|
4672
|
-
}, true);
|
|
4673
|
-
return result;
|
|
4805
|
+
return entity.getProperty(propertyPath);
|
|
4674
4806
|
};
|
|
4675
|
-
|
|
4807
|
+
}
|
|
4808
|
+
else {
|
|
4676
4809
|
return function (entity) {
|
|
4677
|
-
|
|
4678
|
-
return prev || cur(entity);
|
|
4679
|
-
}, false);
|
|
4680
|
-
return result;
|
|
4810
|
+
return EntityAspect.getPropertyPathValue(entity, properties);
|
|
4681
4811
|
};
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
let predFn = this.pred.visit(newContext);
|
|
4690
|
-
let anyAllPredFn = getAnyAllPredicateFn(this.op);
|
|
4691
|
-
return function (entity) {
|
|
4692
|
-
return anyAllPredFn(exprFn(entity), predFn);
|
|
4693
|
-
};
|
|
4694
|
-
}, ɵ5 = function () {
|
|
4695
|
-
let value = this.value;
|
|
4696
|
-
return function (entity) {
|
|
4697
|
-
return value;
|
|
4698
|
-
};
|
|
4699
|
-
}, ɵ6 = function () {
|
|
4700
|
-
let propertyPath = this.propertyPath;
|
|
4701
|
-
let properties = propertyPath.split('.');
|
|
4702
|
-
if (properties.length === 1) {
|
|
4703
|
-
return function (entity) {
|
|
4704
|
-
return entity.getProperty(propertyPath);
|
|
4705
|
-
};
|
|
4706
|
-
}
|
|
4707
|
-
else {
|
|
4812
|
+
}
|
|
4813
|
+
},
|
|
4814
|
+
fnExpr: function (context) {
|
|
4815
|
+
let exprFns = this.exprs.map(function (expr) {
|
|
4816
|
+
return expr.visit(context);
|
|
4817
|
+
});
|
|
4818
|
+
let that = this;
|
|
4708
4819
|
return function (entity) {
|
|
4709
|
-
|
|
4820
|
+
let values = exprFns.map(function (exprFn) {
|
|
4821
|
+
let value = exprFn(entity);
|
|
4822
|
+
return value;
|
|
4823
|
+
});
|
|
4824
|
+
let result = that.localFn.apply(null, values);
|
|
4825
|
+
return result;
|
|
4710
4826
|
};
|
|
4711
4827
|
}
|
|
4712
|
-
}, ɵ7 = function (context) {
|
|
4713
|
-
let exprFns = this.exprs.map(function (expr) {
|
|
4714
|
-
return expr.visit(context);
|
|
4715
|
-
});
|
|
4716
|
-
let that = this;
|
|
4717
|
-
return function (entity) {
|
|
4718
|
-
let values = exprFns.map(function (exprFn) {
|
|
4719
|
-
let value = exprFn(entity);
|
|
4720
|
-
return value;
|
|
4721
|
-
});
|
|
4722
|
-
let result = that.localFn.apply(null, values);
|
|
4723
|
-
return result;
|
|
4724
|
-
};
|
|
4725
|
-
};
|
|
4726
|
-
// toFunctionVisitor
|
|
4727
|
-
let toFunctionVisitor = {
|
|
4728
|
-
isExtended: false,
|
|
4729
|
-
passthruPredicate: ɵ0$2,
|
|
4730
|
-
unaryPredicate: ɵ1$1,
|
|
4731
|
-
binaryPredicate: ɵ2,
|
|
4732
|
-
andOrPredicate: ɵ3,
|
|
4733
|
-
anyAllPredicate: ɵ4,
|
|
4734
|
-
litExpr: ɵ5,
|
|
4735
|
-
propExpr: ɵ6,
|
|
4736
|
-
fnExpr: ɵ7
|
|
4737
4828
|
};
|
|
4738
4829
|
function getAnyAllPredicateFn(op) {
|
|
4739
4830
|
switch (op.key) {
|
|
@@ -4800,12 +4891,12 @@ function getBinaryPredicateFn(binaryPredicate, dataType, lqco) {
|
|
|
4800
4891
|
break;
|
|
4801
4892
|
case 'startswith':
|
|
4802
4893
|
predFn = function (v1, v2) {
|
|
4803
|
-
return stringStartsWith
|
|
4894
|
+
return stringStartsWith(v1, v2, lqco);
|
|
4804
4895
|
};
|
|
4805
4896
|
break;
|
|
4806
4897
|
case 'endswith':
|
|
4807
4898
|
predFn = function (v1, v2) {
|
|
4808
|
-
return stringEndsWith
|
|
4899
|
+
return stringEndsWith(v1, v2, lqco);
|
|
4809
4900
|
};
|
|
4810
4901
|
break;
|
|
4811
4902
|
case 'contains':
|
|
@@ -4841,14 +4932,14 @@ function stringEquals(a, b, lqco) {
|
|
|
4841
4932
|
}
|
|
4842
4933
|
return a === b;
|
|
4843
4934
|
}
|
|
4844
|
-
function stringStartsWith
|
|
4935
|
+
function stringStartsWith(a, b, lqco) {
|
|
4845
4936
|
if (!lqco.isCaseSensitive) {
|
|
4846
4937
|
a = (a || "").toLowerCase();
|
|
4847
4938
|
b = (b || "").toLowerCase();
|
|
4848
4939
|
}
|
|
4849
4940
|
return core.stringStartsWith(a, b);
|
|
4850
4941
|
}
|
|
4851
|
-
function stringEndsWith
|
|
4942
|
+
function stringEndsWith(a, b, lqco) {
|
|
4852
4943
|
if (!lqco.isCaseSensitive) {
|
|
4853
4944
|
a = (a || "").toLowerCase();
|
|
4854
4945
|
b = (b || "").toLowerCase();
|
|
@@ -4862,94 +4953,93 @@ function stringContains(a, b, lqco) {
|
|
|
4862
4953
|
}
|
|
4863
4954
|
return a.indexOf(b) >= 0;
|
|
4864
4955
|
}
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4956
|
+
// toJSONVisitor
|
|
4957
|
+
let toJSONVisitor = {
|
|
4958
|
+
passthruPredicate: function () {
|
|
4959
|
+
return this.value;
|
|
4960
|
+
},
|
|
4961
|
+
unaryPredicate: function (context) {
|
|
4962
|
+
let predVal = this.pred.visit(context);
|
|
4963
|
+
let json = {};
|
|
4964
|
+
json[this.op.key] = predVal;
|
|
4965
|
+
return json;
|
|
4966
|
+
},
|
|
4967
|
+
binaryPredicate: function (context) {
|
|
4968
|
+
let expr1Val = this.expr1.visit(context);
|
|
4969
|
+
let expr2Val = this.expr2.visit(context);
|
|
4970
|
+
let json = {};
|
|
4971
|
+
if (this.expr2 instanceof PropExpr) {
|
|
4972
|
+
expr2Val = { value: expr2Val, isProperty: true };
|
|
4973
|
+
}
|
|
4974
|
+
if (this.op.key === "eq") {
|
|
4975
|
+
json[expr1Val] = expr2Val;
|
|
4976
|
+
}
|
|
4977
|
+
else {
|
|
4978
|
+
let value = {};
|
|
4979
|
+
json[expr1Val] = value;
|
|
4980
|
+
value[this.op.key] = expr2Val;
|
|
4981
|
+
}
|
|
4982
|
+
return json;
|
|
4983
|
+
},
|
|
4984
|
+
andOrPredicate: function (context) {
|
|
4985
|
+
let predVals = this.preds.map(function (pred) {
|
|
4986
|
+
return pred.visit(context);
|
|
4987
|
+
});
|
|
4988
|
+
if (!predVals || !predVals.length) {
|
|
4989
|
+
return {};
|
|
4990
|
+
}
|
|
4991
|
+
let json;
|
|
4992
|
+
// normalizeAnd clauses if possible.
|
|
4993
|
+
// passthru predicate will appear as string and their 'ands' can't be 'normalized'
|
|
4994
|
+
if (this.op.key === 'and' && predVals.length === 2 && !predVals.some((v) => v.or || typeof (v) === 'string')) {
|
|
4995
|
+
// normalize 'and' clauses - will return null if can't be combined.
|
|
4996
|
+
json = predVals.reduce(combine);
|
|
4997
|
+
}
|
|
4998
|
+
if (json == null) {
|
|
4999
|
+
json = {};
|
|
5000
|
+
json[this.op.key] = predVals;
|
|
5001
|
+
}
|
|
5002
|
+
return json;
|
|
5003
|
+
},
|
|
5004
|
+
anyAllPredicate: function (context) {
|
|
5005
|
+
let exprVal = this.expr.visit(context);
|
|
5006
|
+
let newContext = core.extend({}, context);
|
|
5007
|
+
newContext.entityType = this.expr.dataType;
|
|
5008
|
+
let predVal = this.pred.visit(newContext);
|
|
5009
|
+
let json = {};
|
|
4883
5010
|
let value = {};
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
}, ɵ12 = function (context) {
|
|
4908
|
-
let exprVal = this.expr.visit(context);
|
|
4909
|
-
let newContext = core.extend({}, context);
|
|
4910
|
-
newContext.entityType = this.expr.dataType;
|
|
4911
|
-
let predVal = this.pred.visit(newContext);
|
|
4912
|
-
let json = {};
|
|
4913
|
-
let value = {};
|
|
4914
|
-
value[this.op.key] = predVal;
|
|
4915
|
-
json[exprVal] = value;
|
|
4916
|
-
return json;
|
|
4917
|
-
}, ɵ13 = function (context) {
|
|
4918
|
-
// special handling for DateOnly because it serializes improperly
|
|
4919
|
-
const value = (this.dataType === DataType.DateOnly) ? DataType.toDateOnlyString(this.value) : this.value;
|
|
4920
|
-
if (this.hasExplicitDataType || context.useExplicitDataType) {
|
|
4921
|
-
return { value: value, dataType: this.dataType.name };
|
|
4922
|
-
}
|
|
4923
|
-
else {
|
|
4924
|
-
return value;
|
|
4925
|
-
}
|
|
4926
|
-
}, ɵ14 = function (context) {
|
|
4927
|
-
if (context.toNameOnServer) {
|
|
4928
|
-
if (!context.entityType) {
|
|
4929
|
-
console.warn(`No EntityType for propertyPath "${this.propertyPath}". ${core.strings.TO_TYPE}`);
|
|
5011
|
+
value[this.op.key] = predVal;
|
|
5012
|
+
json[exprVal] = value;
|
|
5013
|
+
return json;
|
|
5014
|
+
},
|
|
5015
|
+
litExpr: function (context) {
|
|
5016
|
+
// special handling for DateOnly because it serializes improperly
|
|
5017
|
+
const value = (this.dataType === DataType.DateOnly) ? DataType.toDateOnlyString(this.value) : this.value;
|
|
5018
|
+
if (this.hasExplicitDataType || context.useExplicitDataType) {
|
|
5019
|
+
return { value: value, dataType: this.dataType.name };
|
|
5020
|
+
}
|
|
5021
|
+
else {
|
|
5022
|
+
return value;
|
|
5023
|
+
}
|
|
5024
|
+
},
|
|
5025
|
+
propExpr: function (context) {
|
|
5026
|
+
if (context.toNameOnServer) {
|
|
5027
|
+
if (!context.entityType) {
|
|
5028
|
+
console.warn(`No EntityType for propertyPath "${this.propertyPath}". ${core.strings.TO_TYPE}`);
|
|
5029
|
+
return this.propertyPath;
|
|
5030
|
+
}
|
|
5031
|
+
return context.entityType.clientPropertyPathToServer(this.propertyPath);
|
|
5032
|
+
}
|
|
5033
|
+
else {
|
|
4930
5034
|
return this.propertyPath;
|
|
4931
5035
|
}
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
5036
|
+
},
|
|
5037
|
+
fnExpr: function (context) {
|
|
5038
|
+
let exprVals = this.exprs.map(function (expr) {
|
|
5039
|
+
return expr.visit(context);
|
|
5040
|
+
});
|
|
5041
|
+
return this.fnName + "(" + exprVals.join(",") + ")";
|
|
4936
5042
|
}
|
|
4937
|
-
}, ɵ15 = function (context) {
|
|
4938
|
-
let exprVals = this.exprs.map(function (expr) {
|
|
4939
|
-
return expr.visit(context);
|
|
4940
|
-
});
|
|
4941
|
-
return this.fnName + "(" + exprVals.join(",") + ")";
|
|
4942
|
-
};
|
|
4943
|
-
// toJSONVisitor
|
|
4944
|
-
let toJSONVisitor = {
|
|
4945
|
-
passthruPredicate: ɵ8,
|
|
4946
|
-
unaryPredicate: ɵ9,
|
|
4947
|
-
binaryPredicate: ɵ10,
|
|
4948
|
-
andOrPredicate: ɵ11,
|
|
4949
|
-
anyAllPredicate: ɵ12,
|
|
4950
|
-
litExpr: ɵ13,
|
|
4951
|
-
propExpr: ɵ14,
|
|
4952
|
-
fnExpr: ɵ15
|
|
4953
5043
|
};
|
|
4954
5044
|
function combine(j1, j2) {
|
|
4955
5045
|
let ok = Object.keys(j2).every(function (key) {
|
|
@@ -5521,6 +5611,28 @@ class EntityQuery {
|
|
|
5521
5611
|
q = q.where(pred).toType(entityKey.entityType);
|
|
5522
5612
|
return q;
|
|
5523
5613
|
}
|
|
5614
|
+
/**
|
|
5615
|
+
Creates an EntityQuery for the specified entity and [[NavigationProperty]].
|
|
5616
|
+
> // 'employee' is a previously queried employee
|
|
5617
|
+
> let ordersNavProp = employee.entityType.getProperty("Orders");
|
|
5618
|
+
> let query = EntityQuery.fromEntityNavigation(employee, ordersNavProp);
|
|
5619
|
+
|
|
5620
|
+
will return a query for the "Orders" of the specified 'employee'.
|
|
5621
|
+
@param entity - The Entity whose navigation property will be queried.
|
|
5622
|
+
@param navigationProperty - The [[NavigationProperty]] or name of the NavigationProperty to be queried.
|
|
5623
|
+
**/
|
|
5624
|
+
static fromEntityNavigation = function (entity, navigationProperty) {
|
|
5625
|
+
assertParam(entity, "entity").isEntity().check();
|
|
5626
|
+
let navProperty = entity.entityType._checkNavProperty(navigationProperty);
|
|
5627
|
+
let q = new EntityQuery(navProperty.entityType.defaultResourceName);
|
|
5628
|
+
let pred = buildNavigationPredicate(entity, navProperty);
|
|
5629
|
+
if (pred == null) {
|
|
5630
|
+
throw new Error("Unable to create a NavigationQuery for navigationProperty: " + navProperty.name);
|
|
5631
|
+
}
|
|
5632
|
+
q = q.where(pred);
|
|
5633
|
+
let em = entity.entityAspect.entityManager;
|
|
5634
|
+
return em ? q.using(em) : q;
|
|
5635
|
+
};
|
|
5524
5636
|
// protected methods
|
|
5525
5637
|
/** @hidden @internal */
|
|
5526
5638
|
_getFromEntityType(metadataStore, throwErrorIfNotFound) {
|
|
@@ -5592,28 +5704,6 @@ class EntityQuery {
|
|
|
5592
5704
|
return ds.uriBuilder.buildUri(this, em.metadataStore);
|
|
5593
5705
|
}
|
|
5594
5706
|
}
|
|
5595
|
-
/**
|
|
5596
|
-
Creates an EntityQuery for the specified entity and [[NavigationProperty]].
|
|
5597
|
-
> // 'employee' is a previously queried employee
|
|
5598
|
-
> let ordersNavProp = employee.entityType.getProperty("Orders");
|
|
5599
|
-
> let query = EntityQuery.fromEntityNavigation(employee, ordersNavProp);
|
|
5600
|
-
|
|
5601
|
-
will return a query for the "Orders" of the specified 'employee'.
|
|
5602
|
-
@param entity - The Entity whose navigation property will be queried.
|
|
5603
|
-
@param navigationProperty - The [[NavigationProperty]] or name of the NavigationProperty to be queried.
|
|
5604
|
-
**/
|
|
5605
|
-
EntityQuery.fromEntityNavigation = function (entity, navigationProperty) {
|
|
5606
|
-
assertParam(entity, "entity").isEntity().check();
|
|
5607
|
-
let navProperty = entity.entityType._checkNavProperty(navigationProperty);
|
|
5608
|
-
let q = new EntityQuery(navProperty.entityType.defaultResourceName);
|
|
5609
|
-
let pred = buildNavigationPredicate(entity, navProperty);
|
|
5610
|
-
if (pred == null) {
|
|
5611
|
-
throw new Error("Unable to create a NavigationQuery for navigationProperty: " + navProperty.name);
|
|
5612
|
-
}
|
|
5613
|
-
q = q.where(pred);
|
|
5614
|
-
let em = entity.entityAspect.entityManager;
|
|
5615
|
-
return em ? q.using(em) : q;
|
|
5616
|
-
};
|
|
5617
5707
|
EntityQuery.prototype._$typeName = "EntityQuery";
|
|
5618
5708
|
// private functions
|
|
5619
5709
|
function fromJSON(eq, json) {
|
|
@@ -5755,33 +5845,33 @@ FilterQueryOp is an 'Enum' containing all of the valid [[Predicate]]
|
|
|
5755
5845
|
filter operators for an [[EntityQuery]].
|
|
5756
5846
|
**/
|
|
5757
5847
|
class FilterQueryOp extends BreezeEnum {
|
|
5848
|
+
/** Aliases: "eq", "==" **/
|
|
5849
|
+
static Equals = new FilterQueryOp({ operator: "eq" });
|
|
5850
|
+
/** Aliases: "ne", "!=" **/
|
|
5851
|
+
static NotEquals = new FilterQueryOp({ operator: "ne" });
|
|
5852
|
+
/** Aliases: "gt", ">" **/
|
|
5853
|
+
static GreaterThan = new FilterQueryOp({ operator: "gt" });
|
|
5854
|
+
/** Aliases: "lt", "<" **/
|
|
5855
|
+
static LessThan = new FilterQueryOp({ operator: "lt" });
|
|
5856
|
+
/** Aliases: "ge", ">=" **/
|
|
5857
|
+
static GreaterThanOrEqual = new FilterQueryOp({ operator: "ge" });
|
|
5858
|
+
/** Aliases: "le", "<=" **/
|
|
5859
|
+
static LessThanOrEqual = new FilterQueryOp({ operator: "le" });
|
|
5860
|
+
/** String operation: Is a string a substring of another string. Aliases: "substringof" **/
|
|
5861
|
+
static Contains = new FilterQueryOp({ operator: "contains" });
|
|
5862
|
+
/** No aliases */
|
|
5863
|
+
static StartsWith = new FilterQueryOp({ operator: "startswith" });
|
|
5864
|
+
/** No aliases */
|
|
5865
|
+
static EndsWith = new FilterQueryOp({ operator: "endswith" });
|
|
5866
|
+
/** Aliases: "some" **/
|
|
5867
|
+
static Any = new FilterQueryOp({ operator: "any" });
|
|
5868
|
+
/** Aliases: "every" **/
|
|
5869
|
+
static All = new FilterQueryOp({ operator: "all" });
|
|
5870
|
+
/** No aliases */
|
|
5871
|
+
static In = new FilterQueryOp({ operator: "in" });
|
|
5872
|
+
/** No aliases */
|
|
5873
|
+
static IsTypeOf = new FilterQueryOp({ operator: "isof" });
|
|
5758
5874
|
}
|
|
5759
|
-
/** Aliases: "eq", "==" **/
|
|
5760
|
-
FilterQueryOp.Equals = new FilterQueryOp({ operator: "eq" });
|
|
5761
|
-
/** Aliases: "ne", "!=" **/
|
|
5762
|
-
FilterQueryOp.NotEquals = new FilterQueryOp({ operator: "ne" });
|
|
5763
|
-
/** Aliases: "gt", ">" **/
|
|
5764
|
-
FilterQueryOp.GreaterThan = new FilterQueryOp({ operator: "gt" });
|
|
5765
|
-
/** Aliases: "lt", "<" **/
|
|
5766
|
-
FilterQueryOp.LessThan = new FilterQueryOp({ operator: "lt" });
|
|
5767
|
-
/** Aliases: "ge", ">=" **/
|
|
5768
|
-
FilterQueryOp.GreaterThanOrEqual = new FilterQueryOp({ operator: "ge" });
|
|
5769
|
-
/** Aliases: "le", "<=" **/
|
|
5770
|
-
FilterQueryOp.LessThanOrEqual = new FilterQueryOp({ operator: "le" });
|
|
5771
|
-
/** String operation: Is a string a substring of another string. Aliases: "substringof" **/
|
|
5772
|
-
FilterQueryOp.Contains = new FilterQueryOp({ operator: "contains" });
|
|
5773
|
-
/** No aliases */
|
|
5774
|
-
FilterQueryOp.StartsWith = new FilterQueryOp({ operator: "startswith" });
|
|
5775
|
-
/** No aliases */
|
|
5776
|
-
FilterQueryOp.EndsWith = new FilterQueryOp({ operator: "endswith" });
|
|
5777
|
-
/** Aliases: "some" **/
|
|
5778
|
-
FilterQueryOp.Any = new FilterQueryOp({ operator: "any" });
|
|
5779
|
-
/** Aliases: "every" **/
|
|
5780
|
-
FilterQueryOp.All = new FilterQueryOp({ operator: "all" });
|
|
5781
|
-
/** No aliases */
|
|
5782
|
-
FilterQueryOp.In = new FilterQueryOp({ operator: "in" });
|
|
5783
|
-
/** No aliases */
|
|
5784
|
-
FilterQueryOp.IsTypeOf = new FilterQueryOp({ operator: "isof" });
|
|
5785
5875
|
FilterQueryOp.prototype._$typeName = "FilterQueryOp";
|
|
5786
5876
|
Error['x'] = FilterQueryOp.resolveSymbols();
|
|
5787
5877
|
/**
|
|
@@ -5789,10 +5879,10 @@ Error['x'] = FilterQueryOp.resolveSymbols();
|
|
|
5789
5879
|
operators for an [[EntityQuery]].
|
|
5790
5880
|
**/
|
|
5791
5881
|
class BooleanQueryOp extends BreezeEnum {
|
|
5882
|
+
static And = new BooleanQueryOp({ operator: "and" });
|
|
5883
|
+
static Or = new BooleanQueryOp({ operator: "or" });
|
|
5884
|
+
static Not = new BooleanQueryOp({ operator: "not" });
|
|
5792
5885
|
}
|
|
5793
|
-
BooleanQueryOp.And = new BooleanQueryOp({ operator: "and" });
|
|
5794
|
-
BooleanQueryOp.Or = new BooleanQueryOp({ operator: "or" });
|
|
5795
|
-
BooleanQueryOp.Not = new BooleanQueryOp({ operator: "not" });
|
|
5796
5886
|
BooleanQueryOp.prototype._$typeName = "BooleanQueryOp";
|
|
5797
5887
|
Error['x'] = BooleanQueryOp.resolveSymbols();
|
|
5798
5888
|
/** For use by breeze plugin authors only. The class is used in most [[IUriBuilderAdapter]] implementations
|
|
@@ -5813,6 +5903,8 @@ or
|
|
|
5813
5903
|
> let obc = new OrderByClause("Company.CompanyName, LastName", true);
|
|
5814
5904
|
*/
|
|
5815
5905
|
class OrderByClause {
|
|
5906
|
+
/** @hidden @internal */
|
|
5907
|
+
items;
|
|
5816
5908
|
constructor(propertyPaths, isDesc) {
|
|
5817
5909
|
if (propertyPaths.length === 0) {
|
|
5818
5910
|
throw new Error("OrderByClause cannot be empty");
|
|
@@ -5859,6 +5951,9 @@ class OrderByClause {
|
|
|
5859
5951
|
}
|
|
5860
5952
|
/** @hidden @internal */
|
|
5861
5953
|
class OrderByItem {
|
|
5954
|
+
propertyPath;
|
|
5955
|
+
isDesc;
|
|
5956
|
+
lastProperty;
|
|
5862
5957
|
constructor(propertyPath, isDesc) {
|
|
5863
5958
|
if (!(typeof propertyPath === 'string')) {
|
|
5864
5959
|
throw new Error("propertyPath is not a string");
|
|
@@ -5934,6 +6029,9 @@ class OrderByItem {
|
|
|
5934
6029
|
@hidden
|
|
5935
6030
|
**/
|
|
5936
6031
|
class SelectClause {
|
|
6032
|
+
propertyPaths;
|
|
6033
|
+
/** @hidden @internal */
|
|
6034
|
+
_pathNames;
|
|
5937
6035
|
constructor(propertyPaths) {
|
|
5938
6036
|
this.propertyPaths = propertyPaths;
|
|
5939
6037
|
this._pathNames = propertyPaths.map(function (pp) {
|
|
@@ -5969,6 +6067,7 @@ class SelectClause {
|
|
|
5969
6067
|
@hidden
|
|
5970
6068
|
**/
|
|
5971
6069
|
class ExpandClause {
|
|
6070
|
+
propertyPaths;
|
|
5972
6071
|
constructor(propertyPaths) {
|
|
5973
6072
|
this.propertyPaths = propertyPaths;
|
|
5974
6073
|
}
|
|
@@ -5994,53 +6093,96 @@ a query, import or [[EntityManager.createEntity]] call.
|
|
|
5994
6093
|
|
|
5995
6094
|
**/
|
|
5996
6095
|
class EntityAspect {
|
|
6096
|
+
/** The Entity that this aspect is associated with. __Read Only__ **/
|
|
6097
|
+
entity;
|
|
6098
|
+
/** The [[EntityManager]] that contains this entity. __Read Only__ **/
|
|
6099
|
+
entityManager;
|
|
6100
|
+
/** @hidden @internal */
|
|
6101
|
+
entityGroup;
|
|
6102
|
+
/** The [[EntityState]] of this entity. __Read Only__ **/
|
|
6103
|
+
entityState;
|
|
6104
|
+
/** Whether this entity is in the process of being saved. __Read Only__ */
|
|
6105
|
+
isBeingSaved;
|
|
6106
|
+
/** The 'original values' of this entity where they are different from the 'current values'.
|
|
6107
|
+
This is a map where the key is a property name and the value is the 'original value' of the property. */
|
|
6108
|
+
originalValues;
|
|
6109
|
+
/** Whether this entity has any validation errors. __Read Only__ */
|
|
6110
|
+
hasValidationErrors;
|
|
6111
|
+
/** Whether this entity has a temporary [[EntityKey]]. */
|
|
6112
|
+
hasTempKey;
|
|
6113
|
+
/** Whether this entity was created by being loaded from the database */
|
|
6114
|
+
wasLoaded;
|
|
6115
|
+
/** Extra metadata about this entity such as the entity's etag.
|
|
6116
|
+
You may extend this object with your own metadata information.
|
|
6117
|
+
Breeze (de)serializes this object when importing/exporting the entity. **/
|
|
6118
|
+
extraMetadata;
|
|
6119
|
+
/**
|
|
6120
|
+
A [[BreezeEvent]] that fires whenever any of the validation errors on this entity change.
|
|
6121
|
+
Note that this might be the removal of an error when some data on the entity is fixed.
|
|
6122
|
+
@eventArgs -
|
|
6123
|
+
- entity - The entity on which the validation errors are being added or removed.
|
|
6124
|
+
- added - An array containing any newly added [[ValidationError]]s
|
|
6125
|
+
- removed - An array containing any newly removed [[ValidationError]]s. This is those
|
|
6126
|
+
errors that have been 'fixed'.
|
|
6127
|
+
|
|
6128
|
+
> // assume order is an order entity attached to an EntityManager.
|
|
6129
|
+
> order.entityAspect.validationErrorsChanged.subscribe(
|
|
6130
|
+
> function (validationChangeArgs) {
|
|
6131
|
+
> // this code will be executed anytime a property value changes on the 'order' entity.
|
|
6132
|
+
> var entity == validationChangeArgs.entity; // Note: entity === order
|
|
6133
|
+
> var errorsAdded = validationChangeArgs.added;
|
|
6134
|
+
> var errorsCleared = validationChangeArgs.removed;
|
|
6135
|
+
> });
|
|
6136
|
+
@event
|
|
6137
|
+
**/
|
|
6138
|
+
validationErrorsChanged;
|
|
6139
|
+
/**
|
|
6140
|
+
A [[BreezeEvent]] that fires whenever a value of one of this entity's properties change.
|
|
6141
|
+
@eventArgs -
|
|
6142
|
+
- entity - The entity whose property has changed.
|
|
6143
|
+
- property - The [[DataProperty]] that changed.
|
|
6144
|
+
- propertyName - The name of the property that changed. This value will be 'null' for operations that replace the entire entity. This includes
|
|
6145
|
+
queries, imports and saves that require a merge. The remaining parameters will not exist in this case either. This will actually be a "property path"
|
|
6146
|
+
for any properties of a complex type.
|
|
6147
|
+
- oldValue - The old value of this property before the change.
|
|
6148
|
+
- newValue - The new value of this property after the change.
|
|
6149
|
+
- parent - The immediate parent object for the changed property. This will be a ComplexType instance as opposed to an Entity
|
|
6150
|
+
for any complex type or nested complex type properties.
|
|
6151
|
+
|
|
6152
|
+
> // assume order is an order entity attached to an EntityManager.
|
|
6153
|
+
> order.entityAspect.propertyChanged.subscribe(
|
|
6154
|
+
> function (propertyChangedArgs) {
|
|
6155
|
+
> // this code will be executed anytime a property value changes on the 'order' entity.
|
|
6156
|
+
> var entity = propertyChangedArgs.entity; // Note: entity === order
|
|
6157
|
+
> var propertyNameChanged = propertyChangedArgs.propertyName;
|
|
6158
|
+
> var oldValue = propertyChangedArgs.oldValue;
|
|
6159
|
+
> var newValue = propertyChangedArgs.newValue;
|
|
6160
|
+
> });
|
|
6161
|
+
@event
|
|
6162
|
+
**/
|
|
6163
|
+
propertyChanged;
|
|
6164
|
+
/** @hidden @internal */
|
|
6165
|
+
_validationErrors;
|
|
6166
|
+
/** @hidden @internal */
|
|
6167
|
+
_pendingValidationResult;
|
|
6168
|
+
/** @hidden @internal */
|
|
6169
|
+
_entityKey;
|
|
6170
|
+
/** @hidden @internal */
|
|
6171
|
+
_loadedNps;
|
|
6172
|
+
/** @hidden @internal */
|
|
6173
|
+
_initialized;
|
|
6174
|
+
/** @hidden @internal */
|
|
6175
|
+
_inProcess; // used in defaultPropertyInterceptor for temp storage.
|
|
6176
|
+
/** @hidden @internal */
|
|
6177
|
+
_inProcessEntity; // used in EntityManager
|
|
6178
|
+
/** @hidden @internal */
|
|
6179
|
+
static _nullInstance = new EntityAspect(); // TODO: determine if this works
|
|
5997
6180
|
/** @hidden @internal */
|
|
5998
6181
|
constructor(entity) {
|
|
5999
6182
|
// if called without new
|
|
6000
6183
|
// if (!(this instanceof EntityAspect)) {
|
|
6001
6184
|
// return new EntityAspect(entity);
|
|
6002
6185
|
// }
|
|
6003
|
-
/**
|
|
6004
|
-
Sets the entity to an EntityState of 'Unchanged'. This is also the equivalent of calling [[EntityAspect.acceptChanges]].
|
|
6005
|
-
The same operation can be performed by calling [[EntityAspect.setEntityState]].
|
|
6006
|
-
> // assume order is an order entity attached to an EntityManager.
|
|
6007
|
-
> order.entityAspect.setUnchanged();
|
|
6008
|
-
> // The 'order' entity will now be in an 'Unchanged' state with any changes committed.
|
|
6009
|
-
**/
|
|
6010
|
-
this.setUnchanged = function () {
|
|
6011
|
-
return this.setEntityState(EntityState.Unchanged);
|
|
6012
|
-
};
|
|
6013
|
-
/**
|
|
6014
|
-
Sets the entity to an EntityState of 'Modified'. This can also be achieved by changing the value of any property on an 'Unchanged' entity.
|
|
6015
|
-
The same operation can be performed by calling [[EntityAspect.setEntityState]].
|
|
6016
|
-
> // assume order is an order entity attached to an EntityManager.
|
|
6017
|
-
> order.entityAspect.setModified();
|
|
6018
|
-
> // The 'order' entity will now be in a 'Modified' state.
|
|
6019
|
-
**/
|
|
6020
|
-
this.setModified = function () {
|
|
6021
|
-
return this.setEntityState(EntityState.Modified);
|
|
6022
|
-
};
|
|
6023
|
-
/**
|
|
6024
|
-
Sets the entity to an EntityState of 'Deleted'. This both marks the entity as being scheduled for deletion during the next 'Save' call
|
|
6025
|
-
but also removes the entity from all of its related entities. If the current entityState is 'Added', then `setDeleted()` will mark it 'Detached'
|
|
6026
|
-
The same operation can be performed by calling [[EntityAspect.setEntityState]].
|
|
6027
|
-
> // assume order is an order entity attached to an EntityManager.
|
|
6028
|
-
> order.entityAspect.setDeleted();
|
|
6029
|
-
> // The 'order' entity will now be in a 'Deleted' state and it will no longer have any 'related' entities.
|
|
6030
|
-
**/
|
|
6031
|
-
this.setDeleted = function () {
|
|
6032
|
-
return this.setEntityState(EntityState.Deleted);
|
|
6033
|
-
};
|
|
6034
|
-
/**
|
|
6035
|
-
Sets the entity to an EntityState of 'Detached'. This removes the entity from all of its related entities, but does NOT change the EntityState of any existing entities.
|
|
6036
|
-
The same operation can be performed by calling [[EntityAspect.setEntityState]].
|
|
6037
|
-
> // assume order is an order entity attached to an EntityManager.
|
|
6038
|
-
> order.entityAspect.setDetached();
|
|
6039
|
-
> // The 'order' entity will now be in a 'Detached' state and it will no longer have any 'related' entities.
|
|
6040
|
-
**/
|
|
6041
|
-
this.setDetached = function () {
|
|
6042
|
-
return this.setEntityState(EntityState.Detached);
|
|
6043
|
-
};
|
|
6044
6186
|
this.entity = entity;
|
|
6045
6187
|
// TODO: keep public or not?
|
|
6046
6188
|
this.entityGroup = undefined;
|
|
@@ -6197,9 +6339,50 @@ class EntityAspect {
|
|
|
6197
6339
|
> order.entityAspect.setAdded();
|
|
6198
6340
|
> // The 'order' entity will now be in an 'Added' state.
|
|
6199
6341
|
**/
|
|
6200
|
-
setAdded() {
|
|
6201
|
-
return this.setEntityState(EntityState.Added);
|
|
6202
|
-
}
|
|
6342
|
+
setAdded() {
|
|
6343
|
+
return this.setEntityState(EntityState.Added);
|
|
6344
|
+
}
|
|
6345
|
+
/**
|
|
6346
|
+
Sets the entity to an EntityState of 'Unchanged'. This is also the equivalent of calling [[EntityAspect.acceptChanges]].
|
|
6347
|
+
The same operation can be performed by calling [[EntityAspect.setEntityState]].
|
|
6348
|
+
> // assume order is an order entity attached to an EntityManager.
|
|
6349
|
+
> order.entityAspect.setUnchanged();
|
|
6350
|
+
> // The 'order' entity will now be in an 'Unchanged' state with any changes committed.
|
|
6351
|
+
**/
|
|
6352
|
+
setUnchanged = function () {
|
|
6353
|
+
return this.setEntityState(EntityState.Unchanged);
|
|
6354
|
+
};
|
|
6355
|
+
/**
|
|
6356
|
+
Sets the entity to an EntityState of 'Modified'. This can also be achieved by changing the value of any property on an 'Unchanged' entity.
|
|
6357
|
+
The same operation can be performed by calling [[EntityAspect.setEntityState]].
|
|
6358
|
+
> // assume order is an order entity attached to an EntityManager.
|
|
6359
|
+
> order.entityAspect.setModified();
|
|
6360
|
+
> // The 'order' entity will now be in a 'Modified' state.
|
|
6361
|
+
**/
|
|
6362
|
+
setModified = function () {
|
|
6363
|
+
return this.setEntityState(EntityState.Modified);
|
|
6364
|
+
};
|
|
6365
|
+
/**
|
|
6366
|
+
Sets the entity to an EntityState of 'Deleted'. This both marks the entity as being scheduled for deletion during the next 'Save' call
|
|
6367
|
+
but also removes the entity from all of its related entities. If the current entityState is 'Added', then `setDeleted()` will mark it 'Detached'
|
|
6368
|
+
The same operation can be performed by calling [[EntityAspect.setEntityState]].
|
|
6369
|
+
> // assume order is an order entity attached to an EntityManager.
|
|
6370
|
+
> order.entityAspect.setDeleted();
|
|
6371
|
+
> // The 'order' entity will now be in a 'Deleted' state and it will no longer have any 'related' entities.
|
|
6372
|
+
**/
|
|
6373
|
+
setDeleted = function () {
|
|
6374
|
+
return this.setEntityState(EntityState.Deleted);
|
|
6375
|
+
};
|
|
6376
|
+
/**
|
|
6377
|
+
Sets the entity to an EntityState of 'Detached'. This removes the entity from all of its related entities, but does NOT change the EntityState of any existing entities.
|
|
6378
|
+
The same operation can be performed by calling [[EntityAspect.setEntityState]].
|
|
6379
|
+
> // assume order is an order entity attached to an EntityManager.
|
|
6380
|
+
> order.entityAspect.setDetached();
|
|
6381
|
+
> // The 'order' entity will now be in a 'Detached' state and it will no longer have any 'related' entities.
|
|
6382
|
+
**/
|
|
6383
|
+
setDetached = function () {
|
|
6384
|
+
return this.setEntityState(EntityState.Detached);
|
|
6385
|
+
};
|
|
6203
6386
|
/**
|
|
6204
6387
|
Sets the entity to the specified EntityState. See also 'setUnchanged', 'setModified', 'setDetached', etc.
|
|
6205
6388
|
> // assume order is an order entity attached to an EntityManager.
|
|
@@ -6217,12 +6400,12 @@ class EntityAspect {
|
|
|
6217
6400
|
let em = this.entityManager;
|
|
6218
6401
|
let needsSave = true;
|
|
6219
6402
|
if (entityState === EntityState.Unchanged) {
|
|
6220
|
-
clearOriginalValues(entity);
|
|
6403
|
+
clearOriginalValues$1(entity);
|
|
6221
6404
|
delete this.hasTempKey;
|
|
6222
6405
|
needsSave = false;
|
|
6223
6406
|
}
|
|
6224
6407
|
else if (entityState === EntityState.Added) {
|
|
6225
|
-
clearOriginalValues(entity);
|
|
6408
|
+
clearOriginalValues$1(entity);
|
|
6226
6409
|
// TODO: more to do here... like regenerating key ???
|
|
6227
6410
|
}
|
|
6228
6411
|
else if (entityState === EntityState.Deleted) {
|
|
@@ -6563,8 +6746,6 @@ class EntityAspect {
|
|
|
6563
6746
|
}
|
|
6564
6747
|
}
|
|
6565
6748
|
}
|
|
6566
|
-
/** @hidden @internal */
|
|
6567
|
-
EntityAspect._nullInstance = new EntityAspect(); // TODO: determine if this works
|
|
6568
6749
|
BreezeEvent.bubbleEvent(EntityAspect.prototype, function () {
|
|
6569
6750
|
return this.entityManager;
|
|
6570
6751
|
});
|
|
@@ -6698,6 +6879,17 @@ entity via either a query, import or EntityManager.createEntity call.
|
|
|
6698
6879
|
> // aCustomer === aspect.parent;
|
|
6699
6880
|
**/
|
|
6700
6881
|
class ComplexAspect {
|
|
6882
|
+
/** The complex object that this aspect is associated with. __Read Only__ */
|
|
6883
|
+
complexObject;
|
|
6884
|
+
/** The 'original values' of this complex object where they are different from the 'current values'.
|
|
6885
|
+
This is a map where the key is a property name and the value is the 'original value' of the property.
|
|
6886
|
+
__Read Only__ */
|
|
6887
|
+
originalValues;
|
|
6888
|
+
/** The parent object that to which this aspect belongs; this will either be an entity or another complex object. __Read Only__ */
|
|
6889
|
+
parent;
|
|
6890
|
+
/** The [[DataProperty]] on the 'parent' that contains this complex object. __Read Only__ */
|
|
6891
|
+
parentProperty;
|
|
6892
|
+
extraMetadata;
|
|
6701
6893
|
/** You will rarely, if ever, create a ComplexAspect directly. */
|
|
6702
6894
|
constructor(complexObject, parent, parentProperty) {
|
|
6703
6895
|
if (!complexObject) {
|
|
@@ -6757,18 +6949,18 @@ class ComplexAspect {
|
|
|
6757
6949
|
return aspect.getPropertyPath(this.parentProperty.name + "." + propName);
|
|
6758
6950
|
}
|
|
6759
6951
|
}
|
|
6760
|
-
function clearOriginalValues(target) {
|
|
6952
|
+
function clearOriginalValues$1(target) {
|
|
6761
6953
|
let aspect = target.entityAspect || target.complexAspect;
|
|
6762
6954
|
aspect.originalValues = {};
|
|
6763
6955
|
let stype = target.entityType || target.complexType;
|
|
6764
6956
|
stype.complexProperties.forEach(function (cp) {
|
|
6765
6957
|
let cos = target.getProperty(cp.name);
|
|
6766
6958
|
if (cp.isScalar) {
|
|
6767
|
-
clearOriginalValues(cos);
|
|
6959
|
+
clearOriginalValues$1(cos);
|
|
6768
6960
|
}
|
|
6769
6961
|
else {
|
|
6770
6962
|
cos._acceptChanges();
|
|
6771
|
-
cos.forEach(clearOriginalValues);
|
|
6963
|
+
cos.forEach(clearOriginalValues$1);
|
|
6772
6964
|
}
|
|
6773
6965
|
});
|
|
6774
6966
|
}
|
|
@@ -6781,6 +6973,10 @@ The default NamingConvention does not perform any translation, it simply passes
|
|
|
6781
6973
|
@dynamic
|
|
6782
6974
|
**/
|
|
6783
6975
|
class NamingConvention {
|
|
6976
|
+
/** Function that takes a server property name add converts it into a client side property name. __Read Only__ */
|
|
6977
|
+
serverPropertyNameToClient;
|
|
6978
|
+
/** Function that takes a client property name add converts it into a server side property name. __Read Only__ */
|
|
6979
|
+
clientPropertyNameToServer;
|
|
6784
6980
|
/**
|
|
6785
6981
|
NamingConvention constructor
|
|
6786
6982
|
> // A naming convention that converts the first character of every property name to uppercase on the server
|
|
@@ -6808,6 +7004,38 @@ class NamingConvention {
|
|
|
6808
7004
|
config._storeObject(this, "NamingConvention", this.name);
|
|
6809
7005
|
}
|
|
6810
7006
|
/**
|
|
7007
|
+
|
|
7008
|
+
|
|
7009
|
+
/**
|
|
7010
|
+
A noop naming convention - This is the default unless another is specified.
|
|
7011
|
+
**/
|
|
7012
|
+
static none = new NamingConvention({
|
|
7013
|
+
name: "noChange",
|
|
7014
|
+
serverPropertyNameToClient: (serverPropertyName) => {
|
|
7015
|
+
return serverPropertyName;
|
|
7016
|
+
},
|
|
7017
|
+
clientPropertyNameToServer: (clientPropertyName) => {
|
|
7018
|
+
return clientPropertyName;
|
|
7019
|
+
}
|
|
7020
|
+
});
|
|
7021
|
+
/**
|
|
7022
|
+
The "camelCase" naming convention - This implementation only lowercases the first character of the server property name
|
|
7023
|
+
but leaves the rest of the property name intact. If a more complicated version is needed then one should be created via the ctor.
|
|
7024
|
+
**/
|
|
7025
|
+
static camelCase = new NamingConvention({
|
|
7026
|
+
name: "camelCase",
|
|
7027
|
+
serverPropertyNameToClient: (serverPropertyName) => {
|
|
7028
|
+
return serverPropertyName.substr(0, 1).toLowerCase() + serverPropertyName.substr(1);
|
|
7029
|
+
},
|
|
7030
|
+
clientPropertyNameToServer: (clientPropertyName) => {
|
|
7031
|
+
return clientPropertyName.substr(0, 1).toUpperCase() + clientPropertyName.substr(1);
|
|
7032
|
+
}
|
|
7033
|
+
});
|
|
7034
|
+
/**
|
|
7035
|
+
The default value whenever NamingConventions are not specified.
|
|
7036
|
+
**/
|
|
7037
|
+
static defaultInstance = new NamingConvention(NamingConvention.none);
|
|
7038
|
+
/**
|
|
6811
7039
|
Sets the 'defaultInstance' by creating a copy of the current 'defaultInstance' and then applying all of the properties of the current instance.
|
|
6812
7040
|
The current instance is returned unchanged.
|
|
6813
7041
|
> var namingConv = new NamingConvention({
|
|
@@ -6824,38 +7052,6 @@ class NamingConvention {
|
|
|
6824
7052
|
return core.setAsDefault(this, NamingConvention);
|
|
6825
7053
|
}
|
|
6826
7054
|
}
|
|
6827
|
-
/**
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
/**
|
|
6831
|
-
A noop naming convention - This is the default unless another is specified.
|
|
6832
|
-
**/
|
|
6833
|
-
NamingConvention.none = new NamingConvention({
|
|
6834
|
-
name: "noChange",
|
|
6835
|
-
serverPropertyNameToClient: (serverPropertyName) => {
|
|
6836
|
-
return serverPropertyName;
|
|
6837
|
-
},
|
|
6838
|
-
clientPropertyNameToServer: (clientPropertyName) => {
|
|
6839
|
-
return clientPropertyName;
|
|
6840
|
-
}
|
|
6841
|
-
});
|
|
6842
|
-
/**
|
|
6843
|
-
The "camelCase" naming convention - This implementation only lowercases the first character of the server property name
|
|
6844
|
-
but leaves the rest of the property name intact. If a more complicated version is needed then one should be created via the ctor.
|
|
6845
|
-
**/
|
|
6846
|
-
NamingConvention.camelCase = new NamingConvention({
|
|
6847
|
-
name: "camelCase",
|
|
6848
|
-
serverPropertyNameToClient: (serverPropertyName) => {
|
|
6849
|
-
return serverPropertyName.substr(0, 1).toLowerCase() + serverPropertyName.substr(1);
|
|
6850
|
-
},
|
|
6851
|
-
clientPropertyNameToServer: (clientPropertyName) => {
|
|
6852
|
-
return clientPropertyName.substr(0, 1).toUpperCase() + clientPropertyName.substr(1);
|
|
6853
|
-
}
|
|
6854
|
-
});
|
|
6855
|
-
/**
|
|
6856
|
-
The default value whenever NamingConventions are not specified.
|
|
6857
|
-
**/
|
|
6858
|
-
NamingConvention.defaultInstance = new NamingConvention(NamingConvention.none);
|
|
6859
7055
|
NamingConvention.prototype._$typeName = "NamingConvention";
|
|
6860
7056
|
|
|
6861
7057
|
const RX_COLLECTION = /Collection\((.*)\)/;
|
|
@@ -7275,6 +7471,18 @@ class LocalQueryComparisonOptions {
|
|
|
7275
7471
|
config._storeObject(this, "LocalQueryComparisonOptions", this.name);
|
|
7276
7472
|
}
|
|
7277
7473
|
/**
|
|
7474
|
+
Case insensitive SQL compliant options - this is also the default unless otherwise changed.
|
|
7475
|
+
**/
|
|
7476
|
+
static caseInsensitiveSQL = new LocalQueryComparisonOptions({
|
|
7477
|
+
name: "caseInsensitiveSQL",
|
|
7478
|
+
isCaseSensitive: false,
|
|
7479
|
+
usesSql92CompliantStringComparison: true
|
|
7480
|
+
});
|
|
7481
|
+
/**
|
|
7482
|
+
The default value whenever LocalQueryComparisonOptions are not specified. By default this is 'caseInsensitiveSQL'.
|
|
7483
|
+
**/
|
|
7484
|
+
static defaultInstance = new LocalQueryComparisonOptions(LocalQueryComparisonOptions.caseInsensitiveSQL);
|
|
7485
|
+
/**
|
|
7278
7486
|
Sets the 'defaultInstance' by creating a copy of the current 'defaultInstance' and then applying all of the properties of the current instance.
|
|
7279
7487
|
The current instance is returned unchanged.
|
|
7280
7488
|
> var lqco = new LocalQueryComparisonOptions({
|
|
@@ -7287,18 +7495,6 @@ class LocalQueryComparisonOptions {
|
|
|
7287
7495
|
return core.setAsDefault(this, LocalQueryComparisonOptions);
|
|
7288
7496
|
}
|
|
7289
7497
|
}
|
|
7290
|
-
/**
|
|
7291
|
-
Case insensitive SQL compliant options - this is also the default unless otherwise changed.
|
|
7292
|
-
**/
|
|
7293
|
-
LocalQueryComparisonOptions.caseInsensitiveSQL = new LocalQueryComparisonOptions({
|
|
7294
|
-
name: "caseInsensitiveSQL",
|
|
7295
|
-
isCaseSensitive: false,
|
|
7296
|
-
usesSql92CompliantStringComparison: true
|
|
7297
|
-
});
|
|
7298
|
-
/**
|
|
7299
|
-
The default value whenever LocalQueryComparisonOptions are not specified. By default this is 'caseInsensitiveSQL'.
|
|
7300
|
-
**/
|
|
7301
|
-
LocalQueryComparisonOptions.defaultInstance = new LocalQueryComparisonOptions(LocalQueryComparisonOptions.caseInsensitiveSQL);
|
|
7302
7498
|
LocalQueryComparisonOptions.prototype._$typeName = "LocalQueryComparisonOptions";
|
|
7303
7499
|
|
|
7304
7500
|
/** @hidden @internal */
|
|
@@ -7762,6 +7958,52 @@ explicit MetadataStore, the MetadataStore from the MetadataStore.defaultInstance
|
|
|
7762
7958
|
@dynamic
|
|
7763
7959
|
**/
|
|
7764
7960
|
class MetadataStore {
|
|
7961
|
+
/** @hidden @internal */
|
|
7962
|
+
static __id = 0;
|
|
7963
|
+
/** @hidden @internal */
|
|
7964
|
+
static ANONTYPE_PREFIX = "_IB_";
|
|
7965
|
+
/** The version of any MetadataStores created by this class */
|
|
7966
|
+
static metadataVersion = '1.0.5';
|
|
7967
|
+
name;
|
|
7968
|
+
dataServices;
|
|
7969
|
+
/** The [[NamingConvention]] associated with this MetadataStore. __Read Only__ */
|
|
7970
|
+
namingConvention;
|
|
7971
|
+
/** The [[LocalQueryComparisonOptions]] associated with this MetadataStore. __Read Only__ */
|
|
7972
|
+
localQueryComparisonOptions;
|
|
7973
|
+
serializerFn;
|
|
7974
|
+
/**
|
|
7975
|
+
An [[BreezeEvent]] that fires after a MetadataStore has completed fetching metadata from a remote service.
|
|
7976
|
+
|
|
7977
|
+
@eventArgs -
|
|
7978
|
+
- metadataStore - The MetadataStore into which the metadata was fetched.
|
|
7979
|
+
- dataService - The [[DataService]] that metadata was fetched from.
|
|
7980
|
+
- rawMetadata - {Object} The raw metadata returned from the service. (It will have already been processed by this point).
|
|
7981
|
+
> let ms = myEntityManager.metadataStore;
|
|
7982
|
+
> ms.metadataFetched.subscribe(function(args) {
|
|
7983
|
+
> let metadataStore = args.metadataStore;
|
|
7984
|
+
> let dataService = args.dataService;
|
|
7985
|
+
> });
|
|
7986
|
+
@event
|
|
7987
|
+
**/
|
|
7988
|
+
metadataFetched;
|
|
7989
|
+
/** @hidden @internal */
|
|
7990
|
+
_resourceEntityTypeMap;
|
|
7991
|
+
/** @hidden @internal */
|
|
7992
|
+
_entityTypeResourceMap;
|
|
7993
|
+
/** @hidden @internal key is qualified structuraltype name - value is structuralType. ( structural = entityType or complexType). */
|
|
7994
|
+
_structuralTypeMap;
|
|
7995
|
+
/** @hidden @internal key is shortName, value is qualified name - does not need to be serialized. **/
|
|
7996
|
+
_shortNameMap;
|
|
7997
|
+
/** @hidden @internal key is either short or qual type name - value is ctor; **/
|
|
7998
|
+
_ctorRegistry;
|
|
7999
|
+
/** @hidden @internal key is entityTypeName; value is array of nav props **/
|
|
8000
|
+
_incompleteTypeMap;
|
|
8001
|
+
/** @hidden @internal **/
|
|
8002
|
+
_incompleteComplexTypeMap;
|
|
8003
|
+
/** @hidden @internal { json: any, stype: StructuralType }[] | { entityType: EntityType, csdlEntityType: any }[] **/
|
|
8004
|
+
_deferredTypes;
|
|
8005
|
+
/** @hidden @internal **/
|
|
8006
|
+
_id;
|
|
7765
8007
|
/**
|
|
7766
8008
|
Constructs a new MetadataStore.
|
|
7767
8009
|
|
|
@@ -7801,6 +8043,10 @@ class MetadataStore {
|
|
|
7801
8043
|
this._id = MetadataStore.__id++;
|
|
7802
8044
|
this.metadataFetched = new BreezeEvent("metadataFetched", this);
|
|
7803
8045
|
}
|
|
8046
|
+
// needs to be made avail to dataService.xxx files
|
|
8047
|
+
static normalizeTypeName = core.memoize(function (rawTypeName) {
|
|
8048
|
+
return rawTypeName && MetadataStore.parseTypeName(rawTypeName).typeName;
|
|
8049
|
+
});
|
|
7804
8050
|
// for debugging use the line below instead.
|
|
7805
8051
|
//ctor.normalizeTypeName = function (rawTypeName) { return parseTypeName(rawTypeName).typeName; };
|
|
7806
8052
|
/**
|
|
@@ -8331,16 +8577,6 @@ class MetadataStore {
|
|
|
8331
8577
|
}
|
|
8332
8578
|
}
|
|
8333
8579
|
}
|
|
8334
|
-
/** @hidden @internal */
|
|
8335
|
-
MetadataStore.__id = 0;
|
|
8336
|
-
/** @hidden @internal */
|
|
8337
|
-
MetadataStore.ANONTYPE_PREFIX = "_IB_";
|
|
8338
|
-
/** The version of any MetadataStores created by this class */
|
|
8339
|
-
MetadataStore.metadataVersion = '1.0.5';
|
|
8340
|
-
// needs to be made avail to dataService.xxx files
|
|
8341
|
-
MetadataStore.normalizeTypeName = core.memoize(function (rawTypeName) {
|
|
8342
|
-
return rawTypeName && MetadataStore.parseTypeName(rawTypeName).typeName;
|
|
8343
|
-
});
|
|
8344
8580
|
MetadataStore.prototype._$typeName = "MetadataStore";
|
|
8345
8581
|
BreezeEvent.bubbleEvent(MetadataStore.prototype);
|
|
8346
8582
|
function getTypesFromMap(typeMap) {
|
|
@@ -8459,6 +8695,76 @@ function getQualifiedTypeName(metadataStore, structTypeName, throwIfNotFound) {
|
|
|
8459
8695
|
/** Container for all of the metadata about a specific type of Entity.
|
|
8460
8696
|
**/
|
|
8461
8697
|
class EntityType {
|
|
8698
|
+
/** @hidden @internal */
|
|
8699
|
+
static __nextAnonIx = 0;
|
|
8700
|
+
/** Always false for an EntityType. **/
|
|
8701
|
+
isComplexType = false;
|
|
8702
|
+
/** The [[MetadataStore]] that contains this EntityType. __Read Only__ **/
|
|
8703
|
+
metadataStore;
|
|
8704
|
+
/** The DataProperties (see [[DataProperty]] associated with this EntityType. __Read Only__ **/
|
|
8705
|
+
dataProperties;
|
|
8706
|
+
/** The NavigationProperties (see [[NavigationProperty]] associated with this EntityType. __Read Only__ **/
|
|
8707
|
+
navigationProperties;
|
|
8708
|
+
/**
|
|
8709
|
+
The DataProperties associated with this EntityType that make up it's [[EntityKey]]. __Read Only__ **/
|
|
8710
|
+
keyProperties;
|
|
8711
|
+
/** The DataProperties associated with this EntityType that are foreign key properties. __Read Only__ **/
|
|
8712
|
+
foreignKeyProperties;
|
|
8713
|
+
inverseForeignKeyProperties;
|
|
8714
|
+
/** The DataProperties associated with this EntityType that are concurrency properties. __Read Only__ **/
|
|
8715
|
+
concurrencyProperties;
|
|
8716
|
+
/** The DataProperties for this EntityType that contain instances of a [[ComplexType]]. __Read Only__ **/
|
|
8717
|
+
complexProperties;
|
|
8718
|
+
/** The DataProperties associated with this EntityType that are not mapped to any backend datastore. These are effectively free standing
|
|
8719
|
+
properties. __Read Only__ **/
|
|
8720
|
+
unmappedProperties;
|
|
8721
|
+
/** The fully qualified name of this EntityType. __Read Only__ **/
|
|
8722
|
+
name;
|
|
8723
|
+
/** The short, unqualified, name for this EntityType. __Read Only__ **/
|
|
8724
|
+
shortName;
|
|
8725
|
+
/** The namespace for this EntityType. __Read Only__ **/
|
|
8726
|
+
namespace;
|
|
8727
|
+
/** The name of this EntityType's base EntityType (if any) */
|
|
8728
|
+
baseTypeName;
|
|
8729
|
+
/** The base EntityType (if any) for this EntityType. __Read Only__ **/
|
|
8730
|
+
baseEntityType;
|
|
8731
|
+
subtypes;
|
|
8732
|
+
/** Whether this EntityType is abstract. __Read Only__ **/
|
|
8733
|
+
isAbstract;
|
|
8734
|
+
/** Whether this EntityType is anonymous. Anonymous types will never be communicated to or from the server. They are purely for
|
|
8735
|
+
client side use and are given an automatically generated name. __Read Only__ **/
|
|
8736
|
+
isAnonymous;
|
|
8737
|
+
/** Whether this EntityType has been 'frozen'. EntityTypes become frozen after the first instance
|
|
8738
|
+
of that type has been created and attached to an EntityManager. */
|
|
8739
|
+
isFrozen;
|
|
8740
|
+
/** The [[AutoGeneratedKeyType]] for this EntityType. __Read Only__ **/
|
|
8741
|
+
autoGeneratedKeyType;
|
|
8742
|
+
/** The default resource name associated with this EntityType. An EntityType may be queried via a variety of 'resource names' but this one
|
|
8743
|
+
is used as the default when no resource name is provided. This will occur when calling [[EntityAspect.loadNavigationProperty]]
|
|
8744
|
+
or when executing any [[EntityQuery]] that was created via an [[EntityKey]]. __Read Only__ **/
|
|
8745
|
+
defaultResourceName;
|
|
8746
|
+
/** A function that is used to customize the serialization of any EntityProperties of this type. */
|
|
8747
|
+
serializerFn;
|
|
8748
|
+
/** A free form object that can be used to define any custom metadata for this EntityType. __Read Only__ **/
|
|
8749
|
+
custom;
|
|
8750
|
+
/** The entity level validators associated with this EntityType. Validators can be added and
|
|
8751
|
+
removed from this collection. __Read Only__. **/
|
|
8752
|
+
validators;
|
|
8753
|
+
warnings;
|
|
8754
|
+
initFn;
|
|
8755
|
+
noTrackingFn;
|
|
8756
|
+
/** @hidden @internal */
|
|
8757
|
+
_extra;
|
|
8758
|
+
/** @hidden @internal */
|
|
8759
|
+
_ctor;
|
|
8760
|
+
/** @hidden @internal */
|
|
8761
|
+
_mappedPropertiesCount;
|
|
8762
|
+
/**
|
|
8763
|
+
@deprecated Use [[getCtor]] instead.
|
|
8764
|
+
*/
|
|
8765
|
+
getEntityCtor = this.getCtor;
|
|
8766
|
+
/** @hidden @internal */
|
|
8767
|
+
static qualifyTypeName = qualifyTypeName;
|
|
8462
8768
|
/** EntityType constructor
|
|
8463
8769
|
> let entityType = new EntityType( {
|
|
8464
8770
|
> shortName: "person",
|
|
@@ -8469,12 +8775,6 @@ class EntityType {
|
|
|
8469
8775
|
client side use and will be given an automatically generated name. Normally, however, you will use a configuration object.
|
|
8470
8776
|
**/
|
|
8471
8777
|
constructor(config) {
|
|
8472
|
-
/** Always false for an EntityType. **/
|
|
8473
|
-
this.isComplexType = false;
|
|
8474
|
-
/**
|
|
8475
|
-
@deprecated Use [[getCtor]] instead.
|
|
8476
|
-
*/
|
|
8477
|
-
this.getEntityCtor = this.getCtor;
|
|
8478
8778
|
if (arguments.length > 1) {
|
|
8479
8779
|
throw new Error("The EntityType ctor has a single argument that is either a 'MetadataStore' or a configuration object.");
|
|
8480
8780
|
}
|
|
@@ -9126,10 +9426,6 @@ class EntityType {
|
|
|
9126
9426
|
delete incompleteTypeMap[this.name];
|
|
9127
9427
|
}
|
|
9128
9428
|
}
|
|
9129
|
-
/** @hidden @internal */
|
|
9130
|
-
EntityType.__nextAnonIx = 0;
|
|
9131
|
-
/** @hidden @internal */
|
|
9132
|
-
EntityType.qualifyTypeName = qualifyTypeName;
|
|
9133
9429
|
EntityType.prototype._$typeName = "EntityType";
|
|
9134
9430
|
function getRawValueFromConfig(rawEntity, dp) {
|
|
9135
9431
|
// 'true' fork can happen if an initializer contains an actaul instance of an already created complex object.
|
|
@@ -9268,33 +9564,66 @@ function calcUnmappedProperties(stype, instance) {
|
|
|
9268
9564
|
@param config - Configuration settings
|
|
9269
9565
|
**/
|
|
9270
9566
|
class ComplexType {
|
|
9567
|
+
/** For polymorphic purpose only - always true here */
|
|
9568
|
+
isComplexType = true;
|
|
9569
|
+
/** The [[MetadataStore]] containing this ComplexType. */
|
|
9570
|
+
metadataStore;
|
|
9571
|
+
/** The fully qualifed name of this ComplexType. __Read Only__ **/
|
|
9572
|
+
name;
|
|
9573
|
+
/** The short, unqualified, name for this ComplexType. __Read Only__ **/
|
|
9574
|
+
shortName;
|
|
9575
|
+
/** The namespace for this ComplexType. __Read Only__ **/
|
|
9576
|
+
namespace;
|
|
9577
|
+
/** The DataProperties (see [[DataProperty]] associated with this ComplexType. __Read Only__ */
|
|
9578
|
+
dataProperties;
|
|
9579
|
+
/** The DataProperties for this ComplexType that contain instances of a [[ComplexType]]. __Read Only__ */
|
|
9580
|
+
complexProperties;
|
|
9581
|
+
/**
|
|
9582
|
+
The entity level validators associated with this ComplexType. Validators can be added and
|
|
9583
|
+
removed from this collection. __Read Only__ **/
|
|
9584
|
+
validators;
|
|
9585
|
+
/** For polymorphic purpose only - always empty here */
|
|
9586
|
+
concurrencyProperties;
|
|
9587
|
+
/** The DataProperties associated with this ComplexType that are not mapped to any backend datastore. These are effectively free standing
|
|
9588
|
+
properties. __Read Only__ **/
|
|
9589
|
+
unmappedProperties;
|
|
9590
|
+
// keyProperties and navigationProperties are not used on complexTypes - but here to allow sharing of code between EntityType and ComplexType.
|
|
9591
|
+
navigationProperties;
|
|
9592
|
+
// and may be used later to enforce uniqueness on arrays of complextypes.
|
|
9593
|
+
keyProperties;
|
|
9594
|
+
warnings;
|
|
9595
|
+
serializerFn;
|
|
9596
|
+
/** A free form object that can be used to define any custom metadata for this ComplexType. ***/
|
|
9597
|
+
custom;
|
|
9598
|
+
/** @hidden @internal */
|
|
9599
|
+
_mappedPropertiesCount;
|
|
9600
|
+
/** @hidden @internal */
|
|
9601
|
+
_extra;
|
|
9602
|
+
// copy entityType methods onto complexType
|
|
9603
|
+
/** See [[EntityType.getCtor]] */
|
|
9604
|
+
getCtor = EntityType.prototype.getCtor;
|
|
9605
|
+
// note the name change.
|
|
9606
|
+
createInstance = EntityType.prototype.createEntity;
|
|
9607
|
+
/** See [EntityType.addValidator] */
|
|
9608
|
+
addValidator = EntityType.prototype.addValidator;
|
|
9609
|
+
getProperty = EntityType.prototype.getProperty;
|
|
9610
|
+
getPropertiesOnPath = EntityType.prototype.getPropertiesOnPath;
|
|
9611
|
+
getPropertyNames = EntityType.prototype.getPropertyNames;
|
|
9612
|
+
/** @hidden @internal */
|
|
9613
|
+
_addPropertyCore = EntityType.prototype._addPropertyCore;
|
|
9614
|
+
/** @hidden @internal */
|
|
9615
|
+
_addDataProperty = EntityType.prototype._addDataProperty;
|
|
9616
|
+
/** @hidden @internal */
|
|
9617
|
+
_updateNames = EntityType.prototype._updateNames;
|
|
9618
|
+
/** @hidden @internal */
|
|
9619
|
+
_updateCps = EntityType.prototype._updateCps;
|
|
9620
|
+
/** @hidden @internal */
|
|
9621
|
+
_initializeInstance = EntityType.prototype._initializeInstance;
|
|
9622
|
+
/** @hidden @internal */
|
|
9623
|
+
_updateTargetFromRaw = EntityType.prototype._updateTargetFromRaw;
|
|
9624
|
+
/** @hidden @internal */
|
|
9625
|
+
_setCtor = EntityType.prototype._setCtor;
|
|
9271
9626
|
constructor(config) {
|
|
9272
|
-
/** For polymorphic purpose only - always true here */
|
|
9273
|
-
this.isComplexType = true;
|
|
9274
|
-
// copy entityType methods onto complexType
|
|
9275
|
-
/** See [[EntityType.getCtor]] */
|
|
9276
|
-
this.getCtor = EntityType.prototype.getCtor;
|
|
9277
|
-
// note the name change.
|
|
9278
|
-
this.createInstance = EntityType.prototype.createEntity;
|
|
9279
|
-
/** See [EntityType.addValidator] */
|
|
9280
|
-
this.addValidator = EntityType.prototype.addValidator;
|
|
9281
|
-
this.getProperty = EntityType.prototype.getProperty;
|
|
9282
|
-
this.getPropertiesOnPath = EntityType.prototype.getPropertiesOnPath;
|
|
9283
|
-
this.getPropertyNames = EntityType.prototype.getPropertyNames;
|
|
9284
|
-
/** @hidden @internal */
|
|
9285
|
-
this._addPropertyCore = EntityType.prototype._addPropertyCore;
|
|
9286
|
-
/** @hidden @internal */
|
|
9287
|
-
this._addDataProperty = EntityType.prototype._addDataProperty;
|
|
9288
|
-
/** @hidden @internal */
|
|
9289
|
-
this._updateNames = EntityType.prototype._updateNames;
|
|
9290
|
-
/** @hidden @internal */
|
|
9291
|
-
this._updateCps = EntityType.prototype._updateCps;
|
|
9292
|
-
/** @hidden @internal */
|
|
9293
|
-
this._initializeInstance = EntityType.prototype._initializeInstance;
|
|
9294
|
-
/** @hidden @internal */
|
|
9295
|
-
this._updateTargetFromRaw = EntityType.prototype._updateTargetFromRaw;
|
|
9296
|
-
/** @hidden @internal */
|
|
9297
|
-
this._setCtor = EntityType.prototype._setCtor;
|
|
9298
9627
|
if (arguments.length > 1) {
|
|
9299
9628
|
throw new Error("The ComplexType ctor has a single argument that is a configuration object.");
|
|
9300
9629
|
}
|
|
@@ -9375,6 +9704,10 @@ Instances of the DataProperty class are constructed automatically during Metadat
|
|
|
9375
9704
|
directly via the constructor.
|
|
9376
9705
|
**/
|
|
9377
9706
|
class DataProperty {
|
|
9707
|
+
/** Is this a DataProperty? - always true here. Allows polymorphic treatment of DataProperties and NavigationProperties. __Read Only__ */
|
|
9708
|
+
isDataProperty = true;
|
|
9709
|
+
/** Is this a NavigationProperty? - always false here. Allows polymorphic treatment of DataProperties and NavigationProperties. __Read Only__ */
|
|
9710
|
+
isNavigationProperty = false;
|
|
9378
9711
|
/** DataProperty constructor
|
|
9379
9712
|
> let lastNameProp = new DataProperty( {
|
|
9380
9713
|
> name: "lastName",
|
|
@@ -9387,10 +9720,6 @@ class DataProperty {
|
|
|
9387
9720
|
@param config - A configuration Object or a DataProperty
|
|
9388
9721
|
*/
|
|
9389
9722
|
constructor(config) {
|
|
9390
|
-
/** Is this a DataProperty? - always true here. Allows polymorphic treatment of DataProperties and NavigationProperties. __Read Only__ */
|
|
9391
|
-
this.isDataProperty = true;
|
|
9392
|
-
/** Is this a NavigationProperty? - always false here. Allows polymorphic treatment of DataProperties and NavigationProperties. __Read Only__ */
|
|
9393
|
-
this.isNavigationProperty = false;
|
|
9394
9723
|
assertConfig(config)
|
|
9395
9724
|
.whereParam("name").isString().isOptional()
|
|
9396
9725
|
.whereParam("nameOnServer").isString().isOptional()
|
|
@@ -9554,6 +9883,15 @@ Instances of the NavigationProperty class are constructed automatically during M
|
|
|
9554
9883
|
directly via the constructor.
|
|
9555
9884
|
**/
|
|
9556
9885
|
class NavigationProperty {
|
|
9886
|
+
/** Is this a DataProperty? - always false here
|
|
9887
|
+
Allows polymorphic treatment of DataProperties and NavigationProperties. __Read Only__ */
|
|
9888
|
+
isDataProperty = false;
|
|
9889
|
+
/** Is this a NavigationProperty? - always true here
|
|
9890
|
+
Allows polymorphic treatment of DataProperties and NavigationProperties. __Read Only__ */
|
|
9891
|
+
isNavigationProperty = true;
|
|
9892
|
+
formatName = DataProperty.prototype.formatName;
|
|
9893
|
+
getAllValidators = DataProperty.prototype.getAllValidators;
|
|
9894
|
+
resolveProperty = DataProperty.prototype.resolveProperty;
|
|
9557
9895
|
/** NavigationProperty constructor
|
|
9558
9896
|
> let homeAddressProp = new NavigationProperty( {
|
|
9559
9897
|
> name: "homeAddress",
|
|
@@ -9572,15 +9910,6 @@ class NavigationProperty {
|
|
|
9572
9910
|
@param config - A configuration object.
|
|
9573
9911
|
**/
|
|
9574
9912
|
constructor(config) {
|
|
9575
|
-
/** Is this a DataProperty? - always false here
|
|
9576
|
-
Allows polymorphic treatment of DataProperties and NavigationProperties. __Read Only__ */
|
|
9577
|
-
this.isDataProperty = false;
|
|
9578
|
-
/** Is this a NavigationProperty? - always true here
|
|
9579
|
-
Allows polymorphic treatment of DataProperties and NavigationProperties. __Read Only__ */
|
|
9580
|
-
this.isNavigationProperty = true;
|
|
9581
|
-
this.formatName = DataProperty.prototype.formatName;
|
|
9582
|
-
this.getAllValidators = DataProperty.prototype.getAllValidators;
|
|
9583
|
-
this.resolveProperty = DataProperty.prototype.resolveProperty;
|
|
9584
9913
|
assertConfig(config)
|
|
9585
9914
|
.whereParam("name").isString().isOptional()
|
|
9586
9915
|
.whereParam("nameOnServer").isString().isOptional()
|
|
@@ -9772,24 +10101,24 @@ function resolveRelated(np) {
|
|
|
9772
10101
|
AutoGeneratedKeyType is an 'Enum' containing all of the valid states for an automatically generated key.
|
|
9773
10102
|
**/
|
|
9774
10103
|
class AutoGeneratedKeyType extends BreezeEnum {
|
|
10104
|
+
/**
|
|
10105
|
+
This entity does not have an autogenerated key.
|
|
10106
|
+
The client must set the key before adding the entity to the EntityManager
|
|
10107
|
+
**/
|
|
10108
|
+
static None = new AutoGeneratedKeyType();
|
|
10109
|
+
/**
|
|
10110
|
+
This entity's key is an Identity column and is set by the backend database.
|
|
10111
|
+
Keys for new entities will be temporary until the entities are saved at which point the keys will
|
|
10112
|
+
be converted to their 'real' versions.
|
|
10113
|
+
**/
|
|
10114
|
+
static Identity = new AutoGeneratedKeyType();
|
|
10115
|
+
/**
|
|
10116
|
+
This entity's key is generated by a KeyGenerator and is set by the backend database.
|
|
10117
|
+
Keys for new entities will be temporary until the entities are saved at which point the keys will
|
|
10118
|
+
be converted to their 'real' versions.
|
|
10119
|
+
**/
|
|
10120
|
+
static KeyGenerator = new AutoGeneratedKeyType();
|
|
9775
10121
|
}
|
|
9776
|
-
/**
|
|
9777
|
-
This entity does not have an autogenerated key.
|
|
9778
|
-
The client must set the key before adding the entity to the EntityManager
|
|
9779
|
-
**/
|
|
9780
|
-
AutoGeneratedKeyType.None = new AutoGeneratedKeyType();
|
|
9781
|
-
/**
|
|
9782
|
-
This entity's key is an Identity column and is set by the backend database.
|
|
9783
|
-
Keys for new entities will be temporary until the entities are saved at which point the keys will
|
|
9784
|
-
be converted to their 'real' versions.
|
|
9785
|
-
**/
|
|
9786
|
-
AutoGeneratedKeyType.Identity = new AutoGeneratedKeyType();
|
|
9787
|
-
/**
|
|
9788
|
-
This entity's key is generated by a KeyGenerator and is set by the backend database.
|
|
9789
|
-
Keys for new entities will be temporary until the entities are saved at which point the keys will
|
|
9790
|
-
be converted to their 'real' versions.
|
|
9791
|
-
**/
|
|
9792
|
-
AutoGeneratedKeyType.KeyGenerator = new AutoGeneratedKeyType();
|
|
9793
10122
|
AutoGeneratedKeyType.prototype._$typeName = "AutoGeneratedKeyType";
|
|
9794
10123
|
Error['x'] = AutoGeneratedKeyType.resolveSymbols();
|
|
9795
10124
|
let proto = Param.prototype;
|
|
@@ -9855,41 +10184,6 @@ function addProperties(entityType, propObj, ctor) {
|
|
|
9855
10184
|
@hidden
|
|
9856
10185
|
*/
|
|
9857
10186
|
class AbstractDataServiceAdapter {
|
|
9858
|
-
constructor() {
|
|
9859
|
-
/**
|
|
9860
|
-
Returns a constructor function for a "ChangeRequestInterceptor"
|
|
9861
|
-
that can tweak the saveBundle both as it is built and when it is completed
|
|
9862
|
-
by a concrete DataServiceAdapater.
|
|
9863
|
-
|
|
9864
|
-
Initialized with a default, no-op implementation that developers can replace with a
|
|
9865
|
-
substantive implementation that changes the individual entity change requests
|
|
9866
|
-
or aspects of the entire 'saveBundle' without having to write their own DataService adapters.
|
|
9867
|
-
> let adapter = breeze.config.getAdapterInstance('dataService');
|
|
9868
|
-
> adapter.changeRequestInterceptor = function (saveContext, saveBundle) {
|
|
9869
|
-
> this.getRequest = function (request, entity, index) {
|
|
9870
|
-
> // alter the request that the adapter prepared for this entity
|
|
9871
|
-
> // based on the entity, saveContext, and saveBundle
|
|
9872
|
-
> // e.g., add a custom header or prune the originalValuesMap
|
|
9873
|
-
> return request;
|
|
9874
|
-
> };
|
|
9875
|
-
> this.done = function (requests) {
|
|
9876
|
-
> // alter the array of requests representing the entire change-set
|
|
9877
|
-
> // based on the saveContext and saveBundle
|
|
9878
|
-
> };
|
|
9879
|
-
> }
|
|
9880
|
-
|
|
9881
|
-
@param saveContext - The BreezeJS "context" for the save operation.
|
|
9882
|
-
@param saveBundle - Contains the array of entities-to-be-saved (AKA, the entity change-set).
|
|
9883
|
-
@return Constructor for a "ChangeRequestInterceptor".
|
|
9884
|
-
**/
|
|
9885
|
-
this.changeRequestInterceptor = DefaultChangeRequestInterceptor;
|
|
9886
|
-
this.jsonResultsAdapter = new JsonResultsAdapter({
|
|
9887
|
-
name: "noop",
|
|
9888
|
-
visitNode: function ( /* node, mappingContext, nodeContext */) {
|
|
9889
|
-
return {};
|
|
9890
|
-
}
|
|
9891
|
-
});
|
|
9892
|
-
}
|
|
9893
10187
|
// TODO use interface
|
|
9894
10188
|
checkForRecomposition(interfaceInitializedArgs) {
|
|
9895
10189
|
if (interfaceInitializedArgs.interfaceName === "ajax" && interfaceInitializedArgs.isDefault) {
|
|
@@ -10055,6 +10349,33 @@ class AbstractDataServiceAdapter {
|
|
|
10055
10349
|
// The implementor should call _createChangeRequestInterceptor
|
|
10056
10350
|
throw new Error("Need a concrete implementation of _prepareSaveBundle");
|
|
10057
10351
|
}
|
|
10352
|
+
/**
|
|
10353
|
+
Returns a constructor function for a "ChangeRequestInterceptor"
|
|
10354
|
+
that can tweak the saveBundle both as it is built and when it is completed
|
|
10355
|
+
by a concrete DataServiceAdapater.
|
|
10356
|
+
|
|
10357
|
+
Initialized with a default, no-op implementation that developers can replace with a
|
|
10358
|
+
substantive implementation that changes the individual entity change requests
|
|
10359
|
+
or aspects of the entire 'saveBundle' without having to write their own DataService adapters.
|
|
10360
|
+
> let adapter = breeze.config.getAdapterInstance('dataService');
|
|
10361
|
+
> adapter.changeRequestInterceptor = function (saveContext, saveBundle) {
|
|
10362
|
+
> this.getRequest = function (request, entity, index) {
|
|
10363
|
+
> // alter the request that the adapter prepared for this entity
|
|
10364
|
+
> // based on the entity, saveContext, and saveBundle
|
|
10365
|
+
> // e.g., add a custom header or prune the originalValuesMap
|
|
10366
|
+
> return request;
|
|
10367
|
+
> };
|
|
10368
|
+
> this.done = function (requests) {
|
|
10369
|
+
> // alter the array of requests representing the entire change-set
|
|
10370
|
+
> // based on the saveContext and saveBundle
|
|
10371
|
+
> };
|
|
10372
|
+
> }
|
|
10373
|
+
|
|
10374
|
+
@param saveContext - The BreezeJS "context" for the save operation.
|
|
10375
|
+
@param saveBundle - Contains the array of entities-to-be-saved (AKA, the entity change-set).
|
|
10376
|
+
@return Constructor for a "ChangeRequestInterceptor".
|
|
10377
|
+
**/
|
|
10378
|
+
changeRequestInterceptor = DefaultChangeRequestInterceptor;
|
|
10058
10379
|
/** @hidden @internal */
|
|
10059
10380
|
_createChangeRequestInterceptor(saveContext, saveBundle) {
|
|
10060
10381
|
let adapter = saveContext.adapter;
|
|
@@ -10092,6 +10413,12 @@ class AbstractDataServiceAdapter {
|
|
|
10092
10413
|
"Likely did not or could not reach server. Is the server running?";
|
|
10093
10414
|
}
|
|
10094
10415
|
}
|
|
10416
|
+
jsonResultsAdapter = new JsonResultsAdapter({
|
|
10417
|
+
name: "noop",
|
|
10418
|
+
visitNode: function ( /* node, mappingContext, nodeContext */) {
|
|
10419
|
+
return {};
|
|
10420
|
+
}
|
|
10421
|
+
});
|
|
10095
10422
|
}
|
|
10096
10423
|
function handleHttpError(reject, httpResponse, messagePrefix) {
|
|
10097
10424
|
let err = createError(httpResponse);
|
|
@@ -10186,7 +10513,7 @@ class ValidationOptions {
|
|
|
10186
10513
|
@param config - A configuration object.
|
|
10187
10514
|
**/
|
|
10188
10515
|
constructor(config) {
|
|
10189
|
-
updateWithConfig
|
|
10516
|
+
updateWithConfig(this, config);
|
|
10190
10517
|
}
|
|
10191
10518
|
/**
|
|
10192
10519
|
Returns a copy of this ValidationOptions with changes to the specified config properties.
|
|
@@ -10199,7 +10526,7 @@ class ValidationOptions {
|
|
|
10199
10526
|
if (!config)
|
|
10200
10527
|
return this;
|
|
10201
10528
|
let result = new ValidationOptions(this);
|
|
10202
|
-
updateWithConfig
|
|
10529
|
+
updateWithConfig(result, config);
|
|
10203
10530
|
return result;
|
|
10204
10531
|
}
|
|
10205
10532
|
/**
|
|
@@ -10212,18 +10539,18 @@ class ValidationOptions {
|
|
|
10212
10539
|
setAsDefault() {
|
|
10213
10540
|
return core.setAsDefault(this, ValidationOptions);
|
|
10214
10541
|
}
|
|
10542
|
+
/**
|
|
10543
|
+
The default instance for use whenever ValidationOptions are not specified.
|
|
10544
|
+
**/
|
|
10545
|
+
static defaultInstance = new ValidationOptions({
|
|
10546
|
+
validateOnAttach: true,
|
|
10547
|
+
validateOnSave: true,
|
|
10548
|
+
validateOnQuery: false,
|
|
10549
|
+
validateOnPropertyChange: true
|
|
10550
|
+
});
|
|
10215
10551
|
}
|
|
10216
|
-
/**
|
|
10217
|
-
The default instance for use whenever ValidationOptions are not specified.
|
|
10218
|
-
**/
|
|
10219
|
-
ValidationOptions.defaultInstance = new ValidationOptions({
|
|
10220
|
-
validateOnAttach: true,
|
|
10221
|
-
validateOnSave: true,
|
|
10222
|
-
validateOnQuery: false,
|
|
10223
|
-
validateOnPropertyChange: true
|
|
10224
|
-
});
|
|
10225
10552
|
ValidationOptions.prototype._$typeName = "ValidationOptions";
|
|
10226
|
-
function updateWithConfig
|
|
10553
|
+
function updateWithConfig(options, config) {
|
|
10227
10554
|
if (config) {
|
|
10228
10555
|
assertConfig(config)
|
|
10229
10556
|
.whereParam("validateOnAttach").isBoolean().isOptional()
|
|
@@ -10239,6 +10566,8 @@ function updateWithConfig$1(options, config) {
|
|
|
10239
10566
|
A SaveOptions instance is used to specify the 'options' under which a save will occur.
|
|
10240
10567
|
**/
|
|
10241
10568
|
class SaveOptions {
|
|
10569
|
+
/** The default value whenever SaveOptions are not specified. */
|
|
10570
|
+
static defaultInstance = new SaveOptions({ allowConcurrentSaves: false });
|
|
10242
10571
|
constructor(config) {
|
|
10243
10572
|
SaveOptions._updateWithConfig(this, config);
|
|
10244
10573
|
}
|
|
@@ -10269,14 +10598,14 @@ class SaveOptions {
|
|
|
10269
10598
|
return obj;
|
|
10270
10599
|
}
|
|
10271
10600
|
}
|
|
10272
|
-
/** The default value whenever SaveOptions are not specified. */
|
|
10273
|
-
SaveOptions.defaultInstance = new SaveOptions({ allowConcurrentSaves: false });
|
|
10274
10601
|
SaveOptions.prototype._$typeName = "SaveOptions";
|
|
10275
10602
|
|
|
10276
10603
|
/*
|
|
10277
10604
|
@class KeyGenerator
|
|
10278
10605
|
*/
|
|
10279
10606
|
class KeyGenerator {
|
|
10607
|
+
/** @hidden @internal */
|
|
10608
|
+
_tempIdMap;
|
|
10280
10609
|
constructor() {
|
|
10281
10610
|
// key is dataProperty.name + || + entityType.name, value is propEntry
|
|
10282
10611
|
// propEntry = { entityType, propertyName, keyMap }
|
|
@@ -10381,6 +10710,11 @@ config.registerType(KeyGenerator, "KeyGenerator");
|
|
|
10381
10710
|
|
|
10382
10711
|
/** @hidden @internal */
|
|
10383
10712
|
class EntityGroup {
|
|
10713
|
+
entityManager;
|
|
10714
|
+
entityType;
|
|
10715
|
+
_indexMap;
|
|
10716
|
+
_entities;
|
|
10717
|
+
_emptyIndexes;
|
|
10384
10718
|
constructor(entityManager, entityType) {
|
|
10385
10719
|
this.entityManager = entityManager;
|
|
10386
10720
|
this.entityType = entityType;
|
|
@@ -10568,8 +10902,8 @@ For use by breeze plugin authors only. The class is for use in building a [[IDat
|
|
|
10568
10902
|
@hidden
|
|
10569
10903
|
*/
|
|
10570
10904
|
class MappingContext {
|
|
10905
|
+
rawValueFn = DataProperty.getRawValueFromServer; // think about passing this in later.
|
|
10571
10906
|
constructor(config) {
|
|
10572
|
-
this.rawValueFn = DataProperty.getRawValueFromServer; // think about passing this in later.
|
|
10573
10907
|
core.extend(this, config, [
|
|
10574
10908
|
"query", "entityManager", "dataService", "mergeOptions"
|
|
10575
10909
|
]);
|
|
@@ -10792,7 +11126,7 @@ function mergeEntity(mc, node, meta) {
|
|
|
10792
11126
|
targetEntity.entityAspect.extraMetadata = meta.extraMetadata;
|
|
10793
11127
|
}
|
|
10794
11128
|
targetEntity.entityAspect.entityState = EntityState.Unchanged;
|
|
10795
|
-
clearOriginalValues
|
|
11129
|
+
clearOriginalValues(targetEntity);
|
|
10796
11130
|
// propertyName not specified because multiple props EntityChangedEventArgs
|
|
10797
11131
|
targetEntity.entityAspect.propertyChanged.publish({ entity: targetEntity, propertyName: null });
|
|
10798
11132
|
let action = isSaving ? EntityAction.MergeOnSave : EntityAction.MergeOnQuery;
|
|
@@ -10826,18 +11160,18 @@ function mergeEntity(mc, node, meta) {
|
|
|
10826
11160
|
return targetEntity;
|
|
10827
11161
|
}
|
|
10828
11162
|
// copied from entityAspect
|
|
10829
|
-
function clearOriginalValues
|
|
11163
|
+
function clearOriginalValues(target) {
|
|
10830
11164
|
let aspect = target.entityAspect || target.complexAspect;
|
|
10831
11165
|
aspect.originalValues = {};
|
|
10832
11166
|
let stype = target.entityType || target.complexType;
|
|
10833
11167
|
stype.complexProperties.forEach(function (cp) {
|
|
10834
11168
|
let cos = target.getProperty(cp.name);
|
|
10835
11169
|
if (cp.isScalar) {
|
|
10836
|
-
clearOriginalValues
|
|
11170
|
+
clearOriginalValues(cos);
|
|
10837
11171
|
}
|
|
10838
11172
|
else {
|
|
10839
11173
|
cos._acceptChanges();
|
|
10840
|
-
cos.forEach(clearOriginalValues
|
|
11174
|
+
cos.forEach(clearOriginalValues);
|
|
10841
11175
|
}
|
|
10842
11176
|
});
|
|
10843
11177
|
}
|
|
@@ -10969,10 +11303,8 @@ function updateRelatedEntityInCollection(mc, relatedEntity, relatedEntities, tar
|
|
|
10969
11303
|
/** @hidden @internal */
|
|
10970
11304
|
// Represents entities not yet attached to navigationProperties.
|
|
10971
11305
|
class UnattachedChildrenMap {
|
|
10972
|
-
|
|
10973
|
-
|
|
10974
|
-
this.map = {};
|
|
10975
|
-
}
|
|
11306
|
+
// key is EntityKey.toString(), value is array of { navigationProperty, children }
|
|
11307
|
+
map = {};
|
|
10976
11308
|
addChild(parentEntityKey, navigationProperty, child) {
|
|
10977
11309
|
let tuple = this.getTuple(parentEntityKey, navigationProperty);
|
|
10978
11310
|
if (!tuple) {
|
|
@@ -11027,6 +11359,80 @@ class UnattachedChildrenMap {
|
|
|
11027
11359
|
Instances of the EntityManager contain and manage collections of entities, either retrieved from a backend datastore or created on the client.
|
|
11028
11360
|
**/
|
|
11029
11361
|
class EntityManager {
|
|
11362
|
+
// events
|
|
11363
|
+
/**
|
|
11364
|
+
A [[BreezeEvent]] that fires whenever a change to any entity in this EntityManager occurs. __Read Only__
|
|
11365
|
+
|
|
11366
|
+
@eventArgs -
|
|
11367
|
+
- entityAction - The [[EntityAction]] that occured.
|
|
11368
|
+
- entity - The entity that changed. If this is null, then all entities in the entityManager were affected.
|
|
11369
|
+
- args - Additional information about this event. This will differ based on the entityAction.
|
|
11370
|
+
|
|
11371
|
+
> let em = new EntityManager( {serviceName: "breeze/NorthwindIBModel" });
|
|
11372
|
+
> em.entityChanged.subscribe(function(changeArgs) {
|
|
11373
|
+
> // This code will be executed any time any entity within the entityManager
|
|
11374
|
+
> // is added, modified, deleted or detached for any reason.
|
|
11375
|
+
> let action = changeArgs.entityAction;
|
|
11376
|
+
> let entity = changeArgs.entity;
|
|
11377
|
+
> // .. do something to this entity when it is changed.
|
|
11378
|
+
> });
|
|
11379
|
+
> });
|
|
11380
|
+
@event
|
|
11381
|
+
**/
|
|
11382
|
+
entityChanged;
|
|
11383
|
+
/**
|
|
11384
|
+
An [[BreezeEvent]] that fires whenever validationErrors change for any entity in this EntityManager. __Read Only__
|
|
11385
|
+
@eventArgs -
|
|
11386
|
+
- entity - The entity on which the validation errors have been added or removed.
|
|
11387
|
+
- added - An array containing any newly added [[ValidationError]]s
|
|
11388
|
+
- removed - An array containing any newly removed [[ValidationError]]s. This is those errors that have been 'fixed'
|
|
11389
|
+
|
|
11390
|
+
> let em = new EntityManager( {serviceName: "breeze/NorthwindIBModel" });
|
|
11391
|
+
> em.validationErrorsChanged.subscribe(function(changeArgs) {
|
|
11392
|
+
> // This code will be executed any time any entity within the entityManager experiences a change to its validationErrors collection.
|
|
11393
|
+
> function (validationChangeArgs) {
|
|
11394
|
+
> let entity == validationChangeArgs.entity;
|
|
11395
|
+
> let errorsAdded = validationChangeArgs.added;
|
|
11396
|
+
> let errorsCleared = validationChangeArgs.removed;
|
|
11397
|
+
> // ... do something interesting with the order.
|
|
11398
|
+
> });
|
|
11399
|
+
> });
|
|
11400
|
+
> });
|
|
11401
|
+
@event
|
|
11402
|
+
**/
|
|
11403
|
+
validationErrorsChanged;
|
|
11404
|
+
/**
|
|
11405
|
+
A [[BreezeEvent]] that fires whenever an EntityManager transitions to or from having changes. __Read Only__
|
|
11406
|
+
@eventArgs -
|
|
11407
|
+
- entityManager - The EntityManager whose 'hasChanges' status has changed.
|
|
11408
|
+
- hasChanges - Whether or not this EntityManager has changes.
|
|
11409
|
+
|
|
11410
|
+
> let em = new EntityManager( {serviceName: "breeze/NorthwindIBModel" });
|
|
11411
|
+
> em.hasChangesChanged.subscribe(function(args) {
|
|
11412
|
+
> let hasChangesChanged = args.hasChanges;
|
|
11413
|
+
> let entityManager = args.entityManager;
|
|
11414
|
+
> });
|
|
11415
|
+
> });
|
|
11416
|
+
@event
|
|
11417
|
+
**/
|
|
11418
|
+
hasChangesChanged;
|
|
11419
|
+
/** @hidden @internal */
|
|
11420
|
+
_pendingPubs; // TODO: refine later
|
|
11421
|
+
/** @hidden @internal */
|
|
11422
|
+
_hasChangesAction; // TODO refine later
|
|
11423
|
+
/** @hidden @internal */
|
|
11424
|
+
_hasChanges;
|
|
11425
|
+
/** @hidden @internal */
|
|
11426
|
+
_entityGroupMap;
|
|
11427
|
+
/** @hidden @internal */
|
|
11428
|
+
_unattachedChildrenMap;
|
|
11429
|
+
/** @hidden @internal */
|
|
11430
|
+
_inKeyFixup;
|
|
11431
|
+
helper = {
|
|
11432
|
+
unwrapInstance: unwrapInstance,
|
|
11433
|
+
unwrapOriginalValues: unwrapOriginalValues,
|
|
11434
|
+
unwrapChangedValues: unwrapChangedValues
|
|
11435
|
+
};
|
|
11030
11436
|
/**
|
|
11031
11437
|
EntityManager constructor.
|
|
11032
11438
|
|
|
@@ -11065,11 +11471,6 @@ class EntityManager {
|
|
|
11065
11471
|
@param emConfig - Configuration settings or a service name.
|
|
11066
11472
|
**/
|
|
11067
11473
|
constructor(emConfig) {
|
|
11068
|
-
this.helper = {
|
|
11069
|
-
unwrapInstance: unwrapInstance,
|
|
11070
|
-
unwrapOriginalValues: unwrapOriginalValues,
|
|
11071
|
-
unwrapChangedValues: unwrapChangedValues
|
|
11072
|
-
};
|
|
11073
11474
|
if (arguments.length > 1) {
|
|
11074
11475
|
throw new Error("The EntityManager ctor has a single optional argument that is either a 'serviceName' or a configuration object.");
|
|
11075
11476
|
}
|
|
@@ -13099,12 +13500,10 @@ function getSerializerFn(stype) {
|
|
|
13099
13500
|
|
|
13100
13501
|
/** Registers adapters used by Breeze */
|
|
13101
13502
|
class InterfaceRegistry {
|
|
13102
|
-
|
|
13103
|
-
|
|
13104
|
-
|
|
13105
|
-
|
|
13106
|
-
this.uriBuilder = new InterfaceDef("uriBuilder");
|
|
13107
|
-
}
|
|
13503
|
+
ajax = new InterfaceDef("ajax");
|
|
13504
|
+
modelLibrary = new InterfaceDef("modelLibrary");
|
|
13505
|
+
dataService = new InterfaceDef("dataService");
|
|
13506
|
+
uriBuilder = new InterfaceDef("uriBuilder");
|
|
13108
13507
|
}
|
|
13109
13508
|
config.interfaceRegistry = new InterfaceRegistry();
|
|
13110
13509
|
config._interfaceRegistry = config.interfaceRegistry;
|
|
@@ -13135,119 +13534,118 @@ config.initializeAdapterInstances = function (irConfig) {
|
|
|
13135
13534
|
return core.objectMap(config, this.initializeAdapterInstance);
|
|
13136
13535
|
};
|
|
13137
13536
|
|
|
13138
|
-
const ɵ0$3 = function (...args) {
|
|
13139
|
-
if (this._inProgress) {
|
|
13140
|
-
return -1;
|
|
13141
|
-
}
|
|
13142
|
-
let goodAdds = this._getGoodAdds(args);
|
|
13143
|
-
if (!goodAdds.length) {
|
|
13144
|
-
return this.length;
|
|
13145
|
-
}
|
|
13146
|
-
this._beforeChange();
|
|
13147
|
-
let result;
|
|
13148
|
-
let objPrototype = Object.getPrototypeOf(this);
|
|
13149
|
-
if (objPrototype.push) {
|
|
13150
|
-
result = objPrototype.push.apply(this, goodAdds);
|
|
13151
|
-
}
|
|
13152
|
-
else {
|
|
13153
|
-
result = Array.prototype.push.apply(this, goodAdds);
|
|
13154
|
-
}
|
|
13155
|
-
processAdds(this, goodAdds);
|
|
13156
|
-
return result;
|
|
13157
|
-
}, ɵ1$2 = function (...args) {
|
|
13158
|
-
if (this._inProgress) {
|
|
13159
|
-
return -1;
|
|
13160
|
-
}
|
|
13161
|
-
let goodAdds = args;
|
|
13162
|
-
this._beforeChange();
|
|
13163
|
-
let result;
|
|
13164
|
-
let objPrototype = Object.getPrototypeOf(this);
|
|
13165
|
-
if (objPrototype.push) {
|
|
13166
|
-
result = objPrototype.push.apply(this, goodAdds);
|
|
13167
|
-
}
|
|
13168
|
-
else {
|
|
13169
|
-
result = Array.prototype.push.apply(this, goodAdds);
|
|
13170
|
-
}
|
|
13171
|
-
processAdds(this, goodAdds);
|
|
13172
|
-
return result;
|
|
13173
|
-
}, ɵ2$1 = function (...args) {
|
|
13174
|
-
let goodAdds = this._getGoodAdds(args);
|
|
13175
|
-
if (!goodAdds.length) {
|
|
13176
|
-
return this.length;
|
|
13177
|
-
}
|
|
13178
|
-
this._beforeChange();
|
|
13179
|
-
let result;
|
|
13180
|
-
let objPrototype = Object.getPrototypeOf(this);
|
|
13181
|
-
if (objPrototype.unshift) {
|
|
13182
|
-
result = objPrototype.unshift.apply(this, goodAdds);
|
|
13183
|
-
}
|
|
13184
|
-
else {
|
|
13185
|
-
result = Array.prototype.unshift.apply(this, goodAdds);
|
|
13186
|
-
}
|
|
13187
|
-
processAdds(this, goodAdds);
|
|
13188
|
-
return result;
|
|
13189
|
-
}, ɵ3$1 = function () {
|
|
13190
|
-
this._beforeChange();
|
|
13191
|
-
let result;
|
|
13192
|
-
let objPrototype = Object.getPrototypeOf(this);
|
|
13193
|
-
if (objPrototype.pop) {
|
|
13194
|
-
result = objPrototype.pop.apply(this);
|
|
13195
|
-
}
|
|
13196
|
-
else {
|
|
13197
|
-
result = Array.prototype.pop.apply(this);
|
|
13198
|
-
}
|
|
13199
|
-
processRemoves(this, [result]);
|
|
13200
|
-
return result;
|
|
13201
|
-
}, ɵ4$1 = function () {
|
|
13202
|
-
this._beforeChange();
|
|
13203
|
-
let result;
|
|
13204
|
-
let objPrototype = Object.getPrototypeOf(this);
|
|
13205
|
-
if (objPrototype.shift) {
|
|
13206
|
-
result = objPrototype.shift.apply(this);
|
|
13207
|
-
}
|
|
13208
|
-
else {
|
|
13209
|
-
result = Array.prototype.shift.apply(this);
|
|
13210
|
-
}
|
|
13211
|
-
processRemoves(this, [result]);
|
|
13212
|
-
return result;
|
|
13213
|
-
}, ɵ5$1 = function (...args) {
|
|
13214
|
-
let goodAdds = this._getGoodAdds(core.arraySlice(args, 2));
|
|
13215
|
-
let newArgs = core.arraySlice(args, 0, 2).concat(goodAdds);
|
|
13216
|
-
this._beforeChange();
|
|
13217
|
-
let result;
|
|
13218
|
-
let objPrototype = Object.getPrototypeOf(this);
|
|
13219
|
-
if (objPrototype.splice) {
|
|
13220
|
-
result = objPrototype.splice.apply(this, newArgs);
|
|
13221
|
-
}
|
|
13222
|
-
else {
|
|
13223
|
-
result = Array.prototype.splice.apply(this, newArgs);
|
|
13224
|
-
}
|
|
13225
|
-
processRemoves(this, result);
|
|
13226
|
-
if (goodAdds.length) {
|
|
13227
|
-
processAdds(this, goodAdds);
|
|
13228
|
-
}
|
|
13229
|
-
return result;
|
|
13230
|
-
}, ɵ6$1 = function () {
|
|
13231
|
-
return this.parent.entityAspect || this.parent.complexAspect.getEntityAspect();
|
|
13232
|
-
}, ɵ7$1 = function () {
|
|
13233
|
-
return this.getEntityAspect();
|
|
13234
|
-
}, ɵ8$1 = function () {
|
|
13235
|
-
let em = this.getEntityAspect().entityManager;
|
|
13236
|
-
return em && em._pendingPubs;
|
|
13237
|
-
}, ɵ9$1 = function () {
|
|
13238
|
-
// default is to do nothing
|
|
13239
|
-
};
|
|
13240
13537
|
let mixin = {
|
|
13241
|
-
push:
|
|
13242
|
-
|
|
13243
|
-
|
|
13244
|
-
|
|
13245
|
-
|
|
13246
|
-
|
|
13247
|
-
|
|
13248
|
-
|
|
13249
|
-
|
|
13250
|
-
|
|
13538
|
+
push: function (...args) {
|
|
13539
|
+
if (this._inProgress) {
|
|
13540
|
+
return -1;
|
|
13541
|
+
}
|
|
13542
|
+
let goodAdds = this._getGoodAdds(args);
|
|
13543
|
+
if (!goodAdds.length) {
|
|
13544
|
+
return this.length;
|
|
13545
|
+
}
|
|
13546
|
+
this._beforeChange();
|
|
13547
|
+
let result;
|
|
13548
|
+
let objPrototype = Object.getPrototypeOf(this);
|
|
13549
|
+
if (objPrototype.push) {
|
|
13550
|
+
result = objPrototype.push.apply(this, goodAdds);
|
|
13551
|
+
}
|
|
13552
|
+
else {
|
|
13553
|
+
result = Array.prototype.push.apply(this, goodAdds);
|
|
13554
|
+
}
|
|
13555
|
+
processAdds$2(this, goodAdds);
|
|
13556
|
+
return result;
|
|
13557
|
+
},
|
|
13558
|
+
_push: function (...args) {
|
|
13559
|
+
if (this._inProgress) {
|
|
13560
|
+
return -1;
|
|
13561
|
+
}
|
|
13562
|
+
let goodAdds = args;
|
|
13563
|
+
this._beforeChange();
|
|
13564
|
+
let result;
|
|
13565
|
+
let objPrototype = Object.getPrototypeOf(this);
|
|
13566
|
+
if (objPrototype.push) {
|
|
13567
|
+
result = objPrototype.push.apply(this, goodAdds);
|
|
13568
|
+
}
|
|
13569
|
+
else {
|
|
13570
|
+
result = Array.prototype.push.apply(this, goodAdds);
|
|
13571
|
+
}
|
|
13572
|
+
processAdds$2(this, goodAdds);
|
|
13573
|
+
return result;
|
|
13574
|
+
},
|
|
13575
|
+
unshift: function (...args) {
|
|
13576
|
+
let goodAdds = this._getGoodAdds(args);
|
|
13577
|
+
if (!goodAdds.length) {
|
|
13578
|
+
return this.length;
|
|
13579
|
+
}
|
|
13580
|
+
this._beforeChange();
|
|
13581
|
+
let result;
|
|
13582
|
+
let objPrototype = Object.getPrototypeOf(this);
|
|
13583
|
+
if (objPrototype.unshift) {
|
|
13584
|
+
result = objPrototype.unshift.apply(this, goodAdds);
|
|
13585
|
+
}
|
|
13586
|
+
else {
|
|
13587
|
+
result = Array.prototype.unshift.apply(this, goodAdds);
|
|
13588
|
+
}
|
|
13589
|
+
processAdds$2(this, goodAdds);
|
|
13590
|
+
return result;
|
|
13591
|
+
},
|
|
13592
|
+
pop: function () {
|
|
13593
|
+
this._beforeChange();
|
|
13594
|
+
let result;
|
|
13595
|
+
let objPrototype = Object.getPrototypeOf(this);
|
|
13596
|
+
if (objPrototype.pop) {
|
|
13597
|
+
result = objPrototype.pop.apply(this);
|
|
13598
|
+
}
|
|
13599
|
+
else {
|
|
13600
|
+
result = Array.prototype.pop.apply(this);
|
|
13601
|
+
}
|
|
13602
|
+
processRemoves$2(this, [result]);
|
|
13603
|
+
return result;
|
|
13604
|
+
},
|
|
13605
|
+
shift: function () {
|
|
13606
|
+
this._beforeChange();
|
|
13607
|
+
let result;
|
|
13608
|
+
let objPrototype = Object.getPrototypeOf(this);
|
|
13609
|
+
if (objPrototype.shift) {
|
|
13610
|
+
result = objPrototype.shift.apply(this);
|
|
13611
|
+
}
|
|
13612
|
+
else {
|
|
13613
|
+
result = Array.prototype.shift.apply(this);
|
|
13614
|
+
}
|
|
13615
|
+
processRemoves$2(this, [result]);
|
|
13616
|
+
return result;
|
|
13617
|
+
},
|
|
13618
|
+
splice: function (...args) {
|
|
13619
|
+
let goodAdds = this._getGoodAdds(core.arraySlice(args, 2));
|
|
13620
|
+
let newArgs = core.arraySlice(args, 0, 2).concat(goodAdds);
|
|
13621
|
+
this._beforeChange();
|
|
13622
|
+
let result;
|
|
13623
|
+
let objPrototype = Object.getPrototypeOf(this);
|
|
13624
|
+
if (objPrototype.splice) {
|
|
13625
|
+
result = objPrototype.splice.apply(this, newArgs);
|
|
13626
|
+
}
|
|
13627
|
+
else {
|
|
13628
|
+
result = Array.prototype.splice.apply(this, newArgs);
|
|
13629
|
+
}
|
|
13630
|
+
processRemoves$2(this, result);
|
|
13631
|
+
if (goodAdds.length) {
|
|
13632
|
+
processAdds$2(this, goodAdds);
|
|
13633
|
+
}
|
|
13634
|
+
return result;
|
|
13635
|
+
},
|
|
13636
|
+
getEntityAspect: function () {
|
|
13637
|
+
return this.parent.entityAspect || this.parent.complexAspect.getEntityAspect();
|
|
13638
|
+
},
|
|
13639
|
+
_getEventParent: function () {
|
|
13640
|
+
return this.getEntityAspect();
|
|
13641
|
+
},
|
|
13642
|
+
_getPendingPubs: function () {
|
|
13643
|
+
let em = this.getEntityAspect().entityManager;
|
|
13644
|
+
return em && em._pendingPubs;
|
|
13645
|
+
},
|
|
13646
|
+
_beforeChange: function () {
|
|
13647
|
+
// default is to do nothing
|
|
13648
|
+
}
|
|
13251
13649
|
};
|
|
13252
13650
|
function updateEntityState(obsArray) {
|
|
13253
13651
|
let entityAspect = obsArray.getEntityAspect();
|
|
@@ -13280,14 +13678,14 @@ function initializeParent(obsArray, parent, parentProperty) {
|
|
|
13280
13678
|
obsArray.parent = parent;
|
|
13281
13679
|
obsArray.parentProperty = parentProperty;
|
|
13282
13680
|
}
|
|
13283
|
-
function processAdds(obsArray, adds) {
|
|
13681
|
+
function processAdds$2(obsArray, adds) {
|
|
13284
13682
|
obsArray._processAdds(adds);
|
|
13285
13683
|
// this is referencing the name of the method on the complexArray not the name of the event
|
|
13286
13684
|
//var args = { added: adds };
|
|
13287
13685
|
//args[obsArray._typeName] = obsArray;
|
|
13288
13686
|
publish(obsArray, "arrayChanged", { array: obsArray, added: adds });
|
|
13289
13687
|
}
|
|
13290
|
-
function processRemoves(obsArray, removes) {
|
|
13688
|
+
function processRemoves$2(obsArray, removes) {
|
|
13291
13689
|
obsArray._processRemoves(removes);
|
|
13292
13690
|
// this is referencing the name of the method on the array not the name of the event
|
|
13293
13691
|
publish(obsArray, "arrayChanged", { array: obsArray, removed: removes });
|
|
@@ -13318,23 +13716,6 @@ const observableArray = {
|
|
|
13318
13716
|
initializeParent: initializeParent
|
|
13319
13717
|
};
|
|
13320
13718
|
|
|
13321
|
-
const ɵ0$4 = function (callback, errorCallback) {
|
|
13322
|
-
let parent = this.parentEntity;
|
|
13323
|
-
let query = EntityQuery.fromEntityNavigation(this.parentEntity, this.navigationProperty);
|
|
13324
|
-
let em = parent.entityAspect.entityManager;
|
|
13325
|
-
return em.executeQuery(query, callback, errorCallback);
|
|
13326
|
-
}, ɵ1$3 = function () {
|
|
13327
|
-
return this.parentEntity.entityAspect;
|
|
13328
|
-
}, ɵ2$2 = function () {
|
|
13329
|
-
let em = this.parentEntity.entityAspect.entityManager;
|
|
13330
|
-
return em && em._pendingPubs;
|
|
13331
|
-
}, ɵ3$2 = function (adds) {
|
|
13332
|
-
return getGoodAdds(this, adds);
|
|
13333
|
-
}, ɵ4$2 = function (adds) {
|
|
13334
|
-
processAdds$1(this, adds);
|
|
13335
|
-
}, ɵ5$2 = function (removes) {
|
|
13336
|
-
processRemoves$1(this, removes);
|
|
13337
|
-
};
|
|
13338
13719
|
let relationArrayMixin = {
|
|
13339
13720
|
/**
|
|
13340
13721
|
Relation arrays are not actually classes, they are objects that mimic arrays. A relation array is collection of
|
|
@@ -13371,15 +13752,31 @@ let relationArrayMixin = {
|
|
|
13371
13752
|
@param [errorCallback] {Function}
|
|
13372
13753
|
@return {Promise}
|
|
13373
13754
|
**/
|
|
13374
|
-
load:
|
|
13375
|
-
|
|
13376
|
-
|
|
13755
|
+
load: function (callback, errorCallback) {
|
|
13756
|
+
let parent = this.parentEntity;
|
|
13757
|
+
let query = EntityQuery.fromEntityNavigation(this.parentEntity, this.navigationProperty);
|
|
13758
|
+
let em = parent.entityAspect.entityManager;
|
|
13759
|
+
return em.executeQuery(query, callback, errorCallback);
|
|
13760
|
+
},
|
|
13761
|
+
_getEventParent: function () {
|
|
13762
|
+
return this.parentEntity.entityAspect;
|
|
13763
|
+
},
|
|
13764
|
+
_getPendingPubs: function () {
|
|
13765
|
+
let em = this.parentEntity.entityAspect.entityManager;
|
|
13766
|
+
return em && em._pendingPubs;
|
|
13767
|
+
},
|
|
13377
13768
|
// virtual impls
|
|
13378
|
-
_getGoodAdds:
|
|
13379
|
-
|
|
13380
|
-
|
|
13769
|
+
_getGoodAdds: function (adds) {
|
|
13770
|
+
return getGoodAdds$1(this, adds);
|
|
13771
|
+
},
|
|
13772
|
+
_processAdds: function (adds) {
|
|
13773
|
+
processAdds$1(this, adds);
|
|
13774
|
+
},
|
|
13775
|
+
_processRemoves: function (removes) {
|
|
13776
|
+
processRemoves$1(this, removes);
|
|
13777
|
+
}
|
|
13381
13778
|
};
|
|
13382
|
-
function getGoodAdds(relationArray, adds) {
|
|
13779
|
+
function getGoodAdds$1(relationArray, adds) {
|
|
13383
13780
|
let goodAdds = checkForDups(relationArray, adds);
|
|
13384
13781
|
if (!goodAdds.length) {
|
|
13385
13782
|
return goodAdds;
|
|
@@ -13487,28 +13884,6 @@ function makeRelationArray(arr, parentEntity, navigationProperty) {
|
|
|
13487
13884
|
return core.extend(arrX, relationArrayMixin);
|
|
13488
13885
|
}
|
|
13489
13886
|
|
|
13490
|
-
const ɵ0$5 = function (adds) {
|
|
13491
|
-
return getGoodAdds$1(this, adds);
|
|
13492
|
-
}, ɵ1$4 = function () {
|
|
13493
|
-
observableArray.updateEntityState(this);
|
|
13494
|
-
}, ɵ2$3 = function (adds) {
|
|
13495
|
-
processAdds$2(this, adds);
|
|
13496
|
-
}, ɵ3$3 = function (removes) {
|
|
13497
|
-
processRemoves$2(this, removes);
|
|
13498
|
-
}, ɵ4$3 = function () {
|
|
13499
|
-
if (!this._origValues)
|
|
13500
|
-
return;
|
|
13501
|
-
let that = this;
|
|
13502
|
-
this.forEach(function (co) {
|
|
13503
|
-
clearAspect(co, that);
|
|
13504
|
-
});
|
|
13505
|
-
this.length = 0;
|
|
13506
|
-
this._origValues.forEach(function (co) {
|
|
13507
|
-
that.push(co);
|
|
13508
|
-
});
|
|
13509
|
-
}, ɵ5$3 = function () {
|
|
13510
|
-
this._origValues = null;
|
|
13511
|
-
};
|
|
13512
13887
|
let complexArrayMixin = {
|
|
13513
13888
|
// complexArray will have the following props
|
|
13514
13889
|
// parent
|
|
@@ -13543,22 +13918,43 @@ let complexArrayMixin = {
|
|
|
13543
13918
|
@readOnly
|
|
13544
13919
|
**/
|
|
13545
13920
|
// virtual impls
|
|
13546
|
-
_getGoodAdds:
|
|
13547
|
-
|
|
13548
|
-
|
|
13549
|
-
|
|
13550
|
-
|
|
13551
|
-
|
|
13921
|
+
_getGoodAdds: function (adds) {
|
|
13922
|
+
return getGoodAdds(this, adds);
|
|
13923
|
+
},
|
|
13924
|
+
_beforeChange: function () {
|
|
13925
|
+
observableArray.updateEntityState(this);
|
|
13926
|
+
},
|
|
13927
|
+
_processAdds: function (adds) {
|
|
13928
|
+
processAdds(this, adds);
|
|
13929
|
+
},
|
|
13930
|
+
_processRemoves: function (removes) {
|
|
13931
|
+
processRemoves(this, removes);
|
|
13932
|
+
},
|
|
13933
|
+
_rejectChanges: function () {
|
|
13934
|
+
if (!this._origValues)
|
|
13935
|
+
return;
|
|
13936
|
+
let that = this;
|
|
13937
|
+
this.forEach(function (co) {
|
|
13938
|
+
clearAspect(co, that);
|
|
13939
|
+
});
|
|
13940
|
+
this.length = 0;
|
|
13941
|
+
this._origValues.forEach(function (co) {
|
|
13942
|
+
that.push(co);
|
|
13943
|
+
});
|
|
13944
|
+
},
|
|
13945
|
+
_acceptChanges: function () {
|
|
13946
|
+
this._origValues = null;
|
|
13947
|
+
}
|
|
13552
13948
|
};
|
|
13553
13949
|
// local functions
|
|
13554
|
-
function getGoodAdds
|
|
13950
|
+
function getGoodAdds(complexArray, adds) {
|
|
13555
13951
|
// remove any that are already added here
|
|
13556
13952
|
return adds.filter(function (a) {
|
|
13557
13953
|
// return a.parent !== complexArray.parent; // TODO: check if this is actually a bug in original breezejs ???
|
|
13558
13954
|
return a.complexAspect == null || a.complexAspect.parent !== complexArray.parent;
|
|
13559
13955
|
});
|
|
13560
13956
|
}
|
|
13561
|
-
function processAdds
|
|
13957
|
+
function processAdds(complexArray, adds) {
|
|
13562
13958
|
adds.forEach(function (a) {
|
|
13563
13959
|
// if (a.parent != null) { // TODO: check if this is actually a bug in original breezejs ???
|
|
13564
13960
|
if (a.complexAspect && a.complexAspect.parent != null) {
|
|
@@ -13567,7 +13963,7 @@ function processAdds$2(complexArray, adds) {
|
|
|
13567
13963
|
setAspect(a, complexArray);
|
|
13568
13964
|
});
|
|
13569
13965
|
}
|
|
13570
|
-
function processRemoves
|
|
13966
|
+
function processRemoves(complexArray, removes) {
|
|
13571
13967
|
removes.forEach(function (a) {
|
|
13572
13968
|
clearAspect(a, complexArray);
|
|
13573
13969
|
});
|
|
@@ -13602,28 +13998,6 @@ function makeComplexArray(arr, parent, parentProperty) {
|
|
|
13602
13998
|
return core.extend(arrX, complexArrayMixin);
|
|
13603
13999
|
}
|
|
13604
14000
|
|
|
13605
|
-
const ɵ0$6 = function (adds) {
|
|
13606
|
-
return adds;
|
|
13607
|
-
}, ɵ1$5 = function () {
|
|
13608
|
-
let entityAspect = this.getEntityAspect();
|
|
13609
|
-
if (entityAspect.entityState.isUnchanged()) {
|
|
13610
|
-
entityAspect.setModified();
|
|
13611
|
-
}
|
|
13612
|
-
if (entityAspect.entityState.isModified() && !this._origValues) {
|
|
13613
|
-
this._origValues = this.slice(0);
|
|
13614
|
-
}
|
|
13615
|
-
}, ɵ2$4 = function (adds) {
|
|
13616
|
-
// nothing needed
|
|
13617
|
-
}, ɵ3$4 = function (removes) {
|
|
13618
|
-
// nothing needed;
|
|
13619
|
-
}, ɵ4$4 = function () {
|
|
13620
|
-
if (!this._origValues)
|
|
13621
|
-
return;
|
|
13622
|
-
this.length = 0;
|
|
13623
|
-
Array.prototype.push.apply(this, this._origValues);
|
|
13624
|
-
}, ɵ5$4 = function () {
|
|
13625
|
-
this._origValues = null;
|
|
13626
|
-
};
|
|
13627
14001
|
// TODO: mixin impl is not very typesafe
|
|
13628
14002
|
// Not needed
|
|
13629
14003
|
// interface IPrimitiveArray extends IObservableArray {
|
|
@@ -13665,12 +14039,33 @@ let primitiveArrayMixin = {
|
|
|
13665
14039
|
@readOnly
|
|
13666
14040
|
**/
|
|
13667
14041
|
// virtual impls
|
|
13668
|
-
_getGoodAdds:
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
14042
|
+
_getGoodAdds: function (adds) {
|
|
14043
|
+
return adds;
|
|
14044
|
+
},
|
|
14045
|
+
_beforeChange: function () {
|
|
14046
|
+
let entityAspect = this.getEntityAspect();
|
|
14047
|
+
if (entityAspect.entityState.isUnchanged()) {
|
|
14048
|
+
entityAspect.setModified();
|
|
14049
|
+
}
|
|
14050
|
+
if (entityAspect.entityState.isModified() && !this._origValues) {
|
|
14051
|
+
this._origValues = this.slice(0);
|
|
14052
|
+
}
|
|
14053
|
+
},
|
|
14054
|
+
_processAdds: function (adds) {
|
|
14055
|
+
// nothing needed
|
|
14056
|
+
},
|
|
14057
|
+
_processRemoves: function (removes) {
|
|
14058
|
+
// nothing needed;
|
|
14059
|
+
},
|
|
14060
|
+
_rejectChanges: function () {
|
|
14061
|
+
if (!this._origValues)
|
|
14062
|
+
return;
|
|
14063
|
+
this.length = 0;
|
|
14064
|
+
Array.prototype.push.apply(this, this._origValues);
|
|
14065
|
+
},
|
|
14066
|
+
_acceptChanges: function () {
|
|
14067
|
+
this._origValues = null;
|
|
14068
|
+
}
|
|
13674
14069
|
};
|
|
13675
14070
|
// local functions
|
|
13676
14071
|
/** For use by breeze plugin authors only. The class is for use in building a [[IModelLibraryAdapter]] implementation.
|
|
@@ -13745,5 +14140,5 @@ if (win) {
|
|
|
13745
14140
|
* Generated bundle index. Do not edit.
|
|
13746
14141
|
*/
|
|
13747
14142
|
|
|
13748
|
-
export { AbstractDataServiceAdapter, AndOrPredicate, AnyAllPredicate, AutoGeneratedKeyType, BinaryPredicate, BreezeConfig, BreezeEnum, BreezeEvent, ComplexAspect, ComplexType, DataProperty, DataService, DataType, EntityAction, EntityAspect, EntityKey, EntityManager, EntityQuery, EntityState, EntityType, ExpandClause, FetchStrategy, FilterQueryOp, FnExpr, InterfaceRegistry, JsonResultsAdapter, KeyGenerator, LitExpr, LocalQueryComparisonOptions, MappingContext, MergeStrategy, MetadataStore, NamingConvention, NavigationProperty, OrderByClause, Predicate, PropExpr, QueryOptions, SaveOptions, SelectClause, UnaryPredicate, ValidationError, ValidationOptions, Validator, assertConfig, assertParam, breeze, config, core, makeComplexArray, makePrimitiveArray, makeRelationArray
|
|
13749
|
-
//# sourceMappingURL=breeze-client.
|
|
14143
|
+
export { AbstractDataServiceAdapter, AndOrPredicate, AnyAllPredicate, AutoGeneratedKeyType, BinaryPredicate, BreezeConfig, BreezeEnum, BreezeEvent, ComplexAspect, ComplexType, DataProperty, DataService, DataType, EntityAction, EntityAspect, EntityKey, EntityManager, EntityQuery, EntityState, EntityType, ExpandClause, FetchStrategy, FilterQueryOp, FnExpr, InterfaceRegistry, JsonResultsAdapter, KeyGenerator, LitExpr, LocalQueryComparisonOptions, MappingContext, MergeStrategy, MetadataStore, NamingConvention, NavigationProperty, OrderByClause, Predicate, PropExpr, QueryOptions, SaveOptions, SelectClause, UnaryPredicate, ValidationError, ValidationOptions, Validator, assertConfig, assertParam, breeze, config, core, makeComplexArray, makePrimitiveArray, makeRelationArray };
|
|
14144
|
+
//# sourceMappingURL=breeze-client.mjs.map
|