@apigames/sdk-core 22.1.32 → 22.1.33

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.
@@ -1,4 +1,4 @@
1
- export { default as ResourceContainer, ResourceFilterType } from './resource.container';
1
+ export { default as ResourceContainer, ResourceContainerParams, ResourceFilterType } from './resource.container';
2
2
  export { default as ResourceObject, ResourceObjectClass, ResourceObjectMode } from './resource.object';
3
3
  export { ResourceHeaderParams } from './resource.header.params';
4
4
  export { ResourcePathParams } from './resource.path.params';
@@ -1,5 +1,5 @@
1
1
  import { IRestClient, RestClientResponse } from '@apigames/rest-client';
2
- import { IResourceContainer, IResourceObject, ResourceContainerIncludedResourceTypes, ResourceHeaderParams, ResourcePathParams, ResourceFilterName, ResourceFilterValue, ResourceIncludeOption, ResourceSortOption } from '..';
2
+ import { IResourceContainer, IResourceObject, ResourceContainerIncludedResourceTypes, ResourceHeaderParams, ResourcePathParams, ResourceFilterName, ResourceFilterValue, ResourceIncludeOption, ResourceSortOption, SDKConfiguration } from '..';
3
3
  export declare enum ResourceFilterType {
4
4
  Equal = "equal",
5
5
  NotEqual = "!equal",
@@ -10,6 +10,10 @@ export declare enum ResourceFilterType {
10
10
  NearLocation = "near",
11
11
  Exists = "exists"
12
12
  }
13
+ export declare type ResourceContainerParams = {
14
+ restClient?: IRestClient;
15
+ sdkConfig?: SDKConfiguration;
16
+ };
13
17
  export default class ResourceContainer implements IResourceContainer {
14
18
  private _count;
15
19
  private _countQueryHash;
@@ -17,12 +21,14 @@ export default class ResourceContainer implements IResourceContainer {
17
21
  protected _includes: ResourceContainerIncludedResourceTypes;
18
22
  private _queryParams;
19
23
  private readonly _restClient;
24
+ private readonly _sdkConfig;
20
25
  protected headerParams: ResourceHeaderParams;
21
26
  protected pathParams: ResourcePathParams;
22
- constructor(restClient?: IRestClient);
27
+ constructor(params?: ResourceContainerParams);
23
28
  get data(): IResourceObject | IResourceObject[];
24
29
  get includes(): ResourceContainerIncludedResourceTypes;
25
30
  get restClient(): IRestClient;
31
+ get sdkConfig(): SDKConfiguration;
26
32
  get uri(): string;
27
33
  isResourceObject(value: any): value is IResourceObject;
28
34
  isResourceList(value: any): value is IResourceObject[];
@@ -27,10 +27,11 @@ var ResourceFilterType;
27
27
  ResourceFilterType["Exists"] = "exists";
28
28
  })(ResourceFilterType = exports.ResourceFilterType || (exports.ResourceFilterType = {}));
29
29
  class ResourceContainer {
30
- constructor(restClient) {
30
+ constructor(params) {
31
31
  this._data = undefined;
32
32
  this._includes = {};
33
- this._restClient = (0, json_1.isDefined)(restClient) ? restClient : new rest_client_1.RestClient();
33
+ this._restClient = (0, json_1.isDefined)(params === null || params === void 0 ? void 0 : params.restClient) ? params === null || params === void 0 ? void 0 : params.restClient : new rest_client_1.RestClient();
34
+ this._sdkConfig = (0, json_1.isDefined)(params === null || params === void 0 ? void 0 : params.sdkConfig) ? params === null || params === void 0 ? void 0 : params.sdkConfig : (0, __1.SDKConfig)();
34
35
  this.headerParams = {};
35
36
  this.pathParams = {};
36
37
  this._queryParams = {
@@ -49,6 +50,9 @@ class ResourceContainer {
49
50
  get restClient() {
50
51
  return this._restClient;
51
52
  }
53
+ get sdkConfig() {
54
+ return this._sdkConfig;
55
+ }
52
56
  get uri() {
53
57
  let uriPath = this.EndpointPath();
54
58
  for (const pathParam in this.pathParams) {
@@ -104,7 +108,7 @@ class ResourceContainer {
104
108
  LoadResourceData(resourceData) {
105
109
  if ((0, json_1.hasProperty)(resourceData, 'type') && (0, json_1.isString)(resourceData.type)) {
106
110
  if ((0, json_1.hasProperty)(resourceData, 'id') && (0, json_1.isString)(resourceData.id)) {
107
- const ResourceClass = (0, __1.SDKConfig)().ResourceClass(resourceData.type);
111
+ const ResourceClass = this.sdkConfig.ResourceClass(resourceData.type);
108
112
  return new ResourceClass(this, resource_object_1.ResourceObjectMode.ExistingDocument).LoadData(resourceData);
109
113
  }
110
114
  throw new __1.SDKException('INVALID-RESOURCE-ID', 'The resource being loaded doesn\'t have the required resource id.');
@@ -252,11 +256,11 @@ class ResourceContainer {
252
256
  headers['Content-Type'] = this.EndpointContentType();
253
257
  break;
254
258
  }
255
- if ((0, json_1.isDefined)((0, __1.SDKConfig)().apiKey)) {
256
- headers['x-api-key'] = (0, __1.SDKConfig)().apiKey;
259
+ if ((0, json_1.isDefined)(this.sdkConfig.apiKey)) {
260
+ headers['x-api-key'] = this.sdkConfig.apiKey;
257
261
  }
258
- if ((0, json_1.isDefined)((0, __1.SDKConfig)().accessToken)) {
259
- headers.Authorization = `Bearer ${(0, __1.SDKConfig)().accessToken}`;
262
+ if ((0, json_1.isDefined)(this.sdkConfig.accessToken)) {
263
+ headers.Authorization = `Bearer ${this.sdkConfig.accessToken}`;
260
264
  }
261
265
  return headers;
262
266
  }
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.32",
16
+ "version": "22.1.33",
17
17
  "main": "lib/index.js",
18
18
  "types": "lib/index.d.ts",
19
19
  "scripts": {