@12stonechurch/omnihive-worker-documents
Advanced tools
Comparing version 2.0.71 to 2.0.72
@@ -6,6 +6,3 @@ import { IGraphEndpointWorker } from "@withonevision/omnihive-core/interfaces/IGraphEndpointWorker"; | ||
execute: (customArgs: any, omniHiveContext: GraphContext) => Promise<{}>; | ||
private getDocuSignTemplateId; | ||
private createMpEnvelopeData; | ||
private storeEnvelopeData; | ||
} | ||
//# sourceMappingURL=generateDocument.d.ts.map |
@@ -11,11 +11,7 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const HiveWorkerBase_1 = require("@withonevision/omnihive-core/models/HiveWorkerBase"); | ||
const TokenHelper_1 = require("@12stonechurch/omnihive-worker-common/helpers/TokenHelper"); | ||
const generateDocument_1 = require("../common/generateDocument"); | ||
const HiveWorkerType_1 = require("@withonevision/omnihive-core/enums/HiveWorkerType"); | ||
const dayjs_1 = __importDefault(require("dayjs")); | ||
const getContactData_1 = require("../common/getContactData"); | ||
const TokenHelper_1 = require("@12stonechurch/omnihive-worker-common/helpers/TokenHelper"); | ||
class GenerateDocument extends HiveWorkerBase_1.HiveWorkerBase { | ||
@@ -28,64 +24,8 @@ constructor() { | ||
const docusignWorker = this.getWorker("unknown", "DocuSignWorker"); | ||
const templateId = yield this.getDocuSignTemplateId(customArgs.templateId); | ||
const contactData = yield getContactData_1.getContactData(webRootUrl + this.metadata.customSlug, customArgs.contactId); | ||
const email = contactData.email; | ||
const name = `${contactData.nickname} ${contactData.lastName}`; | ||
if (docusignWorker) { | ||
const mpId = yield this.createMpEnvelopeData(customArgs.templateId, contactData.id); | ||
const envelopeData = yield docusignWorker.createEnvelope(templateId, email, name, customArgs.role, mpId); | ||
yield this.storeEnvelopeData(mpId, envelopeData); | ||
const url = yield docusignWorker.getEnvelopeUrl(customArgs.redirectUrl, email, name, envelopeData.envelopeId); | ||
return { envelopeUrl: url }; | ||
} | ||
else { | ||
throw new Error("DocuSign worker not found."); | ||
} | ||
}); | ||
this.getDocuSignTemplateId = (id) => __awaiter(this, void 0, void 0, function* () { | ||
const databaseWorker = this.getWorker(HiveWorkerType_1.HiveWorkerType.Database, "dbMinistryPlatform"); | ||
if (!databaseWorker) { | ||
throw new Error("Database worker not configured"); | ||
if (docusignWorker && databaseWorker && webRootUrl) { | ||
return yield generateDocument_1.generateDocument(docusignWorker, databaseWorker, customArgs.templateId, webRootUrl, this.metadata.customSlug, customArgs.role, customArgs.redirectUrl, customArgs.contactId); | ||
} | ||
const queryBuilder = databaseWorker === null || databaseWorker === void 0 ? void 0 : databaseWorker.connection.queryBuilder(); | ||
queryBuilder.from("DocuSign_Forms as df"); | ||
queryBuilder.where("df.DocuSign_Form_ID", id); | ||
queryBuilder.select("df.Template_ID as id"); | ||
const results = yield databaseWorker.executeQuery(queryBuilder.toString()); | ||
return results[0][0].id; | ||
throw new Error("Web Root Url, DocuSign, and/or Database Workers are not properly configured."); | ||
}); | ||
this.createMpEnvelopeData = (formId, contactId) => __awaiter(this, void 0, void 0, function* () { | ||
var _a, _b, _c; | ||
const databaseWorker = this.getWorker(HiveWorkerType_1.HiveWorkerType.Database, "dbMinistryPlatform"); | ||
if (!databaseWorker) { | ||
throw new Error("Database worker not configured"); | ||
} | ||
const insertData = { | ||
Form_ID: formId, | ||
Contact_ID: contactId, | ||
Status_ID: 1, | ||
Domain_ID: 1, | ||
}; | ||
const queryBuilder = databaseWorker === null || databaseWorker === void 0 ? void 0 : databaseWorker.connection.queryBuilder(); | ||
queryBuilder.from("DocuSign_Envelopes"); | ||
queryBuilder.insert(insertData, ["DocuSign_Envelope_ID"]); | ||
return (_c = (_b = (_a = (yield databaseWorker.executeQuery(queryBuilder.toString()))) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.DocuSign_Envelope_ID; | ||
}); | ||
this.storeEnvelopeData = (mpId, data) => __awaiter(this, void 0, void 0, function* () { | ||
const databaseWorker = this.getWorker(HiveWorkerType_1.HiveWorkerType.Database, "dbMinistryPlatform"); | ||
if (!databaseWorker) { | ||
throw new Error("Database worker not configured"); | ||
} | ||
const dateCreated = dayjs_1.default(data.statusDateTime).format("YYYY-MM-DD hh:mm:ssa"); | ||
const updateData = { | ||
Envelope_ID: data.envelopeId, | ||
Status_ID: 2, | ||
Last_Updated_Date: dateCreated, | ||
Domain_ID: 1, | ||
}; | ||
const queryBuilder = databaseWorker === null || databaseWorker === void 0 ? void 0 : databaseWorker.connection.queryBuilder(); | ||
queryBuilder.from("DocuSign_Envelopes"); | ||
queryBuilder.update(updateData); | ||
queryBuilder.where("DocuSign_Envelope_ID", mpId); | ||
yield databaseWorker.executeQuery(queryBuilder.toString()); | ||
}); | ||
} | ||
@@ -92,0 +32,0 @@ } |
@@ -14,3 +14,3 @@ "use strict"; | ||
const HiveWorkerBase_1 = require("@withonevision/omnihive-core/models/HiveWorkerBase"); | ||
const getContactData_1 = require("../common/getContactData"); | ||
const getDocumentUrl_1 = require("../common/getDocumentUrl"); | ||
class GetDocumentUrl extends HiveWorkerBase_1.HiveWorkerBase { | ||
@@ -23,7 +23,4 @@ constructor() { | ||
const docusignWorker = this.getWorker("unknown", "DocuSignWorker"); | ||
if (docusignWorker) { | ||
const contactData = yield getContactData_1.getContactData(webRootUrl + this.metadata.customSlug, customArgs.contactId); | ||
const email = contactData.email; | ||
const name = `${contactData.nickname} ${contactData.lastName}`; | ||
const url = yield docusignWorker.getEnvelopeUrl(customArgs.redirectUrl, email, name, customArgs.envelopeId); | ||
if (docusignWorker && webRootUrl) { | ||
const url = yield getDocumentUrl_1.getDocumentUrl(docusignWorker, webRootUrl + this.metadata.customSlug, customArgs.contactId, customArgs.redirectUrl, customArgs.envelopeId); | ||
return { url: url }; | ||
@@ -30,0 +27,0 @@ } |
{ | ||
"name": "@12stonechurch/omnihive-worker-documents", | ||
"version": "2.0.71", | ||
"version": "2.0.72", | ||
"description": "OmniHive Custom Function package", | ||
@@ -42,3 +42,3 @@ "license": "MIT", | ||
"eslint-plugin-prettier": "3.4.0", | ||
"knex": "0.95.11", | ||
"knex": "0.95.7", | ||
"mocha": "9.0.1", | ||
@@ -45,0 +45,0 @@ "nyc": "15.1.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37454
29
371
1