@apigames/sdk-core 23.3.2 → 23.3.3

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.
@@ -2,4 +2,4 @@ export { default as ResourceContainer, ResourceContainerParams, ResourceFilterTy
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';
5
- export { SDKConfiguration, SDKConfig } from './sdk.config';
5
+ export { SDKConfiguration, SDKConfig, UriRewriter } from './sdk.config';
@@ -54,5 +54,6 @@ export default class ResourceContainer implements IResourceContainer {
54
54
  Include(include: ResourceIncludeOption): IResourceContainer;
55
55
  PageOffset(pageOffset: number, pageSize: number): IResourceContainer;
56
56
  PageNumber(pageNumber: number, pageSize: number): IResourceContainer;
57
+ RewriteUri(uri: string): string;
57
58
  toJSON(): any;
58
59
  }
@@ -60,7 +60,7 @@ class ResourceContainer {
60
60
  uriPath = uriPath.replace(`{${pathParam}}`, this.pathParams[pathParam]);
61
61
  }
62
62
  }
63
- return uriPath;
63
+ return this.RewriteUri(uriPath);
64
64
  }
65
65
  isResourceObject(value) {
66
66
  return (0, json_1.isObject)(value);
@@ -318,6 +318,9 @@ class ResourceContainer {
318
318
  this._queryParams.pagination.size = pageSize;
319
319
  return this;
320
320
  }
321
+ RewriteUri(uri) {
322
+ return this.sdkConfig.RewriteUri(uri);
323
+ }
321
324
  toJSON() {
322
325
  if ((0, json_1.isDefined)(this.data)) {
323
326
  if ((0, __1.isResourceObject)(this.data))
@@ -288,7 +288,7 @@ class ResourceObject {
288
288
  throw new Error('Method or Property not implemented.');
289
289
  }
290
290
  get uri() {
291
- return this._uri;
291
+ return this._container.RewriteUri(this._uri);
292
292
  }
293
293
  }
294
294
  exports.default = ResourceObject;
@@ -2,15 +2,18 @@ import { ResourceObjectClass } from './resource.object';
2
2
  export type SDKResourceMap = {
3
3
  [index: string]: ResourceObjectClass;
4
4
  };
5
+ export type UriRewriter = (uri: string) => string;
5
6
  export declare class SDKConfiguration {
6
7
  private _accessToken;
7
8
  private _apiKey;
8
9
  private _hostName;
9
10
  private _resourceMap;
11
+ private _uriRewriter;
10
12
  constructor();
11
13
  RegisterResourceClass(type: string, resourceClass: ResourceObjectClass): void;
12
14
  ResourceClass(type: string): ResourceObjectClass;
13
15
  FormatURL(path: string): string;
16
+ RewriteUri(uri: string): string;
14
17
  get accessToken(): string;
15
18
  set accessToken(value: string);
16
19
  get apiKey(): string;
@@ -17,6 +17,11 @@ class SDKConfiguration {
17
17
  url = url.endsWith('/') ? url.slice(0, -1) : url;
18
18
  return path.startsWith('/') ? `${url}${path}` : `${url}/${path}`;
19
19
  }
20
+ RewriteUri(uri) {
21
+ if ((0, json_1.isDefined)(this._uriRewriter))
22
+ return this._uriRewriter(uri);
23
+ return uri;
24
+ }
20
25
  get accessToken() {
21
26
  return this._accessToken;
22
27
  }
@@ -91,4 +91,5 @@ export interface IResourceContainer {
91
91
  Find(): Promise<void>;
92
92
  Get(id: string): Promise<void>;
93
93
  IncludedObject(type: ResourceObjectType, id: ResourceObjectIdentifier): IResourceObject;
94
+ RewriteUri(uri: string): string;
94
95
  }
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "description": "API Games SDK Core",
15
15
  "license": "MIT",
16
- "version": "23.3.2",
16
+ "version": "23.3.3",
17
17
  "main": "lib/index.js",
18
18
  "types": "lib/index.d.ts",
19
19
  "scripts": {