@envoy/envoy-integrations-sdk 2.5.3 → 2.5.7

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/README.md CHANGED
@@ -211,6 +211,8 @@ res.sendOngoing("We're still working on it.", { hello: 'world' }); // the job is
211
211
  // or
212
212
  res.sendIgnored("We're not gonna do this one, sorry.", { hello: 'world' }); // doesnt meet the requirements to continue.
213
213
  // or
214
+ res.sendHiddenIgnored('No relevant fields changed.'); // ignored, and hidden from dashboard activity.
215
+ // or
214
216
  res.sendFailed('We tried, but failed.', { hello: 'world' }); // we cant continue with this job.
215
217
 
216
218
  /**
package/dist/index.d.ts CHANGED
@@ -48,6 +48,8 @@ export * from './sdk/filters';
48
48
  export * from './sdk/handlers';
49
49
  export * from './sdk/loggers';
50
50
  export * from './sdk/middleware';
51
+ export { HIDDEN_JOB_ATTACHMENT_TYPE, hiddenJobAttachment } from './sdk/EnvoyPluginJobAttachment';
52
+ export type { EnvoyPluginHiddenJobAttachment } from './sdk/EnvoyPluginJobAttachment';
51
53
  export * from './util/EnvoySignatureVerifier';
52
54
  export * from './util/axiosConstructor';
53
55
  export * from './util/errorHandling';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAErB,OAAO,0BAA0B,MAAM,mCAAmC,CAAC;AAE3E,OAAO,qBAAqB,MAAM,mCAAmC,CAAC;AACtE,OAAO,gBAAgB,MAAM,8BAA8B,CAAC;AAC5D,OAAO,sBAAsB,MAAM,oCAAoC,CAAC;AACxE,OAAO,gBAAgB,MAAM,8BAA8B,CAAC;AAE5D,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAE/C,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAC5D,OAAO,8BAA8B,MAAM,wCAAwC,CAAC;AAEpF,OAAO,YAAY,MAAM,yBAAyB,CAAC;AACnD,OAAO,aAAa,MA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AO,EACL,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,SAAS,EACT,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,0BAA0B,EAC1B,8BAA8B,EAC9B,YAAY,EACZ,aAAa,EACb,sBAAsB,EACtB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,gCAAgC,EAChC,WAAW,EACX,eAAe,EACf,UAAU,EACV,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,GACjB,CAAC"}
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  return (mod && mod.__esModule) ? mod : { "default": mod };
14
14
  };
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.routeBodyFactory = exports.inviteEventBodyFactory = exports.eventBodyFactory = exports.entryEventBodyFactory = exports.HttpStatus = exports.EnvoyUserAPI = exports.EnvoyPluginAPI = exports.EnvoySignatureVerifier = exports.EnvoyPluginStoragePipelineMock = exports.EnvoyPluginStoragePipeline = exports.EnvoyPluginStorage = exports.EnvoyPluginSDK = exports.EnvoyPluginJobMock = exports.EnvoyPluginJob = exports.EnvoyJWT = void 0;
16
+ exports.routeBodyFactory = exports.inviteEventBodyFactory = exports.eventBodyFactory = exports.entryEventBodyFactory = exports.HttpStatus = exports.EnvoyUserAPI = exports.EnvoyPluginAPI = exports.EnvoySignatureVerifier = exports.EnvoyPluginStoragePipelineMock = exports.EnvoyPluginStoragePipeline = exports.EnvoyPluginStorage = exports.EnvoyPluginSDK = exports.EnvoyPluginJobMock = exports.EnvoyPluginJob = exports.EnvoyJWT = exports.hiddenJobAttachment = exports.HIDDEN_JOB_ATTACHMENT_TYPE = void 0;
17
17
  require("./constants");
18
18
  var EnvoyPluginStoragePipeline_1 = __importDefault(require("./base/EnvoyPluginStoragePipeline"));
19
19
  exports.EnvoyPluginStoragePipeline = EnvoyPluginStoragePipeline_1.default;
@@ -70,6 +70,9 @@ __exportStar(require("./sdk/filters"), exports);
70
70
  __exportStar(require("./sdk/handlers"), exports);
71
71
  __exportStar(require("./sdk/loggers"), exports);
72
72
  __exportStar(require("./sdk/middleware"), exports);
73
+ var EnvoyPluginJobAttachment_1 = require("./sdk/EnvoyPluginJobAttachment");
74
+ Object.defineProperty(exports, "HIDDEN_JOB_ATTACHMENT_TYPE", { enumerable: true, get: function () { return EnvoyPluginJobAttachment_1.HIDDEN_JOB_ATTACHMENT_TYPE; } });
75
+ Object.defineProperty(exports, "hiddenJobAttachment", { enumerable: true, get: function () { return EnvoyPluginJobAttachment_1.hiddenJobAttachment; } });
73
76
  __exportStar(require("./util/EnvoySignatureVerifier"), exports);
74
77
  __exportStar(require("./util/axiosConstructor"), exports);
75
78
  __exportStar(require("./util/errorHandling"), exports);
@@ -34,6 +34,11 @@ export interface SignInFieldAttributes {
34
34
  * can answer, such as a badge or card number that is read off the credential.
35
35
  */
36
36
  'allow-employee-respondents'?: boolean;
37
+ /**
38
+ * Set by the server when a workflow policy owns this field. Read-only, so it
39
+ * is ignored on create and update.
40
+ */
41
+ 'workflow-definition-field-id'?: string | null;
37
42
  'created-at'?: string;
38
43
  'updated-at'?: string;
39
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SignInFieldResource.d.ts","sourceRoot":"","sources":["../../src/resources/SignInFieldResource.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,+BAA+B,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sBAAsB,EAAE,KAAK,CAAC;QAC5B,eAAe,EAAE,MAAM,CAAC;QACxB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC,CAAC;IACH,O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;;;;;;;OAOG;IACH,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC;;;OAGG;IACH,8BAA8B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,oBAAY,wBAAwB,GAAG,oBAAoB,CAAC;AAE5D;;GAEG;AACH,oBAAY,gBAAgB,GAAG,YAAY,CAAC,qBAAqB,EAAE,wBAAwB,CAAC,CAAC"}
@@ -7,7 +7,37 @@ export interface EnvoyPluginTextJobAttachment {
7
7
  type?: 'text' | 'password' | string;
8
8
  label: string;
9
9
  value: string;
10
+ /**
11
+ * When true, Garaje omits this attachment from the visitor details screen.
12
+ * The job status line still renders.
13
+ * To hide the whole ignored job, use {@link EnvoyResponse.sendHiddenIgnored}.
14
+ */
15
+ hidden?: boolean;
10
16
  }
17
+ /**
18
+ * Marker type that opts a single ignored job out of the dashboard's job panel.
19
+ *
20
+ * Garaje hides the row only when the job status is `ignored` and an attachment
21
+ * has this type (`isHiddenIgnored`). A missing `type` is stamped `password` by
22
+ * envoy-web, which would leave the job visible.
23
+ */
24
+ export declare const HIDDEN_JOB_ATTACHMENT_TYPE = "hidden_job";
25
+ /**
26
+ * Attachment that keeps a no-op's reason on the job and marks that ignored job as hidden.
27
+ *
28
+ * `hidden: true` keeps the reason out of the attachment list if the job is shown.
29
+ * envoy-web drops attachments missing `label` or `value`, so both are required.
30
+ *
31
+ * @category Attachment
32
+ */
33
+ export interface EnvoyPluginHiddenJobAttachment extends EnvoyPluginTextJobAttachment {
34
+ type: typeof HIDDEN_JOB_ATTACHMENT_TYPE;
35
+ hidden: true;
36
+ }
37
+ /**
38
+ * Builds the attachment Garaje uses to drop an ignored job from activity.
39
+ */
40
+ export declare function hiddenJobAttachment(label: string, value: string): EnvoyPluginHiddenJobAttachment;
11
41
  /**
12
42
  * Display some JSON data in Envoy's dashboard.
13
43
  *
@@ -86,6 +116,11 @@ export interface ScreenerInputField {
86
116
  *
87
117
  * @category Attachment
88
118
  */
89
- declare type EnvoyPluginJobAttachment = EnvoyPluginTextJobAttachment | EnvoyPluginLinkJobAttachment | EnvoyPluginCredentialJobAttachment | EnvoyPluginScreenerJobAttachment;
119
+ declare type EnvoyPluginJobAttachment = EnvoyPluginTextJobAttachment | EnvoyPluginHiddenJobAttachment | EnvoyPluginLinkJobAttachment | EnvoyPluginCredentialJobAttachment | EnvoyPluginScreenerJobAttachment;
90
120
  export default EnvoyPluginJobAttachment;
121
+ /**
122
+ * Ensures an ignored response carries a `hidden_job` attachment.
123
+ * A plain text attachment is upgraded in place so its label and value are kept.
124
+ */
125
+ export declare function attachmentsForHiddenIgnored(message: string, attachments?: Array<EnvoyPluginJobAttachment>): Array<EnvoyPluginJobAttachment>;
91
126
  //# sourceMappingURL=EnvoyPluginJobAttachment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EnvoyPluginJobAttachment.d.ts","sourceRoot":"","sources":["../../src/sdk/EnvoyPluginJobAttachment.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,4BAA6B,SAAQ,4BAA4B;IAChF,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;GAKG;AACH,MAAM,WAAW,kCAAmC,SAAQ,4BAA4B;IACtF,IAAI,EAAE,kBAAkB,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE;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AW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;GAMG;AACH,aAAK,wBAAwB,GACzB,4BAA4B,GAC5B,8BAA8B,GAC9B,4BAA4B,GAC5B,kCAAkC,GAClC,gCAAgC,CAAC;AAErC,eAAe,wBAAwB,CAAC;AASxC;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,MAAM,EACf,WAAW,GAAE,KAAK,CAAC,wBAAwB,CAAM,GAChD,KAAK,CAAC,wBAAwB,CAAC,CAmCjC"}
@@ -1,2 +1,79 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
14
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
15
+ to[j] = from[i];
16
+ return to;
17
+ };
2
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.attachmentsForHiddenIgnored = exports.hiddenJobAttachment = exports.HIDDEN_JOB_ATTACHMENT_TYPE = void 0;
20
+ /**
21
+ * Marker type that opts a single ignored job out of the dashboard's job panel.
22
+ *
23
+ * Garaje hides the row only when the job status is `ignored` and an attachment
24
+ * has this type (`isHiddenIgnored`). A missing `type` is stamped `password` by
25
+ * envoy-web, which would leave the job visible.
26
+ */
27
+ exports.HIDDEN_JOB_ATTACHMENT_TYPE = 'hidden_job';
28
+ /**
29
+ * Builds the attachment Garaje uses to drop an ignored job from activity.
30
+ */
31
+ function hiddenJobAttachment(label, value) {
32
+ return {
33
+ type: exports.HIDDEN_JOB_ATTACHMENT_TYPE,
34
+ label: label,
35
+ value: value,
36
+ hidden: true,
37
+ };
38
+ }
39
+ exports.hiddenJobAttachment = hiddenJobAttachment;
40
+ function isPlainTextAttachment(attachment) {
41
+ if (attachment.type !== undefined && attachment.type !== 'text') {
42
+ return false;
43
+ }
44
+ return typeof attachment.label === 'string' && typeof attachment.value === 'string';
45
+ }
46
+ /**
47
+ * Ensures an ignored response carries a `hidden_job` attachment.
48
+ * A plain text attachment is upgraded in place so its label and value are kept.
49
+ */
50
+ function attachmentsForHiddenIgnored(message, attachments) {
51
+ if (attachments === void 0) { attachments = []; }
52
+ var markerIndex = attachments.findIndex(function (attachment) { return attachment.type === exports.HIDDEN_JOB_ATTACHMENT_TYPE; });
53
+ if (markerIndex >= 0) {
54
+ return attachments.map(function (attachment, index) {
55
+ if (index !== markerIndex) {
56
+ return attachment;
57
+ }
58
+ var textAttachment = attachment;
59
+ var label = textAttachment.label || message || 'Ignored';
60
+ var value = textAttachment.value || message || 'Ignored';
61
+ return __assign(__assign({}, textAttachment), hiddenJobAttachment(label, value));
62
+ });
63
+ }
64
+ var textIndex = attachments.findIndex(isPlainTextAttachment);
65
+ if (textIndex === -1) {
66
+ var fallback = message || 'Ignored';
67
+ return __spreadArray([hiddenJobAttachment(fallback, fallback)], attachments);
68
+ }
69
+ return attachments.map(function (attachment, index) {
70
+ if (index !== textIndex) {
71
+ return attachment;
72
+ }
73
+ var textAttachment = attachment;
74
+ var label = textAttachment.label || message || 'Ignored';
75
+ var value = textAttachment.value || message || 'Ignored';
76
+ return __assign(__assign({}, textAttachment), hiddenJobAttachment(label, value));
77
+ });
78
+ }
79
+ exports.attachmentsForHiddenIgnored = attachmentsForHiddenIgnored;
@@ -18,8 +18,17 @@ export default interface EnvoyResponse<Body = unknown> extends Response {
18
18
  sendOngoing: (debugInfo?: unknown) => void;
19
19
  /**
20
20
  * Marks the job as "ignored". Useful when you explicitly do not want to handle the event.
21
+ * The job stays visible in dashboard activity. Use {@link sendHiddenIgnored} for mechanical no-ops.
21
22
  */
22
23
  sendIgnored: (message: string, debugInfo?: unknown, ...attachments: Array<EnvoyPluginJobAttachment>) => void;
24
+ /**
25
+ * Marks the job as "ignored" and hides it from dashboard activity.
26
+ *
27
+ * Garaje drops the row only when the status is ignored and an attachment has type `hidden_job`.
28
+ * A plain text attachment keeps its label and value, and its type is set to `hidden_job`.
29
+ * With no attachment, the message is used for both label and value.
30
+ */
31
+ sendHiddenIgnored: (message: string, debugInfo?: unknown, ...attachments: Array<EnvoyPluginJobAttachment>) => void;
23
32
  /**
24
33
  * Marks the job as "failed". The message will be communicated to the Envoy Dashboard user.
25
34
  */
@@ -1 +1 @@
1
- {"version":3,"file":"EnvoyResponse.d.ts","sourceRoot":"","sources":["../../src/sdk/EnvoyResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,wBAAwB,EAAE,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAC;AACxG,OAAO,6BAA6B,MAAM,2CAA2C,CAAC;AACtF,OAAO,oCAAoC,MAAM,kDAAkD,CAAC;AACpG,OAAO,iCAAiC,MAAM,+CAA+C,CAAC;AAC9F,OAAO,gCAAgC,MAAM,oCAAoC,CAAC;AAElF;;;GAGG;AACH,MAAM,CAAC,OAAO,WAAW,aAAa,CAAC,IAAI,GAAG,OAAO,CAAE,SAAQ,QAAQ;IACrE,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,KAAK,IAAI,CAAC;IAC5B;;;;OAIG;IACH,WAAW,EAAE,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC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ogger(config: AxiosRequestConfig): AxiosRequestConfig<any>;
3
- declare function envoyAxiosResponseLogger(response: AxiosResponse): AxiosResponse<any, any, {}>;
2
+ declare function envoyAxiosRequestLogger(config: AxiosRequestConfig): AxiosRequestConfig<any, any>;
3
+ declare function envoyAxiosResponseLogger(response: AxiosResponse): AxiosResponse<any, any, {}, any>;
4
4
  declare function envoyAxiosErrorLogger(error: AxiosError): void;
5
5
  export { envoyAxiosRequestLogger, envoyAxiosResponseLogger, envoyAxiosErrorLogger };
6
6
  //# sourceMappingURL=loggers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loggers.d.ts","sourceRoot":"","sources":["../../src/sdk/loggers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAItE,iBAAS,uBAAuB,CAAC,MAAM,EAAE,kBAAkB,2BAkD1D;AAED,iBAAS,wBAAwB,CAAC,QAAQ,EAAE,aAAa,+BAoDxD;AAED,iBAAS,qBAAqB,CAAC,KAAK,EAAE,UAAU,QAoD/C;AAED,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,CAAC"}
1
+ {"version":3,"file":"loggers.d.ts","sourceRoot":"","sources":["../../src/sdk/loggers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAItE,iBAAS,uBAAuB,CAAC,MAAM,EAAE,kBAAkB,gCAkD1D;AAED,iBAAS,wBAAwB,CAAC,QAAQ,EAAE,aAAa,oCAoDxD;AAED,iBAAS,qBAAqB,CAAC,KAAK,EAAE,UAAU,QAoD/C;AAED,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,CAAC"}
@@ -1,5 +1,12 @@
1
1
  import { ErrorRequestHandler, RequestHandler } from 'express';
2
2
  import { EnvoySignatureVerifierOptions } from '../util/EnvoySignatureVerifier';
3
+ import EnvoyResponse from './EnvoyResponse';
4
+ /**
5
+ * Attaches job status helpers to the Express response.
6
+ *
7
+ * @internal
8
+ */
9
+ export declare function assignEnvoyResponseHelpers(envoyResponse: EnvoyResponse): void;
3
10
  /**
4
11
  * Sets up an {@link EnvoyPluginSDK} object in the path `req.envoy`.
5
12
  * Modifies the `res` object to include Envoy's helpers, per {@link EnvoyResponse}.
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/sdk/middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,mBAAmB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG/F,OAA+B,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAOvG;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,6BAA6B,GAAG,cAAc,CA8EvF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAe,GAAG,mBAAmB,CAU7F"}
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/sdk/middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,mBAAmB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG/F,OAA+B,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAEvG,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAQ5C;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,aAAa,GAAG,IAAI,CAmE7E;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,6BAA6B,GAAG,cAAc,CA+BvF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAe,GAAG,mBAAmB,CAU7F"}
@@ -39,13 +39,92 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.errorMiddleware = exports.envoyMiddleware = void 0;
42
+ exports.errorMiddleware = exports.envoyMiddleware = exports.assignEnvoyResponseHelpers = void 0;
43
43
  var body_parser_1 = __importDefault(require("body-parser"));
44
44
  var HttpStatus_1 = __importDefault(require("../internal/HttpStatus"));
45
45
  var EnvoySignatureVerifier_1 = __importDefault(require("../util/EnvoySignatureVerifier"));
46
46
  var EnvoyRequest_1 = require("./EnvoyRequest");
47
+ var EnvoyPluginJobAttachment_1 = require("./EnvoyPluginJobAttachment");
47
48
  var EnvoyPluginSDK_1 = __importDefault(require("./EnvoyPluginSDK"));
48
49
  var EnvoyPluginAPI_1 = __importDefault(require("./EnvoyPluginAPI"));
50
+ /**
51
+ * Attaches job status helpers to the Express response.
52
+ *
53
+ * @internal
54
+ */
55
+ function assignEnvoyResponseHelpers(envoyResponse) {
56
+ /**
57
+ * Respond with "ongoing" for long jobs.
58
+ */
59
+ envoyResponse.sendOngoing = function (message, debugInfo) {
60
+ if (message === void 0) { message = ''; }
61
+ if (debugInfo === void 0) { debugInfo = {}; }
62
+ envoyResponse.statusCode = HttpStatus_1.default.ONGOING;
63
+ envoyResponse.setHeader('Content-Type', 'application/json');
64
+ envoyResponse.end(JSON.stringify({ message: message, debugInfo: debugInfo }));
65
+ };
66
+ /**
67
+ * Respond with "ignored" if no action will be performed.
68
+ */
69
+ envoyResponse.sendIgnored = function (message, debugInfo) {
70
+ if (message === void 0) { message = ''; }
71
+ if (debugInfo === void 0) { debugInfo = {}; }
72
+ var attachments = [];
73
+ for (var _i = 2; _i < arguments.length; _i++) {
74
+ attachments[_i - 2] = arguments[_i];
75
+ }
76
+ envoyResponse.statusCode = HttpStatus_1.default.IGNORED;
77
+ envoyResponse.setHeader('Content-Type', 'application/json');
78
+ envoyResponse.end(JSON.stringify({ message: message, debugInfo: debugInfo, attachments: attachments }));
79
+ };
80
+ /**
81
+ * Respond with "ignored" and hide the job from dashboard activity.
82
+ */
83
+ envoyResponse.sendHiddenIgnored = function (message, debugInfo) {
84
+ if (message === void 0) { message = ''; }
85
+ if (debugInfo === void 0) { debugInfo = {}; }
86
+ var attachments = [];
87
+ for (var _i = 2; _i < arguments.length; _i++) {
88
+ attachments[_i - 2] = arguments[_i];
89
+ }
90
+ envoyResponse.statusCode = HttpStatus_1.default.IGNORED;
91
+ envoyResponse.setHeader('Content-Type', 'application/json');
92
+ envoyResponse.end(JSON.stringify({
93
+ message: message,
94
+ debugInfo: debugInfo,
95
+ attachments: EnvoyPluginJobAttachment_1.attachmentsForHiddenIgnored(message, attachments),
96
+ }));
97
+ };
98
+ /**
99
+ * Respond with "failed" in case of errors.
100
+ */
101
+ envoyResponse.sendFailed = function (message, debugInfo) {
102
+ if (message === void 0) { message = ''; }
103
+ if (debugInfo === void 0) { debugInfo = {}; }
104
+ var attachments = [];
105
+ for (var _i = 2; _i < arguments.length; _i++) {
106
+ attachments[_i - 2] = arguments[_i];
107
+ }
108
+ envoyResponse.statusCode = HttpStatus_1.default.FAILED;
109
+ envoyResponse.setHeader('Content-Type', 'application/json');
110
+ envoyResponse.end(JSON.stringify({ message: message, debugInfo: debugInfo, attachments: attachments }));
111
+ };
112
+ /**
113
+ * Respond with "failed" for screener in case of screener matches.
114
+ */
115
+ envoyResponse.sendFailedScreen = function (message, debugInfo) {
116
+ if (message === void 0) { message = ''; }
117
+ if (debugInfo === void 0) { debugInfo = {}; }
118
+ var attachments = [];
119
+ for (var _i = 2; _i < arguments.length; _i++) {
120
+ attachments[_i - 2] = arguments[_i];
121
+ }
122
+ envoyResponse.statusCode = HttpStatus_1.default.FAILED;
123
+ envoyResponse.setHeader('Content-Type', 'application/json');
124
+ envoyResponse.end(JSON.stringify({ message: message, debugInfo: debugInfo, attachments: attachments }));
125
+ };
126
+ }
127
+ exports.assignEnvoyResponseHelpers = assignEnvoyResponseHelpers;
49
128
  /**
50
129
  * Sets up an {@link EnvoyPluginSDK} object in the path `req.envoy`.
51
130
  * Modifies the `res` object to include Envoy's helpers, per {@link EnvoyResponse}.
@@ -66,7 +145,7 @@ function envoyMiddleware(options) {
66
145
  var threshold = 0;
67
146
  return function (req, res, next) {
68
147
  json(req, res, function (err) { return __awaiter(_this, void 0, void 0, function () {
69
- var now, _a, rawAccessToken, expiresIn, envoyRequest, envoyResponse_1, error_1;
148
+ var now, _a, rawAccessToken, expiresIn, envoyRequest, envoyResponse, error_1;
70
149
  return __generator(this, function (_b) {
71
150
  switch (_b.label) {
72
151
  case 0:
@@ -86,60 +165,9 @@ function envoyMiddleware(options) {
86
165
  _b.label = 3;
87
166
  case 3:
88
167
  envoyRequest = req;
89
- envoyResponse_1 = res;
168
+ envoyResponse = res;
90
169
  envoyRequest.envoy = new EnvoyPluginSDK_1.default(envoyRequest.body, envoyRequest[EnvoyRequest_1.VERIFIED], accessToken);
91
- /**
92
- * Respond with "ongoing" for long jobs.
93
- */
94
- envoyResponse_1.sendOngoing = function (message, debugInfo) {
95
- if (message === void 0) { message = ''; }
96
- if (debugInfo === void 0) { debugInfo = {}; }
97
- envoyResponse_1.statusCode = HttpStatus_1.default.ONGOING;
98
- envoyResponse_1.setHeader('Content-Type', 'application/json');
99
- envoyResponse_1.end(JSON.stringify({ message: message, debugInfo: debugInfo }));
100
- };
101
- /**
102
- * Respond with "ignored" if no action will be performed.
103
- */
104
- envoyResponse_1.sendIgnored = function (message, debugInfo) {
105
- if (message === void 0) { message = ''; }
106
- if (debugInfo === void 0) { debugInfo = {}; }
107
- var attachments = [];
108
- for (var _i = 2; _i < arguments.length; _i++) {
109
- attachments[_i - 2] = arguments[_i];
110
- }
111
- envoyResponse_1.statusCode = HttpStatus_1.default.IGNORED;
112
- envoyResponse_1.setHeader('Content-Type', 'application/json');
113
- envoyResponse_1.end(JSON.stringify({ message: message, debugInfo: debugInfo, attachments: attachments }));
114
- };
115
- /**
116
- * Respond with "failed" in case of errors.
117
- */
118
- envoyResponse_1.sendFailed = function (message, debugInfo) {
119
- if (message === void 0) { message = ''; }
120
- if (debugInfo === void 0) { debugInfo = {}; }
121
- var attachments = [];
122
- for (var _i = 2; _i < arguments.length; _i++) {
123
- attachments[_i - 2] = arguments[_i];
124
- }
125
- envoyResponse_1.statusCode = HttpStatus_1.default.FAILED;
126
- envoyResponse_1.setHeader('Content-Type', 'application/json');
127
- envoyResponse_1.end(JSON.stringify({ message: message, debugInfo: debugInfo, attachments: attachments }));
128
- };
129
- /**
130
- * Respond with "failed" for screener in case of screener matches.
131
- */
132
- envoyResponse_1.sendFailedScreen = function (message, debugInfo) {
133
- if (message === void 0) { message = ''; }
134
- if (debugInfo === void 0) { debugInfo = {}; }
135
- var attachments = [];
136
- for (var _i = 2; _i < arguments.length; _i++) {
137
- attachments[_i - 2] = arguments[_i];
138
- }
139
- envoyResponse_1.statusCode = HttpStatus_1.default.FAILED;
140
- envoyResponse_1.setHeader('Content-Type', 'application/json');
141
- envoyResponse_1.end(JSON.stringify({ message: message, debugInfo: debugInfo, attachments: attachments }));
142
- };
170
+ assignEnvoyResponseHelpers(envoyResponse);
143
171
  next();
144
172
  return [3 /*break*/, 5];
145
173
  case 4:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envoy/envoy-integrations-sdk",
3
- "version": "2.5.3",
3
+ "version": "2.5.7",
4
4
  "description": "SDK for building Envoy integrations.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -59,6 +59,9 @@ export * from './sdk/handlers';
59
59
  export * from './sdk/loggers';
60
60
  export * from './sdk/middleware';
61
61
 
62
+ export { HIDDEN_JOB_ATTACHMENT_TYPE, hiddenJobAttachment } from './sdk/EnvoyPluginJobAttachment';
63
+ export type { EnvoyPluginHiddenJobAttachment } from './sdk/EnvoyPluginJobAttachment';
64
+
62
65
  export * from './util/EnvoySignatureVerifier';
63
66
  export * from './util/axiosConstructor';
64
67
  export * from './util/errorHandling';
@@ -35,6 +35,11 @@ export interface SignInFieldAttributes {
35
35
  * can answer, such as a badge or card number that is read off the credential.
36
36
  */
37
37
  'allow-employee-respondents'?: boolean;
38
+ /**
39
+ * Set by the server when a workflow policy owns this field. Read-only, so it
40
+ * is ignored on create and update.
41
+ */
42
+ 'workflow-definition-field-id'?: string | null;
38
43
  'created-at'?: string;
39
44
  'updated-at'?: string;
40
45
  }
@@ -7,6 +7,46 @@ export interface EnvoyPluginTextJobAttachment {
7
7
  type?: 'text' | 'password' | string;
8
8
  label: string;
9
9
  value: string;
10
+ /**
11
+ * When true, Garaje omits this attachment from the visitor details screen.
12
+ * The job status line still renders.
13
+ * To hide the whole ignored job, use {@link EnvoyResponse.sendHiddenIgnored}.
14
+ */
15
+ hidden?: boolean;
16
+ }
17
+
18
+ /**
19
+ * Marker type that opts a single ignored job out of the dashboard's job panel.
20
+ *
21
+ * Garaje hides the row only when the job status is `ignored` and an attachment
22
+ * has this type (`isHiddenIgnored`). A missing `type` is stamped `password` by
23
+ * envoy-web, which would leave the job visible.
24
+ */
25
+ export const HIDDEN_JOB_ATTACHMENT_TYPE = 'hidden_job';
26
+
27
+ /**
28
+ * Attachment that keeps a no-op's reason on the job and marks that ignored job as hidden.
29
+ *
30
+ * `hidden: true` keeps the reason out of the attachment list if the job is shown.
31
+ * envoy-web drops attachments missing `label` or `value`, so both are required.
32
+ *
33
+ * @category Attachment
34
+ */
35
+ export interface EnvoyPluginHiddenJobAttachment extends EnvoyPluginTextJobAttachment {
36
+ type: typeof HIDDEN_JOB_ATTACHMENT_TYPE;
37
+ hidden: true;
38
+ }
39
+
40
+ /**
41
+ * Builds the attachment Garaje uses to drop an ignored job from activity.
42
+ */
43
+ export function hiddenJobAttachment(label: string, value: string): EnvoyPluginHiddenJobAttachment {
44
+ return {
45
+ type: HIDDEN_JOB_ATTACHMENT_TYPE,
46
+ label,
47
+ value,
48
+ hidden: true,
49
+ };
10
50
  }
11
51
 
12
52
  /**
@@ -62,7 +102,7 @@ export interface EnvoyPluginScreenerJobAttachment extends EnvoyPluginJSONJobAtta
62
102
  export interface ScreenerDetails {
63
103
  input: {
64
104
  fields: ScreenerInputField[];
65
- }
105
+ };
66
106
  matches: ScreenerMatch[];
67
107
  }
68
108
 
@@ -98,8 +138,60 @@ export interface ScreenerInputField {
98
138
  */
99
139
  type EnvoyPluginJobAttachment =
100
140
  | EnvoyPluginTextJobAttachment
141
+ | EnvoyPluginHiddenJobAttachment
101
142
  | EnvoyPluginLinkJobAttachment
102
143
  | EnvoyPluginCredentialJobAttachment
103
144
  | EnvoyPluginScreenerJobAttachment;
104
145
 
105
146
  export default EnvoyPluginJobAttachment;
147
+
148
+ function isPlainTextAttachment(attachment: EnvoyPluginJobAttachment): attachment is EnvoyPluginTextJobAttachment {
149
+ if (attachment.type !== undefined && attachment.type !== 'text') {
150
+ return false;
151
+ }
152
+ return typeof attachment.label === 'string' && typeof attachment.value === 'string';
153
+ }
154
+
155
+ /**
156
+ * Ensures an ignored response carries a `hidden_job` attachment.
157
+ * A plain text attachment is upgraded in place so its label and value are kept.
158
+ */
159
+ export function attachmentsForHiddenIgnored(
160
+ message: string,
161
+ attachments: Array<EnvoyPluginJobAttachment> = [],
162
+ ): Array<EnvoyPluginJobAttachment> {
163
+ const markerIndex = attachments.findIndex((attachment) => attachment.type === HIDDEN_JOB_ATTACHMENT_TYPE);
164
+ if (markerIndex >= 0) {
165
+ return attachments.map((attachment, index) => {
166
+ if (index !== markerIndex) {
167
+ return attachment;
168
+ }
169
+ const textAttachment = attachment as EnvoyPluginTextJobAttachment;
170
+ const label = textAttachment.label || message || 'Ignored';
171
+ const value = textAttachment.value || message || 'Ignored';
172
+ return {
173
+ ...textAttachment,
174
+ ...hiddenJobAttachment(label, value),
175
+ };
176
+ });
177
+ }
178
+
179
+ const textIndex = attachments.findIndex(isPlainTextAttachment);
180
+ if (textIndex === -1) {
181
+ const fallback = message || 'Ignored';
182
+ return [hiddenJobAttachment(fallback, fallback), ...attachments];
183
+ }
184
+
185
+ return attachments.map((attachment, index) => {
186
+ if (index !== textIndex) {
187
+ return attachment;
188
+ }
189
+ const textAttachment = attachment as EnvoyPluginTextJobAttachment;
190
+ const label = textAttachment.label || message || 'Ignored';
191
+ const value = textAttachment.value || message || 'Ignored';
192
+ return {
193
+ ...textAttachment,
194
+ ...hiddenJobAttachment(label, value),
195
+ };
196
+ });
197
+ }
@@ -19,9 +19,19 @@ export default interface EnvoyResponse<Body = unknown> extends Response {
19
19
  sendOngoing: (debugInfo?: unknown) => void;
20
20
  /**
21
21
  * Marks the job as "ignored". Useful when you explicitly do not want to handle the event.
22
+ * The job stays visible in dashboard activity. Use {@link sendHiddenIgnored} for mechanical no-ops.
22
23
  */
23
24
  sendIgnored: (message: string, debugInfo?: unknown, ...attachments: Array<EnvoyPluginJobAttachment>) => void;
24
25
 
26
+ /**
27
+ * Marks the job as "ignored" and hides it from dashboard activity.
28
+ *
29
+ * Garaje drops the row only when the status is ignored and an attachment has type `hidden_job`.
30
+ * A plain text attachment keeps its label and value, and its type is set to `hidden_job`.
31
+ * With no attachment, the message is used for both label and value.
32
+ */
33
+ sendHiddenIgnored: (message: string, debugInfo?: unknown, ...attachments: Array<EnvoyPluginJobAttachment>) => void;
34
+
25
35
  /**
26
36
  * Marks the job as "failed". The message will be communicated to the Envoy Dashboard user.
27
37
  */
@@ -5,10 +5,87 @@ import HttpStatus from '../internal/HttpStatus';
5
5
  import EnvoySignatureVerifier, { EnvoySignatureVerifierOptions } from '../util/EnvoySignatureVerifier';
6
6
  import EnvoyRequest, { VERIFIED, VerifiedRequest } from './EnvoyRequest';
7
7
  import EnvoyResponse from './EnvoyResponse';
8
- import EnvoyPluginJobAttachment, { EnvoyPluginScreenerJobAttachment } from './EnvoyPluginJobAttachment';
8
+ import EnvoyPluginJobAttachment, {
9
+ EnvoyPluginScreenerJobAttachment,
10
+ attachmentsForHiddenIgnored,
11
+ } from './EnvoyPluginJobAttachment';
9
12
  import EnvoyPluginSDK from './EnvoyPluginSDK';
10
13
  import EnvoyPluginAPI from './EnvoyPluginAPI';
11
14
 
15
+ /**
16
+ * Attaches job status helpers to the Express response.
17
+ *
18
+ * @internal
19
+ */
20
+ export function assignEnvoyResponseHelpers(envoyResponse: EnvoyResponse): void {
21
+ /**
22
+ * Respond with "ongoing" for long jobs.
23
+ */
24
+ envoyResponse.sendOngoing = (message = '', debugInfo: unknown = {}) => {
25
+ envoyResponse.statusCode = HttpStatus.ONGOING;
26
+ envoyResponse.setHeader('Content-Type', 'application/json');
27
+ envoyResponse.end(JSON.stringify({ message, debugInfo }));
28
+ };
29
+
30
+ /**
31
+ * Respond with "ignored" if no action will be performed.
32
+ */
33
+ envoyResponse.sendIgnored = (
34
+ message = '',
35
+ debugInfo: unknown = {},
36
+ ...attachments: Array<EnvoyPluginJobAttachment>
37
+ ) => {
38
+ envoyResponse.statusCode = HttpStatus.IGNORED;
39
+ envoyResponse.setHeader('Content-Type', 'application/json');
40
+ envoyResponse.end(JSON.stringify({ message, debugInfo, attachments }));
41
+ };
42
+
43
+ /**
44
+ * Respond with "ignored" and hide the job from dashboard activity.
45
+ */
46
+ envoyResponse.sendHiddenIgnored = (
47
+ message = '',
48
+ debugInfo: unknown = {},
49
+ ...attachments: Array<EnvoyPluginJobAttachment>
50
+ ) => {
51
+ envoyResponse.statusCode = HttpStatus.IGNORED;
52
+ envoyResponse.setHeader('Content-Type', 'application/json');
53
+ envoyResponse.end(
54
+ JSON.stringify({
55
+ message,
56
+ debugInfo,
57
+ attachments: attachmentsForHiddenIgnored(message, attachments),
58
+ }),
59
+ );
60
+ };
61
+
62
+ /**
63
+ * Respond with "failed" in case of errors.
64
+ */
65
+ envoyResponse.sendFailed = (
66
+ message = '',
67
+ debugInfo: unknown = {},
68
+ ...attachments: Array<EnvoyPluginJobAttachment>
69
+ ) => {
70
+ envoyResponse.statusCode = HttpStatus.FAILED;
71
+ envoyResponse.setHeader('Content-Type', 'application/json');
72
+ envoyResponse.end(JSON.stringify({ message, debugInfo, attachments }));
73
+ };
74
+
75
+ /**
76
+ * Respond with "failed" for screener in case of screener matches.
77
+ */
78
+ envoyResponse.sendFailedScreen = (
79
+ message = '',
80
+ debugInfo: unknown = {},
81
+ ...attachments: Array<EnvoyPluginScreenerJobAttachment>
82
+ ) => {
83
+ envoyResponse.statusCode = HttpStatus.FAILED;
84
+ envoyResponse.setHeader('Content-Type', 'application/json');
85
+ envoyResponse.end(JSON.stringify({ message, debugInfo, attachments }));
86
+ };
87
+ }
88
+
12
89
  /**
13
90
  * Sets up an {@link EnvoyPluginSDK} object in the path `req.envoy`.
14
91
  * Modifies the `res` object to include Envoy's helpers, per {@link EnvoyResponse}.
@@ -42,54 +119,7 @@ export function envoyMiddleware(options?: EnvoySignatureVerifierOptions): Reques
42
119
  const envoyRequest = req as EnvoyRequest;
43
120
  const envoyResponse = res as EnvoyResponse;
44
121
  envoyRequest.envoy = new EnvoyPluginSDK(envoyRequest.body, envoyRequest[VERIFIED], accessToken);
45
-
46
- /**
47
- * Respond with "ongoing" for long jobs.
48
- */
49
- envoyResponse.sendOngoing = (message = '', debugInfo: unknown = {}) => {
50
- envoyResponse.statusCode = HttpStatus.ONGOING;
51
- envoyResponse.setHeader('Content-Type', 'application/json');
52
- envoyResponse.end(JSON.stringify({ message, debugInfo }));
53
- };
54
-
55
- /**
56
- * Respond with "ignored" if no action will be performed.
57
- */
58
- envoyResponse.sendIgnored = (
59
- message = '',
60
- debugInfo: unknown = {},
61
- ...attachments: Array<EnvoyPluginJobAttachment>
62
- ) => {
63
- envoyResponse.statusCode = HttpStatus.IGNORED;
64
- envoyResponse.setHeader('Content-Type', 'application/json');
65
- envoyResponse.end(JSON.stringify({ message, debugInfo, attachments }));
66
- };
67
-
68
- /**
69
- * Respond with "failed" in case of errors.
70
- */
71
- envoyResponse.sendFailed = (
72
- message = '',
73
- debugInfo: unknown = {},
74
- ...attachments: Array<EnvoyPluginJobAttachment>
75
- ) => {
76
- envoyResponse.statusCode = HttpStatus.FAILED;
77
- envoyResponse.setHeader('Content-Type', 'application/json');
78
- envoyResponse.end(JSON.stringify({ message, debugInfo, attachments }));
79
- };
80
-
81
- /**
82
- * Respond with "failed" for screener in case of screener matches.
83
- */
84
- envoyResponse.sendFailedScreen = (
85
- message = '',
86
- debugInfo: unknown = {},
87
- ...attachments: Array<EnvoyPluginScreenerJobAttachment>
88
- ) => {
89
- envoyResponse.statusCode = HttpStatus.FAILED;
90
- envoyResponse.setHeader('Content-Type', 'application/json');
91
- envoyResponse.end(JSON.stringify({ message, debugInfo, attachments }));
92
- };
122
+ assignEnvoyResponseHelpers(envoyResponse);
93
123
  next();
94
124
  } catch (error) {
95
125
  next(error);