@apigames/sdk-core 22.1.20 → 22.1.23

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.
@@ -119,7 +119,9 @@ class ResourceObject {
119
119
  }
120
120
  }
121
121
  else if ((0, __1.isResourceObjectRelationship)(data[fieldName])) {
122
- if ((0, json_1.isUndefined)(shadow) || !(0, json_1.areEqual)(shadow[fieldName], data[fieldName])) {
122
+ if ((0, json_1.isUndefined)(shadow)
123
+ || (0, json_1.isUndefined)(shadow[fieldName])
124
+ || ((shadow[fieldName].type !== data[fieldName].type) || (shadow[fieldName].id !== data[fieldName].id))) {
123
125
  payload[fieldName] = {
124
126
  data: {
125
127
  type: data[fieldName].type,
@@ -1,3 +1,3 @@
1
1
  import { GeospatialPoint } from '../interfaces';
2
2
  export declare function LoadDateTime(value: string): Date;
3
- export declare function LoadGeospatialPoint(value: any): GeospatialPoint;
3
+ export declare function LoadGeospatialPoint(geospatialPoint: GeospatialPoint, value: any): GeospatialPoint;
@@ -9,10 +9,19 @@ function LoadDateTime(value) {
9
9
  return undefined;
10
10
  }
11
11
  exports.LoadDateTime = LoadDateTime;
12
- function LoadGeospatialPoint(value) {
13
- if ((0, json_1.isDefined)(value) && (0, json_1.hasProperty)(value, 'longitude') && (0, json_1.isNumber)(value.longitude)
14
- && (0, json_1.hasProperty)(value, 'latitude') && (0, json_1.isNumber)(value.latitude)) {
15
- const geospatialPoint = new interfaces_1.GeospatialPoint();
12
+ function LoadGeospatialPoint(geospatialPoint, value) {
13
+ if ((0, json_1.isUndefinedOrNull)(geospatialPoint)) {
14
+ if ((0, json_1.isDefined)(value) && (0, json_1.isObject)(value) && (Object.keys(value).length === 2)
15
+ && (0, json_1.hasProperty)(value, 'longitude') && (0, json_1.isNumber)(value.longitude)
16
+ && (0, json_1.hasProperty)(value, 'latitude') && (0, json_1.isNumber)(value.latitude)) {
17
+ const result = new interfaces_1.GeospatialPoint();
18
+ result.LoadData(value);
19
+ return result;
20
+ }
21
+ }
22
+ else if ((0, json_1.isDefined)(value) && (0, json_1.isObject)(value) && (Object.keys(value).length <= 2)
23
+ && (((0, json_1.hasProperty)(value, 'longitude') && (0, json_1.isNumber)(value.longitude))
24
+ || ((0, json_1.hasProperty)(value, 'latitude') && (0, json_1.isNumber)(value.latitude)))) {
16
25
  geospatialPoint.LoadData(value);
17
26
  return geospatialPoint;
18
27
  }
@@ -43,7 +43,7 @@ export interface IResourceObjectRelationships {
43
43
  export declare type ResourceObjectUri = string;
44
44
  export declare class ResourceObjectAttributeBase {
45
45
  protected static LoadDateTime(value: string): Date;
46
- protected static LoadGeospatialPoint(value: any): GeospatialPoint;
46
+ protected static LoadGeospatialPoint(geospatialPoint: GeospatialPoint, value: any): GeospatialPoint;
47
47
  }
48
48
  export declare class GeospatialPoint extends ResourceObjectAttributeBase implements IResourceObjectAttributes {
49
49
  longitude: number;
@@ -53,7 +53,8 @@ export declare class GeospatialPoint extends ResourceObjectAttributeBase impleme
53
53
  export declare class ResourceObjectRelationshipBase {
54
54
  private _includes;
55
55
  constructor(includes: ResourceContainerIncludedResourceTypes);
56
- protected LoadRelationshipData(expectedType: string, value: any): ResourceObjectRelationship;
56
+ protected LoadRelationship(expectedType: string, value: any): ResourceObjectRelationship;
57
+ protected LoadRelationships(expectedType: string, value: any): ResourceObjectRelationships;
57
58
  static RelationshipType(relationshipName: string): string;
58
59
  }
59
60
  export interface IResourceObject {
@@ -32,15 +32,17 @@ class ResourceObjectAttributeBase {
32
32
  static LoadDateTime(value) {
33
33
  return (0, helpers_1.LoadDateTime)(value);
34
34
  }
35
- static LoadGeospatialPoint(value) {
36
- return (0, helpers_1.LoadGeospatialPoint)(value);
35
+ static LoadGeospatialPoint(geospatialPoint, value) {
36
+ return (0, helpers_1.LoadGeospatialPoint)(geospatialPoint, value);
37
37
  }
38
38
  }
39
39
  exports.ResourceObjectAttributeBase = ResourceObjectAttributeBase;
40
40
  class GeospatialPoint extends ResourceObjectAttributeBase {
41
41
  LoadData(data) {
42
- this.longitude = data.longitude;
43
- this.latitude = data.latitude;
42
+ if ((0, json_1.hasProperty)(data, 'longitude'))
43
+ this.longitude = data.longitude;
44
+ if ((0, json_1.hasProperty)(data, 'latitude'))
45
+ this.latitude = data.latitude;
44
46
  }
45
47
  }
46
48
  exports.GeospatialPoint = GeospatialPoint;
@@ -48,12 +50,45 @@ class ResourceObjectRelationshipBase {
48
50
  constructor(includes) {
49
51
  this._includes = includes;
50
52
  }
51
- LoadRelationshipData(expectedType, value) {
52
- if ((0, json_1.isDefined)(value) && ((0, json_1.hasProperty)(value, 'data') && (0, json_1.isObject)(value.data)
53
- && (0, json_1.hasProperty)(value.data, 'type') && (0, json_1.isString)(value.data.type)
54
- && (value.data.type === expectedType)
55
- && (0, json_1.hasProperty)(value.data, 'id') && (0, json_1.isString)(value.data.id)))
56
- return new ResourceObjectRelationship(this._includes, value.data.type, value.data.id);
53
+ LoadRelationship(expectedType, value) {
54
+ if ((0, json_1.isObject)(value)) {
55
+ if ((0, json_1.hasProperty)(value, 'data') && (0, json_1.isObject)(value.data) && (Object.keys(value.data).length === 2)
56
+ && (0, json_1.hasProperty)(value.data, 'type') && (0, json_1.isString)(value.data.type)
57
+ && (value.data.type === expectedType)
58
+ && (0, json_1.hasProperty)(value.data, 'id') && (0, json_1.isString)(value.data.id)) {
59
+ return new ResourceObjectRelationship(this._includes, value.data.type, value.data.id);
60
+ }
61
+ if ((Object.keys(value).length === 1) && (0, json_1.hasProperty)(value, 'id') && (0, json_1.isString)(value.id)) {
62
+ return new ResourceObjectRelationship(this._includes, expectedType, value.id);
63
+ }
64
+ }
65
+ return undefined;
66
+ }
67
+ LoadRelationships(expectedType, value) {
68
+ if ((0, json_1.isObject)(value)) {
69
+ if ((0, json_1.hasProperty)(value, 'data') && (0, json_1.isArray)(value.data)) {
70
+ const relationships = [];
71
+ for (const relationship of value.data) {
72
+ if ((0, json_1.isObject)(relationship) && (Object.keys(relationship).length === 2)
73
+ && (0, json_1.hasProperty)(relationship, 'type') && (0, json_1.isString)(relationship.type)
74
+ && (relationship.type === expectedType)
75
+ && (0, json_1.hasProperty)(relationship, 'id') && (0, json_1.isString)(relationship.id)) {
76
+ relationships.push(new ResourceObjectRelationship(this._includes, relationship.type, relationship.id));
77
+ }
78
+ }
79
+ return relationships;
80
+ }
81
+ }
82
+ else if ((0, json_1.isArray)(value)) {
83
+ const relationships = [];
84
+ for (const relationship of value) {
85
+ if ((0, json_1.isObject)(relationship) && (Object.keys(relationship).length === 1)
86
+ && (0, json_1.hasProperty)(relationship, 'id') && (0, json_1.isString)(relationship.id)) {
87
+ relationships.push(new ResourceObjectRelationship(this._includes, expectedType, relationship.id));
88
+ }
89
+ }
90
+ return relationships;
91
+ }
57
92
  return undefined;
58
93
  }
59
94
  static RelationshipType(relationshipName) {
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "description": "API Games SDK Core",
15
15
  "license": "MIT",
16
- "version": "22.1.20",
16
+ "version": "22.1.23",
17
17
  "main": "lib/index.js",
18
18
  "types": "lib/index.d.ts",
19
19
  "scripts": {