@datocms/cma-client 5.4.4 → 5.4.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.
- package/dist/cjs/generated/Client.js +1 -1
- package/dist/cjs/utilities/buildBlockRecord.js +10 -1
- package/dist/cjs/utilities/buildBlockRecord.js.map +1 -1
- package/dist/esm/generated/Client.js +1 -1
- package/dist/esm/utilities/buildBlockRecord.js +10 -1
- package/dist/esm/utilities/buildBlockRecord.js.map +1 -1
- package/package.json +2 -2
- package/src/generated/Client.ts +1 -1
- package/src/utilities/buildBlockRecord.ts +13 -1
|
@@ -90,7 +90,7 @@ class Client {
|
|
|
90
90
|
return this.config.baseUrl || Client.defaultBaseUrl;
|
|
91
91
|
}
|
|
92
92
|
request(options) {
|
|
93
|
-
return (0, rest_client_utils_1.request)(Object.assign(Object.assign(Object.assign({}, this.config), options), { logFn: this.config.logFn || console.log, userAgent: '@datocms/cma-client v5.4.
|
|
93
|
+
return (0, rest_client_utils_1.request)(Object.assign(Object.assign(Object.assign({}, this.config), options), { logFn: this.config.logFn || console.log, userAgent: '@datocms/cma-client v5.4.5', baseUrl: this.baseUrl, preCallStack: new Error().stack, extraHeaders: Object.assign(Object.assign(Object.assign({}, (this.config.extraHeaders || {})), (this.config.environment
|
|
94
94
|
? { 'X-Environment': this.config.environment }
|
|
95
95
|
: {})), { 'X-API-Version': '3' }), fetchJobResult: (jobId) => {
|
|
96
96
|
return this.jobResultsFetcher
|
|
@@ -27,6 +27,7 @@ exports.buildBlockRecord = void 0;
|
|
|
27
27
|
const Utils = __importStar(require("@datocms/rest-client-utils"));
|
|
28
28
|
const resources_1 = require("../generated/resources");
|
|
29
29
|
function buildBlockRecord(body) {
|
|
30
|
+
var _a, _b, _c, _d, _e, _f;
|
|
30
31
|
const data = Utils.serializeRequestBody(body, {
|
|
31
32
|
type: resources_1.Item.TYPE,
|
|
32
33
|
attributes: '*',
|
|
@@ -36,7 +37,15 @@ function buildBlockRecord(body) {
|
|
|
36
37
|
// `__itemTypeId` so locally-built blocks support the same TS narrowing
|
|
37
38
|
// pattern as blocks read from API responses. The field is TS-only and is
|
|
38
39
|
// stripped again by the serializer when the outer request is sent.
|
|
39
|
-
|
|
40
|
+
//
|
|
41
|
+
// `item_type` is optional on `UpdateBlockRecordSchema` (id-only updates), so
|
|
42
|
+
// the ID may be absent here. Accept any source the caller provided and
|
|
43
|
+
// leave `__itemTypeId` unset when none is available — the property is
|
|
44
|
+
// declared optional, so consumers already handle the `undefined` case.
|
|
45
|
+
const itemTypeId = (_c = (_a = body.__itemTypeId) !== null && _a !== void 0 ? _a : (_b = body.item_type) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : (_f = (_e = (_d = data.relationships) === null || _d === void 0 ? void 0 : _d.item_type) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.id;
|
|
46
|
+
if (itemTypeId === undefined)
|
|
47
|
+
return data;
|
|
48
|
+
return Object.assign(Object.assign({}, data), { __itemTypeId: itemTypeId });
|
|
40
49
|
}
|
|
41
50
|
exports.buildBlockRecord = buildBlockRecord;
|
|
42
51
|
//# sourceMappingURL=buildBlockRecord.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildBlockRecord.js","sourceRoot":"","sources":["../../../src/utilities/buildBlockRecord.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAAoD;AAGpD,sDAA8C;AA6B9C,SAAgB,gBAAgB,CAG9B,IAEuC
|
|
1
|
+
{"version":3,"file":"buildBlockRecord.js","sourceRoot":"","sources":["../../../src/utilities/buildBlockRecord.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAAoD;AAGpD,sDAA8C;AA6B9C,SAAgB,gBAAgB,CAG9B,IAEuC;;IAEvC,MAAM,IAAI,GAAG,KAAK,CAAC,oBAAoB,CAEpC,IAAI,EAAE;QACP,IAAI,EAAE,gBAAI,CAAC,IAAI;QACf,UAAU,EAAE,GAAG;QACf,aAAa,EAAE,CAAC,WAAW,CAAC;KAC7B,CAAC,CAAC,IAAI,CAAC;IAER,qEAAqE;IACrE,uEAAuE;IACvE,yEAAyE;IACzE,mEAAmE;IACnE,EAAE;IACF,6EAA6E;IAC7E,uEAAuE;IACvE,sEAAsE;IACtE,uEAAuE;IACvE,MAAM,UAAU,GACd,MAAA,MAAA,IAAI,CAAC,YAAY,mCACjB,MAAA,IAAI,CAAC,SAAS,0CAAE,EAAE,mCAClB,MAAA,MAAA,MAAA,IAAI,CAAC,aAAa,0CAAE,SAAS,0CAAE,IAAI,0CAAE,EAAE,CAAC;IAE1C,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAE1C,OAAO,gCACF,IAAI,KACP,YAAY,EAAE,UAAU,GACQ,CAAC;AACrC,CAAC;AAnCD,4CAmCC"}
|
|
@@ -64,7 +64,7 @@ export class Client {
|
|
|
64
64
|
return this.config.baseUrl || Client.defaultBaseUrl;
|
|
65
65
|
}
|
|
66
66
|
request(options) {
|
|
67
|
-
return request(Object.assign(Object.assign(Object.assign({}, this.config), options), { logFn: this.config.logFn || console.log, userAgent: '@datocms/cma-client v5.4.
|
|
67
|
+
return request(Object.assign(Object.assign(Object.assign({}, this.config), options), { logFn: this.config.logFn || console.log, userAgent: '@datocms/cma-client v5.4.5', baseUrl: this.baseUrl, preCallStack: new Error().stack, extraHeaders: Object.assign(Object.assign(Object.assign({}, (this.config.extraHeaders || {})), (this.config.environment
|
|
68
68
|
? { 'X-Environment': this.config.environment }
|
|
69
69
|
: {})), { 'X-API-Version': '3' }), fetchJobResult: (jobId) => {
|
|
70
70
|
return this.jobResultsFetcher
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as Utils from '@datocms/rest-client-utils';
|
|
2
2
|
import { Item } from '../generated/resources';
|
|
3
3
|
export function buildBlockRecord(body) {
|
|
4
|
+
var _a, _b, _c, _d, _e, _f;
|
|
4
5
|
const data = Utils.serializeRequestBody(body, {
|
|
5
6
|
type: Item.TYPE,
|
|
6
7
|
attributes: '*',
|
|
@@ -10,6 +11,14 @@ export function buildBlockRecord(body) {
|
|
|
10
11
|
// `__itemTypeId` so locally-built blocks support the same TS narrowing
|
|
11
12
|
// pattern as blocks read from API responses. The field is TS-only and is
|
|
12
13
|
// stripped again by the serializer when the outer request is sent.
|
|
13
|
-
|
|
14
|
+
//
|
|
15
|
+
// `item_type` is optional on `UpdateBlockRecordSchema` (id-only updates), so
|
|
16
|
+
// the ID may be absent here. Accept any source the caller provided and
|
|
17
|
+
// leave `__itemTypeId` unset when none is available — the property is
|
|
18
|
+
// declared optional, so consumers already handle the `undefined` case.
|
|
19
|
+
const itemTypeId = (_c = (_a = body.__itemTypeId) !== null && _a !== void 0 ? _a : (_b = body.item_type) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : (_f = (_e = (_d = data.relationships) === null || _d === void 0 ? void 0 : _d.item_type) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.id;
|
|
20
|
+
if (itemTypeId === undefined)
|
|
21
|
+
return data;
|
|
22
|
+
return Object.assign(Object.assign({}, data), { __itemTypeId: itemTypeId });
|
|
14
23
|
}
|
|
15
24
|
//# sourceMappingURL=buildBlockRecord.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildBlockRecord.js","sourceRoot":"","sources":["../../../src/utilities/buildBlockRecord.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,4BAA4B,CAAC;AAGpD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AA6B9C,MAAM,UAAU,gBAAgB,CAG9B,IAEuC
|
|
1
|
+
{"version":3,"file":"buildBlockRecord.js","sourceRoot":"","sources":["../../../src/utilities/buildBlockRecord.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,4BAA4B,CAAC;AAGpD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AA6B9C,MAAM,UAAU,gBAAgB,CAG9B,IAEuC;;IAEvC,MAAM,IAAI,GAAG,KAAK,CAAC,oBAAoB,CAEpC,IAAI,EAAE;QACP,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,UAAU,EAAE,GAAG;QACf,aAAa,EAAE,CAAC,WAAW,CAAC;KAC7B,CAAC,CAAC,IAAI,CAAC;IAER,qEAAqE;IACrE,uEAAuE;IACvE,yEAAyE;IACzE,mEAAmE;IACnE,EAAE;IACF,6EAA6E;IAC7E,uEAAuE;IACvE,sEAAsE;IACtE,uEAAuE;IACvE,MAAM,UAAU,GACd,MAAA,MAAA,IAAI,CAAC,YAAY,mCACjB,MAAA,IAAI,CAAC,SAAS,0CAAE,EAAE,mCAClB,MAAA,MAAA,MAAA,IAAI,CAAC,aAAa,0CAAE,SAAS,0CAAE,IAAI,0CAAE,EAAE,CAAC;IAE1C,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAE1C,OAAO,gCACF,IAAI,KACP,YAAY,EAAE,UAAU,GACQ,CAAC;AACrC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datocms/cma-client",
|
|
3
|
-
"version": "5.4.
|
|
3
|
+
"version": "5.4.5",
|
|
4
4
|
"description": "JS client for DatoCMS REST Content Management API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datocms",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"@datocms/dashboard-client": "^5.4.3",
|
|
46
46
|
"@types/uuid": "^9.0.7"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "dac77c6d49f38f49d2a759d2b8c2d4427c8a6c63"
|
|
49
49
|
}
|
package/src/generated/Client.ts
CHANGED
|
@@ -151,7 +151,7 @@ export class Client {
|
|
|
151
151
|
...this.config,
|
|
152
152
|
...options,
|
|
153
153
|
logFn: this.config.logFn || console.log,
|
|
154
|
-
userAgent: '@datocms/cma-client v5.4.
|
|
154
|
+
userAgent: '@datocms/cma-client v5.4.5',
|
|
155
155
|
baseUrl: this.baseUrl,
|
|
156
156
|
preCallStack: new Error().stack,
|
|
157
157
|
extraHeaders: {
|
|
@@ -49,8 +49,20 @@ export function buildBlockRecord<
|
|
|
49
49
|
// `__itemTypeId` so locally-built blocks support the same TS narrowing
|
|
50
50
|
// pattern as blocks read from API responses. The field is TS-only and is
|
|
51
51
|
// stripped again by the serializer when the outer request is sent.
|
|
52
|
+
//
|
|
53
|
+
// `item_type` is optional on `UpdateBlockRecordSchema` (id-only updates), so
|
|
54
|
+
// the ID may be absent here. Accept any source the caller provided and
|
|
55
|
+
// leave `__itemTypeId` unset when none is available — the property is
|
|
56
|
+
// declared optional, so consumers already handle the `undefined` case.
|
|
57
|
+
const itemTypeId =
|
|
58
|
+
body.__itemTypeId ??
|
|
59
|
+
body.item_type?.id ??
|
|
60
|
+
data.relationships?.item_type?.data?.id;
|
|
61
|
+
|
|
62
|
+
if (itemTypeId === undefined) return data;
|
|
63
|
+
|
|
52
64
|
return {
|
|
53
65
|
...data,
|
|
54
|
-
__itemTypeId:
|
|
66
|
+
__itemTypeId: itemTypeId,
|
|
55
67
|
} as NewBlockInRequest<NoInfer<D>>;
|
|
56
68
|
}
|