@forge/events
2.0.152.0.15-experimental-e9a12c2
+
Added (3 files)
~
Modified (22 files)
Index: package/out/errors.js
===================================================================
--- package/out/errors.js
+++ package/out/errors.js
@@ -1,7 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.InvocationLimitReachedError = exports.JobDoesNotExistError = exports.InternalServerError = exports.PartialSuccessError = exports.RateLimitError = exports.NoEventsToPushError = exports.PayloadTooBigError = exports.TooManyEventsError = exports.InvalidPayloadError = exports.InvalidQueueNameError = exports.InvalidPushSettingsError = exports.EventsError = void 0;
+exports.InvocationLimitReachedError = exports.JobDoesNotExistError = exports.InternalServerError = exports.PartialSuccessError = exports.InvalidEventIdError = exports.InvalidGroupIdError = exports.RateLimitError = exports.NoEventsToPushError = exports.PayloadTooBigError = exports.TooManyEventsError = exports.InvalidPayloadError = exports.InvalidQueueNameError = exports.InvalidPushSettingsError = exports.EventsError = void 0;
class EventsError extends Error {
constructor(message) {
super(message);
}
@@ -27,8 +27,14 @@
exports.NoEventsToPushError = NoEventsToPushError;
class RateLimitError extends EventsError {
}
exports.RateLimitError = RateLimitError;
+class InvalidGroupIdError extends EventsError {
+}
+exports.InvalidGroupIdError = InvalidGroupIdError;
+class InvalidEventIdError extends EventsError {
+}
+exports.InvalidEventIdError = InvalidEventIdError;
class PartialSuccessError extends EventsError {
result;
failedEvents;
constructor(message, result, failedEvents) { Index: package/out/index.js
===================================================================
--- package/out/index.js
+++ package/out/index.js
@@ -1,9 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.appEvents = exports.InvocationErrorCode = exports.InvocationError = exports.QueueResponse = exports.JobProgress = exports.InvocationLimitReachedError = exports.InvalidPushSettingsError = exports.JobDoesNotExistError = exports.InternalServerError = exports.PartialSuccessError = exports.RateLimitError = exports.NoEventsToPushError = exports.PayloadTooBigError = exports.TooManyEventsError = exports.InvalidQueueNameError = exports.Queue = void 0;
+exports.appEvents = exports.InvocationErrorCode = exports.InvocationError = exports.QueueResponse = exports.JobProgress = exports.InvocationLimitReachedError = exports.InvalidPushSettingsError = exports.JobDoesNotExistError = exports.InternalServerError = exports.PartialSuccessError = exports.RateLimitError = exports.NoEventsToPushError = exports.PayloadTooBigError = exports.TooManyEventsError = exports.InvalidQueueNameError = exports.FifoQueue = exports.Queue = void 0;
var queue_1 = require("./queue");
Object.defineProperty(exports, "Queue", { enumerable: true, get: function () { return queue_1.Queue; } });
+var fifoQueue_1 = require("./fifoQueue");
+Object.defineProperty(exports, "FifoQueue", { enumerable: true, get: function () { return fifoQueue_1.FifoQueue; } });
var errors_1 = require("./errors");
Object.defineProperty(exports, "InvalidQueueNameError", { enumerable: true, get: function () { return errors_1.InvalidQueueNameError; } });
Object.defineProperty(exports, "TooManyEventsError", { enumerable: true, get: function () { return errors_1.TooManyEventsError; } });
Object.defineProperty(exports, "PayloadTooBigError", { enumerable: true, get: function () { return errors_1.PayloadTooBigError; } }); Index: package/out/queries.js
===================================================================
--- package/out/queries.js
+++ package/out/queries.js
@@ -1,10 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.post = exports.CANCEL_JOB_PATH = exports.GET_STATS_PATH = exports.PUSH_PATH = void 0;
+exports.post = exports.PUSH_FIFO_PATH = exports.CANCEL_JOB_PATH = exports.GET_STATS_PATH = exports.PUSH_PATH = void 0;
exports.PUSH_PATH = '/webhook/queue/publish/{contextAri}/{environmentId}/{appId}/{appVersion}';
exports.GET_STATS_PATH = '/webhook/queue/stats/{contextAri}/{environmentId}/{appId}/{appVersion}';
exports.CANCEL_JOB_PATH = '/webhook/queue/cancel/{contextAri}/{environmentId}/{appId}/{appVersion}';
+exports.PUSH_FIFO_PATH = '/forge/events/v1/forge-fifo-events';
const post = async (endpoint, body, apiClient) => {
const request = {
method: 'POST',
body: JSON.stringify(body), Index: package/out/queue.js
===================================================================
--- package/out/queue.js
+++ package/out/queue.js
@@ -11,28 +11,57 @@
apiClient;
constructor(queueParams, apiClient = api_1.__requestAtlassianAsApp) {
this.queueParams = queueParams;
this.apiClient = apiClient;
+ this.validate();
+ }
+ validate() {
(0, validators_1.validateQueueKey)(this.queueParams.key);
}
+ isFifo() {
+ return false;
+ }
+ getEndpoint() {
+ return queries_1.PUSH_PATH;
+ }
async push(events) {
- const validEvents = (0, validators_1.validatePushEvents)(events);
+ const validEvents = (0, validators_1.validatePushEvents)(events, this.isFifo());
const queueName = this.queueParams.key;
const jobId = (0, uuid_1.v4)();
- const pushRequest = {
- queueName: queueName,
- jobId: jobId,
- type: 'avi:forge:app:event',
- schema: 'ari:cloud:ecosystem::forge/app-event-2',
- payload: validEvents,
- time: new Date().toISOString()
- };
- const response = await (0, queries_1.post)(queries_1.PUSH_PATH, pushRequest, this.apiClient);
+ const pushRequest = this.populatePayload(queueName, jobId, validEvents);
+ const endpoint = this.getEndpoint();
+ const response = await (0, queries_1.post)(endpoint, pushRequest, this.apiClient);
const result = { jobId };
- await (0, validators_1.validatePushAPIResponse)(pushRequest, response, result);
+ if (this.isFifo()) {
+ return await (0, validators_1.validateFifoResponse)(pushRequest, response);
+ }
+ else {
+ await (0, validators_1.validatePushAPIResponse)(pushRequest, response, result);
+ }
return result;
}
getJob(jobId) {
return new jobProgress_1.JobProgress(this.queueParams, jobId, this.apiClient);
}
+ populatePayload(queueName, jobId, validEvents) {
+ if (this.isFifo()) {
+ validEvents.forEach((event) => {
+ event.queueName = queueName;
+ });
+ return {
+ events: validEvents,
+ queueName: queueName,
+ jobId: jobId,
+ time: new Date().toISOString()
+ };
+ }
+ return {
+ queueName,
+ jobId,
+ type: 'avi:forge:app:event',
+ schema: 'ari:cloud:ecosystem::forge/app-event-2',
+ payload: validEvents,
+ time: new Date().toISOString()
+ };
+ }
}
exports.Queue = Queue; Index: package/out/text.js
===================================================================
--- package/out/text.js
+++ package/out/text.js
@@ -3,13 +3,15 @@
exports.Text = void 0;
exports.Text = {
error: {
invalidQueueName: `Queue names can only contain alphanumeric characters, dashes and underscores.`,
+ queueNameExceedingMaxLimit: `Queue names for Fifo queues must be within 36 characters`,
invalidEvent: `Event must be an object.`,
invalidEventBody: `Event body must be an object.`,
invalidDelayInSecondsSetting: `The delayInSeconds setting must be between 0 and 900.`,
maxEventsAllowed: (maxEventsCount) => `This push contains more than the ${maxEventsCount} events allowed.`,
maxPayloadAllowed: (maxPayloadSize) => `The maximum payload size is ${maxPayloadSize}KB.`,
+ invalidEventId: `Event id for Fifo queues must not be null and within 36 characters`,
noEventsPushed: `No events pushed.`,
rateLimitError: `Too many requests.`,
invocationLimitReachedError: `The limit on cyclic invocation has been reached.`,
jobIdEmpty: `jobId cannot be empty.`, Index: package/out/validators.js
===================================================================
--- package/out/validators.js
+++ package/out/validators.js
@@ -1,48 +1,69 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.validateCancelJobAPIResponse = exports.validateGetStatsAPIResponse = exports.validatePushAPIResponse = exports.validateAPIResponse = exports.validateCancelJobRequest = exports.validateGetStatsPayload = exports.validatePushEvents = exports.validatePushSettings = exports.validateQueueKey = void 0;
+exports.validateCancelJobAPIResponse = exports.validateGetStatsAPIResponse = exports.validatePushAPIResponse = exports.validateFifoResponse = exports.validateAPIResponse = exports.validateCancelJobRequest = exports.validateGetStatsPayload = exports.validatePushEvents = exports.validatePushSettings = exports.validateQueueKeyLength = exports.validateQueueKey = void 0;
const errors_1 = require("./errors");
const text_1 = require("./text");
const VALID_QUEUE_NAME_PATTERN = /^[a-zA-Z0-9-_]+$/;
const MAXIMUM_EVENTS = 50;
+const MAXIMUM_EVENTS_FIFO = 10;
const MAXIMUM_PAYLOAD_SIZE_KB = 200;
const validateQueueKey = (queueName) => {
if (!queueName || !VALID_QUEUE_NAME_PATTERN.test(queueName)) {
throw new errors_1.InvalidQueueNameError(text_1.Text.error.invalidQueueName);
}
};
exports.validateQueueKey = validateQueueKey;
+const validateQueueKeyLength = (queueName) => {
+ if (queueName.length > 36) {
+ throw new errors_1.InvalidQueueNameError(text_1.Text.error.queueNameExceedingMaxLimit);
+ }
+};
+exports.validateQueueKeyLength = validateQueueKeyLength;
const validatePushSettings = (event) => {
if ((event.delayInSeconds && event.delayInSeconds > 900) || (event.delayInSeconds && event.delayInSeconds < 0)) {
throw new errors_1.InvalidPushSettingsError(text_1.Text.error.invalidDelayInSecondsSetting);
}
};
exports.validatePushSettings = validatePushSettings;
-function validatePushEvents(arg) {
+function validatePushEvents(arg, isFifo) {
const events = Array.isArray(arg) ? arg : [arg];
if (events.length === 0) {
throw new errors_1.NoEventsToPushError(text_1.Text.error.noEventsPushed);
}
- if (events.length > MAXIMUM_EVENTS) {
- throw new errors_1.TooManyEventsError(text_1.Text.error.maxEventsAllowed(MAXIMUM_EVENTS));
+ const maxAllowed = isFifo ? MAXIMUM_EVENTS_FIFO : MAXIMUM_EVENTS;
+ if (events.length > maxAllowed) {
+ throw new errors_1.TooManyEventsError(text_1.Text.error.maxEventsAllowed(maxAllowed));
}
for (const event of events) {
if (typeof event !== 'object' || Array.isArray(event) || event === null) {
throw new errors_1.InvalidPayloadError(text_1.Text.error.invalidEvent);
}
if (typeof event.body !== 'object' || Array.isArray(event.body) || event.body === null) {
throw new errors_1.InvalidPayloadError(text_1.Text.error.invalidEventBody);
}
- (0, exports.validatePushSettings)(event);
+ if (!isFifo) {
+ (0, exports.validatePushSettings)(event);
+ }
}
const payloadSizeKB = Buffer.byteLength(JSON.stringify(events)) / 1024;
if (payloadSizeKB > MAXIMUM_PAYLOAD_SIZE_KB) {
throw new errors_1.PayloadTooBigError(text_1.Text.error.maxPayloadAllowed(MAXIMUM_PAYLOAD_SIZE_KB));
}
+ if (isFifo) {
+ validateFifoEvents(events);
+ }
return events;
}
exports.validatePushEvents = validatePushEvents;
+function validateFifoEvents(events) {
+ if (!allEventsHaveValidEventId(events)) {
+ throw new errors_1.InvalidEventIdError(text_1.Text.error.invalidEventId);
+ }
+}
+function allEventsHaveValidEventId(events) {
+ return events.every((event) => event.eventId?.trim().length <= 36);
+}
const validateGetStatsPayload = (getStatsRequest) => {
if (!getStatsRequest.jobId) {
throw new errors_1.JobDoesNotExistError(text_1.Text.error.jobIdEmpty);
}
@@ -77,8 +98,22 @@
throw internalServerError;
}
};
exports.validateAPIResponse = validateAPIResponse;
+const validateFifoResponse = async (requestBody, response) => {
+ if (!response.ok) {
+ return {
+ type: 'error',
+ errorMessage: response.statusText,
+ status: response.status
+ };
+ }
+ return {
+ type: 'success',
+ status: response.status
+ };
+};
+exports.validateFifoResponse = validateFifoResponse;
const validatePushAPIResponse = async (requestBody, response, result) => {
if (response.status === 413) {
const responseBody = await response.json();
throw new errors_1.PayloadTooBigError(responseBody.errorMessage);
@@ -91,9 +126,9 @@
partialSuccessError.message = `Failed to process ${responseBody.failedEvents.length} event(s).`;
partialSuccessError.failedEvents = responseBody.failedEvents.map((failedEvent) => {
return {
errorMessage: failedEvent.errorMessage,
- payload: requestBody.payload[+failedEvent.index]
+ payload: requestBody.payload != null && requestBody.payload[+failedEvent.index]
};
});
}
if (responseBody.errorMessage) { Index: package/package.json
===================================================================
--- package/package.json
+++ package/package.json
@@ -1,7 +1,7 @@
{
"name": "@forge/events",
- "version": "2.0.15",
+ "version": "2.0.15-experimental-e9a12c2",
"description": "Forge Async Event methods",
"author": "Atlassian",
"license": "SEE LICENSE IN LICENSE.txt",
"main": "out/index.js", Index: package/out/errors.d.ts.map
===================================================================
--- package/out/errors.d.ts.map
+++ package/out/errors.d.ts.map
@@ -1,1 +1,1 @@
-{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAElD,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,wBAAyB,SAAQ,WAAW;CAAG;AAE5D,qBAAa,qBAAsB,SAAQ,WAAW;CAAG;AAEzD,qBAAa,mBAAoB,SAAQ,WAAW;CAAG;AAEvD,qBAAa,kBAAmB,SAAQ,WAAW;CAAG;A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E,WAAW,EAAE;gBAFlC,OAAO,EAAE,MAAM,EACR,MAAM,EAAE,UAAU,EAClB,YAAY,EAAE,WAAW,EAAE;CAIrC;AAED,qBAAa,mBAAoB,SAAQ,WAAW;gBACtC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;IAMjE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,oBAAqB,SAAQ,WAAW;CAAG;AAExD,qBAAa,2BAA4B,SAAQ,WAAW;CAAG"}
\ No newline at end of file Index: package/out/index.d.ts.map
===================================================================
--- package/out/index.d.ts.map
+++ package/out/index.d.ts.map
@@ -1,1 +1,1 @@
-{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,2BAA2B,EAC5B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EACL,SAAS,EACT,QAAQ,EACR,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,aAAa,CAAC"}
\ No newline at end of file
+{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,2BAA2B,EAC5B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EACL,SAAS,EACT,QAAQ,EACR,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,aAAa,CAAC"}
\ No newline at end of file Index: package/out/queries.d.ts.map
===================================================================
--- package/out/queries.d.ts.map
+++ package/out/queries.d.ts.map
@@ -1,1 +1,1 @@
-{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEtD,eAAO,MAAM,SAAS,6EAA6E,CAAC;AACpG,eAAO,MAAM,cAAc,2EAA2E,CAAC;AACvG,eAAO,MAAM,eAAe,4EAA4E,CAAC;AAEzG,eAAO,MAAM,IAAI,aAAoB,MAAM,QAAQ,OAAO,aAAa,WAAW,KAAG,QAAQ,WAAW,CAUvG,CAAC"}
\ No newline at end of file
+{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEtD,eAAO,MAAM,SAAS,6EAA6E,CAAC;AACpG,eAAO,MAAM,cAAc,2EAA2E,CAAC;AACvG,eAAO,MAAM,eAAe,4EAA4E,CAAC;AACzG,eAAO,MAAM,cAAc,uCAAuC,CAAC;AAEnE,eAAO,MAAM,IAAI,aAAoB,MAAM,QAAQ,OAAO,aAAa,WAAW,KAAG,QAAQ,WAAW,CAUvG,CAAC"}
\ No newline at end of file Index: package/out/queue.d.ts.map
===================================================================
--- package/out/queue.d.ts.map
+++ package/out/queue.d.ts.map
@@ -1,1 +1,1 @@
-{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA2B,MAAM,YAAY,CAAC;AAGlE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAe,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1E,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,qBAAa,KAAK;IAEd,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,SAAS;gBADT,WAAW,EAAE,WAAW,EACxB,SAAS,GAAE,WAAqC;IAK7D,IAAI,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;IAoBhE,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW;CAGnC"}
\ No newline at end of file
+{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,WAAW,EAAE,MAAM,YAAY,CAAC;AAGlE,OAAO,EACL,SAAS,EACT,aAAa,EAEb,cAAc,EAEd,UAAU,EACV,WAAW,EACZ,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,qBAAa,KAAK;IAEd,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW;IAC3C,OAAO,CAAC,QAAQ,CAAC,SAAS;gBADP,WAAW,EAAE,WAAW,EAC1B,SAAS,GAAE,WAAqC;IAKnE,SAAS,CAAC,QAAQ,IAAI,IAAI;IAI1B,SAAS,CAAC,MAAM,IAAI,OAAO;IAI3B,SAAS,CAAC,WAAW,IAAI,MAAM;IAIzB,IAAI,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,EAAE,GAAG,aAAa,GAAG,aAAa,EAAE,GAAG,OAAO,CAAC,UAAU,GAAG,cAAc,CAAC;IAgBnH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW;IAIlC,OAAO,CAAC,eAAe;CAyBxB"}
\ No newline at end of file Index: package/out/text.d.ts.map
===================================================================
--- package/out/text.d.ts.map
+++ package/out/text.d.ts.map
@@ -1,1 +1,1 @@
-{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI;;;;;;2CAMsB,MAAM,KAAG,MAAM;4CAEd,MAAM,KAAG,MAAM;;;;;gCAK3B,MAAM,aAAa,MAAM,KAAG,MAAM;;CAG7D,CAAC"}
\ No newline at end of file
+{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI;;;;;;;2CAOsB,MAAM,KAAG,MAAM;4CAEd,MAAM,KAAG,MAAM;;;;;;gCAM3B,MAAM,aAAa,MAAM,KAAG,MAAM;;CAG7D,CAAC"}
\ No newline at end of file Index: package/out/types.d.ts.map
===================================================================
--- package/out/types.d.ts.map
+++ package/out/types.d.ts.map
@@ -1,1 +1,1 @@
-{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"m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W,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,SAAS,GAAG,aAAa,CAAC;CAClC;AAED,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,GAAG,CAAC;IACf,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,oBAAY,eAAe,GAAG,UAAU,CAAC;AACzC,oBAAY,gBAAgB,GAAG,UAAU,CAAC"}
\ No newline at end of file Index: package/out/validators.d.ts.map
===================================================================
--- package/out/validators.d.ts.map
+++ package/out/validators.d.ts.map
@@ -1,1 +1,1 @@
-{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAezC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAMhG,eAAO,MAAM,gBAAgB,cAAe,MAAM,SAIjD,CAAC;AAEF,eAAO,MAAM,oBAAoB,UAAW,SAAS,SAIpD,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,SAAS,GAAG,SAAS,EAAE,GAAG,SAAS,EAAE,CA6B5E;AAED,eAAO,MAAM,uBAAuB,oBAAqB,eAAe,SAKvE,CAAC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AU,kBAmCnB,CAAC;AAEF,eAAO,MAAM,2BAA2B,aAAoB,WAAW,mBAAmB,eAAe,kBAMxG,CAAC;AAEF,eAAO,MAAM,4BAA4B,aAAoB,WAAW,oBAAoB,eAAe,kBAM1G,CAAC"}
\ No newline at end of file Index: package/CHANGELOG.md
===================================================================
--- package/CHANGELOG.md
+++ package/CHANGELOG.md
@@ -1,6 +1,12 @@
# @forge/events
+## 2.0.15-experimental-e9a12c2
+
+### Minor Changes
+
+- e9a12c2: Changeset
+
## 2.0.15
### Patch Changes Index: package/out/errors.d.ts
===================================================================
--- package/out/errors.d.ts
+++ package/out/errors.d.ts
@@ -15,8 +15,12 @@
export declare class NoEventsToPushError extends EventsError {
}
export declare class RateLimitError extends EventsError {
}
+export declare class InvalidGroupIdError extends EventsError {
+}
+export declare class InvalidEventIdError extends EventsError {
+}
export declare class PartialSuccessError extends EventsError {
result: PushResult;
failedEvents: FailedEvent[];
constructor(message: string, result: PushResult, failedEvents: FailedEvent[]); Index: package/out/index.d.ts
===================================================================
--- package/out/index.d.ts
+++ package/out/index.d.ts
@@ -1,5 +1,6 @@
export { Queue } from './queue';
+export { FifoQueue } from './fifoQueue';
export { InvalidQueueNameError, TooManyEventsError, PayloadTooBigError, NoEventsToPushError, RateLimitError, PartialSuccessError, InternalServerError, JobDoesNotExistError, InvalidPushSettingsError, InvocationLimitReachedError } from './errors';
export { JobProgress, JobStats } from './jobProgress';
export { QueueResponse } from './queueResponse';
export { InvocationError } from './invocationError'; Index: package/out/queries.d.ts
===================================================================
--- package/out/queries.d.ts
+++ package/out/queries.d.ts
@@ -1,6 +1,7 @@
import { APIResponse, FetchMethod } from '@forge/api';
export declare const PUSH_PATH = "/webhook/queue/publish/{contextAri}/{environmentId}/{appId}/{appVersion}";
export declare const GET_STATS_PATH = "/webhook/queue/stats/{contextAri}/{environmentId}/{appId}/{appVersion}";
export declare const CANCEL_JOB_PATH = "/webhook/queue/cancel/{contextAri}/{environmentId}/{appId}/{appVersion}";
+export declare const PUSH_FIFO_PATH = "/forge/events/v1/forge-fifo-events";
export declare const post: (endpoint: string, body: unknown, apiClient: FetchMethod) => Promise<APIResponse>;
//# sourceMappingURL=queries.d.ts.map
\ No newline at end of file Index: package/out/queue.d.ts
===================================================================
--- package/out/queue.d.ts
+++ package/out/queue.d.ts
@@ -1,11 +1,15 @@
import { FetchMethod } from '@forge/api';
-import { QueueParams, PushEvent, PushResult } from './types';
+import { PushEvent, PushFifoEvent, PushFifoResult, PushResult, QueueParams } from './types';
import { JobProgress } from './jobProgress';
export declare class Queue {
- private readonly queueParams;
+ protected readonly queueParams: QueueParams;
private readonly apiClient;
constructor(queueParams: QueueParams, apiClient?: FetchMethod);
- push(events: PushEvent | PushEvent[]): Promise<PushResult>;
+ protected validate(): void;
+ protected isFifo(): boolean;
+ protected getEndpoint(): string;
+ push(events: PushEvent | PushEvent[] | PushFifoEvent | PushFifoEvent[]): Promise<PushResult | PushFifoResult>;
getJob(jobId: string): JobProgress;
+ private populatePayload;
}
//# sourceMappingURL=queue.d.ts.map
\ No newline at end of file Index: package/out/text.d.ts
===================================================================
--- package/out/text.d.ts
+++ package/out/text.d.ts
@@ -1,12 +1,14 @@
export declare const Text: {
error: {
invalidQueueName: string;
+ queueNameExceedingMaxLimit: string;
invalidEvent: string;
invalidEventBody: string;
invalidDelayInSecondsSetting: string;
maxEventsAllowed: (maxEventsCount: number) => string;
maxPayloadAllowed: (maxPayloadSize: number) => string;
+ invalidEventId: string;
noEventsPushed: string;
rateLimitError: string;
invocationLimitReachedError: string;
jobIdEmpty: string; Index: package/out/types.d.ts
===================================================================
--- package/out/types.d.ts
+++ package/out/types.d.ts
@@ -7,8 +7,12 @@
schema: string;
type: string;
jobId: string;
}
+export interface PushFifoRequest extends APIRequest {
+ events: PushFifoEvent[];
+ payload?: PushFifoEvent[];
+}
export interface APIRequest {
queueName: string;
jobId: string;
time: string;
@@ -17,19 +21,29 @@
body: Body;
delayInSeconds?: number;
concurrency?: Concurrency;
}
+export interface PushFifoEvent {
+ body: Body;
+ queueName: string;
+ eventId: string;
+ groupId: string;
+}
export declare type Body = Record<string, unknown>;
export interface Concurrency {
key: string;
limit: number;
}
export interface PushResult {
jobId: string;
}
+export interface PushFifoResult {
+ type: string;
+ errorMessage?: string;
+}
export interface FailedEvent {
errorMessage: string;
- event: PushEvent;
+ event: PushEvent | PushFifoEvent;
}
export interface AsyncEvent extends PushEvent {
queueName: string;
jobId: string; Index: package/out/validators.d.ts
===================================================================
--- package/out/validators.d.ts
+++ package/out/validators.d.ts
@@ -1,12 +1,22 @@
import { APIResponse } from '@forge/api';
-import { CancelJobRequest, GetStatsRequest, PushEvent, PushRequest, PushResult } from './types';
+import { CancelJobRequest, GetStatsRequest, PushEvent, PushFifoEvent, PushFifoRequest, PushRequest, PushResult } from './types';
export declare const validateQueueKey: (queueName: string) => void;
+export declare const validateQueueKeyLength: (queueName: string) => void;
export declare const validatePushSettings: (event: PushEvent) => void;
-export declare function validatePushEvents(arg: PushEvent | PushEvent[]): PushEvent[];
+export declare function validatePushEvents(arg: PushEvent | PushEvent[] | PushFifoEvent | PushFifoEvent[], isFifo: boolean): PushEvent[] | PushFifoEvent[];
export declare const validateGetStatsPayload: (getStatsRequest: GetStatsRequest) => void;
export declare const validateCancelJobRequest: (cancelJobRequest: CancelJobRequest) => void;
export declare const validateAPIResponse: (response: APIResponse, expectedSuccessStatus: number) => Promise<void>;
-export declare const validatePushAPIResponse: (requestBody: PushRequest, response: APIResponse, result: PushResult) => Promise<void>;
+export declare const validateFifoResponse: (requestBody: PushFifoRequest, response: APIResponse) => Promise<{
+ type: string;
+ errorMessage: string;
+ status: number;
+} | {
+ type: string;
+ status: number;
+ errorMessage?: undefined;
+}>;
+export declare const validatePushAPIResponse: (requestBody: PushRequest | PushFifoRequest, response: APIResponse, result: PushResult) => Promise<void>;
export declare const validateGetStatsAPIResponse: (response: APIResponse, getStatsRequest: GetStatsRequest) => Promise<void>;
export declare const validateCancelJobAPIResponse: (response: APIResponse, cancelJobRequest: GetStatsRequest) => Promise<void>;
//# sourceMappingURL=validators.d.ts.map
\ No newline at end of file