node-autotask 0.71.0 → 0.73.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/MCP_TOOL_CATALOG.json +196 -9
  3. package/README.md +1 -1
  4. package/capabilities.json +651 -9
  5. package/dist/capabilities-data.js +650 -8
  6. package/dist/capabilities.cjs +4 -4
  7. package/dist/capabilities.js +1 -1
  8. package/dist/{chunk-4DSLRDIF.cjs → chunk-CKIKNZEB.cjs} +31 -30
  9. package/dist/{chunk-QQFF7X67.cjs → chunk-CWSXFVF2.cjs} +229 -16
  10. package/dist/{chunk-YKQ2KNQO.js → chunk-L4J5EDCU.js} +3 -2
  11. package/dist/{chunk-LKJA57CH.js → chunk-PNMEXWYR.js} +3 -3
  12. package/dist/{chunk-5COLIVBE.js → chunk-RFH4VBMX.js} +126 -2
  13. package/dist/{chunk-QJ327YI6.cjs → chunk-STUQU7AX.cjs} +301 -177
  14. package/dist/{chunk-4OR3XBIP.js → chunk-VHN5B7OQ.js} +223 -12
  15. package/dist/{chunk-JLCHKCEB.cjs → chunk-VHNWLON6.cjs} +3 -3
  16. package/dist/{index-CM_SRgtH.d.cts → index-CGp16Cdm.d.cts} +49 -21
  17. package/dist/{index-CM_SRgtH.d.ts → index-CGp16Cdm.d.ts} +49 -21
  18. package/dist/{index-lGpxr4gY.d.ts → index-Dv8d9p_J.d.ts} +165 -4
  19. package/dist/{index-CAXT5ZKT.d.cts → index-MUM-uBX1.d.cts} +165 -4
  20. package/dist/index.cjs +84 -84
  21. package/dist/index.d.cts +3 -5
  22. package/dist/index.d.ts +3 -5
  23. package/dist/index.js +5 -5
  24. package/dist/operations/index.cjs +51 -51
  25. package/dist/operations/index.d.cts +5 -6
  26. package/dist/operations/index.d.ts +5 -6
  27. package/dist/operations/index.js +2 -2
  28. package/dist/pool.cjs +12 -12
  29. package/dist/pool.d.cts +1 -1
  30. package/dist/pool.d.ts +1 -1
  31. package/dist/pool.js +4 -4
  32. package/dist/resources/index.cjs +27 -27
  33. package/dist/resources/index.d.cts +2 -2
  34. package/dist/resources/index.d.ts +2 -2
  35. package/dist/resources/index.js +3 -3
  36. package/dist/types/index.d.cts +1 -1
  37. package/dist/types/index.d.ts +1 -1
  38. package/docs/API.md +26 -7
  39. package/docs/N8N-ADAPTER.md +1 -1
  40. package/package.json +1 -1
  41. package/dist/base-CHMATPq0.d.cts +0 -145
  42. package/dist/base-CHMATPq0.d.ts +0 -145
@@ -1,5 +1,5 @@
1
- import { GenericResource, readTasks, parseIdentifier, AutotaskConfigError, StaleObjectError, buildDryRunResult, createNamePlan, resolveCompositeNames, addNameSibling, NotFoundError, unwrapItems, ConflictError, clientOf, compositePartLimit, invokeRead, compositePart, openTicketsOfPart, unwrapOperation, unwrapItem, ResolutionError, joinedCompositePart, runMove, resolveTicketStatusSemantics, openStatusFilter, isClosedStatus, vendorId, isAutotaskError, resolveLineOfBusinessChain, cachedRecordGet, uiLinkFor, refuse, queryRows, mergePartialBody, AutotaskError, TICKET_LABEL_FIELDS, addLabelSibling, parseVendorErrors, RELATIONSHIP_MAP, cursorToPath } from './chunk-4OR3XBIP.js';
2
- import { loadCapabilityRecords } from './chunk-LKJA57CH.js';
1
+ import { GenericResource, readTasks, OperationNotSupportedError, parseIdentifier, AutotaskConfigError, isRecord, isDateYMD, isAutotaskError, RateLimitError, MaintenanceError, AutotaskError, StaleObjectError, buildDryRunResult, createNamePlan, resolveCompositeNames, addNameSibling, NotFoundError, unwrapItems, ConflictError, clientOf, compositePartLimit, invokeRead, compositePart, openTicketsOfPart, unwrapOperation, unwrapItem, ResolutionError, joinedCompositePart, runMove, resolveTicketStatusSemantics, openStatusFilter, isClosedStatus, vendorId, resolveLineOfBusinessChain, cachedRecordGet, uiLinkFor, refuse, queryRows, mergePartialBody, TICKET_LABEL_FIELDS, addLabelSibling, parseVendorErrors, RELATIONSHIP_MAP, cursorToPath } from './chunk-VHN5B7OQ.js';
2
+ import { loadCapabilityRecords } from './chunk-PNMEXWYR.js';
3
3
 
4
4
  // src/resources/special/configuration_items.ts
5
5
  async function fetchRecord(http, path, label, readOpts) {
@@ -1842,10 +1842,134 @@ var TimeOffRequestsResource = class extends GenericResource {
1842
1842
  super(http, {
1843
1843
  key: "time_off_requests",
1844
1844
  resourcePath: "/V1.0/TimeOffRequests",
1845
+ parentScopedPath: "/V1.0/Resources/{parentId}/TimeOffRequests",
1846
+ parentPath: "/V1.0/Resources",
1847
+ parentField: "resourceID",
1848
+ staleField: "lastModifiedDateTime",
1849
+ ops: { query: true, queryAll: false, count: true, get: true, create: true, update: true, delete: false, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
1850
+ helpers: { search: false, resolve: true, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
1845
1851
  deletable: false,
1846
1852
  udfCapable: false
1847
1853
  }, pageSize);
1848
1854
  }
1855
+ async get(id, opts) {
1856
+ if (typeof opts === "number" || typeof opts === "string") {
1857
+ throw new OperationNotSupportedError("time_off_requests", "get");
1858
+ }
1859
+ return super.get(id, opts);
1860
+ }
1861
+ async create(a, b, c = {}) {
1862
+ if (typeof a !== "number" && typeof a !== "string") throw new OperationNotSupportedError("time_off_requests", "create");
1863
+ const parentId = parseIdentifier(a, "parentId");
1864
+ if (typeof parentId !== "number") throw this.writeError("create", "parentId cannot be represented safely in the numeric resourceID create body; this is an SDK create-body limit, not a vendor record-id maximum");
1865
+ const data = this.writePayload(b, "create");
1866
+ if (data.resourceID !== void 0 && data.resourceID !== parentId) throw this.writeError("create", "resourceID must equal parentId");
1867
+ const fields = await this.guardWriteStatus(data.status, "Submitted", "create");
1868
+ this.guardChoice(fields, "timeOffRequestType", data.timeOffRequestType, "create");
1869
+ return super.create(parentId, { ...data, resourceID: parentId }, c);
1870
+ }
1871
+ async update(a, b, c, d = {}) {
1872
+ if (typeof b !== "number" && typeof b !== "string") throw new OperationNotSupportedError("time_off_requests", "update");
1873
+ const parentId = parseIdentifier(a, "parentId");
1874
+ const id = parseIdentifier(b, "id");
1875
+ const data = this.writePayload(c, "update");
1876
+ await this.guardWriteStatus(data.status, "Canceled", "update");
1877
+ if (d.dryRun === true) {
1878
+ const preview = await this.runUpdateDryRun(id, data, d, parentId);
1879
+ if (!preview.wouldApply) return preview;
1880
+ return {
1881
+ ...preview,
1882
+ impact: { ...preview.impact, reversible: false },
1883
+ warnings: [...preview.warnings, "A canceled time-off request cannot be restored through the public API."]
1884
+ };
1885
+ }
1886
+ const current = await this.getScopedRaw(parentId, id, true);
1887
+ this.staleObjectCheck(current, d, "time_off_requests.update");
1888
+ return this.updateScopedRaw(parentId, id, data, d);
1889
+ }
1890
+ async getScopedRaw(parentId, id, fresh = false) {
1891
+ const current = await super.getScopedRaw(parentId, id, fresh);
1892
+ if (current.resourceID === void 0 || parseIdentifier(current.resourceID, "resourceID") !== parentId) {
1893
+ throw this.writeError("update", "the current request resourceID must match parentId");
1894
+ }
1895
+ if (parseIdentifier(current.id, "id") !== id) {
1896
+ throw this.writeError("update", "the current request id must match the requested id");
1897
+ }
1898
+ return current;
1899
+ }
1900
+ async createIfNotExists(..._args) {
1901
+ throw new OperationNotSupportedError("time_off_requests", "createIfNotExists");
1902
+ }
1903
+ // Cancellation permits status only; never replace a full model through PUT fallback.
1904
+ putFallbackEligible(_err) {
1905
+ return false;
1906
+ }
1907
+ writeError(operation, detail) {
1908
+ return new AutotaskConfigError(`time_off_requests.${operation}: ${detail}`, { operation: `time_off_requests.${operation}` });
1909
+ }
1910
+ writePayload(value, operation) {
1911
+ if (!isRecord(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) throw this.writeError(operation, "supply a plain object");
1912
+ const allowed = operation === "create" ? ["hours", "requestDate", "resourceID", "status", "timeOffRequestType"] : ["status"];
1913
+ for (const key of Object.keys(value)) if (!allowed.includes(key)) throw this.writeError(operation, operation === "update" ? "cancellation accepts status only" : `${key} is not a supported create field`);
1914
+ if (typeof value.status !== "number" || !Number.isSafeInteger(value.status)) throw this.writeError(operation, "status must be a numeric picklist id");
1915
+ if (operation === "create") {
1916
+ if (typeof value.hours !== "number" || !Number.isFinite(value.hours) || value.hours < -24 || value.hours > 24) throw this.writeError(operation, "hours must be a finite decimal in the documented range -24 to 24");
1917
+ const date = value.requestDate;
1918
+ if (typeof date !== "string" || !isDateYMD(date.slice(0, 10)) || date.length !== 10 && (!/^T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(date.slice(10)) || !Number.isFinite(Date.parse(date)))) {
1919
+ throw this.writeError(operation, "requestDate must be an ISO calendar date or timestamp for the single requested day");
1920
+ }
1921
+ if (typeof value.timeOffRequestType !== "number" || !Number.isSafeInteger(value.timeOffRequestType)) throw this.writeError(operation, "timeOffRequestType must be a numeric picklist id");
1922
+ if (value.resourceID !== void 0) {
1923
+ if (typeof value.resourceID !== "number") throw this.writeError(operation, "resourceID must be a numeric identifier");
1924
+ parseIdentifier(value.resourceID, "resourceID");
1925
+ }
1926
+ }
1927
+ return { ...value, status: value.status };
1928
+ }
1929
+ async guardWriteStatus(status, label, operation) {
1930
+ let fields;
1931
+ try {
1932
+ fields = await this.cachedMeta("fields", `${this.resourcePath}/entityInformation/fields`, "time_off_requests.getFieldInfo", (body) => this.unwrapFields(body, "FieldInformationResultModel"), true);
1933
+ } catch (error) {
1934
+ if (isAutotaskError(error) && error.code === "ABORTED") throw error;
1935
+ if ((error instanceof RateLimitError || error instanceof MaintenanceError) && error.notSent === true) throw error;
1936
+ const detail = `status requires readable current field metadata for ${label}`;
1937
+ if (!isAutotaskError(error)) throw this.writeError(operation, detail);
1938
+ const safe = new AutotaskError(`time_off_requests.${operation}: ${detail}`, {
1939
+ code: error.code,
1940
+ category: error.category,
1941
+ correlationId: error.correlationId,
1942
+ httpStatus: error.httpStatus,
1943
+ nextAction: error.nextAction,
1944
+ operation: error.operation,
1945
+ retryable: error.retryable,
1946
+ suggestedAction: error.suggestedAction,
1947
+ url: error.url,
1948
+ ...error instanceof MaintenanceError ? { details: {
1949
+ since: error.details?.since,
1950
+ retryAfterMs: error.details?.retryAfterMs
1951
+ } } : {}
1952
+ });
1953
+ Object.setPrototypeOf(safe, Object.getPrototypeOf(error));
1954
+ safe.name = error.name;
1955
+ if (error instanceof RateLimitError || error instanceof MaintenanceError) {
1956
+ Object.assign(safe, { retryAfter: error.retryAfter, notSent: error.notSent });
1957
+ }
1958
+ throw safe;
1959
+ }
1960
+ this.guardChoice(fields, "status", status, operation, label);
1961
+ return fields;
1962
+ }
1963
+ guardChoice(fields, name, id, operation, label) {
1964
+ const unavailable = () => this.writeError(operation, `${name} requires an unambiguous active exposed ${label ?? "request-type"} picklist value; inspect time_off_requests.getFieldInfo`);
1965
+ const rows = fields.filter((field) => isRecord(field) && field.name === name);
1966
+ if (rows.length !== 1 || rows[0].isPickList !== true || !Array.isArray(rows[0].picklistValues)) throw unavailable();
1967
+ const values = rows[0].picklistValues;
1968
+ const numeric = (value) => isRecord(value) && typeof value.value === "string" && /^-?\d+$/.test(value.value) && Number.isSafeInteger(Number(value.value));
1969
+ const named = label === void 0 ? values.filter((value) => numeric(value) && Number(value.value) === id) : values.filter((value) => isRecord(value) && typeof value.label === "string" && value.label.trim().toLowerCase() === label.toLowerCase());
1970
+ if (named.length !== 1 || !numeric(named[0]) || named[0].isActive !== true || Number(named[0].value) !== id) throw unavailable();
1971
+ if (values.filter((value) => numeric(value) && Number(value.value) === id).length !== 1) throw unavailable();
1972
+ }
1849
1973
  /** Node-parity special op (hand-written in src/resources/special/time_off_requests.ts). */
1850
1974
  approve(id, opts = {}) {
1851
1975
  return approve(this, id, opts);