@agility/management-sdk 0.1.38 → 0.1.40

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,12 +1,21 @@
1
1
  import { Options } from "../models/options";
2
+ import { TokenPagedResult } from "../models/pagedResult";
2
3
  import { Webhook } from "../models/webhook";
4
+ import { WebhookHistory } from "../models/webhookHistory";
3
5
  import { ClientInstance } from "./clientInstance";
4
6
  export declare class WebhookMethods {
5
7
  _options: Options;
6
- _cleintInstance: ClientInstance;
8
+ _clientInstance: ClientInstance;
7
9
  constructor(options: Options);
8
- webhookList(guid: string, take?: number, token?: string): Promise<any>;
10
+ webhookList(guid: string, take?: number, token?: string): Promise<TokenPagedResult<Webhook>>;
9
11
  saveWebhook(guid: string, webhook: Webhook): Promise<any>;
10
12
  getWebhook(guid: string, webhookID: string): Promise<any>;
11
13
  deleteWebhook(guid: string, webhookID: string): Promise<void>;
14
+ getWebhookHistory(guid: string, webhookID: string, options?: {
15
+ fromDate?: string;
16
+ toDate?: string;
17
+ take?: number;
18
+ token?: string;
19
+ }): Promise<TokenPagedResult<WebhookHistory>>;
20
+ rotateWebhookSecret(guid: string, webhookID: string): Promise<Webhook>;
12
21
  }
@@ -38,23 +38,28 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.WebhookMethods = void 0;
40
40
  var exception_1 = require("../models/exception");
41
+ var queryString_1 = require("../util/queryString");
41
42
  var clientInstance_1 = require("./clientInstance");
42
43
  var WebhookMethods = /** @class */ (function () {
43
44
  function WebhookMethods(options) {
44
45
  this._options = options;
45
- this._cleintInstance = new clientInstance_1.ClientInstance(this._options);
46
+ this._clientInstance = new clientInstance_1.ClientInstance(this._options);
46
47
  }
47
48
  WebhookMethods.prototype.webhookList = function (guid_1) {
48
49
  return __awaiter(this, arguments, void 0, function (guid, take, token) {
49
- var apiPath, resp, err_1;
50
+ var queryParams, apiPath, resp, err_1;
50
51
  if (take === void 0) { take = 20; }
51
52
  if (token === void 0) { token = null; }
52
53
  return __generator(this, function (_a) {
53
54
  switch (_a.label) {
54
55
  case 0:
55
56
  _a.trys.push([0, 2, , 3]);
56
- apiPath = "webhook/list";
57
- return [4 /*yield*/, this._cleintInstance.executeGet(apiPath, guid, this._options.token)];
57
+ queryParams = (0, queryString_1.buildQueryString)({
58
+ take: take,
59
+ token: token
60
+ });
61
+ apiPath = "webhook/list".concat(queryParams);
62
+ return [4 /*yield*/, this._clientInstance.executeGet(apiPath, guid, this._options.token)];
58
63
  case 1:
59
64
  resp = _a.sent();
60
65
  return [2 /*return*/, resp.data];
@@ -74,7 +79,7 @@ var WebhookMethods = /** @class */ (function () {
74
79
  case 0:
75
80
  _a.trys.push([0, 2, , 3]);
76
81
  apiPath = "webhook";
77
- return [4 /*yield*/, this._cleintInstance.executePost(apiPath, guid, this._options.token, webhook)];
82
+ return [4 /*yield*/, this._clientInstance.executePost(apiPath, guid, this._options.token, webhook)];
78
83
  case 1:
79
84
  resp = _a.sent();
80
85
  return [2 /*return*/, resp.data];
@@ -94,7 +99,7 @@ var WebhookMethods = /** @class */ (function () {
94
99
  case 0:
95
100
  _a.trys.push([0, 2, , 3]);
96
101
  apiPath = "webhook/".concat(webhookID);
97
- return [4 /*yield*/, this._cleintInstance.executeGet(apiPath, guid, this._options.token)];
102
+ return [4 /*yield*/, this._clientInstance.executeGet(apiPath, guid, this._options.token)];
98
103
  case 1:
99
104
  resp = _a.sent();
100
105
  return [2 /*return*/, resp.data];
@@ -114,7 +119,7 @@ var WebhookMethods = /** @class */ (function () {
114
119
  case 0:
115
120
  _a.trys.push([0, 2, , 3]);
116
121
  apiPath = "webhook/".concat(webhookID);
117
- return [4 /*yield*/, this._cleintInstance.executeDelete(apiPath, guid, this._options.token)];
122
+ return [4 /*yield*/, this._clientInstance.executeDelete(apiPath, guid, this._options.token)];
118
123
  case 1:
119
124
  _a.sent();
120
125
  return [3 /*break*/, 3];
@@ -126,6 +131,52 @@ var WebhookMethods = /** @class */ (function () {
126
131
  });
127
132
  });
128
133
  };
134
+ WebhookMethods.prototype.getWebhookHistory = function (guid, webhookID, options) {
135
+ return __awaiter(this, void 0, void 0, function () {
136
+ var queryParams, apiPath, resp, err_5;
137
+ return __generator(this, function (_a) {
138
+ switch (_a.label) {
139
+ case 0:
140
+ _a.trys.push([0, 2, , 3]);
141
+ queryParams = (0, queryString_1.buildQueryString)({
142
+ fromDate: options === null || options === void 0 ? void 0 : options.fromDate,
143
+ toDate: options === null || options === void 0 ? void 0 : options.toDate,
144
+ take: options === null || options === void 0 ? void 0 : options.take,
145
+ token: options === null || options === void 0 ? void 0 : options.token
146
+ });
147
+ apiPath = "webhook/".concat(webhookID, "/history").concat(queryParams);
148
+ return [4 /*yield*/, this._clientInstance.executeGet(apiPath, guid, this._options.token)];
149
+ case 1:
150
+ resp = _a.sent();
151
+ return [2 /*return*/, resp.data];
152
+ case 2:
153
+ err_5 = _a.sent();
154
+ throw new exception_1.Exception("Unable to retrieve webhook history for webhookID: ".concat(webhookID, "."), err_5);
155
+ case 3: return [2 /*return*/];
156
+ }
157
+ });
158
+ });
159
+ };
160
+ WebhookMethods.prototype.rotateWebhookSecret = function (guid, webhookID) {
161
+ return __awaiter(this, void 0, void 0, function () {
162
+ var apiPath, resp, err_6;
163
+ return __generator(this, function (_a) {
164
+ switch (_a.label) {
165
+ case 0:
166
+ _a.trys.push([0, 2, , 3]);
167
+ apiPath = "webhook/".concat(webhookID, "/rotate-secret");
168
+ return [4 /*yield*/, this._clientInstance.executePost(apiPath, guid, this._options.token, null)];
169
+ case 1:
170
+ resp = _a.sent();
171
+ return [2 /*return*/, resp.data];
172
+ case 2:
173
+ err_6 = _a.sent();
174
+ throw new exception_1.Exception("Unable to rotate the signing secret for webhookID: ".concat(webhookID, "."), err_6);
175
+ case 3: return [2 /*return*/];
176
+ }
177
+ });
178
+ });
179
+ };
129
180
  return WebhookMethods;
130
181
  }());
131
182
  exports.WebhookMethods = WebhookMethods;
package/dist/index.d.ts CHANGED
@@ -16,6 +16,8 @@ export * from "./models/notification";
16
16
  export * from "./models/pageItem";
17
17
  export * from "./models/pagedResult";
18
18
  export * from "./models/sitemap";
19
+ export * from "./models/webhook";
20
+ export * from "./models/webhookHistory";
19
21
  export * from "./models/websiteUser";
20
22
  export * from "./models/assetContainer";
21
23
  export * from "./models/assetGalleries";
package/dist/index.js CHANGED
@@ -32,6 +32,8 @@ __exportStar(require("./models/notification"), exports);
32
32
  __exportStar(require("./models/pageItem"), exports);
33
33
  __exportStar(require("./models/pagedResult"), exports);
34
34
  __exportStar(require("./models/sitemap"), exports);
35
+ __exportStar(require("./models/webhook"), exports);
36
+ __exportStar(require("./models/webhookHistory"), exports);
35
37
  __exportStar(require("./models/websiteUser"), exports);
36
38
  __exportStar(require("./models/assetContainer"), exports);
37
39
  __exportStar(require("./models/assetGalleries"), exports);
@@ -1,4 +1,8 @@
1
1
  export declare class Exception extends Error {
2
2
  constructor(message: string, inner?: Error);
3
3
  innerError?: Error;
4
+ /** HTTP status code from the underlying response, when available. */
5
+ statusCode?: number;
6
+ /** Raw response body from the underlying response, when available. */
7
+ responseData?: unknown;
4
8
  }
@@ -19,8 +19,24 @@ exports.Exception = void 0;
19
19
  var Exception = /** @class */ (function (_super) {
20
20
  __extends(Exception, _super);
21
21
  function Exception(message, inner) {
22
- var _this = _super.call(this, message) || this;
22
+ var _this = this;
23
+ var _a, _b, _c, _d;
24
+ var anyErr = inner;
25
+ var status = (_a = anyErr === null || anyErr === void 0 ? void 0 : anyErr.response) === null || _a === void 0 ? void 0 : _a.status;
26
+ var data = (_b = anyErr === null || anyErr === void 0 ? void 0 : anyErr.response) === null || _b === void 0 ? void 0 : _b.data;
27
+ var detail = data
28
+ ? (typeof data === "string"
29
+ ? data
30
+ : ((_d = (_c = data.exceptionMessage) !== null && _c !== void 0 ? _c : data.message) !== null && _d !== void 0 ? _d : JSON.stringify(data)))
31
+ : anyErr === null || anyErr === void 0 ? void 0 : anyErr.message;
32
+ // Surface the server's status + response body in the message. The Management API
33
+ // (and other callers) only read Error.message, so folding the response detail in here
34
+ // turns an opaque "Unable to save the container" into
35
+ // "Unable to save the container (HTTP 500): <server message>".
36
+ _this = _super.call(this, detail ? "".concat(message).concat(status ? " (HTTP ".concat(status, ")") : "", ": ").concat(detail) : message) || this;
23
37
  _this.innerError = inner;
38
+ _this.statusCode = status;
39
+ _this.responseData = data;
24
40
  return _this;
25
41
  }
26
42
  return Exception;
@@ -2,3 +2,7 @@ export interface PagedResult<T> {
2
2
  totalCount: number;
3
3
  items: T[];
4
4
  }
5
+ export interface TokenPagedResult<T> {
6
+ token: string | null;
7
+ items: T[];
8
+ }
@@ -1,4 +1,8 @@
1
1
  export declare class Webhook {
2
+ partitionKey: string | null;
3
+ rowKey: string | null;
4
+ timestamp?: string | null;
5
+ eTag?: string | null;
2
6
  name: string | null;
3
7
  url: string | null;
4
8
  instanceGuid: string | null;
@@ -6,4 +10,17 @@ export declare class Webhook {
6
10
  contentWorkflowEvents: boolean;
7
11
  contentPublishEvents: boolean;
8
12
  contentSaveEvents: boolean;
13
+ secureDeliveryEnabled: boolean;
14
+ signingSecret: string | null;
15
+ previousSigningSecret: string | null;
16
+ secretRolledUtc: string | null;
17
+ retriesEnabled: boolean;
18
+ retryCount: number;
19
+ retrySpeed: "fast" | "standard" | "slow" | null;
20
+ /**
21
+ * Set only on a `saveWebhook` response, and only when that save is what minted `signingSecret`
22
+ * (the first save with `secureDeliveryEnabled` on). Use it to surface the new secret once — it is
23
+ * never stored on the webhook, so a `getWebhook` response never has it.
24
+ */
25
+ signingSecretJustCreated?: boolean;
9
26
  }
@@ -0,0 +1,32 @@
1
+ export declare class WebhookHistory {
2
+ partitionKey: string | null;
3
+ rowKey: string | null;
4
+ queuedDate: string | null;
5
+ sendDate: string | null;
6
+ url: string | null;
7
+ instanceGuid: string | null;
8
+ contentWorkflowEvent: boolean;
9
+ contentPublishEvent: boolean;
10
+ contentSaveEvent: boolean;
11
+ payload: string | null;
12
+ httpResponseCode: number | null;
13
+ success: boolean;
14
+ responseText: string | null;
15
+ webhookRowKey: string | null;
16
+ eventKey: string | null;
17
+ attemptCount: number;
18
+ lastAttemptDate: string | null;
19
+ nextAttemptUtc: string | null;
20
+ lastError: string | null;
21
+ /**
22
+ * Whether the last attempt was sent with Standard Webhooks signature headers, as recorded at send
23
+ * time. `null` means no record — the delivery has not been attempted yet, or the row predates the
24
+ * field. This is the fact at delivery time, not the webhook's current `secureDeliveryEnabled`.
25
+ */
26
+ signed: boolean | null;
27
+ /**
28
+ * Signatures sent in the `webhook-signature` header on the last attempt: 0 unsigned, 1 normally,
29
+ * 2 during the 24-hour grace window after a secret roll.
30
+ */
31
+ signatureKeyCount: number;
32
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebhookHistory = void 0;
4
+ var WebhookHistory = /** @class */ (function () {
5
+ function WebhookHistory() {
6
+ }
7
+ return WebhookHistory;
8
+ }());
9
+ exports.WebhookHistory = WebhookHistory;