breeze-client 2.1.7 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -4
- 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 +239 -0
- package/{esm2015/src/data-type.js → esm2022/src/data-type.mjs} +131 -124
- 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 +127 -0
- package/esm2022/src/entity-manager.mjs +2183 -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 +75 -0
- package/esm2022/src/mapping-context.mjs +422 -0
- package/{esm5/src/naming-convention.js → esm2022/src/naming-convention.mjs} +35 -29
- 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 +160 -0
- package/esm2022/src/relation-array.mjs +173 -0
- package/esm2022/src/save-options.mjs +51 -0
- package/esm2022/src/unattached-children-map.mjs +56 -0
- package/{esm5/src/validate.js → esm2022/src/validate.mjs} +116 -110
- package/esm2022/src/validation-options.mjs +78 -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} +2039 -1537
- 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 -14231
- 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/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 -510
- 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/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/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 -13953
- 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
|
}
|
|
@@ -1651,6 +1687,24 @@ anytime a MetadataStore.fetchMetadata call occurs with a new dataService ( or se
|
|
|
1651
1687
|
|
|
1652
1688
|
**/
|
|
1653
1689
|
class DataService {
|
|
1690
|
+
/** @hidden @internal */
|
|
1691
|
+
_$typeName; // actually put on prototype.
|
|
1692
|
+
/** The serviceName for this DataService. __Read Only__ **/
|
|
1693
|
+
serviceName;
|
|
1694
|
+
/** The adapter name for the [[IDataServiceAdapter]] to be used with this service. __Read Only__ **/
|
|
1695
|
+
adapterName;
|
|
1696
|
+
/** The [[IDataServiceAdapter]] implementation instance associated with this EntityManager. __Read Only__ **/
|
|
1697
|
+
adapterInstance;
|
|
1698
|
+
/** The adapter name for the [[IUriBuilderAdapter]] to be used with this service. __Read Only__ **/
|
|
1699
|
+
uriBuilderName;
|
|
1700
|
+
/** The [[IUriBuilderAdapter]] implementation instance associated with this EntityManager. __Read Only__ **/
|
|
1701
|
+
uriBuilder;
|
|
1702
|
+
/** Whether the server can provide metadata for this service. __Read Only__ **/
|
|
1703
|
+
hasServerMetadata;
|
|
1704
|
+
/** The [[JsonResultsAdapter]] used to process the results of any query against this DataService. __Read Only__ **/
|
|
1705
|
+
jsonResultsAdapter;
|
|
1706
|
+
/** Whether to use JSONP when performing a 'GET' request against this service. __Read Only__ **/
|
|
1707
|
+
useJsonp;
|
|
1654
1708
|
/** DataService constructor
|
|
1655
1709
|
> var dataService = new DataService({
|
|
1656
1710
|
> serviceName: altServiceName,
|
|
@@ -1668,7 +1722,7 @@ class DataService {
|
|
|
1668
1722
|
@param config - A configuration object.
|
|
1669
1723
|
**/
|
|
1670
1724
|
constructor(config) {
|
|
1671
|
-
updateWithConfig(this, config);
|
|
1725
|
+
updateWithConfig$1(this, config);
|
|
1672
1726
|
}
|
|
1673
1727
|
/**
|
|
1674
1728
|
Returns a copy of this DataService with the specified properties applied.
|
|
@@ -1678,7 +1732,7 @@ class DataService {
|
|
|
1678
1732
|
if (!config)
|
|
1679
1733
|
return this;
|
|
1680
1734
|
let result = new DataService(this);
|
|
1681
|
-
return updateWithConfig(result, config);
|
|
1735
|
+
return updateWithConfig$1(result, config);
|
|
1682
1736
|
}
|
|
1683
1737
|
static resolve(dataServices) {
|
|
1684
1738
|
// final defaults
|
|
@@ -1749,7 +1803,7 @@ class DataService {
|
|
|
1749
1803
|
}
|
|
1750
1804
|
}
|
|
1751
1805
|
DataService.prototype._$typeName = "DataService";
|
|
1752
|
-
function updateWithConfig(obj, dsConfig) {
|
|
1806
|
+
function updateWithConfig$1(obj, dsConfig) {
|
|
1753
1807
|
if (dsConfig) {
|
|
1754
1808
|
assertConfig(dsConfig)
|
|
1755
1809
|
.whereParam("serviceName").isOptional()
|
|
@@ -1770,6 +1824,24 @@ A JsonResultsAdapter instance is used to provide custom extraction and parsing l
|
|
|
1770
1824
|
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
1825
|
**/
|
|
1772
1826
|
class JsonResultsAdapter {
|
|
1827
|
+
/** @hidden @internal */
|
|
1828
|
+
_$typeName; // actually put on prototype.
|
|
1829
|
+
/** The name of this adapter. This name is used to uniquely identify and locate this instance when an 'exported' JsonResultsAdapter is later imported. */
|
|
1830
|
+
name;
|
|
1831
|
+
/** A Function that is called once per query operation to extract the 'payload' from any json received over the wire.
|
|
1832
|
+
This method has a default implementation which simply returns the "results" property from any json returned as a result of executing the query. */
|
|
1833
|
+
extractResults; // TODO - refine
|
|
1834
|
+
/** A function that is called once per save operation to extract the entities from any json received over the wire. Must return an array.
|
|
1835
|
+
This method has a default implementation which simply returns the "entities" property from any json returned as a result of executing the save. */
|
|
1836
|
+
extractSaveResults;
|
|
1837
|
+
/** 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.
|
|
1838
|
+
This method has a default implementation which simply returns the "keyMappings" property from any json returned as a result of executing the save. */
|
|
1839
|
+
extractKeyMappings;
|
|
1840
|
+
/** 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.
|
|
1841
|
+
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. */
|
|
1842
|
+
extractDeletedKeys; // TODO: refine
|
|
1843
|
+
/** A visitor method that will be called on each node of the returned payload. */
|
|
1844
|
+
visitNode;
|
|
1773
1845
|
/**
|
|
1774
1846
|
JsonResultsAdapter constructor
|
|
1775
1847
|
|
|
@@ -1842,17 +1914,16 @@ const INT32_MIN = -2147483648;
|
|
|
1842
1914
|
const INT32_MAX = 2147483647;
|
|
1843
1915
|
const BYTE_MIN = 0;
|
|
1844
1916
|
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
1917
|
// add common props and methods for every validator 'context' here.
|
|
1854
1918
|
let rootContext = {
|
|
1855
|
-
displayName:
|
|
1919
|
+
displayName: function (context) {
|
|
1920
|
+
if (context.property) {
|
|
1921
|
+
return context.property.resolveProperty("displayName") || context.propertyName || context.property.name;
|
|
1922
|
+
}
|
|
1923
|
+
else {
|
|
1924
|
+
return "Value";
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1856
1927
|
};
|
|
1857
1928
|
/**
|
|
1858
1929
|
Instances of the Validator class provide the logic to validate another object and provide a description of any errors
|
|
@@ -1990,6 +2061,13 @@ of additional properties that will be automatically added to this object if not
|
|
|
1990
2061
|
@dynamic
|
|
1991
2062
|
**/
|
|
1992
2063
|
class Validator {
|
|
2064
|
+
/** @hidden @internal */
|
|
2065
|
+
_$typeName; // on proto
|
|
2066
|
+
name;
|
|
2067
|
+
valFn;
|
|
2068
|
+
context;
|
|
2069
|
+
currentContext;
|
|
2070
|
+
_baseContext;
|
|
1993
2071
|
constructor(name, valFn, context) {
|
|
1994
2072
|
// _baseContext is what will get serialized
|
|
1995
2073
|
this._baseContext = context || {};
|
|
@@ -2138,491 +2216,491 @@ class Validator {
|
|
|
2138
2216
|
static registerFactory(validatorFactory, name) {
|
|
2139
2217
|
config.registerFunction(validatorFactory, "Validator." + name);
|
|
2140
2218
|
}
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2219
|
+
/**
|
|
2220
|
+
Map of standard error message templates keyed by validator name.
|
|
2221
|
+
You can add to or modify this object to customize the template used for any validation error message.
|
|
2222
|
+
@example
|
|
2223
|
+
// v is this function is the value to be validated, in this case a "country" string.
|
|
2224
|
+
var valFn = function (v) {
|
|
2225
|
+
if (v == null) return true;
|
|
2226
|
+
return (core.stringStartsWith(v, "US"));
|
|
2227
|
+
};
|
|
2228
|
+
var countryValidator = new Validator("countryIsUS", valFn, { displayName: "Country" });
|
|
2229
|
+
Validator.messageTemplates.countryIsUS = "'%displayName%' must start with 'US'";
|
|
2230
|
+
// This will have a similar effect to this
|
|
2231
|
+
var countryValidator = new Validator("countryIsUS", valFn, {
|
|
2232
|
+
displayName: "Country",
|
|
2233
|
+
messageTemplate: "'%displayName%' must start with 'US'"
|
|
2234
|
+
});
|
|
2235
|
+
@property messageTemplates {Object}
|
|
2236
|
+
@static
|
|
2237
|
+
**/
|
|
2238
|
+
static messageTemplates = {
|
|
2239
|
+
bool: "'%displayName%' must be a 'true' or 'false' value",
|
|
2240
|
+
creditCard: "The %displayName% is not a valid credit card number",
|
|
2241
|
+
date: "'%displayName%' must be a date",
|
|
2242
|
+
duration: "'%displayName%' must be a ISO8601 duration string, such as 'P3H24M60S'",
|
|
2243
|
+
emailAddress: "The %displayName% '%value%' is not a valid email address",
|
|
2244
|
+
guid: "'%displayName%' must be a GUID",
|
|
2245
|
+
integer: "'%displayName%' must be an integer",
|
|
2246
|
+
integerRange: "'%displayName%' must be an integer between the values of %minValue% and %maxValue%",
|
|
2247
|
+
maxLength: "'%displayName%' must be a string with %maxLength% characters or less",
|
|
2248
|
+
number: "'%displayName%' must be a number",
|
|
2249
|
+
phone: "The %displayName% '%value%' is not a valid phone number",
|
|
2250
|
+
regularExpression: "The %displayName% '%value%' does not match '%expression%'",
|
|
2251
|
+
required: "'%displayName%' is required",
|
|
2252
|
+
string: "'%displayName%' must be a string",
|
|
2253
|
+
stringLength: "'%displayName%' must be a string with between %minLength% and %maxLength% characters",
|
|
2254
|
+
url: "The %displayName% '%value%' is not a valid url"
|
|
2150
2255
|
};
|
|
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)
|
|
2256
|
+
/**
|
|
2257
|
+
Returns a standard 'required value' Validator
|
|
2258
|
+
@example
|
|
2259
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2260
|
+
var custType = em1.metadataStore.getEntityType("Customer");
|
|
2261
|
+
var regionProperty - custType.getProperty("Region");
|
|
2262
|
+
// Makes "Region" on Customer a required property.
|
|
2263
|
+
regionProperty.validators.push(Validator.required());
|
|
2264
|
+
// or to allow empty strings
|
|
2265
|
+
regionProperty.validators.push(Validator.required({ allowEmptyStrings: true }););
|
|
2266
|
+
@method required
|
|
2267
|
+
@static
|
|
2268
|
+
@param context {Object}
|
|
2269
|
+
@param [context.allowEmptyStrings] {Boolean} If this parameter is omitted or false then empty strings do NOT pass validation.
|
|
2270
|
+
@return {Validator} A new Validator
|
|
2271
|
+
**/
|
|
2272
|
+
static required = function (context) {
|
|
2273
|
+
let valFn = function (v, ctx) {
|
|
2274
|
+
if (typeof v === "string") {
|
|
2275
|
+
if (ctx && ctx.allowEmptyStrings)
|
|
2276
|
+
return true;
|
|
2277
|
+
return v.length > 0;
|
|
2278
|
+
}
|
|
2279
|
+
else {
|
|
2280
|
+
return v != null;
|
|
2281
|
+
}
|
|
2282
|
+
};
|
|
2283
|
+
return new Validator("required", valFn, context);
|
|
2284
|
+
};
|
|
2285
|
+
/**
|
|
2286
|
+
Returns a standard maximum string length Validator; the maximum length must be specified
|
|
2287
|
+
@example
|
|
2288
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2289
|
+
var custType = em1.metadataStore.getEntityType("Customer");
|
|
2290
|
+
var regionProperty - custType.getProperty("Region");
|
|
2291
|
+
// Validates that the value of the Region property on Customer will be less than or equal to 5 characters.
|
|
2292
|
+
regionProperty.validators.push(Validator.maxLength( {maxLength: 5}));
|
|
2293
|
+
@method maxLength
|
|
2294
|
+
@static
|
|
2295
|
+
@param context {Object}
|
|
2296
|
+
@param context.maxLength {Integer}
|
|
2297
|
+
@return {Validator} A new Validator
|
|
2298
|
+
**/
|
|
2299
|
+
static maxLength = function (context) {
|
|
2300
|
+
let valFn = function (v, ctx) {
|
|
2301
|
+
if (v == null)
|
|
2199
2302
|
return true;
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2303
|
+
if (typeof (v) !== "string")
|
|
2304
|
+
return false;
|
|
2305
|
+
return v.length <= ctx.maxLength;
|
|
2306
|
+
};
|
|
2307
|
+
return new Validator("maxLength", valFn, context);
|
|
2205
2308
|
};
|
|
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
|
-
|
|
2309
|
+
/**
|
|
2310
|
+
Returns a standard string length Validator; both minimum and maximum lengths must be specified.
|
|
2311
|
+
@example
|
|
2312
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2313
|
+
var custType = em1.metadataStore.getEntityType("Customer");
|
|
2314
|
+
var regionProperty - custType.getProperty("Region");
|
|
2315
|
+
// Validates that the value of the Region property on Customer will be
|
|
2316
|
+
// between 2 and 5 characters
|
|
2317
|
+
regionProperty.validators.push(Validator.stringLength( {minLength: 2, maxLength: 5});
|
|
2318
|
+
@method stringLength
|
|
2319
|
+
@static
|
|
2320
|
+
@param context {Object}
|
|
2321
|
+
@param context.maxLength {Integer}
|
|
2322
|
+
@param context.minLength {Integer}
|
|
2323
|
+
@return {Validator} A new Validator
|
|
2324
|
+
**/
|
|
2325
|
+
static stringLength = function (context) {
|
|
2326
|
+
let valFn = function (v, ctx) {
|
|
2327
|
+
if (v == null)
|
|
2328
|
+
return true;
|
|
2329
|
+
if (typeof (v) !== "string")
|
|
2330
|
+
return false;
|
|
2331
|
+
if (ctx.minLength != null && v.length < ctx.minLength)
|
|
2332
|
+
return false;
|
|
2333
|
+
if (ctx.maxLength != null && v.length > ctx.maxLength)
|
|
2334
|
+
return false;
|
|
2225
2335
|
return true;
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
return v.length <= ctx.maxLength;
|
|
2336
|
+
};
|
|
2337
|
+
return new Validator("stringLength", valFn, context);
|
|
2229
2338
|
};
|
|
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;
|
|
2339
|
+
/**
|
|
2340
|
+
Returns a standard string dataType Validator.
|
|
2341
|
+
@example
|
|
2342
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2343
|
+
var custType = em1.metadataStore.getEntityType("Customer");
|
|
2344
|
+
var regionProperty - custType.getProperty("Region");
|
|
2345
|
+
// Validates that the value of the Region property on Customer is a string.
|
|
2346
|
+
regionProperty.validators.push(Validator.string());
|
|
2347
|
+
@method string
|
|
2348
|
+
@static
|
|
2349
|
+
@return {Validator} A new Validator
|
|
2350
|
+
**/
|
|
2351
|
+
static string = function () {
|
|
2352
|
+
let valFn = function (v) {
|
|
2353
|
+
if (v == null)
|
|
2354
|
+
return true;
|
|
2355
|
+
return (typeof v === "string");
|
|
2356
|
+
};
|
|
2357
|
+
return new Validator("string", valFn);
|
|
2259
2358
|
};
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
@
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
return (
|
|
2359
|
+
/**
|
|
2360
|
+
Returns a Guid data type Validator.
|
|
2361
|
+
@example
|
|
2362
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2363
|
+
var custType = em1.metadataStore.getEntityType("Customer");
|
|
2364
|
+
var customerIdProperty - custType.getProperty("CustomerID");
|
|
2365
|
+
// Validates that the value of the CustomerID property on Customer is a Guid.
|
|
2366
|
+
customerIdProperty.validators.push(Validator.guid());
|
|
2367
|
+
@method guid
|
|
2368
|
+
@static
|
|
2369
|
+
@return {Validator} A new Validator
|
|
2370
|
+
**/
|
|
2371
|
+
static guid = function () {
|
|
2372
|
+
let valFn = function (v) {
|
|
2373
|
+
if (v == null)
|
|
2374
|
+
return true;
|
|
2375
|
+
return core.isGuid(v);
|
|
2376
|
+
};
|
|
2377
|
+
return new Validator("guid", valFn);
|
|
2279
2378
|
};
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
@
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
return
|
|
2379
|
+
/**
|
|
2380
|
+
Returns a ISO 8601 duration string Validator.
|
|
2381
|
+
@example
|
|
2382
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2383
|
+
var eventType = em1.metadataStore.getEntityType("Event");
|
|
2384
|
+
var elapsedTimeProperty - eventType.getProperty("ElapsedTime");
|
|
2385
|
+
// Validates that the value of the ElapsedTime property on Customer is a duration.
|
|
2386
|
+
elapsedTimeProperty.validators.push(Validator.duration());
|
|
2387
|
+
@method duration
|
|
2388
|
+
@static
|
|
2389
|
+
@return {Validator} A new Validator
|
|
2390
|
+
**/
|
|
2391
|
+
static duration = function () {
|
|
2392
|
+
let valFn = function (v) {
|
|
2393
|
+
if (v == null)
|
|
2394
|
+
return true;
|
|
2395
|
+
return core.isDuration(v);
|
|
2396
|
+
};
|
|
2397
|
+
return new Validator("duration", valFn);
|
|
2299
2398
|
};
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
@
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2399
|
+
/**
|
|
2400
|
+
Returns a standard numeric data type Validator.
|
|
2401
|
+
@example
|
|
2402
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2403
|
+
var orderType = em1.metadataStore.getEntityType("Order");
|
|
2404
|
+
var freightProperty - orderType.getProperty("Freight");
|
|
2405
|
+
// Validates that the value of the Freight property on Order is a number.
|
|
2406
|
+
freightProperty.validators.push(Validator.number());
|
|
2407
|
+
@method number
|
|
2408
|
+
@static
|
|
2409
|
+
@return {Validator} A new Validator
|
|
2410
|
+
**/
|
|
2411
|
+
// TODO: may need to have seperate logic for single.
|
|
2412
|
+
static number = 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 = parseFloat(v);
|
|
2418
|
+
}
|
|
2419
|
+
return (typeof v === "number" && !isNaN(v));
|
|
2420
|
+
};
|
|
2421
|
+
return new Validator("number", valFn, context);
|
|
2319
2422
|
};
|
|
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
|
-
|
|
2423
|
+
static double = Validator.number;
|
|
2424
|
+
static single = Validator.number;
|
|
2425
|
+
/**
|
|
2426
|
+
Returns a standard large integer data type - 64 bit - Validator.
|
|
2427
|
+
@example
|
|
2428
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2429
|
+
var orderType = em1.metadataStore.getEntityType("Order");
|
|
2430
|
+
var freightProperty - orderType.getProperty("Freight");
|
|
2431
|
+
// Validates that the value of the Freight property on Order is within the range of a 64 bit integer.
|
|
2432
|
+
freightProperty.validators.push(Validator.int64());
|
|
2433
|
+
@method int64
|
|
2434
|
+
@static
|
|
2435
|
+
@return {Validator} A new Validator
|
|
2436
|
+
**/
|
|
2437
|
+
static integer = function (context) {
|
|
2438
|
+
let valFn = function (v, ctx) {
|
|
2439
|
+
if (v == null)
|
|
2440
|
+
return true;
|
|
2441
|
+
if (typeof v === "string" && ctx && ctx.allowString) {
|
|
2442
|
+
v = parseInt(v, 10);
|
|
2443
|
+
}
|
|
2444
|
+
return (typeof v === "number") && (!isNaN(v)) && Math.floor(v) === v;
|
|
2445
|
+
};
|
|
2446
|
+
return new Validator("integer", valFn, context);
|
|
2343
2447
|
};
|
|
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;
|
|
2448
|
+
static int64 = Validator.integer;
|
|
2449
|
+
/**
|
|
2450
|
+
Returns a standard 32 bit integer data type Validator.
|
|
2451
|
+
@example
|
|
2452
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2453
|
+
var orderType = em1.metadataStore.getEntityType("Order");
|
|
2454
|
+
var freightProperty - orderType.getProperty("Freight");
|
|
2455
|
+
freightProperty.validators.push(Validator.int32());
|
|
2456
|
+
@method int32
|
|
2457
|
+
@static
|
|
2458
|
+
@return {Validator} A new Validator
|
|
2459
|
+
**/
|
|
2460
|
+
static int32 = function (context) {
|
|
2461
|
+
return intRangeValidatorCtor("int32", INT32_MIN, INT32_MAX, context)();
|
|
2368
2462
|
};
|
|
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);
|
|
2463
|
+
/**
|
|
2464
|
+
Returns a standard 16 bit integer data type Validator.
|
|
2465
|
+
@example
|
|
2466
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2467
|
+
var orderType = em1.metadataStore.getEntityType("Order");
|
|
2468
|
+
var freightProperty - orderType.getProperty("Freight");
|
|
2469
|
+
// Validates that the value of the Freight property on Order is within the range of a 16 bit integer.
|
|
2470
|
+
freightProperty.validators.push(Validator.int16());
|
|
2471
|
+
@method int16
|
|
2472
|
+
@static
|
|
2473
|
+
@return {Validator} A new Validator
|
|
2474
|
+
**/
|
|
2475
|
+
static int16 = function (context) {
|
|
2476
|
+
return intRangeValidatorCtor("int16", INT16_MIN, INT16_MAX, context)();
|
|
2434
2477
|
};
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2478
|
+
/**
|
|
2479
|
+
Returns a standard byte data type Validator. (This is a integer between 0 and 255 inclusive for js purposes).
|
|
2480
|
+
@example
|
|
2481
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2482
|
+
var orderType = em1.metadataStore.getEntityType("Order");
|
|
2483
|
+
var freightProperty - orderType.getProperty("Freight");
|
|
2484
|
+
// Validates that the value of the Freight property on Order is within the range of a 16 bit integer.
|
|
2485
|
+
// Probably not a very good validation to place on the Freight property.
|
|
2486
|
+
regionProperty.validators.push(Validator.byte());
|
|
2487
|
+
@method byte
|
|
2488
|
+
@static
|
|
2489
|
+
@return {Validator} A new Validator
|
|
2490
|
+
**/
|
|
2491
|
+
static byte = function (context) {
|
|
2492
|
+
return intRangeValidatorCtor("byte", BYTE_MIN, BYTE_MAX, context)();
|
|
2440
2493
|
};
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2494
|
+
/**
|
|
2495
|
+
Returns a standard boolean data type Validator.
|
|
2496
|
+
@example
|
|
2497
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2498
|
+
var productType = em1.metadataStore.getEntityType("Product");
|
|
2499
|
+
var discontinuedProperty - productType.getProperty("Discontinued");
|
|
2500
|
+
// Validates that the value of the Discontinued property on Product is a boolean
|
|
2501
|
+
discontinuedProperty.validators.push(Validator.bool());
|
|
2502
|
+
@method bool
|
|
2503
|
+
@static
|
|
2504
|
+
@return {Validator} A new Validator
|
|
2505
|
+
**/
|
|
2506
|
+
static bool = function () {
|
|
2507
|
+
let valFn = function (v) {
|
|
2508
|
+
if (v == null)
|
|
2509
|
+
return true;
|
|
2510
|
+
return (v === true) || (v === false);
|
|
2511
|
+
};
|
|
2512
|
+
return new Validator("bool", valFn);
|
|
2513
|
+
};
|
|
2514
|
+
static none = function () {
|
|
2515
|
+
let valFn = function (v) {
|
|
2459
2516
|
return true;
|
|
2460
|
-
|
|
2517
|
+
};
|
|
2518
|
+
return new Validator("none", valFn);
|
|
2519
|
+
};
|
|
2520
|
+
/**
|
|
2521
|
+
Returns a standard date data type Validator.
|
|
2522
|
+
@example
|
|
2523
|
+
// Assume em1 is a preexisting EntityManager.
|
|
2524
|
+
var orderType = em1.metadataStore.getEntityType("Order");
|
|
2525
|
+
var orderDateProperty - orderType.getProperty("OrderDate");
|
|
2526
|
+
// Validates that the value of the OrderDate property on Order is a date
|
|
2527
|
+
// Probably not a very good validation to place on the Freight property.
|
|
2528
|
+
orderDateProperty.validators.push(Validator.date());
|
|
2529
|
+
@method date
|
|
2530
|
+
@static
|
|
2531
|
+
@return {Validator} A new Validator
|
|
2532
|
+
**/
|
|
2533
|
+
static date = function () {
|
|
2534
|
+
let valFn = function (v) {
|
|
2535
|
+
if (v == null)
|
|
2536
|
+
return true;
|
|
2537
|
+
if (typeof v === "string") {
|
|
2538
|
+
try {
|
|
2539
|
+
return !isNaN(Date.parse(v));
|
|
2540
|
+
// old code
|
|
2541
|
+
// return __isDate(new Date(v));
|
|
2542
|
+
}
|
|
2543
|
+
catch (e) {
|
|
2544
|
+
return false;
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
else {
|
|
2548
|
+
return core.isDate(v);
|
|
2549
|
+
}
|
|
2550
|
+
};
|
|
2551
|
+
return new Validator("date", valFn);
|
|
2552
|
+
};
|
|
2553
|
+
/**
|
|
2554
|
+
Returns a credit card number validator
|
|
2555
|
+
Performs a luhn algorithm checksum test for plausability
|
|
2556
|
+
catches simple mistakes; only service knows for sure
|
|
2557
|
+
@example
|
|
2558
|
+
// Assume em is a preexisting EntityManager.
|
|
2559
|
+
var personType = em.metadataStore.getEntityType("Person");
|
|
2560
|
+
var creditCardProperty = personType.getProperty("creditCard");
|
|
2561
|
+
// Validates that the value of the Person.creditCard property is credit card.
|
|
2562
|
+
creditCardProperty.validators.push(Validator.creditCard());
|
|
2563
|
+
@method creditCard
|
|
2564
|
+
@static
|
|
2565
|
+
@param [context] {Object} optional parameters to pass through to validation constructor
|
|
2566
|
+
@return {Validator} A new Validator
|
|
2567
|
+
**/
|
|
2568
|
+
static creditCard = function (context) {
|
|
2569
|
+
function valFn(v) {
|
|
2570
|
+
if (v == null || v === '')
|
|
2571
|
+
return true;
|
|
2572
|
+
if (typeof (v) !== 'string')
|
|
2573
|
+
return false;
|
|
2574
|
+
v = v.replace(/(\-|\s)/g, ""); // remove dashes and spaces
|
|
2575
|
+
if (!v || /\D/.test(v))
|
|
2576
|
+
return false; // all digits, not empty
|
|
2577
|
+
return luhn(v);
|
|
2578
|
+
}
|
|
2579
|
+
return new Validator('creditCard', valFn, context);
|
|
2580
|
+
};
|
|
2581
|
+
/**
|
|
2582
|
+
Returns a regular expression validator; the expression must be specified
|
|
2583
|
+
@example
|
|
2584
|
+
// Add validator to a property. Assume em is a preexisting EntityManager.
|
|
2585
|
+
var customerType = em.metadataStore.getEntityType("Customer");
|
|
2586
|
+
var regionProperty = customerType.getProperty("Region");
|
|
2587
|
+
// Validates that the value of Customer.Region is 2 char uppercase alpha.
|
|
2588
|
+
regionProperty.validators.push(Validator.regularExpression( {expression: '^[A-Z]{2}$'} );
|
|
2589
|
+
@method regularExpression
|
|
2590
|
+
@static
|
|
2591
|
+
@param context {Object}
|
|
2592
|
+
@param context.expression {String} String form of the regular expression to apply
|
|
2593
|
+
@return {Validator} A new Validator
|
|
2594
|
+
**/
|
|
2595
|
+
static regularExpression = function (context) {
|
|
2596
|
+
function valFn(v, ctx) {
|
|
2597
|
+
// do not invalidate if empty; use a separate required test
|
|
2598
|
+
if (v == null || v === '')
|
|
2599
|
+
return true;
|
|
2600
|
+
if (typeof (v) !== 'string')
|
|
2601
|
+
return false;
|
|
2461
2602
|
try {
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
// return __isDate(new Date(v));
|
|
2603
|
+
let re = new RegExp(ctx.expression);
|
|
2604
|
+
return re.test(v);
|
|
2465
2605
|
}
|
|
2466
2606
|
catch (e) {
|
|
2467
|
-
|
|
2607
|
+
throw new Error('Missing or invalid expression parameter to regExp validator');
|
|
2468
2608
|
}
|
|
2469
2609
|
}
|
|
2470
|
-
|
|
2471
|
-
return core.isDate(v);
|
|
2472
|
-
}
|
|
2610
|
+
return new Validator('regularExpression', valFn, context);
|
|
2473
2611
|
};
|
|
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;
|
|
2612
|
+
/**
|
|
2613
|
+
Returns the email address validator
|
|
2614
|
+
@example
|
|
2615
|
+
// Assume em is a preexisting EntityManager.
|
|
2616
|
+
var personType = em.metadataStore.getEntityType("Person");
|
|
2617
|
+
var emailProperty = personType.getProperty("email");
|
|
2618
|
+
// Validates that the value of the Person.email property is an email address.
|
|
2619
|
+
emailProperty.validators.push(Validator.emailAddress());
|
|
2620
|
+
@method emailAddress
|
|
2621
|
+
@static
|
|
2622
|
+
@param [context] {Object} optional parameters to pass through to validation constructor
|
|
2623
|
+
@return {Validator} A new Validator
|
|
2624
|
+
**/
|
|
2625
|
+
static emailAddress = function (context) {
|
|
2626
|
+
// See https://github.com/srkirkland/DataAnnotationsExtensions/blob/master/DataAnnotationsExtensions/EmailAttribute.cs
|
|
2627
|
+
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;
|
|
2628
|
+
return makeRegExpValidator('emailAddress', reEmailAddress, null, context);
|
|
2629
|
+
};
|
|
2630
|
+
/**
|
|
2631
|
+
Returns the phone validator
|
|
2632
|
+
Provides basic assertions on the format and will help to eliminate most nonsense input
|
|
2633
|
+
Matches:
|
|
2634
|
+
International dialing prefix: {{}, +, 0, 0000} (with or without a trailing break character, if not '+': [-/. ])
|
|
2635
|
+
> ((\+)|(0(\d+)?[-/.\s]))
|
|
2636
|
+
Country code: {{}, 1, ..., 999} (with or without a trailing break character: [-/. ])
|
|
2637
|
+
> [1-9]\d{,2}[-/.\s]?
|
|
2638
|
+
Area code: {(0), ..., (000000), 0, ..., 000000} (with or without a trailing break character: [-/. ])
|
|
2639
|
+
> ((\(\d{1,6}\)|\d{1,6})[-/.\s]?)?
|
|
2640
|
+
Local: {0, ...}+ (with or without a trailing break character: [-/. ])
|
|
2641
|
+
> (\d+[-/.\s]?)+\d+
|
|
2642
|
+
@example
|
|
2643
|
+
// Assume em is a preexisting EntityManager.
|
|
2644
|
+
var customerType = em.metadataStore.getEntityType("Customer");
|
|
2645
|
+
var phoneProperty = customerType.getProperty("phone");
|
|
2646
|
+
// Validates that the value of the Customer.phone property is phone.
|
|
2647
|
+
phoneProperty.validators.push(Validator.phone());
|
|
2648
|
+
@method phone
|
|
2649
|
+
@static
|
|
2650
|
+
@param [context] {Object} optional parameters to pass through to validation constructor
|
|
2651
|
+
@return {Validator} A new Validator
|
|
2652
|
+
**/
|
|
2653
|
+
static phone = function (context) {
|
|
2654
|
+
// See https://github.com/srkirkland/DataAnnotationsExtensions/blob/master/DataAnnotationsExtensions/Expressions.cs
|
|
2655
|
+
let rePhone = /^((\+|(0(\d+)?[-/.\s]?))[1-9]\d{0,2}[-/.\s]?)?((\(\d{1,6}\)|\d{1,6})[-/.\s]?)?(\d+[-/.\s]?)+\d+$/;
|
|
2656
|
+
return makeRegExpValidator('phone', rePhone, null, context);
|
|
2657
|
+
};
|
|
2658
|
+
/**
|
|
2659
|
+
Returns the URL (protocol required) validator
|
|
2660
|
+
@example
|
|
2661
|
+
// Assume em is a preexisting EntityManager.
|
|
2662
|
+
var personType = em.metadataStore.getEntityType("Person");
|
|
2663
|
+
var websiteProperty = personType.getProperty("website");
|
|
2664
|
+
// Validates that the value of the Person.website property is a URL.
|
|
2665
|
+
websiteProperty.validators.push(Validator.url());
|
|
2666
|
+
@method url
|
|
2667
|
+
@static
|
|
2668
|
+
@param [context] {Object} optional parameters to pass through to validation constructor
|
|
2669
|
+
@return {Validator} A new Validator
|
|
2670
|
+
**/
|
|
2671
|
+
static url = function (context) {
|
|
2672
|
+
//See https://github.com/srkirkland/DataAnnotationsExtensions/blob/master/DataAnnotationsExtensions/UrlAttribute.cs
|
|
2673
|
+
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})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/;
|
|
2674
|
+
return makeRegExpValidator('url', reUrlProtocolRequired, null, context);
|
|
2675
|
+
};
|
|
2676
|
+
/**
|
|
2677
|
+
Creates a regular expression validator with a fixed expression.
|
|
2678
|
+
Many of the stock validators are built with this factory method.
|
|
2679
|
+
Their expressions are often derived from
|
|
2680
|
+
https://github.com/srkirkland/DataAnnotationsExtensions/blob/master/DataAnnotationsExtensions
|
|
2681
|
+
You can try many of them at http://dataannotationsextensions.org/
|
|
2682
|
+
@example
|
|
2683
|
+
// Make a zipcode validator
|
|
2684
|
+
function zipValidator = Validator.makeRegExpValidator(
|
|
2685
|
+
"zipVal,
|
|
2686
|
+
/^\d{5}([\-]\d{4})?$/,
|
|
2687
|
+
"The %displayName% '%value%' is not a valid U.S. zipcode");
|
|
2688
|
+
// Register it.
|
|
2689
|
+
Validator.register(zipValidator);
|
|
2690
|
+
// Add it to a data property. Assume em is a preexisting EntityManager.
|
|
2691
|
+
var custType = em.metadataStore.getEntityType("Customer");
|
|
2692
|
+
var zipProperty = custType.getProperty("PostalCode");
|
|
2693
|
+
zipProperty.validators.push(zipValidator);
|
|
2694
|
+
@method makeRegExpValidator
|
|
2695
|
+
@static
|
|
2696
|
+
@param validatorName {String} name of this validator
|
|
2697
|
+
@param expression {String | RegExp} regular expression to apply
|
|
2698
|
+
@param [defaultMessage] {String} default message for failed validations
|
|
2699
|
+
@param [context] {Object} optional parameters to pass through to validation constructor
|
|
2700
|
+
@return {Validator} A new Validator
|
|
2701
|
+
**/
|
|
2702
|
+
static makeRegExpValidator = makeRegExpValidator;
|
|
2703
|
+
}
|
|
2626
2704
|
Validator.prototype._$typeName = "Validator";
|
|
2627
2705
|
// register all validators
|
|
2628
2706
|
Error['x'] = core.objectForEach(Validator, function (key, value) {
|
|
@@ -2709,7 +2787,14 @@ function makeRegExpValidator(validatorName, expression, defaultMessage, context)
|
|
|
2709
2787
|
};
|
|
2710
2788
|
return new Validator(validatorName, valFn, context);
|
|
2711
2789
|
}
|
|
2712
|
-
|
|
2790
|
+
// http://rosettacode.org/wiki/Luhn_test_of_credit_card_numbers#JavaScript
|
|
2791
|
+
// function luhn(a: string, b: number, c: number, d: number, e: number) {
|
|
2792
|
+
// for (d = +a[b = a.length - 1], e = 0; b--; ) {
|
|
2793
|
+
// c = +a[b], d += ++e % 2 ? 2 * c % 10 + (c > 4) : c;
|
|
2794
|
+
// }
|
|
2795
|
+
// return !(d % 10);
|
|
2796
|
+
// };
|
|
2797
|
+
let luhn = (function () {
|
|
2713
2798
|
let luhnArr = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9];
|
|
2714
2799
|
return function (str) {
|
|
2715
2800
|
let counter = 0;
|
|
@@ -2724,15 +2809,7 @@ const ɵ1 = function () {
|
|
|
2724
2809
|
}
|
|
2725
2810
|
return (counter % 10 === 0);
|
|
2726
2811
|
};
|
|
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)();
|
|
2812
|
+
})();
|
|
2736
2813
|
/**
|
|
2737
2814
|
A ValidationError is used to describe a failed validation.
|
|
2738
2815
|
|
|
@@ -2748,6 +2825,13 @@ Constructs a new ValidationError
|
|
|
2748
2825
|
@param [key] {String} An optional key used to define a key for this error. One will be created automatically if not provided here.
|
|
2749
2826
|
**/
|
|
2750
2827
|
class ValidationError {
|
|
2828
|
+
validator;
|
|
2829
|
+
key;
|
|
2830
|
+
context;
|
|
2831
|
+
errorMessage;
|
|
2832
|
+
property; // IProperty
|
|
2833
|
+
propertyName;
|
|
2834
|
+
isServerError;
|
|
2751
2835
|
constructor(validator, context, errorMessage, key) {
|
|
2752
2836
|
// Error is with isInstanceOf(Validator)
|
|
2753
2837
|
assertParam(validator, "validator").isOptional().isInstanceOf(Validator).check();
|
|
@@ -2829,6 +2913,131 @@ DataType is an 'Enum' containing all of the supported data types.
|
|
|
2829
2913
|
@dynamic
|
|
2830
2914
|
**/
|
|
2831
2915
|
class DataType extends BreezeEnum {
|
|
2916
|
+
static parseDateFromServer = (value) => DataType.parseDateAsUTC(value);
|
|
2917
|
+
// same effect as above but doesn't give right TSDOC.
|
|
2918
|
+
// static parseDateFromServer = DataType.parseDateAsUTC;
|
|
2919
|
+
/** @hidden @internal */
|
|
2920
|
+
static constants;
|
|
2921
|
+
static String = new DataType({
|
|
2922
|
+
defaultValue: "",
|
|
2923
|
+
parse: coerceToString,
|
|
2924
|
+
fmtOData: fmtString,
|
|
2925
|
+
getNext: getNextString
|
|
2926
|
+
});
|
|
2927
|
+
static Int64 = new DataType({
|
|
2928
|
+
defaultValue: 0,
|
|
2929
|
+
isNumeric: true,
|
|
2930
|
+
isInteger: true,
|
|
2931
|
+
quoteJsonOData: true,
|
|
2932
|
+
parse: coerceToInt,
|
|
2933
|
+
fmtOData: makeFloatFmt("L"),
|
|
2934
|
+
getNext: getNextNumber
|
|
2935
|
+
});
|
|
2936
|
+
static Int32 = new DataType({
|
|
2937
|
+
defaultValue: 0,
|
|
2938
|
+
isNumeric: true,
|
|
2939
|
+
isInteger: true,
|
|
2940
|
+
parse: coerceToInt,
|
|
2941
|
+
fmtOData: fmtInt,
|
|
2942
|
+
getNext: getNextNumber
|
|
2943
|
+
});
|
|
2944
|
+
static Int16 = new DataType({
|
|
2945
|
+
defaultValue: 0,
|
|
2946
|
+
isNumeric: true,
|
|
2947
|
+
isInteger: true,
|
|
2948
|
+
parse: coerceToInt,
|
|
2949
|
+
fmtOData: fmtInt,
|
|
2950
|
+
getNext: getNextNumber
|
|
2951
|
+
});
|
|
2952
|
+
static Byte = new DataType({
|
|
2953
|
+
defaultValue: 0,
|
|
2954
|
+
isNumeric: true,
|
|
2955
|
+
isInteger: true,
|
|
2956
|
+
parse: coerceToInt,
|
|
2957
|
+
fmtOData: fmtInt
|
|
2958
|
+
});
|
|
2959
|
+
static Decimal = new DataType({
|
|
2960
|
+
defaultValue: 0,
|
|
2961
|
+
isNumeric: true,
|
|
2962
|
+
quoteJsonOData: true,
|
|
2963
|
+
isFloat: true,
|
|
2964
|
+
parse: coerceToFloat,
|
|
2965
|
+
fmtOData: makeFloatFmt("m"),
|
|
2966
|
+
getNext: getNextNumber
|
|
2967
|
+
});
|
|
2968
|
+
static Double = new DataType({
|
|
2969
|
+
defaultValue: 0,
|
|
2970
|
+
isNumeric: true,
|
|
2971
|
+
isFloat: true,
|
|
2972
|
+
parse: coerceToFloat,
|
|
2973
|
+
fmtOData: makeFloatFmt("d"),
|
|
2974
|
+
getNext: getNextNumber
|
|
2975
|
+
});
|
|
2976
|
+
static Single = new DataType({
|
|
2977
|
+
defaultValue: 0,
|
|
2978
|
+
isNumeric: true,
|
|
2979
|
+
isFloat: true,
|
|
2980
|
+
parse: coerceToFloat,
|
|
2981
|
+
fmtOData: makeFloatFmt("f"),
|
|
2982
|
+
getNext: getNextNumber
|
|
2983
|
+
});
|
|
2984
|
+
static DateOnly = new DataType({
|
|
2985
|
+
defaultValue: new Date(1900, 0, 1),
|
|
2986
|
+
isDate: true,
|
|
2987
|
+
parse: coerceToDateOnly,
|
|
2988
|
+
parseRawValue: parseRawDateOnly,
|
|
2989
|
+
normalize: function (value) { return value && value.getTime && (new Date(value.getYear(), value.getMonth(), value.getDate())).getTime(); },
|
|
2990
|
+
fmtOData: fmtDateOnly,
|
|
2991
|
+
getNext: getNextDateTime,
|
|
2992
|
+
getConcurrencyValue: getConcurrencyDateTime
|
|
2993
|
+
});
|
|
2994
|
+
static DateTime = new DataType({
|
|
2995
|
+
defaultValue: new Date(1900, 0, 1),
|
|
2996
|
+
isDate: true,
|
|
2997
|
+
parse: coerceToDate,
|
|
2998
|
+
parseRawValue: parseRawDate,
|
|
2999
|
+
normalize: function (value) { return value && value.getTime && value.getTime(); },
|
|
3000
|
+
fmtOData: fmtDateTime,
|
|
3001
|
+
getNext: getNextDateTime,
|
|
3002
|
+
getConcurrencyValue: getConcurrencyDateTime
|
|
3003
|
+
});
|
|
3004
|
+
static DateTimeOffset = new DataType({
|
|
3005
|
+
defaultValue: new Date(1900, 0, 1),
|
|
3006
|
+
isDate: true,
|
|
3007
|
+
parse: coerceToDate,
|
|
3008
|
+
parseRawValue: parseRawDate,
|
|
3009
|
+
normalize: function (value) { return value && value.getTime && value.getTime(); },
|
|
3010
|
+
fmtOData: fmtDateTimeOffset,
|
|
3011
|
+
getNext: getNextDateTime,
|
|
3012
|
+
getConcurrencyValue: getConcurrencyDateTime
|
|
3013
|
+
});
|
|
3014
|
+
static Time = new DataType({
|
|
3015
|
+
defaultValue: "PT0S",
|
|
3016
|
+
fmtOData: fmtTime,
|
|
3017
|
+
parseRawValue: DataType.parseTimeFromServer
|
|
3018
|
+
});
|
|
3019
|
+
static Boolean = new DataType({
|
|
3020
|
+
defaultValue: false,
|
|
3021
|
+
parse: coerceToBool,
|
|
3022
|
+
fmtOData: fmtBoolean
|
|
3023
|
+
});
|
|
3024
|
+
static Guid = new DataType({
|
|
3025
|
+
defaultValue: "00000000-0000-0000-0000-000000000000",
|
|
3026
|
+
parse: coerceToGuid,
|
|
3027
|
+
fmtOData: fmtGuid,
|
|
3028
|
+
getNext: getNextGuid,
|
|
3029
|
+
parseRawValue: function (val) { return val.toLowerCase(); },
|
|
3030
|
+
getConcurrencyValue: core.getUuid
|
|
3031
|
+
});
|
|
3032
|
+
static Binary = new DataType({
|
|
3033
|
+
defaultValue: null,
|
|
3034
|
+
fmtOData: fmtBinary,
|
|
3035
|
+
parseRawValue: parseRawBinary
|
|
3036
|
+
});
|
|
3037
|
+
static Undefined = new DataType({
|
|
3038
|
+
defaultValue: undefined,
|
|
3039
|
+
fmtOData: fmtUndefined
|
|
3040
|
+
});
|
|
2832
3041
|
static getComparableFn(dataType) {
|
|
2833
3042
|
if (dataType && dataType.normalize) {
|
|
2834
3043
|
return dataType.normalize;
|
|
@@ -2949,127 +3158,6 @@ class DataType extends BreezeEnum {
|
|
|
2949
3158
|
};
|
|
2950
3159
|
}
|
|
2951
3160
|
}
|
|
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
3161
|
DataType.prototype._$typeName = "DataType";
|
|
3074
3162
|
Error['x'] = DataType._resetConstants();
|
|
3075
3163
|
Error['x'] = DataType.resolveSymbols();
|
|
@@ -3170,8 +3258,9 @@ function coerceToDate(source, sourceTypeName) {
|
|
|
3170
3258
|
let val;
|
|
3171
3259
|
if (sourceTypeName === "string") {
|
|
3172
3260
|
let src = source.trim();
|
|
3173
|
-
if (
|
|
3261
|
+
if (!source || !source.trim()) {
|
|
3174
3262
|
return null;
|
|
3263
|
+
}
|
|
3175
3264
|
val = new Date(Date.parse(src));
|
|
3176
3265
|
return core.isDate(val) ? val : source;
|
|
3177
3266
|
}
|
|
@@ -3185,7 +3274,9 @@ function coerceToDate(source, sourceTypeName) {
|
|
|
3185
3274
|
function coerceToDateOnly(source, sourceTypeName) {
|
|
3186
3275
|
let val;
|
|
3187
3276
|
if (sourceTypeName === "string") {
|
|
3188
|
-
|
|
3277
|
+
if (!source || !source.trim()) {
|
|
3278
|
+
return null;
|
|
3279
|
+
}
|
|
3189
3280
|
val = DataType.parseDateAsLocal(val);
|
|
3190
3281
|
return core.isDate(val) ? val : source;
|
|
3191
3282
|
}
|
|
@@ -3327,6 +3418,16 @@ function parseRawBinary(val) {
|
|
|
3327
3418
|
EntityState is an 'Enum' containing all of the valid states for an 'Entity'.
|
|
3328
3419
|
**/
|
|
3329
3420
|
class EntityState extends BreezeEnum {
|
|
3421
|
+
/** The 'Unchanged' state. **/
|
|
3422
|
+
static Unchanged = new EntityState();
|
|
3423
|
+
/** The 'Added' state. **/
|
|
3424
|
+
static Added = new EntityState();
|
|
3425
|
+
/** The 'Modified' state. **/
|
|
3426
|
+
static Modified = new EntityState();
|
|
3427
|
+
/** The 'Deleted' state. **/
|
|
3428
|
+
static Deleted = new EntityState();
|
|
3429
|
+
/** The 'Detached' state. **/
|
|
3430
|
+
static Detached = new EntityState();
|
|
3330
3431
|
/**
|
|
3331
3432
|
Returns whether an entityState instance is EntityState.Unchanged.
|
|
3332
3433
|
> var es = anEntity.entityAspect.entityState;
|
|
@@ -3416,16 +3517,6 @@ class EntityState extends BreezeEnum {
|
|
|
3416
3517
|
this === EntityState.Deleted;
|
|
3417
3518
|
}
|
|
3418
3519
|
}
|
|
3419
|
-
/** The 'Unchanged' state. **/
|
|
3420
|
-
EntityState.Unchanged = new EntityState();
|
|
3421
|
-
/** The 'Added' state. **/
|
|
3422
|
-
EntityState.Added = new EntityState();
|
|
3423
|
-
/** The 'Modified' state. **/
|
|
3424
|
-
EntityState.Modified = new EntityState();
|
|
3425
|
-
/** The 'Deleted' state. **/
|
|
3426
|
-
EntityState.Deleted = new EntityState();
|
|
3427
|
-
/** The 'Detached' state. **/
|
|
3428
|
-
EntityState.Detached = new EntityState();
|
|
3429
3520
|
EntityState.prototype._$typeName = "EntityState";
|
|
3430
3521
|
Error['x'] = EntityState.resolveSymbols();
|
|
3431
3522
|
|
|
@@ -3433,6 +3524,30 @@ Error['x'] = EntityState.resolveSymbols();
|
|
|
3433
3524
|
|
|
3434
3525
|
*/
|
|
3435
3526
|
class EntityAction extends BreezeEnum {
|
|
3527
|
+
/** Entity was attached via an AttachEntity call. */
|
|
3528
|
+
static Attach = new EntityAction({ _isAttach: true });
|
|
3529
|
+
/** Entity was attached as a result of a query. */
|
|
3530
|
+
static AttachOnQuery = new EntityAction({ _isAttach: true });
|
|
3531
|
+
/** Entity was attached as a result of an import. */
|
|
3532
|
+
static AttachOnImport = new EntityAction({ _isAttach: true });
|
|
3533
|
+
/** Entity was detached */
|
|
3534
|
+
static Detach = new EntityAction({ _isDetach: true });
|
|
3535
|
+
/** Properties on the entity were merged as a result of a query. */
|
|
3536
|
+
static MergeOnQuery = new EntityAction({ _isModification: true });
|
|
3537
|
+
/** Properties on the entity were merged as a result of an import. */
|
|
3538
|
+
static MergeOnImport = new EntityAction({ _isModification: true });
|
|
3539
|
+
/** Properties on the entity were merged as a result of a save */
|
|
3540
|
+
static MergeOnSave = new EntityAction({ _isModification: true });
|
|
3541
|
+
/** A property on the entity was changed. */
|
|
3542
|
+
static PropertyChange = new EntityAction({ _isModification: true });
|
|
3543
|
+
/** The EntityState of the entity was changed. */
|
|
3544
|
+
static EntityStateChange = new EntityAction();
|
|
3545
|
+
/** AcceptChanges was called on the entity, or its entityState was set to Unmodified. */
|
|
3546
|
+
static AcceptChanges = new EntityAction();
|
|
3547
|
+
/** RejectChanges was called on the entity. */
|
|
3548
|
+
static RejectChanges = new EntityAction({ _isModification: true });
|
|
3549
|
+
/** The EntityManager was cleared. All entities detached. */
|
|
3550
|
+
static Clear = new EntityAction({ _isDetach: true });
|
|
3436
3551
|
/** Is this an 'attach' operation? ( Attach, AttachOnQuery or AttachOnImport) */
|
|
3437
3552
|
isAttach() {
|
|
3438
3553
|
return !!this._isAttach;
|
|
@@ -3446,30 +3561,6 @@ class EntityAction extends BreezeEnum {
|
|
|
3446
3561
|
return !!this._isModification;
|
|
3447
3562
|
}
|
|
3448
3563
|
}
|
|
3449
|
-
/** Entity was attached via an AttachEntity call. */
|
|
3450
|
-
EntityAction.Attach = new EntityAction({ _isAttach: true });
|
|
3451
|
-
/** Entity was attached as a result of a query. */
|
|
3452
|
-
EntityAction.AttachOnQuery = new EntityAction({ _isAttach: true });
|
|
3453
|
-
/** Entity was attached as a result of an import. */
|
|
3454
|
-
EntityAction.AttachOnImport = new EntityAction({ _isAttach: true });
|
|
3455
|
-
/** Entity was detached */
|
|
3456
|
-
EntityAction.Detach = new EntityAction({ _isDetach: true });
|
|
3457
|
-
/** Properties on the entity were merged as a result of a query. */
|
|
3458
|
-
EntityAction.MergeOnQuery = new EntityAction({ _isModification: true });
|
|
3459
|
-
/** Properties on the entity were merged as a result of an import. */
|
|
3460
|
-
EntityAction.MergeOnImport = new EntityAction({ _isModification: true });
|
|
3461
|
-
/** Properties on the entity were merged as a result of a save */
|
|
3462
|
-
EntityAction.MergeOnSave = new EntityAction({ _isModification: true });
|
|
3463
|
-
/** A property on the entity was changed. */
|
|
3464
|
-
EntityAction.PropertyChange = new EntityAction({ _isModification: true });
|
|
3465
|
-
/** The EntityState of the entity was changed. */
|
|
3466
|
-
EntityAction.EntityStateChange = new EntityAction();
|
|
3467
|
-
/** AcceptChanges was called on the entity, or its entityState was set to Unmodified. */
|
|
3468
|
-
EntityAction.AcceptChanges = new EntityAction();
|
|
3469
|
-
/** RejectChanges was called on the entity. */
|
|
3470
|
-
EntityAction.RejectChanges = new EntityAction({ _isModification: true });
|
|
3471
|
-
/** The EntityManager was cleared. All entities detached. */
|
|
3472
|
-
EntityAction.Clear = new EntityAction({ _isDetach: true });
|
|
3473
3564
|
EntityAction.prototype._$typeName = "EntityAction";
|
|
3474
3565
|
Error['x'] = EntityAction.resolveSymbols();
|
|
3475
3566
|
|
|
@@ -3479,6 +3570,19 @@ An EntityKey is an object that represents the unique identity of an entity. Ent
|
|
|
3479
3570
|
|
|
3480
3571
|
**/
|
|
3481
3572
|
class EntityKey {
|
|
3573
|
+
/** @hidden @internal */
|
|
3574
|
+
_$typeName; // actually placed on prototype
|
|
3575
|
+
/** @hidden @internal */
|
|
3576
|
+
static ENTITY_KEY_DELIMITER = ":::";
|
|
3577
|
+
/** The 'EntityType' that this is a key for. __Read Only__ */
|
|
3578
|
+
entityType;
|
|
3579
|
+
/** An array of the values for this key. This will usually only have a single element,
|
|
3580
|
+
unless the entity type has a multipart key. __Read Only__ */
|
|
3581
|
+
values;
|
|
3582
|
+
/** @hidden @internal */
|
|
3583
|
+
_keyInGroup;
|
|
3584
|
+
/** @hidden @internal */
|
|
3585
|
+
_subtypes;
|
|
3482
3586
|
/**
|
|
3483
3587
|
Constructs a new EntityKey. Each entity within an EntityManager will have a unique EntityKey.
|
|
3484
3588
|
> // assume em1 is an EntityManager containing a number of existing entities.
|
|
@@ -3581,8 +3685,6 @@ class EntityKey {
|
|
|
3581
3685
|
return keyValues.join(EntityKey.ENTITY_KEY_DELIMITER);
|
|
3582
3686
|
}
|
|
3583
3687
|
}
|
|
3584
|
-
/** @hidden @internal */
|
|
3585
|
-
EntityKey.ENTITY_KEY_DELIMITER = ":::";
|
|
3586
3688
|
EntityKey.prototype._$typeName = "EntityKey";
|
|
3587
3689
|
|
|
3588
3690
|
/**
|
|
@@ -3592,53 +3694,69 @@ MergeStrategy is an 'Enum' that determines how entities are merged into an Entit
|
|
|
3592
3694
|
@static
|
|
3593
3695
|
**/
|
|
3594
3696
|
class MergeStrategy extends BreezeEnum {
|
|
3697
|
+
/**
|
|
3698
|
+
MergeStrategy.PreserveChanges updates the cached entity with the incoming values unless the cached entity is in a changed
|
|
3699
|
+
state (added, modified, deleted) in which case the incoming values are ignored. The updated cached entity’s EntityState will
|
|
3700
|
+
remain [[EntityState.Unchanged]] unless you’re importing entities in which case the new EntityState will
|
|
3701
|
+
be that of the imported entities.
|
|
3702
|
+
**/
|
|
3703
|
+
static PreserveChanges = new MergeStrategy();
|
|
3704
|
+
/**
|
|
3705
|
+
MergeStrategy.OverwriteChanges always updates the cached entity with incoming values even if the entity is in
|
|
3706
|
+
a changed state (added, modified, deleted). After the merge, the pending changes are lost.
|
|
3707
|
+
The new EntityState will be [[EntityState/Unchanged]] unless you’re importing entities
|
|
3708
|
+
in which case the new EntityState will be that of the imported entities.
|
|
3709
|
+
**/
|
|
3710
|
+
static OverwriteChanges = new MergeStrategy();
|
|
3711
|
+
/**
|
|
3712
|
+
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.
|
|
3713
|
+
This is the fastest merge strategy but your existing cached data will remain “stale”.
|
|
3714
|
+
**/
|
|
3715
|
+
static SkipMerge = new MergeStrategy();
|
|
3716
|
+
/**
|
|
3717
|
+
Disallowed is used to throw an exception if there is an incoming entity with the same key as an entity already in the cache.
|
|
3718
|
+
Use this strategy when you want to be sure that the incoming entity is not already in cache.
|
|
3719
|
+
This is the default strategy for EntityManager.attachEntity.
|
|
3720
|
+
**/
|
|
3721
|
+
static Disallowed = new MergeStrategy();
|
|
3595
3722
|
}
|
|
3596
|
-
/**
|
|
3597
|
-
MergeStrategy.PreserveChanges updates the cached entity with the incoming values unless the cached entity is in a changed
|
|
3598
|
-
state (added, modified, deleted) in which case the incoming values are ignored. The updated cached entity’s EntityState will
|
|
3599
|
-
remain [[EntityState.Unchanged]] unless you’re importing entities in which case the new EntityState will
|
|
3600
|
-
be that of the imported entities.
|
|
3601
|
-
**/
|
|
3602
|
-
MergeStrategy.PreserveChanges = new MergeStrategy();
|
|
3603
|
-
/**
|
|
3604
|
-
MergeStrategy.OverwriteChanges always updates the cached entity with incoming values even if the entity is in
|
|
3605
|
-
a changed state (added, modified, deleted). After the merge, the pending changes are lost.
|
|
3606
|
-
The new EntityState will be [[EntityState/Unchanged]] unless you’re importing entities
|
|
3607
|
-
in which case the new EntityState will be that of the imported entities.
|
|
3608
|
-
**/
|
|
3609
|
-
MergeStrategy.OverwriteChanges = new MergeStrategy();
|
|
3610
|
-
/**
|
|
3611
|
-
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.
|
|
3612
|
-
This is the fastest merge strategy but your existing cached data will remain “stale”.
|
|
3613
|
-
**/
|
|
3614
|
-
MergeStrategy.SkipMerge = new MergeStrategy();
|
|
3615
|
-
/**
|
|
3616
|
-
Disallowed is used to throw an exception if there is an incoming entity with the same key as an entity already in the cache.
|
|
3617
|
-
Use this strategy when you want to be sure that the incoming entity is not already in cache.
|
|
3618
|
-
This is the default strategy for EntityManager.attachEntity.
|
|
3619
|
-
**/
|
|
3620
|
-
MergeStrategy.Disallowed = new MergeStrategy();
|
|
3621
3723
|
MergeStrategy.prototype._$typeName = "MergeStrategy";
|
|
3622
3724
|
Error['x'] = MergeStrategy.resolveSymbols();
|
|
3623
3725
|
/**
|
|
3624
3726
|
FetchStrategy is an 'Enum' that determines how and where entities are retrieved from as a result of a query.
|
|
3625
3727
|
**/
|
|
3626
3728
|
class FetchStrategy extends BreezeEnum {
|
|
3729
|
+
/**
|
|
3730
|
+
FromServer is used to tell the query to execute the query against a remote data source on the server.
|
|
3731
|
+
**/
|
|
3732
|
+
static FromServer = new FetchStrategy();
|
|
3733
|
+
/**
|
|
3734
|
+
FromLocalCache is used to tell the query to execute the query against a local EntityManager instead of going to a remote server.
|
|
3735
|
+
**/
|
|
3736
|
+
static FromLocalCache = new FetchStrategy();
|
|
3627
3737
|
}
|
|
3628
|
-
/**
|
|
3629
|
-
FromServer is used to tell the query to execute the query against a remote data source on the server.
|
|
3630
|
-
**/
|
|
3631
|
-
FetchStrategy.FromServer = new FetchStrategy();
|
|
3632
|
-
/**
|
|
3633
|
-
FromLocalCache is used to tell the query to execute the query against a local EntityManager instead of going to a remote server.
|
|
3634
|
-
**/
|
|
3635
|
-
FetchStrategy.FromLocalCache = new FetchStrategy();
|
|
3636
3738
|
FetchStrategy.prototype._$typeName = "FetchStrategy";
|
|
3637
3739
|
Error['x'] = FetchStrategy.resolveSymbols();
|
|
3638
3740
|
/**
|
|
3639
3741
|
A QueryOptions instance is used to specify the 'options' under which a query will occur.
|
|
3640
3742
|
**/
|
|
3641
3743
|
class QueryOptions {
|
|
3744
|
+
/** @hidden @internal */
|
|
3745
|
+
_$typeName;
|
|
3746
|
+
/** The [[FetchStrategy]] to use with any queries. __Read Only__ */
|
|
3747
|
+
fetchStrategy;
|
|
3748
|
+
/** The [[MergeStrategy]] to use with any queries. __Read Only__ */
|
|
3749
|
+
mergeStrategy;
|
|
3750
|
+
/** Whether to include cached deleted entities in a query result (false by default). __Read Only__ */
|
|
3751
|
+
includeDeleted;
|
|
3752
|
+
/**
|
|
3753
|
+
The default instance for use whenever QueryOptions are not specified.
|
|
3754
|
+
**/
|
|
3755
|
+
static defaultInstance = new QueryOptions({
|
|
3756
|
+
fetchStrategy: FetchStrategy.FromServer,
|
|
3757
|
+
mergeStrategy: MergeStrategy.PreserveChanges,
|
|
3758
|
+
includeDeleted: false
|
|
3759
|
+
});
|
|
3642
3760
|
/**
|
|
3643
3761
|
QueryOptions constructor
|
|
3644
3762
|
> var newQo = new QueryOptions( { mergeStrategy: MergeStrategy.OverwriteChanges });
|
|
@@ -3724,14 +3842,6 @@ class QueryOptions {
|
|
|
3724
3842
|
return obj;
|
|
3725
3843
|
}
|
|
3726
3844
|
}
|
|
3727
|
-
/**
|
|
3728
|
-
The default instance for use whenever QueryOptions are not specified.
|
|
3729
|
-
**/
|
|
3730
|
-
QueryOptions.defaultInstance = new QueryOptions({
|
|
3731
|
-
fetchStrategy: FetchStrategy.FromServer,
|
|
3732
|
-
mergeStrategy: MergeStrategy.PreserveChanges,
|
|
3733
|
-
includeDeleted: false
|
|
3734
|
-
});
|
|
3735
3845
|
QueryOptions.prototype._$typeName = "QueryOptions";
|
|
3736
3846
|
|
|
3737
3847
|
/**
|
|
@@ -4128,6 +4238,7 @@ function updateAliasMap(aliasMap, opStr, op) {
|
|
|
4128
4238
|
@hidden @internal
|
|
4129
4239
|
*/
|
|
4130
4240
|
class PassthruPredicate extends Predicate {
|
|
4241
|
+
value;
|
|
4131
4242
|
constructor(value) {
|
|
4132
4243
|
super();
|
|
4133
4244
|
this.value = value;
|
|
@@ -4139,6 +4250,7 @@ Error['x'] = PassthruPredicate.prototype._initialize('passthruPredicate');
|
|
|
4139
4250
|
@hidden
|
|
4140
4251
|
*/
|
|
4141
4252
|
class UnaryPredicate extends Predicate {
|
|
4253
|
+
pred;
|
|
4142
4254
|
constructor(op, ...args) {
|
|
4143
4255
|
super();
|
|
4144
4256
|
this.op = this._resolveOp(op);
|
|
@@ -4156,6 +4268,10 @@ Error['x'] = UnaryPredicate.prototype._initialize('unaryPredicate', {
|
|
|
4156
4268
|
@hidden
|
|
4157
4269
|
*/
|
|
4158
4270
|
class BinaryPredicate extends Predicate {
|
|
4271
|
+
expr1Source;
|
|
4272
|
+
expr2Source;
|
|
4273
|
+
expr1;
|
|
4274
|
+
expr2;
|
|
4159
4275
|
constructor(op, expr1, expr2) {
|
|
4160
4276
|
super();
|
|
4161
4277
|
// 5 public props op, expr1Source, expr2Source, expr1, expr2
|
|
@@ -4224,6 +4340,7 @@ Error['x'] = BinaryPredicate.prototype._initialize('binaryPredicate', {
|
|
|
4224
4340
|
@hidden
|
|
4225
4341
|
*/
|
|
4226
4342
|
class AndOrPredicate extends Predicate {
|
|
4343
|
+
preds;
|
|
4227
4344
|
constructor(op, preds) {
|
|
4228
4345
|
super();
|
|
4229
4346
|
this.op = this._resolveOp(op);
|
|
@@ -4259,6 +4376,10 @@ Error['x'] = AndOrPredicate.prototype._initialize("andOrPredicate", {
|
|
|
4259
4376
|
@hidden
|
|
4260
4377
|
*/
|
|
4261
4378
|
class AnyAllPredicate extends Predicate {
|
|
4379
|
+
/** @internal */
|
|
4380
|
+
expr;
|
|
4381
|
+
exprSource;
|
|
4382
|
+
pred;
|
|
4262
4383
|
// 4 public props: op, exprSource, expr, pred
|
|
4263
4384
|
constructor(op, expr, pred) {
|
|
4264
4385
|
super();
|
|
@@ -4282,6 +4403,9 @@ Error['x'] = AnyAllPredicate.prototype._initialize("anyAllPredicate", {
|
|
|
4282
4403
|
});
|
|
4283
4404
|
/** @hidden */
|
|
4284
4405
|
class PredicateExpression {
|
|
4406
|
+
visitorMethodName;
|
|
4407
|
+
visit; // TODO
|
|
4408
|
+
dataType;
|
|
4285
4409
|
constructor(visitorMethodName) {
|
|
4286
4410
|
this.visitorMethodName = visitorMethodName;
|
|
4287
4411
|
// give expressions the Predicate prototype method
|
|
@@ -4297,6 +4421,8 @@ class PredicateExpression {
|
|
|
4297
4421
|
@hidden
|
|
4298
4422
|
*/
|
|
4299
4423
|
class LitExpr extends PredicateExpression {
|
|
4424
|
+
value;
|
|
4425
|
+
hasExplicitDataType;
|
|
4300
4426
|
// 2 public props: value, dataType
|
|
4301
4427
|
constructor(value, dataType, hasExplicitDataType) {
|
|
4302
4428
|
super("litExpr");
|
|
@@ -4345,6 +4471,7 @@ function resolveDataType(dataType) {
|
|
|
4345
4471
|
@hidden
|
|
4346
4472
|
*/
|
|
4347
4473
|
class PropExpr extends PredicateExpression {
|
|
4474
|
+
propertyPath;
|
|
4348
4475
|
// two public props: propertyPath, dateType
|
|
4349
4476
|
constructor(propertyPath) {
|
|
4350
4477
|
super('propExpr');
|
|
@@ -4378,6 +4505,9 @@ class PropExpr extends PredicateExpression {
|
|
|
4378
4505
|
@hidden @dynamic
|
|
4379
4506
|
*/
|
|
4380
4507
|
class FnExpr extends PredicateExpression {
|
|
4508
|
+
fnName;
|
|
4509
|
+
exprs;
|
|
4510
|
+
localFn; // TODO:
|
|
4381
4511
|
constructor(fnName, exprs) {
|
|
4382
4512
|
super('fnExpr');
|
|
4383
4513
|
// 4 public props: fnName, exprs, localFn, dataType
|
|
@@ -4401,109 +4531,109 @@ class FnExpr extends PredicateExpression {
|
|
|
4401
4531
|
expr._validate(entityType, usesNameOnServer);
|
|
4402
4532
|
});
|
|
4403
4533
|
}
|
|
4534
|
+
static _funcMap = {
|
|
4535
|
+
toupper: {
|
|
4536
|
+
fn: function (source) {
|
|
4537
|
+
return source.toUpperCase();
|
|
4538
|
+
}, dataType: DataType.String
|
|
4539
|
+
},
|
|
4540
|
+
tolower: {
|
|
4541
|
+
fn: function (source) {
|
|
4542
|
+
return source.toLowerCase();
|
|
4543
|
+
}, dataType: DataType.String
|
|
4544
|
+
},
|
|
4545
|
+
substring: {
|
|
4546
|
+
fn: function (source, pos, length) {
|
|
4547
|
+
return source.substring(pos, length);
|
|
4548
|
+
}, dataType: DataType.String
|
|
4549
|
+
},
|
|
4550
|
+
substringof: {
|
|
4551
|
+
fn: function (find, source) {
|
|
4552
|
+
return source.indexOf(find) >= 0;
|
|
4553
|
+
}, dataType: DataType.Boolean
|
|
4554
|
+
},
|
|
4555
|
+
length: {
|
|
4556
|
+
fn: function (source) {
|
|
4557
|
+
return source.length;
|
|
4558
|
+
}, dataType: DataType.Int32
|
|
4559
|
+
},
|
|
4560
|
+
trim: {
|
|
4561
|
+
fn: function (source) {
|
|
4562
|
+
return source.trim();
|
|
4563
|
+
}, dataType: DataType.String
|
|
4564
|
+
},
|
|
4565
|
+
concat: {
|
|
4566
|
+
fn: function (s1, s2) {
|
|
4567
|
+
return s1.concat(s2);
|
|
4568
|
+
}, dataType: DataType.String
|
|
4569
|
+
},
|
|
4570
|
+
replace: {
|
|
4571
|
+
fn: function (source, find, replace) {
|
|
4572
|
+
return source.replace(find, replace);
|
|
4573
|
+
}, dataType: DataType.String
|
|
4574
|
+
},
|
|
4575
|
+
startswith: {
|
|
4576
|
+
fn: function (source, find) {
|
|
4577
|
+
return core.stringStartsWith(source, find);
|
|
4578
|
+
}, dataType: DataType.Boolean
|
|
4579
|
+
},
|
|
4580
|
+
endswith: {
|
|
4581
|
+
fn: function (source, find) {
|
|
4582
|
+
return core.stringEndsWith(source, find);
|
|
4583
|
+
}, dataType: DataType.Boolean
|
|
4584
|
+
},
|
|
4585
|
+
indexof: {
|
|
4586
|
+
fn: function (source, find) {
|
|
4587
|
+
return source.indexOf(find);
|
|
4588
|
+
}, dataType: DataType.Int32
|
|
4589
|
+
},
|
|
4590
|
+
round: {
|
|
4591
|
+
fn: function (source) {
|
|
4592
|
+
return Math.round(source);
|
|
4593
|
+
}, dataType: DataType.Int32
|
|
4594
|
+
},
|
|
4595
|
+
ceiling: {
|
|
4596
|
+
fn: function (source) {
|
|
4597
|
+
return Math.ceil(source);
|
|
4598
|
+
}, dataType: DataType.Int32
|
|
4599
|
+
},
|
|
4600
|
+
floor: {
|
|
4601
|
+
fn: function (source) {
|
|
4602
|
+
return Math.floor(source);
|
|
4603
|
+
}, dataType: DataType.Int32
|
|
4604
|
+
},
|
|
4605
|
+
second: {
|
|
4606
|
+
fn: function (source) {
|
|
4607
|
+
return source.getSeconds();
|
|
4608
|
+
}, dataType: DataType.Int32
|
|
4609
|
+
},
|
|
4610
|
+
minute: {
|
|
4611
|
+
fn: function (source) {
|
|
4612
|
+
return source.getMinutes();
|
|
4613
|
+
}, dataType: DataType.Int32
|
|
4614
|
+
},
|
|
4615
|
+
hour: {
|
|
4616
|
+
fn: function (source) {
|
|
4617
|
+
return source.getHours();
|
|
4618
|
+
}, dataType: DataType.Int32
|
|
4619
|
+
},
|
|
4620
|
+
day: {
|
|
4621
|
+
fn: function (source) {
|
|
4622
|
+
return source.getDate();
|
|
4623
|
+
}, dataType: DataType.Int32
|
|
4624
|
+
},
|
|
4625
|
+
month: {
|
|
4626
|
+
fn: function (source) {
|
|
4627
|
+
return source.getMonth() + 1;
|
|
4628
|
+
}, dataType: DataType.Int32
|
|
4629
|
+
},
|
|
4630
|
+
year: {
|
|
4631
|
+
fn: function (source) {
|
|
4632
|
+
return source.getFullYear();
|
|
4633
|
+
}, dataType: DataType.Int32
|
|
4634
|
+
}
|
|
4635
|
+
};
|
|
4404
4636
|
}
|
|
4405
|
-
FnExpr._funcMap = {
|
|
4406
|
-
toupper: {
|
|
4407
|
-
fn: function (source) {
|
|
4408
|
-
return source.toUpperCase();
|
|
4409
|
-
}, dataType: DataType.String
|
|
4410
|
-
},
|
|
4411
|
-
tolower: {
|
|
4412
|
-
fn: function (source) {
|
|
4413
|
-
return source.toLowerCase();
|
|
4414
|
-
}, dataType: DataType.String
|
|
4415
|
-
},
|
|
4416
|
-
substring: {
|
|
4417
|
-
fn: function (source, pos, length) {
|
|
4418
|
-
return source.substring(pos, length);
|
|
4419
|
-
}, dataType: DataType.String
|
|
4420
|
-
},
|
|
4421
|
-
substringof: {
|
|
4422
|
-
fn: function (find, source) {
|
|
4423
|
-
return source.indexOf(find) >= 0;
|
|
4424
|
-
}, dataType: DataType.Boolean
|
|
4425
|
-
},
|
|
4426
|
-
length: {
|
|
4427
|
-
fn: function (source) {
|
|
4428
|
-
return source.length;
|
|
4429
|
-
}, dataType: DataType.Int32
|
|
4430
|
-
},
|
|
4431
|
-
trim: {
|
|
4432
|
-
fn: function (source) {
|
|
4433
|
-
return source.trim();
|
|
4434
|
-
}, dataType: DataType.String
|
|
4435
|
-
},
|
|
4436
|
-
concat: {
|
|
4437
|
-
fn: function (s1, s2) {
|
|
4438
|
-
return s1.concat(s2);
|
|
4439
|
-
}, dataType: DataType.String
|
|
4440
|
-
},
|
|
4441
|
-
replace: {
|
|
4442
|
-
fn: function (source, find, replace) {
|
|
4443
|
-
return source.replace(find, replace);
|
|
4444
|
-
}, dataType: DataType.String
|
|
4445
|
-
},
|
|
4446
|
-
startswith: {
|
|
4447
|
-
fn: function (source, find) {
|
|
4448
|
-
return core.stringStartsWith(source, find);
|
|
4449
|
-
}, dataType: DataType.Boolean
|
|
4450
|
-
},
|
|
4451
|
-
endswith: {
|
|
4452
|
-
fn: function (source, find) {
|
|
4453
|
-
return core.stringEndsWith(source, find);
|
|
4454
|
-
}, dataType: DataType.Boolean
|
|
4455
|
-
},
|
|
4456
|
-
indexof: {
|
|
4457
|
-
fn: function (source, find) {
|
|
4458
|
-
return source.indexOf(find);
|
|
4459
|
-
}, dataType: DataType.Int32
|
|
4460
|
-
},
|
|
4461
|
-
round: {
|
|
4462
|
-
fn: function (source) {
|
|
4463
|
-
return Math.round(source);
|
|
4464
|
-
}, dataType: DataType.Int32
|
|
4465
|
-
},
|
|
4466
|
-
ceiling: {
|
|
4467
|
-
fn: function (source) {
|
|
4468
|
-
return Math.ceil(source);
|
|
4469
|
-
}, dataType: DataType.Int32
|
|
4470
|
-
},
|
|
4471
|
-
floor: {
|
|
4472
|
-
fn: function (source) {
|
|
4473
|
-
return Math.floor(source);
|
|
4474
|
-
}, dataType: DataType.Int32
|
|
4475
|
-
},
|
|
4476
|
-
second: {
|
|
4477
|
-
fn: function (source) {
|
|
4478
|
-
return source.getSeconds();
|
|
4479
|
-
}, dataType: DataType.Int32
|
|
4480
|
-
},
|
|
4481
|
-
minute: {
|
|
4482
|
-
fn: function (source) {
|
|
4483
|
-
return source.getMinutes();
|
|
4484
|
-
}, dataType: DataType.Int32
|
|
4485
|
-
},
|
|
4486
|
-
hour: {
|
|
4487
|
-
fn: function (source) {
|
|
4488
|
-
return source.getHours();
|
|
4489
|
-
}, dataType: DataType.Int32
|
|
4490
|
-
},
|
|
4491
|
-
day: {
|
|
4492
|
-
fn: function (source) {
|
|
4493
|
-
return source.getDate();
|
|
4494
|
-
}, dataType: DataType.Int32
|
|
4495
|
-
},
|
|
4496
|
-
month: {
|
|
4497
|
-
fn: function (source) {
|
|
4498
|
-
return source.getMonth() + 1;
|
|
4499
|
-
}, dataType: DataType.Int32
|
|
4500
|
-
},
|
|
4501
|
-
year: {
|
|
4502
|
-
fn: function (source) {
|
|
4503
|
-
return source.getFullYear();
|
|
4504
|
-
}, dataType: DataType.Int32
|
|
4505
|
-
}
|
|
4506
|
-
};
|
|
4507
4637
|
// TODO: add dataTypes for the args next - will help to infer other dataTypes.
|
|
4508
4638
|
let RX_IDENTIFIER = /^[a-z_][\w.$]*$/i;
|
|
4509
4639
|
// comma delimited expressions ignoring commas inside of both single and double quotes.
|
|
@@ -4633,104 +4763,103 @@ function parseFnExpr(source, parts, tokens, exprContext) {
|
|
|
4633
4763
|
throw e;
|
|
4634
4764
|
}
|
|
4635
4765
|
}
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
}
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
return
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4766
|
+
// toFunctionVisitor
|
|
4767
|
+
let toFunctionVisitor = {
|
|
4768
|
+
isExtended: false,
|
|
4769
|
+
passthruPredicate: function () {
|
|
4770
|
+
throw new Error("Cannot execute an PassthruPredicate expression against the local cache: " + this.value);
|
|
4771
|
+
},
|
|
4772
|
+
unaryPredicate: function (context) {
|
|
4773
|
+
let predFn = this.pred.visit(context);
|
|
4774
|
+
switch (this.op.key) {
|
|
4775
|
+
case "not":
|
|
4776
|
+
return function (entity) {
|
|
4777
|
+
return !predFn(entity);
|
|
4778
|
+
};
|
|
4779
|
+
default:
|
|
4780
|
+
throw new Error("Invalid unary operator:" + this.op.key);
|
|
4781
|
+
}
|
|
4782
|
+
},
|
|
4783
|
+
binaryPredicate: function (context) {
|
|
4784
|
+
let expr1Fn = this.expr1.visit(context);
|
|
4785
|
+
let expr2Fn = this.expr2.visit(context);
|
|
4786
|
+
let dataType = this.expr1.dataType || this.expr2.dataType;
|
|
4787
|
+
let lqco = context.entityType.metadataStore.localQueryComparisonOptions;
|
|
4788
|
+
let predFn = getBinaryPredicateFn(this, dataType, lqco);
|
|
4789
|
+
if (predFn == null) {
|
|
4790
|
+
throw new Error("Invalid binaryPredicate operator:" + this.op.key);
|
|
4791
|
+
}
|
|
4792
|
+
return function (entity) {
|
|
4793
|
+
return predFn(expr1Fn(entity), expr2Fn(entity));
|
|
4794
|
+
};
|
|
4795
|
+
},
|
|
4796
|
+
andOrPredicate: function (context) {
|
|
4797
|
+
let predFns = this.preds.map((pred) => {
|
|
4798
|
+
return pred.visit(context);
|
|
4799
|
+
});
|
|
4800
|
+
switch (this.op.key) {
|
|
4801
|
+
case "and":
|
|
4802
|
+
return function (entity) {
|
|
4803
|
+
let result = predFns.reduce(function (prev, cur) {
|
|
4804
|
+
return prev && cur(entity);
|
|
4805
|
+
}, true);
|
|
4806
|
+
return result;
|
|
4807
|
+
};
|
|
4808
|
+
case "or":
|
|
4809
|
+
return function (entity) {
|
|
4810
|
+
let result = predFns.reduce(function (prev, cur) {
|
|
4811
|
+
return prev || cur(entity);
|
|
4812
|
+
}, false);
|
|
4813
|
+
return result;
|
|
4814
|
+
};
|
|
4815
|
+
default:
|
|
4816
|
+
throw new Error("Invalid boolean operator:" + this.op.key);
|
|
4817
|
+
}
|
|
4818
|
+
},
|
|
4819
|
+
anyAllPredicate: function (context) {
|
|
4820
|
+
let exprFn = this.expr.visit(context);
|
|
4821
|
+
let newContext = core.extend({}, context);
|
|
4822
|
+
newContext.entityType = this.expr.dataType;
|
|
4823
|
+
let predFn = this.pred.visit(newContext);
|
|
4824
|
+
let anyAllPredFn = getAnyAllPredicateFn(this.op);
|
|
4825
|
+
return function (entity) {
|
|
4826
|
+
return anyAllPredFn(exprFn(entity), predFn);
|
|
4827
|
+
};
|
|
4828
|
+
},
|
|
4829
|
+
litExpr: function () {
|
|
4830
|
+
let value = this.value;
|
|
4831
|
+
return function (entity) {
|
|
4832
|
+
return value;
|
|
4833
|
+
};
|
|
4834
|
+
},
|
|
4835
|
+
propExpr: function () {
|
|
4836
|
+
let propertyPath = this.propertyPath;
|
|
4837
|
+
let properties = propertyPath.split('.');
|
|
4838
|
+
if (properties.length === 1) {
|
|
4666
4839
|
return function (entity) {
|
|
4667
|
-
|
|
4668
|
-
return prev && cur(entity);
|
|
4669
|
-
}, true);
|
|
4670
|
-
return result;
|
|
4840
|
+
return entity.getProperty(propertyPath);
|
|
4671
4841
|
};
|
|
4672
|
-
|
|
4842
|
+
}
|
|
4843
|
+
else {
|
|
4673
4844
|
return function (entity) {
|
|
4674
|
-
|
|
4675
|
-
return prev || cur(entity);
|
|
4676
|
-
}, false);
|
|
4677
|
-
return result;
|
|
4845
|
+
return EntityAspect.getPropertyPathValue(entity, properties);
|
|
4678
4846
|
};
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
let predFn = this.pred.visit(newContext);
|
|
4687
|
-
let anyAllPredFn = getAnyAllPredicateFn(this.op);
|
|
4688
|
-
return function (entity) {
|
|
4689
|
-
return anyAllPredFn(exprFn(entity), predFn);
|
|
4690
|
-
};
|
|
4691
|
-
}, ɵ5 = function () {
|
|
4692
|
-
let value = this.value;
|
|
4693
|
-
return function (entity) {
|
|
4694
|
-
return value;
|
|
4695
|
-
};
|
|
4696
|
-
}, ɵ6 = function () {
|
|
4697
|
-
let propertyPath = this.propertyPath;
|
|
4698
|
-
let properties = propertyPath.split('.');
|
|
4699
|
-
if (properties.length === 1) {
|
|
4700
|
-
return function (entity) {
|
|
4701
|
-
return entity.getProperty(propertyPath);
|
|
4702
|
-
};
|
|
4703
|
-
}
|
|
4704
|
-
else {
|
|
4847
|
+
}
|
|
4848
|
+
},
|
|
4849
|
+
fnExpr: function (context) {
|
|
4850
|
+
let exprFns = this.exprs.map(function (expr) {
|
|
4851
|
+
return expr.visit(context);
|
|
4852
|
+
});
|
|
4853
|
+
let that = this;
|
|
4705
4854
|
return function (entity) {
|
|
4706
|
-
|
|
4855
|
+
let values = exprFns.map(function (exprFn) {
|
|
4856
|
+
let value = exprFn(entity);
|
|
4857
|
+
return value;
|
|
4858
|
+
});
|
|
4859
|
+
let result = that.localFn.apply(null, values);
|
|
4860
|
+
return result;
|
|
4707
4861
|
};
|
|
4708
4862
|
}
|
|
4709
|
-
}, ɵ7 = function (context) {
|
|
4710
|
-
let exprFns = this.exprs.map(function (expr) {
|
|
4711
|
-
return expr.visit(context);
|
|
4712
|
-
});
|
|
4713
|
-
let that = this;
|
|
4714
|
-
return function (entity) {
|
|
4715
|
-
let values = exprFns.map(function (exprFn) {
|
|
4716
|
-
let value = exprFn(entity);
|
|
4717
|
-
return value;
|
|
4718
|
-
});
|
|
4719
|
-
let result = that.localFn.apply(null, values);
|
|
4720
|
-
return result;
|
|
4721
|
-
};
|
|
4722
|
-
};
|
|
4723
|
-
// toFunctionVisitor
|
|
4724
|
-
let toFunctionVisitor = {
|
|
4725
|
-
isExtended: false,
|
|
4726
|
-
passthruPredicate: ɵ0$2,
|
|
4727
|
-
unaryPredicate: ɵ1$1,
|
|
4728
|
-
binaryPredicate: ɵ2,
|
|
4729
|
-
andOrPredicate: ɵ3,
|
|
4730
|
-
anyAllPredicate: ɵ4,
|
|
4731
|
-
litExpr: ɵ5,
|
|
4732
|
-
propExpr: ɵ6,
|
|
4733
|
-
fnExpr: ɵ7
|
|
4734
4863
|
};
|
|
4735
4864
|
function getAnyAllPredicateFn(op) {
|
|
4736
4865
|
switch (op.key) {
|
|
@@ -4797,12 +4926,12 @@ function getBinaryPredicateFn(binaryPredicate, dataType, lqco) {
|
|
|
4797
4926
|
break;
|
|
4798
4927
|
case 'startswith':
|
|
4799
4928
|
predFn = function (v1, v2) {
|
|
4800
|
-
return stringStartsWith
|
|
4929
|
+
return stringStartsWith(v1, v2, lqco);
|
|
4801
4930
|
};
|
|
4802
4931
|
break;
|
|
4803
4932
|
case 'endswith':
|
|
4804
4933
|
predFn = function (v1, v2) {
|
|
4805
|
-
return stringEndsWith
|
|
4934
|
+
return stringEndsWith(v1, v2, lqco);
|
|
4806
4935
|
};
|
|
4807
4936
|
break;
|
|
4808
4937
|
case 'contains':
|
|
@@ -4838,14 +4967,14 @@ function stringEquals(a, b, lqco) {
|
|
|
4838
4967
|
}
|
|
4839
4968
|
return a === b;
|
|
4840
4969
|
}
|
|
4841
|
-
function stringStartsWith
|
|
4970
|
+
function stringStartsWith(a, b, lqco) {
|
|
4842
4971
|
if (!lqco.isCaseSensitive) {
|
|
4843
4972
|
a = (a || "").toLowerCase();
|
|
4844
4973
|
b = (b || "").toLowerCase();
|
|
4845
4974
|
}
|
|
4846
4975
|
return core.stringStartsWith(a, b);
|
|
4847
4976
|
}
|
|
4848
|
-
function stringEndsWith
|
|
4977
|
+
function stringEndsWith(a, b, lqco) {
|
|
4849
4978
|
if (!lqco.isCaseSensitive) {
|
|
4850
4979
|
a = (a || "").toLowerCase();
|
|
4851
4980
|
b = (b || "").toLowerCase();
|
|
@@ -4859,94 +4988,93 @@ function stringContains(a, b, lqco) {
|
|
|
4859
4988
|
}
|
|
4860
4989
|
return a.indexOf(b) >= 0;
|
|
4861
4990
|
}
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4991
|
+
// toJSONVisitor
|
|
4992
|
+
let toJSONVisitor = {
|
|
4993
|
+
passthruPredicate: function () {
|
|
4994
|
+
return this.value;
|
|
4995
|
+
},
|
|
4996
|
+
unaryPredicate: function (context) {
|
|
4997
|
+
let predVal = this.pred.visit(context);
|
|
4998
|
+
let json = {};
|
|
4999
|
+
json[this.op.key] = predVal;
|
|
5000
|
+
return json;
|
|
5001
|
+
},
|
|
5002
|
+
binaryPredicate: function (context) {
|
|
5003
|
+
let expr1Val = this.expr1.visit(context);
|
|
5004
|
+
let expr2Val = this.expr2.visit(context);
|
|
5005
|
+
let json = {};
|
|
5006
|
+
if (this.expr2 instanceof PropExpr) {
|
|
5007
|
+
expr2Val = { value: expr2Val, isProperty: true };
|
|
5008
|
+
}
|
|
5009
|
+
if (this.op.key === "eq") {
|
|
5010
|
+
json[expr1Val] = expr2Val;
|
|
5011
|
+
}
|
|
5012
|
+
else {
|
|
5013
|
+
let value = {};
|
|
5014
|
+
json[expr1Val] = value;
|
|
5015
|
+
value[this.op.key] = expr2Val;
|
|
5016
|
+
}
|
|
5017
|
+
return json;
|
|
5018
|
+
},
|
|
5019
|
+
andOrPredicate: function (context) {
|
|
5020
|
+
let predVals = this.preds.map(function (pred) {
|
|
5021
|
+
return pred.visit(context);
|
|
5022
|
+
});
|
|
5023
|
+
if (!predVals || !predVals.length) {
|
|
5024
|
+
return {};
|
|
5025
|
+
}
|
|
5026
|
+
let json;
|
|
5027
|
+
// normalizeAnd clauses if possible.
|
|
5028
|
+
// passthru predicate will appear as string and their 'ands' can't be 'normalized'
|
|
5029
|
+
if (this.op.key === 'and' && predVals.length === 2 && !predVals.some((v) => v.or || typeof (v) === 'string')) {
|
|
5030
|
+
// normalize 'and' clauses - will return null if can't be combined.
|
|
5031
|
+
json = predVals.reduce(combine);
|
|
5032
|
+
}
|
|
5033
|
+
if (json == null) {
|
|
5034
|
+
json = {};
|
|
5035
|
+
json[this.op.key] = predVals;
|
|
5036
|
+
}
|
|
5037
|
+
return json;
|
|
5038
|
+
},
|
|
5039
|
+
anyAllPredicate: function (context) {
|
|
5040
|
+
let exprVal = this.expr.visit(context);
|
|
5041
|
+
let newContext = core.extend({}, context);
|
|
5042
|
+
newContext.entityType = this.expr.dataType;
|
|
5043
|
+
let predVal = this.pred.visit(newContext);
|
|
5044
|
+
let json = {};
|
|
4880
5045
|
let value = {};
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
}, ɵ12 = function (context) {
|
|
4905
|
-
let exprVal = this.expr.visit(context);
|
|
4906
|
-
let newContext = core.extend({}, context);
|
|
4907
|
-
newContext.entityType = this.expr.dataType;
|
|
4908
|
-
let predVal = this.pred.visit(newContext);
|
|
4909
|
-
let json = {};
|
|
4910
|
-
let value = {};
|
|
4911
|
-
value[this.op.key] = predVal;
|
|
4912
|
-
json[exprVal] = value;
|
|
4913
|
-
return json;
|
|
4914
|
-
}, ɵ13 = function (context) {
|
|
4915
|
-
// special handling for DateOnly because it serializes improperly
|
|
4916
|
-
const value = (this.dataType === DataType.DateOnly) ? DataType.toDateOnlyString(this.value) : this.value;
|
|
4917
|
-
if (this.hasExplicitDataType || context.useExplicitDataType) {
|
|
4918
|
-
return { value: value, dataType: this.dataType.name };
|
|
4919
|
-
}
|
|
4920
|
-
else {
|
|
4921
|
-
return value;
|
|
4922
|
-
}
|
|
4923
|
-
}, ɵ14 = function (context) {
|
|
4924
|
-
if (context.toNameOnServer) {
|
|
4925
|
-
if (!context.entityType) {
|
|
4926
|
-
console.warn(`No EntityType for propertyPath "${this.propertyPath}". ${core.strings.TO_TYPE}`);
|
|
5046
|
+
value[this.op.key] = predVal;
|
|
5047
|
+
json[exprVal] = value;
|
|
5048
|
+
return json;
|
|
5049
|
+
},
|
|
5050
|
+
litExpr: function (context) {
|
|
5051
|
+
// special handling for DateOnly because it serializes improperly
|
|
5052
|
+
const value = (this.dataType === DataType.DateOnly) ? DataType.toDateOnlyString(this.value) : this.value;
|
|
5053
|
+
if (this.hasExplicitDataType || context.useExplicitDataType) {
|
|
5054
|
+
return { value: value, dataType: this.dataType.name };
|
|
5055
|
+
}
|
|
5056
|
+
else {
|
|
5057
|
+
return value;
|
|
5058
|
+
}
|
|
5059
|
+
},
|
|
5060
|
+
propExpr: function (context) {
|
|
5061
|
+
if (context.toNameOnServer) {
|
|
5062
|
+
if (!context.entityType) {
|
|
5063
|
+
console.warn(`No EntityType for propertyPath "${this.propertyPath}". ${core.strings.TO_TYPE}`);
|
|
5064
|
+
return this.propertyPath;
|
|
5065
|
+
}
|
|
5066
|
+
return context.entityType.clientPropertyPathToServer(this.propertyPath);
|
|
5067
|
+
}
|
|
5068
|
+
else {
|
|
4927
5069
|
return this.propertyPath;
|
|
4928
5070
|
}
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
5071
|
+
},
|
|
5072
|
+
fnExpr: function (context) {
|
|
5073
|
+
let exprVals = this.exprs.map(function (expr) {
|
|
5074
|
+
return expr.visit(context);
|
|
5075
|
+
});
|
|
5076
|
+
return this.fnName + "(" + exprVals.join(",") + ")";
|
|
4933
5077
|
}
|
|
4934
|
-
}, ɵ15 = function (context) {
|
|
4935
|
-
let exprVals = this.exprs.map(function (expr) {
|
|
4936
|
-
return expr.visit(context);
|
|
4937
|
-
});
|
|
4938
|
-
return this.fnName + "(" + exprVals.join(",") + ")";
|
|
4939
|
-
};
|
|
4940
|
-
// toJSONVisitor
|
|
4941
|
-
let toJSONVisitor = {
|
|
4942
|
-
passthruPredicate: ɵ8,
|
|
4943
|
-
unaryPredicate: ɵ9,
|
|
4944
|
-
binaryPredicate: ɵ10,
|
|
4945
|
-
andOrPredicate: ɵ11,
|
|
4946
|
-
anyAllPredicate: ɵ12,
|
|
4947
|
-
litExpr: ɵ13,
|
|
4948
|
-
propExpr: ɵ14,
|
|
4949
|
-
fnExpr: ɵ15
|
|
4950
5078
|
};
|
|
4951
5079
|
function combine(j1, j2) {
|
|
4952
5080
|
let ok = Object.keys(j2).every(function (key) {
|
|
@@ -5518,6 +5646,28 @@ class EntityQuery {
|
|
|
5518
5646
|
q = q.where(pred).toType(entityKey.entityType);
|
|
5519
5647
|
return q;
|
|
5520
5648
|
}
|
|
5649
|
+
/**
|
|
5650
|
+
Creates an EntityQuery for the specified entity and [[NavigationProperty]].
|
|
5651
|
+
> // 'employee' is a previously queried employee
|
|
5652
|
+
> let ordersNavProp = employee.entityType.getProperty("Orders");
|
|
5653
|
+
> let query = EntityQuery.fromEntityNavigation(employee, ordersNavProp);
|
|
5654
|
+
|
|
5655
|
+
will return a query for the "Orders" of the specified 'employee'.
|
|
5656
|
+
@param entity - The Entity whose navigation property will be queried.
|
|
5657
|
+
@param navigationProperty - The [[NavigationProperty]] or name of the NavigationProperty to be queried.
|
|
5658
|
+
**/
|
|
5659
|
+
static fromEntityNavigation = function (entity, navigationProperty) {
|
|
5660
|
+
assertParam(entity, "entity").isEntity().check();
|
|
5661
|
+
let navProperty = entity.entityType._checkNavProperty(navigationProperty);
|
|
5662
|
+
let q = new EntityQuery(navProperty.entityType.defaultResourceName);
|
|
5663
|
+
let pred = buildNavigationPredicate(entity, navProperty);
|
|
5664
|
+
if (pred == null) {
|
|
5665
|
+
throw new Error("Unable to create a NavigationQuery for navigationProperty: " + navProperty.name);
|
|
5666
|
+
}
|
|
5667
|
+
q = q.where(pred);
|
|
5668
|
+
let em = entity.entityAspect.entityManager;
|
|
5669
|
+
return em ? q.using(em) : q;
|
|
5670
|
+
};
|
|
5521
5671
|
// protected methods
|
|
5522
5672
|
/** @hidden @internal */
|
|
5523
5673
|
_getFromEntityType(metadataStore, throwErrorIfNotFound) {
|
|
@@ -5589,28 +5739,6 @@ class EntityQuery {
|
|
|
5589
5739
|
return ds.uriBuilder.buildUri(this, em.metadataStore);
|
|
5590
5740
|
}
|
|
5591
5741
|
}
|
|
5592
|
-
/**
|
|
5593
|
-
Creates an EntityQuery for the specified entity and [[NavigationProperty]].
|
|
5594
|
-
> // 'employee' is a previously queried employee
|
|
5595
|
-
> let ordersNavProp = employee.entityType.getProperty("Orders");
|
|
5596
|
-
> let query = EntityQuery.fromEntityNavigation(employee, ordersNavProp);
|
|
5597
|
-
|
|
5598
|
-
will return a query for the "Orders" of the specified 'employee'.
|
|
5599
|
-
@param entity - The Entity whose navigation property will be queried.
|
|
5600
|
-
@param navigationProperty - The [[NavigationProperty]] or name of the NavigationProperty to be queried.
|
|
5601
|
-
**/
|
|
5602
|
-
EntityQuery.fromEntityNavigation = function (entity, navigationProperty) {
|
|
5603
|
-
assertParam(entity, "entity").isEntity().check();
|
|
5604
|
-
let navProperty = entity.entityType._checkNavProperty(navigationProperty);
|
|
5605
|
-
let q = new EntityQuery(navProperty.entityType.defaultResourceName);
|
|
5606
|
-
let pred = buildNavigationPredicate(entity, navProperty);
|
|
5607
|
-
if (pred == null) {
|
|
5608
|
-
throw new Error("Unable to create a NavigationQuery for navigationProperty: " + navProperty.name);
|
|
5609
|
-
}
|
|
5610
|
-
q = q.where(pred);
|
|
5611
|
-
let em = entity.entityAspect.entityManager;
|
|
5612
|
-
return em ? q.using(em) : q;
|
|
5613
|
-
};
|
|
5614
5742
|
EntityQuery.prototype._$typeName = "EntityQuery";
|
|
5615
5743
|
// private functions
|
|
5616
5744
|
function fromJSON(eq, json) {
|
|
@@ -5752,33 +5880,33 @@ FilterQueryOp is an 'Enum' containing all of the valid [[Predicate]]
|
|
|
5752
5880
|
filter operators for an [[EntityQuery]].
|
|
5753
5881
|
**/
|
|
5754
5882
|
class FilterQueryOp extends BreezeEnum {
|
|
5883
|
+
/** Aliases: "eq", "==" **/
|
|
5884
|
+
static Equals = new FilterQueryOp({ operator: "eq" });
|
|
5885
|
+
/** Aliases: "ne", "!=" **/
|
|
5886
|
+
static NotEquals = new FilterQueryOp({ operator: "ne" });
|
|
5887
|
+
/** Aliases: "gt", ">" **/
|
|
5888
|
+
static GreaterThan = new FilterQueryOp({ operator: "gt" });
|
|
5889
|
+
/** Aliases: "lt", "<" **/
|
|
5890
|
+
static LessThan = new FilterQueryOp({ operator: "lt" });
|
|
5891
|
+
/** Aliases: "ge", ">=" **/
|
|
5892
|
+
static GreaterThanOrEqual = new FilterQueryOp({ operator: "ge" });
|
|
5893
|
+
/** Aliases: "le", "<=" **/
|
|
5894
|
+
static LessThanOrEqual = new FilterQueryOp({ operator: "le" });
|
|
5895
|
+
/** String operation: Is a string a substring of another string. Aliases: "substringof" **/
|
|
5896
|
+
static Contains = new FilterQueryOp({ operator: "contains" });
|
|
5897
|
+
/** No aliases */
|
|
5898
|
+
static StartsWith = new FilterQueryOp({ operator: "startswith" });
|
|
5899
|
+
/** No aliases */
|
|
5900
|
+
static EndsWith = new FilterQueryOp({ operator: "endswith" });
|
|
5901
|
+
/** Aliases: "some" **/
|
|
5902
|
+
static Any = new FilterQueryOp({ operator: "any" });
|
|
5903
|
+
/** Aliases: "every" **/
|
|
5904
|
+
static All = new FilterQueryOp({ operator: "all" });
|
|
5905
|
+
/** No aliases */
|
|
5906
|
+
static In = new FilterQueryOp({ operator: "in" });
|
|
5907
|
+
/** No aliases */
|
|
5908
|
+
static IsTypeOf = new FilterQueryOp({ operator: "isof" });
|
|
5755
5909
|
}
|
|
5756
|
-
/** Aliases: "eq", "==" **/
|
|
5757
|
-
FilterQueryOp.Equals = new FilterQueryOp({ operator: "eq" });
|
|
5758
|
-
/** Aliases: "ne", "!=" **/
|
|
5759
|
-
FilterQueryOp.NotEquals = new FilterQueryOp({ operator: "ne" });
|
|
5760
|
-
/** Aliases: "gt", ">" **/
|
|
5761
|
-
FilterQueryOp.GreaterThan = new FilterQueryOp({ operator: "gt" });
|
|
5762
|
-
/** Aliases: "lt", "<" **/
|
|
5763
|
-
FilterQueryOp.LessThan = new FilterQueryOp({ operator: "lt" });
|
|
5764
|
-
/** Aliases: "ge", ">=" **/
|
|
5765
|
-
FilterQueryOp.GreaterThanOrEqual = new FilterQueryOp({ operator: "ge" });
|
|
5766
|
-
/** Aliases: "le", "<=" **/
|
|
5767
|
-
FilterQueryOp.LessThanOrEqual = new FilterQueryOp({ operator: "le" });
|
|
5768
|
-
/** String operation: Is a string a substring of another string. Aliases: "substringof" **/
|
|
5769
|
-
FilterQueryOp.Contains = new FilterQueryOp({ operator: "contains" });
|
|
5770
|
-
/** No aliases */
|
|
5771
|
-
FilterQueryOp.StartsWith = new FilterQueryOp({ operator: "startswith" });
|
|
5772
|
-
/** No aliases */
|
|
5773
|
-
FilterQueryOp.EndsWith = new FilterQueryOp({ operator: "endswith" });
|
|
5774
|
-
/** Aliases: "some" **/
|
|
5775
|
-
FilterQueryOp.Any = new FilterQueryOp({ operator: "any" });
|
|
5776
|
-
/** Aliases: "every" **/
|
|
5777
|
-
FilterQueryOp.All = new FilterQueryOp({ operator: "all" });
|
|
5778
|
-
/** No aliases */
|
|
5779
|
-
FilterQueryOp.In = new FilterQueryOp({ operator: "in" });
|
|
5780
|
-
/** No aliases */
|
|
5781
|
-
FilterQueryOp.IsTypeOf = new FilterQueryOp({ operator: "isof" });
|
|
5782
5910
|
FilterQueryOp.prototype._$typeName = "FilterQueryOp";
|
|
5783
5911
|
Error['x'] = FilterQueryOp.resolveSymbols();
|
|
5784
5912
|
/**
|
|
@@ -5786,10 +5914,10 @@ Error['x'] = FilterQueryOp.resolveSymbols();
|
|
|
5786
5914
|
operators for an [[EntityQuery]].
|
|
5787
5915
|
**/
|
|
5788
5916
|
class BooleanQueryOp extends BreezeEnum {
|
|
5917
|
+
static And = new BooleanQueryOp({ operator: "and" });
|
|
5918
|
+
static Or = new BooleanQueryOp({ operator: "or" });
|
|
5919
|
+
static Not = new BooleanQueryOp({ operator: "not" });
|
|
5789
5920
|
}
|
|
5790
|
-
BooleanQueryOp.And = new BooleanQueryOp({ operator: "and" });
|
|
5791
|
-
BooleanQueryOp.Or = new BooleanQueryOp({ operator: "or" });
|
|
5792
|
-
BooleanQueryOp.Not = new BooleanQueryOp({ operator: "not" });
|
|
5793
5921
|
BooleanQueryOp.prototype._$typeName = "BooleanQueryOp";
|
|
5794
5922
|
Error['x'] = BooleanQueryOp.resolveSymbols();
|
|
5795
5923
|
/** For use by breeze plugin authors only. The class is used in most [[IUriBuilderAdapter]] implementations
|
|
@@ -5810,6 +5938,8 @@ or
|
|
|
5810
5938
|
> let obc = new OrderByClause("Company.CompanyName, LastName", true);
|
|
5811
5939
|
*/
|
|
5812
5940
|
class OrderByClause {
|
|
5941
|
+
/** @hidden @internal */
|
|
5942
|
+
items;
|
|
5813
5943
|
constructor(propertyPaths, isDesc) {
|
|
5814
5944
|
if (propertyPaths.length === 0) {
|
|
5815
5945
|
throw new Error("OrderByClause cannot be empty");
|
|
@@ -5856,6 +5986,9 @@ class OrderByClause {
|
|
|
5856
5986
|
}
|
|
5857
5987
|
/** @hidden @internal */
|
|
5858
5988
|
class OrderByItem {
|
|
5989
|
+
propertyPath;
|
|
5990
|
+
isDesc;
|
|
5991
|
+
lastProperty;
|
|
5859
5992
|
constructor(propertyPath, isDesc) {
|
|
5860
5993
|
if (!(typeof propertyPath === 'string')) {
|
|
5861
5994
|
throw new Error("propertyPath is not a string");
|
|
@@ -5931,6 +6064,9 @@ class OrderByItem {
|
|
|
5931
6064
|
@hidden
|
|
5932
6065
|
**/
|
|
5933
6066
|
class SelectClause {
|
|
6067
|
+
propertyPaths;
|
|
6068
|
+
/** @hidden @internal */
|
|
6069
|
+
_pathNames;
|
|
5934
6070
|
constructor(propertyPaths) {
|
|
5935
6071
|
this.propertyPaths = propertyPaths;
|
|
5936
6072
|
this._pathNames = propertyPaths.map(function (pp) {
|
|
@@ -5966,6 +6102,7 @@ class SelectClause {
|
|
|
5966
6102
|
@hidden
|
|
5967
6103
|
**/
|
|
5968
6104
|
class ExpandClause {
|
|
6105
|
+
propertyPaths;
|
|
5969
6106
|
constructor(propertyPaths) {
|
|
5970
6107
|
this.propertyPaths = propertyPaths;
|
|
5971
6108
|
}
|
|
@@ -5991,53 +6128,96 @@ a query, import or [[EntityManager.createEntity]] call.
|
|
|
5991
6128
|
|
|
5992
6129
|
**/
|
|
5993
6130
|
class EntityAspect {
|
|
6131
|
+
/** The Entity that this aspect is associated with. __Read Only__ **/
|
|
6132
|
+
entity;
|
|
6133
|
+
/** The [[EntityManager]] that contains this entity. __Read Only__ **/
|
|
6134
|
+
entityManager;
|
|
6135
|
+
/** @hidden @internal */
|
|
6136
|
+
entityGroup;
|
|
6137
|
+
/** The [[EntityState]] of this entity. __Read Only__ **/
|
|
6138
|
+
entityState;
|
|
6139
|
+
/** Whether this entity is in the process of being saved. __Read Only__ */
|
|
6140
|
+
isBeingSaved;
|
|
6141
|
+
/** The 'original values' of this entity where they are different from the 'current values'.
|
|
6142
|
+
This is a map where the key is a property name and the value is the 'original value' of the property. */
|
|
6143
|
+
originalValues;
|
|
6144
|
+
/** Whether this entity has any validation errors. __Read Only__ */
|
|
6145
|
+
hasValidationErrors;
|
|
6146
|
+
/** Whether this entity has a temporary [[EntityKey]]. */
|
|
6147
|
+
hasTempKey;
|
|
6148
|
+
/** Whether this entity was created by being loaded from the database */
|
|
6149
|
+
wasLoaded;
|
|
6150
|
+
/** Extra metadata about this entity such as the entity's etag.
|
|
6151
|
+
You may extend this object with your own metadata information.
|
|
6152
|
+
Breeze (de)serializes this object when importing/exporting the entity. **/
|
|
6153
|
+
extraMetadata;
|
|
6154
|
+
/**
|
|
6155
|
+
A [[BreezeEvent]] that fires whenever any of the validation errors on this entity change.
|
|
6156
|
+
Note that this might be the removal of an error when some data on the entity is fixed.
|
|
6157
|
+
@eventArgs -
|
|
6158
|
+
- entity - The entity on which the validation errors are being added or removed.
|
|
6159
|
+
- added - An array containing any newly added [[ValidationError]]s
|
|
6160
|
+
- removed - An array containing any newly removed [[ValidationError]]s. This is those
|
|
6161
|
+
errors that have been 'fixed'.
|
|
6162
|
+
|
|
6163
|
+
> // assume order is an order entity attached to an EntityManager.
|
|
6164
|
+
> order.entityAspect.validationErrorsChanged.subscribe(
|
|
6165
|
+
> function (validationChangeArgs) {
|
|
6166
|
+
> // this code will be executed anytime a property value changes on the 'order' entity.
|
|
6167
|
+
> var entity == validationChangeArgs.entity; // Note: entity === order
|
|
6168
|
+
> var errorsAdded = validationChangeArgs.added;
|
|
6169
|
+
> var errorsCleared = validationChangeArgs.removed;
|
|
6170
|
+
> });
|
|
6171
|
+
@event
|
|
6172
|
+
**/
|
|
6173
|
+
validationErrorsChanged;
|
|
6174
|
+
/**
|
|
6175
|
+
A [[BreezeEvent]] that fires whenever a value of one of this entity's properties change.
|
|
6176
|
+
@eventArgs -
|
|
6177
|
+
- entity - The entity whose property has changed.
|
|
6178
|
+
- property - The [[DataProperty]] that changed.
|
|
6179
|
+
- propertyName - The name of the property that changed. This value will be 'null' for operations that replace the entire entity. This includes
|
|
6180
|
+
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"
|
|
6181
|
+
for any properties of a complex type.
|
|
6182
|
+
- oldValue - The old value of this property before the change.
|
|
6183
|
+
- newValue - The new value of this property after the change.
|
|
6184
|
+
- parent - The immediate parent object for the changed property. This will be a ComplexType instance as opposed to an Entity
|
|
6185
|
+
for any complex type or nested complex type properties.
|
|
6186
|
+
|
|
6187
|
+
> // assume order is an order entity attached to an EntityManager.
|
|
6188
|
+
> order.entityAspect.propertyChanged.subscribe(
|
|
6189
|
+
> function (propertyChangedArgs) {
|
|
6190
|
+
> // this code will be executed anytime a property value changes on the 'order' entity.
|
|
6191
|
+
> var entity = propertyChangedArgs.entity; // Note: entity === order
|
|
6192
|
+
> var propertyNameChanged = propertyChangedArgs.propertyName;
|
|
6193
|
+
> var oldValue = propertyChangedArgs.oldValue;
|
|
6194
|
+
> var newValue = propertyChangedArgs.newValue;
|
|
6195
|
+
> });
|
|
6196
|
+
@event
|
|
6197
|
+
**/
|
|
6198
|
+
propertyChanged;
|
|
6199
|
+
/** @hidden @internal */
|
|
6200
|
+
_validationErrors;
|
|
6201
|
+
/** @hidden @internal */
|
|
6202
|
+
_pendingValidationResult;
|
|
6203
|
+
/** @hidden @internal */
|
|
6204
|
+
_entityKey;
|
|
6205
|
+
/** @hidden @internal */
|
|
6206
|
+
_loadedNps;
|
|
6207
|
+
/** @hidden @internal */
|
|
6208
|
+
_initialized;
|
|
6209
|
+
/** @hidden @internal */
|
|
6210
|
+
_inProcess; // used in defaultPropertyInterceptor for temp storage.
|
|
6211
|
+
/** @hidden @internal */
|
|
6212
|
+
_inProcessEntity; // used in EntityManager
|
|
6213
|
+
/** @hidden @internal */
|
|
6214
|
+
static _nullInstance = new EntityAspect(); // TODO: determine if this works
|
|
5994
6215
|
/** @hidden @internal */
|
|
5995
6216
|
constructor(entity) {
|
|
5996
6217
|
// if called without new
|
|
5997
6218
|
// if (!(this instanceof EntityAspect)) {
|
|
5998
6219
|
// return new EntityAspect(entity);
|
|
5999
6220
|
// }
|
|
6000
|
-
/**
|
|
6001
|
-
Sets the entity to an EntityState of 'Unchanged'. This is also the equivalent of calling [[EntityAspect.acceptChanges]].
|
|
6002
|
-
The same operation can be performed by calling [[EntityAspect.setEntityState]].
|
|
6003
|
-
> // assume order is an order entity attached to an EntityManager.
|
|
6004
|
-
> order.entityAspect.setUnchanged();
|
|
6005
|
-
> // The 'order' entity will now be in an 'Unchanged' state with any changes committed.
|
|
6006
|
-
**/
|
|
6007
|
-
this.setUnchanged = function () {
|
|
6008
|
-
return this.setEntityState(EntityState.Unchanged);
|
|
6009
|
-
};
|
|
6010
|
-
/**
|
|
6011
|
-
Sets the entity to an EntityState of 'Modified'. This can also be achieved by changing the value of any property on an 'Unchanged' entity.
|
|
6012
|
-
The same operation can be performed by calling [[EntityAspect.setEntityState]].
|
|
6013
|
-
> // assume order is an order entity attached to an EntityManager.
|
|
6014
|
-
> order.entityAspect.setModified();
|
|
6015
|
-
> // The 'order' entity will now be in a 'Modified' state.
|
|
6016
|
-
**/
|
|
6017
|
-
this.setModified = function () {
|
|
6018
|
-
return this.setEntityState(EntityState.Modified);
|
|
6019
|
-
};
|
|
6020
|
-
/**
|
|
6021
|
-
Sets the entity to an EntityState of 'Deleted'. This both marks the entity as being scheduled for deletion during the next 'Save' call
|
|
6022
|
-
but also removes the entity from all of its related entities. If the current entityState is 'Added', then `setDeleted()` will mark it 'Detached'
|
|
6023
|
-
The same operation can be performed by calling [[EntityAspect.setEntityState]].
|
|
6024
|
-
> // assume order is an order entity attached to an EntityManager.
|
|
6025
|
-
> order.entityAspect.setDeleted();
|
|
6026
|
-
> // The 'order' entity will now be in a 'Deleted' state and it will no longer have any 'related' entities.
|
|
6027
|
-
**/
|
|
6028
|
-
this.setDeleted = function () {
|
|
6029
|
-
return this.setEntityState(EntityState.Deleted);
|
|
6030
|
-
};
|
|
6031
|
-
/**
|
|
6032
|
-
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.
|
|
6033
|
-
The same operation can be performed by calling [[EntityAspect.setEntityState]].
|
|
6034
|
-
> // assume order is an order entity attached to an EntityManager.
|
|
6035
|
-
> order.entityAspect.setDetached();
|
|
6036
|
-
> // The 'order' entity will now be in a 'Detached' state and it will no longer have any 'related' entities.
|
|
6037
|
-
**/
|
|
6038
|
-
this.setDetached = function () {
|
|
6039
|
-
return this.setEntityState(EntityState.Detached);
|
|
6040
|
-
};
|
|
6041
6221
|
this.entity = entity;
|
|
6042
6222
|
// TODO: keep public or not?
|
|
6043
6223
|
this.entityGroup = undefined;
|
|
@@ -6198,6 +6378,47 @@ class EntityAspect {
|
|
|
6198
6378
|
return this.setEntityState(EntityState.Added);
|
|
6199
6379
|
}
|
|
6200
6380
|
/**
|
|
6381
|
+
Sets the entity to an EntityState of 'Unchanged'. This is also the equivalent of calling [[EntityAspect.acceptChanges]].
|
|
6382
|
+
The same operation can be performed by calling [[EntityAspect.setEntityState]].
|
|
6383
|
+
> // assume order is an order entity attached to an EntityManager.
|
|
6384
|
+
> order.entityAspect.setUnchanged();
|
|
6385
|
+
> // The 'order' entity will now be in an 'Unchanged' state with any changes committed.
|
|
6386
|
+
**/
|
|
6387
|
+
setUnchanged = function () {
|
|
6388
|
+
return this.setEntityState(EntityState.Unchanged);
|
|
6389
|
+
};
|
|
6390
|
+
/**
|
|
6391
|
+
Sets the entity to an EntityState of 'Modified'. This can also be achieved by changing the value of any property on an 'Unchanged' entity.
|
|
6392
|
+
The same operation can be performed by calling [[EntityAspect.setEntityState]].
|
|
6393
|
+
> // assume order is an order entity attached to an EntityManager.
|
|
6394
|
+
> order.entityAspect.setModified();
|
|
6395
|
+
> // The 'order' entity will now be in a 'Modified' state.
|
|
6396
|
+
**/
|
|
6397
|
+
setModified = function () {
|
|
6398
|
+
return this.setEntityState(EntityState.Modified);
|
|
6399
|
+
};
|
|
6400
|
+
/**
|
|
6401
|
+
Sets the entity to an EntityState of 'Deleted'. This both marks the entity as being scheduled for deletion during the next 'Save' call
|
|
6402
|
+
but also removes the entity from all of its related entities. If the current entityState is 'Added', then `setDeleted()` will mark it 'Detached'
|
|
6403
|
+
The same operation can be performed by calling [[EntityAspect.setEntityState]].
|
|
6404
|
+
> // assume order is an order entity attached to an EntityManager.
|
|
6405
|
+
> order.entityAspect.setDeleted();
|
|
6406
|
+
> // The 'order' entity will now be in a 'Deleted' state and it will no longer have any 'related' entities.
|
|
6407
|
+
**/
|
|
6408
|
+
setDeleted = function () {
|
|
6409
|
+
return this.setEntityState(EntityState.Deleted);
|
|
6410
|
+
};
|
|
6411
|
+
/**
|
|
6412
|
+
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.
|
|
6413
|
+
The same operation can be performed by calling [[EntityAspect.setEntityState]].
|
|
6414
|
+
> // assume order is an order entity attached to an EntityManager.
|
|
6415
|
+
> order.entityAspect.setDetached();
|
|
6416
|
+
> // The 'order' entity will now be in a 'Detached' state and it will no longer have any 'related' entities.
|
|
6417
|
+
**/
|
|
6418
|
+
setDetached = function () {
|
|
6419
|
+
return this.setEntityState(EntityState.Detached);
|
|
6420
|
+
};
|
|
6421
|
+
/**
|
|
6201
6422
|
Sets the entity to the specified EntityState. See also 'setUnchanged', 'setModified', 'setDetached', etc.
|
|
6202
6423
|
> // assume order is an order entity attached to an EntityManager.
|
|
6203
6424
|
> order.entityAspect.setEntityState(EntityState.Unchanged);
|
|
@@ -6214,12 +6435,12 @@ class EntityAspect {
|
|
|
6214
6435
|
let em = this.entityManager;
|
|
6215
6436
|
let needsSave = true;
|
|
6216
6437
|
if (entityState === EntityState.Unchanged) {
|
|
6217
|
-
clearOriginalValues(entity);
|
|
6438
|
+
clearOriginalValues$1(entity);
|
|
6218
6439
|
delete this.hasTempKey;
|
|
6219
6440
|
needsSave = false;
|
|
6220
6441
|
}
|
|
6221
6442
|
else if (entityState === EntityState.Added) {
|
|
6222
|
-
clearOriginalValues(entity);
|
|
6443
|
+
clearOriginalValues$1(entity);
|
|
6223
6444
|
// TODO: more to do here... like regenerating key ???
|
|
6224
6445
|
}
|
|
6225
6446
|
else if (entityState === EntityState.Deleted) {
|
|
@@ -6560,8 +6781,6 @@ class EntityAspect {
|
|
|
6560
6781
|
}
|
|
6561
6782
|
}
|
|
6562
6783
|
}
|
|
6563
|
-
/** @hidden @internal */
|
|
6564
|
-
EntityAspect._nullInstance = new EntityAspect(); // TODO: determine if this works
|
|
6565
6784
|
BreezeEvent.bubbleEvent(EntityAspect.prototype, function () {
|
|
6566
6785
|
return this.entityManager;
|
|
6567
6786
|
});
|
|
@@ -6695,6 +6914,17 @@ entity via either a query, import or EntityManager.createEntity call.
|
|
|
6695
6914
|
> // aCustomer === aspect.parent;
|
|
6696
6915
|
**/
|
|
6697
6916
|
class ComplexAspect {
|
|
6917
|
+
/** The complex object that this aspect is associated with. __Read Only__ */
|
|
6918
|
+
complexObject;
|
|
6919
|
+
/** The 'original values' of this complex object where they are different from the 'current values'.
|
|
6920
|
+
This is a map where the key is a property name and the value is the 'original value' of the property.
|
|
6921
|
+
__Read Only__ */
|
|
6922
|
+
originalValues;
|
|
6923
|
+
/** The parent object that to which this aspect belongs; this will either be an entity or another complex object. __Read Only__ */
|
|
6924
|
+
parent;
|
|
6925
|
+
/** The [[DataProperty]] on the 'parent' that contains this complex object. __Read Only__ */
|
|
6926
|
+
parentProperty;
|
|
6927
|
+
extraMetadata;
|
|
6698
6928
|
/** You will rarely, if ever, create a ComplexAspect directly. */
|
|
6699
6929
|
constructor(complexObject, parent, parentProperty) {
|
|
6700
6930
|
if (!complexObject) {
|
|
@@ -6754,18 +6984,18 @@ class ComplexAspect {
|
|
|
6754
6984
|
return aspect.getPropertyPath(this.parentProperty.name + "." + propName);
|
|
6755
6985
|
}
|
|
6756
6986
|
}
|
|
6757
|
-
function clearOriginalValues(target) {
|
|
6987
|
+
function clearOriginalValues$1(target) {
|
|
6758
6988
|
let aspect = target.entityAspect || target.complexAspect;
|
|
6759
6989
|
aspect.originalValues = {};
|
|
6760
6990
|
let stype = target.entityType || target.complexType;
|
|
6761
6991
|
stype.complexProperties.forEach(function (cp) {
|
|
6762
6992
|
let cos = target.getProperty(cp.name);
|
|
6763
6993
|
if (cp.isScalar) {
|
|
6764
|
-
clearOriginalValues(cos);
|
|
6994
|
+
clearOriginalValues$1(cos);
|
|
6765
6995
|
}
|
|
6766
6996
|
else {
|
|
6767
6997
|
cos._acceptChanges();
|
|
6768
|
-
cos.forEach(clearOriginalValues);
|
|
6998
|
+
cos.forEach(clearOriginalValues$1);
|
|
6769
6999
|
}
|
|
6770
7000
|
});
|
|
6771
7001
|
}
|
|
@@ -6778,6 +7008,14 @@ The default NamingConvention does not perform any translation, it simply passes
|
|
|
6778
7008
|
@dynamic
|
|
6779
7009
|
**/
|
|
6780
7010
|
class NamingConvention {
|
|
7011
|
+
/** @hidden @internal */
|
|
7012
|
+
_$typeName;
|
|
7013
|
+
/** The name of this NamingConvention. __Read Only__ */
|
|
7014
|
+
name;
|
|
7015
|
+
/** Function that takes a server property name add converts it into a client side property name. __Read Only__ */
|
|
7016
|
+
serverPropertyNameToClient;
|
|
7017
|
+
/** Function that takes a client property name add converts it into a server side property name. __Read Only__ */
|
|
7018
|
+
clientPropertyNameToServer;
|
|
6781
7019
|
/**
|
|
6782
7020
|
NamingConvention constructor
|
|
6783
7021
|
> // A naming convention that converts the first character of every property name to uppercase on the server
|
|
@@ -6805,6 +7043,38 @@ class NamingConvention {
|
|
|
6805
7043
|
config._storeObject(this, "NamingConvention", this.name);
|
|
6806
7044
|
}
|
|
6807
7045
|
/**
|
|
7046
|
+
|
|
7047
|
+
|
|
7048
|
+
/**
|
|
7049
|
+
A noop naming convention - This is the default unless another is specified.
|
|
7050
|
+
**/
|
|
7051
|
+
static none = new NamingConvention({
|
|
7052
|
+
name: "noChange",
|
|
7053
|
+
serverPropertyNameToClient: (serverPropertyName) => {
|
|
7054
|
+
return serverPropertyName;
|
|
7055
|
+
},
|
|
7056
|
+
clientPropertyNameToServer: (clientPropertyName) => {
|
|
7057
|
+
return clientPropertyName;
|
|
7058
|
+
}
|
|
7059
|
+
});
|
|
7060
|
+
/**
|
|
7061
|
+
The "camelCase" naming convention - This implementation only lowercases the first character of the server property name
|
|
7062
|
+
but leaves the rest of the property name intact. If a more complicated version is needed then one should be created via the ctor.
|
|
7063
|
+
**/
|
|
7064
|
+
static camelCase = new NamingConvention({
|
|
7065
|
+
name: "camelCase",
|
|
7066
|
+
serverPropertyNameToClient: (serverPropertyName) => {
|
|
7067
|
+
return serverPropertyName.substr(0, 1).toLowerCase() + serverPropertyName.substr(1);
|
|
7068
|
+
},
|
|
7069
|
+
clientPropertyNameToServer: (clientPropertyName) => {
|
|
7070
|
+
return clientPropertyName.substr(0, 1).toUpperCase() + clientPropertyName.substr(1);
|
|
7071
|
+
}
|
|
7072
|
+
});
|
|
7073
|
+
/**
|
|
7074
|
+
The default value whenever NamingConventions are not specified.
|
|
7075
|
+
**/
|
|
7076
|
+
static defaultInstance = new NamingConvention(NamingConvention.none);
|
|
7077
|
+
/**
|
|
6808
7078
|
Sets the 'defaultInstance' by creating a copy of the current 'defaultInstance' and then applying all of the properties of the current instance.
|
|
6809
7079
|
The current instance is returned unchanged.
|
|
6810
7080
|
> var namingConv = new NamingConvention({
|
|
@@ -6821,38 +7091,6 @@ class NamingConvention {
|
|
|
6821
7091
|
return core.setAsDefault(this, NamingConvention);
|
|
6822
7092
|
}
|
|
6823
7093
|
}
|
|
6824
|
-
/**
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
/**
|
|
6828
|
-
A noop naming convention - This is the default unless another is specified.
|
|
6829
|
-
**/
|
|
6830
|
-
NamingConvention.none = new NamingConvention({
|
|
6831
|
-
name: "noChange",
|
|
6832
|
-
serverPropertyNameToClient: (serverPropertyName) => {
|
|
6833
|
-
return serverPropertyName;
|
|
6834
|
-
},
|
|
6835
|
-
clientPropertyNameToServer: (clientPropertyName) => {
|
|
6836
|
-
return clientPropertyName;
|
|
6837
|
-
}
|
|
6838
|
-
});
|
|
6839
|
-
/**
|
|
6840
|
-
The "camelCase" naming convention - This implementation only lowercases the first character of the server property name
|
|
6841
|
-
but leaves the rest of the property name intact. If a more complicated version is needed then one should be created via the ctor.
|
|
6842
|
-
**/
|
|
6843
|
-
NamingConvention.camelCase = new NamingConvention({
|
|
6844
|
-
name: "camelCase",
|
|
6845
|
-
serverPropertyNameToClient: (serverPropertyName) => {
|
|
6846
|
-
return serverPropertyName.substr(0, 1).toLowerCase() + serverPropertyName.substr(1);
|
|
6847
|
-
},
|
|
6848
|
-
clientPropertyNameToServer: (clientPropertyName) => {
|
|
6849
|
-
return clientPropertyName.substr(0, 1).toUpperCase() + clientPropertyName.substr(1);
|
|
6850
|
-
}
|
|
6851
|
-
});
|
|
6852
|
-
/**
|
|
6853
|
-
The default value whenever NamingConventions are not specified.
|
|
6854
|
-
**/
|
|
6855
|
-
NamingConvention.defaultInstance = new NamingConvention(NamingConvention.none);
|
|
6856
7094
|
NamingConvention.prototype._$typeName = "NamingConvention";
|
|
6857
7095
|
|
|
6858
7096
|
const RX_COLLECTION = /Collection\((.*)\)/;
|
|
@@ -7245,6 +7483,16 @@ The default LocalQueryComparisonOptions stipulates 'caseInsensitive" queries wit
|
|
|
7245
7483
|
length strings.
|
|
7246
7484
|
**/
|
|
7247
7485
|
class LocalQueryComparisonOptions {
|
|
7486
|
+
/** @hidden @internal */
|
|
7487
|
+
_$typeName; // on prototype
|
|
7488
|
+
/** The name for this instance. */
|
|
7489
|
+
name;
|
|
7490
|
+
/** Whether predicates that involve strings will be interpreted in a "caseSensitive" manner. (default = false). */
|
|
7491
|
+
isCaseSensitive;
|
|
7492
|
+
/* Whether or not to enforce the ANSI SQL standard
|
|
7493
|
+
of padding strings of unequal lengths before comparison with spaces. Note that per the standard, padding only occurs with equality and
|
|
7494
|
+
inequality predicates, and not with operations like 'startsWith', 'endsWith' or 'contains'. Default is true. */
|
|
7495
|
+
usesSql92CompliantStringComparison;
|
|
7248
7496
|
/**
|
|
7249
7497
|
LocalQueryComparisonOptions constructor
|
|
7250
7498
|
> // create a 'caseSensitive - non SQL' instance.
|
|
@@ -7272,6 +7520,18 @@ class LocalQueryComparisonOptions {
|
|
|
7272
7520
|
config._storeObject(this, "LocalQueryComparisonOptions", this.name);
|
|
7273
7521
|
}
|
|
7274
7522
|
/**
|
|
7523
|
+
Case insensitive SQL compliant options - this is also the default unless otherwise changed.
|
|
7524
|
+
**/
|
|
7525
|
+
static caseInsensitiveSQL = new LocalQueryComparisonOptions({
|
|
7526
|
+
name: "caseInsensitiveSQL",
|
|
7527
|
+
isCaseSensitive: false,
|
|
7528
|
+
usesSql92CompliantStringComparison: true
|
|
7529
|
+
});
|
|
7530
|
+
/**
|
|
7531
|
+
The default value whenever LocalQueryComparisonOptions are not specified. By default this is 'caseInsensitiveSQL'.
|
|
7532
|
+
**/
|
|
7533
|
+
static defaultInstance = new LocalQueryComparisonOptions(LocalQueryComparisonOptions.caseInsensitiveSQL);
|
|
7534
|
+
/**
|
|
7275
7535
|
Sets the 'defaultInstance' by creating a copy of the current 'defaultInstance' and then applying all of the properties of the current instance.
|
|
7276
7536
|
The current instance is returned unchanged.
|
|
7277
7537
|
> var lqco = new LocalQueryComparisonOptions({
|
|
@@ -7284,18 +7544,6 @@ class LocalQueryComparisonOptions {
|
|
|
7284
7544
|
return core.setAsDefault(this, LocalQueryComparisonOptions);
|
|
7285
7545
|
}
|
|
7286
7546
|
}
|
|
7287
|
-
/**
|
|
7288
|
-
Case insensitive SQL compliant options - this is also the default unless otherwise changed.
|
|
7289
|
-
**/
|
|
7290
|
-
LocalQueryComparisonOptions.caseInsensitiveSQL = new LocalQueryComparisonOptions({
|
|
7291
|
-
name: "caseInsensitiveSQL",
|
|
7292
|
-
isCaseSensitive: false,
|
|
7293
|
-
usesSql92CompliantStringComparison: true
|
|
7294
|
-
});
|
|
7295
|
-
/**
|
|
7296
|
-
The default value whenever LocalQueryComparisonOptions are not specified. By default this is 'caseInsensitiveSQL'.
|
|
7297
|
-
**/
|
|
7298
|
-
LocalQueryComparisonOptions.defaultInstance = new LocalQueryComparisonOptions(LocalQueryComparisonOptions.caseInsensitiveSQL);
|
|
7299
7547
|
LocalQueryComparisonOptions.prototype._$typeName = "LocalQueryComparisonOptions";
|
|
7300
7548
|
|
|
7301
7549
|
/** @hidden @internal */
|
|
@@ -7759,6 +8007,52 @@ explicit MetadataStore, the MetadataStore from the MetadataStore.defaultInstance
|
|
|
7759
8007
|
@dynamic
|
|
7760
8008
|
**/
|
|
7761
8009
|
class MetadataStore {
|
|
8010
|
+
/** @hidden @internal */
|
|
8011
|
+
static __id = 0;
|
|
8012
|
+
/** @hidden @internal */
|
|
8013
|
+
static ANONTYPE_PREFIX = "_IB_";
|
|
8014
|
+
/** The version of any MetadataStores created by this class */
|
|
8015
|
+
static metadataVersion = '1.0.5';
|
|
8016
|
+
name;
|
|
8017
|
+
dataServices;
|
|
8018
|
+
/** The [[NamingConvention]] associated with this MetadataStore. __Read Only__ */
|
|
8019
|
+
namingConvention;
|
|
8020
|
+
/** The [[LocalQueryComparisonOptions]] associated with this MetadataStore. __Read Only__ */
|
|
8021
|
+
localQueryComparisonOptions;
|
|
8022
|
+
serializerFn;
|
|
8023
|
+
/**
|
|
8024
|
+
An [[BreezeEvent]] that fires after a MetadataStore has completed fetching metadata from a remote service.
|
|
8025
|
+
|
|
8026
|
+
@eventArgs -
|
|
8027
|
+
- metadataStore - The MetadataStore into which the metadata was fetched.
|
|
8028
|
+
- dataService - The [[DataService]] that metadata was fetched from.
|
|
8029
|
+
- rawMetadata - {Object} The raw metadata returned from the service. (It will have already been processed by this point).
|
|
8030
|
+
> let ms = myEntityManager.metadataStore;
|
|
8031
|
+
> ms.metadataFetched.subscribe(function(args) {
|
|
8032
|
+
> let metadataStore = args.metadataStore;
|
|
8033
|
+
> let dataService = args.dataService;
|
|
8034
|
+
> });
|
|
8035
|
+
@event
|
|
8036
|
+
**/
|
|
8037
|
+
metadataFetched;
|
|
8038
|
+
/** @hidden @internal */
|
|
8039
|
+
_resourceEntityTypeMap;
|
|
8040
|
+
/** @hidden @internal */
|
|
8041
|
+
_entityTypeResourceMap;
|
|
8042
|
+
/** @hidden @internal key is qualified structuraltype name - value is structuralType. ( structural = entityType or complexType). */
|
|
8043
|
+
_structuralTypeMap;
|
|
8044
|
+
/** @hidden @internal key is shortName, value is qualified name - does not need to be serialized. **/
|
|
8045
|
+
_shortNameMap;
|
|
8046
|
+
/** @hidden @internal key is either short or qual type name - value is ctor; **/
|
|
8047
|
+
_ctorRegistry;
|
|
8048
|
+
/** @hidden @internal key is entityTypeName; value is array of nav props **/
|
|
8049
|
+
_incompleteTypeMap;
|
|
8050
|
+
/** @hidden @internal **/
|
|
8051
|
+
_incompleteComplexTypeMap;
|
|
8052
|
+
/** @hidden @internal { json: any, stype: StructuralType }[] | { entityType: EntityType, csdlEntityType: any }[] **/
|
|
8053
|
+
_deferredTypes;
|
|
8054
|
+
/** @hidden @internal **/
|
|
8055
|
+
_id;
|
|
7762
8056
|
/**
|
|
7763
8057
|
Constructs a new MetadataStore.
|
|
7764
8058
|
|
|
@@ -7798,6 +8092,10 @@ class MetadataStore {
|
|
|
7798
8092
|
this._id = MetadataStore.__id++;
|
|
7799
8093
|
this.metadataFetched = new BreezeEvent("metadataFetched", this);
|
|
7800
8094
|
}
|
|
8095
|
+
// needs to be made avail to dataService.xxx files
|
|
8096
|
+
static normalizeTypeName = core.memoize(function (rawTypeName) {
|
|
8097
|
+
return rawTypeName && MetadataStore.parseTypeName(rawTypeName).typeName;
|
|
8098
|
+
});
|
|
7801
8099
|
// for debugging use the line below instead.
|
|
7802
8100
|
//ctor.normalizeTypeName = function (rawTypeName) { return parseTypeName(rawTypeName).typeName; };
|
|
7803
8101
|
/**
|
|
@@ -8328,16 +8626,6 @@ class MetadataStore {
|
|
|
8328
8626
|
}
|
|
8329
8627
|
}
|
|
8330
8628
|
}
|
|
8331
|
-
/** @hidden @internal */
|
|
8332
|
-
MetadataStore.__id = 0;
|
|
8333
|
-
/** @hidden @internal */
|
|
8334
|
-
MetadataStore.ANONTYPE_PREFIX = "_IB_";
|
|
8335
|
-
/** The version of any MetadataStores created by this class */
|
|
8336
|
-
MetadataStore.metadataVersion = '1.0.5';
|
|
8337
|
-
// needs to be made avail to dataService.xxx files
|
|
8338
|
-
MetadataStore.normalizeTypeName = core.memoize(function (rawTypeName) {
|
|
8339
|
-
return rawTypeName && MetadataStore.parseTypeName(rawTypeName).typeName;
|
|
8340
|
-
});
|
|
8341
8629
|
MetadataStore.prototype._$typeName = "MetadataStore";
|
|
8342
8630
|
BreezeEvent.bubbleEvent(MetadataStore.prototype);
|
|
8343
8631
|
function getTypesFromMap(typeMap) {
|
|
@@ -8456,6 +8744,76 @@ function getQualifiedTypeName(metadataStore, structTypeName, throwIfNotFound) {
|
|
|
8456
8744
|
/** Container for all of the metadata about a specific type of Entity.
|
|
8457
8745
|
**/
|
|
8458
8746
|
class EntityType {
|
|
8747
|
+
/** @hidden @internal */
|
|
8748
|
+
static __nextAnonIx = 0;
|
|
8749
|
+
/** Always false for an EntityType. **/
|
|
8750
|
+
isComplexType = false;
|
|
8751
|
+
/** The [[MetadataStore]] that contains this EntityType. __Read Only__ **/
|
|
8752
|
+
metadataStore;
|
|
8753
|
+
/** The DataProperties (see [[DataProperty]] associated with this EntityType. __Read Only__ **/
|
|
8754
|
+
dataProperties;
|
|
8755
|
+
/** The NavigationProperties (see [[NavigationProperty]] associated with this EntityType. __Read Only__ **/
|
|
8756
|
+
navigationProperties;
|
|
8757
|
+
/**
|
|
8758
|
+
The DataProperties associated with this EntityType that make up it's [[EntityKey]]. __Read Only__ **/
|
|
8759
|
+
keyProperties;
|
|
8760
|
+
/** The DataProperties associated with this EntityType that are foreign key properties. __Read Only__ **/
|
|
8761
|
+
foreignKeyProperties;
|
|
8762
|
+
inverseForeignKeyProperties;
|
|
8763
|
+
/** The DataProperties associated with this EntityType that are concurrency properties. __Read Only__ **/
|
|
8764
|
+
concurrencyProperties;
|
|
8765
|
+
/** The DataProperties for this EntityType that contain instances of a [[ComplexType]]. __Read Only__ **/
|
|
8766
|
+
complexProperties;
|
|
8767
|
+
/** The DataProperties associated with this EntityType that are not mapped to any backend datastore. These are effectively free standing
|
|
8768
|
+
properties. __Read Only__ **/
|
|
8769
|
+
unmappedProperties;
|
|
8770
|
+
/** The fully qualified name of this EntityType. __Read Only__ **/
|
|
8771
|
+
name;
|
|
8772
|
+
/** The short, unqualified, name for this EntityType. __Read Only__ **/
|
|
8773
|
+
shortName;
|
|
8774
|
+
/** The namespace for this EntityType. __Read Only__ **/
|
|
8775
|
+
namespace;
|
|
8776
|
+
/** The name of this EntityType's base EntityType (if any) */
|
|
8777
|
+
baseTypeName;
|
|
8778
|
+
/** The base EntityType (if any) for this EntityType. __Read Only__ **/
|
|
8779
|
+
baseEntityType;
|
|
8780
|
+
subtypes;
|
|
8781
|
+
/** Whether this EntityType is abstract. __Read Only__ **/
|
|
8782
|
+
isAbstract;
|
|
8783
|
+
/** Whether this EntityType is anonymous. Anonymous types will never be communicated to or from the server. They are purely for
|
|
8784
|
+
client side use and are given an automatically generated name. __Read Only__ **/
|
|
8785
|
+
isAnonymous;
|
|
8786
|
+
/** Whether this EntityType has been 'frozen'. EntityTypes become frozen after the first instance
|
|
8787
|
+
of that type has been created and attached to an EntityManager. */
|
|
8788
|
+
isFrozen;
|
|
8789
|
+
/** The [[AutoGeneratedKeyType]] for this EntityType. __Read Only__ **/
|
|
8790
|
+
autoGeneratedKeyType;
|
|
8791
|
+
/** The default resource name associated with this EntityType. An EntityType may be queried via a variety of 'resource names' but this one
|
|
8792
|
+
is used as the default when no resource name is provided. This will occur when calling [[EntityAspect.loadNavigationProperty]]
|
|
8793
|
+
or when executing any [[EntityQuery]] that was created via an [[EntityKey]]. __Read Only__ **/
|
|
8794
|
+
defaultResourceName;
|
|
8795
|
+
/** A function that is used to customize the serialization of any EntityProperties of this type. */
|
|
8796
|
+
serializerFn;
|
|
8797
|
+
/** A free form object that can be used to define any custom metadata for this EntityType. __Read Only__ **/
|
|
8798
|
+
custom;
|
|
8799
|
+
/** The entity level validators associated with this EntityType. Validators can be added and
|
|
8800
|
+
removed from this collection. __Read Only__. **/
|
|
8801
|
+
validators;
|
|
8802
|
+
warnings;
|
|
8803
|
+
initFn;
|
|
8804
|
+
noTrackingFn;
|
|
8805
|
+
/** @hidden @internal */
|
|
8806
|
+
_extra;
|
|
8807
|
+
/** @hidden @internal */
|
|
8808
|
+
_ctor;
|
|
8809
|
+
/** @hidden @internal */
|
|
8810
|
+
_mappedPropertiesCount;
|
|
8811
|
+
/**
|
|
8812
|
+
@deprecated Use [[getCtor]] instead.
|
|
8813
|
+
*/
|
|
8814
|
+
getEntityCtor = this.getCtor;
|
|
8815
|
+
/** @hidden @internal */
|
|
8816
|
+
static qualifyTypeName = qualifyTypeName;
|
|
8459
8817
|
/** EntityType constructor
|
|
8460
8818
|
> let entityType = new EntityType( {
|
|
8461
8819
|
> shortName: "person",
|
|
@@ -8466,12 +8824,6 @@ class EntityType {
|
|
|
8466
8824
|
client side use and will be given an automatically generated name. Normally, however, you will use a configuration object.
|
|
8467
8825
|
**/
|
|
8468
8826
|
constructor(config) {
|
|
8469
|
-
/** Always false for an EntityType. **/
|
|
8470
|
-
this.isComplexType = false;
|
|
8471
|
-
/**
|
|
8472
|
-
@deprecated Use [[getCtor]] instead.
|
|
8473
|
-
*/
|
|
8474
|
-
this.getEntityCtor = this.getCtor;
|
|
8475
8827
|
if (arguments.length > 1) {
|
|
8476
8828
|
throw new Error("The EntityType ctor has a single argument that is either a 'MetadataStore' or a configuration object.");
|
|
8477
8829
|
}
|
|
@@ -9123,10 +9475,6 @@ class EntityType {
|
|
|
9123
9475
|
delete incompleteTypeMap[this.name];
|
|
9124
9476
|
}
|
|
9125
9477
|
}
|
|
9126
|
-
/** @hidden @internal */
|
|
9127
|
-
EntityType.__nextAnonIx = 0;
|
|
9128
|
-
/** @hidden @internal */
|
|
9129
|
-
EntityType.qualifyTypeName = qualifyTypeName;
|
|
9130
9478
|
EntityType.prototype._$typeName = "EntityType";
|
|
9131
9479
|
function getRawValueFromConfig(rawEntity, dp) {
|
|
9132
9480
|
// 'true' fork can happen if an initializer contains an actaul instance of an already created complex object.
|
|
@@ -9265,33 +9613,66 @@ function calcUnmappedProperties(stype, instance) {
|
|
|
9265
9613
|
@param config - Configuration settings
|
|
9266
9614
|
**/
|
|
9267
9615
|
class ComplexType {
|
|
9616
|
+
/** For polymorphic purpose only - always true here */
|
|
9617
|
+
isComplexType = true;
|
|
9618
|
+
/** The [[MetadataStore]] containing this ComplexType. */
|
|
9619
|
+
metadataStore;
|
|
9620
|
+
/** The fully qualifed name of this ComplexType. __Read Only__ **/
|
|
9621
|
+
name;
|
|
9622
|
+
/** The short, unqualified, name for this ComplexType. __Read Only__ **/
|
|
9623
|
+
shortName;
|
|
9624
|
+
/** The namespace for this ComplexType. __Read Only__ **/
|
|
9625
|
+
namespace;
|
|
9626
|
+
/** The DataProperties (see [[DataProperty]] associated with this ComplexType. __Read Only__ */
|
|
9627
|
+
dataProperties;
|
|
9628
|
+
/** The DataProperties for this ComplexType that contain instances of a [[ComplexType]]. __Read Only__ */
|
|
9629
|
+
complexProperties;
|
|
9630
|
+
/**
|
|
9631
|
+
The entity level validators associated with this ComplexType. Validators can be added and
|
|
9632
|
+
removed from this collection. __Read Only__ **/
|
|
9633
|
+
validators;
|
|
9634
|
+
/** For polymorphic purpose only - always empty here */
|
|
9635
|
+
concurrencyProperties;
|
|
9636
|
+
/** The DataProperties associated with this ComplexType that are not mapped to any backend datastore. These are effectively free standing
|
|
9637
|
+
properties. __Read Only__ **/
|
|
9638
|
+
unmappedProperties;
|
|
9639
|
+
// keyProperties and navigationProperties are not used on complexTypes - but here to allow sharing of code between EntityType and ComplexType.
|
|
9640
|
+
navigationProperties;
|
|
9641
|
+
// and may be used later to enforce uniqueness on arrays of complextypes.
|
|
9642
|
+
keyProperties;
|
|
9643
|
+
warnings;
|
|
9644
|
+
serializerFn;
|
|
9645
|
+
/** A free form object that can be used to define any custom metadata for this ComplexType. ***/
|
|
9646
|
+
custom;
|
|
9647
|
+
/** @hidden @internal */
|
|
9648
|
+
_mappedPropertiesCount;
|
|
9649
|
+
/** @hidden @internal */
|
|
9650
|
+
_extra;
|
|
9651
|
+
// copy entityType methods onto complexType
|
|
9652
|
+
/** See [[EntityType.getCtor]] */
|
|
9653
|
+
getCtor = EntityType.prototype.getCtor;
|
|
9654
|
+
// note the name change.
|
|
9655
|
+
createInstance = EntityType.prototype.createEntity;
|
|
9656
|
+
/** See [EntityType.addValidator] */
|
|
9657
|
+
addValidator = EntityType.prototype.addValidator;
|
|
9658
|
+
getProperty = EntityType.prototype.getProperty;
|
|
9659
|
+
getPropertiesOnPath = EntityType.prototype.getPropertiesOnPath;
|
|
9660
|
+
getPropertyNames = EntityType.prototype.getPropertyNames;
|
|
9661
|
+
/** @hidden @internal */
|
|
9662
|
+
_addPropertyCore = EntityType.prototype._addPropertyCore;
|
|
9663
|
+
/** @hidden @internal */
|
|
9664
|
+
_addDataProperty = EntityType.prototype._addDataProperty;
|
|
9665
|
+
/** @hidden @internal */
|
|
9666
|
+
_updateNames = EntityType.prototype._updateNames;
|
|
9667
|
+
/** @hidden @internal */
|
|
9668
|
+
_updateCps = EntityType.prototype._updateCps;
|
|
9669
|
+
/** @hidden @internal */
|
|
9670
|
+
_initializeInstance = EntityType.prototype._initializeInstance;
|
|
9671
|
+
/** @hidden @internal */
|
|
9672
|
+
_updateTargetFromRaw = EntityType.prototype._updateTargetFromRaw;
|
|
9673
|
+
/** @hidden @internal */
|
|
9674
|
+
_setCtor = EntityType.prototype._setCtor;
|
|
9268
9675
|
constructor(config) {
|
|
9269
|
-
/** For polymorphic purpose only - always true here */
|
|
9270
|
-
this.isComplexType = true;
|
|
9271
|
-
// copy entityType methods onto complexType
|
|
9272
|
-
/** See [[EntityType.getCtor]] */
|
|
9273
|
-
this.getCtor = EntityType.prototype.getCtor;
|
|
9274
|
-
// note the name change.
|
|
9275
|
-
this.createInstance = EntityType.prototype.createEntity;
|
|
9276
|
-
/** See [EntityType.addValidator] */
|
|
9277
|
-
this.addValidator = EntityType.prototype.addValidator;
|
|
9278
|
-
this.getProperty = EntityType.prototype.getProperty;
|
|
9279
|
-
this.getPropertiesOnPath = EntityType.prototype.getPropertiesOnPath;
|
|
9280
|
-
this.getPropertyNames = EntityType.prototype.getPropertyNames;
|
|
9281
|
-
/** @hidden @internal */
|
|
9282
|
-
this._addPropertyCore = EntityType.prototype._addPropertyCore;
|
|
9283
|
-
/** @hidden @internal */
|
|
9284
|
-
this._addDataProperty = EntityType.prototype._addDataProperty;
|
|
9285
|
-
/** @hidden @internal */
|
|
9286
|
-
this._updateNames = EntityType.prototype._updateNames;
|
|
9287
|
-
/** @hidden @internal */
|
|
9288
|
-
this._updateCps = EntityType.prototype._updateCps;
|
|
9289
|
-
/** @hidden @internal */
|
|
9290
|
-
this._initializeInstance = EntityType.prototype._initializeInstance;
|
|
9291
|
-
/** @hidden @internal */
|
|
9292
|
-
this._updateTargetFromRaw = EntityType.prototype._updateTargetFromRaw;
|
|
9293
|
-
/** @hidden @internal */
|
|
9294
|
-
this._setCtor = EntityType.prototype._setCtor;
|
|
9295
9676
|
if (arguments.length > 1) {
|
|
9296
9677
|
throw new Error("The ComplexType ctor has a single argument that is a configuration object.");
|
|
9297
9678
|
}
|
|
@@ -9372,6 +9753,10 @@ Instances of the DataProperty class are constructed automatically during Metadat
|
|
|
9372
9753
|
directly via the constructor.
|
|
9373
9754
|
**/
|
|
9374
9755
|
class DataProperty {
|
|
9756
|
+
/** Is this a DataProperty? - always true here. Allows polymorphic treatment of DataProperties and NavigationProperties. __Read Only__ */
|
|
9757
|
+
isDataProperty = true;
|
|
9758
|
+
/** Is this a NavigationProperty? - always false here. Allows polymorphic treatment of DataProperties and NavigationProperties. __Read Only__ */
|
|
9759
|
+
isNavigationProperty = false;
|
|
9375
9760
|
/** DataProperty constructor
|
|
9376
9761
|
> let lastNameProp = new DataProperty( {
|
|
9377
9762
|
> name: "lastName",
|
|
@@ -9384,10 +9769,6 @@ class DataProperty {
|
|
|
9384
9769
|
@param config - A configuration Object or a DataProperty
|
|
9385
9770
|
*/
|
|
9386
9771
|
constructor(config) {
|
|
9387
|
-
/** Is this a DataProperty? - always true here. Allows polymorphic treatment of DataProperties and NavigationProperties. __Read Only__ */
|
|
9388
|
-
this.isDataProperty = true;
|
|
9389
|
-
/** Is this a NavigationProperty? - always false here. Allows polymorphic treatment of DataProperties and NavigationProperties. __Read Only__ */
|
|
9390
|
-
this.isNavigationProperty = false;
|
|
9391
9772
|
assertConfig(config)
|
|
9392
9773
|
.whereParam("name").isString().isOptional()
|
|
9393
9774
|
.whereParam("nameOnServer").isString().isOptional()
|
|
@@ -9551,6 +9932,15 @@ Instances of the NavigationProperty class are constructed automatically during M
|
|
|
9551
9932
|
directly via the constructor.
|
|
9552
9933
|
**/
|
|
9553
9934
|
class NavigationProperty {
|
|
9935
|
+
/** Is this a DataProperty? - always false here
|
|
9936
|
+
Allows polymorphic treatment of DataProperties and NavigationProperties. __Read Only__ */
|
|
9937
|
+
isDataProperty = false;
|
|
9938
|
+
/** Is this a NavigationProperty? - always true here
|
|
9939
|
+
Allows polymorphic treatment of DataProperties and NavigationProperties. __Read Only__ */
|
|
9940
|
+
isNavigationProperty = true;
|
|
9941
|
+
formatName = DataProperty.prototype.formatName;
|
|
9942
|
+
getAllValidators = DataProperty.prototype.getAllValidators;
|
|
9943
|
+
resolveProperty = DataProperty.prototype.resolveProperty;
|
|
9554
9944
|
/** NavigationProperty constructor
|
|
9555
9945
|
> let homeAddressProp = new NavigationProperty( {
|
|
9556
9946
|
> name: "homeAddress",
|
|
@@ -9569,15 +9959,6 @@ class NavigationProperty {
|
|
|
9569
9959
|
@param config - A configuration object.
|
|
9570
9960
|
**/
|
|
9571
9961
|
constructor(config) {
|
|
9572
|
-
/** Is this a DataProperty? - always false here
|
|
9573
|
-
Allows polymorphic treatment of DataProperties and NavigationProperties. __Read Only__ */
|
|
9574
|
-
this.isDataProperty = false;
|
|
9575
|
-
/** Is this a NavigationProperty? - always true here
|
|
9576
|
-
Allows polymorphic treatment of DataProperties and NavigationProperties. __Read Only__ */
|
|
9577
|
-
this.isNavigationProperty = true;
|
|
9578
|
-
this.formatName = DataProperty.prototype.formatName;
|
|
9579
|
-
this.getAllValidators = DataProperty.prototype.getAllValidators;
|
|
9580
|
-
this.resolveProperty = DataProperty.prototype.resolveProperty;
|
|
9581
9962
|
assertConfig(config)
|
|
9582
9963
|
.whereParam("name").isString().isOptional()
|
|
9583
9964
|
.whereParam("nameOnServer").isString().isOptional()
|
|
@@ -9769,24 +10150,24 @@ function resolveRelated(np) {
|
|
|
9769
10150
|
AutoGeneratedKeyType is an 'Enum' containing all of the valid states for an automatically generated key.
|
|
9770
10151
|
**/
|
|
9771
10152
|
class AutoGeneratedKeyType extends BreezeEnum {
|
|
10153
|
+
/**
|
|
10154
|
+
This entity does not have an autogenerated key.
|
|
10155
|
+
The client must set the key before adding the entity to the EntityManager
|
|
10156
|
+
**/
|
|
10157
|
+
static None = new AutoGeneratedKeyType();
|
|
10158
|
+
/**
|
|
10159
|
+
This entity's key is an Identity column and is set by the backend database.
|
|
10160
|
+
Keys for new entities will be temporary until the entities are saved at which point the keys will
|
|
10161
|
+
be converted to their 'real' versions.
|
|
10162
|
+
**/
|
|
10163
|
+
static Identity = new AutoGeneratedKeyType();
|
|
10164
|
+
/**
|
|
10165
|
+
This entity's key is generated by a KeyGenerator and is set by the backend database.
|
|
10166
|
+
Keys for new entities will be temporary until the entities are saved at which point the keys will
|
|
10167
|
+
be converted to their 'real' versions.
|
|
10168
|
+
**/
|
|
10169
|
+
static KeyGenerator = new AutoGeneratedKeyType();
|
|
9772
10170
|
}
|
|
9773
|
-
/**
|
|
9774
|
-
This entity does not have an autogenerated key.
|
|
9775
|
-
The client must set the key before adding the entity to the EntityManager
|
|
9776
|
-
**/
|
|
9777
|
-
AutoGeneratedKeyType.None = new AutoGeneratedKeyType();
|
|
9778
|
-
/**
|
|
9779
|
-
This entity's key is an Identity column and is set by the backend database.
|
|
9780
|
-
Keys for new entities will be temporary until the entities are saved at which point the keys will
|
|
9781
|
-
be converted to their 'real' versions.
|
|
9782
|
-
**/
|
|
9783
|
-
AutoGeneratedKeyType.Identity = new AutoGeneratedKeyType();
|
|
9784
|
-
/**
|
|
9785
|
-
This entity's key is generated by a KeyGenerator and is set by the backend database.
|
|
9786
|
-
Keys for new entities will be temporary until the entities are saved at which point the keys will
|
|
9787
|
-
be converted to their 'real' versions.
|
|
9788
|
-
**/
|
|
9789
|
-
AutoGeneratedKeyType.KeyGenerator = new AutoGeneratedKeyType();
|
|
9790
10171
|
AutoGeneratedKeyType.prototype._$typeName = "AutoGeneratedKeyType";
|
|
9791
10172
|
Error['x'] = AutoGeneratedKeyType.resolveSymbols();
|
|
9792
10173
|
let proto = Param.prototype;
|
|
@@ -9852,41 +10233,6 @@ function addProperties(entityType, propObj, ctor) {
|
|
|
9852
10233
|
@hidden
|
|
9853
10234
|
*/
|
|
9854
10235
|
class AbstractDataServiceAdapter {
|
|
9855
|
-
constructor() {
|
|
9856
|
-
/**
|
|
9857
|
-
Returns a constructor function for a "ChangeRequestInterceptor"
|
|
9858
|
-
that can tweak the saveBundle both as it is built and when it is completed
|
|
9859
|
-
by a concrete DataServiceAdapater.
|
|
9860
|
-
|
|
9861
|
-
Initialized with a default, no-op implementation that developers can replace with a
|
|
9862
|
-
substantive implementation that changes the individual entity change requests
|
|
9863
|
-
or aspects of the entire 'saveBundle' without having to write their own DataService adapters.
|
|
9864
|
-
> let adapter = breeze.config.getAdapterInstance('dataService');
|
|
9865
|
-
> adapter.changeRequestInterceptor = function (saveContext, saveBundle) {
|
|
9866
|
-
> this.getRequest = function (request, entity, index) {
|
|
9867
|
-
> // alter the request that the adapter prepared for this entity
|
|
9868
|
-
> // based on the entity, saveContext, and saveBundle
|
|
9869
|
-
> // e.g., add a custom header or prune the originalValuesMap
|
|
9870
|
-
> return request;
|
|
9871
|
-
> };
|
|
9872
|
-
> this.done = function (requests) {
|
|
9873
|
-
> // alter the array of requests representing the entire change-set
|
|
9874
|
-
> // based on the saveContext and saveBundle
|
|
9875
|
-
> };
|
|
9876
|
-
> }
|
|
9877
|
-
|
|
9878
|
-
@param saveContext - The BreezeJS "context" for the save operation.
|
|
9879
|
-
@param saveBundle - Contains the array of entities-to-be-saved (AKA, the entity change-set).
|
|
9880
|
-
@return Constructor for a "ChangeRequestInterceptor".
|
|
9881
|
-
**/
|
|
9882
|
-
this.changeRequestInterceptor = DefaultChangeRequestInterceptor;
|
|
9883
|
-
this.jsonResultsAdapter = new JsonResultsAdapter({
|
|
9884
|
-
name: "noop",
|
|
9885
|
-
visitNode: function ( /* node, mappingContext, nodeContext */) {
|
|
9886
|
-
return {};
|
|
9887
|
-
}
|
|
9888
|
-
});
|
|
9889
|
-
}
|
|
9890
10236
|
// TODO use interface
|
|
9891
10237
|
checkForRecomposition(interfaceInitializedArgs) {
|
|
9892
10238
|
if (interfaceInitializedArgs.interfaceName === "ajax" && interfaceInitializedArgs.isDefault) {
|
|
@@ -10052,6 +10398,33 @@ class AbstractDataServiceAdapter {
|
|
|
10052
10398
|
// The implementor should call _createChangeRequestInterceptor
|
|
10053
10399
|
throw new Error("Need a concrete implementation of _prepareSaveBundle");
|
|
10054
10400
|
}
|
|
10401
|
+
/**
|
|
10402
|
+
Returns a constructor function for a "ChangeRequestInterceptor"
|
|
10403
|
+
that can tweak the saveBundle both as it is built and when it is completed
|
|
10404
|
+
by a concrete DataServiceAdapater.
|
|
10405
|
+
|
|
10406
|
+
Initialized with a default, no-op implementation that developers can replace with a
|
|
10407
|
+
substantive implementation that changes the individual entity change requests
|
|
10408
|
+
or aspects of the entire 'saveBundle' without having to write their own DataService adapters.
|
|
10409
|
+
> let adapter = breeze.config.getAdapterInstance('dataService');
|
|
10410
|
+
> adapter.changeRequestInterceptor = function (saveContext, saveBundle) {
|
|
10411
|
+
> this.getRequest = function (request, entity, index) {
|
|
10412
|
+
> // alter the request that the adapter prepared for this entity
|
|
10413
|
+
> // based on the entity, saveContext, and saveBundle
|
|
10414
|
+
> // e.g., add a custom header or prune the originalValuesMap
|
|
10415
|
+
> return request;
|
|
10416
|
+
> };
|
|
10417
|
+
> this.done = function (requests) {
|
|
10418
|
+
> // alter the array of requests representing the entire change-set
|
|
10419
|
+
> // based on the saveContext and saveBundle
|
|
10420
|
+
> };
|
|
10421
|
+
> }
|
|
10422
|
+
|
|
10423
|
+
@param saveContext - The BreezeJS "context" for the save operation.
|
|
10424
|
+
@param saveBundle - Contains the array of entities-to-be-saved (AKA, the entity change-set).
|
|
10425
|
+
@return Constructor for a "ChangeRequestInterceptor".
|
|
10426
|
+
**/
|
|
10427
|
+
changeRequestInterceptor = DefaultChangeRequestInterceptor;
|
|
10055
10428
|
/** @hidden @internal */
|
|
10056
10429
|
_createChangeRequestInterceptor(saveContext, saveBundle) {
|
|
10057
10430
|
let adapter = saveContext.adapter;
|
|
@@ -10089,6 +10462,12 @@ class AbstractDataServiceAdapter {
|
|
|
10089
10462
|
"Likely did not or could not reach server. Is the server running?";
|
|
10090
10463
|
}
|
|
10091
10464
|
}
|
|
10465
|
+
jsonResultsAdapter = new JsonResultsAdapter({
|
|
10466
|
+
name: "noop",
|
|
10467
|
+
visitNode: function ( /* node, mappingContext, nodeContext */) {
|
|
10468
|
+
return {};
|
|
10469
|
+
}
|
|
10470
|
+
});
|
|
10092
10471
|
}
|
|
10093
10472
|
function handleHttpError(reject, httpResponse, messagePrefix) {
|
|
10094
10473
|
let err = createError(httpResponse);
|
|
@@ -10175,6 +10554,20 @@ A ValidationOptions instance is used to specify the conditions under which valid
|
|
|
10175
10554
|
|
|
10176
10555
|
*/
|
|
10177
10556
|
class ValidationOptions {
|
|
10557
|
+
/** @hidden @internal */
|
|
10558
|
+
_$typeName; // on proto
|
|
10559
|
+
/** Whether entity and property level validation should occur when entities are attached to the EntityManager
|
|
10560
|
+
other than via a query. (default = true) __Read Only__ */
|
|
10561
|
+
validateOnAttach;
|
|
10562
|
+
/** Whether entity and property level validation should occur before entities are saved.
|
|
10563
|
+
A failed validation will force the save to fail early. (default = true) __Read Only__ */
|
|
10564
|
+
validateOnSave;
|
|
10565
|
+
/** Whether entity and property level validation should occur after entities are queried from a remote server.
|
|
10566
|
+
(default = false) __Read Only__ **/
|
|
10567
|
+
validateOnQuery;
|
|
10568
|
+
/** Whether property level validation should occur after entities are modified.
|
|
10569
|
+
(default = true) __Read Only__ **/
|
|
10570
|
+
validateOnPropertyChange;
|
|
10178
10571
|
/**
|
|
10179
10572
|
ValidationOptions constructor
|
|
10180
10573
|
> var newVo = new ValidationOptions( { validateOnSave: false, validateOnAttach: false });
|
|
@@ -10183,7 +10576,7 @@ class ValidationOptions {
|
|
|
10183
10576
|
@param config - A configuration object.
|
|
10184
10577
|
**/
|
|
10185
10578
|
constructor(config) {
|
|
10186
|
-
updateWithConfig
|
|
10579
|
+
updateWithConfig(this, config);
|
|
10187
10580
|
}
|
|
10188
10581
|
/**
|
|
10189
10582
|
Returns a copy of this ValidationOptions with changes to the specified config properties.
|
|
@@ -10196,7 +10589,7 @@ class ValidationOptions {
|
|
|
10196
10589
|
if (!config)
|
|
10197
10590
|
return this;
|
|
10198
10591
|
let result = new ValidationOptions(this);
|
|
10199
|
-
updateWithConfig
|
|
10592
|
+
updateWithConfig(result, config);
|
|
10200
10593
|
return result;
|
|
10201
10594
|
}
|
|
10202
10595
|
/**
|
|
@@ -10209,18 +10602,18 @@ class ValidationOptions {
|
|
|
10209
10602
|
setAsDefault() {
|
|
10210
10603
|
return core.setAsDefault(this, ValidationOptions);
|
|
10211
10604
|
}
|
|
10605
|
+
/**
|
|
10606
|
+
The default instance for use whenever ValidationOptions are not specified.
|
|
10607
|
+
**/
|
|
10608
|
+
static defaultInstance = new ValidationOptions({
|
|
10609
|
+
validateOnAttach: true,
|
|
10610
|
+
validateOnSave: true,
|
|
10611
|
+
validateOnQuery: false,
|
|
10612
|
+
validateOnPropertyChange: true
|
|
10613
|
+
});
|
|
10212
10614
|
}
|
|
10213
|
-
/**
|
|
10214
|
-
The default instance for use whenever ValidationOptions are not specified.
|
|
10215
|
-
**/
|
|
10216
|
-
ValidationOptions.defaultInstance = new ValidationOptions({
|
|
10217
|
-
validateOnAttach: true,
|
|
10218
|
-
validateOnSave: true,
|
|
10219
|
-
validateOnQuery: false,
|
|
10220
|
-
validateOnPropertyChange: true
|
|
10221
|
-
});
|
|
10222
10615
|
ValidationOptions.prototype._$typeName = "ValidationOptions";
|
|
10223
|
-
function updateWithConfig
|
|
10616
|
+
function updateWithConfig(options, config) {
|
|
10224
10617
|
if (config) {
|
|
10225
10618
|
assertConfig(config)
|
|
10226
10619
|
.whereParam("validateOnAttach").isBoolean().isOptional()
|
|
@@ -10236,6 +10629,18 @@ function updateWithConfig$1(options, config) {
|
|
|
10236
10629
|
A SaveOptions instance is used to specify the 'options' under which a save will occur.
|
|
10237
10630
|
**/
|
|
10238
10631
|
class SaveOptions {
|
|
10632
|
+
/** @hidden @internal */
|
|
10633
|
+
_$typeName; // on proto
|
|
10634
|
+
/** Resource name to be used during the save - this defaults to "SaveChanges". __Read Only__ */
|
|
10635
|
+
resourceName;
|
|
10636
|
+
/** The DataService to be used for this save. __Read Only__ */
|
|
10637
|
+
dataService;
|
|
10638
|
+
/** Whether multiple saves can be in-flight at the same time. The default is false. __Read Only__ */
|
|
10639
|
+
allowConcurrentSaves;
|
|
10640
|
+
/** Free form value that will be sent to the server during the save. __Read Only__ */
|
|
10641
|
+
tag;
|
|
10642
|
+
/** The default value whenever SaveOptions are not specified. */
|
|
10643
|
+
static defaultInstance = new SaveOptions({ allowConcurrentSaves: false });
|
|
10239
10644
|
constructor(config) {
|
|
10240
10645
|
SaveOptions._updateWithConfig(this, config);
|
|
10241
10646
|
}
|
|
@@ -10266,14 +10671,14 @@ class SaveOptions {
|
|
|
10266
10671
|
return obj;
|
|
10267
10672
|
}
|
|
10268
10673
|
}
|
|
10269
|
-
/** The default value whenever SaveOptions are not specified. */
|
|
10270
|
-
SaveOptions.defaultInstance = new SaveOptions({ allowConcurrentSaves: false });
|
|
10271
10674
|
SaveOptions.prototype._$typeName = "SaveOptions";
|
|
10272
10675
|
|
|
10273
10676
|
/*
|
|
10274
10677
|
@class KeyGenerator
|
|
10275
10678
|
*/
|
|
10276
10679
|
class KeyGenerator {
|
|
10680
|
+
/** @hidden @internal */
|
|
10681
|
+
_tempIdMap;
|
|
10277
10682
|
constructor() {
|
|
10278
10683
|
// key is dataProperty.name + || + entityType.name, value is propEntry
|
|
10279
10684
|
// propEntry = { entityType, propertyName, keyMap }
|
|
@@ -10378,6 +10783,11 @@ config.registerType(KeyGenerator, "KeyGenerator");
|
|
|
10378
10783
|
|
|
10379
10784
|
/** @hidden @internal */
|
|
10380
10785
|
class EntityGroup {
|
|
10786
|
+
entityManager;
|
|
10787
|
+
entityType;
|
|
10788
|
+
_indexMap;
|
|
10789
|
+
_entities;
|
|
10790
|
+
_emptyIndexes;
|
|
10381
10791
|
constructor(entityManager, entityType) {
|
|
10382
10792
|
this.entityManager = entityManager;
|
|
10383
10793
|
this.entityType = entityType;
|
|
@@ -10565,8 +10975,19 @@ For use by breeze plugin authors only. The class is for use in building a [[IDat
|
|
|
10565
10975
|
@hidden
|
|
10566
10976
|
*/
|
|
10567
10977
|
class MappingContext {
|
|
10978
|
+
/** @hidden @internal */
|
|
10979
|
+
_$typeName; // on prototype
|
|
10980
|
+
rawValueFn = DataProperty.getRawValueFromServer; // think about passing this in later.
|
|
10981
|
+
dataService;
|
|
10982
|
+
query;
|
|
10983
|
+
entityManager;
|
|
10984
|
+
mergeOptions;
|
|
10985
|
+
adapter; // assigned in the AbstractDataServiceAdapter.
|
|
10986
|
+
refMap; // TODO
|
|
10987
|
+
deferredFns; // TODO
|
|
10988
|
+
jsonResultsAdapter;
|
|
10989
|
+
metadataStore;
|
|
10568
10990
|
constructor(config) {
|
|
10569
|
-
this.rawValueFn = DataProperty.getRawValueFromServer; // think about passing this in later.
|
|
10570
10991
|
core.extend(this, config, [
|
|
10571
10992
|
"query", "entityManager", "dataService", "mergeOptions"
|
|
10572
10993
|
]);
|
|
@@ -10789,7 +11210,7 @@ function mergeEntity(mc, node, meta) {
|
|
|
10789
11210
|
targetEntity.entityAspect.extraMetadata = meta.extraMetadata;
|
|
10790
11211
|
}
|
|
10791
11212
|
targetEntity.entityAspect.entityState = EntityState.Unchanged;
|
|
10792
|
-
clearOriginalValues
|
|
11213
|
+
clearOriginalValues(targetEntity);
|
|
10793
11214
|
// propertyName not specified because multiple props EntityChangedEventArgs
|
|
10794
11215
|
targetEntity.entityAspect.propertyChanged.publish({ entity: targetEntity, propertyName: null });
|
|
10795
11216
|
let action = isSaving ? EntityAction.MergeOnSave : EntityAction.MergeOnQuery;
|
|
@@ -10823,18 +11244,18 @@ function mergeEntity(mc, node, meta) {
|
|
|
10823
11244
|
return targetEntity;
|
|
10824
11245
|
}
|
|
10825
11246
|
// copied from entityAspect
|
|
10826
|
-
function clearOriginalValues
|
|
11247
|
+
function clearOriginalValues(target) {
|
|
10827
11248
|
let aspect = target.entityAspect || target.complexAspect;
|
|
10828
11249
|
aspect.originalValues = {};
|
|
10829
11250
|
let stype = target.entityType || target.complexType;
|
|
10830
11251
|
stype.complexProperties.forEach(function (cp) {
|
|
10831
11252
|
let cos = target.getProperty(cp.name);
|
|
10832
11253
|
if (cp.isScalar) {
|
|
10833
|
-
clearOriginalValues
|
|
11254
|
+
clearOriginalValues(cos);
|
|
10834
11255
|
}
|
|
10835
11256
|
else {
|
|
10836
11257
|
cos._acceptChanges();
|
|
10837
|
-
cos.forEach(clearOriginalValues
|
|
11258
|
+
cos.forEach(clearOriginalValues);
|
|
10838
11259
|
}
|
|
10839
11260
|
});
|
|
10840
11261
|
}
|
|
@@ -10966,10 +11387,8 @@ function updateRelatedEntityInCollection(mc, relatedEntity, relatedEntities, tar
|
|
|
10966
11387
|
/** @hidden @internal */
|
|
10967
11388
|
// Represents entities not yet attached to navigationProperties.
|
|
10968
11389
|
class UnattachedChildrenMap {
|
|
10969
|
-
|
|
10970
|
-
|
|
10971
|
-
this.map = {};
|
|
10972
|
-
}
|
|
11390
|
+
// key is EntityKey.toString(), value is array of { navigationProperty, children }
|
|
11391
|
+
map = {};
|
|
10973
11392
|
addChild(parentEntityKey, navigationProperty, child) {
|
|
10974
11393
|
let tuple = this.getTuple(parentEntityKey, navigationProperty);
|
|
10975
11394
|
if (!tuple) {
|
|
@@ -11024,6 +11443,100 @@ class UnattachedChildrenMap {
|
|
|
11024
11443
|
Instances of the EntityManager contain and manage collections of entities, either retrieved from a backend datastore or created on the client.
|
|
11025
11444
|
**/
|
|
11026
11445
|
class EntityManager {
|
|
11446
|
+
/** @hidden @internal */
|
|
11447
|
+
_$typeName; // actually defined on prototype
|
|
11448
|
+
/** The service name associated with this EntityManager. __Read Only__ **/
|
|
11449
|
+
serviceName;
|
|
11450
|
+
/** The DataService associated with this EntityManager. __Read Only__ **/
|
|
11451
|
+
dataService;
|
|
11452
|
+
/** The [[QueryOptions]] associated with this EntityManager. __Read Only__ **/
|
|
11453
|
+
queryOptions;
|
|
11454
|
+
/** The [[SaveOptions]] associated with this EntityManager. __Read Only__ **/
|
|
11455
|
+
saveOptions;
|
|
11456
|
+
/** The [[ValidationOptions]] associated with this EntityManager. __Read Only__ **/
|
|
11457
|
+
validationOptions;
|
|
11458
|
+
/** The [[KeyGenerator]] associated with this EntityManager. __Read Only__ **/
|
|
11459
|
+
keyGenerator;
|
|
11460
|
+
/** The [[KeyGenerator]] constructor associated with this EntityManager. __Read Only__ **/
|
|
11461
|
+
keyGeneratorCtor; // TODO: review this
|
|
11462
|
+
/** The [[MetadataStore]] associated with this EntityManager. __Read Only__ **/
|
|
11463
|
+
metadataStore;
|
|
11464
|
+
isLoading;
|
|
11465
|
+
isRejectingChanges;
|
|
11466
|
+
// events
|
|
11467
|
+
/**
|
|
11468
|
+
A [[BreezeEvent]] that fires whenever a change to any entity in this EntityManager occurs. __Read Only__
|
|
11469
|
+
|
|
11470
|
+
@eventArgs -
|
|
11471
|
+
- entityAction - The [[EntityAction]] that occured.
|
|
11472
|
+
- entity - The entity that changed. If this is null, then all entities in the entityManager were affected.
|
|
11473
|
+
- args - Additional information about this event. This will differ based on the entityAction.
|
|
11474
|
+
|
|
11475
|
+
> let em = new EntityManager( {serviceName: "breeze/NorthwindIBModel" });
|
|
11476
|
+
> em.entityChanged.subscribe(function(changeArgs) {
|
|
11477
|
+
> // This code will be executed any time any entity within the entityManager
|
|
11478
|
+
> // is added, modified, deleted or detached for any reason.
|
|
11479
|
+
> let action = changeArgs.entityAction;
|
|
11480
|
+
> let entity = changeArgs.entity;
|
|
11481
|
+
> // .. do something to this entity when it is changed.
|
|
11482
|
+
> });
|
|
11483
|
+
> });
|
|
11484
|
+
@event
|
|
11485
|
+
**/
|
|
11486
|
+
entityChanged;
|
|
11487
|
+
/**
|
|
11488
|
+
An [[BreezeEvent]] that fires whenever validationErrors change for any entity in this EntityManager. __Read Only__
|
|
11489
|
+
@eventArgs -
|
|
11490
|
+
- entity - The entity on which the validation errors have been added or removed.
|
|
11491
|
+
- added - An array containing any newly added [[ValidationError]]s
|
|
11492
|
+
- removed - An array containing any newly removed [[ValidationError]]s. This is those errors that have been 'fixed'
|
|
11493
|
+
|
|
11494
|
+
> let em = new EntityManager( {serviceName: "breeze/NorthwindIBModel" });
|
|
11495
|
+
> em.validationErrorsChanged.subscribe(function(changeArgs) {
|
|
11496
|
+
> // This code will be executed any time any entity within the entityManager experiences a change to its validationErrors collection.
|
|
11497
|
+
> function (validationChangeArgs) {
|
|
11498
|
+
> let entity == validationChangeArgs.entity;
|
|
11499
|
+
> let errorsAdded = validationChangeArgs.added;
|
|
11500
|
+
> let errorsCleared = validationChangeArgs.removed;
|
|
11501
|
+
> // ... do something interesting with the order.
|
|
11502
|
+
> });
|
|
11503
|
+
> });
|
|
11504
|
+
> });
|
|
11505
|
+
@event
|
|
11506
|
+
**/
|
|
11507
|
+
validationErrorsChanged;
|
|
11508
|
+
/**
|
|
11509
|
+
A [[BreezeEvent]] that fires whenever an EntityManager transitions to or from having changes. __Read Only__
|
|
11510
|
+
@eventArgs -
|
|
11511
|
+
- entityManager - The EntityManager whose 'hasChanges' status has changed.
|
|
11512
|
+
- hasChanges - Whether or not this EntityManager has changes.
|
|
11513
|
+
|
|
11514
|
+
> let em = new EntityManager( {serviceName: "breeze/NorthwindIBModel" });
|
|
11515
|
+
> em.hasChangesChanged.subscribe(function(args) {
|
|
11516
|
+
> let hasChangesChanged = args.hasChanges;
|
|
11517
|
+
> let entityManager = args.entityManager;
|
|
11518
|
+
> });
|
|
11519
|
+
> });
|
|
11520
|
+
@event
|
|
11521
|
+
**/
|
|
11522
|
+
hasChangesChanged;
|
|
11523
|
+
/** @hidden @internal */
|
|
11524
|
+
_pendingPubs; // TODO: refine later
|
|
11525
|
+
/** @hidden @internal */
|
|
11526
|
+
_hasChangesAction; // TODO refine later
|
|
11527
|
+
/** @hidden @internal */
|
|
11528
|
+
_hasChanges;
|
|
11529
|
+
/** @hidden @internal */
|
|
11530
|
+
_entityGroupMap;
|
|
11531
|
+
/** @hidden @internal */
|
|
11532
|
+
_unattachedChildrenMap;
|
|
11533
|
+
/** @hidden @internal */
|
|
11534
|
+
_inKeyFixup;
|
|
11535
|
+
helper = {
|
|
11536
|
+
unwrapInstance: unwrapInstance,
|
|
11537
|
+
unwrapOriginalValues: unwrapOriginalValues,
|
|
11538
|
+
unwrapChangedValues: unwrapChangedValues
|
|
11539
|
+
};
|
|
11027
11540
|
/**
|
|
11028
11541
|
EntityManager constructor.
|
|
11029
11542
|
|
|
@@ -11062,11 +11575,6 @@ class EntityManager {
|
|
|
11062
11575
|
@param emConfig - Configuration settings or a service name.
|
|
11063
11576
|
**/
|
|
11064
11577
|
constructor(emConfig) {
|
|
11065
|
-
this.helper = {
|
|
11066
|
-
unwrapInstance: unwrapInstance,
|
|
11067
|
-
unwrapOriginalValues: unwrapOriginalValues,
|
|
11068
|
-
unwrapChangedValues: unwrapChangedValues
|
|
11069
|
-
};
|
|
11070
11578
|
if (arguments.length > 1) {
|
|
11071
11579
|
throw new Error("The EntityManager ctor has a single optional argument that is either a 'serviceName' or a configuration object.");
|
|
11072
11580
|
}
|
|
@@ -13096,12 +13604,10 @@ function getSerializerFn(stype) {
|
|
|
13096
13604
|
|
|
13097
13605
|
/** Registers adapters used by Breeze */
|
|
13098
13606
|
class InterfaceRegistry {
|
|
13099
|
-
|
|
13100
|
-
|
|
13101
|
-
|
|
13102
|
-
|
|
13103
|
-
this.uriBuilder = new InterfaceDef("uriBuilder");
|
|
13104
|
-
}
|
|
13607
|
+
ajax = new InterfaceDef("ajax");
|
|
13608
|
+
modelLibrary = new InterfaceDef("modelLibrary");
|
|
13609
|
+
dataService = new InterfaceDef("dataService");
|
|
13610
|
+
uriBuilder = new InterfaceDef("uriBuilder");
|
|
13105
13611
|
}
|
|
13106
13612
|
config.interfaceRegistry = new InterfaceRegistry();
|
|
13107
13613
|
config._interfaceRegistry = config.interfaceRegistry;
|
|
@@ -13132,119 +13638,118 @@ config.initializeAdapterInstances = function (irConfig) {
|
|
|
13132
13638
|
return core.objectMap(config, this.initializeAdapterInstance);
|
|
13133
13639
|
};
|
|
13134
13640
|
|
|
13135
|
-
const ɵ0$3 = function (...args) {
|
|
13136
|
-
if (this._inProgress) {
|
|
13137
|
-
return -1;
|
|
13138
|
-
}
|
|
13139
|
-
let goodAdds = this._getGoodAdds(args);
|
|
13140
|
-
if (!goodAdds.length) {
|
|
13141
|
-
return this.length;
|
|
13142
|
-
}
|
|
13143
|
-
this._beforeChange();
|
|
13144
|
-
let result;
|
|
13145
|
-
let objPrototype = Object.getPrototypeOf(this);
|
|
13146
|
-
if (objPrototype.push) {
|
|
13147
|
-
result = objPrototype.push.apply(this, goodAdds);
|
|
13148
|
-
}
|
|
13149
|
-
else {
|
|
13150
|
-
result = Array.prototype.push.apply(this, goodAdds);
|
|
13151
|
-
}
|
|
13152
|
-
processAdds(this, goodAdds);
|
|
13153
|
-
return result;
|
|
13154
|
-
}, ɵ1$2 = function (...args) {
|
|
13155
|
-
if (this._inProgress) {
|
|
13156
|
-
return -1;
|
|
13157
|
-
}
|
|
13158
|
-
let goodAdds = args;
|
|
13159
|
-
this._beforeChange();
|
|
13160
|
-
let result;
|
|
13161
|
-
let objPrototype = Object.getPrototypeOf(this);
|
|
13162
|
-
if (objPrototype.push) {
|
|
13163
|
-
result = objPrototype.push.apply(this, goodAdds);
|
|
13164
|
-
}
|
|
13165
|
-
else {
|
|
13166
|
-
result = Array.prototype.push.apply(this, goodAdds);
|
|
13167
|
-
}
|
|
13168
|
-
processAdds(this, goodAdds);
|
|
13169
|
-
return result;
|
|
13170
|
-
}, ɵ2$1 = function (...args) {
|
|
13171
|
-
let goodAdds = this._getGoodAdds(args);
|
|
13172
|
-
if (!goodAdds.length) {
|
|
13173
|
-
return this.length;
|
|
13174
|
-
}
|
|
13175
|
-
this._beforeChange();
|
|
13176
|
-
let result;
|
|
13177
|
-
let objPrototype = Object.getPrototypeOf(this);
|
|
13178
|
-
if (objPrototype.unshift) {
|
|
13179
|
-
result = objPrototype.unshift.apply(this, goodAdds);
|
|
13180
|
-
}
|
|
13181
|
-
else {
|
|
13182
|
-
result = Array.prototype.unshift.apply(this, goodAdds);
|
|
13183
|
-
}
|
|
13184
|
-
processAdds(this, goodAdds);
|
|
13185
|
-
return result;
|
|
13186
|
-
}, ɵ3$1 = function () {
|
|
13187
|
-
this._beforeChange();
|
|
13188
|
-
let result;
|
|
13189
|
-
let objPrototype = Object.getPrototypeOf(this);
|
|
13190
|
-
if (objPrototype.pop) {
|
|
13191
|
-
result = objPrototype.pop.apply(this);
|
|
13192
|
-
}
|
|
13193
|
-
else {
|
|
13194
|
-
result = Array.prototype.pop.apply(this);
|
|
13195
|
-
}
|
|
13196
|
-
processRemoves(this, [result]);
|
|
13197
|
-
return result;
|
|
13198
|
-
}, ɵ4$1 = function () {
|
|
13199
|
-
this._beforeChange();
|
|
13200
|
-
let result;
|
|
13201
|
-
let objPrototype = Object.getPrototypeOf(this);
|
|
13202
|
-
if (objPrototype.shift) {
|
|
13203
|
-
result = objPrototype.shift.apply(this);
|
|
13204
|
-
}
|
|
13205
|
-
else {
|
|
13206
|
-
result = Array.prototype.shift.apply(this);
|
|
13207
|
-
}
|
|
13208
|
-
processRemoves(this, [result]);
|
|
13209
|
-
return result;
|
|
13210
|
-
}, ɵ5$1 = function (...args) {
|
|
13211
|
-
let goodAdds = this._getGoodAdds(core.arraySlice(args, 2));
|
|
13212
|
-
let newArgs = core.arraySlice(args, 0, 2).concat(goodAdds);
|
|
13213
|
-
this._beforeChange();
|
|
13214
|
-
let result;
|
|
13215
|
-
let objPrototype = Object.getPrototypeOf(this);
|
|
13216
|
-
if (objPrototype.splice) {
|
|
13217
|
-
result = objPrototype.splice.apply(this, newArgs);
|
|
13218
|
-
}
|
|
13219
|
-
else {
|
|
13220
|
-
result = Array.prototype.splice.apply(this, newArgs);
|
|
13221
|
-
}
|
|
13222
|
-
processRemoves(this, result);
|
|
13223
|
-
if (goodAdds.length) {
|
|
13224
|
-
processAdds(this, goodAdds);
|
|
13225
|
-
}
|
|
13226
|
-
return result;
|
|
13227
|
-
}, ɵ6$1 = function () {
|
|
13228
|
-
return this.parent.entityAspect || this.parent.complexAspect.getEntityAspect();
|
|
13229
|
-
}, ɵ7$1 = function () {
|
|
13230
|
-
return this.getEntityAspect();
|
|
13231
|
-
}, ɵ8$1 = function () {
|
|
13232
|
-
let em = this.getEntityAspect().entityManager;
|
|
13233
|
-
return em && em._pendingPubs;
|
|
13234
|
-
}, ɵ9$1 = function () {
|
|
13235
|
-
// default is to do nothing
|
|
13236
|
-
};
|
|
13237
13641
|
let mixin = {
|
|
13238
|
-
push:
|
|
13239
|
-
|
|
13240
|
-
|
|
13241
|
-
|
|
13242
|
-
|
|
13243
|
-
|
|
13244
|
-
|
|
13245
|
-
|
|
13246
|
-
|
|
13247
|
-
|
|
13642
|
+
push: function (...args) {
|
|
13643
|
+
if (this._inProgress) {
|
|
13644
|
+
return -1;
|
|
13645
|
+
}
|
|
13646
|
+
let goodAdds = this._getGoodAdds(args);
|
|
13647
|
+
if (!goodAdds.length) {
|
|
13648
|
+
return this.length;
|
|
13649
|
+
}
|
|
13650
|
+
this._beforeChange();
|
|
13651
|
+
let result;
|
|
13652
|
+
let objPrototype = Object.getPrototypeOf(this);
|
|
13653
|
+
if (objPrototype.push) {
|
|
13654
|
+
result = objPrototype.push.apply(this, goodAdds);
|
|
13655
|
+
}
|
|
13656
|
+
else {
|
|
13657
|
+
result = Array.prototype.push.apply(this, goodAdds);
|
|
13658
|
+
}
|
|
13659
|
+
processAdds$2(this, goodAdds);
|
|
13660
|
+
return result;
|
|
13661
|
+
},
|
|
13662
|
+
_push: function (...args) {
|
|
13663
|
+
if (this._inProgress) {
|
|
13664
|
+
return -1;
|
|
13665
|
+
}
|
|
13666
|
+
let goodAdds = args;
|
|
13667
|
+
this._beforeChange();
|
|
13668
|
+
let result;
|
|
13669
|
+
let objPrototype = Object.getPrototypeOf(this);
|
|
13670
|
+
if (objPrototype.push) {
|
|
13671
|
+
result = objPrototype.push.apply(this, goodAdds);
|
|
13672
|
+
}
|
|
13673
|
+
else {
|
|
13674
|
+
result = Array.prototype.push.apply(this, goodAdds);
|
|
13675
|
+
}
|
|
13676
|
+
processAdds$2(this, goodAdds);
|
|
13677
|
+
return result;
|
|
13678
|
+
},
|
|
13679
|
+
unshift: function (...args) {
|
|
13680
|
+
let goodAdds = this._getGoodAdds(args);
|
|
13681
|
+
if (!goodAdds.length) {
|
|
13682
|
+
return this.length;
|
|
13683
|
+
}
|
|
13684
|
+
this._beforeChange();
|
|
13685
|
+
let result;
|
|
13686
|
+
let objPrototype = Object.getPrototypeOf(this);
|
|
13687
|
+
if (objPrototype.unshift) {
|
|
13688
|
+
result = objPrototype.unshift.apply(this, goodAdds);
|
|
13689
|
+
}
|
|
13690
|
+
else {
|
|
13691
|
+
result = Array.prototype.unshift.apply(this, goodAdds);
|
|
13692
|
+
}
|
|
13693
|
+
processAdds$2(this, goodAdds);
|
|
13694
|
+
return result;
|
|
13695
|
+
},
|
|
13696
|
+
pop: function () {
|
|
13697
|
+
this._beforeChange();
|
|
13698
|
+
let result;
|
|
13699
|
+
let objPrototype = Object.getPrototypeOf(this);
|
|
13700
|
+
if (objPrototype.pop) {
|
|
13701
|
+
result = objPrototype.pop.apply(this);
|
|
13702
|
+
}
|
|
13703
|
+
else {
|
|
13704
|
+
result = Array.prototype.pop.apply(this);
|
|
13705
|
+
}
|
|
13706
|
+
processRemoves$2(this, [result]);
|
|
13707
|
+
return result;
|
|
13708
|
+
},
|
|
13709
|
+
shift: function () {
|
|
13710
|
+
this._beforeChange();
|
|
13711
|
+
let result;
|
|
13712
|
+
let objPrototype = Object.getPrototypeOf(this);
|
|
13713
|
+
if (objPrototype.shift) {
|
|
13714
|
+
result = objPrototype.shift.apply(this);
|
|
13715
|
+
}
|
|
13716
|
+
else {
|
|
13717
|
+
result = Array.prototype.shift.apply(this);
|
|
13718
|
+
}
|
|
13719
|
+
processRemoves$2(this, [result]);
|
|
13720
|
+
return result;
|
|
13721
|
+
},
|
|
13722
|
+
splice: function (...args) {
|
|
13723
|
+
let goodAdds = this._getGoodAdds(core.arraySlice(args, 2));
|
|
13724
|
+
let newArgs = core.arraySlice(args, 0, 2).concat(goodAdds);
|
|
13725
|
+
this._beforeChange();
|
|
13726
|
+
let result;
|
|
13727
|
+
let objPrototype = Object.getPrototypeOf(this);
|
|
13728
|
+
if (objPrototype.splice) {
|
|
13729
|
+
result = objPrototype.splice.apply(this, newArgs);
|
|
13730
|
+
}
|
|
13731
|
+
else {
|
|
13732
|
+
result = Array.prototype.splice.apply(this, newArgs);
|
|
13733
|
+
}
|
|
13734
|
+
processRemoves$2(this, result);
|
|
13735
|
+
if (goodAdds.length) {
|
|
13736
|
+
processAdds$2(this, goodAdds);
|
|
13737
|
+
}
|
|
13738
|
+
return result;
|
|
13739
|
+
},
|
|
13740
|
+
getEntityAspect: function () {
|
|
13741
|
+
return this.parent.entityAspect || this.parent.complexAspect.getEntityAspect();
|
|
13742
|
+
},
|
|
13743
|
+
_getEventParent: function () {
|
|
13744
|
+
return this.getEntityAspect();
|
|
13745
|
+
},
|
|
13746
|
+
_getPendingPubs: function () {
|
|
13747
|
+
let em = this.getEntityAspect().entityManager;
|
|
13748
|
+
return em && em._pendingPubs;
|
|
13749
|
+
},
|
|
13750
|
+
_beforeChange: function () {
|
|
13751
|
+
// default is to do nothing
|
|
13752
|
+
}
|
|
13248
13753
|
};
|
|
13249
13754
|
function updateEntityState(obsArray) {
|
|
13250
13755
|
let entityAspect = obsArray.getEntityAspect();
|
|
@@ -13277,14 +13782,14 @@ function initializeParent(obsArray, parent, parentProperty) {
|
|
|
13277
13782
|
obsArray.parent = parent;
|
|
13278
13783
|
obsArray.parentProperty = parentProperty;
|
|
13279
13784
|
}
|
|
13280
|
-
function processAdds(obsArray, adds) {
|
|
13785
|
+
function processAdds$2(obsArray, adds) {
|
|
13281
13786
|
obsArray._processAdds(adds);
|
|
13282
13787
|
// this is referencing the name of the method on the complexArray not the name of the event
|
|
13283
13788
|
//var args = { added: adds };
|
|
13284
13789
|
//args[obsArray._typeName] = obsArray;
|
|
13285
13790
|
publish(obsArray, "arrayChanged", { array: obsArray, added: adds });
|
|
13286
13791
|
}
|
|
13287
|
-
function processRemoves(obsArray, removes) {
|
|
13792
|
+
function processRemoves$2(obsArray, removes) {
|
|
13288
13793
|
obsArray._processRemoves(removes);
|
|
13289
13794
|
// this is referencing the name of the method on the array not the name of the event
|
|
13290
13795
|
publish(obsArray, "arrayChanged", { array: obsArray, removed: removes });
|
|
@@ -13315,23 +13820,6 @@ const observableArray = {
|
|
|
13315
13820
|
initializeParent: initializeParent
|
|
13316
13821
|
};
|
|
13317
13822
|
|
|
13318
|
-
const ɵ0$4 = function (callback, errorCallback) {
|
|
13319
|
-
let parent = this.parentEntity;
|
|
13320
|
-
let query = EntityQuery.fromEntityNavigation(this.parentEntity, this.navigationProperty);
|
|
13321
|
-
let em = parent.entityAspect.entityManager;
|
|
13322
|
-
return em.executeQuery(query, callback, errorCallback);
|
|
13323
|
-
}, ɵ1$3 = function () {
|
|
13324
|
-
return this.parentEntity.entityAspect;
|
|
13325
|
-
}, ɵ2$2 = function () {
|
|
13326
|
-
let em = this.parentEntity.entityAspect.entityManager;
|
|
13327
|
-
return em && em._pendingPubs;
|
|
13328
|
-
}, ɵ3$2 = function (adds) {
|
|
13329
|
-
return getGoodAdds(this, adds);
|
|
13330
|
-
}, ɵ4$2 = function (adds) {
|
|
13331
|
-
processAdds$1(this, adds);
|
|
13332
|
-
}, ɵ5$2 = function (removes) {
|
|
13333
|
-
processRemoves$1(this, removes);
|
|
13334
|
-
};
|
|
13335
13823
|
let relationArrayMixin = {
|
|
13336
13824
|
/**
|
|
13337
13825
|
Relation arrays are not actually classes, they are objects that mimic arrays. A relation array is collection of
|
|
@@ -13368,15 +13856,31 @@ let relationArrayMixin = {
|
|
|
13368
13856
|
@param [errorCallback] {Function}
|
|
13369
13857
|
@return {Promise}
|
|
13370
13858
|
**/
|
|
13371
|
-
load:
|
|
13372
|
-
|
|
13373
|
-
|
|
13859
|
+
load: function (callback, errorCallback) {
|
|
13860
|
+
let parent = this.parentEntity;
|
|
13861
|
+
let query = EntityQuery.fromEntityNavigation(this.parentEntity, this.navigationProperty);
|
|
13862
|
+
let em = parent.entityAspect.entityManager;
|
|
13863
|
+
return em.executeQuery(query, callback, errorCallback);
|
|
13864
|
+
},
|
|
13865
|
+
_getEventParent: function () {
|
|
13866
|
+
return this.parentEntity.entityAspect;
|
|
13867
|
+
},
|
|
13868
|
+
_getPendingPubs: function () {
|
|
13869
|
+
let em = this.parentEntity.entityAspect.entityManager;
|
|
13870
|
+
return em && em._pendingPubs;
|
|
13871
|
+
},
|
|
13374
13872
|
// virtual impls
|
|
13375
|
-
_getGoodAdds:
|
|
13376
|
-
|
|
13377
|
-
|
|
13873
|
+
_getGoodAdds: function (adds) {
|
|
13874
|
+
return getGoodAdds$1(this, adds);
|
|
13875
|
+
},
|
|
13876
|
+
_processAdds: function (adds) {
|
|
13877
|
+
processAdds$1(this, adds);
|
|
13878
|
+
},
|
|
13879
|
+
_processRemoves: function (removes) {
|
|
13880
|
+
processRemoves$1(this, removes);
|
|
13881
|
+
}
|
|
13378
13882
|
};
|
|
13379
|
-
function getGoodAdds(relationArray, adds) {
|
|
13883
|
+
function getGoodAdds$1(relationArray, adds) {
|
|
13380
13884
|
let goodAdds = checkForDups(relationArray, adds);
|
|
13381
13885
|
if (!goodAdds.length) {
|
|
13382
13886
|
return goodAdds;
|
|
@@ -13484,28 +13988,6 @@ function makeRelationArray(arr, parentEntity, navigationProperty) {
|
|
|
13484
13988
|
return core.extend(arrX, relationArrayMixin);
|
|
13485
13989
|
}
|
|
13486
13990
|
|
|
13487
|
-
const ɵ0$5 = function (adds) {
|
|
13488
|
-
return getGoodAdds$1(this, adds);
|
|
13489
|
-
}, ɵ1$4 = function () {
|
|
13490
|
-
observableArray.updateEntityState(this);
|
|
13491
|
-
}, ɵ2$3 = function (adds) {
|
|
13492
|
-
processAdds$2(this, adds);
|
|
13493
|
-
}, ɵ3$3 = function (removes) {
|
|
13494
|
-
processRemoves$2(this, removes);
|
|
13495
|
-
}, ɵ4$3 = function () {
|
|
13496
|
-
if (!this._origValues)
|
|
13497
|
-
return;
|
|
13498
|
-
let that = this;
|
|
13499
|
-
this.forEach(function (co) {
|
|
13500
|
-
clearAspect(co, that);
|
|
13501
|
-
});
|
|
13502
|
-
this.length = 0;
|
|
13503
|
-
this._origValues.forEach(function (co) {
|
|
13504
|
-
that.push(co);
|
|
13505
|
-
});
|
|
13506
|
-
}, ɵ5$3 = function () {
|
|
13507
|
-
this._origValues = null;
|
|
13508
|
-
};
|
|
13509
13991
|
let complexArrayMixin = {
|
|
13510
13992
|
// complexArray will have the following props
|
|
13511
13993
|
// parent
|
|
@@ -13540,22 +14022,43 @@ let complexArrayMixin = {
|
|
|
13540
14022
|
@readOnly
|
|
13541
14023
|
**/
|
|
13542
14024
|
// virtual impls
|
|
13543
|
-
_getGoodAdds:
|
|
13544
|
-
|
|
13545
|
-
|
|
13546
|
-
|
|
13547
|
-
|
|
13548
|
-
|
|
14025
|
+
_getGoodAdds: function (adds) {
|
|
14026
|
+
return getGoodAdds(this, adds);
|
|
14027
|
+
},
|
|
14028
|
+
_beforeChange: function () {
|
|
14029
|
+
observableArray.updateEntityState(this);
|
|
14030
|
+
},
|
|
14031
|
+
_processAdds: function (adds) {
|
|
14032
|
+
processAdds(this, adds);
|
|
14033
|
+
},
|
|
14034
|
+
_processRemoves: function (removes) {
|
|
14035
|
+
processRemoves(this, removes);
|
|
14036
|
+
},
|
|
14037
|
+
_rejectChanges: function () {
|
|
14038
|
+
if (!this._origValues)
|
|
14039
|
+
return;
|
|
14040
|
+
let that = this;
|
|
14041
|
+
this.forEach(function (co) {
|
|
14042
|
+
clearAspect(co, that);
|
|
14043
|
+
});
|
|
14044
|
+
this.length = 0;
|
|
14045
|
+
this._origValues.forEach(function (co) {
|
|
14046
|
+
that.push(co);
|
|
14047
|
+
});
|
|
14048
|
+
},
|
|
14049
|
+
_acceptChanges: function () {
|
|
14050
|
+
this._origValues = null;
|
|
14051
|
+
}
|
|
13549
14052
|
};
|
|
13550
14053
|
// local functions
|
|
13551
|
-
function getGoodAdds
|
|
14054
|
+
function getGoodAdds(complexArray, adds) {
|
|
13552
14055
|
// remove any that are already added here
|
|
13553
14056
|
return adds.filter(function (a) {
|
|
13554
14057
|
// return a.parent !== complexArray.parent; // TODO: check if this is actually a bug in original breezejs ???
|
|
13555
14058
|
return a.complexAspect == null || a.complexAspect.parent !== complexArray.parent;
|
|
13556
14059
|
});
|
|
13557
14060
|
}
|
|
13558
|
-
function processAdds
|
|
14061
|
+
function processAdds(complexArray, adds) {
|
|
13559
14062
|
adds.forEach(function (a) {
|
|
13560
14063
|
// if (a.parent != null) { // TODO: check if this is actually a bug in original breezejs ???
|
|
13561
14064
|
if (a.complexAspect && a.complexAspect.parent != null) {
|
|
@@ -13564,7 +14067,7 @@ function processAdds$2(complexArray, adds) {
|
|
|
13564
14067
|
setAspect(a, complexArray);
|
|
13565
14068
|
});
|
|
13566
14069
|
}
|
|
13567
|
-
function processRemoves
|
|
14070
|
+
function processRemoves(complexArray, removes) {
|
|
13568
14071
|
removes.forEach(function (a) {
|
|
13569
14072
|
clearAspect(a, complexArray);
|
|
13570
14073
|
});
|
|
@@ -13599,28 +14102,6 @@ function makeComplexArray(arr, parent, parentProperty) {
|
|
|
13599
14102
|
return core.extend(arrX, complexArrayMixin);
|
|
13600
14103
|
}
|
|
13601
14104
|
|
|
13602
|
-
const ɵ0$6 = function (adds) {
|
|
13603
|
-
return adds;
|
|
13604
|
-
}, ɵ1$5 = function () {
|
|
13605
|
-
let entityAspect = this.getEntityAspect();
|
|
13606
|
-
if (entityAspect.entityState.isUnchanged()) {
|
|
13607
|
-
entityAspect.setModified();
|
|
13608
|
-
}
|
|
13609
|
-
if (entityAspect.entityState.isModified() && !this._origValues) {
|
|
13610
|
-
this._origValues = this.slice(0);
|
|
13611
|
-
}
|
|
13612
|
-
}, ɵ2$4 = function (adds) {
|
|
13613
|
-
// nothing needed
|
|
13614
|
-
}, ɵ3$4 = function (removes) {
|
|
13615
|
-
// nothing needed;
|
|
13616
|
-
}, ɵ4$4 = function () {
|
|
13617
|
-
if (!this._origValues)
|
|
13618
|
-
return;
|
|
13619
|
-
this.length = 0;
|
|
13620
|
-
Array.prototype.push.apply(this, this._origValues);
|
|
13621
|
-
}, ɵ5$4 = function () {
|
|
13622
|
-
this._origValues = null;
|
|
13623
|
-
};
|
|
13624
14105
|
// TODO: mixin impl is not very typesafe
|
|
13625
14106
|
// Not needed
|
|
13626
14107
|
// interface IPrimitiveArray extends IObservableArray {
|
|
@@ -13662,12 +14143,33 @@ let primitiveArrayMixin = {
|
|
|
13662
14143
|
@readOnly
|
|
13663
14144
|
**/
|
|
13664
14145
|
// virtual impls
|
|
13665
|
-
_getGoodAdds:
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
|
|
14146
|
+
_getGoodAdds: function (adds) {
|
|
14147
|
+
return adds;
|
|
14148
|
+
},
|
|
14149
|
+
_beforeChange: function () {
|
|
14150
|
+
let entityAspect = this.getEntityAspect();
|
|
14151
|
+
if (entityAspect.entityState.isUnchanged()) {
|
|
14152
|
+
entityAspect.setModified();
|
|
14153
|
+
}
|
|
14154
|
+
if (entityAspect.entityState.isModified() && !this._origValues) {
|
|
14155
|
+
this._origValues = this.slice(0);
|
|
14156
|
+
}
|
|
14157
|
+
},
|
|
14158
|
+
_processAdds: function (adds) {
|
|
14159
|
+
// nothing needed
|
|
14160
|
+
},
|
|
14161
|
+
_processRemoves: function (removes) {
|
|
14162
|
+
// nothing needed;
|
|
14163
|
+
},
|
|
14164
|
+
_rejectChanges: function () {
|
|
14165
|
+
if (!this._origValues)
|
|
14166
|
+
return;
|
|
14167
|
+
this.length = 0;
|
|
14168
|
+
Array.prototype.push.apply(this, this._origValues);
|
|
14169
|
+
},
|
|
14170
|
+
_acceptChanges: function () {
|
|
14171
|
+
this._origValues = null;
|
|
14172
|
+
}
|
|
13671
14173
|
};
|
|
13672
14174
|
// local functions
|
|
13673
14175
|
/** For use by breeze plugin authors only. The class is for use in building a [[IModelLibraryAdapter]] implementation.
|
|
@@ -13742,5 +14244,5 @@ if (win) {
|
|
|
13742
14244
|
* Generated bundle index. Do not edit.
|
|
13743
14245
|
*/
|
|
13744
14246
|
|
|
13745
|
-
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
|
|
13746
|
-
//# sourceMappingURL=breeze-client.
|
|
14247
|
+
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 };
|
|
14248
|
+
//# sourceMappingURL=breeze-client.mjs.map
|