node-autotask 0.92.0 → 0.93.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 (40) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/MCP_TOOL_CATALOG.json +255 -9
  3. package/README.md +1 -1
  4. package/capabilities.json +1042 -222
  5. package/dist/capabilities-data.js +1296 -476
  6. package/dist/capabilities.cjs +4 -4
  7. package/dist/capabilities.js +1 -1
  8. package/dist/{chunk-ATDGRAX2.cjs → chunk-2FM7MRK2.cjs} +32 -30
  9. package/dist/{chunk-ELAU2MT5.js → chunk-3SURRIOQ.js} +4 -2
  10. package/dist/{chunk-2MC3LDZU.js → chunk-DCISF6AG.js} +3 -3
  11. package/dist/{chunk-XAOWO42G.js → chunk-FCQPZAIK.js} +4 -2
  12. package/dist/{chunk-NQNAEA23.js → chunk-HJKI5VVJ.js} +981 -523
  13. package/dist/{chunk-QXJQIZCT.cjs → chunk-SBHQIPCJ.cjs} +3 -3
  14. package/dist/{chunk-JPZ7M7QI.cjs → chunk-X7FGWEZ2.cjs} +202 -200
  15. package/dist/{chunk-H24SV774.cjs → chunk-ZIBH42H3.cjs} +987 -527
  16. package/dist/{index-B9y5IwT1.d.cts → index-Cbos4Wgx.d.cts} +100 -2
  17. package/dist/{index-B9y5IwT1.d.ts → index-Cbos4Wgx.d.ts} +100 -2
  18. package/dist/{index-lWek2NrV.d.cts → index-CnNxnu7M.d.cts} +14 -2
  19. package/dist/{index-U7Lepdm2.d.ts → index-coyFHSSF.d.ts} +14 -2
  20. package/dist/index.cjs +89 -85
  21. package/dist/index.d.cts +8 -4
  22. package/dist/index.d.ts +8 -4
  23. package/dist/index.js +5 -5
  24. package/dist/operations/index.cjs +51 -51
  25. package/dist/operations/index.d.cts +7 -4
  26. package/dist/operations/index.d.ts +7 -4
  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 +40 -2
  39. package/examples/mcp-server-http.ts +6 -3
  40. package/package.json +1 -1
@@ -1,7 +1,8 @@
1
- import { loadCapabilityRecords } from './chunk-2MC3LDZU.js';
1
+ import { loadCapabilityRecords } from './chunk-DCISF6AG.js';
2
2
  import { NoopLogger, REDACTED, deepMarkUntrusted, wrapUntrusted } from './chunk-X6VWD6WW.js';
3
3
  import { randomUUID, createHash } from 'crypto';
4
4
  import { AsyncLocalStorage } from 'async_hooks';
5
+ import { types } from 'util';
5
6
 
6
7
  // src/errors/base.ts
7
8
  function nextActionFor(code, opts = {}) {
@@ -1440,6 +1441,7 @@ function resolveConfig(config) {
1440
1441
  }
1441
1442
 
1442
1443
  // src/http/types.ts
1444
+ var INVENTORY_APPROVAL_PRODUCT_ID = /* @__PURE__ */ Symbol("inventoryApprovalProductId");
1443
1445
  var IDEMPOTENT_METHODS = ["GET", "PUT", "DELETE"];
1444
1446
  var AUDIT_DECIMAL_ID = /^(?:0|[1-9]\d{0,18})$/;
1445
1447
  var MAX_AUDIT_ID = "9223372036854775807";
@@ -6049,7 +6051,26 @@ var RELATIONSHIP_MAP = {
6049
6051
  "workflowResource": false,
6050
6052
  "group": "B",
6051
6053
  "parent": null,
6052
- "children": [],
6054
+ "children": [
6055
+ {
6056
+ "resource": "organizational_resources",
6057
+ "apiEntity": "OrganizationalResource",
6058
+ "parentField": "organizationalLevelAssociationID",
6059
+ "parentSegment": "Resources",
6060
+ "tier": "advanced",
6061
+ "workflowResource": false,
6062
+ "specialOps": [
6063
+ "listByParent"
6064
+ ],
6065
+ "searchCovers": null,
6066
+ "scopedOps": {
6067
+ "create": false,
6068
+ "query": true,
6069
+ "update": false,
6070
+ "delete": false
6071
+ }
6072
+ }
6073
+ ],
6053
6074
  "naturalKeys": {
6054
6075
  "hasSearch": false,
6055
6076
  "searchCovers": null,
@@ -7300,6 +7321,24 @@ var RELATIONSHIP_MAP = {
7300
7321
  "delete": true
7301
7322
  }
7302
7323
  },
7324
+ {
7325
+ "resource": "resource_daily_availabilities",
7326
+ "apiEntity": "ResourceDailyAvailability",
7327
+ "parentField": "resourceID",
7328
+ "parentSegment": "DailyAvailabilities",
7329
+ "tier": "advanced",
7330
+ "workflowResource": false,
7331
+ "specialOps": [
7332
+ "listByParent"
7333
+ ],
7334
+ "searchCovers": null,
7335
+ "scopedOps": {
7336
+ "create": false,
7337
+ "query": true,
7338
+ "update": false,
7339
+ "delete": false
7340
+ }
7341
+ },
7303
7342
  {
7304
7343
  "resource": "resource_role_queues",
7305
7344
  "apiEntity": "ResourceRoleQueue",
@@ -11123,6 +11162,56 @@ var RELATIONSHIP_MAP = {
11123
11162
  "zoneFacts": null,
11124
11163
  "deleteBoundary": null,
11125
11164
  "markerField": null
11165
+ },
11166
+ "resource_daily_availabilities": {
11167
+ "resource": "resource_daily_availabilities",
11168
+ "apiEntity": "ResourceDailyAvailability",
11169
+ "kind": "entity",
11170
+ "path": "ResourceDailyAvailabilities",
11171
+ "parentScoped": true,
11172
+ "tier": "advanced",
11173
+ "workflowResource": false,
11174
+ "group": "B",
11175
+ "parent": {
11176
+ "resource": "resources",
11177
+ "segment": "DailyAvailabilities",
11178
+ "field": "resourceID"
11179
+ },
11180
+ "children": [],
11181
+ "naturalKeys": {
11182
+ "hasSearch": false,
11183
+ "searchCovers": null,
11184
+ "findBy": []
11185
+ },
11186
+ "blindSurfaces": null,
11187
+ "zoneFacts": null,
11188
+ "deleteBoundary": null,
11189
+ "markerField": null
11190
+ },
11191
+ "organizational_resources": {
11192
+ "resource": "organizational_resources",
11193
+ "apiEntity": "OrganizationalResource",
11194
+ "kind": "entity",
11195
+ "path": "OrganizationalResources",
11196
+ "parentScoped": true,
11197
+ "tier": "advanced",
11198
+ "workflowResource": false,
11199
+ "group": "B",
11200
+ "parent": {
11201
+ "resource": "organizational_level_associations",
11202
+ "segment": "Resources",
11203
+ "field": "organizationalLevelAssociationID"
11204
+ },
11205
+ "children": [],
11206
+ "naturalKeys": {
11207
+ "hasSearch": false,
11208
+ "searchCovers": null,
11209
+ "findBy": []
11210
+ },
11211
+ "blindSurfaces": null,
11212
+ "zoneFacts": null,
11213
+ "deleteBoundary": null,
11214
+ "markerField": null
11126
11215
  }
11127
11216
  };
11128
11217
  var BLIND_SURFACE_STAMPS = {
@@ -16602,6 +16691,9 @@ var UNTRUSTED_FIELDS_BY_RESOURCE = {
16602
16691
  "shipping_types": [
16603
16692
  "description",
16604
16693
  "name"
16694
+ ],
16695
+ "resource_daily_availabilities": [
16696
+ "travelAvailability"
16605
16697
  ]
16606
16698
  };
16607
16699
 
@@ -17060,11 +17152,22 @@ function auditReadTarget(path, operation) {
17060
17152
  function isKnowledgeBaseRootResource(resource) {
17061
17153
  return resource === "knowledge_base_categories" || resource === "knowledge_base_articles";
17062
17154
  }
17155
+ var STAFF_COLLECTION_PATHS = {
17156
+ organizational_resources: /^\/v1\.0\/OrganizationalLevelAssociations\/\d+\/Resources\/?$/i,
17157
+ resource_daily_availabilities: /^\/v1\.0\/Resources\/\d+\/DailyAvailabilities\/?$/i
17158
+ };
17159
+ function hasNativeStaffCollection(resource) {
17160
+ return Object.hasOwn(STAFF_COLLECTION_PATHS, resource);
17161
+ }
17063
17162
  function isExactRecordResource(resource) {
17064
- return resource === "inventory_locations" || resource === "inventory_items" || resource === "internal_locations" || resource === "shipping_types" || isKnowledgeBaseRootResource(resource);
17163
+ return hasNativeStaffCollection(resource) || resource === "inventory_locations" || resource === "inventory_items" || resource === "internal_locations" || resource === "shipping_types" || isKnowledgeBaseRootResource(resource);
17065
17164
  }
17066
- var EXACT_RECORD_PATH = /^\/v1\.0\/(?:InventoryLocations|InventoryItems|InternalLocations|ShippingTypes|KnowledgeBaseArticles|KnowledgeBaseCategories(?:\/\d+\/KnowledgeBaseArticles)?)(?:\/(query(?:\/(?:next|previous|count))?|\d+))?\/?$/i;
17165
+ var EXACT_RECORD_PATH = /^\/v1\.0\/(?:OrganizationalResources|ResourceDailyAvailabilities|InventoryLocations|InventoryItems|InternalLocations|ShippingTypes|KnowledgeBaseArticles|KnowledgeBaseCategories(?:\/\d+\/KnowledgeBaseArticles)?)(?:\/(query(?:\/(?:next|previous|count))?|\d+))?\/?$/i;
17067
17166
  function exactRecordResponseTarget(path, method, operation) {
17167
+ if (method === "GET" && operation?.endsWith(".listByParent")) {
17168
+ const resource = operation.slice(0, -".listByParent".length);
17169
+ if (hasNativeStaffCollection(resource) && STAFF_COLLECTION_PATHS[resource].test(path)) return "query";
17170
+ }
17068
17171
  const match = EXACT_RECORD_PATH.exec(path);
17069
17172
  if (match === null) return void 0;
17070
17173
  const suffix = match[1]?.toLowerCase();
@@ -17132,7 +17235,7 @@ function validateExactRecordResponse(body, target, path, method, requestBody, op
17132
17235
  if (String(id) !== expectedId) {
17133
17236
  throw new AutotaskConfigError(`returned ${resource} id must match the requested id`, { operation });
17134
17237
  }
17135
- if (parts.length === 6) {
17238
+ if (entity === "knowledgebasearticles" && parts.length === 6) {
17136
17239
  const parent = ownField(item, "articleCategoryID");
17137
17240
  if (typeof parent !== "number" || !Number.isInteger(parent) || parent <= 0 || parent > 2147483647) {
17138
17241
  invalid("Expected a valid category ID in the Knowledge Base article response");
@@ -17158,13 +17261,22 @@ function decodeResponseJson(text, auditTarget, recordTarget, path) {
17158
17261
  }
17159
17262
  const idTokens = /* @__PURE__ */ new WeakMap();
17160
17263
  const receiptTokens = /* @__PURE__ */ new WeakMap();
17161
- const holidaySetTokens = /* @__PURE__ */ new WeakMap();
17162
- const internalLocations = path !== void 0 && /^\/v1\.0\/InternalLocations\//i.test(path);
17264
+ const signedIdTokens = /* @__PURE__ */ new WeakMap();
17265
+ const nativeStaffQuery = recordTarget === "query" && path !== void 0;
17266
+ const organizationalList = nativeStaffQuery && STAFF_COLLECTION_PATHS.organizational_resources.test(path);
17267
+ const nativeParentField = organizationalList ? "organizationalLevelAssociationID" : nativeStaffQuery && STAFF_COLLECTION_PATHS.resource_daily_availabilities.test(path) ? "resourceID" : void 0;
17268
+ const invalidNativeParents = nativeParentField === void 0 ? void 0 : /* @__PURE__ */ new WeakSet();
17269
+ const organizationalRead = organizationalList || path !== void 0 && (target === "query" || target === "item") && /^\/v1\.0\/OrganizationalResources\//i.test(path);
17270
+ const signedIdField = organizationalRead ? "soapParentPropertyId" : path !== void 0 && /^\/v1\.0\/InternalLocations\//i.test(path) ? "holidaySetId" : void 0;
17163
17271
  const body = JSON.parse(text, function(key, value, context) {
17164
17272
  if (typeof value === "number" && context?.source !== void 0) {
17165
- if (key === "id") idTokens.set(this, context.source);
17166
- if (key === "itemId" && target === "mutation") receiptTokens.set(this, context.source);
17167
- if (internalLocations && key === "holidaySetId") holidaySetTokens.set(this, context.source);
17273
+ const token = context.source;
17274
+ if (key === "id") idTokens.set(this, token);
17275
+ if (key === "itemId" && target === "mutation") receiptTokens.set(this, token);
17276
+ if (key === signedIdField) signedIdTokens.set(this, token);
17277
+ if (key === nativeParentField && (!isAuditDecimalId(token) || value > 2147483647)) {
17278
+ invalidNativeParents?.add(this);
17279
+ }
17168
17280
  }
17169
17281
  return value;
17170
17282
  });
@@ -17172,9 +17284,12 @@ function decodeResponseJson(text, auditTarget, recordTarget, path) {
17172
17284
  if (Array.isArray(rows)) {
17173
17285
  for (const row of rows) {
17174
17286
  if (!isRecord2(row)) continue;
17175
- const holidaySet = holidaySetTokens.get(row);
17176
- if (holidaySet !== void 0 && !Number.isSafeInteger(row.holidaySetId) && isSignedInt64Token(holidaySet)) {
17177
- row.holidaySetId = holidaySet;
17287
+ if (nativeParentField !== void 0 && invalidNativeParents?.has(row)) {
17288
+ row[nativeParentField] = null;
17289
+ }
17290
+ const signedId = signedIdTokens.get(row);
17291
+ if (signedIdField !== void 0 && signedId !== void 0 && !Number.isSafeInteger(row[signedIdField]) && isSignedInt64Token(signedId)) {
17292
+ row[signedIdField] = signedId;
17178
17293
  }
17179
17294
  const key = target === "mutation" && ownField(row, "itemId") !== void 0 ? "itemId" : "id";
17180
17295
  const value = ownField(row, key);
@@ -17224,6 +17339,16 @@ function attachEmptyReasonDetails(err) {
17224
17339
  err.details = { ...err.details ?? {} };
17225
17340
  if (stamp !== void 0) {
17226
17341
  err.details.emptyReason = stamp;
17342
+ } else if (isGetMiss && hasNativeStaffCollection(resource)) {
17343
+ const remedy = `Verify the ID with ${resource}.query and an exact id filter, or use ${resource}.listByParent with the known parent ID. Check the API user's permissions.`;
17344
+ err.suggestedAction = remedy;
17345
+ err.details.emptyReason = {
17346
+ surface,
17347
+ kind: "not-found",
17348
+ authority: `${resource}.query`,
17349
+ note: "No record at this ID was visible to this API user.",
17350
+ remedy
17351
+ };
17227
17352
  } else if (isGetMiss) {
17228
17353
  const blind = BLIND_SURFACE_STAMPS[resource]?.query;
17229
17354
  err.details.emptyReason = blind !== void 0 ? {
@@ -17801,7 +17926,8 @@ var HttpClient = class {
17801
17926
  }
17802
17927
  let parsed;
17803
17928
  try {
17804
- parsed = decodeResponseJson(text, s.auditTarget, s.recordTarget, decodeURIComponent(s.opts.path));
17929
+ const decodeTarget = opts[INVENTORY_APPROVAL_PRODUCT_ID] === true ? "item" : s.recordTarget;
17930
+ parsed = decodeResponseJson(text, s.auditTarget, decodeTarget, decodeURIComponent(s.opts.path));
17805
17931
  } catch {
17806
17932
  return this.handleNonJson2xx(s, res, status, text);
17807
17933
  }
@@ -18457,114 +18583,610 @@ function slimCompany(row) {
18457
18583
  return { id: row.id, companyName: row.companyName, isActive: row.isActive, parentCompanyID: row.parentCompanyID };
18458
18584
  }
18459
18585
 
18460
- // src/operations/requiredFields.ts
18461
- function effectiveRequiredFields(record, zoneFacts) {
18462
- const guidance = zoneFacts?.createGuidance;
18463
- const prefix = guidance?.liveProvenPrefix;
18464
- if (Array.isArray(prefix) && prefix.length > 0) {
18465
- const gates = guidance?.requiresByValue;
18466
- const gated = new Set((gates ?? []).flatMap((g) => [...g.requires.allOf ?? [], ...g.requires.anyOf ?? []]));
18467
- return {
18468
- fields: prefix.filter((f) => !gated.has(f)),
18469
- from: "live-proven",
18470
- unproven: guidance?.unproven === true,
18471
- ...Array.isArray(gates) && gates.length > 0 ? { conditional: gates } : {}
18472
- };
18473
- }
18474
- const zoneSet = zoneFacts?.createRequiredSet;
18475
- if (Array.isArray(zoneSet) && zoneSet.length > 0) {
18476
- return { fields: [...zoneSet], from: "zone", unproven: guidance?.unproven === true };
18586
+ // src/resources/base/helpers.ts
18587
+ function describeResponseShape(body) {
18588
+ if (body === null) return "null";
18589
+ if (Array.isArray(body)) return `array(len=${body.length})`;
18590
+ if (typeof body !== "object") return typeof body;
18591
+ const rec = body;
18592
+ const keys = Object.keys(rec).sort();
18593
+ const typeOf = (v) => v === null ? "null" : Array.isArray(v) ? "array" : typeof v;
18594
+ const parts = keys.slice(0, 16).map((k) => `${k}:${typeOf(rec[k])}`);
18595
+ const more = keys.length > 16 ? `, +${keys.length - 16} more` : "";
18596
+ return `{ ${parts.join(", ")}${more} }`;
18597
+ }
18598
+ function defaultMarkerToken(data) {
18599
+ for (const field of ["name", "title"]) {
18600
+ const v = data[field];
18601
+ if (typeof v === "string" && v.trim() !== "") return v.trim();
18477
18602
  }
18478
- const spec = record?.requiredFields;
18479
- return { fields: Array.isArray(spec) ? [...spec] : [], from: "spec", unproven: true };
18603
+ return null;
18480
18604
  }
18481
-
18482
- // src/operations/types.ts
18483
- var WORKFLOW_RESOURCES = [
18484
- "companies",
18485
- "tickets",
18486
- "contacts",
18487
- "configuration_items",
18488
- "projects"
18489
- ];
18490
-
18491
- // src/metadata-views.ts
18492
- function liveFieldNamesView(rows) {
18493
- if (!Array.isArray(rows)) return null;
18494
- const names = [];
18495
- for (const row of rows) if (typeof row.name === "string") names.push(row.name);
18496
- return names.length === 0 ? null : { names, known: new Set(names) };
18605
+ var CONTEXT_ABSENT_MARKER = "#context-absent";
18606
+ function contextAbsentKey(path) {
18607
+ return path + "\0context-absent";
18497
18608
  }
18498
- function projectFieldRow(raw, labels = false, udf = false) {
18499
- const r = typeof raw === "object" && raw !== null ? raw : {};
18500
- const name = typeof r.name === "string" ? r.name : "";
18501
- const type = typeof r.dataType === "string" ? r.dataType : typeof r.type === "string" ? r.type : "";
18502
- const values = labels && r.isPickList === true && Array.isArray(r.picklistValues) && r.picklistValues.length > 0 ? r.picklistValues : void 0;
18503
- const referenceEntityType = typeof r.referenceEntityType === "string" ? r.referenceEntityType : "";
18504
- return {
18505
- name,
18506
- ...typeof r.label === "string" && r.label !== "" ? { label: r.label } : {},
18507
- type,
18508
- isRequired: r.isRequired === true,
18509
- isReadOnly: r.isReadOnly === true,
18510
- // Issue #219 N7: a UDF row never serves the vendor's isQueryable (it is
18511
- // true for UDFs while a plain filter on a UDF name is refused); it serves
18512
- // the marker the filter actually needs.
18513
- ...udf ? { filterable: "udf-marker" } : { isQueryable: r.isQueryable === true },
18514
- isPickList: r.isPickList === true,
18515
- ...isObjectOrArrayType(type) ? { writeShape: "replace-all" } : {},
18516
- maxLength: typeof r.length === "number" ? r.length : null,
18517
- referenceEntityType,
18518
- ...values !== void 0 ? { picklistValues: values } : {}
18519
- };
18609
+ function noteCharsTruncationMarker(charsRemoved) {
18610
+ return `\u2026 [+${charsRemoved} chars truncated]`;
18520
18611
  }
18521
- function isObjectOrArrayType(type) {
18522
- const t = type.trim().toLowerCase();
18523
- return t === "object" || t === "array" || t === "collection" || t.endsWith("[]");
18612
+ function truncateNoteChars(items, cap, fields) {
18613
+ let truncated = 0;
18614
+ const out = items.map((item) => {
18615
+ if (!isRecord2(item)) return item;
18616
+ let changed = false;
18617
+ const copy = { ...item };
18618
+ for (const field of fields) {
18619
+ const v = copy[field];
18620
+ if (typeof v === "string" && v !== REDACTED && v.length > cap) {
18621
+ const end = cap > 0 && (v.charCodeAt(cap - 1) & 64512) === 55296 ? cap - 1 : cap;
18622
+ copy[field] = v.slice(0, end) + noteCharsTruncationMarker(v.length - end);
18623
+ truncated += 1;
18624
+ changed = true;
18625
+ }
18626
+ }
18627
+ return changed ? copy : item;
18628
+ });
18629
+ return [out, truncated];
18524
18630
  }
18525
- function exposesPicklistValues(raw) {
18526
- const r = typeof raw === "object" && raw !== null ? raw : {};
18527
- return Array.isArray(r.picklistValues) && r.picklistValues.length > 0;
18631
+ function blindEmptyReason(stamp) {
18632
+ return {
18633
+ surface: stamp.surface,
18634
+ kind: "blind-surface",
18635
+ note: stamp.note,
18636
+ authority: stamp.authority,
18637
+ remedy: "the note is the remedy \u2014 the authority op answers for a record"
18638
+ };
18528
18639
  }
18529
- function catalogList(raw, labels, udf) {
18530
- return Array.isArray(raw) ? { rows: raw.map((row) => projectFieldRow(row, labels, udf)), exposesValues: raw.some(exposesPicklistValues) } : { rows: null, exposesValues: false };
18640
+ function attachUpdateTargetMissReason(err, key) {
18641
+ const pinned = EMPTY_REASON_STAMPS[key]?.update;
18642
+ if (pinned === void 0) return;
18643
+ err.details = { ...err.details ?? {}, emptyReason: pinned };
18531
18644
  }
18532
- var catalogFieldsView = (raw) => catalogList(raw, false, false);
18533
- var catalogLabelledFieldsView = (raw) => catalogList(raw, true, false);
18534
- var catalogUdfView = (raw) => catalogList(raw, false, true);
18535
- var catalogLabelledUdfView = (raw) => catalogList(raw, true, true);
18536
- function compactCatalogList(raw, keepValues, udf) {
18537
- const view = catalogList(raw, keepValues, udf);
18538
- if (view.rows === null) return { rows: null, exposesValues: view.exposesValues };
18539
- const flags = {
18540
- required: view.rows.filter((row) => row.isRequired).map((row) => row.name),
18541
- readOnly: view.rows.filter((row) => row.isReadOnly).map((row) => row.name),
18542
- queryable: view.rows.filter((row) => row.isQueryable).map((row) => row.name),
18543
- picklistFields: view.rows.filter((row) => row.isPickList).map((row) => row.name)
18544
- };
18645
+ function buildDryRunResult(spec, policy) {
18646
+ if (spec.operation === "") {
18647
+ throw new AutotaskConfigError("dry-run: the operation name is required");
18648
+ }
18649
+ const wouldApply = spec.checks.every((check) => check.ok);
18650
+ const resource = spec.operation.split(".")[0] ?? spec.operation;
18651
+ const diffPart = spec.diff !== void 0 ? {
18652
+ diff: spec.diff.map((entry) => {
18653
+ if (entry.to === void 0) return entry;
18654
+ const to = isRedactedFieldName(entry.field, policy) ? REDACTED : redactResponseBody(entry.to, policy);
18655
+ return { ...entry, to };
18656
+ })
18657
+ } : {};
18658
+ const dataPart = spec.data !== void 0 ? { data: redactResponseBody(spec.data, policy) } : {};
18545
18659
  return {
18546
- rows: view.rows.map((row) => ({
18547
- name: row.name,
18548
- type: row.type,
18549
- isPickList: row.isPickList,
18550
- isReference: row.referenceEntityType !== "",
18551
- udf,
18552
- ...keepValues && row.picklistValues !== void 0 ? { picklistValues: row.picklistValues } : {}
18553
- })),
18554
- flags,
18555
- exposesValues: view.exposesValues
18660
+ operation: spec.operation,
18661
+ wouldApply,
18662
+ target: { resource, ids: spec.ids },
18663
+ request: { method: spec.method, path: spec.path },
18664
+ ...diffPart,
18665
+ checks: spec.checks,
18666
+ impact: spec.impact,
18667
+ simulated: true,
18668
+ warnings: spec.warnings ?? [],
18669
+ ...dataPart,
18670
+ ...spec.emptyReason !== void 0 ? { emptyReason: spec.emptyReason } : {}
18556
18671
  };
18557
18672
  }
18558
- var compactCatalogFieldsView = (raw) => compactCatalogList(raw, false, false);
18559
- var compactCatalogLabelledFieldsView = (raw) => compactCatalogList(raw, true, false);
18560
- var compactCatalogUdfView = (raw) => compactCatalogList(raw, false, true);
18561
- var compactCatalogLabelledUdfView = (raw) => compactCatalogList(raw, true, true);
18562
- function ticketStatusView(fields) {
18563
- if (!Array.isArray(fields)) return [];
18564
- const status = fields.find((f) => typeof f?.name === "string" && f.name.toLowerCase() === "status");
18565
- if (status === void 0 || status.isPickList !== true || !Array.isArray(status.picklistValues)) return [];
18673
+ function computeFieldDiff(current, data) {
18566
18674
  const out = [];
18567
- for (const v of status.picklistValues) {
18675
+ for (const [field, to] of Object.entries(data)) {
18676
+ if (field === "id" || to === void 0) continue;
18677
+ const from = Object.hasOwn(current, field) ? current[field] : void 0;
18678
+ if (from !== void 0 && JSON.stringify(from) === JSON.stringify(to)) continue;
18679
+ out.push({ field, from: from === void 0 ? null : from, to });
18680
+ }
18681
+ return out;
18682
+ }
18683
+ function mergePartialBody(current, data) {
18684
+ const merged = { ...current };
18685
+ for (const [key, value] of Object.entries(data)) {
18686
+ if (value === void 0) continue;
18687
+ merged[key] = value;
18688
+ }
18689
+ return merged;
18690
+ }
18691
+ function snapshotMutationOptions(options) {
18692
+ const { dryRun, lastModifiedDate, maxRetries, raw, verifyPersisted } = options ?? {};
18693
+ if (dryRun !== void 0 && typeof dryRun !== "boolean") {
18694
+ throw new AutotaskConfigError("dryRun must be a boolean");
18695
+ }
18696
+ return { dryRun, lastModifiedDate, maxRetries, raw, verifyPersisted };
18697
+ }
18698
+ function normalizeUdfInput(value) {
18699
+ if (Array.isArray(value)) {
18700
+ return value.map((entry) => {
18701
+ if (!isRecord2(entry) || typeof entry.name !== "string" || entry.name === "") {
18702
+ throw new AutotaskConfigError("userDefinedFields array entries must be { name, value } objects");
18703
+ }
18704
+ return { name: entry.name, value: entry.value };
18705
+ });
18706
+ }
18707
+ if (isRecord2(value)) {
18708
+ return Object.entries(value).map(([name, entryValue]) => ({ name, value: entryValue }));
18709
+ }
18710
+ throw new AutotaskConfigError("userDefinedFields must be an array of { name, value } entries or a name-to-value map");
18711
+ }
18712
+ function blindStampFor(stamp, filter) {
18713
+ if (stamp === void 0) return void 0;
18714
+ if (stamp.kind !== "unfiltered-blind") return stamp;
18715
+ const conditions = normalizedConditions(filter);
18716
+ return conditions === void 0 || conditions.length === 0 ? stamp : void 0;
18717
+ }
18718
+ function decodeFileData(body) {
18719
+ if (isRecord2(body)) {
18720
+ const data = body.data;
18721
+ if (typeof data === "string") return Buffer.from(data, "base64");
18722
+ if (Array.isArray(data) && data.every((b) => typeof b === "number")) {
18723
+ return Buffer.from(data);
18724
+ }
18725
+ }
18726
+ if (typeof body === "string") return Buffer.from(body, "base64");
18727
+ throw new AutotaskError(
18728
+ "Expected the file envelope FileQueryResultModel { data } (or a base64 string); got a different shape",
18729
+ { code: "INVALID_RESPONSE", category: "server" }
18730
+ );
18731
+ }
18732
+ var DEPLURAL_EXCEPTIONS = {
18733
+ tag_aliase: "tag_alias"
18734
+ };
18735
+ function entityNameFromPath(resourcePath) {
18736
+ const segment = resourcePath.slice(resourcePath.lastIndexOf("/") + 1);
18737
+ const snake = segment.replace(/([A-Z])/g, (_m, c, i) => (i > 0 ? `_` : "") + c.toLowerCase()).replace(/_{2,}/g, "_");
18738
+ if (snake.endsWith("ies")) return `${snake.slice(0, -3)}y`;
18739
+ if (snake.endsWith("s")) {
18740
+ const stripped = snake.slice(0, -1);
18741
+ return DEPLURAL_EXCEPTIONS[stripped] ?? stripped;
18742
+ }
18743
+ return snake;
18744
+ }
18745
+
18746
+ // src/resources/special/inventoryItems.ts
18747
+ var REFERENCES = ["inventoryLocationID", "productID"];
18748
+ var QUANTITIES = ["quantityMinimum", "quantityMaximum", "quantityOnHand"];
18749
+ var TEXT_FIELDS = ["bin", "referenceNumber"];
18750
+ var MUTATION_OPTIONS = ["dryRun", "lastModifiedDate", "maxRetries", "raw", "verifyPersisted", "expectedInventoryFacts"];
18751
+ function fail(message) {
18752
+ throw new AutotaskConfigError(`inventory_items: ${message}`);
18753
+ }
18754
+ function own(record, field) {
18755
+ return Object.hasOwn(record, field) ? record[field] : void 0;
18756
+ }
18757
+ function int32(value, label, minimum = -2147483648) {
18758
+ if (typeof value !== "number" || !Number.isInteger(value) || value < minimum || value > 2147483647) {
18759
+ fail(`${label} must be an integer between ${minimum} and 2147483647`);
18760
+ }
18761
+ return value;
18762
+ }
18763
+ function inventoryItemId(value) {
18764
+ const id = parseIdentifier(value, "inventory_items: id");
18765
+ if (!isAuditDecimalId(String(id))) fail("id must fit a signed 64-bit integer");
18766
+ return id;
18767
+ }
18768
+ function admitInventoryItem(value, creating) {
18769
+ if (!isRecord2(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail("data must be a plain record");
18770
+ const body = captureInventoryPayload(value)();
18771
+ const writable = [...QUANTITIES, ...TEXT_FIELDS, ...creating ? REFERENCES : []];
18772
+ for (const field of Object.keys(body)) {
18773
+ if (!writable.some((name) => name === field)) fail(`${field} is not a writable InventoryItems field on ${creating ? "create" : "update"}`);
18774
+ }
18775
+ if (!creating && Object.keys(body).length === 0) fail("update must contain a writable field");
18776
+ if (creating) for (const field of REFERENCES) int32(own(body, field), field, 1);
18777
+ for (const field of QUANTITIES) {
18778
+ const nonnegative = field === "quantityMinimum" || creating && field === "quantityOnHand";
18779
+ if (creating || Object.hasOwn(body, field)) int32(own(body, field), field, nonnegative ? 0 : void 0);
18780
+ }
18781
+ for (const field of TEXT_FIELDS) {
18782
+ const text = own(body, field);
18783
+ if (Object.hasOwn(body, field) && (typeof text !== "string" || text.length > 50)) fail(`${field} must be a string of at most 50 characters`);
18784
+ }
18785
+ assertQuantityRange(own(body, "quantityMinimum"), own(body, "quantityMaximum"));
18786
+ return body;
18787
+ }
18788
+ function captureInventoryPayload(value) {
18789
+ if (types.isProxy(value)) fail("payload must not be a Proxy");
18790
+ if (!isRecord2(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail("data must be a plain record");
18791
+ const descriptors = Object.getOwnPropertyDescriptors(value);
18792
+ const captured = /* @__PURE__ */ Object.create(null);
18793
+ const accessors = [];
18794
+ for (const [field, descriptor2] of Object.entries(descriptors)) {
18795
+ if (!descriptor2.enumerable) continue;
18796
+ if (Object.hasOwn(descriptor2, "value")) captured[field] = descriptor2.value;
18797
+ else accessors.push([field, descriptor2]);
18798
+ }
18799
+ return (allowAccessors = true) => {
18800
+ if (!allowAccessors && accessors.length > 0) fail("approved InventoryItems payload fields must be data properties; accessors are unsupported");
18801
+ const body = { ...captured };
18802
+ for (const [field, descriptor2] of accessors) {
18803
+ const capturedValue = descriptor2.get === void 0 ? void 0 : Reflect.apply(descriptor2.get, value, []);
18804
+ Object.defineProperty(body, field, { value: capturedValue, enumerable: true });
18805
+ }
18806
+ return body;
18807
+ };
18808
+ }
18809
+ function captureInventoryOptionDescriptors(options) {
18810
+ if (types.isProxy(options)) fail("options must not be a Proxy");
18811
+ if (!isRecord2(options)) fail("options must be an object");
18812
+ const prototype = Object.getPrototypeOf(options);
18813
+ for (let owner = prototype; owner !== null && owner !== Object.prototype; owner = Object.getPrototypeOf(owner)) {
18814
+ if (types.isProxy(owner)) fail("options must not inherit from a Proxy");
18815
+ }
18816
+ const descriptors = Object.getOwnPropertyDescriptors(options);
18817
+ const fact = Object.hasOwn(descriptors, "expectedInventoryFacts") ? descriptors.expectedInventoryFacts : void 0;
18818
+ if (fact === void 0 ? "expectedInventoryFacts" in options : !Object.hasOwn(fact, "value")) {
18819
+ fail("expectedInventoryFacts must be an own data property; accessors are unsupported");
18820
+ }
18821
+ const suppliedFacts = fact?.value;
18822
+ if (suppliedFacts !== void 0 && ![Object.prototype, null].includes(prototype)) fail("approved options must be a plain record");
18823
+ const expectedInventoryFacts = suppliedFacts === void 0 ? void 0 : snapshotExpectedInventoryFacts(suppliedFacts);
18824
+ return { options, descriptors, expectedInventoryFacts };
18825
+ }
18826
+ function snapshotInventoryMutationOptions(value) {
18827
+ const { options, descriptors, expectedInventoryFacts } = captureInventoryOptionDescriptors(value === void 0 ? {} : value);
18828
+ for (const key of MUTATION_OPTIONS) {
18829
+ if (key !== "expectedInventoryFacts" && !Object.hasOwn(descriptors, key) && key in options) fail(`${key} must be an own option`);
18830
+ }
18831
+ if (expectedInventoryFacts !== void 0 && Object.values(descriptors).some((descriptor2) => !Object.hasOwn(descriptor2, "value"))) fail("approved InventoryItems options must be data properties; accessors are unsupported");
18832
+ const captured = /* @__PURE__ */ Object.create(null);
18833
+ const dryRun = Object.hasOwn(descriptors, "dryRun") ? descriptors.dryRun : void 0;
18834
+ if (dryRun !== void 0) {
18835
+ const dataFlag = Object.hasOwn(dryRun, "value");
18836
+ const value2 = dataFlag ? dryRun.value : dryRun.get === void 0 ? void 0 : Reflect.apply(dryRun.get, options, []);
18837
+ captured.dryRun = !dataFlag && value2 === void 0 ? true : value2;
18838
+ }
18839
+ for (const key of MUTATION_OPTIONS) {
18840
+ if (key === "expectedInventoryFacts" || key === "dryRun") continue;
18841
+ const descriptor2 = descriptors[key];
18842
+ captured[key] = descriptor2 === void 0 ? void 0 : Object.hasOwn(descriptor2, "value") ? descriptor2.value : descriptor2.get === void 0 ? void 0 : Reflect.apply(descriptor2.get, options, []);
18843
+ }
18844
+ const result = snapshotMutationOptions(captured);
18845
+ if (expectedInventoryFacts !== void 0) result.expectedInventoryFacts = expectedInventoryFacts;
18846
+ if (result.lastModifiedDate !== void 0) fail("no documented stale timestamp is available");
18847
+ if (result.raw !== void 0 && result.raw !== false) fail("raw updates are unsupported");
18848
+ if (result.maxRetries !== void 0 && (!Number.isSafeInteger(result.maxRetries) || result.maxRetries < 0)) fail("maxRetries must be a nonnegative safe integer");
18849
+ if (result.verifyPersisted !== void 0 && typeof result.verifyPersisted !== "boolean") fail("verifyPersisted must be a boolean");
18850
+ return result;
18851
+ }
18852
+ function validateInventoryFactIntent(result, creating, data) {
18853
+ const facts = result.expectedInventoryFacts;
18854
+ if (facts === void 0) return;
18855
+ if (creating ? facts.item !== void 0 || facts.product === void 0 || facts.location === void 0 : facts.item === void 0 || facts.location !== void 0 || (Object.hasOwn(data, "quantityOnHand") ? facts.product === void 0 : facts.product !== void 0)) {
18856
+ fail("expectedInventoryFacts must supply only the facts required by this create or update");
18857
+ }
18858
+ if (creating && (facts.product.id !== data.productID || facts.location.id !== data.inventoryLocationID)) fail("expectedInventoryFacts references must match the submitted references");
18859
+ }
18860
+ function captureInventoryItemCall(value, options, creating) {
18861
+ const payload = captureInventoryPayload(value);
18862
+ const opts = snapshotInventoryMutationOptions(options);
18863
+ const body = admitInventoryItem(payload(opts.expectedInventoryFacts === void 0), creating);
18864
+ validateInventoryFactIntent(opts, creating, body);
18865
+ return { body, opts };
18866
+ }
18867
+ function deferredInventoryPayload(value, allowAccessors) {
18868
+ if (types.isProxy(value)) fail("payload must not be a Proxy");
18869
+ if (!isRecord2(value)) return value;
18870
+ if (![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail("data must be a plain record");
18871
+ const result = Object.create(Object.getPrototypeOf(value));
18872
+ for (const [field, descriptor2] of Object.entries(Object.getOwnPropertyDescriptors(value))) {
18873
+ if (!descriptor2.enumerable) continue;
18874
+ if (Object.hasOwn(descriptor2, "value")) Object.defineProperty(result, field, { value: descriptor2.value, enumerable: true });
18875
+ else {
18876
+ if (!allowAccessors) fail("approved InventoryItems payload fields must be data properties; accessors are unsupported");
18877
+ let resolved = false;
18878
+ let captured;
18879
+ Object.defineProperty(result, field, { enumerable: true, get() {
18880
+ if (!resolved) {
18881
+ captured = descriptor2.get === void 0 ? void 0 : Reflect.apply(descriptor2.get, value, []);
18882
+ resolved = true;
18883
+ }
18884
+ return captured;
18885
+ } });
18886
+ }
18887
+ }
18888
+ return result;
18889
+ }
18890
+ function captureInventoryInvocationArgs(operation, args) {
18891
+ if (operation !== "inventory_items.create" && operation !== "inventory_items.update") return () => args;
18892
+ if (types.isProxy(args)) fail("invoke arguments must not be a Proxy");
18893
+ const array = Array.isArray(args);
18894
+ if (!array && (!isRecord2(args) || ![Object.prototype, null].includes(Object.getPrototypeOf(args))) || array && args.length !== (operation === "inventory_items.create" ? 1 : 2)) fail("InventoryItems invoke requires its documented positional or plain named inputs");
18895
+ const descriptors = Object.getOwnPropertyDescriptors(args);
18896
+ if (!array && Object.getOwnPropertySymbols(descriptors).length > 0) fail("InventoryItems named inputs must use string keys");
18897
+ const dataKey = array ? operation === "inventory_items.create" ? "0" : "1" : "data";
18898
+ const payload = descriptors[dataKey];
18899
+ const pinnedPayload = payload !== void 0 && Object.hasOwn(payload, "value") ? deferredInventoryPayload(payload.value, true) : void 0;
18900
+ return (allowAccessors = true) => {
18901
+ const result = array ? [] : Object.create(Object.getPrototypeOf(args));
18902
+ for (const [key, descriptor2] of Object.entries(descriptors)) {
18903
+ if (array && key === "length") continue;
18904
+ const enumerable = !array || descriptor2.enumerable;
18905
+ if (Object.hasOwn(descriptor2, "value")) {
18906
+ const value = key === dataKey ? deferredInventoryPayload(pinnedPayload, allowAccessors) : descriptor2.value;
18907
+ Object.defineProperty(result, key, { value, enumerable, configurable: true });
18908
+ } else {
18909
+ if (!allowAccessors) fail("approved InventoryItems named inputs must be data properties; accessors are unsupported");
18910
+ let resolved = false;
18911
+ let captured;
18912
+ Object.defineProperty(result, key, { enumerable, configurable: true, get() {
18913
+ if (!resolved) {
18914
+ const value = descriptor2.get === void 0 ? void 0 : Reflect.apply(descriptor2.get, args, []);
18915
+ captured = key === dataKey ? deferredInventoryPayload(value, true) : value;
18916
+ resolved = true;
18917
+ }
18918
+ return captured;
18919
+ } });
18920
+ }
18921
+ }
18922
+ return result;
18923
+ };
18924
+ }
18925
+ var ITEM_NUMERIC_FACTS = [...REFERENCES, ...QUANTITIES, "quantityPicked", "quantityReserved", "quantityOnOrder", "backOrderQuantity", "impersonatorCreatorResourceID"];
18926
+ var ITEM_FACT_KEYS = ["id", ...ITEM_NUMERIC_FACTS, ...TEXT_FIELDS];
18927
+ function inventoryItemGuardFacts(value) {
18928
+ const captured = closedFacts(value, ITEM_FACT_KEYS, false);
18929
+ if (!Object.hasOwn(captured, "id")) fail("inventory facts require an own item id");
18930
+ const facts = { id: inventoryItemId(captured.id) };
18931
+ for (const field of ITEM_NUMERIC_FACTS) if (Object.hasOwn(captured, field)) {
18932
+ const current = captured[field];
18933
+ facts[field] = current === null ? null : int32(current, "inventory fact");
18934
+ }
18935
+ for (const field of TEXT_FIELDS) if (Object.hasOwn(captured, field)) {
18936
+ const current = captured[field];
18937
+ if (current !== null && typeof current !== "string") fail("inventory text facts must be strings or null");
18938
+ facts[field] = current;
18939
+ }
18940
+ return facts;
18941
+ }
18942
+ function closedFacts(value, fields, closed = true) {
18943
+ if (types.isProxy(value)) fail("expectedInventoryFacts records must not be a Proxy");
18944
+ if (!isRecord2(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail("expectedInventoryFacts must contain plain records");
18945
+ const descriptors = Object.getOwnPropertyDescriptors(value);
18946
+ if (closed && Reflect.ownKeys(descriptors).some((key) => typeof key !== "string" || !fields.includes(key))) fail("expectedInventoryFacts contains an unsupported field");
18947
+ for (const key of fields) if (key in value && !Object.hasOwn(value, key)) fail("expectedInventoryFacts fields must be own fields");
18948
+ const captured = /* @__PURE__ */ Object.create(null);
18949
+ for (const key of fields) {
18950
+ const descriptor2 = descriptors[key];
18951
+ if (descriptor2 === void 0) continue;
18952
+ if (!Object.hasOwn(descriptor2, "value")) fail("expectedInventoryFacts fields must be data properties; accessors are unsupported");
18953
+ captured[key] = descriptor2.value;
18954
+ }
18955
+ return captured;
18956
+ }
18957
+ function snapshotExpectedInventoryFacts(value) {
18958
+ const source = closedFacts(value, ["item", "product", "location"]);
18959
+ const result = {};
18960
+ if (Object.hasOwn(source, "item")) {
18961
+ const item = closedFacts(source.item, ITEM_FACT_KEYS);
18962
+ result.item = inventoryItemGuardFacts(item);
18963
+ }
18964
+ for (const kind of ["product", "location"]) if (Object.hasOwn(source, kind)) {
18965
+ const flag = kind === "product" ? "isSerialized" : "isActive";
18966
+ const record = closedFacts(source[kind], ["id", flag]);
18967
+ const id = int32(own(record, "id"), "expected reference id", 1);
18968
+ const state2 = own(record, flag);
18969
+ if (typeof state2 !== "boolean") fail("expected reference state must be an own boolean");
18970
+ if (kind === "product") result.product = { id, isSerialized: state2 };
18971
+ else result.location = { id, isActive: state2 };
18972
+ }
18973
+ return result;
18974
+ }
18975
+ function rejectInventoryFactsOption(options, operation) {
18976
+ if (operation === "inventory_items.create" || operation === "inventory_items.update" || !isRecord2(options)) return;
18977
+ const option = Object.getOwnPropertyDescriptor(options, "expectedInventoryFacts");
18978
+ if (option === void 0 && !("expectedInventoryFacts" in options)) return;
18979
+ if (option !== void 0 && Object.hasOwn(option, "value") && option.value === void 0) return;
18980
+ fail("expectedInventoryFacts is supported only by inventory_items.create/update");
18981
+ }
18982
+ function inventoryFactsStale(operation) {
18983
+ const error = new StaleObjectError("inventory_items: approved facts changed; no mutation was sent", {
18984
+ operation,
18985
+ suggestedAction: "Read fresh inventory facts and generate a new preview and approval before retrying."
18986
+ });
18987
+ Object.assign(error, { notSent: true });
18988
+ throw error;
18989
+ }
18990
+ function rethrowInventoryGuardError(error, expected, operation) {
18991
+ if (expected !== void 0 && error instanceof NotFoundError && error.httpStatus === 200) inventoryFactsStale(operation);
18992
+ throw error;
18993
+ }
18994
+ function assertApprovedFacts(expected, actual, operation) {
18995
+ const before = expected;
18996
+ const after = actual;
18997
+ if (Object.keys(before).length !== Object.keys(after).length || Object.keys(before).some((key) => !Object.hasOwn(after, key) || before[key] !== after[key])) {
18998
+ inventoryFactsStale(operation);
18999
+ }
19000
+ }
19001
+ function assertQuantityRange(minimum, maximum) {
19002
+ if (typeof minimum === "number" && typeof maximum === "number" && maximum < minimum) fail("quantityMaximum must be at least quantityMinimum");
19003
+ }
19004
+ function exactItem(value, id, label, approvedOperation) {
19005
+ const record = isRecord2(value);
19006
+ if (approvedOperation !== void 0 && (!record || own(value, "id") === null)) {
19007
+ throw Object.assign(new AutotaskError("InventoryItems approval could not verify the Product item or its exact ID", {
19008
+ code: "INVALID_RESPONSE",
19009
+ category: "server",
19010
+ operation: approvedOperation
19011
+ }), { notSent: true });
19012
+ }
19013
+ if (!record) fail(`${label} must be a record`);
19014
+ if (approvedOperation !== void 0 && !Object.hasOwn(value, "id")) inventoryFactsStale(approvedOperation);
19015
+ const returned = own(value, "id");
19016
+ if (typeof returned !== "string" && (typeof returned !== "number" || !Number.isSafeInteger(returned))) fail(`${label} requires its own exact id`);
19017
+ if (String(returned) !== String(id)) {
19018
+ if (approvedOperation !== void 0 && isAuditDecimalId(String(returned))) inventoryFactsStale(approvedOperation);
19019
+ fail(`${label} id must match the requested id`);
19020
+ }
19021
+ return value;
19022
+ }
19023
+ async function productIsSerialized(http, id, checkedBaseUrl, maxRetries, expected, mutationOperation = "inventory_items.update") {
19024
+ const operation = "products.get";
19025
+ const body = await http.request({
19026
+ method: "GET",
19027
+ path: `/V1.0/Products/${id}`,
19028
+ operation,
19029
+ maxRetries,
19030
+ checkedBaseUrl,
19031
+ ...expected !== void 0 ? { [INVENTORY_APPROVAL_PRODUCT_ID]: true } : {}
19032
+ });
19033
+ let raw;
19034
+ try {
19035
+ raw = unwrapItem(body, id, operation, "product");
19036
+ } catch (error) {
19037
+ rethrowInventoryGuardError(error, expected === void 0 ? void 0 : { }, mutationOperation);
19038
+ }
19039
+ const product = exactItem(raw, id, "product", expected === void 0 ? void 0 : mutationOperation);
19040
+ const serialized = own(product, "isSerialized");
19041
+ if (expected !== void 0) assertApprovedFacts(expected, { id, isSerialized: serialized }, mutationOperation);
19042
+ if (typeof serialized !== "boolean") fail("product requires a fresh boolean isSerialized fact");
19043
+ return serialized;
19044
+ }
19045
+ async function guardInventoryItemCreate(http, data, checkedBaseUrl, maxRetries, expected) {
19046
+ const locationId = data.inventoryLocationID;
19047
+ const operation = "inventory_locations.get";
19048
+ const body = await http.request({ method: "GET", path: `/V1.0/InventoryLocations/${locationId}`, operation, maxRetries, checkedBaseUrl });
19049
+ let raw;
19050
+ try {
19051
+ raw = unwrapItem(body, locationId, operation, "inventory_location");
19052
+ } catch (error) {
19053
+ rethrowInventoryGuardError(error, expected, "inventory_items.create");
19054
+ }
19055
+ const location = exactItem(raw, locationId, "inventory location");
19056
+ if (expected?.location !== void 0) assertApprovedFacts(expected.location, { id: locationId, isActive: own(location, "isActive") }, "inventory_items.create");
19057
+ if (own(location, "isActive") !== true) fail("inventory location requires a fresh isActive value explicitly true");
19058
+ if (await productIsSerialized(http, data.productID, checkedBaseUrl, maxRetries, expected?.product, "inventory_items.create") && data.quantityOnHand !== 0) {
19059
+ fail("quantityOnHand must be zero when creating an item for a serialized product");
19060
+ }
19061
+ }
19062
+ async function checkInventoryItemCurrent(http, data, current, id, checkedBaseUrl, maxRetries, expected) {
19063
+ const item = exactItem(current, id, "current record");
19064
+ if (expected?.item !== void 0) assertApprovedFacts(expected.item, inventoryItemGuardFacts(item), "inventory_items.update");
19065
+ const minimum = own(data, "quantityMinimum");
19066
+ const maximum = own(data, "quantityMaximum");
19067
+ if (minimum !== void 0 || maximum !== void 0) {
19068
+ assertQuantityRange(
19069
+ minimum ?? int32(own(item, "quantityMinimum"), "current quantityMinimum", 0),
19070
+ maximum ?? int32(own(item, "quantityMaximum"), "current quantityMaximum")
19071
+ );
19072
+ }
19073
+ const onHand = own(data, "quantityOnHand");
19074
+ if (typeof onHand !== "number") return;
19075
+ const picked = int32(own(item, "quantityPicked"), "current quantityPicked");
19076
+ const reserved = int32(own(item, "quantityReserved"), "current quantityReserved");
19077
+ if (onHand < picked + reserved) fail("quantityOnHand must be at least quantityPicked plus quantityReserved");
19078
+ const productId = int32(own(item, "productID"), "current productID", 1);
19079
+ if (await productIsSerialized(http, productId, checkedBaseUrl, maxRetries, expected?.product)) fail("quantityOnHand is read-only on update for a serialized product");
19080
+ }
19081
+
19082
+ // src/operations/requiredFields.ts
19083
+ function effectiveRequiredFields(record, zoneFacts) {
19084
+ const guidance = zoneFacts?.createGuidance;
19085
+ const prefix = guidance?.liveProvenPrefix;
19086
+ if (Array.isArray(prefix) && prefix.length > 0) {
19087
+ const gates = guidance?.requiresByValue;
19088
+ const gated = new Set((gates ?? []).flatMap((g) => [...g.requires.allOf ?? [], ...g.requires.anyOf ?? []]));
19089
+ return {
19090
+ fields: prefix.filter((f) => !gated.has(f)),
19091
+ from: "live-proven",
19092
+ unproven: guidance?.unproven === true,
19093
+ ...Array.isArray(gates) && gates.length > 0 ? { conditional: gates } : {}
19094
+ };
19095
+ }
19096
+ const zoneSet = zoneFacts?.createRequiredSet;
19097
+ if (Array.isArray(zoneSet) && zoneSet.length > 0) {
19098
+ return { fields: [...zoneSet], from: "zone", unproven: guidance?.unproven === true };
19099
+ }
19100
+ const spec = record?.requiredFields;
19101
+ return { fields: Array.isArray(spec) ? [...spec] : [], from: "spec", unproven: true };
19102
+ }
19103
+
19104
+ // src/operations/types.ts
19105
+ var WORKFLOW_RESOURCES = [
19106
+ "companies",
19107
+ "tickets",
19108
+ "contacts",
19109
+ "configuration_items",
19110
+ "projects"
19111
+ ];
19112
+
19113
+ // src/metadata-views.ts
19114
+ function liveFieldNamesView(rows) {
19115
+ if (!Array.isArray(rows)) return null;
19116
+ const names = [];
19117
+ for (const row of rows) if (typeof row.name === "string") names.push(row.name);
19118
+ return names.length === 0 ? null : { names, known: new Set(names) };
19119
+ }
19120
+ function projectFieldRow(raw, labels = false, udf = false) {
19121
+ const r = typeof raw === "object" && raw !== null ? raw : {};
19122
+ const name = typeof r.name === "string" ? r.name : "";
19123
+ const type = typeof r.dataType === "string" ? r.dataType : typeof r.type === "string" ? r.type : "";
19124
+ const values = labels && r.isPickList === true && Array.isArray(r.picklistValues) && r.picklistValues.length > 0 ? r.picklistValues : void 0;
19125
+ const referenceEntityType = typeof r.referenceEntityType === "string" ? r.referenceEntityType : "";
19126
+ return {
19127
+ name,
19128
+ ...typeof r.label === "string" && r.label !== "" ? { label: r.label } : {},
19129
+ type,
19130
+ isRequired: r.isRequired === true,
19131
+ isReadOnly: r.isReadOnly === true,
19132
+ // Issue #219 N7: a UDF row never serves the vendor's isQueryable (it is
19133
+ // true for UDFs while a plain filter on a UDF name is refused); it serves
19134
+ // the marker the filter actually needs.
19135
+ ...udf ? { filterable: "udf-marker" } : { isQueryable: r.isQueryable === true },
19136
+ isPickList: r.isPickList === true,
19137
+ ...isObjectOrArrayType(type) ? { writeShape: "replace-all" } : {},
19138
+ maxLength: typeof r.length === "number" ? r.length : null,
19139
+ referenceEntityType,
19140
+ ...values !== void 0 ? { picklistValues: values } : {}
19141
+ };
19142
+ }
19143
+ function isObjectOrArrayType(type) {
19144
+ const t = type.trim().toLowerCase();
19145
+ return t === "object" || t === "array" || t === "collection" || t.endsWith("[]");
19146
+ }
19147
+ function exposesPicklistValues(raw) {
19148
+ const r = typeof raw === "object" && raw !== null ? raw : {};
19149
+ return Array.isArray(r.picklistValues) && r.picklistValues.length > 0;
19150
+ }
19151
+ function catalogList(raw, labels, udf) {
19152
+ return Array.isArray(raw) ? { rows: raw.map((row) => projectFieldRow(row, labels, udf)), exposesValues: raw.some(exposesPicklistValues) } : { rows: null, exposesValues: false };
19153
+ }
19154
+ var catalogFieldsView = (raw) => catalogList(raw, false, false);
19155
+ var catalogLabelledFieldsView = (raw) => catalogList(raw, true, false);
19156
+ var catalogUdfView = (raw) => catalogList(raw, false, true);
19157
+ var catalogLabelledUdfView = (raw) => catalogList(raw, true, true);
19158
+ function compactCatalogList(raw, keepValues, udf) {
19159
+ const view = catalogList(raw, keepValues, udf);
19160
+ if (view.rows === null) return { rows: null, exposesValues: view.exposesValues };
19161
+ const flags = {
19162
+ required: view.rows.filter((row) => row.isRequired).map((row) => row.name),
19163
+ readOnly: view.rows.filter((row) => row.isReadOnly).map((row) => row.name),
19164
+ queryable: view.rows.filter((row) => row.isQueryable).map((row) => row.name),
19165
+ picklistFields: view.rows.filter((row) => row.isPickList).map((row) => row.name)
19166
+ };
19167
+ return {
19168
+ rows: view.rows.map((row) => ({
19169
+ name: row.name,
19170
+ type: row.type,
19171
+ isPickList: row.isPickList,
19172
+ isReference: row.referenceEntityType !== "",
19173
+ udf,
19174
+ ...keepValues && row.picklistValues !== void 0 ? { picklistValues: row.picklistValues } : {}
19175
+ })),
19176
+ flags,
19177
+ exposesValues: view.exposesValues
19178
+ };
19179
+ }
19180
+ var compactCatalogFieldsView = (raw) => compactCatalogList(raw, false, false);
19181
+ var compactCatalogLabelledFieldsView = (raw) => compactCatalogList(raw, true, false);
19182
+ var compactCatalogUdfView = (raw) => compactCatalogList(raw, false, true);
19183
+ var compactCatalogLabelledUdfView = (raw) => compactCatalogList(raw, true, true);
19184
+ function ticketStatusView(fields) {
19185
+ if (!Array.isArray(fields)) return [];
19186
+ const status = fields.find((f) => typeof f?.name === "string" && f.name.toLowerCase() === "status");
19187
+ if (status === void 0 || status.isPickList !== true || !Array.isArray(status.picklistValues)) return [];
19188
+ const out = [];
19189
+ for (const v of status.picklistValues) {
18568
19190
  const id = Number(v?.value);
18569
19191
  if (!Number.isSafeInteger(id)) continue;
18570
19192
  out.push({ id, label: typeof v.label === "string" ? v.label : "" });
@@ -18933,291 +19555,131 @@ async function readKind(ctx, resource, kind, fetch2, holder, projector = catalog
18933
19555
  async function sweepResource(ctx, resource, tally, reads) {
18934
19556
  const { fieldsFilter } = ctx;
18935
19557
  const fieldOp = ctx.fieldOps.get(resource);
18936
- if (fieldOp === void 0) return void 0;
18937
- const apiEntity = apiEntityFor(fieldOp);
18938
- const row = {
18939
- resource,
18940
- apiEntity,
18941
- udfCapable: ctx.udfCapable.has(resource),
18942
- // Issue #219 N7: the UDF surface is declared with the mechanism, not a boolean.
18943
- ...ctx.udfCapable.has(resource) ? { udfFilter: "udf-marker", udfWriteShape: "merge" } : {},
18944
- unmatchedFields: [],
18945
- required: [],
18946
- readOnly: [],
18947
- queryable: [],
18948
- picklistFields: [],
18949
- cache: { hit: false, age: null },
18950
- wire: 0,
18951
- error: null
18952
- };
18953
- let allCached = true;
18954
- const ages = [];
18955
- for (const { kind, peek, outcome } of reads) {
18956
- if (!peek.hit) {
18957
- allCached = false;
18958
- tally.wireUsed += 1;
18959
- row.wire += 1;
18960
- } else if (peek.age !== null) ages.push(peek.age);
18961
- if (outcome.status === "rejected") {
18962
- const error = outcome.reason;
18963
- if (row.error === null) row.error = { code: error.code, message: error.message };
18964
- continue;
18965
- }
18966
- const value = outcome.value;
18967
- if (kind === "info") {
18968
- row.info = value ?? null;
18969
- } else {
18970
- const view = value;
18971
- if (view.rows === null) {
18972
- if (row.error === null) row.error = { code: "INVALID_RESPONSE", message: `fieldCatalog: the ${kind} response for ${resource} was not a list` };
18973
- continue;
18974
- }
18975
- if (kind === "fields") applyFieldsFilter(view.rows, fieldsFilter, row, view.flags);
18976
- else row.udf = view.rows;
18977
- if (view.exposesValues) tally.anyPicklistValues = true;
18978
- }
18979
- }
18980
- row.cache = allCached ? { hit: true, age: ages.length > 0 ? Math.max(...ages) : 0 } : { hit: false, age: null };
18981
- const declared = await derivedFieldsFor(resource);
18982
- if (declared.length > 0) {
18983
- const byField = new Map(declared.map((d) => [d.field, d]));
18984
- row.derivedFields = declared;
18985
- for (const field of ctx.compact ? [] : row.fields ?? []) {
18986
- const derivation = byField.get(field.name);
18987
- if (derivation === void 0) continue;
18988
- field.derived = {
18989
- rule: derivation.rule,
18990
- ...derivation.writableRoute !== void 0 ? { writableRoute: derivation.writableRoute } : {}
18991
- };
18992
- }
18993
- }
18994
- return row;
18995
- }
18996
- async function prepareCatalog(client, opts) {
18997
- validateCatalogOptsShape(opts);
18998
- const { fieldOps, udfCapable, resources: allResources } = await capabilitySets();
18999
- const include = resolveInclude(opts);
19000
- const targets = resolveTargets(opts, fieldOps, allResources);
19001
- const fieldsFilter = resolveFieldsFilter(opts);
19002
- const labels = resolveLabels(opts);
19003
- const { compact, maxBytes } = resolveSizeOpts(opts);
19004
- assertWithinWireCap(targets.length, include.length);
19005
- const ctx = { client, include, fieldsFilter, labels, compact, fresh: opts?.fresh === true, fieldOps, udfCapable };
19006
- return { ctx, targets, compact, maxBytes };
19007
- }
19008
- async function fieldCatalogPicklists(client, resource, fields) {
19009
- const { ctx } = await prepareCatalog(client, { resources: [resource], labels: true, fields: [...fields] });
19010
- const holder = client[camelKey(resource)];
19011
- const [read] = await mapReadTasks(client.http, [resource], () => readKind(ctx, resource, "fields", kindFetches(holder, resource).fields, holder, picklistsView));
19012
- return read.outcome.status === "fulfilled" ? read.outcome.value : null;
19013
- }
19014
- async function fieldCatalog(client, opts) {
19015
- const { ctx, targets, compact, maxBytes } = await prepareCatalog(client, opts);
19016
- const { include, labels, fieldOps, udfCapable } = ctx;
19017
- const cache = client.http.fieldCache;
19018
- const zone = client.config.zone ?? "unknown";
19019
- const rows = [];
19020
- const tally = { wireUsed: 0, anyPicklistValues: false };
19021
- for (const resource of targets) {
19022
- apiEntityFor(fieldOps.get(resource));
19023
- if (ctx.fresh) cache?.invalidate(`${resource}:`);
19024
- }
19025
- const tasks = targets.flatMap((resource) => {
19026
- const holder = client[camelKey(resource)];
19027
- const fetches = kindFetches(holder, resource);
19028
- return include.map((kind) => ({ resource, kind, fetch: fetches[kind], holder }));
19029
- });
19030
- const reads = await mapReadTasks(client.http, tasks, ({ resource, kind, fetch: fetch2, holder }) => readKind(ctx, resource, kind, fetch2, holder));
19031
- for (let index = 0; index < targets.length; index += 1) {
19032
- const start = index * include.length;
19033
- const row = await sweepResource(ctx, targets[index], tally, reads.slice(start, start + include.length));
19034
- if (row !== void 0) rows.push(row);
19035
- }
19036
- const result = {
19037
- zone,
19038
- label: zone,
19039
- cached: cache !== void 0,
19040
- labels,
19041
- compact,
19042
- ttlMs: cache?.ttlMs ?? null,
19043
- fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
19044
- rows,
19045
- wireUsed: tally.wireUsed,
19046
- cap: MAX_FIELD_CATALOG_WIRE,
19047
- truncated: false,
19048
- counts: {
19049
- resources: targets.length,
19050
- fieldCapableResources: fieldOps.size,
19051
- udfCapableResources: udfCapable.size,
19052
- cached: rows.filter((r) => r.cache.hit === true).length
19053
- },
19054
- honesty: {
19055
- picklistValues: tally.anyPicklistValues ? "partial" : "unexposed",
19056
- note: FIELD_CATALOG_HONESTY_NOTE
19057
- }
19058
- };
19059
- if (maxBytes !== void 0) applyMaxBytes(result, maxBytes);
19060
- return result;
19061
- }
19062
-
19063
- // src/resources/base/helpers.ts
19064
- function describeResponseShape(body) {
19065
- if (body === null) return "null";
19066
- if (Array.isArray(body)) return `array(len=${body.length})`;
19067
- if (typeof body !== "object") return typeof body;
19068
- const rec = body;
19069
- const keys = Object.keys(rec).sort();
19070
- const typeOf = (v) => v === null ? "null" : Array.isArray(v) ? "array" : typeof v;
19071
- const parts = keys.slice(0, 16).map((k) => `${k}:${typeOf(rec[k])}`);
19072
- const more = keys.length > 16 ? `, +${keys.length - 16} more` : "";
19073
- return `{ ${parts.join(", ")}${more} }`;
19074
- }
19075
- function defaultMarkerToken(data) {
19076
- for (const field of ["name", "title"]) {
19077
- const v = data[field];
19078
- if (typeof v === "string" && v.trim() !== "") return v.trim();
19079
- }
19080
- return null;
19081
- }
19082
- var CONTEXT_ABSENT_MARKER = "#context-absent";
19083
- function contextAbsentKey(path) {
19084
- return path + "\0context-absent";
19085
- }
19086
- function noteCharsTruncationMarker(charsRemoved) {
19087
- return `\u2026 [+${charsRemoved} chars truncated]`;
19088
- }
19089
- function truncateNoteChars(items, cap, fields) {
19090
- let truncated = 0;
19091
- const out = items.map((item) => {
19092
- if (!isRecord2(item)) return item;
19093
- let changed = false;
19094
- const copy = { ...item };
19095
- for (const field of fields) {
19096
- const v = copy[field];
19097
- if (typeof v === "string" && v !== REDACTED && v.length > cap) {
19098
- const end = cap > 0 && (v.charCodeAt(cap - 1) & 64512) === 55296 ? cap - 1 : cap;
19099
- copy[field] = v.slice(0, end) + noteCharsTruncationMarker(v.length - end);
19100
- truncated += 1;
19101
- changed = true;
19102
- }
19103
- }
19104
- return changed ? copy : item;
19105
- });
19106
- return [out, truncated];
19107
- }
19108
- function blindEmptyReason(stamp) {
19109
- return {
19110
- surface: stamp.surface,
19111
- kind: "blind-surface",
19112
- note: stamp.note,
19113
- authority: stamp.authority,
19114
- remedy: "the note is the remedy \u2014 the authority op answers for a record"
19115
- };
19116
- }
19117
- function attachUpdateTargetMissReason(err, key) {
19118
- const pinned = EMPTY_REASON_STAMPS[key]?.update;
19119
- if (pinned === void 0) return;
19120
- err.details = { ...err.details ?? {}, emptyReason: pinned };
19121
- }
19122
- function buildDryRunResult(spec, policy) {
19123
- if (spec.operation === "") {
19124
- throw new AutotaskConfigError("dry-run: the operation name is required");
19125
- }
19126
- const wouldApply = spec.checks.every((check) => check.ok);
19127
- const resource = spec.operation.split(".")[0] ?? spec.operation;
19128
- const diffPart = spec.diff !== void 0 ? {
19129
- diff: spec.diff.map((entry) => {
19130
- if (entry.to === void 0) return entry;
19131
- const to = isRedactedFieldName(entry.field, policy) ? REDACTED : redactResponseBody(entry.to, policy);
19132
- return { ...entry, to };
19133
- })
19134
- } : {};
19135
- const dataPart = spec.data !== void 0 ? { data: redactResponseBody(spec.data, policy) } : {};
19136
- return {
19137
- operation: spec.operation,
19138
- wouldApply,
19139
- target: { resource, ids: spec.ids },
19140
- request: { method: spec.method, path: spec.path },
19141
- ...diffPart,
19142
- checks: spec.checks,
19143
- impact: spec.impact,
19144
- simulated: true,
19145
- warnings: spec.warnings ?? [],
19146
- ...dataPart,
19147
- ...spec.emptyReason !== void 0 ? { emptyReason: spec.emptyReason } : {}
19148
- };
19149
- }
19150
- function computeFieldDiff(current, data) {
19151
- const out = [];
19152
- for (const [field, to] of Object.entries(data)) {
19153
- if (field === "id" || to === void 0) continue;
19154
- const from = Object.hasOwn(current, field) ? current[field] : void 0;
19155
- if (from !== void 0 && JSON.stringify(from) === JSON.stringify(to)) continue;
19156
- out.push({ field, from: from === void 0 ? null : from, to });
19157
- }
19158
- return out;
19159
- }
19160
- function mergePartialBody(current, data) {
19161
- const merged = { ...current };
19162
- for (const [key, value] of Object.entries(data)) {
19163
- if (value === void 0) continue;
19164
- merged[key] = value;
19165
- }
19166
- return merged;
19167
- }
19168
- function snapshotMutationOptions(options) {
19169
- const { dryRun, lastModifiedDate, maxRetries, raw, verifyPersisted } = options ?? {};
19170
- if (dryRun !== void 0 && typeof dryRun !== "boolean") {
19171
- throw new AutotaskConfigError("dryRun must be a boolean");
19172
- }
19173
- return { dryRun, lastModifiedDate, maxRetries, raw, verifyPersisted };
19174
- }
19175
- function normalizeUdfInput(value) {
19176
- if (Array.isArray(value)) {
19177
- return value.map((entry) => {
19178
- if (!isRecord2(entry) || typeof entry.name !== "string" || entry.name === "") {
19179
- throw new AutotaskConfigError("userDefinedFields array entries must be { name, value } objects");
19558
+ if (fieldOp === void 0) return void 0;
19559
+ const apiEntity = apiEntityFor(fieldOp);
19560
+ const row = {
19561
+ resource,
19562
+ apiEntity,
19563
+ udfCapable: ctx.udfCapable.has(resource),
19564
+ // Issue #219 N7: the UDF surface is declared with the mechanism, not a boolean.
19565
+ ...ctx.udfCapable.has(resource) ? { udfFilter: "udf-marker", udfWriteShape: "merge" } : {},
19566
+ unmatchedFields: [],
19567
+ required: [],
19568
+ readOnly: [],
19569
+ queryable: [],
19570
+ picklistFields: [],
19571
+ cache: { hit: false, age: null },
19572
+ wire: 0,
19573
+ error: null
19574
+ };
19575
+ let allCached = true;
19576
+ const ages = [];
19577
+ for (const { kind, peek, outcome } of reads) {
19578
+ if (!peek.hit) {
19579
+ allCached = false;
19580
+ tally.wireUsed += 1;
19581
+ row.wire += 1;
19582
+ } else if (peek.age !== null) ages.push(peek.age);
19583
+ if (outcome.status === "rejected") {
19584
+ const error = outcome.reason;
19585
+ if (row.error === null) row.error = { code: error.code, message: error.message };
19586
+ continue;
19587
+ }
19588
+ const value = outcome.value;
19589
+ if (kind === "info") {
19590
+ row.info = value ?? null;
19591
+ } else {
19592
+ const view = value;
19593
+ if (view.rows === null) {
19594
+ if (row.error === null) row.error = { code: "INVALID_RESPONSE", message: `fieldCatalog: the ${kind} response for ${resource} was not a list` };
19595
+ continue;
19180
19596
  }
19181
- return { name: entry.name, value: entry.value };
19182
- });
19597
+ if (kind === "fields") applyFieldsFilter(view.rows, fieldsFilter, row, view.flags);
19598
+ else row.udf = view.rows;
19599
+ if (view.exposesValues) tally.anyPicklistValues = true;
19600
+ }
19183
19601
  }
19184
- if (isRecord2(value)) {
19185
- return Object.entries(value).map(([name, entryValue]) => ({ name, value: entryValue }));
19602
+ row.cache = allCached ? { hit: true, age: ages.length > 0 ? Math.max(...ages) : 0 } : { hit: false, age: null };
19603
+ const declared = await derivedFieldsFor(resource);
19604
+ if (declared.length > 0) {
19605
+ const byField = new Map(declared.map((d) => [d.field, d]));
19606
+ row.derivedFields = declared;
19607
+ for (const field of ctx.compact ? [] : row.fields ?? []) {
19608
+ const derivation = byField.get(field.name);
19609
+ if (derivation === void 0) continue;
19610
+ field.derived = {
19611
+ rule: derivation.rule,
19612
+ ...derivation.writableRoute !== void 0 ? { writableRoute: derivation.writableRoute } : {}
19613
+ };
19614
+ }
19186
19615
  }
19187
- throw new AutotaskConfigError("userDefinedFields must be an array of { name, value } entries or a name-to-value map");
19616
+ return row;
19188
19617
  }
19189
- function blindStampFor(stamp, filter) {
19190
- if (stamp === void 0) return void 0;
19191
- if (stamp.kind !== "unfiltered-blind") return stamp;
19192
- const conditions = normalizedConditions(filter);
19193
- return conditions === void 0 || conditions.length === 0 ? stamp : void 0;
19618
+ async function prepareCatalog(client, opts) {
19619
+ validateCatalogOptsShape(opts);
19620
+ const { fieldOps, udfCapable, resources: allResources } = await capabilitySets();
19621
+ const include = resolveInclude(opts);
19622
+ const targets = resolveTargets(opts, fieldOps, allResources);
19623
+ const fieldsFilter = resolveFieldsFilter(opts);
19624
+ const labels = resolveLabels(opts);
19625
+ const { compact, maxBytes } = resolveSizeOpts(opts);
19626
+ assertWithinWireCap(targets.length, include.length);
19627
+ const ctx = { client, include, fieldsFilter, labels, compact, fresh: opts?.fresh === true, fieldOps, udfCapable };
19628
+ return { ctx, targets, compact, maxBytes };
19194
19629
  }
19195
- function decodeFileData(body) {
19196
- if (isRecord2(body)) {
19197
- const data = body.data;
19198
- if (typeof data === "string") return Buffer.from(data, "base64");
19199
- if (Array.isArray(data) && data.every((b) => typeof b === "number")) {
19200
- return Buffer.from(data);
19201
- }
19202
- }
19203
- if (typeof body === "string") return Buffer.from(body, "base64");
19204
- throw new AutotaskError(
19205
- "Expected the file envelope FileQueryResultModel { data } (or a base64 string); got a different shape",
19206
- { code: "INVALID_RESPONSE", category: "server" }
19207
- );
19630
+ async function fieldCatalogPicklists(client, resource, fields) {
19631
+ const { ctx } = await prepareCatalog(client, { resources: [resource], labels: true, fields: [...fields] });
19632
+ const holder = client[camelKey(resource)];
19633
+ const [read] = await mapReadTasks(client.http, [resource], () => readKind(ctx, resource, "fields", kindFetches(holder, resource).fields, holder, picklistsView));
19634
+ return read.outcome.status === "fulfilled" ? read.outcome.value : null;
19208
19635
  }
19209
- var DEPLURAL_EXCEPTIONS = {
19210
- tag_aliase: "tag_alias"
19211
- };
19212
- function entityNameFromPath(resourcePath) {
19213
- const segment = resourcePath.slice(resourcePath.lastIndexOf("/") + 1);
19214
- const snake = segment.replace(/([A-Z])/g, (_m, c, i) => (i > 0 ? `_` : "") + c.toLowerCase()).replace(/_{2,}/g, "_");
19215
- if (snake.endsWith("ies")) return `${snake.slice(0, -3)}y`;
19216
- if (snake.endsWith("s")) {
19217
- const stripped = snake.slice(0, -1);
19218
- return DEPLURAL_EXCEPTIONS[stripped] ?? stripped;
19636
+ async function fieldCatalog(client, opts) {
19637
+ const { ctx, targets, compact, maxBytes } = await prepareCatalog(client, opts);
19638
+ const { include, labels, fieldOps, udfCapable } = ctx;
19639
+ const cache = client.http.fieldCache;
19640
+ const zone = client.config.zone ?? "unknown";
19641
+ const rows = [];
19642
+ const tally = { wireUsed: 0, anyPicklistValues: false };
19643
+ for (const resource of targets) {
19644
+ apiEntityFor(fieldOps.get(resource));
19645
+ if (ctx.fresh) cache?.invalidate(`${resource}:`);
19219
19646
  }
19220
- return snake;
19647
+ const tasks = targets.flatMap((resource) => {
19648
+ const holder = client[camelKey(resource)];
19649
+ const fetches = kindFetches(holder, resource);
19650
+ return include.map((kind) => ({ resource, kind, fetch: fetches[kind], holder }));
19651
+ });
19652
+ const reads = await mapReadTasks(client.http, tasks, ({ resource, kind, fetch: fetch2, holder }) => readKind(ctx, resource, kind, fetch2, holder));
19653
+ for (let index = 0; index < targets.length; index += 1) {
19654
+ const start = index * include.length;
19655
+ const row = await sweepResource(ctx, targets[index], tally, reads.slice(start, start + include.length));
19656
+ if (row !== void 0) rows.push(row);
19657
+ }
19658
+ const result = {
19659
+ zone,
19660
+ label: zone,
19661
+ cached: cache !== void 0,
19662
+ labels,
19663
+ compact,
19664
+ ttlMs: cache?.ttlMs ?? null,
19665
+ fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
19666
+ rows,
19667
+ wireUsed: tally.wireUsed,
19668
+ cap: MAX_FIELD_CATALOG_WIRE,
19669
+ truncated: false,
19670
+ counts: {
19671
+ resources: targets.length,
19672
+ fieldCapableResources: fieldOps.size,
19673
+ udfCapableResources: udfCapable.size,
19674
+ cached: rows.filter((r) => r.cache.hit === true).length
19675
+ },
19676
+ honesty: {
19677
+ picklistValues: tally.anyPicklistValues ? "partial" : "unexposed",
19678
+ note: FIELD_CATALOG_HONESTY_NOTE
19679
+ }
19680
+ };
19681
+ if (maxBytes !== void 0) applyMaxBytes(result, maxBytes);
19682
+ return result;
19221
19683
  }
19222
19684
 
19223
19685
  // src/operations/nameSnapshot.ts
@@ -20064,17 +20526,17 @@ function validateParamsBag(record, args) {
20064
20526
  }
20065
20527
  );
20066
20528
  }
20067
- var INVOKE_OPTION_KEYS = ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted", "mode"];
20529
+ var INVOKE_OPTION_KEYS = ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted", "expectedInventoryFacts", "mode"];
20068
20530
  function validateInvokeOptions(opts, operation) {
20069
20531
  if (opts === void 0 || opts === null) return;
20070
20532
  const unknown = Object.keys(opts).filter((k) => !INVOKE_OPTION_KEYS.includes(k));
20071
20533
  if (unknown.length === 0) return;
20072
- const suggestions = keySuggestions(unknown, ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted"]);
20534
+ const suggestions = keySuggestions(unknown, ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted", "expectedInventoryFacts"]);
20073
20535
  throw new AutotaskConfigError(
20074
- `invoke: "${operation}" has unknown option key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the options set is closed (valid: dryRun, confirm, lastModifiedDate, maxRetries, fresh, verifyPersisted; "mode" is internal to the mode wrappers)`,
20536
+ `invoke: "${operation}" has unknown option key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the options set is closed (valid: dryRun, confirm, lastModifiedDate, maxRetries, fresh, verifyPersisted, expectedInventoryFacts; "mode" is internal to the mode wrappers)`,
20075
20537
  {
20076
20538
  operation,
20077
- suggestedAction: suggestions.length > 0 ? `Fix the option name (${suggestions.join(", ")}).` : `Pass only dryRun / confirm / lastModifiedDate / maxRetries / fresh / verifyPersisted.`
20539
+ suggestedAction: suggestions.length > 0 ? `Fix the option name (${suggestions.join(", ")}).` : `Pass only dryRun / confirm / lastModifiedDate / maxRetries / fresh / verifyPersisted / expectedInventoryFacts.`
20078
20540
  }
20079
20541
  );
20080
20542
  }
@@ -20093,126 +20555,24 @@ function unknownKeysRefusal(raw, validKeys, subject, operation) {
20093
20555
  }
20094
20556
 
20095
20557
  // src/resources/special/inventoryLocations.ts
20096
- var fail = (message) => {
20558
+ var fail2 = (message) => {
20097
20559
  throw new AutotaskConfigError(`inventory_locations: ${message}`);
20098
20560
  };
20099
20561
  function admitInventoryLocation(value, creating) {
20100
- if (!isRecord2(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail("data must be a plain record");
20562
+ if (!isRecord2(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail2("data must be a plain record");
20101
20563
  const body = { ...value };
20102
- for (const field of Object.keys(body)) if (!["locationName", "isActive"].includes(field)) fail(`${field} is not a writable InventoryLocations field`);
20564
+ for (const field of Object.keys(body)) if (!["locationName", "isActive"].includes(field)) fail2(`${field} is not a writable InventoryLocations field`);
20103
20565
  const hasName = Object.hasOwn(body, "locationName");
20104
20566
  const hasActive = Object.hasOwn(body, "isActive");
20105
- if (creating && !hasName || hasName && (typeof body.locationName !== "string" || body.locationName.trim() === "" || body.locationName.length > 50)) fail("locationName is required and must be a nonblank string of at most 50 characters");
20106
- if (creating && !hasActive || hasActive && typeof body.isActive !== "boolean") fail("isActive must be a boolean");
20107
- if (!creating && !hasName && !hasActive) fail("update must contain locationName or isActive");
20567
+ if (creating && !hasName || hasName && (typeof body.locationName !== "string" || body.locationName.trim() === "" || body.locationName.length > 50)) fail2("locationName is required and must be a nonblank string of at most 50 characters");
20568
+ if (creating && !hasActive || hasActive && typeof body.isActive !== "boolean") fail2("isActive must be a boolean");
20569
+ if (!creating && !hasName && !hasActive) fail2("update must contain locationName or isActive");
20108
20570
  return body;
20109
20571
  }
20110
20572
  function checkInventoryLocationCurrent(value, current, id) {
20111
- if (!isRecord2(current) || !Object.hasOwn(current, "id")) fail("current record requires its own id");
20112
- if (parseIdentifier(current.id, "inventory_locations: current id") !== id) fail("current record id must match the requested id");
20113
- if (Object.hasOwn(value, "isActive") && value.isActive === false && (!Object.hasOwn(current, "isDefault") || current.isDefault !== false)) fail("inactivation requires a fresh current isDefault value explicitly false; default or unknown locations cannot be inactivated");
20114
- }
20115
-
20116
- // src/resources/special/inventoryItems.ts
20117
- var REFERENCES = ["inventoryLocationID", "productID"];
20118
- var QUANTITIES = ["quantityMinimum", "quantityMaximum", "quantityOnHand"];
20119
- var TEXT_FIELDS = ["bin", "referenceNumber"];
20120
- var MUTATION_OPTIONS = ["dryRun", "lastModifiedDate", "maxRetries", "raw", "verifyPersisted"];
20121
- function fail2(message) {
20122
- throw new AutotaskConfigError(`inventory_items: ${message}`);
20123
- }
20124
- function own(record, field) {
20125
- return Object.hasOwn(record, field) ? record[field] : void 0;
20126
- }
20127
- function int32(value, label, minimum = -2147483648) {
20128
- if (typeof value !== "number" || !Number.isInteger(value) || value < minimum || value > 2147483647) {
20129
- fail2(`${label} must be an integer between ${minimum} and 2147483647`);
20130
- }
20131
- return value;
20132
- }
20133
- function inventoryItemId(value) {
20134
- const id = parseIdentifier(value, "inventory_items: id");
20135
- if (!isAuditDecimalId(String(id))) fail2("id must fit a signed 64-bit integer");
20136
- return id;
20137
- }
20138
- function admitInventoryItem(value, creating) {
20139
- if (!isRecord2(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail2("data must be a plain record");
20140
- const body = { ...value };
20141
- const writable = [...QUANTITIES, ...TEXT_FIELDS, ...creating ? REFERENCES : []];
20142
- for (const field of Object.keys(body)) {
20143
- if (!writable.some((name) => name === field)) fail2(`${field} is not a writable InventoryItems field on ${creating ? "create" : "update"}`);
20144
- }
20145
- if (!creating && Object.keys(body).length === 0) fail2("update must contain a writable field");
20146
- if (creating) for (const field of REFERENCES) int32(own(body, field), field, 1);
20147
- for (const field of QUANTITIES) {
20148
- const nonnegative = field === "quantityMinimum" || creating && field === "quantityOnHand";
20149
- if (creating || Object.hasOwn(body, field)) int32(own(body, field), field, nonnegative ? 0 : void 0);
20150
- }
20151
- for (const field of TEXT_FIELDS) {
20152
- const text = own(body, field);
20153
- if (Object.hasOwn(body, field) && (typeof text !== "string" || text.length > 50)) fail2(`${field} must be a string of at most 50 characters`);
20154
- }
20155
- assertQuantityRange(own(body, "quantityMinimum"), own(body, "quantityMaximum"));
20156
- return body;
20157
- }
20158
- function snapshotInventoryItemOptions(value) {
20159
- if (value !== void 0 && !isRecord2(value)) fail2("options must be an object");
20160
- const options = value ?? {};
20161
- for (const key of MUTATION_OPTIONS) {
20162
- if (key in options && !Object.hasOwn(options, key)) fail2(`${key} must be an own option`);
20163
- }
20164
- const result = snapshotMutationOptions(Object.fromEntries(MUTATION_OPTIONS.map((key) => [key, own(options, key)])));
20165
- if (result.lastModifiedDate !== void 0) fail2("no documented stale timestamp is available");
20166
- if (result.raw !== void 0 && result.raw !== false) fail2("raw updates are unsupported");
20167
- if (result.maxRetries !== void 0 && (!Number.isSafeInteger(result.maxRetries) || result.maxRetries < 0)) fail2("maxRetries must be a nonnegative safe integer");
20168
- if (result.verifyPersisted !== void 0 && typeof result.verifyPersisted !== "boolean") fail2("verifyPersisted must be a boolean");
20169
- return result;
20170
- }
20171
- function assertQuantityRange(minimum, maximum) {
20172
- if (typeof minimum === "number" && typeof maximum === "number" && maximum < minimum) fail2("quantityMaximum must be at least quantityMinimum");
20173
- }
20174
- function exactItem(value, id, label) {
20175
- if (!isRecord2(value)) fail2(`${label} must be a record`);
20176
- const returned = own(value, "id");
20177
- if (typeof returned !== "string" && (typeof returned !== "number" || !Number.isSafeInteger(returned))) fail2(`${label} requires its own exact id`);
20178
- if (String(returned) !== String(id)) fail2(`${label} id must match the requested id`);
20179
- return value;
20180
- }
20181
- async function productIsSerialized(http, id, checkedBaseUrl, maxRetries) {
20182
- const operation = "products.get";
20183
- const body = await http.request({ method: "GET", path: `/V1.0/Products/${id}`, operation, maxRetries, checkedBaseUrl });
20184
- const product = exactItem(unwrapItem(body, id, operation, "product"), id, "product");
20185
- const serialized = own(product, "isSerialized");
20186
- if (typeof serialized !== "boolean") fail2("product requires a fresh boolean isSerialized fact");
20187
- return serialized;
20188
- }
20189
- async function guardInventoryItemCreate(http, data, checkedBaseUrl, maxRetries) {
20190
- const locationId = data.inventoryLocationID;
20191
- const operation = "inventory_locations.get";
20192
- const body = await http.request({ method: "GET", path: `/V1.0/InventoryLocations/${locationId}`, operation, maxRetries, checkedBaseUrl });
20193
- const location = exactItem(unwrapItem(body, locationId, operation, "inventory_location"), locationId, "inventory location");
20194
- if (own(location, "isActive") !== true) fail2("inventory location requires a fresh isActive value explicitly true");
20195
- if (await productIsSerialized(http, data.productID, checkedBaseUrl, maxRetries) && data.quantityOnHand !== 0) {
20196
- fail2("quantityOnHand must be zero when creating an item for a serialized product");
20197
- }
20198
- }
20199
- async function checkInventoryItemCurrent(http, data, current, id, checkedBaseUrl, maxRetries) {
20200
- const item = exactItem(current, id, "current record");
20201
- const minimum = own(data, "quantityMinimum");
20202
- const maximum = own(data, "quantityMaximum");
20203
- if (minimum !== void 0 || maximum !== void 0) {
20204
- assertQuantityRange(
20205
- minimum ?? int32(own(item, "quantityMinimum"), "current quantityMinimum", 0),
20206
- maximum ?? int32(own(item, "quantityMaximum"), "current quantityMaximum")
20207
- );
20208
- }
20209
- const onHand = own(data, "quantityOnHand");
20210
- if (typeof onHand !== "number") return;
20211
- const picked = int32(own(item, "quantityPicked"), "current quantityPicked");
20212
- const reserved = int32(own(item, "quantityReserved"), "current quantityReserved");
20213
- if (onHand < picked + reserved) fail2("quantityOnHand must be at least quantityPicked plus quantityReserved");
20214
- const productId = int32(own(item, "productID"), "current productID", 1);
20215
- if (await productIsSerialized(http, productId, checkedBaseUrl, maxRetries)) fail2("quantityOnHand is read-only on update for a serialized product");
20573
+ if (!isRecord2(current) || !Object.hasOwn(current, "id")) fail2("current record requires its own id");
20574
+ if (parseIdentifier(current.id, "inventory_locations: current id") !== id) fail2("current record id must match the requested id");
20575
+ if (Object.hasOwn(value, "isActive") && value.isActive === false && (!Object.hasOwn(current, "isDefault") || current.isDefault !== false)) fail2("inactivation requires a fresh current isDefault value explicitly false; default or unknown locations cannot be inactivated");
20216
20576
  }
20217
20577
 
20218
20578
  // src/resources/base/types.ts
@@ -20396,6 +20756,7 @@ var MODEL_FIELD_SETS = {
20396
20756
  "organizational_level1s": ["id", "description", "isActive", "name"],
20397
20757
  "organizational_level2s": ["id", "description", "isActive", "name"],
20398
20758
  "organizational_level_associations": ["id", "isActive", "organizationalLevel1ID", "organizationalLevel2ID"],
20759
+ "organizational_resources": ["id", "organizationalLevelAssociationID", "resourceID", "soapParentPropertyId"],
20399
20760
  "phases": ["id", "createDate", "creatorResourceID", "description", "dueDate", "estimatedHours", "externalID", "isScheduled", "lastActivityDateTime", "parentPhaseID", "phaseNumber", "projectID", "startDate", "title", "soapParentPropertyId"],
20400
20761
  "product_vendors": ["id", "isActive", "isDefault", "productID", "vendorCost", "vendorID", "vendorPartNumber", "soapParentPropertyId"],
20401
20762
  "products": ["id", "billingType", "chargeBillingCodeID", "createdByResourceID", "createdTime", "defaultVendorID", "description", "doesNotRequireProcurement", "externalProductID", "impersonatorCreatorResourceID", "internalProductID", "isActive", "isEligibleForRma", "isSerialized", "link", "manufacturerName", "manufacturerProductName", "markupRate", "msrp", "name", "periodType", "priceCostMethod", "productBillingCodeID", "productCategory", "sku", "unitCost", "unitPrice", "vendorProductNumber", "defaultInstalledProductCategoryID", "userDefinedFields"],
@@ -20413,6 +20774,7 @@ var MODEL_FIELD_SETS = {
20413
20774
  "quote_templates": ["id", "calculateTaxSeparately", "createDate", "createdBy", "currencyNegativeFormat", "currencyPositiveFormat", "dateFormat", "description", "displayTaxCategorySuperscripts", "isActive", "lastActivityBy", "lastActivityDate", "name", "numberFormat", "pageLayout", "pageNumberFormat", "showEachTaxInGroup", "showGridHeader", "showTaxCategory", "showVerticalGridLines"],
20414
20775
  "quotes": ["id", "approvalStatus", "approvalStatusChangedByResourceID", "approvalStatusChangedDate", "billToLocationID", "calculateTaxSeparately", "comment", "companyID", "contactID", "createDate", "creatorResourceID", "description", "effectiveDate", "expirationDate", "extApprovalContactResponse", "extApprovalResponseDate", "extApprovalResponseSignature", "externalQuoteNumber", "groupByID", "impersonatorCreatorResourceID", "isActive", "lastActivityDate", "lastModifiedBy", "lastPublishedByResourceID", "lastPublishedDateTime", "name", "opportunityID", "paymentTerm", "paymentType", "primaryQuote", "proposalProjectID", "purchaseOrderNumber", "quoteNumber", "quoteTemplateID", "shippingType", "shipToLocationID", "showEachTaxInGroup", "showTaxCategory", "soldToLocationID", "taxRegionID"],
20415
20776
  "resource_attachments": ["id", "attachDate", "attachedByContactID", "attachedByResourceID", "attachmentType", "contentType", "creatorType", "fileSize", "fullPath", "impersonatorCreatorResourceID", "opportunityID", "parentID", "publish", "resourceID", "title", "data", "parentType", "soapParentPropertyId", "isTaskAttachment"],
20777
+ "resource_daily_availabilities": ["id", "resourceID", "sundayAvailableHours", "mondayAvailableHours", "tuesdayAvailableHours", "wednesdayAvailableHours", "thursdayAvailableHours", "fridayAvailableHours", "saturdayAvailableHours", "weeklyBillableHoursGoal", "travelAvailability", "soapParentPropertyId"],
20416
20778
  "resource_role_queues": ["id", "queueID", "resourceID", "soapParentPropertyId"],
20417
20779
  "resource_roles": ["id", "departmentID", "isActive", "queueID", "resourceID", "roleID", "soapParentPropertyId"],
20418
20780
  "resource_skills": ["id", "resourceID", "skillDescription", "skillID", "skillLevel", "soapParentPropertyId"],
@@ -22771,6 +23133,11 @@ var MutationBase = class extends MetaBase {
22771
23133
  current = currentRecord ?? (parentId === void 0 ? await this.getGlobal(id, true, this.config.key === "knowledge_base_categories" || partialCollection !== void 0 ? opts.maxRetries : void 0, partialCollection?.checkedBaseUrl) : this.config.attachmentGet ? await this.getScopedModel(parentId, id, true) : await this.getScopedRaw(parentId, id, true));
22772
23134
  } catch (err) {
22773
23135
  if (err instanceof NotFoundError) {
23136
+ if (this.config.key === "inventory_items" && opts.expectedInventoryFacts !== void 0) {
23137
+ if (err.httpStatus === 200) inventoryFactsStale(operation);
23138
+ Object.assign(err, { notSent: true });
23139
+ throw err;
23140
+ }
22774
23141
  const reasons = EMPTY_REASON_STAMPS[this.config.key];
22775
23142
  const updateReason = reasons?.update ?? (partialCollection === void 0 ? void 0 : reasons?.get);
22776
23143
  checks.push({
@@ -24277,6 +24644,19 @@ var SIMPLE_RESOURCES = [
24277
24644
  helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
24278
24645
  opForms: { get: "global", create: "global", update: "global" }
24279
24646
  },
24647
+ {
24648
+ key: "organizational_resources",
24649
+ accessor: "organizationalResources",
24650
+ resourcePath: "/V1.0/OrganizationalResources",
24651
+ parentScopedPath: "/V1.0/OrganizationalLevelAssociations/{parentId}/Resources",
24652
+ parentPath: "/V1.0/OrganizationalLevelAssociations",
24653
+ parentField: "organizationalLevelAssociationID",
24654
+ deletable: false,
24655
+ udfCapable: false,
24656
+ ops: { query: true, queryAll: false, count: true, get: true, create: false, update: false, delete: false, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
24657
+ helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
24658
+ opForms: { get: "global" }
24659
+ },
24280
24660
  {
24281
24661
  key: "phases",
24282
24662
  accessor: "phases",
@@ -24486,6 +24866,19 @@ var SIMPLE_RESOURCES = [
24486
24866
  helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
24487
24867
  opForms: { get: "scoped", create: "scoped", delete: "scoped" }
24488
24868
  },
24869
+ {
24870
+ key: "resource_daily_availabilities",
24871
+ accessor: "resourceDailyAvailabilities",
24872
+ resourcePath: "/V1.0/ResourceDailyAvailabilities",
24873
+ parentScopedPath: "/V1.0/Resources/{parentId}/DailyAvailabilities",
24874
+ parentPath: "/V1.0/Resources",
24875
+ parentField: "resourceID",
24876
+ deletable: false,
24877
+ udfCapable: false,
24878
+ ops: { query: true, queryAll: false, count: true, get: true, create: false, update: false, delete: false, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
24879
+ helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
24880
+ opForms: { get: "global" }
24881
+ },
24489
24882
  {
24490
24883
  key: "resource_role_queues",
24491
24884
  accessor: "resourceRoleQueues",
@@ -25142,6 +25535,23 @@ var GenericResource = class extends BaseResource {
25142
25535
  this.requireOp("count");
25143
25536
  return this.countGlobal(params);
25144
25537
  }
25538
+ /** Read one native staff-association page; raw continuations are neither returned nor followed. */
25539
+ async listByParent(parentId) {
25540
+ if (!["organizational_resources", "resource_daily_availabilities"].includes(this.config.key)) throw new OperationNotSupportedError(this.config.key, "listByParent");
25541
+ const operation = `${this.config.key}.listByParent`;
25542
+ const parent = parseIdentifier(parentId, "parentId");
25543
+ if (!isAuditDecimalId(String(parent))) throw new AutotaskConfigError("parentId must be a non-negative signed 64-bit integer", { operation });
25544
+ const page = unwrapItems(await this.http.request({ method: "GET", path: this.scopedCollectionPath(parent), operation }), operation);
25545
+ const next = Object.hasOwn(page.pageDetails, "nextPageUrl") ? page.pageDetails.nextPageUrl : void 0;
25546
+ if (next !== null && (typeof next !== "string" || next.length === 0)) throw new AutotaskError("Expected explicit native page continuation metadata", { code: "INVALID_RESPONSE", category: "server", operation });
25547
+ const field = this.config.parentField;
25548
+ const hasInvalidParent = page.items.some((row) => {
25549
+ const value = isRecord2(row) && Object.hasOwn(row, field) ? row[field] : void 0;
25550
+ return typeof value !== "number" || !Number.isInteger(value) || value > 2147483647 || String(value) !== String(parent);
25551
+ });
25552
+ if (hasInvalidParent) throw new AutotaskError("Native page rows must bind the requested parent through the int32 model field", { code: "INVALID_RESPONSE", category: "server", operation });
25553
+ return { items: page.items, hasMore: next !== null };
25554
+ }
25145
25555
  async get(a, b = void 0, c = void 0) {
25146
25556
  this.requireOp("get");
25147
25557
  if (isIdentifier(b)) {
@@ -25160,6 +25570,7 @@ var GenericResource = class extends BaseResource {
25160
25570
  }
25161
25571
  async create(a, b = void 0, c = void 0) {
25162
25572
  this.requireOp("create");
25573
+ rejectInventoryFactsOption(isIdentifier(a) ? c : b, `${this.config.key}.create`);
25163
25574
  if (isIdentifier(a)) {
25164
25575
  if (this.config.opForms?.create === "global") throw new OperationNotSupportedError(this.config.key, "create");
25165
25576
  const parentId = this.config.key === "knowledge_base_articles" ? articleParent(a) : a;
@@ -25183,11 +25594,10 @@ var GenericResource = class extends BaseResource {
25183
25594
  }
25184
25595
  if (this.config.opForms?.create === "scoped") throw new OperationNotSupportedError(this.config.key, "create");
25185
25596
  if (this.config.key === "inventory_items") {
25186
- const body = admitInventoryItem(a, true);
25187
- const opts2 = snapshotInventoryItemOptions(b);
25597
+ const { body, opts: opts2 } = captureInventoryItemCall(a, b, true);
25188
25598
  const checkedBaseUrl = this.http.baseUrl;
25189
25599
  try {
25190
- await guardInventoryItemCreate(this.http, body, checkedBaseUrl, opts2.maxRetries);
25600
+ await guardInventoryItemCreate(this.http, body, checkedBaseUrl, opts2.maxRetries, opts2.expectedInventoryFacts);
25191
25601
  } catch (error) {
25192
25602
  if (error instanceof AutotaskError) Object.assign(error, { notSent: true });
25193
25603
  throw error;
@@ -25204,6 +25614,7 @@ var GenericResource = class extends BaseResource {
25204
25614
  }
25205
25615
  async update(a, b = void 0, c = void 0, d = void 0) {
25206
25616
  this.requireOp("update");
25617
+ rejectInventoryFactsOption(isIdentifier(b) ? d : c, `${this.config.key}.update`);
25207
25618
  if (isIdentifier(a) && isIdentifier(b)) {
25208
25619
  if (this.config.opForms?.update === "global") throw new OperationNotSupportedError(this.config.key, "update");
25209
25620
  const parentId = this.config.key === "knowledge_base_articles" ? articleParent(a) : a;
@@ -25226,16 +25637,15 @@ var GenericResource = class extends BaseResource {
25226
25637
  if (this.config.opForms?.update === "scoped") throw new OperationNotSupportedError(this.config.key, "update");
25227
25638
  if (this.config.key === "inventory_items") {
25228
25639
  const id2 = inventoryItemId(a);
25229
- const body = admitInventoryItem(b, false);
25230
- const opts2 = snapshotInventoryItemOptions(c);
25640
+ const { body, opts: opts2 } = captureInventoryItemCall(b, c, false);
25231
25641
  const checkedBaseUrl = this.http.baseUrl;
25232
- const checkCurrent = (current) => checkInventoryItemCurrent(this.http, body, current, id2, checkedBaseUrl, opts2.maxRetries);
25642
+ const checkCurrent = (current) => checkInventoryItemCurrent(this.http, body, current, id2, checkedBaseUrl, opts2.maxRetries, opts2.expectedInventoryFacts);
25233
25643
  if (opts2.dryRun === true) return this.runUpdateDryRun(id2, body, opts2, void 0, void 0, { checkCurrent, checkedBaseUrl });
25234
25644
  try {
25235
25645
  await checkCurrent(await this.getGlobal(id2, true, opts2.maxRetries, checkedBaseUrl));
25236
25646
  } catch (error) {
25237
25647
  if (error instanceof AutotaskError) Object.assign(error, { notSent: true });
25238
- throw error;
25648
+ rethrowInventoryGuardError(error, opts2.expectedInventoryFacts, "inventory_items.update");
25239
25649
  }
25240
25650
  return this.updateGlobal(id2, body, opts2, "PATCH", checkedBaseUrl);
25241
25651
  }
@@ -25269,6 +25679,7 @@ var GenericResource = class extends BaseResource {
25269
25679
  }
25270
25680
  async delete(a, b = void 0, c = void 0) {
25271
25681
  this.requireOp("delete");
25682
+ rejectInventoryFactsOption(isIdentifier(b) ? c : b, `${this.config.key}.delete`);
25272
25683
  if (isIdentifier(a) && isIdentifier(b)) {
25273
25684
  if (this.config.opForms?.delete === "global") throw new OperationNotSupportedError(this.config.key, "delete");
25274
25685
  const parentId = this.config.key === "knowledge_base_articles" ? articleParent(a) : a;
@@ -27261,6 +27672,13 @@ function validateFetchManyItems(items, cap, opName = "fetchByIds", capRef = `FET
27261
27672
  );
27262
27673
  continue;
27263
27674
  }
27675
+ if (hasNativeStaffCollection(resourceKey)) {
27676
+ const clientResource = `client.${camelKey(resourceKey)}`;
27677
+ problems.push(
27678
+ `${at}.resource: "${resourceKey}" is a parent-scoped child outside ${opName}; use ${clientResource}.get(id) or ${clientResource}.listByParent(parentId)`
27679
+ );
27680
+ continue;
27681
+ }
27264
27682
  const rel = RELATIONSHIP_MAP[resourceKey];
27265
27683
  const globalRead = resourceKey === "time_off_requests" || resourceKey === "knowledge_base_articles";
27266
27684
  if (rel !== void 0 && rel.parentScoped && !globalRead) {
@@ -31341,7 +31759,7 @@ async function wipHours(client, opts) {
31341
31759
  } else {
31342
31760
  const contractIds = positiveIds2(wipIn.map((e) => e["contractID"]));
31343
31761
  gate(chunks2(contractIds.length) + (contractIds.length > 0 ? 1 : 0), "before label reads", { contracts: contractIds.length });
31344
- const [contracts, types] = await readTasks(http, [
31762
+ const [contracts, types2] = await readTasks(http, [
31345
31763
  () => readChunks2(http, "/V1.0/Contracts", contractIds, ["contractType"]),
31346
31764
  async () => contractIds.length > 0 ? (await readPicklists(http, "/V1.0/Contracts", OP10)).get("contractType") : void 0
31347
31765
  ]);
@@ -31349,7 +31767,7 @@ async function wipHours(client, opts) {
31349
31767
  const bad = contractIds.filter((id) => typeof typeOf(id) !== "number");
31350
31768
  if (bad.length > 0) throw unresolved("contracts", bad);
31351
31769
  keyOfEntry = (e) => num(e["contractID"]) > 0 ? typeOf(num(e["contractID"])) : null;
31352
- for (const [id, label] of types ?? []) labels.set(id, { label });
31770
+ for (const [id, label] of types2 ?? []) labels.set(id, { label });
31353
31771
  }
31354
31772
  const approvalData = entries.some((e) => isApproved(e));
31355
31773
  const acc = () => ({ entries: 0, worked: 0, toBill: 0, approved: 0 });
@@ -31540,7 +31958,7 @@ async function nonChargeableWork(client, opts) {
31540
31958
  const contractIds = distinctIds(ncLines.map((x) => x.line["contractID"]), 1);
31541
31959
  const typed = v.groupBy === "contractType";
31542
31960
  gate(chunks3(contractIds.length) + (typed && contractIds.length > 0 ? 1 : 0) + (v.includeUnpostedTime ? 1 : 0), "before label reads", { contracts: contractIds.length });
31543
- const [contracts, types] = await readTasks(http, [
31961
+ const [contracts, types2] = await readTasks(http, [
31544
31962
  () => readChunks3(http, "/V1.0/Contracts", contractIds, [typed ? "contractType" : "contractName"]),
31545
31963
  async () => typed && contractIds.length > 0 ? (await readPicklists(http, "/V1.0/Contracts", OP11)).get("contractType") : void 0
31546
31964
  ]);
@@ -31551,7 +31969,7 @@ async function nonChargeableWork(client, opts) {
31551
31969
  if (!typed) return num(line["contractID"]);
31552
31970
  return isId(c["contractType"]) ? c["contractType"] : UNRESOLVED;
31553
31971
  };
31554
- if (typed) for (const [id, label] of types ?? []) labels.set(id, { label });
31972
+ if (typed) for (const [id, label] of types2 ?? []) labels.set(id, { label });
31555
31973
  else for (const [id, r] of contracts) labels.set(Number(id), typeof r["contractName"] === "string" ? { name: r["contractName"] } : {});
31556
31974
  }
31557
31975
  const cells = /* @__PURE__ */ new Map();
@@ -31729,8 +32147,37 @@ function bufferResult(buf) {
31729
32147
  };
31730
32148
  }
31731
32149
  var PUBLIC_INVOKE_OPTION_KEYS = INVOKE_OPTION_KEYS.filter((key) => key !== "mode");
31732
- function snapshotInvokeOptions(options, mode) {
32150
+ function snapshotInventoryInvokeOptions(options, operation, mode) {
32151
+ const { descriptors, expectedInventoryFacts: facts } = captureInventoryOptionDescriptors(options);
32152
+ if (Object.getOwnPropertySymbols(descriptors).length > 0) throw new AutotaskConfigError("inventory_items: invoke options must use string keys", { operation });
32153
+ const applyFlag = Object.hasOwn(descriptors, "dryRun") ? descriptors.dryRun : void 0;
32154
+ for (const key of PUBLIC_INVOKE_OPTION_KEYS) {
32155
+ if (key === "expectedInventoryFacts" || Object.hasOwn(descriptors, key)) continue;
32156
+ for (let owner = Object.getPrototypeOf(options); owner !== null && owner !== Object.prototype; owner = Object.getPrototypeOf(owner)) {
32157
+ const descriptor2 = Object.getOwnPropertyDescriptor(owner, key);
32158
+ if (descriptor2 !== void 0) {
32159
+ descriptors[key] = descriptor2;
32160
+ break;
32161
+ }
32162
+ }
32163
+ }
32164
+ const captured = /* @__PURE__ */ Object.create(null);
32165
+ for (const [key, descriptor2] of Object.entries(descriptors)) captured[key] = Object.hasOwn(descriptor2, "value") ? descriptor2.value : void 0;
32166
+ validateInvokeOptions(captured, operation);
32167
+ if (facts !== void 0 && Object.values(descriptors).some((descriptor2) => !Object.hasOwn(descriptor2, "value"))) throw new AutotaskConfigError("inventory_items: approved options must be data properties; accessors are unsupported", { operation });
32168
+ const applyRequested = applyFlag !== void 0 && Object.hasOwn(applyFlag, "value") && applyFlag.value === false;
32169
+ for (const [key, descriptor2] of Object.entries(descriptors)) {
32170
+ if (key === "expectedInventoryFacts" || Object.hasOwn(descriptor2, "value")) continue;
32171
+ captured[key] = descriptor2.get === void 0 ? void 0 : Reflect.apply(descriptor2.get, options, []);
32172
+ }
32173
+ captured.expectedInventoryFacts = facts;
32174
+ captured.dryRun = applyRequested || captured.dryRun !== false ? captured.dryRun : void 0;
32175
+ return Object.assign(captured, { mode });
32176
+ }
32177
+ function snapshotInvokeOptions(options, operation, mode) {
32178
+ if (operation === "inventory_items.create" || operation === "inventory_items.update") return snapshotInventoryInvokeOptions(options, operation, mode);
31733
32179
  if (!isRecord2(options)) throw new AutotaskConfigError("invoke: options must be an object");
32180
+ rejectInventoryFactsOption(options, operation);
31734
32181
  const applyFlag = Object.getOwnPropertyDescriptor(options, "dryRun");
31735
32182
  const applyRequested = applyFlag !== void 0 && Object.hasOwn(applyFlag, "value") && applyFlag.value === false;
31736
32183
  let confirmation;
@@ -31746,7 +32193,8 @@ function snapshotInvokeOptions(options, mode) {
31746
32193
  const dryRun = options.dryRun;
31747
32194
  const captured = snapshotFields(options, PUBLIC_INVOKE_OPTION_KEYS, {
31748
32195
  dryRun: applyRequested || dryRun !== false ? dryRun : void 0,
31749
- confirm
32196
+ confirm,
32197
+ expectedInventoryFacts: void 0
31750
32198
  });
31751
32199
  return Object.assign(/* @__PURE__ */ Object.create(null), captured, { mode });
31752
32200
  }
@@ -31762,6 +32210,7 @@ async function resolveRecord(operation) {
31762
32210
  }
31763
32211
  function governPreRequest(record, operation, opts) {
31764
32212
  validateInvokeOptions(opts, operation);
32213
+ if (opts.expectedInventoryFacts !== void 0) rejectInventoryFactsOption(opts, operation);
31765
32214
  const mode = opts.mode;
31766
32215
  if (mode !== void 0 && MODE_BY_EFFECT[record.effect] !== mode) {
31767
32216
  throw new AutotaskConfigError(crossModeRefusal(operation, record.effect, mode), { operation });
@@ -31885,6 +32334,7 @@ var BAG_RIDING_ARGS = {
31885
32334
  function buildMutationOpts(opts, isWrite) {
31886
32335
  const dryRun = isWrite ? opts.dryRun !== false : false;
31887
32336
  const mutationOpts = { dryRun };
32337
+ if (opts.expectedInventoryFacts !== void 0) mutationOpts.expectedInventoryFacts = opts.expectedInventoryFacts;
31888
32338
  if (isWrite && opts.lastModifiedDate !== void 0) {
31889
32339
  mutationOpts.lastModifiedDate = opts.lastModifiedDate;
31890
32340
  }
@@ -31986,6 +32436,10 @@ async function runPreRequestPass(ctx) {
31986
32436
  }
31987
32437
  async function prepareInvocation(client, operation, argsIn, opts, streaming = false) {
31988
32438
  const record = await resolveRecord(operation);
32439
+ if (operation === "inventory_items.create" || operation === "inventory_items.update") {
32440
+ governPreRequest(record, operation, opts);
32441
+ snapshotInventoryMutationOptions(opts);
32442
+ }
31989
32443
  const resolvedArgs = resolveDispatchArgs(record, argsIn);
31990
32444
  const boundedQuery = record.kind === "primitive" && record.operation === "query";
31991
32445
  const countedQuery = record.kind === "primitive" && record.operation === "count";
@@ -32027,14 +32481,16 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
32027
32481
  return scopeNote !== void 0 && finished !== null && typeof finished === "object" ? { ...finished, scopeNote } : finished;
32028
32482
  }
32029
32483
  async function invoke(client, operation, args = [], opts = {}) {
32030
- return invokeMode(client, operation, args, snapshotInvokeOptions(opts));
32484
+ const capturedArgs = captureInventoryInvocationArgs(operation, args);
32485
+ const capturedOpts = snapshotInvokeOptions(opts, operation);
32486
+ return invokeMode(client, operation, capturedArgs(capturedOpts.expectedInventoryFacts === void 0), capturedOpts);
32031
32487
  }
32032
32488
  async function invokeRead(client, operation, args = [], opts = {}) {
32033
- return invokeMode(client, operation, args, snapshotInvokeOptions(opts, "read"));
32489
+ return invokeMode(client, operation, args, snapshotInvokeOptions(opts, operation, "read"));
32034
32490
  }
32035
32491
  async function invokeReadPages(client, operation, args, onPage, opts = {}) {
32036
32492
  if (typeof onPage !== "function") throw new AutotaskConfigError("invokeReadPages: onPage must be a function", { operation });
32037
- const prepared = await prepareInvocation(client, operation, args, snapshotInvokeOptions(opts, "read"), true);
32493
+ const prepared = await prepareInvocation(client, operation, args, snapshotInvokeOptions(opts, operation, "read"), true);
32038
32494
  prepared.pageSession.guard();
32039
32495
  const consume = prepared.method;
32040
32496
  const result = await consume.call(prepared.holder, prepared.callArgs[0], onPage);
@@ -32042,10 +32498,12 @@ async function invokeReadPages(client, operation, args, onPage, opts = {}) {
32042
32498
  return prepared.scopeNote === void 0 ? result : { ...result, scopeNote: prepared.scopeNote };
32043
32499
  }
32044
32500
  async function invokeWrite(client, operation, args = [], opts = {}) {
32045
- return invokeMode(client, operation, args, snapshotInvokeOptions(opts, "write"));
32501
+ const capturedArgs = captureInventoryInvocationArgs(operation, args);
32502
+ const capturedOpts = snapshotInvokeOptions(opts, operation, "write");
32503
+ return invokeMode(client, operation, capturedArgs(capturedOpts.expectedInventoryFacts === void 0), capturedOpts);
32046
32504
  }
32047
32505
  async function invokeDelete(client, operation, args = [], opts = {}) {
32048
- return invokeMode(client, operation, args, snapshotInvokeOptions(opts, "delete"));
32506
+ return invokeMode(client, operation, args, snapshotInvokeOptions(opts, operation, "delete"));
32049
32507
  }
32050
32508
 
32051
32509
  // src/resources/special/_shared/compositeParts.ts
@@ -32204,4 +32662,4 @@ var ContractsResource = class extends GenericResource {
32204
32662
  }
32205
32663
  };
32206
32664
 
32207
- export { AGGREGATE_DATE_BUCKETS, AGGREGATE_DEFAULT_LIMIT, AGGREGATE_DEFAULT_TOP, AGGREGATE_TOP_MAX, AutotaskAbortError, AutotaskConfigError, AutotaskError, AutotaskNetworkError, AutotaskTimeoutError, CREATE_BLOCKER_KINDS, CREDENTIAL_ENV_LOAD_ACTION, CREDENTIAL_SHAPE_POINTER, CompaniesResource, ConfirmationRequiredError, ConflictError, ContractsResource, DEFAULT_ZONE, DeleteBoundaryError, EXPAND_RESOURCE_NAMES_MAX_IDS, EmptyResponseError, FETCH_BY_IDS_CHUNK_SIZE, FETCH_BY_IDS_MAX_ITEMS, FIELD_CACHE_KINDS, FIELD_CATALOG_HONESTY_NOTE, GenericResource, HostPolicyDeniedError, HttpClient, INVOKE_OPTION_KEYS, InvoicesResource, MAX_FIELD_CATALOG_WIRE, MIN_FIELD_CATALOG_MAX_BYTES, MIN_PREFIX_SUMMARY_LENGTH, MaintenanceError, MarkerUnsafeIdError, MoveRefusedError, NotFoundError, OperationNotSupportedError, PARAMS_BAG_KEYS, PICKLIST_VALUE_NOT_SERVED_NOTE, PaginationLimitError, QueryTooLongError, RELATIONSHIP_MAP, RateLimitError, RecoveryTruncatedError, ResolutionError, ResponseRejectedError, SIMPLE_RESOURCES, ScopeRequiredError, StaleObjectError, TICKET_LABEL_FIELDS, TimeEntriesResource, TtlCache, UI_LINK_ENTITIES, UNSCOPED_WALK_THRESHOLD, UnexpectedContentTypeError, WORKFLOW_RESOURCES, ZONES, addLabelSibling, addNameSibling, aggregate, arAging, buildDryRunResult, buildQueryRequest, buildReadCache, buildUiLink, cachedRecordGet, clientOf, compositePart, compositePartLimit, createGuidance, createNamePlan, credentialShapeProblem, credentialValueSummary, cursorToPath, dateBucketLabel, effectiveRequiredFields, errorFromStatus, expandResourceNames, fetchByIds, fieldCatalog, foldFlattenedOpts, formatVendorDetail, invoke, invokeDelete, invokeRead, invokeReadPages, invokeWrite, isAutotaskError, isClosedStatus, isDateYMD, isDeterministicVendor500, isRecord2 as isRecord, joinedCompositePart, mergeDetails, mergePartialBody, needsConfirmation, nextActionFor, nonChargeableWork, notPersistedFields, openStatusFilter, openTicketsOfPart, parseIdentifier, parseVendorErrors, portfolioMargin, queryRows, readTasks, recurringRevenue, refuse2 as refuse, relationshipMap, resolveAny, resolveCompositeNames, resolveConfig, resolveCredentials, resolveLineOfBusinessChain, resolveStaff, resolveTicketStatusSemantics, revenueRollup, runBounded, runMove, runWithSignal, sanitiseResult, searchAcrossResources, suspendCompanyIndex, uiLink, uiLinkFor, unknownKeysRefusal, unwrapItem, unwrapItems, unwrapOperation, validateDispatchArgs, validateInvokeOptions, validateParamsBag, vendorId, wipHours, zoneUrl };
32665
+ export { AGGREGATE_DATE_BUCKETS, AGGREGATE_DEFAULT_LIMIT, AGGREGATE_DEFAULT_TOP, AGGREGATE_TOP_MAX, AutotaskAbortError, AutotaskConfigError, AutotaskError, AutotaskNetworkError, AutotaskTimeoutError, CREATE_BLOCKER_KINDS, CREDENTIAL_ENV_LOAD_ACTION, CREDENTIAL_SHAPE_POINTER, CompaniesResource, ConfirmationRequiredError, ConflictError, ContractsResource, DEFAULT_ZONE, DeleteBoundaryError, EXPAND_RESOURCE_NAMES_MAX_IDS, EmptyResponseError, FETCH_BY_IDS_CHUNK_SIZE, FETCH_BY_IDS_MAX_ITEMS, FIELD_CACHE_KINDS, FIELD_CATALOG_HONESTY_NOTE, GenericResource, HostPolicyDeniedError, HttpClient, INVOKE_OPTION_KEYS, InvoicesResource, MAX_FIELD_CATALOG_WIRE, MIN_FIELD_CATALOG_MAX_BYTES, MIN_PREFIX_SUMMARY_LENGTH, MaintenanceError, MarkerUnsafeIdError, MoveRefusedError, NotFoundError, OperationNotSupportedError, PARAMS_BAG_KEYS, PICKLIST_VALUE_NOT_SERVED_NOTE, PaginationLimitError, QueryTooLongError, RELATIONSHIP_MAP, RateLimitError, RecoveryTruncatedError, ResolutionError, ResponseRejectedError, SIMPLE_RESOURCES, ScopeRequiredError, StaleObjectError, TICKET_LABEL_FIELDS, TimeEntriesResource, TtlCache, UI_LINK_ENTITIES, UNSCOPED_WALK_THRESHOLD, UnexpectedContentTypeError, WORKFLOW_RESOURCES, ZONES, addLabelSibling, addNameSibling, aggregate, arAging, buildDryRunResult, buildQueryRequest, buildReadCache, buildUiLink, cachedRecordGet, clientOf, compositePart, compositePartLimit, createGuidance, createNamePlan, credentialShapeProblem, credentialValueSummary, cursorToPath, dateBucketLabel, effectiveRequiredFields, errorFromStatus, expandResourceNames, fetchByIds, fieldCatalog, foldFlattenedOpts, formatVendorDetail, inventoryItemGuardFacts, invoke, invokeDelete, invokeRead, invokeReadPages, invokeWrite, isAutotaskError, isClosedStatus, isDateYMD, isDeterministicVendor500, isRecord2 as isRecord, joinedCompositePart, mergeDetails, mergePartialBody, needsConfirmation, nextActionFor, nonChargeableWork, notPersistedFields, openStatusFilter, openTicketsOfPart, parseIdentifier, parseVendorErrors, portfolioMargin, queryRows, readTasks, recurringRevenue, refuse2 as refuse, rejectInventoryFactsOption, relationshipMap, resolveAny, resolveCompositeNames, resolveConfig, resolveCredentials, resolveLineOfBusinessChain, resolveStaff, resolveTicketStatusSemantics, revenueRollup, runBounded, runMove, runWithSignal, sanitiseResult, searchAcrossResources, suspendCompanyIndex, uiLink, uiLinkFor, unknownKeysRefusal, unwrapItem, unwrapItems, unwrapOperation, validateDispatchArgs, validateInvokeOptions, validateParamsBag, vendorId, wipHours, zoneUrl };