Add customer contract clearance console
This commit is contained in:
@@ -160,6 +160,7 @@ import { backupSummary, createDatabaseBackup } from "./backup.mjs";
|
||||
import { systemReadiness } from "./readiness.mjs";
|
||||
import { bindProjectStyleKit, createStyleKit, getProjectStyleKit, getStyleKit, listStyleKits, updateStyleKit } from "./style-kits.mjs";
|
||||
import { evaluateAndRecordOrganizationPolicies, listOrganizationPolicies, updateOrganizationPolicy } from "./organization-policies.mjs";
|
||||
import { bindContractProject, createContract, createCustomer, evaluateProjectContractClearance, listContracts, listCustomers, updateContract, updateCustomer, upsertCustomerContact } from "./contracts.mjs";
|
||||
import { dispatchNotificationEvent, listUserNotificationPreferences, listUserNotifications, markAllUserNotificationsRead, markUserNotificationRead, notificationDeliveries, updateUserNotificationPreference } from "./notifications.mjs";
|
||||
import { composeProject, listCompositions } from "./composition.mjs";
|
||||
import { listProjectArtifacts, readArtifactContent } from "./media-artifacts.mjs";
|
||||
@@ -1717,6 +1718,68 @@ createServer(async (req, res) => {
|
||||
return send(res, 200, organizationCommercial(context));
|
||||
}
|
||||
|
||||
const organizationCustomersMatch = pathname.match(/^\/api\/organizations\/([^/]+)\/customers$/);
|
||||
if (req.method === "GET" && organizationCustomersMatch) {
|
||||
const organizationId = decodeURIComponent(organizationCustomersMatch[1]);
|
||||
const context = contextWith({ organizationId, workspaceId: "", projectId: "" }, req);
|
||||
return send(res, 200, listCustomers(context, organizationId, Object.fromEntries(url.searchParams.entries())));
|
||||
}
|
||||
if (req.method === "POST" && organizationCustomersMatch) {
|
||||
const organizationId = decodeURIComponent(organizationCustomersMatch[1]);
|
||||
const context = contextWith({ organizationId, workspaceId: "", projectId: "" }, req);
|
||||
return send(res, 201, createCustomer(context, organizationId, await readBody(req)));
|
||||
}
|
||||
|
||||
const organizationCustomerMatch = pathname.match(/^\/api\/organizations\/([^/]+)\/customers\/([^/]+)$/);
|
||||
if (req.method === "PATCH" && organizationCustomerMatch) {
|
||||
const organizationId = decodeURIComponent(organizationCustomerMatch[1]);
|
||||
const context = contextWith({ organizationId, workspaceId: "", projectId: "" }, req);
|
||||
return send(res, 200, updateCustomer(context, organizationId, decodeURIComponent(organizationCustomerMatch[2]), await readBody(req)));
|
||||
}
|
||||
|
||||
const organizationCustomerContactsMatch = pathname.match(/^\/api\/organizations\/([^/]+)\/customers\/([^/]+)\/contacts$/);
|
||||
if (req.method === "POST" && organizationCustomerContactsMatch) {
|
||||
const organizationId = decodeURIComponent(organizationCustomerContactsMatch[1]);
|
||||
const customerId = decodeURIComponent(organizationCustomerContactsMatch[2]);
|
||||
const context = contextWith({ organizationId, workspaceId: "", projectId: "" }, req);
|
||||
return send(res, 201, upsertCustomerContact(context, organizationId, customerId, await readBody(req)));
|
||||
}
|
||||
|
||||
const organizationContractClearanceMatch = pathname.match(/^\/api\/organizations\/([^/]+)\/contracts\/clearance$/);
|
||||
if (req.method === "GET" && organizationContractClearanceMatch) {
|
||||
const organizationId = decodeURIComponent(organizationContractClearanceMatch[1]);
|
||||
const context = contextWith({ organizationId, workspaceId: "", projectId: "" }, req);
|
||||
return send(res, 200, { clearance: evaluateProjectContractClearance(context, url.searchParams.get("projectId") || url.searchParams.get("project_id") || "", Object.fromEntries(url.searchParams.entries())) });
|
||||
}
|
||||
|
||||
const organizationContractsMatch = pathname.match(/^\/api\/organizations\/([^/]+)\/contracts$/);
|
||||
if (req.method === "GET" && organizationContractsMatch) {
|
||||
const organizationId = decodeURIComponent(organizationContractsMatch[1]);
|
||||
const context = contextWith({ organizationId, workspaceId: "", projectId: "" }, req);
|
||||
return send(res, 200, listContracts(context, organizationId, Object.fromEntries(url.searchParams.entries())));
|
||||
}
|
||||
if (req.method === "POST" && organizationContractsMatch) {
|
||||
const organizationId = decodeURIComponent(organizationContractsMatch[1]);
|
||||
const context = contextWith({ organizationId, workspaceId: "", projectId: "" }, req);
|
||||
return send(res, 201, createContract(context, organizationId, await readBody(req)));
|
||||
}
|
||||
|
||||
const organizationContractBindMatch = pathname.match(/^\/api\/organizations\/([^/]+)\/contracts\/([^/]+)\/bind-project$/);
|
||||
if (req.method === "POST" && organizationContractBindMatch) {
|
||||
const organizationId = decodeURIComponent(organizationContractBindMatch[1]);
|
||||
const contractId = decodeURIComponent(organizationContractBindMatch[2]);
|
||||
const context = contextWith({ organizationId, workspaceId: "", projectId: "" }, req);
|
||||
return send(res, 200, bindContractProject(context, organizationId, contractId, await readBody(req)));
|
||||
}
|
||||
|
||||
const organizationContractMatch = pathname.match(/^\/api\/organizations\/([^/]+)\/contracts\/([^/]+)$/);
|
||||
if (req.method === "PATCH" && organizationContractMatch) {
|
||||
const organizationId = decodeURIComponent(organizationContractMatch[1]);
|
||||
const contractId = decodeURIComponent(organizationContractMatch[2]);
|
||||
const context = contextWith({ organizationId, workspaceId: "", projectId: "" }, req);
|
||||
return send(res, 200, updateContract(context, organizationId, contractId, await readBody(req)));
|
||||
}
|
||||
|
||||
const organizationEntitlementsMatch = pathname.match(/^\/api\/organizations\/([^/]+)\/entitlements$/);
|
||||
if (req.method === "GET" && organizationEntitlementsMatch) {
|
||||
const organizationId = decodeURIComponent(organizationEntitlementsMatch[1]);
|
||||
|
||||
Reference in New Issue
Block a user