breeze-client 2.1.5 → 2.1.6

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.
Files changed (65) hide show
  1. package/adapter-data-service-odata/adapter-data-service-odata.d.ts +0 -1
  2. package/breeze-client.metadata.json +1 -1
  3. package/bundles/breeze-client-adapter-data-service-odata.umd.js +4 -0
  4. package/bundles/breeze-client-adapter-data-service-odata.umd.js.map +1 -1
  5. package/bundles/breeze-client-adapter-data-service-odata.umd.min.js +1 -1
  6. package/bundles/breeze-client-adapter-data-service-odata.umd.min.js.map +1 -1
  7. package/bundles/breeze-client-adapter-data-service-webapi.umd.js +8 -1
  8. package/bundles/breeze-client-adapter-data-service-webapi.umd.js.map +1 -1
  9. package/bundles/breeze-client-adapter-data-service-webapi.umd.min.js +1 -1
  10. package/bundles/breeze-client-adapter-data-service-webapi.umd.min.js.map +1 -1
  11. package/bundles/breeze-client.umd.js +103 -20
  12. package/bundles/breeze-client.umd.js.map +1 -1
  13. package/bundles/breeze-client.umd.min.js +1 -1
  14. package/bundles/breeze-client.umd.min.js.map +1 -1
  15. package/esm2015/adapter-data-service-odata/adapter-data-service-odata.js +5 -1
  16. package/esm2015/adapter-data-service-webapi/adapter-data-service-webapi.js +9 -2
  17. package/esm2015/src/abstract-data-service-adapter.js +1 -1
  18. package/esm2015/src/core.js +14 -9
  19. package/esm2015/src/data-type.js +60 -1
  20. package/esm2015/src/entity-action.js +1 -1
  21. package/esm2015/src/entity-aspect.js +6 -8
  22. package/esm2015/src/entity-manager.js +1 -1
  23. package/esm2015/src/entity-metadata.js +1 -1
  24. package/esm2015/src/entity-query.js +1 -1
  25. package/esm2015/src/entity-state.js +9 -1
  26. package/esm2015/src/enum.js +1 -1
  27. package/esm2015/src/key-generator.js +1 -1
  28. package/esm2015/src/mapping-context.js +9 -3
  29. package/esm2015/src/predicate.js +12 -5
  30. package/esm5/adapter-data-service-odata/adapter-data-service-odata.js +5 -1
  31. package/esm5/adapter-data-service-webapi/adapter-data-service-webapi.js +9 -2
  32. package/esm5/src/abstract-data-service-adapter.js +1 -1
  33. package/esm5/src/core.js +13 -8
  34. package/esm5/src/data-type.js +60 -1
  35. package/esm5/src/entity-action.js +1 -1
  36. package/esm5/src/entity-aspect.js +6 -8
  37. package/esm5/src/entity-manager.js +1 -1
  38. package/esm5/src/entity-metadata.js +1 -1
  39. package/esm5/src/entity-query.js +1 -1
  40. package/esm5/src/entity-state.js +9 -1
  41. package/esm5/src/enum.js +1 -1
  42. package/esm5/src/key-generator.js +1 -1
  43. package/esm5/src/mapping-context.js +9 -3
  44. package/esm5/src/predicate.js +12 -5
  45. package/fesm2015/breeze-client-adapter-data-service-odata.js +4 -0
  46. package/fesm2015/breeze-client-adapter-data-service-odata.js.map +1 -1
  47. package/fesm2015/breeze-client-adapter-data-service-webapi.js +9 -2
  48. package/fesm2015/breeze-client-adapter-data-service-webapi.js.map +1 -1
  49. package/fesm2015/breeze-client.js +104 -21
  50. package/fesm2015/breeze-client.js.map +1 -1
  51. package/fesm5/breeze-client-adapter-data-service-odata.js +4 -0
  52. package/fesm5/breeze-client-adapter-data-service-odata.js.map +1 -1
  53. package/fesm5/breeze-client-adapter-data-service-webapi.js +9 -2
  54. package/fesm5/breeze-client-adapter-data-service-webapi.js.map +1 -1
  55. package/fesm5/breeze-client.js +103 -20
  56. package/fesm5/breeze-client.js.map +1 -1
  57. package/package.json +1 -1
  58. package/src/abstract-data-service-adapter.d.ts +0 -1
  59. package/src/data-type.d.ts +5 -0
  60. package/src/entity-aspect.d.ts +5 -5
  61. package/src/entity-manager.d.ts +4 -4
  62. package/src/entity-metadata.d.ts +37 -27
  63. package/src/entity-state.d.ts +4 -0
  64. package/src/mapping-context.d.ts +1 -1
  65. package/src/predicate.d.ts +4 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "breeze-client",
3
- "version": "2.1.5",
3
+ "version": "2.1.6",
4
4
  "private": false,
5
5
  "description": "Breeze data management for JavaScript clients",
6
6
  "repository": "https://github.com/Breeze/breeze-client.git",
@@ -14,7 +14,6 @@ export declare abstract class AbstractDataServiceAdapter implements DataServiceA
14
14
  name: string;
15
15
  /** The [[IAjaxAdapter]] used by this [[IDataServiceAdapter]]. */
16
16
  ajaxImpl: AjaxAdapter;
17
- constructor();
18
17
  checkForRecomposition(interfaceInitializedArgs: any): void;
19
18
  initialize(): void;
20
19
  fetchMetadata(metadataStore: MetadataStore, dataService: DataService): Promise<unknown>;
@@ -62,6 +62,7 @@ export declare class DataType extends BreezeEnum {
62
62
  static Decimal: DataType;
63
63
  static Double: DataType;
64
64
  static Single: DataType;
65
+ static DateOnly: DataType;
65
66
  static DateTime: DataType;
66
67
  static DateTimeOffset: DataType;
67
68
  static Time: DataType;
@@ -77,6 +78,10 @@ export declare class DataType extends BreezeEnum {
77
78
  static fromValue(val: any): DataType;
78
79
  static parseTimeFromServer(source: any): any;
79
80
  static parseDateAsUTC(source: any): any;
81
+ /** Parse as UTC then shift to local time */
82
+ static parseDateAsLocal(source: string): any;
83
+ /** if val is a Date, return a date-only string e.g. '2023-12-31' */
84
+ static toDateOnlyString(val: any): any;
80
85
  /** Returns a raw value converted to the specified DataType */
81
86
  static parseRawValue(val: any, dataType?: DataType): any;
82
87
  /** @hidden @internal */
@@ -8,9 +8,9 @@ import { ValidationError } from './validate';
8
8
  export interface Entity {
9
9
  entityAspect: EntityAspect;
10
10
  entityType: EntityType;
11
- /** @internal */
11
+ /** Get the property with the given name */
12
12
  getProperty?(prop: string): any;
13
- /** @internal */
13
+ /** Set the property with the given name */
14
14
  setProperty?(prop: any, value: any): void;
15
15
  /** @hidden @internal */
16
16
  prototype?: {
@@ -70,7 +70,7 @@ export declare class EntityAspect {
70
70
  isBeingSaved: boolean;
71
71
  /** The 'original values' of this entity where they are different from the 'current values'.
72
72
  This is a map where the key is a property name and the value is the 'original value' of the property. */
73
- originalValues: {};
73
+ originalValues: Record<string, any>;
74
74
  /** Whether this entity has any validation errors. __Read Only__ */
75
75
  hasValidationErrors: boolean;
76
76
  /** Whether this entity has a temporary [[EntityKey]]. */
@@ -208,7 +208,7 @@ export declare class EntityAspect {
208
208
  setModified: () => any;
209
209
  /**
210
210
  Sets the entity to an EntityState of 'Deleted'. This both marks the entity as being scheduled for deletion during the next 'Save' call
211
- but also removes the entity from all of its related entities.
211
+ but also removes the entity from all of its related entities. If the current entityState is 'Added', then `setDeleted()` will mark it 'Detached'
212
212
  The same operation can be performed by calling [[EntityAspect.setEntityState]].
213
213
  > // assume order is an order entity attached to an EntityManager.
214
214
  > order.entityAspect.setDeleted();
@@ -315,7 +315,7 @@ export declare class ComplexAspect {
315
315
  /** The 'original values' of this complex object where they are different from the 'current values'.
316
316
  This is a map where the key is a property name and the value is the 'original value' of the property.
317
317
  __Read Only__ */
318
- originalValues: {};
318
+ originalValues: Record<string, any>;
319
319
  /** The parent object that to which this aspect belongs; this will either be an entity or another complex object. __Read Only__ */
320
320
  parent?: StructuralObject;
321
321
  /** The [[DataProperty]] on the 'parent' that contains this complex object. __Read Only__ */
@@ -72,7 +72,7 @@ export interface EntityError {
72
72
  }
73
73
  /** The shape of the Promise returned by an [[EntityManager.executeQuery]] call. */
74
74
  export interface QueryResult {
75
- /** Top level entities returned */
75
+ /** Top level entities returned. Excludes entities that are Deleted. */
76
76
  results: any[];
77
77
  /** Query that was executed */
78
78
  query: EntityQuery | string;
@@ -80,7 +80,7 @@ export interface QueryResult {
80
80
  entityManager?: EntityManager;
81
81
  /** Total number of results available on the server */
82
82
  inlineCount?: number;
83
- /** All entities returned by the query. Differs from results when an expand is used. */
83
+ /** All entities returned by the query. Differs from `results` when an expand is used. Includes entities that are Deleted. */
84
84
  retrievedEntities?: Entity[];
85
85
  /** Raw response from the server */
86
86
  httpResponse?: HttpResponse;
@@ -675,6 +675,6 @@ export interface IEntityByKeyResult {
675
675
  fromCache: boolean;
676
676
  }
677
677
  declare function unwrapInstance(structObj: StructuralObject, transformFn?: (dp: DataProperty, val: any) => any): any;
678
- declare function unwrapOriginalValues(target: StructuralObject, metadataStore: MetadataStore, transformFn?: (dp: DataProperty, val: any) => any): {};
679
- declare function unwrapChangedValues(entity: Entity, metadataStore: MetadataStore, transformFn: (dp: DataProperty, val: any) => any): {};
678
+ declare function unwrapOriginalValues(target: StructuralObject, metadataStore: MetadataStore, transformFn?: (dp: DataProperty, val: any) => any): Record<string, any>;
679
+ declare function unwrapChangedValues(entity: Entity, metadataStore: MetadataStore, transformFn: (dp: DataProperty, val: any) => any): Record<string, any>;
680
680
  export {};
@@ -14,6 +14,14 @@ export declare type StructuralType = EntityType | ComplexType;
14
14
  export interface IStructuralTypeMap {
15
15
  [index: string]: StructuralType;
16
16
  }
17
+ /** Keep track of constructors and initializers for StructuralTypes */
18
+ interface CtorRecord {
19
+ ctor: {
20
+ new (): StructuralObject;
21
+ };
22
+ initFn?: Function | string;
23
+ noTrackingFn?: Function;
24
+ }
17
25
  /** @hidden @internal */
18
26
  export interface IMetadataJson {
19
27
  metadataVersion: string;
@@ -77,21 +85,21 @@ export declare class MetadataStore {
77
85
  **/
78
86
  metadataFetched: BreezeEvent<MetadataFetchedEventArgs>;
79
87
  /** @hidden @internal */
80
- _resourceEntityTypeMap: {};
81
- /** @hidden @internal */
82
- _entityTypeResourceMap: {};
88
+ _resourceEntityTypeMap: Record<string, string>;
83
89
  /** @hidden @internal */
90
+ _entityTypeResourceMap: Record<string, string>;
91
+ /** @hidden @internal key is qualified structuraltype name - value is structuralType. ( structural = entityType or complexType). */
84
92
  _structuralTypeMap: IStructuralTypeMap;
93
+ /** @hidden @internal key is shortName, value is qualified name - does not need to be serialized. **/
94
+ _shortNameMap: Record<string, string>;
95
+ /** @hidden @internal key is either short or qual type name - value is ctor; **/
96
+ _ctorRegistry: Record<string, CtorRecord>;
97
+ /** @hidden @internal key is entityTypeName; value is array of nav props **/
98
+ _incompleteTypeMap: Record<string, NavigationProperty[]>;
85
99
  /** @hidden @internal **/
86
- _shortNameMap: {};
87
- /** @hidden @internal **/
88
- _ctorRegistry: {};
89
- /** @hidden @internal **/
90
- _incompleteTypeMap: {};
91
- /** @hidden @internal **/
92
- _incompleteComplexTypeMap: {};
93
- /** @hidden @internal **/
94
- _deferredTypes: {};
100
+ _incompleteComplexTypeMap: Record<string, DataProperty[]>;
101
+ /** @hidden @internal { json: any, stype: StructuralType }[] | { entityType: EntityType, csdlEntityType: any }[] **/
102
+ _deferredTypes: Record<string, any>;
95
103
  /** @hidden @internal **/
96
104
  _id: number;
97
105
  /**
@@ -330,7 +338,7 @@ export declare class MetadataStore {
330
338
  Returns a fully qualified entityTypeName for a specified resource name. The reverse of this operation
331
339
  can be obtained via the [[EntityType.defaultResourceName]] property
332
340
  **/
333
- getEntityTypeNameForResourceName(resourceName: string): any;
341
+ getEntityTypeNameForResourceName(resourceName: string): string;
334
342
  /**
335
343
  Associates a resourceName with an entityType.
336
344
 
@@ -368,14 +376,14 @@ export interface EntityTypeConfig {
368
376
  dataProperties?: DataProperty[] | Object[] | Object;
369
377
  navigationProperties?: NavigationProperty[] | Object[] | Object;
370
378
  serializerFn?: (prop: EntityProperty, val: any) => any;
371
- custom?: Object;
379
+ custom?: any;
372
380
  }
373
381
  /** Configuration info to be passed to the [[EntityType.setProperties]] method */
374
382
  export interface EntityTypeSetConfig {
375
383
  autoGeneratedKeyType?: AutoGeneratedKeyType;
376
384
  defaultResourceName?: string;
377
385
  serializerFn?: (prop: EntityProperty, val: any) => any;
378
- custom?: Object;
386
+ custom?: any;
379
387
  }
380
388
  /** Container for all of the metadata about a specific type of Entity.
381
389
  **/
@@ -433,7 +441,7 @@ export declare class EntityType {
433
441
  /** A function that is used to customize the serialization of any EntityProperties of this type. */
434
442
  serializerFn?: (prop: EntityProperty, val: any) => any;
435
443
  /** A free form object that can be used to define any custom metadata for this EntityType. __Read Only__ **/
436
- custom?: Object;
444
+ custom?: any;
437
445
  /** The entity level validators associated with this EntityType. Validators can be added and
438
446
  removed from this collection. __Read Only__. **/
439
447
  validators: Validator[];
@@ -626,7 +634,7 @@ export interface ComplexTypeConfig {
626
634
  namespace?: string;
627
635
  dataProperties?: DataProperty[] | Object[] | Object;
628
636
  isComplexType?: boolean;
629
- custom?: Object;
637
+ custom?: any;
630
638
  }
631
639
  /** Container for all of the metadata about a specific type of Complex object.
632
640
  > let complexType = new ComplexType( {
@@ -705,7 +713,7 @@ export declare class ComplexType {
705
713
  @param config.custom - {Object}
706
714
  **/
707
715
  setProperties(config: {
708
- custom?: Object;
716
+ custom?: any;
709
717
  }): void;
710
718
  getAllValidators(): Validator[];
711
719
  /** @hidden @internal */
@@ -729,9 +737,9 @@ export interface DataPropertyConfig {
729
737
  maxLength?: number;
730
738
  validators?: Validator[];
731
739
  displayName?: string;
732
- enumType?: any;
740
+ enumType?: string;
733
741
  rawTypeName?: string;
734
- custom?: Object;
742
+ custom?: any;
735
743
  }
736
744
  /**
737
745
  A DataProperty describes the metadata for a single property of an [[EntityType]] that contains simple data.
@@ -778,11 +786,12 @@ export declare class DataProperty {
778
786
  validators: Validator[];
779
787
  /** The display name of this property. __Read Only__ */
780
788
  displayName: string;
781
- enumType?: any;
789
+ /** The full name of the enum type */
790
+ enumType?: string;
782
791
  /** The raw type name of this property. will only be defined for properties with a DataType of 'Undefined' */
783
792
  rawTypeName?: string;
784
793
  /** A free form object that can be used to define any custom metadata for this DataProperty. __Read Only__ */
785
- custom?: Object;
794
+ custom?: any;
786
795
  inverseNavigationProperty?: NavigationProperty;
787
796
  /**
788
797
  The navigation property related to this property. Will only be set if this is a foreign key property. __Read Only__ */
@@ -803,8 +812,8 @@ export declare class DataProperty {
803
812
  @param config - A configuration Object or a DataProperty
804
813
  */
805
814
  constructor(config: DataPropertyConfig | DataProperty);
806
- static getRawValueFromServer(rawEntity: Object, dp: DataProperty): any;
807
- static getRawValueFromClient(rawEntity: Object, dp: DataProperty): any;
815
+ static getRawValueFromServer(rawEntity: Object & Record<string, any>, dp: DataProperty): any;
816
+ static getRawValueFromClient(rawEntity: Object & Record<string, any>, dp: DataProperty): any;
808
817
  resolveProperty(propName: string): any;
809
818
  formatName(): string;
810
819
  /**
@@ -836,7 +845,7 @@ export interface NavigationPropertyConfig {
836
845
  invForeignKeyNamesOnServer?: string[];
837
846
  validators?: Validator[];
838
847
  displayName?: string;
839
- custom?: Object;
848
+ custom?: any;
840
849
  }
841
850
  /** A NavigationProperty describes the metadata for a single property of an [[EntityType]] that return instances of other EntityTypes.
842
851
 
@@ -898,7 +907,7 @@ export declare class NavigationProperty {
898
907
  displayName: string;
899
908
  isUnmapped: boolean;
900
909
  /** A free form object that can be used to define any custom metadata for this NavigationProperty. **/
901
- custom: Object;
910
+ custom: any;
902
911
  /** NavigationProperty constructor
903
912
  > let homeAddressProp = new NavigationProperty( {
904
913
  > name: "homeAddress",
@@ -931,7 +940,7 @@ export declare class NavigationProperty {
931
940
  foreignKeyNames?: string[];
932
941
  invForeignKeyNames?: string[];
933
942
  inverse?: NavigationProperty | string;
934
- custom?: Object;
943
+ custom?: any;
935
944
  }): void;
936
945
  /*The inverse of this NavigationProperty. The NavigationProperty that represents a navigation in the opposite direction
937
946
  to this NavigationProperty. May be undefined for a undirectional NavigationProperty. __Read Only__ */
@@ -974,3 +983,4 @@ declare module "./assert-param" {
974
983
  }
975
984
  }
976
985
  export declare function qualifyTypeName(shortName: string, ns?: string): string;
986
+ export {};
@@ -60,6 +60,8 @@ export declare class EntityState extends BreezeEnum {
60
60
  > return es === EntityState.Detached;
61
61
  **/
62
62
  isDetached(): boolean;
63
+ /** Return true if EntityState is Deleted or Detached */
64
+ isDeletedOrDetached(): boolean;
63
65
  /**
64
66
  Returns whether an entityState instance is EntityState.Unchanged or EntityState.Modified.
65
67
  > var es = anEntity.entityAspect.entityState;
@@ -69,6 +71,8 @@ export declare class EntityState extends BreezeEnum {
69
71
  > return es === EntityState.Unchanged || es === EntityState.Modified
70
72
  **/
71
73
  isUnchangedOrModified(): boolean;
74
+ /** Return true if EntityStatis is Added or Modified */
75
+ isAddedOrModified(): boolean;
72
76
  /** Returns whether an entityState instance is EntityState.Added or EntityState.Modified or EntityState.Deleted.
73
77
  > var es = anEntity.entityAspect.entityState;
74
78
  > return es.isAddedModifiedOrDeleted();
@@ -35,7 +35,7 @@ export declare class MappingContext {
35
35
  entityManager: EntityManager;
36
36
  mergeOptions: MergeOptions;
37
37
  adapter: DataServiceAdapter;
38
- refMap: Object;
38
+ refMap: Record<string, any>;
39
39
  deferredFns: Function[];
40
40
  jsonResultsAdapter: JsonResultsAdapter;
41
41
  metadataStore: MetadataStore;
@@ -215,7 +215,6 @@ export declare class Predicate {
215
215
  @hidden
216
216
  */
217
217
  export declare class UnaryPredicate extends Predicate {
218
- op: Op;
219
218
  pred: Predicate;
220
219
  constructor(op: string | QueryOp, ...args: any[]);
221
220
  _validate(entityType: EntityType, usesNameOnServer?: boolean): void;
@@ -225,7 +224,6 @@ export declare class UnaryPredicate extends Predicate {
225
224
  @hidden
226
225
  */
227
226
  export declare class BinaryPredicate extends Predicate {
228
- op: Op;
229
227
  expr1Source: any;
230
228
  expr2Source: any;
231
229
  expr1?: PredicateExpression;
@@ -238,7 +236,6 @@ export declare class BinaryPredicate extends Predicate {
238
236
  @hidden
239
237
  */
240
238
  export declare class AndOrPredicate extends Predicate {
241
- op: Op;
242
239
  preds: Predicate[];
243
240
  constructor(op: string | QueryOp, preds: any[]);
244
241
  _validate(entityType: EntityType, usesNameOnServer?: boolean): void;
@@ -248,7 +245,6 @@ export declare class AndOrPredicate extends Predicate {
248
245
  @hidden
249
246
  */
250
247
  export declare class AnyAllPredicate extends Predicate {
251
- op: Op;
252
248
  /** @internal */
253
249
  expr: PredicateExpression;
254
250
  exprSource: string;
@@ -270,7 +266,6 @@ export declare class PredicateExpression {
270
266
  */
271
267
  export declare class LitExpr extends PredicateExpression {
272
268
  value: any;
273
- dataType: DataType;
274
269
  hasExplicitDataType: boolean;
275
270
  constructor(value: any, dataType: string | DataType | undefined, hasExplicitDataType?: boolean);
276
271
  toString(): string;
@@ -281,7 +276,6 @@ export declare class LitExpr extends PredicateExpression {
281
276
  */
282
277
  export declare class PropExpr extends PredicateExpression {
283
278
  propertyPath: string;
284
- dataType: DataType | StructuralType;
285
279
  constructor(propertyPath: string);
286
280
  toString(): string;
287
281
  _validate(entityType: EntityType | undefined, usesNameOnServer?: boolean): void;
@@ -294,7 +288,6 @@ export declare class FnExpr extends PredicateExpression {
294
288
  fnName: string;
295
289
  exprs: PredicateExpression[];
296
290
  localFn: any;
297
- dataType: DataType;
298
291
  constructor(fnName: string, exprs: PredicateExpression[]);
299
292
  toString(): string;
300
293
  _validate(entityType: EntityType | undefined, usesNameOnServer?: boolean): void;
@@ -363,6 +356,10 @@ export declare class FnExpr extends PredicateExpression {
363
356
  fn: (source: Date) => number;
364
357
  dataType: DataType;
365
358
  };
359
+ hour: {
360
+ fn: (source: Date) => number;
361
+ dataType: DataType;
362
+ };
366
363
  day: {
367
364
  fn: (source: Date) => number;
368
365
  dataType: DataType;