node-autotask 0.28.0 → 0.29.0
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/CHANGELOG.md +13 -0
- package/MCP_TOOL_CATALOG.json +27 -8
- package/MCP_TOOL_MANIFEST.md +12 -11
- package/N8N_MCP_MANIFEST.json +34 -5
- package/N8N_MCP_MANIFEST.md +8 -7
- package/README.md +1 -2
- package/capabilities.json +1471 -1307
- package/dist/capabilities.cjs +2 -2
- package/dist/capabilities.js +1 -1
- package/dist/{chunk-GUY2KK7U.cjs → chunk-APXBBN3D.cjs} +143 -143
- package/dist/{chunk-WYKGD5UD.cjs → chunk-BNIOQEKP.cjs} +536 -491
- package/dist/{chunk-D5IVS6GY.cjs → chunk-IKWHRUQ5.cjs} +97 -6
- package/dist/{chunk-IRVZGW5K.js → chunk-KVT5V7SA.js} +93 -2
- package/dist/{chunk-ZEGMVEF3.cjs → chunk-PY45RBQ2.cjs} +1470 -1306
- package/dist/{chunk-SYX6EWMT.js → chunk-T4SZGOJB.js} +98 -53
- package/dist/{chunk-6EQSXYRW.js → chunk-WKP442HS.js} +1470 -1306
- package/dist/{chunk-O2D7KDDD.js → chunk-X4TUU2Y6.js} +2 -2
- package/dist/{index-DXuV04zM.d.ts → index-6_i-__sN.d.ts} +25 -2
- package/dist/{index-DQ9NgraW.d.cts → index-BGZ1Mhbh.d.cts} +105 -82
- package/dist/{index-DQ9NgraW.d.ts → index-BGZ1Mhbh.d.ts} +105 -82
- package/dist/{index-CORcZUNm.d.cts → index-BZkfUU59.d.cts} +25 -2
- package/dist/index.cjs +22 -22
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/operations/index.cjs +112 -112
- package/dist/operations/index.d.cts +4 -4
- package/dist/operations/index.d.ts +4 -4
- package/dist/operations/index.js +2 -2
- package/dist/pool.cjs +9 -9
- package/dist/pool.d.cts +2 -2
- package/dist/pool.d.ts +2 -2
- package/dist/pool.js +4 -4
- package/dist/resources/index.cjs +4 -4
- package/dist/resources/index.d.cts +2 -2
- package/dist/resources/index.d.ts +2 -2
- package/dist/resources/index.js +3 -3
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/docs/API.md +1 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkPY45RBQ2cjs = require('./chunk-PY45RBQ2.cjs');
|
|
4
4
|
|
|
5
5
|
// src/auth.ts
|
|
6
6
|
var AUTH_HEADERS = {
|
|
@@ -17031,7 +17031,7 @@ function buildEntityTypeMap() {
|
|
|
17031
17031
|
}
|
|
17032
17032
|
var ENTITY_TYPE_TO_RESOURCE = buildEntityTypeMap();
|
|
17033
17033
|
var ENUMERABLE_RESOURCES = new Set(
|
|
17034
|
-
|
|
17034
|
+
_chunkPY45RBQ2cjs.CAPABILITIES.filter((rec) => rec.resource !== "operations" && (rec.operation === "query" || rec.operation === "get")).map(
|
|
17035
17035
|
(rec) => rec.resource
|
|
17036
17036
|
)
|
|
17037
17037
|
);
|
|
@@ -17108,7 +17108,7 @@ function capabilitySets() {
|
|
|
17108
17108
|
const fieldOps = /* @__PURE__ */ new Map();
|
|
17109
17109
|
const udfOps = /* @__PURE__ */ new Map();
|
|
17110
17110
|
const resources = /* @__PURE__ */ new Set();
|
|
17111
|
-
for (const rec of
|
|
17111
|
+
for (const rec of _chunkPY45RBQ2cjs.CAPABILITIES) {
|
|
17112
17112
|
if (rec.resource === "operations") continue;
|
|
17113
17113
|
resources.add(rec.resource);
|
|
17114
17114
|
if (rec.operation === "getFieldInfo") fieldOps.set(rec.resource, rec);
|
|
@@ -17120,7 +17120,7 @@ var derivedIndex = null;
|
|
|
17120
17120
|
function derivedFieldsFor(resource) {
|
|
17121
17121
|
if (derivedIndex === null) {
|
|
17122
17122
|
derivedIndex = /* @__PURE__ */ new Map();
|
|
17123
|
-
for (const rec of
|
|
17123
|
+
for (const rec of _chunkPY45RBQ2cjs.CAPABILITIES) {
|
|
17124
17124
|
const declared = _optionalChain([rec, 'access', _127 => _127.metadata, 'optionalAccess', _128 => _128.derivedFields]);
|
|
17125
17125
|
if (!Array.isArray(declared) || derivedIndex.has(rec.resource)) continue;
|
|
17126
17126
|
const rows = [];
|
|
@@ -17390,8 +17390,9 @@ function createNamePlan(labelFields = []) {
|
|
|
17390
17390
|
const resSeen = /* @__PURE__ */ new Set();
|
|
17391
17391
|
const recordFks = [];
|
|
17392
17392
|
const fkSeen = /* @__PURE__ */ new Set();
|
|
17393
|
+
let lineOfBusinessId;
|
|
17393
17394
|
return {
|
|
17394
|
-
plan: () => ({ resourceIds, recordFks, labelFields }),
|
|
17395
|
+
plan: () => ({ resourceIds, recordFks, labelFields, ...lineOfBusinessId !== void 0 ? { lineOfBusinessId } : {} }),
|
|
17395
17396
|
addResource: (value) => {
|
|
17396
17397
|
if (!isVendorId(value)) return;
|
|
17397
17398
|
const k = String(value);
|
|
@@ -17407,6 +17408,10 @@ function createNamePlan(labelFields = []) {
|
|
|
17407
17408
|
fkSeen.add(k);
|
|
17408
17409
|
recordFks.push({ table, id: value });
|
|
17409
17410
|
}
|
|
17411
|
+
},
|
|
17412
|
+
addLineOfBusiness: (value) => {
|
|
17413
|
+
if (!isVendorId(value)) return;
|
|
17414
|
+
lineOfBusinessId = value;
|
|
17410
17415
|
}
|
|
17411
17416
|
};
|
|
17412
17417
|
}
|
|
@@ -17438,6 +17443,82 @@ function faultRow(err) {
|
|
|
17438
17443
|
const e = err;
|
|
17439
17444
|
return e.httpStatus !== void 0 ? { code: e.code, message: e.message, httpStatus: e.httpStatus } : { code: e.code, message: e.message };
|
|
17440
17445
|
}
|
|
17446
|
+
function vendorId(value) {
|
|
17447
|
+
if (typeof value === "number") return Number.isSafeInteger(value) && value >= 1 ? value : void 0;
|
|
17448
|
+
if (typeof value === "string" && /^[0-9]+$/.test(value.trim())) {
|
|
17449
|
+
const n = Number(value.trim());
|
|
17450
|
+
return Number.isSafeInteger(n) && n >= 1 ? n : void 0;
|
|
17451
|
+
}
|
|
17452
|
+
return void 0;
|
|
17453
|
+
}
|
|
17454
|
+
async function resolveLineOfBusinessChain(http, associationId, options) {
|
|
17455
|
+
const operation = _nullishCoalesce(options.operation, () => ( "compositeNames"));
|
|
17456
|
+
const degrade = options.onError === "degrade";
|
|
17457
|
+
const get = (path) => {
|
|
17458
|
+
const res = http.request({ method: "GET", path, operation }).then((body) => {
|
|
17459
|
+
const b = body;
|
|
17460
|
+
if (b === null || !("item" in b) || b.item === null || b.item === void 0) return null;
|
|
17461
|
+
return b.item;
|
|
17462
|
+
});
|
|
17463
|
+
if (!degrade) {
|
|
17464
|
+
return res.catch((e) => {
|
|
17465
|
+
if (e instanceof NotFoundError) return null;
|
|
17466
|
+
throw e;
|
|
17467
|
+
});
|
|
17468
|
+
}
|
|
17469
|
+
return res.catch((e) => {
|
|
17470
|
+
if (e instanceof NotFoundError || isAutotaskError(e) && e.code !== "ABORTED") return null;
|
|
17471
|
+
throw e;
|
|
17472
|
+
});
|
|
17473
|
+
};
|
|
17474
|
+
let remaining = options.budget;
|
|
17475
|
+
if (remaining < 1) {
|
|
17476
|
+
return {
|
|
17477
|
+
lineOfBusiness: { association: null, organizationalLevel2: null, organizationalLevel1: null, markers: { association: "capped", organizationalLevel2: "capped", organizationalLevel1: "capped" } },
|
|
17478
|
+
used: 0,
|
|
17479
|
+
truncated: true
|
|
17480
|
+
};
|
|
17481
|
+
}
|
|
17482
|
+
remaining -= 1;
|
|
17483
|
+
const association = await get(`/V1.0/OrganizationalLevelAssociations/${associationId}`);
|
|
17484
|
+
const associationMarker = association === null ? "unresolved" : "ok";
|
|
17485
|
+
if (association === null) {
|
|
17486
|
+
return {
|
|
17487
|
+
lineOfBusiness: { association: null, organizationalLevel2: null, organizationalLevel1: null, markers: { association: associationMarker, organizationalLevel2: "missing", organizationalLevel1: "missing" } },
|
|
17488
|
+
used: 1,
|
|
17489
|
+
truncated: false
|
|
17490
|
+
};
|
|
17491
|
+
}
|
|
17492
|
+
const l2Id = vendorId(association.organizationalLevel2ID);
|
|
17493
|
+
const l1Id = vendorId(association.organizationalLevel1ID);
|
|
17494
|
+
let l2Marker = l2Id !== void 0 ? "unresolved" : "missing";
|
|
17495
|
+
let l1Marker = l1Id !== void 0 ? "unresolved" : "missing";
|
|
17496
|
+
const need = (l2Id !== void 0 ? 1 : 0) + (l1Id !== void 0 ? 1 : 0);
|
|
17497
|
+
let l2 = null;
|
|
17498
|
+
let l1 = null;
|
|
17499
|
+
let used = 1;
|
|
17500
|
+
let truncated = false;
|
|
17501
|
+
if (need > 0 && remaining < need) {
|
|
17502
|
+
truncated = true;
|
|
17503
|
+
if (l2Id !== void 0) l2Marker = "capped";
|
|
17504
|
+
if (l1Id !== void 0) l1Marker = "capped";
|
|
17505
|
+
} else {
|
|
17506
|
+
used += need;
|
|
17507
|
+
const [r2, r1] = await Promise.all([
|
|
17508
|
+
l2Id !== void 0 ? get(`/V1.0/OrganizationalLevel2s/${l2Id}`) : Promise.resolve(null),
|
|
17509
|
+
l1Id !== void 0 ? get(`/V1.0/OrganizationalLevel1s/${l1Id}`) : Promise.resolve(null)
|
|
17510
|
+
]);
|
|
17511
|
+
l2 = r2;
|
|
17512
|
+
l1 = r1;
|
|
17513
|
+
if (l2Id !== void 0) l2Marker = l2 === null ? "unresolved" : "ok";
|
|
17514
|
+
if (l1Id !== void 0) l1Marker = l1 === null ? "unresolved" : "ok";
|
|
17515
|
+
}
|
|
17516
|
+
return {
|
|
17517
|
+
lineOfBusiness: { association, organizationalLevel2: l2, organizationalLevel1: l1, markers: { association: associationMarker, organizationalLevel2: l2Marker, organizationalLevel1: l1Marker } },
|
|
17518
|
+
used,
|
|
17519
|
+
truncated
|
|
17520
|
+
};
|
|
17521
|
+
}
|
|
17441
17522
|
async function resolveCompositeNames(http, plan, opts = {}) {
|
|
17442
17523
|
if (opts.maxNameReads !== void 0 && (!Number.isInteger(opts.maxNameReads) || opts.maxNameReads < 1)) {
|
|
17443
17524
|
throw new AutotaskConfigError(`composite names: maxNameReads must be an integer >= 1 (got ${String(opts.maxNameReads)})`);
|
|
@@ -17531,8 +17612,16 @@ async function resolveCompositeNames(http, plan, opts = {}) {
|
|
|
17531
17612
|
}
|
|
17532
17613
|
if (!usable) for (const f of plan.labelFields) section.reasons[f] = FIELD_CATALOG_HONESTY_NOTE;
|
|
17533
17614
|
}
|
|
17615
|
+
let lineOfBusiness = null;
|
|
17616
|
+
if (plan.lineOfBusinessId !== void 0) {
|
|
17617
|
+
const chain = await resolveLineOfBusinessChain(http, plan.lineOfBusinessId, { budget: remaining, onError: "degrade" });
|
|
17618
|
+
remaining -= chain.used;
|
|
17619
|
+
if (chain.truncated) section.truncated = true;
|
|
17620
|
+
lineOfBusiness = chain.lineOfBusiness;
|
|
17621
|
+
}
|
|
17534
17622
|
return {
|
|
17535
17623
|
section,
|
|
17624
|
+
lineOfBusiness,
|
|
17536
17625
|
resourceName: (id) => _nullishCoalesce(_optionalChain([section, 'access', _145 => _145.rows, 'access', _146 => _146[`resource:${id}`], 'optionalAccess', _147 => _147.name]), () => ( null)),
|
|
17537
17626
|
recordName: (table, id) => _nullishCoalesce(_optionalChain([section, 'access', _148 => _148.rows, 'access', _149 => _149[`${table}:${id}`], 'optionalAccess', _150 => _150.name]), () => ( null)),
|
|
17538
17627
|
labelFor: (field, value) => {
|
|
@@ -20307,4 +20396,6 @@ async function validateQueryFieldNames(record, holder, args) {
|
|
|
20307
20396
|
|
|
20308
20397
|
|
|
20309
20398
|
|
|
20310
|
-
|
|
20399
|
+
|
|
20400
|
+
|
|
20401
|
+
exports.AUTH_HEADERS = AUTH_HEADERS; exports.buildAuthHeaders = buildAuthHeaders; exports.withAuthHeaders = withAuthHeaders; exports.AutotaskError = AutotaskError; exports.AutotaskConfigError = AutotaskConfigError; exports.isAutotaskError = isAutotaskError; exports.AutotaskNetworkError = AutotaskNetworkError; exports.AutotaskTimeoutError = AutotaskTimeoutError; exports.AutotaskAbortError = AutotaskAbortError; exports.ResponseRejectedError = ResponseRejectedError; exports.BadRequestError = BadRequestError; exports.UnauthorizedError = UnauthorizedError; exports.ForbiddenError = ForbiddenError; exports.NotFoundError = NotFoundError; exports.ConflictError = ConflictError; exports.UnprocessableEntityError = UnprocessableEntityError; exports.RateLimitError = RateLimitError; exports.ServerError = ServerError; exports.UnexpectedContentTypeError = UnexpectedContentTypeError; exports.EmptyResponseError = EmptyResponseError; exports.CircuitBreakerError = CircuitBreakerError; exports.HostPolicyDeniedError = HostPolicyDeniedError; exports.ResolutionError = ResolutionError; exports.PaginationLimitError = PaginationLimitError; exports.QueryTooLongError = QueryTooLongError; exports.parseVendorErrors = parseVendorErrors; exports.isDeterministicVendor500 = isDeterministicVendor500; exports.formatVendorDetail = formatVendorDetail; exports.NoopLogger = NoopLogger; exports.REDACTED = REDACTED; exports.CREDENTIAL_HEADER_NAMES = CREDENTIAL_HEADER_NAMES; exports.isCredentialHeaderName = isCredentialHeaderName; exports.redactRecord = redactRecord; exports.SECRET_RESPONSE_FIELDS = SECRET_RESPONSE_FIELDS; exports.PERSONAL_RESPONSE_FIELDS = PERSONAL_RESPONSE_FIELDS; exports.CONFIDENTIAL_RESPONSE_FIELDS = CONFIDENTIAL_RESPONSE_FIELDS; exports.isRedactedFieldName = isRedactedFieldName; exports.redactResponseBody = redactResponseBody; exports.CREDENTIAL_SHAPE_POINTER = CREDENTIAL_SHAPE_POINTER; exports.mergeDetails = mergeDetails; exports.errorFromStatus = errorFromStatus; exports.StaleObjectError = StaleObjectError; exports.ConfirmationRequiredError = ConfirmationRequiredError; exports.DeleteBoundaryError = DeleteBoundaryError; exports.MarkerUnsafeIdError = MarkerUnsafeIdError; exports.RecoveryTruncatedError = RecoveryTruncatedError; exports.MoveRefusedError = MoveRefusedError; exports.READ_CACHE_MAX_ENTRIES = READ_CACHE_MAX_ENTRIES; exports.ReadCache = ReadCache; exports.ZONE_CATALOG = ZONE_CATALOG; exports.ZONES = ZONES; exports.DEFAULT_ZONE = DEFAULT_ZONE; exports.zoneUrl = zoneUrl; exports.resolveBaseUrl = resolveBaseUrl; exports.AGENT_PROFILE = AGENT_PROFILE; exports.DEFAULT_PAGE_SIZE = DEFAULT_PAGE_SIZE; exports.MAX_PAGE_SIZE = MAX_PAGE_SIZE; exports.DEFAULT_TIMEOUT_MS = DEFAULT_TIMEOUT_MS; exports.DEFAULT_MAX_RETRIES = DEFAULT_MAX_RETRIES; exports.DEFAULT_MAINTENANCE_MAX_WAIT_MS = DEFAULT_MAINTENANCE_MAX_WAIT_MS; exports.DEFAULT_MAINTENANCE_POLL_MS = DEFAULT_MAINTENANCE_POLL_MS; exports.MAINTENANCE_WINDOW_MAX_MS = MAINTENANCE_WINDOW_MAX_MS; exports.DEFAULT_MAX_CONCURRENT = DEFAULT_MAX_CONCURRENT; exports.DEFAULT_MAX_RESPONSE_BYTES = DEFAULT_MAX_RESPONSE_BYTES; exports.DEFAULT_MAX_SCAN_RECORDS = DEFAULT_MAX_SCAN_RECORDS; exports.DEFAULT_MAX_SCAN_PAGES = DEFAULT_MAX_SCAN_PAGES; exports.DEFAULT_READ_CACHE_TTL_MS = DEFAULT_READ_CACHE_TTL_MS; exports.DEFAULT_FIELD_CACHE_TTL_MS = DEFAULT_FIELD_CACHE_TTL_MS; exports.DEFAULT_RESOURCE_NAME_CACHE_TTL_MS = DEFAULT_RESOURCE_NAME_CACHE_TTL_MS; exports.hasSurroundingQuotes = hasSurroundingQuotes; exports.credentialShapeProblem = credentialShapeProblem; exports.CREDENTIAL_ENV_LOAD_ACTION = CREDENTIAL_ENV_LOAD_ACTION; exports.MIN_PREFIX_SUMMARY_LENGTH = MIN_PREFIX_SUMMARY_LENGTH; exports.credentialValueSummary = credentialValueSummary; exports.FIELD_CACHE_KINDS = FIELD_CACHE_KINDS; exports.DEFAULT_CIRCUIT_BREAKER_WINDOW_MS = DEFAULT_CIRCUIT_BREAKER_WINDOW_MS; exports.DEFAULT_CIRCUIT_BREAKER_FAILURE_THRESHOLD = DEFAULT_CIRCUIT_BREAKER_FAILURE_THRESHOLD; exports.DEFAULT_CIRCUIT_BREAKER_OPEN_TIMEOUT_MS = DEFAULT_CIRCUIT_BREAKER_OPEN_TIMEOUT_MS; exports.DEFAULT_CIRCUIT_BREAKER_SUCCESSES_TO_CLOSE = DEFAULT_CIRCUIT_BREAKER_SUCCESSES_TO_CLOSE; exports.DEFAULT_CIRCUIT_BREAKER_MAX_ENTRIES = DEFAULT_CIRCUIT_BREAKER_MAX_ENTRIES; exports.InMemoryCircuitBreakerStore = InMemoryCircuitBreakerStore; exports.defaultCircuitBreakerStore = defaultCircuitBreakerStore; exports.resetDefaultCircuitBreakerStore = resetDefaultCircuitBreakerStore; exports.buildBreakerKey = buildBreakerKey; exports.isBreakerFailure = isBreakerFailure; exports.DEFAULT_COOLDOWN_MAX_MS = DEFAULT_COOLDOWN_MAX_MS; exports.DEFAULT_COOLDOWN_DEFAULT_MS = DEFAULT_COOLDOWN_DEFAULT_MS; exports.DEFAULT_COOLDOWN_MAX_ENTRIES = DEFAULT_COOLDOWN_MAX_ENTRIES; exports.InMemoryCooldownStore = InMemoryCooldownStore; exports.defaultCooldownStore = defaultCooldownStore; exports.resetDefaultCooldownStore = resetDefaultCooldownStore; exports.buildTenantKey = buildTenantKey; exports.cooldownDurationMs = cooldownDurationMs; exports.resolveCredentials = resolveCredentials; exports.buildReadCache = buildReadCache; exports.resolveConfig = resolveConfig; exports.IDEMPOTENT_METHODS = IDEMPOTENT_METHODS; exports.isRecord = isRecord2; exports.assertRecord = assertRecord; exports.deepMergeParams = deepMergeParams; exports.isIdentifierCandidate = isIdentifierCandidate; exports.parseIdentifier = parseIdentifier; exports.flattenUdfs = flattenUdfs; exports.newCorrelationId = newCorrelationId; exports.redactAuditBody = redactAuditBody; exports.camelKey = camelKey; exports.FILTER_OPERATORS = FILTER_OPERATORS; exports.GROUPING_OPERATORS = GROUPING_OPERATORS; exports.MAX_OR_CONDITIONS = MAX_OR_CONDITIONS; exports.MAX_UDF_PER_QUERY = MAX_UDF_PER_QUERY; exports.MAX_QUERY_LENGTH = MAX_QUERY_LENGTH; exports.MAX_GET_LENGTH = MAX_GET_LENGTH; exports.MAX_FIELD_LENGTH = MAX_FIELD_LENGTH; exports.isFilterOperator = isFilterOperator; exports.serializeFilter = serializeFilter; exports.validateFilter = validateFilter; exports.buildFilter = buildFilter; exports.normalizedConditions = normalizedConditions; exports.buildUrl = buildUrl; exports.cursorToPath = cursorToPath; exports.buildQueryBody = buildQueryBody; exports.buildQueryRequest = buildQueryRequest; exports.runWithSignal = runWithSignal; exports.RELATIONSHIP_ZONE = RELATIONSHIP_ZONE; exports.RELATIONSHIP_MAP = RELATIONSHIP_MAP; exports.BLIND_SURFACE_STAMPS = BLIND_SURFACE_STAMPS; exports.DELETE_BOUNDARY_NOTES = DELETE_BOUNDARY_NOTES; exports.MARKER_FIELDS = MARKER_FIELDS; exports.EMPTY_REASON_STAMPS = EMPTY_REASON_STAMPS; exports.BLIND_SURFACE_INVENTORY = BLIND_SURFACE_INVENTORY; exports.REACHABILITY_PROBE_DEFAULTS = REACHABILITY_PROBE_DEFAULTS; exports.CREATE_GUIDANCE = CREATE_GUIDANCE; exports.UNTRUSTED_FIELDS_BY_RESOURCE = UNTRUSTED_FIELDS_BY_RESOURCE; exports.unwrapItems = unwrapItems; exports.unwrapItem = unwrapItem; exports.unwrapQueryCount = unwrapQueryCount; exports.unwrapOperation = unwrapOperation; exports.passthrough = passthrough; exports.HttpClient = HttpClient; exports.BOUNDED_QUERY_MAX_LIMIT = BOUNDED_QUERY_MAX_LIMIT; exports.truncateNoteChars = truncateNoteChars; exports.buildDryRunResult = buildDryRunResult; exports.mergePartialBody = mergePartialBody; exports.blindStampFor = blindStampFor; exports.decodeFileData = decodeFileData; exports.MAX_PAGES = MAX_PAGES; exports.clampPageSize = clampPageSize; exports.totalPagesFor = totalPagesFor; exports.paginate = paginate; exports.paginateItems = paginateItems; exports.collectAll = collectAll; exports.toArray = toArray; exports.FIELD_PRESETS = FIELD_PRESETS; exports.FIELD_PRESET_NAMES = FIELD_PRESET_NAMES; exports.resolveFieldsPreset = resolveFieldsPreset; exports.BaseResource = BaseResource; exports.MODEL_FIELD_SETS = MODEL_FIELD_SETS; exports.MODEL_DATE_FIELDS = MODEL_DATE_FIELDS; exports.formatUnknownNameList = formatUnknownNameList; exports.validateQueryFieldNames = validateQueryFieldNames; exports.EXPAND_RESOURCE_NAMES_MAX_IDS = EXPAND_RESOURCE_NAMES_MAX_IDS; exports.expandResourceNames = expandResourceNames; exports.ENTITY_TYPE_TO_RESOURCE = ENTITY_TYPE_TO_RESOURCE; exports.resourceForEntityType = resourceForEntityType; exports.isEnumerableResource = isEnumerableResource; exports.WORKFLOW_RESOURCES = WORKFLOW_RESOURCES; exports.MAX_FIELD_CATALOG_WIRE = MAX_FIELD_CATALOG_WIRE; exports.FIELD_CATALOG_HONESTY_NOTE = FIELD_CATALOG_HONESTY_NOTE; exports.fieldCatalog = fieldCatalog; exports.PICKLIST_VALUE_NOT_SERVED_NOTE = PICKLIST_VALUE_NOT_SERVED_NOTE; exports.TICKET_LABEL_FIELDS = TICKET_LABEL_FIELDS; exports.createNamePlan = createNamePlan; exports.addNameSibling = addNameSibling; exports.addLabelSibling = addLabelSibling; exports.vendorId = vendorId; exports.resolveLineOfBusinessChain = resolveLineOfBusinessChain; exports.resolveCompositeNames = resolveCompositeNames; exports.FETCH_MANY_MAX_ITEMS = FETCH_MANY_MAX_ITEMS; exports.validateFetchManyItems = validateFetchManyItems; exports.fetchMany = fetchMany; exports.FETCH_BY_IDS_MAX_ITEMS = FETCH_BY_IDS_MAX_ITEMS; exports.FETCH_BY_IDS_CHUNK_SIZE = FETCH_BY_IDS_CHUNK_SIZE; exports.fetchByIds = fetchByIds; exports.UI_LINK_ENTITIES = UI_LINK_ENTITIES; exports.buildUiLink = buildUiLink; exports.uiLink = uiLink;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CAPABILITIES
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WKP442HS.js";
|
|
4
4
|
|
|
5
5
|
// src/auth.ts
|
|
6
6
|
var AUTH_HEADERS = {
|
|
@@ -17390,8 +17390,9 @@ function createNamePlan(labelFields = []) {
|
|
|
17390
17390
|
const resSeen = /* @__PURE__ */ new Set();
|
|
17391
17391
|
const recordFks = [];
|
|
17392
17392
|
const fkSeen = /* @__PURE__ */ new Set();
|
|
17393
|
+
let lineOfBusinessId;
|
|
17393
17394
|
return {
|
|
17394
|
-
plan: () => ({ resourceIds, recordFks, labelFields }),
|
|
17395
|
+
plan: () => ({ resourceIds, recordFks, labelFields, ...lineOfBusinessId !== void 0 ? { lineOfBusinessId } : {} }),
|
|
17395
17396
|
addResource: (value) => {
|
|
17396
17397
|
if (!isVendorId(value)) return;
|
|
17397
17398
|
const k = String(value);
|
|
@@ -17407,6 +17408,10 @@ function createNamePlan(labelFields = []) {
|
|
|
17407
17408
|
fkSeen.add(k);
|
|
17408
17409
|
recordFks.push({ table, id: value });
|
|
17409
17410
|
}
|
|
17411
|
+
},
|
|
17412
|
+
addLineOfBusiness: (value) => {
|
|
17413
|
+
if (!isVendorId(value)) return;
|
|
17414
|
+
lineOfBusinessId = value;
|
|
17410
17415
|
}
|
|
17411
17416
|
};
|
|
17412
17417
|
}
|
|
@@ -17438,6 +17443,82 @@ function faultRow(err) {
|
|
|
17438
17443
|
const e = err;
|
|
17439
17444
|
return e.httpStatus !== void 0 ? { code: e.code, message: e.message, httpStatus: e.httpStatus } : { code: e.code, message: e.message };
|
|
17440
17445
|
}
|
|
17446
|
+
function vendorId(value) {
|
|
17447
|
+
if (typeof value === "number") return Number.isSafeInteger(value) && value >= 1 ? value : void 0;
|
|
17448
|
+
if (typeof value === "string" && /^[0-9]+$/.test(value.trim())) {
|
|
17449
|
+
const n = Number(value.trim());
|
|
17450
|
+
return Number.isSafeInteger(n) && n >= 1 ? n : void 0;
|
|
17451
|
+
}
|
|
17452
|
+
return void 0;
|
|
17453
|
+
}
|
|
17454
|
+
async function resolveLineOfBusinessChain(http, associationId, options) {
|
|
17455
|
+
const operation = options.operation ?? "compositeNames";
|
|
17456
|
+
const degrade = options.onError === "degrade";
|
|
17457
|
+
const get = (path) => {
|
|
17458
|
+
const res = http.request({ method: "GET", path, operation }).then((body) => {
|
|
17459
|
+
const b = body;
|
|
17460
|
+
if (b === null || !("item" in b) || b.item === null || b.item === void 0) return null;
|
|
17461
|
+
return b.item;
|
|
17462
|
+
});
|
|
17463
|
+
if (!degrade) {
|
|
17464
|
+
return res.catch((e) => {
|
|
17465
|
+
if (e instanceof NotFoundError) return null;
|
|
17466
|
+
throw e;
|
|
17467
|
+
});
|
|
17468
|
+
}
|
|
17469
|
+
return res.catch((e) => {
|
|
17470
|
+
if (e instanceof NotFoundError || isAutotaskError(e) && e.code !== "ABORTED") return null;
|
|
17471
|
+
throw e;
|
|
17472
|
+
});
|
|
17473
|
+
};
|
|
17474
|
+
let remaining = options.budget;
|
|
17475
|
+
if (remaining < 1) {
|
|
17476
|
+
return {
|
|
17477
|
+
lineOfBusiness: { association: null, organizationalLevel2: null, organizationalLevel1: null, markers: { association: "capped", organizationalLevel2: "capped", organizationalLevel1: "capped" } },
|
|
17478
|
+
used: 0,
|
|
17479
|
+
truncated: true
|
|
17480
|
+
};
|
|
17481
|
+
}
|
|
17482
|
+
remaining -= 1;
|
|
17483
|
+
const association = await get(`/V1.0/OrganizationalLevelAssociations/${associationId}`);
|
|
17484
|
+
const associationMarker = association === null ? "unresolved" : "ok";
|
|
17485
|
+
if (association === null) {
|
|
17486
|
+
return {
|
|
17487
|
+
lineOfBusiness: { association: null, organizationalLevel2: null, organizationalLevel1: null, markers: { association: associationMarker, organizationalLevel2: "missing", organizationalLevel1: "missing" } },
|
|
17488
|
+
used: 1,
|
|
17489
|
+
truncated: false
|
|
17490
|
+
};
|
|
17491
|
+
}
|
|
17492
|
+
const l2Id = vendorId(association.organizationalLevel2ID);
|
|
17493
|
+
const l1Id = vendorId(association.organizationalLevel1ID);
|
|
17494
|
+
let l2Marker = l2Id !== void 0 ? "unresolved" : "missing";
|
|
17495
|
+
let l1Marker = l1Id !== void 0 ? "unresolved" : "missing";
|
|
17496
|
+
const need = (l2Id !== void 0 ? 1 : 0) + (l1Id !== void 0 ? 1 : 0);
|
|
17497
|
+
let l2 = null;
|
|
17498
|
+
let l1 = null;
|
|
17499
|
+
let used = 1;
|
|
17500
|
+
let truncated = false;
|
|
17501
|
+
if (need > 0 && remaining < need) {
|
|
17502
|
+
truncated = true;
|
|
17503
|
+
if (l2Id !== void 0) l2Marker = "capped";
|
|
17504
|
+
if (l1Id !== void 0) l1Marker = "capped";
|
|
17505
|
+
} else {
|
|
17506
|
+
used += need;
|
|
17507
|
+
const [r2, r1] = await Promise.all([
|
|
17508
|
+
l2Id !== void 0 ? get(`/V1.0/OrganizationalLevel2s/${l2Id}`) : Promise.resolve(null),
|
|
17509
|
+
l1Id !== void 0 ? get(`/V1.0/OrganizationalLevel1s/${l1Id}`) : Promise.resolve(null)
|
|
17510
|
+
]);
|
|
17511
|
+
l2 = r2;
|
|
17512
|
+
l1 = r1;
|
|
17513
|
+
if (l2Id !== void 0) l2Marker = l2 === null ? "unresolved" : "ok";
|
|
17514
|
+
if (l1Id !== void 0) l1Marker = l1 === null ? "unresolved" : "ok";
|
|
17515
|
+
}
|
|
17516
|
+
return {
|
|
17517
|
+
lineOfBusiness: { association, organizationalLevel2: l2, organizationalLevel1: l1, markers: { association: associationMarker, organizationalLevel2: l2Marker, organizationalLevel1: l1Marker } },
|
|
17518
|
+
used,
|
|
17519
|
+
truncated
|
|
17520
|
+
};
|
|
17521
|
+
}
|
|
17441
17522
|
async function resolveCompositeNames(http, plan, opts = {}) {
|
|
17442
17523
|
if (opts.maxNameReads !== void 0 && (!Number.isInteger(opts.maxNameReads) || opts.maxNameReads < 1)) {
|
|
17443
17524
|
throw new AutotaskConfigError(`composite names: maxNameReads must be an integer >= 1 (got ${String(opts.maxNameReads)})`);
|
|
@@ -17531,8 +17612,16 @@ async function resolveCompositeNames(http, plan, opts = {}) {
|
|
|
17531
17612
|
}
|
|
17532
17613
|
if (!usable) for (const f of plan.labelFields) section.reasons[f] = FIELD_CATALOG_HONESTY_NOTE;
|
|
17533
17614
|
}
|
|
17615
|
+
let lineOfBusiness = null;
|
|
17616
|
+
if (plan.lineOfBusinessId !== void 0) {
|
|
17617
|
+
const chain = await resolveLineOfBusinessChain(http, plan.lineOfBusinessId, { budget: remaining, onError: "degrade" });
|
|
17618
|
+
remaining -= chain.used;
|
|
17619
|
+
if (chain.truncated) section.truncated = true;
|
|
17620
|
+
lineOfBusiness = chain.lineOfBusiness;
|
|
17621
|
+
}
|
|
17534
17622
|
return {
|
|
17535
17623
|
section,
|
|
17624
|
+
lineOfBusiness,
|
|
17536
17625
|
resourceName: (id) => section.rows[`resource:${id}`]?.name ?? null,
|
|
17537
17626
|
recordName: (table, id) => section.rows[`${table}:${id}`]?.name ?? null,
|
|
17538
17627
|
labelFor: (field, value) => {
|
|
@@ -20297,6 +20386,8 @@ export {
|
|
|
20297
20386
|
createNamePlan,
|
|
20298
20387
|
addNameSibling,
|
|
20299
20388
|
addLabelSibling,
|
|
20389
|
+
vendorId,
|
|
20390
|
+
resolveLineOfBusinessChain,
|
|
20300
20391
|
resolveCompositeNames,
|
|
20301
20392
|
FETCH_MANY_MAX_ITEMS,
|
|
20302
20393
|
validateFetchManyItems,
|