node-autotask 0.93.0 → 0.93.1

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.
@@ -1,5 +1,5 @@
1
- import { ConfigurationItemsResource, ContactsResource, InventoryProductsResource, QuotesResource, ResourceTimeOffAdditionalResource, ResourceTimeOffBalancesResource, ResourcesResource, ServiceCallsResource, TicketChargesResource, TicketsResource, TimeOffRequestsResource, AuthenticateResource, EntityInformationResource, ModulesResource, ThresholdInformationResource, VersionResource, VersionInformationResource, ZoneInformationResource } from './chunk-FCQPZAIK.js';
2
- import { resolveConfig, HttpClient, SIMPLE_RESOURCES, GenericResource, CompaniesResource, ContractsResource, InvoicesResource, TimeEntriesResource, runWithSignal, runBounded } from './chunk-HJKI5VVJ.js';
1
+ import { ConfigurationItemsResource, ContactsResource, InventoryProductsResource, QuotesResource, ResourceTimeOffAdditionalResource, ResourceTimeOffBalancesResource, ResourcesResource, ServiceCallsResource, TicketChargesResource, TicketsResource, TimeOffRequestsResource, AuthenticateResource, EntityInformationResource, ModulesResource, ThresholdInformationResource, VersionResource, VersionInformationResource, ZoneInformationResource } from './chunk-NDGMPMCW.js';
2
+ import { resolveConfig, HttpClient, SIMPLE_RESOURCES, GenericResource, CompaniesResource, ContractsResource, InvoicesResource, TimeEntriesResource, runWithSignal, runBounded } from './chunk-TWQQ3EER.js';
3
3
 
4
4
  // src/client.ts
5
5
  var AutotaskClient = class {
@@ -1,4 +1,4 @@
1
- import { GenericResource, readTasks, OperationNotSupportedError, rejectInventoryFactsOption, 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-HJKI5VVJ.js';
1
+ import { GenericResource, readTasks, OperationNotSupportedError, rejectInventoryFactsOption, 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-TWQQ3EER.js';
2
2
  import { loadCapabilityRecords } from './chunk-DCISF6AG.js';
3
3
 
4
4
  // src/resources/special/configuration_items.ts
@@ -19529,6 +19529,7 @@ function kindFetches(holder, resource) {
19529
19529
  udf: () => holder?.getUdfInfo?.() ?? Promise.reject(new AutotaskError(`fieldCatalog: the client exposes no getUdfInfo read for "${resource}"`, { code: "INVALID_RESPONSE", category: "server" }))
19530
19530
  };
19531
19531
  }
19532
+ var KIND_OPERATIONS = { info: "getEntityInfo", fields: "getFieldInfo", udf: "getUdfInfo" };
19532
19533
  function catalogProjector(kind, ctx) {
19533
19534
  if (ctx.compact) {
19534
19535
  const keepValues = ctx.labels && ctx.fieldsFilter !== void 0;
@@ -19584,6 +19585,11 @@ async function sweepResource(ctx, resource, tally, reads) {
19584
19585
  } else if (peek.age !== null) ages.push(peek.age);
19585
19586
  if (outcome.status === "rejected") {
19586
19587
  const error = outcome.reason;
19588
+ const { category, httpStatus } = error;
19589
+ const operation = `${resource}.${KIND_OPERATIONS[kind]}`;
19590
+ if (category === "auth" && error.operation === operation && (httpStatus === 401 || httpStatus === 403) && (tally.authFailure === void 0 || httpStatus < tally.authFailure.httpStatus)) {
19591
+ tally.authFailure = { httpStatus, operation };
19592
+ }
19587
19593
  if (row.error === null) row.error = { code: error.code, message: error.message };
19588
19594
  continue;
19589
19595
  }
@@ -19666,6 +19672,7 @@ async function fieldCatalog(client, opts) {
19666
19672
  ttlMs: cache?.ttlMs ?? null,
19667
19673
  fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
19668
19674
  rows,
19675
+ ...tally.authFailure === void 0 ? {} : { authFailure: tally.authFailure },
19669
19676
  wireUsed: tally.wireUsed,
19670
19677
  cap: MAX_FIELD_CATALOG_WIRE,
19671
19678
  truncated: false,
@@ -32119,7 +32126,8 @@ async function guardUnscopedQueryWalk(holder, operation, bag) {
32119
32126
  counted = await holder.count({ filter: conditions === void 0 ? void 0 : conditions });
32120
32127
  } catch (err) {
32121
32128
  const code = err?.code;
32122
- if (typeof code === "string" && PROPAGATE_CODES.has(code)) throw err;
32129
+ const denied = isAutotaskError(err) && err.category === "auth" && (err.httpStatus === 401 || err.httpStatus === 403);
32130
+ if (denied || typeof code === "string" && PROPAGATE_CODES.has(code)) throw err;
32123
32131
  const label = typeof code === "string" && /^[A-Z][A-Z_]{2,40}$/.test(code) ? ` (${code})` : "";
32124
32132
  return { note: `scope check skipped: the pre-flight count failed${label}; this unscoped walk was not guarded.` };
32125
32133
  }
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkX7FGWEZ2_cjs = require('./chunk-X7FGWEZ2.cjs');
4
- var chunkZIBH42H3_cjs = require('./chunk-ZIBH42H3.cjs');
3
+ var chunkI75N5VVE_cjs = require('./chunk-I75N5VVE.cjs');
4
+ var chunkNRO2NJAZ_cjs = require('./chunk-NRO2NJAZ.cjs');
5
5
 
6
6
  // src/client.ts
7
7
  var AutotaskClient = class {
@@ -180,34 +180,34 @@ var AutotaskClient = class {
180
180
  * anything is wired. Construction issues NO request.
181
181
  */
182
182
  constructor(options) {
183
- this.config = chunkZIBH42H3_cjs.resolveConfig(options);
184
- this.http = new chunkZIBH42H3_cjs.HttpClient(this.config);
183
+ this.config = chunkNRO2NJAZ_cjs.resolveConfig(options);
184
+ this.http = new chunkNRO2NJAZ_cjs.HttpClient(this.config);
185
185
  this.http.client = this;
186
- for (const entry of chunkZIBH42H3_cjs.SIMPLE_RESOURCES) {
187
- this[entry.accessor] = new chunkZIBH42H3_cjs.GenericResource(this.http, entry, this.config.pageSize);
186
+ for (const entry of chunkNRO2NJAZ_cjs.SIMPLE_RESOURCES) {
187
+ this[entry.accessor] = new chunkNRO2NJAZ_cjs.GenericResource(this.http, entry, this.config.pageSize);
188
188
  }
189
- this.companies = new chunkZIBH42H3_cjs.CompaniesResource(this.http, this.config.pageSize);
190
- this.configurationItems = new chunkX7FGWEZ2_cjs.ConfigurationItemsResource(this.http, this.config.pageSize);
191
- this.contacts = new chunkX7FGWEZ2_cjs.ContactsResource(this.http, this.config.pageSize);
192
- this.contracts = new chunkZIBH42H3_cjs.ContractsResource(this.http, this.config.pageSize);
193
- this.inventoryProducts = new chunkX7FGWEZ2_cjs.InventoryProductsResource(this.http, this.config.pageSize);
194
- this.invoices = new chunkZIBH42H3_cjs.InvoicesResource(this.http, this.config.pageSize);
195
- this.quotes = new chunkX7FGWEZ2_cjs.QuotesResource(this.http, this.config.pageSize);
196
- this.resourceTimeOffAdditional = new chunkX7FGWEZ2_cjs.ResourceTimeOffAdditionalResource(this.http, this.config.pageSize);
197
- this.resourceTimeOffBalances = new chunkX7FGWEZ2_cjs.ResourceTimeOffBalancesResource(this.http, this.config.pageSize);
198
- this.resources = new chunkX7FGWEZ2_cjs.ResourcesResource(this.http, this.config, this.config.pageSize);
199
- this.serviceCalls = new chunkX7FGWEZ2_cjs.ServiceCallsResource(this.http, this.config.pageSize);
200
- this.ticketCharges = new chunkX7FGWEZ2_cjs.TicketChargesResource(this.http, this.config.pageSize);
201
- this.tickets = new chunkX7FGWEZ2_cjs.TicketsResource(this.http, this.config.pageSize);
202
- this.timeEntries = new chunkZIBH42H3_cjs.TimeEntriesResource(this.http, this.config.pageSize);
203
- this.timeOffRequests = new chunkX7FGWEZ2_cjs.TimeOffRequestsResource(this.http, this.config.pageSize);
204
- this.authenticateResource = new chunkX7FGWEZ2_cjs.AuthenticateResource(this.http);
205
- this.entityInformation = new chunkX7FGWEZ2_cjs.EntityInformationResource(this.http);
206
- this.modules = new chunkX7FGWEZ2_cjs.ModulesResource(this.http);
207
- this.thresholdInformation = new chunkX7FGWEZ2_cjs.ThresholdInformationResource(this.http);
208
- this.version = new chunkX7FGWEZ2_cjs.VersionResource(this.http);
209
- this.versionInformation = new chunkX7FGWEZ2_cjs.VersionInformationResource(this.http);
210
- this.zoneInformation = new chunkX7FGWEZ2_cjs.ZoneInformationResource(this.http);
189
+ this.companies = new chunkNRO2NJAZ_cjs.CompaniesResource(this.http, this.config.pageSize);
190
+ this.configurationItems = new chunkI75N5VVE_cjs.ConfigurationItemsResource(this.http, this.config.pageSize);
191
+ this.contacts = new chunkI75N5VVE_cjs.ContactsResource(this.http, this.config.pageSize);
192
+ this.contracts = new chunkNRO2NJAZ_cjs.ContractsResource(this.http, this.config.pageSize);
193
+ this.inventoryProducts = new chunkI75N5VVE_cjs.InventoryProductsResource(this.http, this.config.pageSize);
194
+ this.invoices = new chunkNRO2NJAZ_cjs.InvoicesResource(this.http, this.config.pageSize);
195
+ this.quotes = new chunkI75N5VVE_cjs.QuotesResource(this.http, this.config.pageSize);
196
+ this.resourceTimeOffAdditional = new chunkI75N5VVE_cjs.ResourceTimeOffAdditionalResource(this.http, this.config.pageSize);
197
+ this.resourceTimeOffBalances = new chunkI75N5VVE_cjs.ResourceTimeOffBalancesResource(this.http, this.config.pageSize);
198
+ this.resources = new chunkI75N5VVE_cjs.ResourcesResource(this.http, this.config, this.config.pageSize);
199
+ this.serviceCalls = new chunkI75N5VVE_cjs.ServiceCallsResource(this.http, this.config.pageSize);
200
+ this.ticketCharges = new chunkI75N5VVE_cjs.TicketChargesResource(this.http, this.config.pageSize);
201
+ this.tickets = new chunkI75N5VVE_cjs.TicketsResource(this.http, this.config.pageSize);
202
+ this.timeEntries = new chunkNRO2NJAZ_cjs.TimeEntriesResource(this.http, this.config.pageSize);
203
+ this.timeOffRequests = new chunkI75N5VVE_cjs.TimeOffRequestsResource(this.http, this.config.pageSize);
204
+ this.authenticateResource = new chunkI75N5VVE_cjs.AuthenticateResource(this.http);
205
+ this.entityInformation = new chunkI75N5VVE_cjs.EntityInformationResource(this.http);
206
+ this.modules = new chunkI75N5VVE_cjs.ModulesResource(this.http);
207
+ this.thresholdInformation = new chunkI75N5VVE_cjs.ThresholdInformationResource(this.http);
208
+ this.version = new chunkI75N5VVE_cjs.VersionResource(this.http);
209
+ this.versionInformation = new chunkI75N5VVE_cjs.VersionInformationResource(this.http);
210
+ this.zoneInformation = new chunkI75N5VVE_cjs.ZoneInformationResource(this.http);
211
211
  }
212
212
  /**
213
213
  * `GET /V1.0/Authenticate` → `AuthTokenResultModel` (as-is). The SDK does
@@ -241,10 +241,10 @@ var AutotaskClient = class {
241
241
  * parameter on each: `await client.withSignal(signal, () => invoke(client, ...))`.
242
242
  */
243
243
  withSignal(signal, fn) {
244
- return chunkZIBH42H3_cjs.runWithSignal(signal, fn);
244
+ return chunkNRO2NJAZ_cjs.runWithSignal(signal, fn);
245
245
  }
246
246
  async batch(fn, items, opts = {}) {
247
- return chunkZIBH42H3_cjs.runBounded(fn, items, { ...opts, concurrency: opts.concurrency ?? this.config.maxConcurrent });
247
+ return chunkNRO2NJAZ_cjs.runBounded(fn, items, { ...opts, concurrency: opts.concurrency ?? this.config.maxConcurrent });
248
248
  }
249
249
  };
250
250
 
@@ -19527,6 +19527,7 @@ function kindFetches(holder, resource) {
19527
19527
  udf: () => holder?.getUdfInfo?.() ?? Promise.reject(new AutotaskError(`fieldCatalog: the client exposes no getUdfInfo read for "${resource}"`, { code: "INVALID_RESPONSE", category: "server" }))
19528
19528
  };
19529
19529
  }
19530
+ var KIND_OPERATIONS = { info: "getEntityInfo", fields: "getFieldInfo", udf: "getUdfInfo" };
19530
19531
  function catalogProjector(kind, ctx) {
19531
19532
  if (ctx.compact) {
19532
19533
  const keepValues = ctx.labels && ctx.fieldsFilter !== void 0;
@@ -19582,6 +19583,11 @@ async function sweepResource(ctx, resource, tally, reads) {
19582
19583
  } else if (peek.age !== null) ages.push(peek.age);
19583
19584
  if (outcome.status === "rejected") {
19584
19585
  const error = outcome.reason;
19586
+ const { category, httpStatus } = error;
19587
+ const operation = `${resource}.${KIND_OPERATIONS[kind]}`;
19588
+ if (category === "auth" && error.operation === operation && (httpStatus === 401 || httpStatus === 403) && (tally.authFailure === void 0 || httpStatus < tally.authFailure.httpStatus)) {
19589
+ tally.authFailure = { httpStatus, operation };
19590
+ }
19585
19591
  if (row.error === null) row.error = { code: error.code, message: error.message };
19586
19592
  continue;
19587
19593
  }
@@ -19664,6 +19670,7 @@ async function fieldCatalog(client, opts) {
19664
19670
  ttlMs: cache?.ttlMs ?? null,
19665
19671
  fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
19666
19672
  rows,
19673
+ ...tally.authFailure === void 0 ? {} : { authFailure: tally.authFailure },
19667
19674
  wireUsed: tally.wireUsed,
19668
19675
  cap: MAX_FIELD_CATALOG_WIRE,
19669
19676
  truncated: false,
@@ -32117,7 +32124,8 @@ async function guardUnscopedQueryWalk(holder, operation, bag) {
32117
32124
  counted = await holder.count({ filter: conditions === void 0 ? void 0 : conditions });
32118
32125
  } catch (err) {
32119
32126
  const code = err?.code;
32120
- if (typeof code === "string" && PROPAGATE_CODES.has(code)) throw err;
32127
+ const denied = isAutotaskError(err) && err.category === "auth" && (err.httpStatus === 401 || err.httpStatus === 403);
32128
+ if (denied || typeof code === "string" && PROPAGATE_CODES.has(code)) throw err;
32121
32129
  const label = typeof code === "string" && /^[A-Z][A-Z_]{2,40}$/.test(code) ? ` (${code})` : "";
32122
32130
  return { note: `scope check skipped: the pre-flight count failed${label}; this unscoped walk was not guarded.` };
32123
32131
  }