@apigames/sdk-core 25.1.4 → 25.1.5

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.
@@ -11,6 +11,10 @@ export type ResourceObjectMetadata = {
11
11
  searchScore?: number;
12
12
  distance?: number;
13
13
  };
14
+ export type ResourceObjectSaveOptions = {
15
+ onRewritePostPayload?: (payload: any) => any;
16
+ onRewritePatchPayload?: (payload: any) => any;
17
+ };
14
18
  export default class ResourceObject implements IResourceObject {
15
19
  private _container;
16
20
  private _id;
@@ -35,7 +39,7 @@ export default class ResourceObject implements IResourceObject {
35
39
  private HasHeader;
36
40
  private InsertResource;
37
41
  private UpdateResource;
38
- Save(): Promise<void>;
42
+ Save(options?: ResourceObjectSaveOptions): Promise<void>;
39
43
  toJSON(): any;
40
44
  get type(): string;
41
45
  get id(): string;
@@ -239,12 +239,15 @@ class ResourceObject {
239
239
  }
240
240
  return hasHeader;
241
241
  }
242
- InsertResource() {
242
+ InsertResource(options) {
243
243
  return __awaiter(this, void 0, void 0, function* () {
244
244
  const queryUri = this._container.uri;
245
245
  const queryHeaders = this._container.GetHeaders('INSERT');
246
246
  const queryOptions = {};
247
- const payload = this.GetInsertPayload();
247
+ let payload = this.GetInsertPayload();
248
+ if ((options === null || options === void 0 ? void 0 : options.onRewritePostPayload) && (0, json_1.isDefinedAndNotNull)(options.onRewritePostPayload) && options.onRewritePostPayload instanceof Function) {
249
+ payload = options === null || options === void 0 ? void 0 : options.onRewritePostPayload(payload);
250
+ }
248
251
  const response = yield this._container.restClient.Post(queryUri, payload, queryHeaders, queryOptions);
249
252
  if (!this.HasHeader(response.headers, 'location')) {
250
253
  throw new __1.SDKException('INVALID-LOCATION', 'The save operation was unable to retrieve the location '
@@ -270,22 +273,25 @@ class ResourceObject {
270
273
  this._mode = ResourceObjectMode.ExistingDocument;
271
274
  });
272
275
  }
273
- UpdateResource() {
276
+ UpdateResource(options) {
274
277
  return __awaiter(this, void 0, void 0, function* () {
275
278
  const queryUri = this.uri;
276
279
  const queryHeaders = this._container.GetHeaders('UPDATE');
277
280
  const queryOptions = {};
278
- const payload = this.GetUpdatePayload();
281
+ let payload = this.GetUpdatePayload();
282
+ if ((options === null || options === void 0 ? void 0 : options.onRewritePatchPayload) && (0, json_1.isDefinedAndNotNull)(options.onRewritePatchPayload) && options.onRewritePatchPayload instanceof Function) {
283
+ payload = options === null || options === void 0 ? void 0 : options.onRewritePatchPayload(payload);
284
+ }
279
285
  yield this._container.restClient.Patch(queryUri, payload, queryHeaders, queryOptions);
280
286
  });
281
287
  }
282
- Save() {
288
+ Save(options) {
283
289
  return __awaiter(this, void 0, void 0, function* () {
284
290
  if (this._mode === ResourceObjectMode.NewDocument) {
285
- yield this.InsertResource();
291
+ yield this.InsertResource(options);
286
292
  }
287
293
  else {
288
- yield this.UpdateResource();
294
+ yield this.UpdateResource(options);
289
295
  }
290
296
  if ((0, json_1.isDefined)(this.attributes)) {
291
297
  this.shadowAttributes.LoadData(this.attributes, __1.ResourceObjectAttributesLoadType.Replace);
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "description": "API Games SDK Core",
15
15
  "license": "MIT",
16
- "version": "25.1.4",
16
+ "version": "25.1.5",
17
17
  "main": "lib/index.js",
18
18
  "types": "lib/index.d.ts",
19
19
  "scripts": {
@@ -39,9 +39,9 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/jest": "^30.0.0",
42
- "@types/node": "^24.10.9",
43
- "@typescript-eslint/eslint-plugin": "^8.54.0",
44
- "@typescript-eslint/parser": "^8.54.0",
42
+ "@types/node": "^24.10.13",
43
+ "@typescript-eslint/eslint-plugin": "^8.56.1",
44
+ "@typescript-eslint/parser": "^8.56.1",
45
45
  "date-and-time": "^3.6.0",
46
46
  "eslint": "^8.57.1",
47
47
  "eslint-config-airbnb-base": "^15.0.0",