@datocms/cma-client 3.0.4 → 3.0.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.
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateId = void 0;
4
+ var uuid_1 = require("uuid");
5
+ var decoder = new TextDecoder('utf8');
6
+ function toBase64(bytes) {
7
+ if (typeof Buffer !== 'undefined') {
8
+ return Buffer.from(bytes).toString('base64');
9
+ }
10
+ return btoa(decoder.decode(bytes));
11
+ }
12
+ function generateId() {
13
+ var bytes = (0, uuid_1.v4)(null, new Uint8Array(16));
14
+ // unset first bit to ensure [A-Za-f] first char
15
+ bytes[0] = bytes[0] & 0x7f;
16
+ var base64 = toBase64(bytes);
17
+ return (base64
18
+ // Replace + with - (see RFC 4648, sec. 5)
19
+ .replace(/\+/g, '-')
20
+ // Replace / with _ (see RFC 4648, sec. 5)
21
+ .replace(/\//g, '_')
22
+ // Drop '==' padding
23
+ .substring(0, 22));
24
+ }
25
+ exports.generateId = generateId;
26
+ //# sourceMappingURL=generateId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateId.js","sourceRoot":"","sources":["../../src/generateId.ts"],"names":[],"mappings":";;;AAAA,6BAA0B;AAC1B,IAAM,OAAO,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;AAExC,SAAS,QAAQ,CAAC,KAAiB;IACjC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;KAC9C;IAED,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACrC,CAAC;AAED,SAAgB,UAAU;IACxB,IAAM,KAAK,GAAG,IAAA,SAAE,EAAC,IAAI,EAAE,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;IAE3C,gDAAgD;IAChD,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAE3B,IAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE/B,OAAO,CACL,MAAM;QACJ,0CAA0C;SACzC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;QACpB,0CAA0C;SACzC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;QACpB,oBAAoB;SACnB,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CACpB,CAAC;AACJ,CAAC;AAjBD,gCAiBC"}
@@ -127,7 +127,7 @@ var Client = /** @class */ (function () {
127
127
  });
128
128
  Client.prototype.request = function (options) {
129
129
  var _this = this;
130
- return (0, rest_client_utils_1.request)(__assign(__assign(__assign({}, this.config), options), { logFn: this.config.logFn || console.log, userAgent: '@datocms/cma-client v3.0.4', baseUrl: this.baseUrl, preCallStack: new Error().stack, extraHeaders: __assign(__assign(__assign({}, (this.config.extraHeaders || {})), (this.config.environment
130
+ return (0, rest_client_utils_1.request)(__assign(__assign(__assign({}, this.config), options), { logFn: this.config.logFn || console.log, userAgent: '@datocms/cma-client v3.0.5', baseUrl: this.baseUrl, preCallStack: new Error().stack, extraHeaders: __assign(__assign(__assign({}, (this.config.extraHeaders || {})), (this.config.environment
131
131
  ? { 'X-Environment': this.config.environment }
132
132
  : {})), { 'X-API-Version': '3' }), fetchJobResult: function (jobId) {
133
133
  return _this.jobResultsFetcher
@@ -99,8 +99,9 @@ var Webhook = /** @class */ (function (_super) {
99
99
  * @throws {ApiError}
100
100
  * @throws {TimeoutError}
101
101
  */
102
- Webhook.prototype.update = function (userId, body) {
103
- return this.rawUpdate(Utils.toId(userId), Utils.serializeRequestBody(body, {
102
+ Webhook.prototype.update = function (webhookId, body) {
103
+ return this.rawUpdate(Utils.toId(webhookId), Utils.serializeRequestBody(body, {
104
+ id: Utils.toId(webhookId),
104
105
  type: 'webhook',
105
106
  attributes: [
106
107
  'name',
@@ -127,10 +128,10 @@ var Webhook = /** @class */ (function (_super) {
127
128
  * @throws {ApiError}
128
129
  * @throws {TimeoutError}
129
130
  */
130
- Webhook.prototype.rawUpdate = function (userId, body) {
131
+ Webhook.prototype.rawUpdate = function (webhookId, body) {
131
132
  return this.client.request({
132
133
  method: 'PUT',
133
- url: "/webhooks/".concat(userId),
134
+ url: "/webhooks/".concat(webhookId),
134
135
  body: body,
135
136
  });
136
137
  };
@@ -169,8 +170,8 @@ var Webhook = /** @class */ (function (_super) {
169
170
  * @throws {ApiError}
170
171
  * @throws {TimeoutError}
171
172
  */
172
- Webhook.prototype.find = function (userId) {
173
- return this.rawFind(Utils.toId(userId)).then(function (body) {
173
+ Webhook.prototype.find = function (webhookId) {
174
+ return this.rawFind(Utils.toId(webhookId)).then(function (body) {
174
175
  return Utils.deserializeResponseBody(body);
175
176
  });
176
177
  };
@@ -182,10 +183,10 @@ var Webhook = /** @class */ (function (_super) {
182
183
  * @throws {ApiError}
183
184
  * @throws {TimeoutError}
184
185
  */
185
- Webhook.prototype.rawFind = function (userId) {
186
+ Webhook.prototype.rawFind = function (webhookId) {
186
187
  return this.client.request({
187
188
  method: 'GET',
188
- url: "/webhooks/".concat(userId),
189
+ url: "/webhooks/".concat(webhookId),
189
190
  });
190
191
  };
191
192
  /**
@@ -196,8 +197,8 @@ var Webhook = /** @class */ (function (_super) {
196
197
  * @throws {ApiError}
197
198
  * @throws {TimeoutError}
198
199
  */
199
- Webhook.prototype.destroy = function (userId) {
200
- return this.rawDestroy(Utils.toId(userId)).then(function (body) {
200
+ Webhook.prototype.destroy = function (webhookId) {
201
+ return this.rawDestroy(Utils.toId(webhookId)).then(function (body) {
201
202
  return Utils.deserializeResponseBody(body);
202
203
  });
203
204
  };
@@ -209,10 +210,10 @@ var Webhook = /** @class */ (function (_super) {
209
210
  * @throws {ApiError}
210
211
  * @throws {TimeoutError}
211
212
  */
212
- Webhook.prototype.rawDestroy = function (userId) {
213
+ Webhook.prototype.rawDestroy = function (webhookId) {
213
214
  return this.client.request({
214
215
  method: 'DELETE',
215
- url: "/webhooks/".concat(userId),
216
+ url: "/webhooks/".concat(webhookId),
216
217
  });
217
218
  };
218
219
  Webhook.TYPE = 'webhook';
@@ -1 +1 @@
1
- {"version":3,"file":"Webhook.js","sourceRoot":"","sources":["../../../../src/generated/resources/Webhook.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAAoD;AAGpD,oEAA8C;AAE9C;IAAqC,2BAAY;IAAjD;;IA0MA,CAAC;IAvMC;;;;;;;OAOG;IACH,wBAAM,GAAN,UAAO,IAA2C;QAChD,OAAO,IAAI,CAAC,SAAS,CACnB,KAAK,CAAC,oBAAoB,CAAkC,IAAI,EAAE;YAChE,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACV,MAAM;gBACN,KAAK;gBACL,gBAAgB;gBAChB,SAAS;gBACT,QAAQ;gBACR,iBAAiB;gBACjB,qBAAqB;gBACrB,SAAS;gBACT,qBAAqB;gBACrB,yBAAyB;aAC1B;YACD,aAAa,EAAE,EAAE;SAClB,CAAC,CACH,CAAC,IAAI,CAAC,UAAC,IAAI;YACV,OAAA,KAAK,CAAC,uBAAuB,CAC3B,IAAI,CACL;QAFD,CAEC,CACF,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,2BAAS,GAAT,UACE,IAAqC;QAErC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAwC;YAChE,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,WAAW;YAChB,IAAI,MAAA;SACL,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,wBAAM,GAAN,UACE,MAA2C,EAC3C,IAA2C;QAE3C,OAAO,IAAI,CAAC,SAAS,CACnB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAClB,KAAK,CAAC,oBAAoB,CAAkC,IAAI,EAAE;YAChE,IAAI,EAAE,S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C;IAED;;;;;;;OAOG;IACH,yBAAO,GAAP;QACE,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAA2C;YACnE,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,WAAW;SACjB,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,sBAAI,GAAJ,UAAK,SAAiD;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,UAAC,IAAI;YACnD,OAAA,KAAK,CAAC,uBAAuB,CAC3B,IAAI,CACL;QAFD,CAEC,CACF,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,yBAAO,GAAP,UAAQ,SAAiB;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAsC;YAC9D,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,oBAAa,SAAS,CAAE;SAC9B,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,yBAAO,GAAP,UAAQ,SAAiD;QACvD,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,UAAC,IAAI;YACtD,OAAA,KAAK,CAAC,uBAAuB,CAC3B,IAAI,CACL;QAFD,CAEC,CACF,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,4BAAU,GAAV,UACE,SAAiB;QAEjB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAyC;YACjE,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,oBAAa,SAAS,CAAE;SAC9B,CAAC,CAAC;IACL,CAAC;IA3Me,YAAI,GAAc,SAAS,CAAC;IA4M9C,cAAC;CAAA,AA7MD,CAAqC,sBAAY,GA6MhD;kBA7MoB,OAAO"}
package/dist/cjs/index.js CHANGED
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "Client", { enumerable: true, get: function () {
36
36
  exports.Resources = __importStar(require("./generated/resources"));
37
37
  __exportStar(require("./buildClient"), exports);
38
38
  __exportStar(require("./buildBlockRecord"), exports);
39
+ __exportStar(require("./generateId"), exports);
39
40
  exports.SchemaTypes = __importStar(require("./generated/SchemaTypes"));
40
41
  exports.SimpleSchemaTypes = __importStar(require("./generated/SimpleSchemaTypes"));
41
42
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAA8E;AAArE,6GAAA,QAAQ,OAAA;AAAE,iHAAA,YAAY,OAAA;AAAE,6GAAA,QAAQ,OAAA;AACzC,6CAA4C;AAAnC,gGAAA,MAAM,OAAA;AACf,mEAAmD;AAEnD,gDAA8B;AAC9B,qDAAmC;AACnC,uEAAuD;AACvD,mFAAmE"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAA8E;AAArE,6GAAA,QAAQ,OAAA;AAAE,iHAAA,YAAY,OAAA;AAAE,6GAAA,QAAQ,OAAA;AACzC,6CAA4C;AAAnC,gGAAA,MAAM,OAAA;AACf,mEAAmD;AAEnD,gDAA8B;AAC9B,qDAAmC;AACnC,+CAA6B;AAC7B,uEAAuD;AACvD,mFAAmE"}
@@ -0,0 +1 @@
1
+ export declare function generateId(): string;
@@ -0,0 +1,22 @@
1
+ import { v4 } from 'uuid';
2
+ var decoder = new TextDecoder('utf8');
3
+ function toBase64(bytes) {
4
+ if (typeof Buffer !== 'undefined') {
5
+ return Buffer.from(bytes).toString('base64');
6
+ }
7
+ return btoa(decoder.decode(bytes));
8
+ }
9
+ export function generateId() {
10
+ var bytes = v4(null, new Uint8Array(16));
11
+ // unset first bit to ensure [A-Za-f] first char
12
+ bytes[0] = bytes[0] & 0x7f;
13
+ var base64 = toBase64(bytes);
14
+ return (base64
15
+ // Replace + with - (see RFC 4648, sec. 5)
16
+ .replace(/\+/g, '-')
17
+ // Replace / with _ (see RFC 4648, sec. 5)
18
+ .replace(/\//g, '_')
19
+ // Drop '==' padding
20
+ .substring(0, 22));
21
+ }
22
+ //# sourceMappingURL=generateId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateId.js","sourceRoot":"","sources":["../../src/generateId.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,IAAM,OAAO,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;AAExC,SAAS,QAAQ,CAAC,KAAiB;IACjC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;KAC9C;IAED,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,IAAM,KAAK,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;IAE3C,gDAAgD;IAChD,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAE3B,IAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE/B,OAAO,CACL,MAAM;QACJ,0CAA0C;SACzC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;QACpB,0CAA0C;SACzC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;QACpB,oBAAoB;SACnB,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CACpB,CAAC;AACJ,CAAC"}
@@ -101,7 +101,7 @@ var Client = /** @class */ (function () {
101
101
  });
102
102
  Client.prototype.request = function (options) {
103
103
  var _this = this;
104
- return request(__assign(__assign(__assign({}, this.config), options), { logFn: this.config.logFn || console.log, userAgent: '@datocms/cma-client v3.0.4', baseUrl: this.baseUrl, preCallStack: new Error().stack, extraHeaders: __assign(__assign(__assign({}, (this.config.extraHeaders || {})), (this.config.environment
104
+ return request(__assign(__assign(__assign({}, this.config), options), { logFn: this.config.logFn || console.log, userAgent: '@datocms/cma-client v3.0.5', baseUrl: this.baseUrl, preCallStack: new Error().stack, extraHeaders: __assign(__assign(__assign({}, (this.config.extraHeaders || {})), (this.config.environment
105
105
  ? { 'X-Environment': this.config.environment }
106
106
  : {})), { 'X-API-Version': '3' }), fetchJobResult: function (jobId) {
107
107
  return _this.jobResultsFetcher
@@ -29,7 +29,7 @@ export default class Webhook extends BaseResource {
29
29
  * @throws {ApiError}
30
30
  * @throws {TimeoutError}
31
31
  */
32
- update(userId: string | SimpleSchemaTypes.UserData, body: SimpleSchemaTypes.WebhookUpdateSchema): Promise<SimpleSchemaTypes.Webhook>;
32
+ update(webhookId: string | SimpleSchemaTypes.WebhookData, body: SimpleSchemaTypes.WebhookUpdateSchema): Promise<SimpleSchemaTypes.Webhook>;
33
33
  /**
34
34
  * Update a webhook
35
35
  *
@@ -38,7 +38,7 @@ export default class Webhook extends BaseResource {
38
38
  * @throws {ApiError}
39
39
  * @throws {TimeoutError}
40
40
  */
41
- rawUpdate(userId: string, body: SchemaTypes.WebhookUpdateSchema): Promise<SchemaTypes.WebhookUpdateTargetSchema>;
41
+ rawUpdate(webhookId: string, body: SchemaTypes.WebhookUpdateSchema): Promise<SchemaTypes.WebhookUpdateTargetSchema>;
42
42
  /**
43
43
  * List all webhooks
44
44
  *
@@ -65,7 +65,7 @@ export default class Webhook extends BaseResource {
65
65
  * @throws {ApiError}
66
66
  * @throws {TimeoutError}
67
67
  */
68
- find(userId: string | SimpleSchemaTypes.UserData): Promise<SimpleSchemaTypes.Webhook>;
68
+ find(webhookId: string | SimpleSchemaTypes.WebhookData): Promise<SimpleSchemaTypes.Webhook>;
69
69
  /**
70
70
  * Retrieve a webhook
71
71
  *
@@ -74,7 +74,7 @@ export default class Webhook extends BaseResource {
74
74
  * @throws {ApiError}
75
75
  * @throws {TimeoutError}
76
76
  */
77
- rawFind(userId: string): Promise<SchemaTypes.WebhookSelfTargetSchema>;
77
+ rawFind(webhookId: string): Promise<SchemaTypes.WebhookSelfTargetSchema>;
78
78
  /**
79
79
  * Delete a webhook
80
80
  *
@@ -83,7 +83,7 @@ export default class Webhook extends BaseResource {
83
83
  * @throws {ApiError}
84
84
  * @throws {TimeoutError}
85
85
  */
86
- destroy(userId: string | SimpleSchemaTypes.UserData): Promise<SimpleSchemaTypes.Webhook>;
86
+ destroy(webhookId: string | SimpleSchemaTypes.WebhookData): Promise<SimpleSchemaTypes.Webhook>;
87
87
  /**
88
88
  * Delete a webhook
89
89
  *
@@ -92,5 +92,5 @@ export default class Webhook extends BaseResource {
92
92
  * @throws {ApiError}
93
93
  * @throws {TimeoutError}
94
94
  */
95
- rawDestroy(userId: string): Promise<SchemaTypes.WebhookDestroyTargetSchema>;
95
+ rawDestroy(webhookId: string): Promise<SchemaTypes.WebhookDestroyTargetSchema>;
96
96
  }
@@ -71,8 +71,9 @@ var Webhook = /** @class */ (function (_super) {
71
71
  * @throws {ApiError}
72
72
  * @throws {TimeoutError}
73
73
  */
74
- Webhook.prototype.update = function (userId, body) {
75
- return this.rawUpdate(Utils.toId(userId), Utils.serializeRequestBody(body, {
74
+ Webhook.prototype.update = function (webhookId, body) {
75
+ return this.rawUpdate(Utils.toId(webhookId), Utils.serializeRequestBody(body, {
76
+ id: Utils.toId(webhookId),
76
77
  type: 'webhook',
77
78
  attributes: [
78
79
  'name',
@@ -99,10 +100,10 @@ var Webhook = /** @class */ (function (_super) {
99
100
  * @throws {ApiError}
100
101
  * @throws {TimeoutError}
101
102
  */
102
- Webhook.prototype.rawUpdate = function (userId, body) {
103
+ Webhook.prototype.rawUpdate = function (webhookId, body) {
103
104
  return this.client.request({
104
105
  method: 'PUT',
105
- url: "/webhooks/".concat(userId),
106
+ url: "/webhooks/".concat(webhookId),
106
107
  body: body,
107
108
  });
108
109
  };
@@ -141,8 +142,8 @@ var Webhook = /** @class */ (function (_super) {
141
142
  * @throws {ApiError}
142
143
  * @throws {TimeoutError}
143
144
  */
144
- Webhook.prototype.find = function (userId) {
145
- return this.rawFind(Utils.toId(userId)).then(function (body) {
145
+ Webhook.prototype.find = function (webhookId) {
146
+ return this.rawFind(Utils.toId(webhookId)).then(function (body) {
146
147
  return Utils.deserializeResponseBody(body);
147
148
  });
148
149
  };
@@ -154,10 +155,10 @@ var Webhook = /** @class */ (function (_super) {
154
155
  * @throws {ApiError}
155
156
  * @throws {TimeoutError}
156
157
  */
157
- Webhook.prototype.rawFind = function (userId) {
158
+ Webhook.prototype.rawFind = function (webhookId) {
158
159
  return this.client.request({
159
160
  method: 'GET',
160
- url: "/webhooks/".concat(userId),
161
+ url: "/webhooks/".concat(webhookId),
161
162
  });
162
163
  };
163
164
  /**
@@ -168,8 +169,8 @@ var Webhook = /** @class */ (function (_super) {
168
169
  * @throws {ApiError}
169
170
  * @throws {TimeoutError}
170
171
  */
171
- Webhook.prototype.destroy = function (userId) {
172
- return this.rawDestroy(Utils.toId(userId)).then(function (body) {
172
+ Webhook.prototype.destroy = function (webhookId) {
173
+ return this.rawDestroy(Utils.toId(webhookId)).then(function (body) {
173
174
  return Utils.deserializeResponseBody(body);
174
175
  });
175
176
  };
@@ -181,10 +182,10 @@ var Webhook = /** @class */ (function (_super) {
181
182
  * @throws {ApiError}
182
183
  * @throws {TimeoutError}
183
184
  */
184
- Webhook.prototype.rawDestroy = function (userId) {
185
+ Webhook.prototype.rawDestroy = function (webhookId) {
185
186
  return this.client.request({
186
187
  method: 'DELETE',
187
- url: "/webhooks/".concat(userId),
188
+ url: "/webhooks/".concat(webhookId),
188
189
  });
189
190
  };
190
191
  Webhook.TYPE = 'webhook';
@@ -1 +1 @@
1
- {"version":3,"file":"Webhook.js","sourceRoot":"","sources":["../../../../src/generated/resources/Webhook.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;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I;YACnD,OAAA,KAAK,CAAC,uBAAuB,CAC3B,IAAI,CACL;QAFD,CAEC,CACF,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,4BAAU,GAAV,UAAW,MAAc;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAyC;YACjE,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,oBAAa,MAAM,CAAE;SAC3B,CAAC,CAAC;IACL,CAAC;IAxMe,YAAI,GAAc,SAAS,CAAC;IAyM9C,cAAC;CAAA,AA1MD,CAAqC,YAAY,GA0MhD;eA1MoB,OAAO"}
1
+ {"version":3,"file":"Webhook.js","sourceRoot":"","sources":["../../../../src/generated/resources/Webhook.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,KAAK,KAAK,MAAM,4BAA4B,CAAC;AAGpD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAE9C;IAAqC,2BAAY;IAAjD;;IA6MA,CAAC;IA1MC;;;;;;;OAOG;IACH,wBAAM,GAAN,UAAO,IAA2C;QAChD,OAAO,IAAI,CAAC,SAAS,CACnB,KAAK,CAAC,oBAAoB,CAAkC,IAAI,EAAE;YAChE,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACV,MAAM;gBACN,KAAK;gBACL,gBAAgB;gBAChB,SAAS;gBACT,QAAQ;gBACR,iBAAiB;gBACjB,qBAAqB;gBACrB,SAAS;gBACT,qBAAqB;gBACrB,yBAAyB;aAC1B;YACD,aAAa,EAAE,EAAE;SAClB,CAAC,CACH,CAAC,IAAI,CAAC,UAAC,IAAI;YACV,OAAA,KAAK,CAAC,uBAAuB,CAC3B,IAAI,CACL;QAFD,CAEC,CACF,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,2BAAS,GAAT,UACE,IAAqC;QAErC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAwC;YAChE,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,WAAW;YAChB,IAAI,MAAA;SAC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AI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,UAAC,IAAI;YACnD,OAAA,KAAK,CAAC,uBAAuB,CAC3B,IAAI,CACL;QAFD,CAEC,CACF,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,yBAAO,GAAP,UAAQ,SAAiB;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAsC;YAC9D,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,oBAAa,SAAS,CAAE;SAC9B,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,yBAAO,GAAP,UAAQ,SAAiD;QACvD,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,UAAC,IAAI;YACtD,OAAA,KAAK,CAAC,uBAAuB,CAC3B,IAAI,CACL;QAFD,CAEC,CACF,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,4BAAU,GAAV,UACE,SAAiB;QAEjB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAyC;YACjE,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,oBAAa,SAAS,CAAE;SAC9B,CAAC,CAAC;IACL,CAAC;IA3Me,YAAI,GAAc,SAAS,CAAC;IA4M9C,cAAC;CAAA,AA7MD,CAAqC,YAAY,GA6MhD;eA7MoB,OAAO"}
@@ -4,5 +4,6 @@ export * as Resources from './generated/resources';
4
4
  export type { ClientConfigOptions } from './generated/Client';
5
5
  export * from './buildClient';
6
6
  export * from './buildBlockRecord';
7
+ export * from './generateId';
7
8
  export * as SchemaTypes from './generated/SchemaTypes';
8
9
  export * as SimpleSchemaTypes from './generated/SimpleSchemaTypes';
package/dist/esm/index.js CHANGED
@@ -3,6 +3,7 @@ export { Client } from './generated/Client';
3
3
  export * as Resources from './generated/resources';
4
4
  export * from './buildClient';
5
5
  export * from './buildBlockRecord';
6
+ export * from './generateId';
6
7
  export * as SchemaTypes from './generated/SchemaTypes';
7
8
  export * as SimpleSchemaTypes from './generated/SimpleSchemaTypes';
8
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AAEnD,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,iBAAiB,MAAM,+BAA+B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AAEnD,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,iBAAiB,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function generateId(): string;
@@ -29,7 +29,7 @@ export default class Webhook extends BaseResource {
29
29
  * @throws {ApiError}
30
30
  * @throws {TimeoutError}
31
31
  */
32
- update(userId: string | SimpleSchemaTypes.UserData, body: SimpleSchemaTypes.WebhookUpdateSchema): Promise<SimpleSchemaTypes.Webhook>;
32
+ update(webhookId: string | SimpleSchemaTypes.WebhookData, body: SimpleSchemaTypes.WebhookUpdateSchema): Promise<SimpleSchemaTypes.Webhook>;
33
33
  /**
34
34
  * Update a webhook
35
35
  *
@@ -38,7 +38,7 @@ export default class Webhook extends BaseResource {
38
38
  * @throws {ApiError}
39
39
  * @throws {TimeoutError}
40
40
  */
41
- rawUpdate(userId: string, body: SchemaTypes.WebhookUpdateSchema): Promise<SchemaTypes.WebhookUpdateTargetSchema>;
41
+ rawUpdate(webhookId: string, body: SchemaTypes.WebhookUpdateSchema): Promise<SchemaTypes.WebhookUpdateTargetSchema>;
42
42
  /**
43
43
  * List all webhooks
44
44
  *
@@ -65,7 +65,7 @@ export default class Webhook extends BaseResource {
65
65
  * @throws {ApiError}
66
66
  * @throws {TimeoutError}
67
67
  */
68
- find(userId: string | SimpleSchemaTypes.UserData): Promise<SimpleSchemaTypes.Webhook>;
68
+ find(webhookId: string | SimpleSchemaTypes.WebhookData): Promise<SimpleSchemaTypes.Webhook>;
69
69
  /**
70
70
  * Retrieve a webhook
71
71
  *
@@ -74,7 +74,7 @@ export default class Webhook extends BaseResource {
74
74
  * @throws {ApiError}
75
75
  * @throws {TimeoutError}
76
76
  */
77
- rawFind(userId: string): Promise<SchemaTypes.WebhookSelfTargetSchema>;
77
+ rawFind(webhookId: string): Promise<SchemaTypes.WebhookSelfTargetSchema>;
78
78
  /**
79
79
  * Delete a webhook
80
80
  *
@@ -83,7 +83,7 @@ export default class Webhook extends BaseResource {
83
83
  * @throws {ApiError}
84
84
  * @throws {TimeoutError}
85
85
  */
86
- destroy(userId: string | SimpleSchemaTypes.UserData): Promise<SimpleSchemaTypes.Webhook>;
86
+ destroy(webhookId: string | SimpleSchemaTypes.WebhookData): Promise<SimpleSchemaTypes.Webhook>;
87
87
  /**
88
88
  * Delete a webhook
89
89
  *
@@ -92,5 +92,5 @@ export default class Webhook extends BaseResource {
92
92
  * @throws {ApiError}
93
93
  * @throws {TimeoutError}
94
94
  */
95
- rawDestroy(userId: string): Promise<SchemaTypes.WebhookDestroyTargetSchema>;
95
+ rawDestroy(webhookId: string): Promise<SchemaTypes.WebhookDestroyTargetSchema>;
96
96
  }
@@ -4,5 +4,6 @@ export * as Resources from './generated/resources';
4
4
  export type { ClientConfigOptions } from './generated/Client';
5
5
  export * from './buildClient';
6
6
  export * from './buildBlockRecord';
7
+ export * from './generateId';
7
8
  export * as SchemaTypes from './generated/SchemaTypes';
8
9
  export * as SimpleSchemaTypes from './generated/SimpleSchemaTypes';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datocms/cma-client",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "description": "JS client for DatoCMS REST Content Management API",
5
5
  "keywords": [
6
6
  "datocms",
@@ -37,10 +37,12 @@
37
37
  "url": "https://github.com/datocms/js-rest-api-clients/issues"
38
38
  },
39
39
  "dependencies": {
40
- "@datocms/rest-client-utils": "^3.0.1"
40
+ "@datocms/rest-client-utils": "^3.0.5",
41
+ "uuid": "^9.0.1"
41
42
  },
42
43
  "devDependencies": {
43
- "@datocms/dashboard-client": "^3.0.4"
44
+ "@datocms/dashboard-client": "^3.0.5",
45
+ "@types/uuid": "^9.0.7"
44
46
  },
45
- "gitHead": "d6bbcf5972f0854f49bbf2e04270de9596287092"
47
+ "gitHead": "ac36c1649815c85b27d86f7a9fc87b9bb44e1596"
46
48
  }
package/resources.json CHANGED
@@ -2408,13 +2408,13 @@
2408
2408
  "returnsCollection": false,
2409
2409
  "docUrl": "https://www.datocms.com/docs/content-management-api/resources/webhook/update",
2410
2410
  "rel": "update",
2411
- "urlTemplate": "/webhooks/${userId}",
2411
+ "urlTemplate": "/webhooks/${webhookId}",
2412
2412
  "method": "PUT",
2413
2413
  "comment": "Update a webhook",
2414
2414
  "urlPlaceholder": {
2415
- "variableName": "userId",
2416
- "isEntityId": false,
2417
- "relType": "UserData"
2415
+ "variableName": "webhookId",
2416
+ "isEntityId": true,
2417
+ "relType": "WebhookData"
2418
2418
  },
2419
2419
  "requestBodyType": "WebhookUpdateSchema",
2420
2420
  "optionalRequestBody": false,
@@ -2457,13 +2457,13 @@
2457
2457
  "returnsCollection": false,
2458
2458
  "docUrl": "https://www.datocms.com/docs/content-management-api/resources/webhook/self",
2459
2459
  "rel": "self",
2460
- "urlTemplate": "/webhooks/${userId}",
2460
+ "urlTemplate": "/webhooks/${webhookId}",
2461
2461
  "method": "GET",
2462
2462
  "comment": "Retrieve a webhook",
2463
2463
  "urlPlaceholder": {
2464
- "variableName": "userId",
2465
- "isEntityId": false,
2466
- "relType": "UserData"
2464
+ "variableName": "webhookId",
2465
+ "isEntityId": true,
2466
+ "relType": "WebhookData"
2467
2467
  },
2468
2468
  "optionalRequestBody": false,
2469
2469
  "queryParamsRequired": false,
@@ -2475,13 +2475,13 @@
2475
2475
  "returnsCollection": false,
2476
2476
  "docUrl": "https://www.datocms.com/docs/content-management-api/resources/webhook/destroy",
2477
2477
  "rel": "destroy",
2478
- "urlTemplate": "/webhooks/${userId}",
2478
+ "urlTemplate": "/webhooks/${webhookId}",
2479
2479
  "method": "DELETE",
2480
2480
  "comment": "Delete a webhook",
2481
2481
  "urlPlaceholder": {
2482
- "variableName": "userId",
2483
- "isEntityId": false,
2484
- "relType": "UserData"
2482
+ "variableName": "webhookId",
2483
+ "isEntityId": true,
2484
+ "relType": "WebhookData"
2485
2485
  },
2486
2486
  "optionalRequestBody": false,
2487
2487
  "queryParamsRequired": false,
@@ -3259,7 +3259,6 @@
3259
3259
  "optionalRequestBody": false,
3260
3260
  "requestStructure": {
3261
3261
  "type": "sso_settings",
3262
- "idRequired": true,
3263
3262
  "attributes": [
3264
3263
  "idp_saml_metadata_url",
3265
3264
  "idp_saml_metadata_xml"
@@ -3304,7 +3303,6 @@
3304
3303
  "optionalRequestBody": false,
3305
3304
  "requestStructure": {
3306
3305
  "type": "white_label_settings",
3307
- "idRequired": true,
3308
3306
  "attributes": [
3309
3307
  "custom_i18n_messages_template_url"
3310
3308
  ],
@@ -3484,7 +3482,6 @@
3484
3482
  "optionalRequestBody": false,
3485
3483
  "requestStructure": {
3486
3484
  "type": "site",
3487
- "idRequired": true,
3488
3485
  "attributes": [
3489
3486
  "no_index",
3490
3487
  "favicon",
@@ -0,0 +1,29 @@
1
+ import { v4 } from 'uuid';
2
+ const decoder = new TextDecoder('utf8');
3
+
4
+ function toBase64(bytes: Uint8Array) {
5
+ if (typeof Buffer !== 'undefined') {
6
+ return Buffer.from(bytes).toString('base64');
7
+ }
8
+
9
+ return btoa(decoder.decode(bytes));
10
+ }
11
+
12
+ export function generateId() {
13
+ const bytes = v4(null, new Uint8Array(16));
14
+
15
+ // unset first bit to ensure [A-Za-f] first char
16
+ bytes[0] = bytes[0] & 0x7f;
17
+
18
+ const base64 = toBase64(bytes);
19
+
20
+ return (
21
+ base64
22
+ // Replace + with - (see RFC 4648, sec. 5)
23
+ .replace(/\+/g, '-')
24
+ // Replace / with _ (see RFC 4648, sec. 5)
25
+ .replace(/\//g, '_')
26
+ // Drop '==' padding
27
+ .substring(0, 22)
28
+ );
29
+ }
@@ -135,7 +135,7 @@ export class Client {
135
135
  ...this.config,
136
136
  ...options,
137
137
  logFn: this.config.logFn || console.log,
138
- userAgent: '@datocms/cma-client v3.0.4',
138
+ userAgent: '@datocms/cma-client v3.0.5',
139
139
  baseUrl: this.baseUrl,
140
140
  preCallStack: new Error().stack,
141
141
  extraHeaders: {
@@ -66,12 +66,13 @@ export default class Webhook extends BaseResource {
66
66
  * @throws {TimeoutError}
67
67
  */
68
68
  update(
69
- userId: string | SimpleSchemaTypes.UserData,
69
+ webhookId: string | SimpleSchemaTypes.WebhookData,
70
70
  body: SimpleSchemaTypes.WebhookUpdateSchema,
71
71
  ) {
72
72
  return this.rawUpdate(
73
- Utils.toId(userId),
73
+ Utils.toId(webhookId),
74
74
  Utils.serializeRequestBody<SchemaTypes.WebhookUpdateSchema>(body, {
75
+ id: Utils.toId(webhookId),
75
76
  type: 'webhook',
76
77
  attributes: [
77
78
  'name',
@@ -103,12 +104,12 @@ export default class Webhook extends BaseResource {
103
104
  * @throws {TimeoutError}
104
105
  */
105
106
  rawUpdate(
106
- userId: string,
107
+ webhookId: string,
107
108
  body: SchemaTypes.WebhookUpdateSchema,
108
109
  ): Promise<SchemaTypes.WebhookUpdateTargetSchema> {
109
110
  return this.client.request<SchemaTypes.WebhookUpdateTargetSchema>({
110
111
  method: 'PUT',
111
- url: `/webhooks/${userId}`,
112
+ url: `/webhooks/${webhookId}`,
112
113
  body,
113
114
  });
114
115
  }
@@ -152,8 +153,8 @@ export default class Webhook extends BaseResource {
152
153
  * @throws {ApiError}
153
154
  * @throws {TimeoutError}
154
155
  */
155
- find(userId: string | SimpleSchemaTypes.UserData) {
156
- return this.rawFind(Utils.toId(userId)).then((body) =>
156
+ find(webhookId: string | SimpleSchemaTypes.WebhookData) {
157
+ return this.rawFind(Utils.toId(webhookId)).then((body) =>
157
158
  Utils.deserializeResponseBody<SimpleSchemaTypes.WebhookSelfTargetSchema>(
158
159
  body,
159
160
  ),
@@ -168,10 +169,10 @@ export default class Webhook extends BaseResource {
168
169
  * @throws {ApiError}
169
170
  * @throws {TimeoutError}
170
171
  */
171
- rawFind(userId: string): Promise<SchemaTypes.WebhookSelfTargetSchema> {
172
+ rawFind(webhookId: string): Promise<SchemaTypes.WebhookSelfTargetSchema> {
172
173
  return this.client.request<SchemaTypes.WebhookSelfTargetSchema>({
173
174
  method: 'GET',
174
- url: `/webhooks/${userId}`,
175
+ url: `/webhooks/${webhookId}`,
175
176
  });
176
177
  }
177
178
 
@@ -183,8 +184,8 @@ export default class Webhook extends BaseResource {
183
184
  * @throws {ApiError}
184
185
  * @throws {TimeoutError}
185
186
  */
186
- destroy(userId: string | SimpleSchemaTypes.UserData) {
187
- return this.rawDestroy(Utils.toId(userId)).then((body) =>
187
+ destroy(webhookId: string | SimpleSchemaTypes.WebhookData) {
188
+ return this.rawDestroy(Utils.toId(webhookId)).then((body) =>
188
189
  Utils.deserializeResponseBody<SimpleSchemaTypes.WebhookDestroyTargetSchema>(
189
190
  body,
190
191
  ),
@@ -199,10 +200,12 @@ export default class Webhook extends BaseResource {
199
200
  * @throws {ApiError}
200
201
  * @throws {TimeoutError}
201
202
  */
202
- rawDestroy(userId: string): Promise<SchemaTypes.WebhookDestroyTargetSchema> {
203
+ rawDestroy(
204
+ webhookId: string,
205
+ ): Promise<SchemaTypes.WebhookDestroyTargetSchema> {
203
206
  return this.client.request<SchemaTypes.WebhookDestroyTargetSchema>({
204
207
  method: 'DELETE',
205
- url: `/webhooks/${userId}`,
208
+ url: `/webhooks/${webhookId}`,
206
209
  });
207
210
  }
208
211
  }
package/src/index.ts CHANGED
@@ -4,5 +4,6 @@ export * as Resources from './generated/resources';
4
4
  export type { ClientConfigOptions } from './generated/Client';
5
5
  export * from './buildClient';
6
6
  export * from './buildBlockRecord';
7
+ export * from './generateId';
7
8
  export * as SchemaTypes from './generated/SchemaTypes';
8
9
  export * as SimpleSchemaTypes from './generated/SimpleSchemaTypes';