@apigames/sdk-core 25.1.4 → 25.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IResourceContainer, IResourceObject, IResourceObjectAttributes, IResourceObjectRelationships, ResourceObjectUri } from '..';
|
|
1
|
+
import { IResourceContainer, IResourceObject, IResourceObjectAttributes, IResourceObjectRelationships, ResourceObjectSaveOptions, ResourceObjectUri } from '..';
|
|
2
2
|
export declare enum ResourceObjectMode {
|
|
3
3
|
NewDocument = 0,
|
|
4
4
|
ExistingDocument = 1
|
|
@@ -35,7 +35,7 @@ export default class ResourceObject implements IResourceObject {
|
|
|
35
35
|
private HasHeader;
|
|
36
36
|
private InsertResource;
|
|
37
37
|
private UpdateResource;
|
|
38
|
-
Save(): Promise<void>;
|
|
38
|
+
Save(options?: ResourceObjectSaveOptions): Promise<void>;
|
|
39
39
|
toJSON(): any;
|
|
40
40
|
get type(): string;
|
|
41
41
|
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
|
-
|
|
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
|
-
|
|
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);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { ISDKError, ISDKRequestError, ISDKException, ISDKRequestException, } from './sdk.errors';
|
|
2
|
-
export { IResourceContainer, ResourceContainerFacetValue, ResourceContainerFacets, ResourceContainerIncludedResourceTypes, ResourceFacetField, ResourceFieldName, ResourceFilterName, ResourceFilterValue, ResourceObjectType, ResourceSortOption, ResourceIncludeOption, IResourceObject, IResourceObjectAttributes, IResourceObjectRelationships, GeospatialPoint, ResourceObjectAttributeBase, ResourceObjectAttributesLoadType, ResourceObjectRelationshipLinkObject, ResourceObjectRelationshipLink, ResourceObjectRelationshipsLinks, ResourceObjectRelationshipsLoadType, ResourceObjectRelationship, ResourceObjectRelationships, ResourceObjectUri, ResourceObjectRelationshipBase, } from './resource.interfaces';
|
|
2
|
+
export { IResourceContainer, ResourceContainerFacetValue, ResourceContainerFacets, ResourceContainerIncludedResourceTypes, ResourceFacetField, ResourceFieldName, ResourceFilterName, ResourceFilterValue, ResourceObjectType, ResourceSortOption, ResourceIncludeOption, ResourceObjectSaveOptions, IResourceObject, IResourceObjectAttributes, IResourceObjectRelationships, GeospatialPoint, ResourceObjectAttributeBase, ResourceObjectAttributesLoadType, ResourceObjectRelationshipLinkObject, ResourceObjectRelationshipLink, ResourceObjectRelationshipsLinks, ResourceObjectRelationshipsLoadType, ResourceObjectRelationship, ResourceObjectRelationships, ResourceObjectUri, ResourceObjectRelationshipBase, } from './resource.interfaces';
|
|
@@ -64,6 +64,10 @@ export declare class ResourceObjectRelationshipBase {
|
|
|
64
64
|
protected LoadRelationships(expectedType: string, value: any): ResourceObjectRelationships;
|
|
65
65
|
static RelationshipType(relationshipName: string): string;
|
|
66
66
|
}
|
|
67
|
+
export type ResourceObjectSaveOptions = {
|
|
68
|
+
onRewritePostPayload?: (payload: any) => any;
|
|
69
|
+
onRewritePatchPayload?: (payload: any) => any;
|
|
70
|
+
};
|
|
67
71
|
export interface IResourceObject {
|
|
68
72
|
type: ResourceObjectType;
|
|
69
73
|
id?: ResourceObjectIdentifier;
|
|
@@ -72,7 +76,7 @@ export interface IResourceObject {
|
|
|
72
76
|
uri: ResourceObjectUri;
|
|
73
77
|
LoadData(value: any): IResourceObject;
|
|
74
78
|
Delete(): Promise<void>;
|
|
75
|
-
Save(): Promise<void>;
|
|
79
|
+
Save(options?: ResourceObjectSaveOptions): Promise<void>;
|
|
76
80
|
UpdateAttributes(value: any): void;
|
|
77
81
|
UpdateRelationships(value: any): void;
|
|
78
82
|
}
|
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.
|
|
16
|
+
"version": "25.1.6",
|
|
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.
|
|
43
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
44
|
-
"@typescript-eslint/parser": "^8.
|
|
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",
|