node-autotask 0.91.0 → 0.92.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/MCP_TOOL_CATALOG.json +152 -9
- package/README.md +1 -1
- package/capabilities.json +575 -28
- package/dist/capabilities-data.js +574 -27
- package/dist/capabilities.cjs +4 -4
- package/dist/capabilities.js +1 -1
- package/dist/{chunk-43ADHLZJ.js → chunk-2MC3LDZU.js} +3 -3
- package/dist/{chunk-2GP7W6QB.js → chunk-4BICEQ4S.js} +841 -295
- package/dist/{chunk-Y2KXGSWM.js → chunk-C7KZ7PB3.js} +3 -2
- package/dist/{chunk-5PUHGPKG.cjs → chunk-JY6BQUPO.cjs} +202 -200
- package/dist/{chunk-RXXITZH4.cjs → chunk-LYAHXYZR.cjs} +847 -299
- package/dist/{chunk-YFC5VAKK.cjs → chunk-QC45KFQQ.cjs} +31 -30
- package/dist/{chunk-WAHRZDV4.js → chunk-QVDXIXY4.js} +4 -2
- package/dist/{chunk-KRYDLTY3.cjs → chunk-QXJQIZCT.cjs} +3 -3
- package/dist/{index-Dy92Xbpv.d.cts → index-B0p5O-2e.d.cts} +70 -2
- package/dist/{index-Dy92Xbpv.d.ts → index-B0p5O-2e.d.ts} +70 -2
- package/dist/{index-C3jXvpXZ.d.ts → index-it9IqLsM.d.ts} +13 -5
- package/dist/{index-BfGOllfY.d.cts → index-opnSlg90.d.cts} +13 -5
- package/dist/index.cjs +89 -85
- package/dist/index.d.cts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +5 -5
- package/dist/operations/index.cjs +51 -51
- package/dist/operations/index.d.cts +9 -4
- package/dist/operations/index.d.ts +9 -4
- package/dist/operations/index.js +2 -2
- package/dist/pool.cjs +12 -12
- package/dist/pool.d.cts +1 -1
- package/dist/pool.d.ts +1 -1
- package/dist/pool.js +4 -4
- package/dist/resources/index.cjs +27 -27
- package/dist/resources/index.d.cts +2 -2
- package/dist/resources/index.d.ts +2 -2
- package/dist/resources/index.js +3 -3
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/docs/API.md +39 -2
- package/examples/mcp/manifest.ts +1 -1
- package/examples/mcp/tools-mode.ts +15 -6
- package/examples/mcp/tools-read.ts +8 -2
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkQXJQIZCT_cjs = require('./chunk-QXJQIZCT.cjs');
|
|
4
4
|
var chunkCM5O672I_cjs = require('./chunk-CM5O672I.cjs');
|
|
5
5
|
var crypto = require('crypto');
|
|
6
6
|
var async_hooks = require('async_hooks');
|
|
7
|
+
var util = require('util');
|
|
7
8
|
|
|
8
9
|
// src/errors/base.ts
|
|
9
10
|
function nextActionFor(code, opts = {}) {
|
|
@@ -1442,6 +1443,7 @@ function resolveConfig(config) {
|
|
|
1442
1443
|
}
|
|
1443
1444
|
|
|
1444
1445
|
// src/http/types.ts
|
|
1446
|
+
var INVENTORY_APPROVAL_PRODUCT_ID = /* @__PURE__ */ Symbol("inventoryApprovalProductId");
|
|
1445
1447
|
var IDEMPOTENT_METHODS = ["GET", "PUT", "DELETE"];
|
|
1446
1448
|
var AUDIT_DECIMAL_ID = /^(?:0|[1-9]\d{0,18})$/;
|
|
1447
1449
|
var MAX_AUDIT_ID = "9223372036854775807";
|
|
@@ -1588,6 +1590,11 @@ function countUdfConditions(conditions) {
|
|
|
1588
1590
|
}
|
|
1589
1591
|
return n;
|
|
1590
1592
|
}
|
|
1593
|
+
function assertSupportedUdfConditions(conditions, operation) {
|
|
1594
|
+
if (operation.startsWith("inventory_items.") && conditions !== void 0 && countUdfConditions(conditions) > 0) {
|
|
1595
|
+
throw new AutotaskConfigError("InventoryItems has no record UDFs. Filter on its documented fields.", { operation });
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1591
1598
|
function serializeFilter(filter) {
|
|
1592
1599
|
return JSON.stringify(filter);
|
|
1593
1600
|
}
|
|
@@ -10967,6 +10974,65 @@ var RELATIONSHIP_MAP = {
|
|
|
10967
10974
|
"deleteBoundary": null,
|
|
10968
10975
|
"markerField": null
|
|
10969
10976
|
},
|
|
10977
|
+
"inventory_items": {
|
|
10978
|
+
"resource": "inventory_items",
|
|
10979
|
+
"apiEntity": "InventoryItem",
|
|
10980
|
+
"kind": "entity",
|
|
10981
|
+
"path": "InventoryItems",
|
|
10982
|
+
"parentScoped": false,
|
|
10983
|
+
"tier": "extended",
|
|
10984
|
+
"workflowResource": false,
|
|
10985
|
+
"group": "A",
|
|
10986
|
+
"parent": null,
|
|
10987
|
+
"children": [],
|
|
10988
|
+
"naturalKeys": {
|
|
10989
|
+
"hasSearch": false,
|
|
10990
|
+
"searchCovers": null,
|
|
10991
|
+
"findBy": []
|
|
10992
|
+
},
|
|
10993
|
+
"blindSurfaces": null,
|
|
10994
|
+
"zoneFacts": {
|
|
10995
|
+
"createRequiredSet": [
|
|
10996
|
+
"inventoryLocationID",
|
|
10997
|
+
"productID",
|
|
10998
|
+
"quantityMinimum",
|
|
10999
|
+
"quantityMaximum",
|
|
11000
|
+
"quantityOnHand"
|
|
11001
|
+
],
|
|
11002
|
+
"createGuidance": {
|
|
11003
|
+
"createOp": "inventory_items.create",
|
|
11004
|
+
"parentScoped": false,
|
|
11005
|
+
"liveProvenPrefix": [],
|
|
11006
|
+
"unproven": true,
|
|
11007
|
+
"blocker": {
|
|
11008
|
+
"kind": "unknown",
|
|
11009
|
+
"message": "Inventory access, an active location, a visible product and a unique product-location pair are required.",
|
|
11010
|
+
"remedy": "Read product and location metadata, supply the required quantities and preview before apply.",
|
|
11011
|
+
"requires": {
|
|
11012
|
+
"allOf": [
|
|
11013
|
+
"inventoryLocationID",
|
|
11014
|
+
"productID",
|
|
11015
|
+
"quantityMinimum",
|
|
11016
|
+
"quantityMaximum",
|
|
11017
|
+
"quantityOnHand"
|
|
11018
|
+
]
|
|
11019
|
+
}
|
|
11020
|
+
},
|
|
11021
|
+
"vendorEvidence": [
|
|
11022
|
+
"https://www.autotask.net/help/developerhelp/Content/APIs/REST/Entities/InventoryItemsEntity.htm"
|
|
11023
|
+
],
|
|
11024
|
+
"deleteBoundary": {
|
|
11025
|
+
"available": false,
|
|
11026
|
+
"note": "The specification defines no public DELETE for InventoryItems."
|
|
11027
|
+
}
|
|
11028
|
+
}
|
|
11029
|
+
},
|
|
11030
|
+
"deleteBoundary": {
|
|
11031
|
+
"note": "The specification defines no public DELETE for InventoryItems. A created item cannot be removed through that API.",
|
|
11032
|
+
"proof": "spec-derived"
|
|
11033
|
+
},
|
|
11034
|
+
"markerField": null
|
|
11035
|
+
},
|
|
10970
11036
|
"inventory_locations": {
|
|
10971
11037
|
"resource": "inventory_locations",
|
|
10972
11038
|
"apiEntity": "InventoryLocation",
|
|
@@ -11173,6 +11239,7 @@ var DELETE_BOUNDARY_NOTES = {
|
|
|
11173
11239
|
"user_defined_field_list_items": "the vendor defines no DELETE for user_defined_field_list_items (spec-derived: the vendored api-docs.json defines no DELETE on the standalone or parent-scoped ListItems paths) \u2014 a picklist value cannot be deleted through the API; deactivation is via isActive (vendor soft-removal); hard cleanup is UI-only.",
|
|
11174
11240
|
"task_notes": "The vendor defines no DELETE for task_notes (spec-derived); a created task note cannot be removed through the public API.",
|
|
11175
11241
|
"time_off_requests": "The vendor defines no DELETE for time-off requests; cancel through time_off_requests.update using the Canceled status from exposed field metadata. Cancellation is leave management, not timesheet unposting.",
|
|
11242
|
+
"inventory_items": "The specification defines no public DELETE for InventoryItems. A created item cannot be removed through that API.",
|
|
11176
11243
|
"inventory_locations": "The vendor defines no DELETE for inventory_locations (spec-derived); a created inventory location cannot be removed through the public API."
|
|
11177
11244
|
};
|
|
11178
11245
|
var RESPONSE_DRIFT_MARKERS = {
|
|
@@ -14100,6 +14167,34 @@ var CREATE_GUIDANCE = {
|
|
|
14100
14167
|
"note": null
|
|
14101
14168
|
}
|
|
14102
14169
|
},
|
|
14170
|
+
{
|
|
14171
|
+
"resource": "inventory_items",
|
|
14172
|
+
"createOp": "inventory_items.create",
|
|
14173
|
+
"parentScoped": false,
|
|
14174
|
+
"liveProvenPrefix": [],
|
|
14175
|
+
"unproven": true,
|
|
14176
|
+
"blocker": {
|
|
14177
|
+
"kind": "unknown",
|
|
14178
|
+
"message": "Inventory access, an active location, a visible product and a unique product-location pair are required.",
|
|
14179
|
+
"remedy": "Read product and location metadata, supply the required quantities and preview before apply.",
|
|
14180
|
+
"requires": {
|
|
14181
|
+
"allOf": [
|
|
14182
|
+
"inventoryLocationID",
|
|
14183
|
+
"productID",
|
|
14184
|
+
"quantityMinimum",
|
|
14185
|
+
"quantityMaximum",
|
|
14186
|
+
"quantityOnHand"
|
|
14187
|
+
]
|
|
14188
|
+
}
|
|
14189
|
+
},
|
|
14190
|
+
"vendorEvidence": [
|
|
14191
|
+
"https://www.autotask.net/help/developerhelp/Content/APIs/REST/Entities/InventoryItemsEntity.htm"
|
|
14192
|
+
],
|
|
14193
|
+
"deleteBoundary": {
|
|
14194
|
+
"available": false,
|
|
14195
|
+
"note": "The specification defines no public DELETE for InventoryItems."
|
|
14196
|
+
}
|
|
14197
|
+
},
|
|
14103
14198
|
{
|
|
14104
14199
|
"resource": "inventory_locations",
|
|
14105
14200
|
"createOp": "inventory_locations.create",
|
|
@@ -15705,7 +15800,7 @@ var CREATE_GUIDANCE = {
|
|
|
15705
15800
|
}
|
|
15706
15801
|
],
|
|
15707
15802
|
"counts": {
|
|
15708
|
-
"total":
|
|
15803
|
+
"total": 118,
|
|
15709
15804
|
"byKind": {
|
|
15710
15805
|
"ok": 41,
|
|
15711
15806
|
"blind-reference": 16,
|
|
@@ -15715,7 +15810,7 @@ var CREATE_GUIDANCE = {
|
|
|
15715
15810
|
"resource-role-pair": 2,
|
|
15716
15811
|
"delete-absent": 0,
|
|
15717
15812
|
"non-mutable": 0,
|
|
15718
|
-
"unknown":
|
|
15813
|
+
"unknown": 42
|
|
15719
15814
|
}
|
|
15720
15815
|
}
|
|
15721
15816
|
};
|
|
@@ -16495,6 +16590,10 @@ var UNTRUSTED_FIELDS_BY_RESOURCE = {
|
|
|
16495
16590
|
"referenceLink",
|
|
16496
16591
|
"title"
|
|
16497
16592
|
],
|
|
16593
|
+
"inventory_items": [
|
|
16594
|
+
"bin",
|
|
16595
|
+
"referenceNumber"
|
|
16596
|
+
],
|
|
16498
16597
|
"inventory_locations": [
|
|
16499
16598
|
"locationName"
|
|
16500
16599
|
],
|
|
@@ -16966,9 +17065,9 @@ function isKnowledgeBaseRootResource(resource) {
|
|
|
16966
17065
|
return resource === "knowledge_base_categories" || resource === "knowledge_base_articles";
|
|
16967
17066
|
}
|
|
16968
17067
|
function isExactRecordResource(resource) {
|
|
16969
|
-
return resource === "inventory_locations" || resource === "internal_locations" || resource === "shipping_types" || isKnowledgeBaseRootResource(resource);
|
|
17068
|
+
return resource === "inventory_locations" || resource === "inventory_items" || resource === "internal_locations" || resource === "shipping_types" || isKnowledgeBaseRootResource(resource);
|
|
16970
17069
|
}
|
|
16971
|
-
var EXACT_RECORD_PATH = /^\/v1\.0\/(?:InventoryLocations|InternalLocations|ShippingTypes|KnowledgeBaseArticles|KnowledgeBaseCategories(?:\/\d+\/KnowledgeBaseArticles)?)(?:\/(query(?:\/(?:next|previous|count))?|\d+))?\/?$/i;
|
|
17070
|
+
var EXACT_RECORD_PATH = /^\/v1\.0\/(?:InventoryLocations|InventoryItems|InternalLocations|ShippingTypes|KnowledgeBaseArticles|KnowledgeBaseCategories(?:\/\d+\/KnowledgeBaseArticles)?)(?:\/(query(?:\/(?:next|previous|count))?|\d+))?\/?$/i;
|
|
16972
17071
|
function exactRecordResponseTarget(path, method, operation) {
|
|
16973
17072
|
const match = EXACT_RECORD_PATH.exec(path);
|
|
16974
17073
|
if (match === null) return void 0;
|
|
@@ -17140,7 +17239,7 @@ function attachEmptyReasonDetails(err) {
|
|
|
17140
17239
|
} : {
|
|
17141
17240
|
surface,
|
|
17142
17241
|
kind: "not-found",
|
|
17143
|
-
note: isDeletedAuditRead(surface) ? "No audit log entry at this ID was visible to this API user." : resource === "internal_locations" || resource === "shipping_types" ? "No record at this ID was visible to this API user." : resource === "knowledge_base_articles" ? "No published article at this ID was visible to this API user." : `no ${resource} record exists at this id (a miss is the data, not an error condition)`,
|
|
17242
|
+
note: isDeletedAuditRead(surface) ? "No audit log entry at this ID was visible to this API user." : resource === "internal_locations" || resource === "shipping_types" || resource === "inventory_items" ? "No record at this ID was visible to this API user." : resource === "knowledge_base_articles" ? "No published article at this ID was visible to this API user." : `no ${resource} record exists at this id (a miss is the data, not an error condition)`,
|
|
17144
17243
|
authority: `${resource}.query`,
|
|
17145
17244
|
remedy: `query the ${resource} collection (a bounded queryBounded walk) or verify the id from the authority surface \u2014 do not retry the same get`
|
|
17146
17245
|
};
|
|
@@ -17706,7 +17805,8 @@ var HttpClient = class {
|
|
|
17706
17805
|
}
|
|
17707
17806
|
let parsed;
|
|
17708
17807
|
try {
|
|
17709
|
-
|
|
17808
|
+
const decodeTarget = opts[INVENTORY_APPROVAL_PRODUCT_ID] === true ? "item" : s.recordTarget;
|
|
17809
|
+
parsed = decodeResponseJson(text, s.auditTarget, decodeTarget, decodeURIComponent(s.opts.path));
|
|
17710
17810
|
} catch {
|
|
17711
17811
|
return this.handleNonJson2xx(s, res, status, text);
|
|
17712
17812
|
}
|
|
@@ -18362,6 +18462,502 @@ function slimCompany(row) {
|
|
|
18362
18462
|
return { id: row.id, companyName: row.companyName, isActive: row.isActive, parentCompanyID: row.parentCompanyID };
|
|
18363
18463
|
}
|
|
18364
18464
|
|
|
18465
|
+
// src/resources/base/helpers.ts
|
|
18466
|
+
function describeResponseShape(body) {
|
|
18467
|
+
if (body === null) return "null";
|
|
18468
|
+
if (Array.isArray(body)) return `array(len=${body.length})`;
|
|
18469
|
+
if (typeof body !== "object") return typeof body;
|
|
18470
|
+
const rec = body;
|
|
18471
|
+
const keys = Object.keys(rec).sort();
|
|
18472
|
+
const typeOf = (v) => v === null ? "null" : Array.isArray(v) ? "array" : typeof v;
|
|
18473
|
+
const parts = keys.slice(0, 16).map((k) => `${k}:${typeOf(rec[k])}`);
|
|
18474
|
+
const more = keys.length > 16 ? `, +${keys.length - 16} more` : "";
|
|
18475
|
+
return `{ ${parts.join(", ")}${more} }`;
|
|
18476
|
+
}
|
|
18477
|
+
function defaultMarkerToken(data) {
|
|
18478
|
+
for (const field of ["name", "title"]) {
|
|
18479
|
+
const v = data[field];
|
|
18480
|
+
if (typeof v === "string" && v.trim() !== "") return v.trim();
|
|
18481
|
+
}
|
|
18482
|
+
return null;
|
|
18483
|
+
}
|
|
18484
|
+
var CONTEXT_ABSENT_MARKER = "#context-absent";
|
|
18485
|
+
function contextAbsentKey(path) {
|
|
18486
|
+
return path + "\0context-absent";
|
|
18487
|
+
}
|
|
18488
|
+
function noteCharsTruncationMarker(charsRemoved) {
|
|
18489
|
+
return `\u2026 [+${charsRemoved} chars truncated]`;
|
|
18490
|
+
}
|
|
18491
|
+
function truncateNoteChars(items, cap, fields) {
|
|
18492
|
+
let truncated = 0;
|
|
18493
|
+
const out = items.map((item) => {
|
|
18494
|
+
if (!isRecord2(item)) return item;
|
|
18495
|
+
let changed = false;
|
|
18496
|
+
const copy = { ...item };
|
|
18497
|
+
for (const field of fields) {
|
|
18498
|
+
const v = copy[field];
|
|
18499
|
+
if (typeof v === "string" && v !== chunkCM5O672I_cjs.REDACTED && v.length > cap) {
|
|
18500
|
+
const end = cap > 0 && (v.charCodeAt(cap - 1) & 64512) === 55296 ? cap - 1 : cap;
|
|
18501
|
+
copy[field] = v.slice(0, end) + noteCharsTruncationMarker(v.length - end);
|
|
18502
|
+
truncated += 1;
|
|
18503
|
+
changed = true;
|
|
18504
|
+
}
|
|
18505
|
+
}
|
|
18506
|
+
return changed ? copy : item;
|
|
18507
|
+
});
|
|
18508
|
+
return [out, truncated];
|
|
18509
|
+
}
|
|
18510
|
+
function blindEmptyReason(stamp) {
|
|
18511
|
+
return {
|
|
18512
|
+
surface: stamp.surface,
|
|
18513
|
+
kind: "blind-surface",
|
|
18514
|
+
note: stamp.note,
|
|
18515
|
+
authority: stamp.authority,
|
|
18516
|
+
remedy: "the note is the remedy \u2014 the authority op answers for a record"
|
|
18517
|
+
};
|
|
18518
|
+
}
|
|
18519
|
+
function attachUpdateTargetMissReason(err, key) {
|
|
18520
|
+
const pinned = EMPTY_REASON_STAMPS[key]?.update;
|
|
18521
|
+
if (pinned === void 0) return;
|
|
18522
|
+
err.details = { ...err.details ?? {}, emptyReason: pinned };
|
|
18523
|
+
}
|
|
18524
|
+
function buildDryRunResult(spec, policy) {
|
|
18525
|
+
if (spec.operation === "") {
|
|
18526
|
+
throw new AutotaskConfigError("dry-run: the operation name is required");
|
|
18527
|
+
}
|
|
18528
|
+
const wouldApply = spec.checks.every((check) => check.ok);
|
|
18529
|
+
const resource = spec.operation.split(".")[0] ?? spec.operation;
|
|
18530
|
+
const diffPart = spec.diff !== void 0 ? {
|
|
18531
|
+
diff: spec.diff.map((entry) => {
|
|
18532
|
+
if (entry.to === void 0) return entry;
|
|
18533
|
+
const to = isRedactedFieldName(entry.field, policy) ? chunkCM5O672I_cjs.REDACTED : redactResponseBody(entry.to, policy);
|
|
18534
|
+
return { ...entry, to };
|
|
18535
|
+
})
|
|
18536
|
+
} : {};
|
|
18537
|
+
const dataPart = spec.data !== void 0 ? { data: redactResponseBody(spec.data, policy) } : {};
|
|
18538
|
+
return {
|
|
18539
|
+
operation: spec.operation,
|
|
18540
|
+
wouldApply,
|
|
18541
|
+
target: { resource, ids: spec.ids },
|
|
18542
|
+
request: { method: spec.method, path: spec.path },
|
|
18543
|
+
...diffPart,
|
|
18544
|
+
checks: spec.checks,
|
|
18545
|
+
impact: spec.impact,
|
|
18546
|
+
simulated: true,
|
|
18547
|
+
warnings: spec.warnings ?? [],
|
|
18548
|
+
...dataPart,
|
|
18549
|
+
...spec.emptyReason !== void 0 ? { emptyReason: spec.emptyReason } : {}
|
|
18550
|
+
};
|
|
18551
|
+
}
|
|
18552
|
+
function computeFieldDiff(current, data) {
|
|
18553
|
+
const out = [];
|
|
18554
|
+
for (const [field, to] of Object.entries(data)) {
|
|
18555
|
+
if (field === "id" || to === void 0) continue;
|
|
18556
|
+
const from = Object.hasOwn(current, field) ? current[field] : void 0;
|
|
18557
|
+
if (from !== void 0 && JSON.stringify(from) === JSON.stringify(to)) continue;
|
|
18558
|
+
out.push({ field, from: from === void 0 ? null : from, to });
|
|
18559
|
+
}
|
|
18560
|
+
return out;
|
|
18561
|
+
}
|
|
18562
|
+
function mergePartialBody(current, data) {
|
|
18563
|
+
const merged = { ...current };
|
|
18564
|
+
for (const [key, value] of Object.entries(data)) {
|
|
18565
|
+
if (value === void 0) continue;
|
|
18566
|
+
merged[key] = value;
|
|
18567
|
+
}
|
|
18568
|
+
return merged;
|
|
18569
|
+
}
|
|
18570
|
+
function snapshotMutationOptions(options) {
|
|
18571
|
+
const { dryRun, lastModifiedDate, maxRetries, raw, verifyPersisted } = options ?? {};
|
|
18572
|
+
if (dryRun !== void 0 && typeof dryRun !== "boolean") {
|
|
18573
|
+
throw new AutotaskConfigError("dryRun must be a boolean");
|
|
18574
|
+
}
|
|
18575
|
+
return { dryRun, lastModifiedDate, maxRetries, raw, verifyPersisted };
|
|
18576
|
+
}
|
|
18577
|
+
function normalizeUdfInput(value) {
|
|
18578
|
+
if (Array.isArray(value)) {
|
|
18579
|
+
return value.map((entry) => {
|
|
18580
|
+
if (!isRecord2(entry) || typeof entry.name !== "string" || entry.name === "") {
|
|
18581
|
+
throw new AutotaskConfigError("userDefinedFields array entries must be { name, value } objects");
|
|
18582
|
+
}
|
|
18583
|
+
return { name: entry.name, value: entry.value };
|
|
18584
|
+
});
|
|
18585
|
+
}
|
|
18586
|
+
if (isRecord2(value)) {
|
|
18587
|
+
return Object.entries(value).map(([name, entryValue]) => ({ name, value: entryValue }));
|
|
18588
|
+
}
|
|
18589
|
+
throw new AutotaskConfigError("userDefinedFields must be an array of { name, value } entries or a name-to-value map");
|
|
18590
|
+
}
|
|
18591
|
+
function blindStampFor(stamp, filter) {
|
|
18592
|
+
if (stamp === void 0) return void 0;
|
|
18593
|
+
if (stamp.kind !== "unfiltered-blind") return stamp;
|
|
18594
|
+
const conditions = normalizedConditions(filter);
|
|
18595
|
+
return conditions === void 0 || conditions.length === 0 ? stamp : void 0;
|
|
18596
|
+
}
|
|
18597
|
+
function decodeFileData(body) {
|
|
18598
|
+
if (isRecord2(body)) {
|
|
18599
|
+
const data = body.data;
|
|
18600
|
+
if (typeof data === "string") return Buffer.from(data, "base64");
|
|
18601
|
+
if (Array.isArray(data) && data.every((b) => typeof b === "number")) {
|
|
18602
|
+
return Buffer.from(data);
|
|
18603
|
+
}
|
|
18604
|
+
}
|
|
18605
|
+
if (typeof body === "string") return Buffer.from(body, "base64");
|
|
18606
|
+
throw new AutotaskError(
|
|
18607
|
+
"Expected the file envelope FileQueryResultModel { data } (or a base64 string); got a different shape",
|
|
18608
|
+
{ code: "INVALID_RESPONSE", category: "server" }
|
|
18609
|
+
);
|
|
18610
|
+
}
|
|
18611
|
+
var DEPLURAL_EXCEPTIONS = {
|
|
18612
|
+
tag_aliase: "tag_alias"
|
|
18613
|
+
};
|
|
18614
|
+
function entityNameFromPath(resourcePath) {
|
|
18615
|
+
const segment = resourcePath.slice(resourcePath.lastIndexOf("/") + 1);
|
|
18616
|
+
const snake = segment.replace(/([A-Z])/g, (_m, c, i) => (i > 0 ? `_` : "") + c.toLowerCase()).replace(/_{2,}/g, "_");
|
|
18617
|
+
if (snake.endsWith("ies")) return `${snake.slice(0, -3)}y`;
|
|
18618
|
+
if (snake.endsWith("s")) {
|
|
18619
|
+
const stripped = snake.slice(0, -1);
|
|
18620
|
+
return DEPLURAL_EXCEPTIONS[stripped] ?? stripped;
|
|
18621
|
+
}
|
|
18622
|
+
return snake;
|
|
18623
|
+
}
|
|
18624
|
+
|
|
18625
|
+
// src/resources/special/inventoryItems.ts
|
|
18626
|
+
var REFERENCES = ["inventoryLocationID", "productID"];
|
|
18627
|
+
var QUANTITIES = ["quantityMinimum", "quantityMaximum", "quantityOnHand"];
|
|
18628
|
+
var TEXT_FIELDS = ["bin", "referenceNumber"];
|
|
18629
|
+
var MUTATION_OPTIONS = ["dryRun", "lastModifiedDate", "maxRetries", "raw", "verifyPersisted", "expectedInventoryFacts"];
|
|
18630
|
+
function fail(message) {
|
|
18631
|
+
throw new AutotaskConfigError(`inventory_items: ${message}`);
|
|
18632
|
+
}
|
|
18633
|
+
function own(record, field) {
|
|
18634
|
+
return Object.hasOwn(record, field) ? record[field] : void 0;
|
|
18635
|
+
}
|
|
18636
|
+
function int32(value, label, minimum = -2147483648) {
|
|
18637
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < minimum || value > 2147483647) {
|
|
18638
|
+
fail(`${label} must be an integer between ${minimum} and 2147483647`);
|
|
18639
|
+
}
|
|
18640
|
+
return value;
|
|
18641
|
+
}
|
|
18642
|
+
function inventoryItemId(value) {
|
|
18643
|
+
const id = parseIdentifier(value, "inventory_items: id");
|
|
18644
|
+
if (!isAuditDecimalId(String(id))) fail("id must fit a signed 64-bit integer");
|
|
18645
|
+
return id;
|
|
18646
|
+
}
|
|
18647
|
+
function admitInventoryItem(value, creating) {
|
|
18648
|
+
if (!isRecord2(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail("data must be a plain record");
|
|
18649
|
+
const body = captureInventoryPayload(value)();
|
|
18650
|
+
const writable = [...QUANTITIES, ...TEXT_FIELDS, ...creating ? REFERENCES : []];
|
|
18651
|
+
for (const field of Object.keys(body)) {
|
|
18652
|
+
if (!writable.some((name) => name === field)) fail(`${field} is not a writable InventoryItems field on ${creating ? "create" : "update"}`);
|
|
18653
|
+
}
|
|
18654
|
+
if (!creating && Object.keys(body).length === 0) fail("update must contain a writable field");
|
|
18655
|
+
if (creating) for (const field of REFERENCES) int32(own(body, field), field, 1);
|
|
18656
|
+
for (const field of QUANTITIES) {
|
|
18657
|
+
const nonnegative = field === "quantityMinimum" || creating && field === "quantityOnHand";
|
|
18658
|
+
if (creating || Object.hasOwn(body, field)) int32(own(body, field), field, nonnegative ? 0 : void 0);
|
|
18659
|
+
}
|
|
18660
|
+
for (const field of TEXT_FIELDS) {
|
|
18661
|
+
const text = own(body, field);
|
|
18662
|
+
if (Object.hasOwn(body, field) && (typeof text !== "string" || text.length > 50)) fail(`${field} must be a string of at most 50 characters`);
|
|
18663
|
+
}
|
|
18664
|
+
assertQuantityRange(own(body, "quantityMinimum"), own(body, "quantityMaximum"));
|
|
18665
|
+
return body;
|
|
18666
|
+
}
|
|
18667
|
+
function captureInventoryPayload(value) {
|
|
18668
|
+
if (util.types.isProxy(value)) fail("payload must not be a Proxy");
|
|
18669
|
+
if (!isRecord2(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail("data must be a plain record");
|
|
18670
|
+
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
18671
|
+
const captured = /* @__PURE__ */ Object.create(null);
|
|
18672
|
+
const accessors = [];
|
|
18673
|
+
for (const [field, descriptor2] of Object.entries(descriptors)) {
|
|
18674
|
+
if (!descriptor2.enumerable) continue;
|
|
18675
|
+
if (Object.hasOwn(descriptor2, "value")) captured[field] = descriptor2.value;
|
|
18676
|
+
else accessors.push([field, descriptor2]);
|
|
18677
|
+
}
|
|
18678
|
+
return (allowAccessors = true) => {
|
|
18679
|
+
if (!allowAccessors && accessors.length > 0) fail("approved InventoryItems payload fields must be data properties; accessors are unsupported");
|
|
18680
|
+
const body = { ...captured };
|
|
18681
|
+
for (const [field, descriptor2] of accessors) {
|
|
18682
|
+
const capturedValue = descriptor2.get === void 0 ? void 0 : Reflect.apply(descriptor2.get, value, []);
|
|
18683
|
+
Object.defineProperty(body, field, { value: capturedValue, enumerable: true });
|
|
18684
|
+
}
|
|
18685
|
+
return body;
|
|
18686
|
+
};
|
|
18687
|
+
}
|
|
18688
|
+
function captureInventoryOptionDescriptors(options) {
|
|
18689
|
+
if (util.types.isProxy(options)) fail("options must not be a Proxy");
|
|
18690
|
+
if (!isRecord2(options)) fail("options must be an object");
|
|
18691
|
+
const prototype = Object.getPrototypeOf(options);
|
|
18692
|
+
for (let owner = prototype; owner !== null && owner !== Object.prototype; owner = Object.getPrototypeOf(owner)) {
|
|
18693
|
+
if (util.types.isProxy(owner)) fail("options must not inherit from a Proxy");
|
|
18694
|
+
}
|
|
18695
|
+
const descriptors = Object.getOwnPropertyDescriptors(options);
|
|
18696
|
+
const fact = Object.hasOwn(descriptors, "expectedInventoryFacts") ? descriptors.expectedInventoryFacts : void 0;
|
|
18697
|
+
if (fact === void 0 ? "expectedInventoryFacts" in options : !Object.hasOwn(fact, "value")) {
|
|
18698
|
+
fail("expectedInventoryFacts must be an own data property; accessors are unsupported");
|
|
18699
|
+
}
|
|
18700
|
+
const suppliedFacts = fact?.value;
|
|
18701
|
+
if (suppliedFacts !== void 0 && ![Object.prototype, null].includes(prototype)) fail("approved options must be a plain record");
|
|
18702
|
+
const expectedInventoryFacts = suppliedFacts === void 0 ? void 0 : snapshotExpectedInventoryFacts(suppliedFacts);
|
|
18703
|
+
return { options, descriptors, expectedInventoryFacts };
|
|
18704
|
+
}
|
|
18705
|
+
function snapshotInventoryMutationOptions(value) {
|
|
18706
|
+
const { options, descriptors, expectedInventoryFacts } = captureInventoryOptionDescriptors(value === void 0 ? {} : value);
|
|
18707
|
+
for (const key of MUTATION_OPTIONS) {
|
|
18708
|
+
if (key !== "expectedInventoryFacts" && !Object.hasOwn(descriptors, key) && key in options) fail(`${key} must be an own option`);
|
|
18709
|
+
}
|
|
18710
|
+
if (expectedInventoryFacts !== void 0 && Object.values(descriptors).some((descriptor2) => !Object.hasOwn(descriptor2, "value"))) fail("approved InventoryItems options must be data properties; accessors are unsupported");
|
|
18711
|
+
const captured = /* @__PURE__ */ Object.create(null);
|
|
18712
|
+
const dryRun = Object.hasOwn(descriptors, "dryRun") ? descriptors.dryRun : void 0;
|
|
18713
|
+
if (dryRun !== void 0) {
|
|
18714
|
+
const dataFlag = Object.hasOwn(dryRun, "value");
|
|
18715
|
+
const value2 = dataFlag ? dryRun.value : dryRun.get === void 0 ? void 0 : Reflect.apply(dryRun.get, options, []);
|
|
18716
|
+
captured.dryRun = !dataFlag && value2 === void 0 ? true : value2;
|
|
18717
|
+
}
|
|
18718
|
+
for (const key of MUTATION_OPTIONS) {
|
|
18719
|
+
if (key === "expectedInventoryFacts" || key === "dryRun") continue;
|
|
18720
|
+
const descriptor2 = descriptors[key];
|
|
18721
|
+
captured[key] = descriptor2 === void 0 ? void 0 : Object.hasOwn(descriptor2, "value") ? descriptor2.value : descriptor2.get === void 0 ? void 0 : Reflect.apply(descriptor2.get, options, []);
|
|
18722
|
+
}
|
|
18723
|
+
const result = snapshotMutationOptions(captured);
|
|
18724
|
+
if (expectedInventoryFacts !== void 0) result.expectedInventoryFacts = expectedInventoryFacts;
|
|
18725
|
+
if (result.lastModifiedDate !== void 0) fail("no documented stale timestamp is available");
|
|
18726
|
+
if (result.raw !== void 0 && result.raw !== false) fail("raw updates are unsupported");
|
|
18727
|
+
if (result.maxRetries !== void 0 && (!Number.isSafeInteger(result.maxRetries) || result.maxRetries < 0)) fail("maxRetries must be a nonnegative safe integer");
|
|
18728
|
+
if (result.verifyPersisted !== void 0 && typeof result.verifyPersisted !== "boolean") fail("verifyPersisted must be a boolean");
|
|
18729
|
+
return result;
|
|
18730
|
+
}
|
|
18731
|
+
function validateInventoryFactIntent(result, creating, data) {
|
|
18732
|
+
const facts = result.expectedInventoryFacts;
|
|
18733
|
+
if (facts === void 0) return;
|
|
18734
|
+
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)) {
|
|
18735
|
+
fail("expectedInventoryFacts must supply only the facts required by this create or update");
|
|
18736
|
+
}
|
|
18737
|
+
if (creating && (facts.product.id !== data.productID || facts.location.id !== data.inventoryLocationID)) fail("expectedInventoryFacts references must match the submitted references");
|
|
18738
|
+
}
|
|
18739
|
+
function captureInventoryItemCall(value, options, creating) {
|
|
18740
|
+
const payload = captureInventoryPayload(value);
|
|
18741
|
+
const opts = snapshotInventoryMutationOptions(options);
|
|
18742
|
+
const body = admitInventoryItem(payload(opts.expectedInventoryFacts === void 0), creating);
|
|
18743
|
+
validateInventoryFactIntent(opts, creating, body);
|
|
18744
|
+
return { body, opts };
|
|
18745
|
+
}
|
|
18746
|
+
function deferredInventoryPayload(value, allowAccessors) {
|
|
18747
|
+
if (util.types.isProxy(value)) fail("payload must not be a Proxy");
|
|
18748
|
+
if (!isRecord2(value)) return value;
|
|
18749
|
+
if (![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail("data must be a plain record");
|
|
18750
|
+
const result = Object.create(Object.getPrototypeOf(value));
|
|
18751
|
+
for (const [field, descriptor2] of Object.entries(Object.getOwnPropertyDescriptors(value))) {
|
|
18752
|
+
if (!descriptor2.enumerable) continue;
|
|
18753
|
+
if (Object.hasOwn(descriptor2, "value")) Object.defineProperty(result, field, { value: descriptor2.value, enumerable: true });
|
|
18754
|
+
else {
|
|
18755
|
+
if (!allowAccessors) fail("approved InventoryItems payload fields must be data properties; accessors are unsupported");
|
|
18756
|
+
let resolved = false;
|
|
18757
|
+
let captured;
|
|
18758
|
+
Object.defineProperty(result, field, { enumerable: true, get() {
|
|
18759
|
+
if (!resolved) {
|
|
18760
|
+
captured = descriptor2.get === void 0 ? void 0 : Reflect.apply(descriptor2.get, value, []);
|
|
18761
|
+
resolved = true;
|
|
18762
|
+
}
|
|
18763
|
+
return captured;
|
|
18764
|
+
} });
|
|
18765
|
+
}
|
|
18766
|
+
}
|
|
18767
|
+
return result;
|
|
18768
|
+
}
|
|
18769
|
+
function captureInventoryInvocationArgs(operation, args) {
|
|
18770
|
+
if (operation !== "inventory_items.create" && operation !== "inventory_items.update") return () => args;
|
|
18771
|
+
if (util.types.isProxy(args)) fail("invoke arguments must not be a Proxy");
|
|
18772
|
+
const array = Array.isArray(args);
|
|
18773
|
+
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");
|
|
18774
|
+
const descriptors = Object.getOwnPropertyDescriptors(args);
|
|
18775
|
+
if (!array && Object.getOwnPropertySymbols(descriptors).length > 0) fail("InventoryItems named inputs must use string keys");
|
|
18776
|
+
const dataKey = array ? operation === "inventory_items.create" ? "0" : "1" : "data";
|
|
18777
|
+
const payload = descriptors[dataKey];
|
|
18778
|
+
const pinnedPayload = payload !== void 0 && Object.hasOwn(payload, "value") ? deferredInventoryPayload(payload.value, true) : void 0;
|
|
18779
|
+
return (allowAccessors = true) => {
|
|
18780
|
+
const result = array ? [] : Object.create(Object.getPrototypeOf(args));
|
|
18781
|
+
for (const [key, descriptor2] of Object.entries(descriptors)) {
|
|
18782
|
+
if (array && key === "length") continue;
|
|
18783
|
+
const enumerable = !array || descriptor2.enumerable;
|
|
18784
|
+
if (Object.hasOwn(descriptor2, "value")) {
|
|
18785
|
+
const value = key === dataKey ? deferredInventoryPayload(pinnedPayload, allowAccessors) : descriptor2.value;
|
|
18786
|
+
Object.defineProperty(result, key, { value, enumerable, configurable: true });
|
|
18787
|
+
} else {
|
|
18788
|
+
if (!allowAccessors) fail("approved InventoryItems named inputs must be data properties; accessors are unsupported");
|
|
18789
|
+
let resolved = false;
|
|
18790
|
+
let captured;
|
|
18791
|
+
Object.defineProperty(result, key, { enumerable, configurable: true, get() {
|
|
18792
|
+
if (!resolved) {
|
|
18793
|
+
const value = descriptor2.get === void 0 ? void 0 : Reflect.apply(descriptor2.get, args, []);
|
|
18794
|
+
captured = key === dataKey ? deferredInventoryPayload(value, true) : value;
|
|
18795
|
+
resolved = true;
|
|
18796
|
+
}
|
|
18797
|
+
return captured;
|
|
18798
|
+
} });
|
|
18799
|
+
}
|
|
18800
|
+
}
|
|
18801
|
+
return result;
|
|
18802
|
+
};
|
|
18803
|
+
}
|
|
18804
|
+
var ITEM_NUMERIC_FACTS = [...REFERENCES, ...QUANTITIES, "quantityPicked", "quantityReserved", "quantityOnOrder", "backOrderQuantity", "impersonatorCreatorResourceID"];
|
|
18805
|
+
var ITEM_FACT_KEYS = ["id", ...ITEM_NUMERIC_FACTS, ...TEXT_FIELDS];
|
|
18806
|
+
function inventoryItemGuardFacts(value) {
|
|
18807
|
+
const captured = closedFacts(value, ITEM_FACT_KEYS, false);
|
|
18808
|
+
if (!Object.hasOwn(captured, "id")) fail("inventory facts require an own item id");
|
|
18809
|
+
const facts = { id: inventoryItemId(captured.id) };
|
|
18810
|
+
for (const field of ITEM_NUMERIC_FACTS) if (Object.hasOwn(captured, field)) {
|
|
18811
|
+
const current = captured[field];
|
|
18812
|
+
facts[field] = current === null ? null : int32(current, "inventory fact");
|
|
18813
|
+
}
|
|
18814
|
+
for (const field of TEXT_FIELDS) if (Object.hasOwn(captured, field)) {
|
|
18815
|
+
const current = captured[field];
|
|
18816
|
+
if (current !== null && typeof current !== "string") fail("inventory text facts must be strings or null");
|
|
18817
|
+
facts[field] = current;
|
|
18818
|
+
}
|
|
18819
|
+
return facts;
|
|
18820
|
+
}
|
|
18821
|
+
function closedFacts(value, fields, closed = true) {
|
|
18822
|
+
if (util.types.isProxy(value)) fail("expectedInventoryFacts records must not be a Proxy");
|
|
18823
|
+
if (!isRecord2(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail("expectedInventoryFacts must contain plain records");
|
|
18824
|
+
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
18825
|
+
if (closed && Reflect.ownKeys(descriptors).some((key) => typeof key !== "string" || !fields.includes(key))) fail("expectedInventoryFacts contains an unsupported field");
|
|
18826
|
+
for (const key of fields) if (key in value && !Object.hasOwn(value, key)) fail("expectedInventoryFacts fields must be own fields");
|
|
18827
|
+
const captured = /* @__PURE__ */ Object.create(null);
|
|
18828
|
+
for (const key of fields) {
|
|
18829
|
+
const descriptor2 = descriptors[key];
|
|
18830
|
+
if (descriptor2 === void 0) continue;
|
|
18831
|
+
if (!Object.hasOwn(descriptor2, "value")) fail("expectedInventoryFacts fields must be data properties; accessors are unsupported");
|
|
18832
|
+
captured[key] = descriptor2.value;
|
|
18833
|
+
}
|
|
18834
|
+
return captured;
|
|
18835
|
+
}
|
|
18836
|
+
function snapshotExpectedInventoryFacts(value) {
|
|
18837
|
+
const source = closedFacts(value, ["item", "product", "location"]);
|
|
18838
|
+
const result = {};
|
|
18839
|
+
if (Object.hasOwn(source, "item")) {
|
|
18840
|
+
const item = closedFacts(source.item, ITEM_FACT_KEYS);
|
|
18841
|
+
result.item = inventoryItemGuardFacts(item);
|
|
18842
|
+
}
|
|
18843
|
+
for (const kind of ["product", "location"]) if (Object.hasOwn(source, kind)) {
|
|
18844
|
+
const flag = kind === "product" ? "isSerialized" : "isActive";
|
|
18845
|
+
const record = closedFacts(source[kind], ["id", flag]);
|
|
18846
|
+
const id = int32(own(record, "id"), "expected reference id", 1);
|
|
18847
|
+
const state2 = own(record, flag);
|
|
18848
|
+
if (typeof state2 !== "boolean") fail("expected reference state must be an own boolean");
|
|
18849
|
+
if (kind === "product") result.product = { id, isSerialized: state2 };
|
|
18850
|
+
else result.location = { id, isActive: state2 };
|
|
18851
|
+
}
|
|
18852
|
+
return result;
|
|
18853
|
+
}
|
|
18854
|
+
function rejectInventoryFactsOption(options, operation) {
|
|
18855
|
+
if (operation === "inventory_items.create" || operation === "inventory_items.update" || !isRecord2(options)) return;
|
|
18856
|
+
const option = Object.getOwnPropertyDescriptor(options, "expectedInventoryFacts");
|
|
18857
|
+
if (option === void 0 && !("expectedInventoryFacts" in options)) return;
|
|
18858
|
+
if (option !== void 0 && Object.hasOwn(option, "value") && option.value === void 0) return;
|
|
18859
|
+
fail("expectedInventoryFacts is supported only by inventory_items.create/update");
|
|
18860
|
+
}
|
|
18861
|
+
function inventoryFactsStale(operation) {
|
|
18862
|
+
const error = new StaleObjectError("inventory_items: approved facts changed; no mutation was sent", {
|
|
18863
|
+
operation,
|
|
18864
|
+
suggestedAction: "Read fresh inventory facts and generate a new preview and approval before retrying."
|
|
18865
|
+
});
|
|
18866
|
+
Object.assign(error, { notSent: true });
|
|
18867
|
+
throw error;
|
|
18868
|
+
}
|
|
18869
|
+
function rethrowInventoryGuardError(error, expected, operation) {
|
|
18870
|
+
if (expected !== void 0 && error instanceof NotFoundError && error.httpStatus === 200) inventoryFactsStale(operation);
|
|
18871
|
+
throw error;
|
|
18872
|
+
}
|
|
18873
|
+
function assertApprovedFacts(expected, actual, operation) {
|
|
18874
|
+
const before = expected;
|
|
18875
|
+
const after = actual;
|
|
18876
|
+
if (Object.keys(before).length !== Object.keys(after).length || Object.keys(before).some((key) => !Object.hasOwn(after, key) || before[key] !== after[key])) {
|
|
18877
|
+
inventoryFactsStale(operation);
|
|
18878
|
+
}
|
|
18879
|
+
}
|
|
18880
|
+
function assertQuantityRange(minimum, maximum) {
|
|
18881
|
+
if (typeof minimum === "number" && typeof maximum === "number" && maximum < minimum) fail("quantityMaximum must be at least quantityMinimum");
|
|
18882
|
+
}
|
|
18883
|
+
function exactItem(value, id, label, approvedOperation) {
|
|
18884
|
+
const record = isRecord2(value);
|
|
18885
|
+
if (approvedOperation !== void 0 && (!record || own(value, "id") === null)) {
|
|
18886
|
+
throw Object.assign(new AutotaskError("InventoryItems approval could not verify the Product item or its exact ID", {
|
|
18887
|
+
code: "INVALID_RESPONSE",
|
|
18888
|
+
category: "server",
|
|
18889
|
+
operation: approvedOperation
|
|
18890
|
+
}), { notSent: true });
|
|
18891
|
+
}
|
|
18892
|
+
if (!record) fail(`${label} must be a record`);
|
|
18893
|
+
if (approvedOperation !== void 0 && !Object.hasOwn(value, "id")) inventoryFactsStale(approvedOperation);
|
|
18894
|
+
const returned = own(value, "id");
|
|
18895
|
+
if (typeof returned !== "string" && (typeof returned !== "number" || !Number.isSafeInteger(returned))) fail(`${label} requires its own exact id`);
|
|
18896
|
+
if (String(returned) !== String(id)) {
|
|
18897
|
+
if (approvedOperation !== void 0 && isAuditDecimalId(String(returned))) inventoryFactsStale(approvedOperation);
|
|
18898
|
+
fail(`${label} id must match the requested id`);
|
|
18899
|
+
}
|
|
18900
|
+
return value;
|
|
18901
|
+
}
|
|
18902
|
+
async function productIsSerialized(http, id, checkedBaseUrl, maxRetries, expected, mutationOperation = "inventory_items.update") {
|
|
18903
|
+
const operation = "products.get";
|
|
18904
|
+
const body = await http.request({
|
|
18905
|
+
method: "GET",
|
|
18906
|
+
path: `/V1.0/Products/${id}`,
|
|
18907
|
+
operation,
|
|
18908
|
+
maxRetries,
|
|
18909
|
+
checkedBaseUrl,
|
|
18910
|
+
...expected !== void 0 ? { [INVENTORY_APPROVAL_PRODUCT_ID]: true } : {}
|
|
18911
|
+
});
|
|
18912
|
+
let raw;
|
|
18913
|
+
try {
|
|
18914
|
+
raw = unwrapItem(body, id, operation, "product");
|
|
18915
|
+
} catch (error) {
|
|
18916
|
+
rethrowInventoryGuardError(error, expected === void 0 ? void 0 : { }, mutationOperation);
|
|
18917
|
+
}
|
|
18918
|
+
const product = exactItem(raw, id, "product", expected === void 0 ? void 0 : mutationOperation);
|
|
18919
|
+
const serialized = own(product, "isSerialized");
|
|
18920
|
+
if (expected !== void 0) assertApprovedFacts(expected, { id, isSerialized: serialized }, mutationOperation);
|
|
18921
|
+
if (typeof serialized !== "boolean") fail("product requires a fresh boolean isSerialized fact");
|
|
18922
|
+
return serialized;
|
|
18923
|
+
}
|
|
18924
|
+
async function guardInventoryItemCreate(http, data, checkedBaseUrl, maxRetries, expected) {
|
|
18925
|
+
const locationId = data.inventoryLocationID;
|
|
18926
|
+
const operation = "inventory_locations.get";
|
|
18927
|
+
const body = await http.request({ method: "GET", path: `/V1.0/InventoryLocations/${locationId}`, operation, maxRetries, checkedBaseUrl });
|
|
18928
|
+
let raw;
|
|
18929
|
+
try {
|
|
18930
|
+
raw = unwrapItem(body, locationId, operation, "inventory_location");
|
|
18931
|
+
} catch (error) {
|
|
18932
|
+
rethrowInventoryGuardError(error, expected, "inventory_items.create");
|
|
18933
|
+
}
|
|
18934
|
+
const location = exactItem(raw, locationId, "inventory location");
|
|
18935
|
+
if (expected?.location !== void 0) assertApprovedFacts(expected.location, { id: locationId, isActive: own(location, "isActive") }, "inventory_items.create");
|
|
18936
|
+
if (own(location, "isActive") !== true) fail("inventory location requires a fresh isActive value explicitly true");
|
|
18937
|
+
if (await productIsSerialized(http, data.productID, checkedBaseUrl, maxRetries, expected?.product, "inventory_items.create") && data.quantityOnHand !== 0) {
|
|
18938
|
+
fail("quantityOnHand must be zero when creating an item for a serialized product");
|
|
18939
|
+
}
|
|
18940
|
+
}
|
|
18941
|
+
async function checkInventoryItemCurrent(http, data, current, id, checkedBaseUrl, maxRetries, expected) {
|
|
18942
|
+
const item = exactItem(current, id, "current record");
|
|
18943
|
+
if (expected?.item !== void 0) assertApprovedFacts(expected.item, inventoryItemGuardFacts(item), "inventory_items.update");
|
|
18944
|
+
const minimum = own(data, "quantityMinimum");
|
|
18945
|
+
const maximum = own(data, "quantityMaximum");
|
|
18946
|
+
if (minimum !== void 0 || maximum !== void 0) {
|
|
18947
|
+
assertQuantityRange(
|
|
18948
|
+
minimum ?? int32(own(item, "quantityMinimum"), "current quantityMinimum", 0),
|
|
18949
|
+
maximum ?? int32(own(item, "quantityMaximum"), "current quantityMaximum")
|
|
18950
|
+
);
|
|
18951
|
+
}
|
|
18952
|
+
const onHand = own(data, "quantityOnHand");
|
|
18953
|
+
if (typeof onHand !== "number") return;
|
|
18954
|
+
const picked = int32(own(item, "quantityPicked"), "current quantityPicked");
|
|
18955
|
+
const reserved = int32(own(item, "quantityReserved"), "current quantityReserved");
|
|
18956
|
+
if (onHand < picked + reserved) fail("quantityOnHand must be at least quantityPicked plus quantityReserved");
|
|
18957
|
+
const productId = int32(own(item, "productID"), "current productID", 1);
|
|
18958
|
+
if (await productIsSerialized(http, productId, checkedBaseUrl, maxRetries, expected?.product)) fail("quantityOnHand is read-only on update for a serialized product");
|
|
18959
|
+
}
|
|
18960
|
+
|
|
18365
18961
|
// src/operations/requiredFields.ts
|
|
18366
18962
|
function effectiveRequiredFields(record, zoneFacts) {
|
|
18367
18963
|
const guidance = zoneFacts?.createGuidance;
|
|
@@ -18529,13 +19125,13 @@ async function runBounded(fn, items, opts) {
|
|
|
18529
19125
|
const results = new Array(items.length);
|
|
18530
19126
|
let next = 0;
|
|
18531
19127
|
let failure;
|
|
18532
|
-
const
|
|
19128
|
+
const fail5 = (error, index) => {
|
|
18533
19129
|
if (failure === void 0 || opts.orderedErrors === true && index < failure.index) failure = { error, index };
|
|
18534
19130
|
};
|
|
18535
19131
|
const worker = async () => {
|
|
18536
19132
|
while (failure === void 0 && next < items.length) {
|
|
18537
19133
|
if (signal?.aborted) {
|
|
18538
|
-
|
|
19134
|
+
fail5(signal.reason, -1);
|
|
18539
19135
|
return;
|
|
18540
19136
|
}
|
|
18541
19137
|
const i = next++;
|
|
@@ -18545,7 +19141,7 @@ async function runBounded(fn, items, opts) {
|
|
|
18545
19141
|
results[i] = settle ? { status: "fulfilled", value } : value;
|
|
18546
19142
|
} catch (error) {
|
|
18547
19143
|
if (settle) results[i] = { status: "rejected", reason: error };
|
|
18548
|
-
else
|
|
19144
|
+
else fail5(error, i);
|
|
18549
19145
|
}
|
|
18550
19146
|
}
|
|
18551
19147
|
};
|
|
@@ -18601,7 +19197,7 @@ async function capabilitySets() {
|
|
|
18601
19197
|
const fieldOps = /* @__PURE__ */ new Map();
|
|
18602
19198
|
const udfCapable = /* @__PURE__ */ new Set();
|
|
18603
19199
|
const resources = /* @__PURE__ */ new Set();
|
|
18604
|
-
for (const rec of await
|
|
19200
|
+
for (const rec of await chunkQXJQIZCT_cjs.loadCapabilityRecords()) {
|
|
18605
19201
|
if (rec.resource === "operations") continue;
|
|
18606
19202
|
resources.add(rec.resource);
|
|
18607
19203
|
if (rec.operation === "getFieldInfo") fieldOps.set(rec.resource, rec);
|
|
@@ -18612,7 +19208,7 @@ async function capabilitySets() {
|
|
|
18612
19208
|
var derivedIndexPromise = null;
|
|
18613
19209
|
function derivedIndexLoad() {
|
|
18614
19210
|
if (derivedIndexPromise === null) {
|
|
18615
|
-
derivedIndexPromise =
|
|
19211
|
+
derivedIndexPromise = chunkQXJQIZCT_cjs.loadCapabilityRecords().then((records) => {
|
|
18616
19212
|
const index = /* @__PURE__ */ new Map();
|
|
18617
19213
|
for (const rec of records) {
|
|
18618
19214
|
const declared = rec.metadata?.derivedFields;
|
|
@@ -18965,166 +19561,6 @@ async function fieldCatalog(client, opts) {
|
|
|
18965
19561
|
return result;
|
|
18966
19562
|
}
|
|
18967
19563
|
|
|
18968
|
-
// src/resources/base/helpers.ts
|
|
18969
|
-
function describeResponseShape(body) {
|
|
18970
|
-
if (body === null) return "null";
|
|
18971
|
-
if (Array.isArray(body)) return `array(len=${body.length})`;
|
|
18972
|
-
if (typeof body !== "object") return typeof body;
|
|
18973
|
-
const rec = body;
|
|
18974
|
-
const keys = Object.keys(rec).sort();
|
|
18975
|
-
const typeOf = (v) => v === null ? "null" : Array.isArray(v) ? "array" : typeof v;
|
|
18976
|
-
const parts = keys.slice(0, 16).map((k) => `${k}:${typeOf(rec[k])}`);
|
|
18977
|
-
const more = keys.length > 16 ? `, +${keys.length - 16} more` : "";
|
|
18978
|
-
return `{ ${parts.join(", ")}${more} }`;
|
|
18979
|
-
}
|
|
18980
|
-
function defaultMarkerToken(data) {
|
|
18981
|
-
for (const field of ["name", "title"]) {
|
|
18982
|
-
const v = data[field];
|
|
18983
|
-
if (typeof v === "string" && v.trim() !== "") return v.trim();
|
|
18984
|
-
}
|
|
18985
|
-
return null;
|
|
18986
|
-
}
|
|
18987
|
-
var CONTEXT_ABSENT_MARKER = "#context-absent";
|
|
18988
|
-
function contextAbsentKey(path) {
|
|
18989
|
-
return path + "\0context-absent";
|
|
18990
|
-
}
|
|
18991
|
-
function noteCharsTruncationMarker(charsRemoved) {
|
|
18992
|
-
return `\u2026 [+${charsRemoved} chars truncated]`;
|
|
18993
|
-
}
|
|
18994
|
-
function truncateNoteChars(items, cap, fields) {
|
|
18995
|
-
let truncated = 0;
|
|
18996
|
-
const out = items.map((item) => {
|
|
18997
|
-
if (!isRecord2(item)) return item;
|
|
18998
|
-
let changed = false;
|
|
18999
|
-
const copy = { ...item };
|
|
19000
|
-
for (const field of fields) {
|
|
19001
|
-
const v = copy[field];
|
|
19002
|
-
if (typeof v === "string" && v !== chunkCM5O672I_cjs.REDACTED && v.length > cap) {
|
|
19003
|
-
const end = cap > 0 && (v.charCodeAt(cap - 1) & 64512) === 55296 ? cap - 1 : cap;
|
|
19004
|
-
copy[field] = v.slice(0, end) + noteCharsTruncationMarker(v.length - end);
|
|
19005
|
-
truncated += 1;
|
|
19006
|
-
changed = true;
|
|
19007
|
-
}
|
|
19008
|
-
}
|
|
19009
|
-
return changed ? copy : item;
|
|
19010
|
-
});
|
|
19011
|
-
return [out, truncated];
|
|
19012
|
-
}
|
|
19013
|
-
function blindEmptyReason(stamp) {
|
|
19014
|
-
return {
|
|
19015
|
-
surface: stamp.surface,
|
|
19016
|
-
kind: "blind-surface",
|
|
19017
|
-
note: stamp.note,
|
|
19018
|
-
authority: stamp.authority,
|
|
19019
|
-
remedy: "the note is the remedy \u2014 the authority op answers for a record"
|
|
19020
|
-
};
|
|
19021
|
-
}
|
|
19022
|
-
function attachUpdateTargetMissReason(err, key) {
|
|
19023
|
-
const pinned = EMPTY_REASON_STAMPS[key]?.update;
|
|
19024
|
-
if (pinned === void 0) return;
|
|
19025
|
-
err.details = { ...err.details ?? {}, emptyReason: pinned };
|
|
19026
|
-
}
|
|
19027
|
-
function buildDryRunResult(spec, policy) {
|
|
19028
|
-
if (spec.operation === "") {
|
|
19029
|
-
throw new AutotaskConfigError("dry-run: the operation name is required");
|
|
19030
|
-
}
|
|
19031
|
-
const wouldApply = spec.checks.every((check) => check.ok);
|
|
19032
|
-
const resource = spec.operation.split(".")[0] ?? spec.operation;
|
|
19033
|
-
const diffPart = spec.diff !== void 0 ? {
|
|
19034
|
-
diff: spec.diff.map((entry) => {
|
|
19035
|
-
if (entry.to === void 0) return entry;
|
|
19036
|
-
const to = isRedactedFieldName(entry.field, policy) ? chunkCM5O672I_cjs.REDACTED : redactResponseBody(entry.to, policy);
|
|
19037
|
-
return { ...entry, to };
|
|
19038
|
-
})
|
|
19039
|
-
} : {};
|
|
19040
|
-
const dataPart = spec.data !== void 0 ? { data: redactResponseBody(spec.data, policy) } : {};
|
|
19041
|
-
return {
|
|
19042
|
-
operation: spec.operation,
|
|
19043
|
-
wouldApply,
|
|
19044
|
-
target: { resource, ids: spec.ids },
|
|
19045
|
-
request: { method: spec.method, path: spec.path },
|
|
19046
|
-
...diffPart,
|
|
19047
|
-
checks: spec.checks,
|
|
19048
|
-
impact: spec.impact,
|
|
19049
|
-
simulated: true,
|
|
19050
|
-
warnings: spec.warnings ?? [],
|
|
19051
|
-
...dataPart,
|
|
19052
|
-
...spec.emptyReason !== void 0 ? { emptyReason: spec.emptyReason } : {}
|
|
19053
|
-
};
|
|
19054
|
-
}
|
|
19055
|
-
function computeFieldDiff(current, data) {
|
|
19056
|
-
const out = [];
|
|
19057
|
-
for (const [field, to] of Object.entries(data)) {
|
|
19058
|
-
if (field === "id" || to === void 0) continue;
|
|
19059
|
-
const from = Object.hasOwn(current, field) ? current[field] : void 0;
|
|
19060
|
-
if (from !== void 0 && JSON.stringify(from) === JSON.stringify(to)) continue;
|
|
19061
|
-
out.push({ field, from: from === void 0 ? null : from, to });
|
|
19062
|
-
}
|
|
19063
|
-
return out;
|
|
19064
|
-
}
|
|
19065
|
-
function mergePartialBody(current, data) {
|
|
19066
|
-
const merged = { ...current };
|
|
19067
|
-
for (const [key, value] of Object.entries(data)) {
|
|
19068
|
-
if (value === void 0) continue;
|
|
19069
|
-
merged[key] = value;
|
|
19070
|
-
}
|
|
19071
|
-
return merged;
|
|
19072
|
-
}
|
|
19073
|
-
function snapshotMutationOptions(options) {
|
|
19074
|
-
const { dryRun, lastModifiedDate, maxRetries, raw, verifyPersisted } = options ?? {};
|
|
19075
|
-
if (dryRun !== void 0 && typeof dryRun !== "boolean") {
|
|
19076
|
-
throw new AutotaskConfigError("dryRun must be a boolean");
|
|
19077
|
-
}
|
|
19078
|
-
return { dryRun, lastModifiedDate, maxRetries, raw, verifyPersisted };
|
|
19079
|
-
}
|
|
19080
|
-
function normalizeUdfInput(value) {
|
|
19081
|
-
if (Array.isArray(value)) {
|
|
19082
|
-
return value.map((entry) => {
|
|
19083
|
-
if (!isRecord2(entry) || typeof entry.name !== "string" || entry.name === "") {
|
|
19084
|
-
throw new AutotaskConfigError("userDefinedFields array entries must be { name, value } objects");
|
|
19085
|
-
}
|
|
19086
|
-
return { name: entry.name, value: entry.value };
|
|
19087
|
-
});
|
|
19088
|
-
}
|
|
19089
|
-
if (isRecord2(value)) {
|
|
19090
|
-
return Object.entries(value).map(([name, entryValue]) => ({ name, value: entryValue }));
|
|
19091
|
-
}
|
|
19092
|
-
throw new AutotaskConfigError("userDefinedFields must be an array of { name, value } entries or a name-to-value map");
|
|
19093
|
-
}
|
|
19094
|
-
function blindStampFor(stamp, filter) {
|
|
19095
|
-
if (stamp === void 0) return void 0;
|
|
19096
|
-
if (stamp.kind !== "unfiltered-blind") return stamp;
|
|
19097
|
-
const conditions = normalizedConditions(filter);
|
|
19098
|
-
return conditions === void 0 || conditions.length === 0 ? stamp : void 0;
|
|
19099
|
-
}
|
|
19100
|
-
function decodeFileData(body) {
|
|
19101
|
-
if (isRecord2(body)) {
|
|
19102
|
-
const data = body.data;
|
|
19103
|
-
if (typeof data === "string") return Buffer.from(data, "base64");
|
|
19104
|
-
if (Array.isArray(data) && data.every((b) => typeof b === "number")) {
|
|
19105
|
-
return Buffer.from(data);
|
|
19106
|
-
}
|
|
19107
|
-
}
|
|
19108
|
-
if (typeof body === "string") return Buffer.from(body, "base64");
|
|
19109
|
-
throw new AutotaskError(
|
|
19110
|
-
"Expected the file envelope FileQueryResultModel { data } (or a base64 string); got a different shape",
|
|
19111
|
-
{ code: "INVALID_RESPONSE", category: "server" }
|
|
19112
|
-
);
|
|
19113
|
-
}
|
|
19114
|
-
var DEPLURAL_EXCEPTIONS = {
|
|
19115
|
-
tag_aliase: "tag_alias"
|
|
19116
|
-
};
|
|
19117
|
-
function entityNameFromPath(resourcePath) {
|
|
19118
|
-
const segment = resourcePath.slice(resourcePath.lastIndexOf("/") + 1);
|
|
19119
|
-
const snake = segment.replace(/([A-Z])/g, (_m, c, i) => (i > 0 ? `_` : "") + c.toLowerCase()).replace(/_{2,}/g, "_");
|
|
19120
|
-
if (snake.endsWith("ies")) return `${snake.slice(0, -3)}y`;
|
|
19121
|
-
if (snake.endsWith("s")) {
|
|
19122
|
-
const stripped = snake.slice(0, -1);
|
|
19123
|
-
return DEPLURAL_EXCEPTIONS[stripped] ?? stripped;
|
|
19124
|
-
}
|
|
19125
|
-
return snake;
|
|
19126
|
-
}
|
|
19127
|
-
|
|
19128
19564
|
// src/operations/nameSnapshot.ts
|
|
19129
19565
|
function nameRecordSnapshot(cache, path, id, operation) {
|
|
19130
19566
|
const body = cache?.get(path);
|
|
@@ -19969,17 +20405,17 @@ function validateParamsBag(record, args) {
|
|
|
19969
20405
|
}
|
|
19970
20406
|
);
|
|
19971
20407
|
}
|
|
19972
|
-
var INVOKE_OPTION_KEYS = ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted", "mode"];
|
|
20408
|
+
var INVOKE_OPTION_KEYS = ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted", "expectedInventoryFacts", "mode"];
|
|
19973
20409
|
function validateInvokeOptions(opts, operation) {
|
|
19974
20410
|
if (opts === void 0 || opts === null) return;
|
|
19975
20411
|
const unknown = Object.keys(opts).filter((k) => !INVOKE_OPTION_KEYS.includes(k));
|
|
19976
20412
|
if (unknown.length === 0) return;
|
|
19977
|
-
const suggestions = keySuggestions(unknown, ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted"]);
|
|
20413
|
+
const suggestions = keySuggestions(unknown, ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted", "expectedInventoryFacts"]);
|
|
19978
20414
|
throw new AutotaskConfigError(
|
|
19979
|
-
`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)`,
|
|
20415
|
+
`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)`,
|
|
19980
20416
|
{
|
|
19981
20417
|
operation,
|
|
19982
|
-
suggestedAction: suggestions.length > 0 ? `Fix the option name (${suggestions.join(", ")}).` : `Pass only dryRun / confirm / lastModifiedDate / maxRetries / fresh / verifyPersisted.`
|
|
20418
|
+
suggestedAction: suggestions.length > 0 ? `Fix the option name (${suggestions.join(", ")}).` : `Pass only dryRun / confirm / lastModifiedDate / maxRetries / fresh / verifyPersisted / expectedInventoryFacts.`
|
|
19983
20419
|
}
|
|
19984
20420
|
);
|
|
19985
20421
|
}
|
|
@@ -19998,24 +20434,24 @@ function unknownKeysRefusal(raw, validKeys, subject, operation) {
|
|
|
19998
20434
|
}
|
|
19999
20435
|
|
|
20000
20436
|
// src/resources/special/inventoryLocations.ts
|
|
20001
|
-
var
|
|
20437
|
+
var fail2 = (message) => {
|
|
20002
20438
|
throw new AutotaskConfigError(`inventory_locations: ${message}`);
|
|
20003
20439
|
};
|
|
20004
20440
|
function admitInventoryLocation(value, creating) {
|
|
20005
|
-
if (!isRecord2(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value)))
|
|
20441
|
+
if (!isRecord2(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail2("data must be a plain record");
|
|
20006
20442
|
const body = { ...value };
|
|
20007
|
-
for (const field of Object.keys(body)) if (!["locationName", "isActive"].includes(field))
|
|
20443
|
+
for (const field of Object.keys(body)) if (!["locationName", "isActive"].includes(field)) fail2(`${field} is not a writable InventoryLocations field`);
|
|
20008
20444
|
const hasName = Object.hasOwn(body, "locationName");
|
|
20009
20445
|
const hasActive = Object.hasOwn(body, "isActive");
|
|
20010
|
-
if (creating && !hasName || hasName && (typeof body.locationName !== "string" || body.locationName.trim() === "" || body.locationName.length > 50))
|
|
20011
|
-
if (creating && !hasActive || hasActive && typeof body.isActive !== "boolean")
|
|
20012
|
-
if (!creating && !hasName && !hasActive)
|
|
20446
|
+
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");
|
|
20447
|
+
if (creating && !hasActive || hasActive && typeof body.isActive !== "boolean") fail2("isActive must be a boolean");
|
|
20448
|
+
if (!creating && !hasName && !hasActive) fail2("update must contain locationName or isActive");
|
|
20013
20449
|
return body;
|
|
20014
20450
|
}
|
|
20015
20451
|
function checkInventoryLocationCurrent(value, current, id) {
|
|
20016
|
-
if (!isRecord2(current) || !Object.hasOwn(current, "id"))
|
|
20017
|
-
if (parseIdentifier(current.id, "inventory_locations: current id") !== id)
|
|
20018
|
-
if (Object.hasOwn(value, "isActive") && value.isActive === false && (!Object.hasOwn(current, "isDefault") || current.isDefault !== false))
|
|
20452
|
+
if (!isRecord2(current) || !Object.hasOwn(current, "id")) fail2("current record requires its own id");
|
|
20453
|
+
if (parseIdentifier(current.id, "inventory_locations: current id") !== id) fail2("current record id must match the requested id");
|
|
20454
|
+
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");
|
|
20019
20455
|
}
|
|
20020
20456
|
|
|
20021
20457
|
// src/resources/base/types.ts
|
|
@@ -20185,6 +20621,7 @@ var MODEL_FIELD_SETS = {
|
|
|
20185
20621
|
"holiday_sets": ["id", "holidaySetDescription", "holidaySetName"],
|
|
20186
20622
|
"holidays": ["id", "holidayDate", "holidayName", "holidaySetID", "soapParentPropertyId"],
|
|
20187
20623
|
"internal_locations": ["id", "additionalAddressInfo", "address1", "address2", "city", "country", "holidaySetId", "isDefault", "name", "postalCode", "state", "timeZone"],
|
|
20624
|
+
"inventory_items": ["id", "backOrderQuantity", "bin", "impersonatorCreatorResourceID", "inventoryLocationID", "productID", "quantityMaximum", "quantityMinimum", "quantityOnHand", "quantityOnOrder", "quantityPicked", "quantityReserved", "referenceNumber"],
|
|
20188
20625
|
"inventory_locations": ["id", "impersonatorCreatorResourceID", "isActive", "isDefault", "locationName", "resourceID"],
|
|
20189
20626
|
"inventory_products": ["id", "availableUnits", "backOrderQuantity", "bin", "createDateTime", "createdByResourceID", "inventoryLocationID", "onHandUnits", "pickedUnits", "productID", "quantityMaximum", "quantityMinimum", "referenceNumber", "reservedUnits", "unitsOnOrder"],
|
|
20190
20627
|
"invoice_templates": ["id", "coveredByBlockRetainerContractLabel", "coveredByRecurringServiceFixedPricePerTicketContractLabel", "currencyNegativeFormat", "currencyPositiveFormat", "dateFormat", "displayFixedPriceContractLabor", "displayRecurringServiceContractLabor", "displaySeparateLineItemForEachTax", "displayTaxCategory", "displayTaxCategorySuperscripts", "displayZeroAmountRecurringServicesAndBundles", "groupBy", "itemizeItemsInEachGroup", "itemizeServicesAndBundles", "name", "nonBillableLaborLabel", "numberFormat", "pageLayout", "pageNumberFormat", "paymentTerms", "rateCostExpression", "showGridHeader", "showVerticalGridLines", "sortBy", "timeFormat"],
|
|
@@ -20426,27 +20863,28 @@ function validateRelationLeaves(resourceKey, conditions, op) {
|
|
|
20426
20863
|
assertUndottedUdfField(c, op);
|
|
20427
20864
|
const field = c.field;
|
|
20428
20865
|
const [rel, sub, ...rest] = field.split(".");
|
|
20429
|
-
const
|
|
20866
|
+
const fail5 = (why) => {
|
|
20430
20867
|
throw new AutotaskConfigError(`${op}: relation filter "${field}" ${why} \u2014 the request was not issued`, {
|
|
20431
20868
|
operation: op,
|
|
20432
20869
|
suggestedAction: valid.length > 0 ? `Use ${valid.map((r) => `${r}.<${RELATION_TARGETS[r].resource} field>`).join(" or ")} (one hop; field names from operations.fieldCatalog).` : `${resourceKey} has no relation filters; filter on its own fields.`
|
|
20433
20870
|
});
|
|
20434
20871
|
};
|
|
20435
20872
|
if (selfPrefixes(resourceKey).includes(rel)) {
|
|
20436
|
-
if (rest.length > 0 || !sub)
|
|
20873
|
+
if (rest.length > 0 || !sub) fail5("is not <resource>.<field> (multi-hop relations are not supported)");
|
|
20437
20874
|
continue;
|
|
20438
20875
|
}
|
|
20439
|
-
if (rest.length > 0 || !sub)
|
|
20440
|
-
if (!valid.includes(rel))
|
|
20876
|
+
if (rest.length > 0 || !sub) fail5("is not <relation>.<field> (multi-hop relations are not supported)");
|
|
20877
|
+
if (!valid.includes(rel)) fail5(`names an unknown relation for ${resourceKey} (valid: ${valid.join(", ") || "none"})`);
|
|
20441
20878
|
const parentFields = MODEL_FIELD_SETS[RELATION_TARGETS[rel].resource];
|
|
20442
20879
|
if (parentFields !== void 0 && modelFieldLookup(RELATION_TARGETS[rel].resource)?.(sub) !== true) {
|
|
20443
|
-
|
|
20880
|
+
fail5(`names a field unknown on ${RELATION_TARGETS[rel].resource}`);
|
|
20444
20881
|
}
|
|
20445
20882
|
}
|
|
20446
20883
|
};
|
|
20447
20884
|
walk(conditions);
|
|
20448
20885
|
}
|
|
20449
20886
|
async function rewriteRelationFilters(http, resourceKey, conditions, op) {
|
|
20887
|
+
assertSupportedUdfConditions(conditions, op);
|
|
20450
20888
|
if (!hasRelationConditions(conditions)) return void 0;
|
|
20451
20889
|
const conds = conditions;
|
|
20452
20890
|
validateRelationLeaves(resourceKey, conds, op);
|
|
@@ -20799,11 +21237,13 @@ var QueryBase = class {
|
|
|
20799
21237
|
walkPageSize(params) {
|
|
20800
21238
|
return clampPageSize(params?.maxRecords ?? this.defaultPageSize);
|
|
20801
21239
|
}
|
|
21240
|
+
/** Capture mutable input for Knowledge Base and InventoryItems reads. */
|
|
20802
21241
|
snapshotKnowledgeBaseQuery(params) {
|
|
20803
|
-
|
|
21242
|
+
const knowledgeBase = isKnowledgeBaseRootResource(this.config.key);
|
|
21243
|
+
if ((knowledgeBase || this.config.key === "inventory_items") && isRecord2(params)) {
|
|
20804
21244
|
const captured = snapshotQueryBag(params, QUERY_BAG_KEYS);
|
|
20805
21245
|
const conditions = Array.isArray(captured.filter) ? captured.filter : captured.filter?.filter;
|
|
20806
|
-
if (conditions?.length === 0) delete captured.filter;
|
|
21246
|
+
if (knowledgeBase && conditions?.length === 0) delete captured.filter;
|
|
20807
21247
|
return captured;
|
|
20808
21248
|
}
|
|
20809
21249
|
return params;
|
|
@@ -20844,7 +21284,7 @@ var QueryBase = class {
|
|
|
20844
21284
|
}
|
|
20845
21285
|
/** Stream page objects (the resource `queryPages` surface; relation filters resolve first, #281). */
|
|
20846
21286
|
async *queryPageIter(params) {
|
|
20847
|
-
const walk = await this.relationWalkParams(params, `${this.config.key}.query`);
|
|
21287
|
+
const walk = await this.relationWalkParams(this.snapshotKnowledgeBaseQuery(params), `${this.config.key}.query`);
|
|
20848
21288
|
if (walk === void 0) return;
|
|
20849
21289
|
yield* paginate(this.pageFetcher(walk), { pageSize: this.walkPageSize(walk), continueOnEmpty: this.continueAcrossEmptyPage() });
|
|
20850
21290
|
}
|
|
@@ -21881,26 +22321,26 @@ var MetaBase = class _MetaBase extends QueryBase {
|
|
|
21881
22321
|
|
|
21882
22322
|
// src/resources/special/knowledgeBaseCategories.ts
|
|
21883
22323
|
function admitKnowledgeBaseCategory(data, creating, staleToken) {
|
|
21884
|
-
const
|
|
22324
|
+
const fail5 = (message) => {
|
|
21885
22325
|
throw new AutotaskConfigError(`knowledge_base_categories: ${message}`);
|
|
21886
22326
|
};
|
|
21887
|
-
if (!creating && staleToken !== void 0)
|
|
21888
|
-
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
22327
|
+
if (!creating && staleToken !== void 0) fail5("no documented stale timestamp is available");
|
|
22328
|
+
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail5("data must be a plain record");
|
|
21889
22329
|
const body = { ...data };
|
|
21890
|
-
for (const field of Object.keys(body)) if (!["name", "description", "parentCategoryID"].includes(field))
|
|
22330
|
+
for (const field of Object.keys(body)) if (!["name", "description", "parentCategoryID"].includes(field)) fail5(`${field} is not a writable KnowledgeBaseCategories field`);
|
|
21891
22331
|
for (const [field, max] of [["name", 50], ["description", 1e3]]) {
|
|
21892
22332
|
const value = body[field];
|
|
21893
|
-
if (value !== void 0 && (typeof value !== "string" || value.length > max))
|
|
22333
|
+
if (value !== void 0 && (typeof value !== "string" || value.length > max)) fail5(`${field} must be a string of at most ${max} characters`);
|
|
21894
22334
|
}
|
|
21895
|
-
if ((creating || body.name !== void 0) && (typeof body.name !== "string" || body.name.trim() === ""))
|
|
21896
|
-
if (creating && body.parentCategoryID === void 0)
|
|
22335
|
+
if ((creating || body.name !== void 0) && (typeof body.name !== "string" || body.name.trim() === "")) fail5("name is required");
|
|
22336
|
+
if (creating && body.parentCategoryID === void 0) fail5("parentCategoryID is required; choose a documented visible category rather than guessing a root id");
|
|
21897
22337
|
const parent = body.parentCategoryID;
|
|
21898
22338
|
if (parent !== void 0) {
|
|
21899
|
-
if (typeof parent !== "number") return
|
|
22339
|
+
if (typeof parent !== "number") return fail5("parentCategoryID must be a numeric identifier");
|
|
21900
22340
|
parseIdentifier(parent, "parentCategoryID");
|
|
21901
|
-
if (parent > 2147483647)
|
|
22341
|
+
if (parent > 2147483647) fail5("parentCategoryID must fit a signed 32-bit integer");
|
|
21902
22342
|
}
|
|
21903
|
-
if (!creating && !Object.values(body).some((value) => value !== void 0))
|
|
22343
|
+
if (!creating && !Object.values(body).some((value) => value !== void 0)) fail5("update must contain a writable field");
|
|
21904
22344
|
return body;
|
|
21905
22345
|
}
|
|
21906
22346
|
function categoryReplacement(body) {
|
|
@@ -21914,45 +22354,45 @@ function categoryReplacement(body) {
|
|
|
21914
22354
|
}
|
|
21915
22355
|
|
|
21916
22356
|
// src/resources/special/knowledgeBaseArticles.ts
|
|
21917
|
-
function
|
|
22357
|
+
function fail3(detail) {
|
|
21918
22358
|
throw new AutotaskConfigError(`knowledge_base_articles: ${detail}`);
|
|
21919
22359
|
}
|
|
21920
22360
|
function reference(value, name) {
|
|
21921
|
-
if (typeof value !== "number")
|
|
22361
|
+
if (typeof value !== "number") fail3(`${name} must be a numeric identifier`);
|
|
21922
22362
|
parseIdentifier(value, name);
|
|
21923
|
-
if (value > 2147483647)
|
|
22363
|
+
if (value > 2147483647) fail3(`${name} must fit a signed 32-bit integer`);
|
|
21924
22364
|
return value;
|
|
21925
22365
|
}
|
|
21926
22366
|
function articleParent(value) {
|
|
21927
22367
|
const parent = parseIdentifier(value, "parentId");
|
|
21928
|
-
if (typeof parent !== "number" || parent > 2147483647)
|
|
21929
|
-
if (parent === 0)
|
|
22368
|
+
if (typeof parent !== "number" || parent > 2147483647) fail3("parentId must fit a signed 32-bit category identifier");
|
|
22369
|
+
if (parent === 0) fail3("parentId must name an article category");
|
|
21930
22370
|
return parent;
|
|
21931
22371
|
}
|
|
21932
22372
|
function admitArticle(data, parentId, creating) {
|
|
21933
22373
|
const parent = articleParent(parentId);
|
|
21934
|
-
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
22374
|
+
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail3("data must be a plain record");
|
|
21935
22375
|
const body = { ...data };
|
|
21936
22376
|
const allowed = ["articleCategoryID", "publish", "title", "errorCodes", "keywords", "referenceLink", "isActive"];
|
|
21937
22377
|
for (const key of Object.keys(body)) {
|
|
21938
|
-
if (!allowed.includes(key))
|
|
22378
|
+
if (!allowed.includes(key)) fail3(`${key} is not a writable article root field`);
|
|
21939
22379
|
if (key !== "articleCategoryID" && body[key] === void 0) delete body[key];
|
|
21940
22380
|
}
|
|
21941
22381
|
for (const [field, max] of [["title", 200], ["errorCodes", 200], ["keywords", 300], ["referenceLink", 500]]) {
|
|
21942
|
-
if (Object.hasOwn(body, field) && (typeof body[field] !== "string" || body[field].length > max))
|
|
21943
|
-
}
|
|
21944
|
-
if ((creating || Object.hasOwn(body, "title")) && (typeof body.title !== "string" || !body.title.trim()))
|
|
21945
|
-
if (!creating && Object.hasOwn(body, "articleCategoryID"))
|
|
21946
|
-
if (creating && String(reference(body.articleCategoryID, "articleCategoryID")) !== String(parent))
|
|
21947
|
-
if ((creating || Object.hasOwn(body, "publish")) && (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish) || body.publish < -2147483648 || body.publish > 2147483647))
|
|
21948
|
-
if (Object.hasOwn(body, "isActive") && typeof body.isActive !== "boolean")
|
|
21949
|
-
if (!creating && !Object.keys(body).length)
|
|
22382
|
+
if (Object.hasOwn(body, field) && (typeof body[field] !== "string" || body[field].length > max)) fail3(`${field} must be a string of at most ${max} characters`);
|
|
22383
|
+
}
|
|
22384
|
+
if ((creating || Object.hasOwn(body, "title")) && (typeof body.title !== "string" || !body.title.trim())) fail3("title is required and cannot be blank");
|
|
22385
|
+
if (!creating && Object.hasOwn(body, "articleCategoryID")) fail3("articleCategoryID is read-only after creation");
|
|
22386
|
+
if (creating && String(reference(body.articleCategoryID, "articleCategoryID")) !== String(parent)) fail3("articleCategoryID must match parentId");
|
|
22387
|
+
if ((creating || Object.hasOwn(body, "publish")) && (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish) || body.publish < -2147483648 || body.publish > 2147483647)) fail3("publish must be an int32 from current field metadata");
|
|
22388
|
+
if (Object.hasOwn(body, "isActive") && typeof body.isActive !== "boolean") fail3("isActive must be boolean");
|
|
22389
|
+
if (!creating && !Object.keys(body).length) fail3("update must contain a writable field");
|
|
21950
22390
|
return body;
|
|
21951
22391
|
}
|
|
21952
22392
|
async function guardArticle(http, parentId, id, maxRetries) {
|
|
21953
22393
|
const parent = articleParent(parentId);
|
|
21954
22394
|
const target = id === void 0 ? void 0 : parseIdentifier(id, "id");
|
|
21955
|
-
if (target !== void 0 && (target === 0 || !isAuditDecimalId(String(target))))
|
|
22395
|
+
if (target !== void 0 && (target === 0 || !isAuditDecimalId(String(target)))) fail3("id must name an article within the signed 64-bit range");
|
|
21956
22396
|
unwrapItem(await http.request({ method: "GET", path: `/V1.0/KnowledgeBaseCategories/${parent}`, operation: "knowledge_base_categories.get", maxRetries }), parent, "knowledge_base_categories.get", "article_category");
|
|
21957
22397
|
if (target !== void 0) {
|
|
21958
22398
|
return unwrapItem(await http.request({ method: "GET", path: `/V1.0/KnowledgeBaseCategories/${parent}/KnowledgeBaseArticles/${target}`, operation: "knowledge_base_articles.get", maxRetries }), target, "knowledge_base_articles.get", "article");
|
|
@@ -21961,7 +22401,7 @@ async function guardArticle(http, parentId, id, maxRetries) {
|
|
|
21961
22401
|
}
|
|
21962
22402
|
function assertArticlePublish(data, fields) {
|
|
21963
22403
|
if (!Object.hasOwn(data, "publish")) return;
|
|
21964
|
-
const unavailable = () =>
|
|
22404
|
+
const unavailable = () => fail3("publish requires an unambiguous active value in current field metadata");
|
|
21965
22405
|
if (!Array.isArray(fields)) unavailable();
|
|
21966
22406
|
const rows = fields.filter((field) => isRecord2(field) && field.name === "publish");
|
|
21967
22407
|
if (rows.length !== 1 || rows[0].isPickList !== true || rows[0].isReadOnly !== false || !Array.isArray(rows[0].picklistValues)) unavailable();
|
|
@@ -21995,14 +22435,15 @@ var MutationBase = class extends MetaBase {
|
|
|
21995
22435
|
return body;
|
|
21996
22436
|
}
|
|
21997
22437
|
/** `POST /V1.0/<E>` → `{ id }` (issue #13: a drifted 2xx runs the bounded marker recovery where the plan pins a marker field). */
|
|
21998
|
-
async createGlobal(data, opts = {}) {
|
|
22438
|
+
async createGlobal(data, opts = {}, checkedBaseUrl) {
|
|
21999
22439
|
const body = this.normalizeMutationBody(data);
|
|
22000
22440
|
const res = await this.http.request({
|
|
22001
22441
|
method: "POST",
|
|
22002
22442
|
path: this.resourcePath,
|
|
22003
22443
|
body,
|
|
22004
22444
|
operation: `${this.config.key}.create`,
|
|
22005
|
-
maxRetries: opts.maxRetries
|
|
22445
|
+
maxRetries: opts.maxRetries,
|
|
22446
|
+
...checkedBaseUrl === void 0 ? {} : { checkedBaseUrl, maintenanceMaxWaitMs: 0 }
|
|
22006
22447
|
});
|
|
22007
22448
|
return this.unwrapCreateOperation(res, body, opts);
|
|
22008
22449
|
}
|
|
@@ -22174,11 +22615,12 @@ var MutationBase = class extends MetaBase {
|
|
|
22174
22615
|
const stored = parentId === void 0 ? await this.getGlobal(id, true, maxRetries, checkedBaseUrl) : this.config.attachmentGet === true ? await this.getScopedModel(parentId, id, true) : await this.getScopedRaw(parentId, id, true, maxRetries);
|
|
22175
22616
|
const submitted = data;
|
|
22176
22617
|
const persisted = stored;
|
|
22177
|
-
|
|
22178
|
-
|
|
22618
|
+
const inventory = this.config.key === "inventory_locations" || this.config.key === "inventory_items";
|
|
22619
|
+
if (inventory) {
|
|
22620
|
+
if (!Object.hasOwn(persisted, "id")) throw new AutotaskConfigError(`${this.config.key}: persisted record requires its own id`);
|
|
22179
22621
|
validateExactRecordResponse({ item: persisted }, "item", `${this.resourcePath}/${parseIdentifier(id, "id")}`, "GET", void 0, `${this.config.key}.get`);
|
|
22180
22622
|
}
|
|
22181
|
-
const notPersisted =
|
|
22623
|
+
const notPersisted = inventory ? Object.keys(submitted).filter((field) => !Object.hasOwn(persisted, field) || submitted[field] !== persisted[field]) : notPersistedFields(submitted, persisted);
|
|
22182
22624
|
return { ...result, notPersisted };
|
|
22183
22625
|
} catch (err) {
|
|
22184
22626
|
return { ...result, persistedCheckFailed: err instanceof AutotaskError ? err.code : `UNKNOWN (${err instanceof Error ? err.name : typeof err})` };
|
|
@@ -22565,9 +23007,14 @@ var MutationBase = class extends MetaBase {
|
|
|
22565
23007
|
const method = scopedUpdate || partialCollection !== void 0 ? "PATCH" : "PUT";
|
|
22566
23008
|
let current;
|
|
22567
23009
|
try {
|
|
22568
|
-
current = currentRecord ?? (parentId === void 0 ? await this.getGlobal(id, true, this.config.key === "knowledge_base_categories" || partialCollection !== void 0 ? opts.maxRetries : void 0) : this.config.attachmentGet ? await this.getScopedModel(parentId, id, true) : await this.getScopedRaw(parentId, id, true));
|
|
23010
|
+
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));
|
|
22569
23011
|
} catch (err) {
|
|
22570
23012
|
if (err instanceof NotFoundError) {
|
|
23013
|
+
if (this.config.key === "inventory_items" && opts.expectedInventoryFacts !== void 0) {
|
|
23014
|
+
if (err.httpStatus === 200) inventoryFactsStale(operation);
|
|
23015
|
+
Object.assign(err, { notSent: true });
|
|
23016
|
+
throw err;
|
|
23017
|
+
}
|
|
22571
23018
|
const reasons = EMPTY_REASON_STAMPS[this.config.key];
|
|
22572
23019
|
const updateReason = reasons?.update ?? (partialCollection === void 0 ? void 0 : reasons?.get);
|
|
22573
23020
|
checks.push({
|
|
@@ -22591,7 +23038,7 @@ var MutationBase = class extends MetaBase {
|
|
|
22591
23038
|
throw err;
|
|
22592
23039
|
}
|
|
22593
23040
|
checks.push({ name: "current-record-exists", ok: true });
|
|
22594
|
-
partialCollection
|
|
23041
|
+
if (partialCollection !== void 0) await partialCollection.checkCurrent(current);
|
|
22595
23042
|
if (this.staleObjectCheck(current, opts, operation)) {
|
|
22596
23043
|
checks.push({ name: "stale-check", ok: true });
|
|
22597
23044
|
}
|
|
@@ -22673,34 +23120,34 @@ var BaseResource = class extends MutationBase {
|
|
|
22673
23120
|
};
|
|
22674
23121
|
|
|
22675
23122
|
// src/resources/special/taskPredecessors.ts
|
|
22676
|
-
function
|
|
23123
|
+
function fail4(detail) {
|
|
22677
23124
|
throw new AutotaskConfigError(`task_predecessors: ${detail}`);
|
|
22678
23125
|
}
|
|
22679
23126
|
function numeric(value, field) {
|
|
22680
|
-
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0)
|
|
23127
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) fail4(`${field} must be a positive numeric identifier`);
|
|
22681
23128
|
return value;
|
|
22682
23129
|
}
|
|
22683
23130
|
function predecessorParent(value) {
|
|
22684
23131
|
const parent = parseIdentifier(value, "parentId");
|
|
22685
|
-
if (parent === 0)
|
|
23132
|
+
if (parent === 0) fail4("parentId must name a successor task");
|
|
22686
23133
|
return parent;
|
|
22687
23134
|
}
|
|
22688
23135
|
function assertPredecessorBinding(value, parentId, id) {
|
|
22689
|
-
if (!isRecord2(value))
|
|
22690
|
-
if (String(parseIdentifier(value.id, "record.id")) !== String(parseIdentifier(id, "id")) || String(parseIdentifier(value.successorTaskID, "record.successorTaskID")) !== String(predecessorParent(parentId)))
|
|
23136
|
+
if (!isRecord2(value)) fail4("the returned record must establish id and successorTaskID parent");
|
|
23137
|
+
if (String(parseIdentifier(value.id, "record.id")) !== String(parseIdentifier(id, "id")) || String(parseIdentifier(value.successorTaskID, "record.successorTaskID")) !== String(predecessorParent(parentId))) fail4("the returned record must match id and successorTaskID parent");
|
|
22691
23138
|
}
|
|
22692
23139
|
function admitTaskPredecessor(data, parentId, creating) {
|
|
22693
23140
|
const parent = predecessorParent(parentId);
|
|
22694
|
-
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
23141
|
+
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail4("data must be a plain record");
|
|
22695
23142
|
const payload = { ...data };
|
|
22696
23143
|
const allowed = creating ? ["predecessorTaskID", "successorTaskID", "lagDays"] : ["lagDays"];
|
|
22697
|
-
if (Object.keys(payload).some((key) => !allowed.includes(key)))
|
|
22698
|
-
if ((!creating || payload.lagDays !== void 0) && (typeof payload.lagDays !== "number" || !Number.isInteger(payload.lagDays) || payload.lagDays < -2147483648 || payload.lagDays > 2147483647))
|
|
23144
|
+
if (Object.keys(payload).some((key) => !allowed.includes(key))) fail4(creating ? "only predecessorTaskID, successorTaskID and lagDays are writable on create" : "only lagDays can be updated");
|
|
23145
|
+
if ((!creating || payload.lagDays !== void 0) && (typeof payload.lagDays !== "number" || !Number.isInteger(payload.lagDays) || payload.lagDays < -2147483648 || payload.lagDays > 2147483647)) fail4("lagDays must be an int32 integer");
|
|
22699
23146
|
if (creating) {
|
|
22700
23147
|
const successor = numeric(payload.successorTaskID, "successorTaskID");
|
|
22701
23148
|
const predecessor = numeric(payload.predecessorTaskID, "predecessorTaskID");
|
|
22702
|
-
if (String(successor) !== String(parent))
|
|
22703
|
-
if (predecessor === successor)
|
|
23149
|
+
if (String(successor) !== String(parent)) fail4("successorTaskID must match parentId");
|
|
23150
|
+
if (predecessor === successor) fail4("predecessorTaskID and successorTaskID must be distinct");
|
|
22704
23151
|
}
|
|
22705
23152
|
return payload;
|
|
22706
23153
|
}
|
|
@@ -22709,50 +23156,50 @@ async function guardTaskPredecessor(http, parentId, id, data) {
|
|
|
22709
23156
|
let row = data;
|
|
22710
23157
|
if (id !== void 0) {
|
|
22711
23158
|
const target = parseIdentifier(id, "id");
|
|
22712
|
-
if (target === 0)
|
|
23159
|
+
if (target === 0) fail4("id must name a predecessor relationship");
|
|
22713
23160
|
row = unwrapItem(await http.request({ method: "GET", path: `/V1.0/Tasks/${parent}/Predecessors/${target}`, operation: "task_predecessors.get" }), target, "task_predecessors.get", "task_predecessor");
|
|
22714
23161
|
assertPredecessorBinding(row, parent, target);
|
|
22715
23162
|
}
|
|
22716
23163
|
const predecessor = numeric(row?.predecessorTaskID, "predecessorTaskID");
|
|
22717
23164
|
const successor = numeric(row?.successorTaskID, "successorTaskID");
|
|
22718
|
-
if (predecessor === successor)
|
|
23165
|
+
if (predecessor === successor) fail4("predecessorTaskID and successorTaskID must be distinct");
|
|
22719
23166
|
const projects = [];
|
|
22720
23167
|
for (const taskId of [predecessor, successor]) {
|
|
22721
23168
|
const task = unwrapItem(await http.request({ method: "GET", path: `/V1.0/Tasks/${taskId}`, operation: "tasks.get" }), taskId, "tasks.get", "task");
|
|
22722
|
-
if (String(parseIdentifier(task.id, "task.id")) !== String(taskId))
|
|
23169
|
+
if (String(parseIdentifier(task.id, "task.id")) !== String(taskId)) fail4("the returned task must match its requested id");
|
|
22723
23170
|
projects.push(numeric(task.projectID, "task.projectID"));
|
|
22724
23171
|
}
|
|
22725
|
-
if (projects[0] !== projects[1])
|
|
23172
|
+
if (projects[0] !== projects[1]) fail4("predecessor and successor tasks must belong to the same project");
|
|
22726
23173
|
}
|
|
22727
23174
|
|
|
22728
23175
|
// src/resources/special/taskNotes.ts
|
|
22729
23176
|
var WRITABLE = /* @__PURE__ */ new Set(["id", "itemId", "createdByContactID", "description", "noteType", "publish", "taskID", "title"]);
|
|
22730
23177
|
function admitTaskNote(data, parentId, creating) {
|
|
22731
23178
|
const parent = parseIdentifier(parentId, "parentId");
|
|
22732
|
-
const
|
|
23179
|
+
const fail5 = (message) => {
|
|
22733
23180
|
throw new AutotaskConfigError(`task_notes: ${message}`);
|
|
22734
23181
|
};
|
|
22735
|
-
if (data === null || typeof data !== "object" || Array.isArray(data))
|
|
23182
|
+
if (data === null || typeof data !== "object" || Array.isArray(data)) fail5("data must be a record");
|
|
22736
23183
|
const body = data;
|
|
22737
|
-
for (const key of Object.keys(body)) if (!WRITABLE.has(key))
|
|
23184
|
+
for (const key of Object.keys(body)) if (!WRITABLE.has(key)) fail5(`${key} is not a writable TaskNotes field`);
|
|
22738
23185
|
for (const [field, maximum] of [["description", 3200], ["title", 250]]) {
|
|
22739
23186
|
const value = body[field];
|
|
22740
|
-
if (value !== void 0 && (typeof value !== "string" || value.length > maximum))
|
|
23187
|
+
if (value !== void 0 && (typeof value !== "string" || value.length > maximum)) fail5(`${field} must be a string of at most ${maximum} characters`);
|
|
22741
23188
|
}
|
|
22742
|
-
if (creating && (typeof body.description !== "string" || body.description.trim() === ""))
|
|
23189
|
+
if (creating && (typeof body.description !== "string" || body.description.trim() === "")) fail5("description is required");
|
|
22743
23190
|
for (const field of ["noteType", "publish"]) {
|
|
22744
23191
|
const value = body[field];
|
|
22745
|
-
if ((creating || value !== void 0) && (typeof value !== "number" || !Number.isSafeInteger(value)))
|
|
23192
|
+
if ((creating || value !== void 0) && (typeof value !== "number" || !Number.isSafeInteger(value))) fail5(`${field} must be an integer from the current field metadata`);
|
|
22746
23193
|
}
|
|
22747
|
-
if (creating && body.taskID === void 0)
|
|
23194
|
+
if (creating && body.taskID === void 0) fail5("taskID is required in the create body and must match parentId");
|
|
22748
23195
|
for (const field of ["createdByContactID", "taskID"]) {
|
|
22749
23196
|
if (body[field] !== void 0) {
|
|
22750
|
-
if (typeof body[field] !== "number")
|
|
23197
|
+
if (typeof body[field] !== "number") fail5(`${field} must be a numeric identifier`);
|
|
22751
23198
|
const id = parseIdentifier(body[field], field);
|
|
22752
|
-
if (field === "taskID" && String(id) !== String(parent))
|
|
23199
|
+
if (field === "taskID" && String(id) !== String(parent)) fail5("taskID must match the parentId path argument");
|
|
22753
23200
|
}
|
|
22754
23201
|
}
|
|
22755
|
-
if (!creating && !Object.keys(body).some((key) => key !== "id" && key !== "itemId"))
|
|
23202
|
+
if (!creating && !Object.keys(body).some((key) => key !== "id" && key !== "itemId")) fail5("update must contain a writable field");
|
|
22756
23203
|
}
|
|
22757
23204
|
|
|
22758
23205
|
// src/operations/invoke/fieldSuggest.ts
|
|
@@ -22887,8 +23334,8 @@ function collectFilterFieldNames(conditions, resourceKey, operation = `${resourc
|
|
|
22887
23334
|
continue;
|
|
22888
23335
|
}
|
|
22889
23336
|
if (resourceKey !== void 0) {
|
|
22890
|
-
const
|
|
22891
|
-
if (
|
|
23337
|
+
const own2 = normalizeOwnField(resourceKey, cond.field);
|
|
23338
|
+
if (own2 !== cond.field) out.push(own2);
|
|
22892
23339
|
}
|
|
22893
23340
|
}
|
|
22894
23341
|
}
|
|
@@ -22980,6 +23427,7 @@ async function validateQueryFieldNames(record, holder, args) {
|
|
|
22980
23427
|
let filterNames;
|
|
22981
23428
|
if (bag["filter"] !== void 0) {
|
|
22982
23429
|
const conditions = normalizedConditions(bag["filter"]);
|
|
23430
|
+
assertSupportedUdfConditions(conditions, record.id);
|
|
22983
23431
|
filterNames = collectFilterFieldNames(conditions ?? [], record.resource, record.id);
|
|
22984
23432
|
}
|
|
22985
23433
|
if (fieldCheck === false) return;
|
|
@@ -23022,38 +23470,38 @@ function isBase64(value) {
|
|
|
23022
23470
|
}
|
|
23023
23471
|
function admitTaskAttachment(data, parentId) {
|
|
23024
23472
|
const parent = parseIdentifier(parentId, "parentId");
|
|
23025
|
-
const
|
|
23473
|
+
const fail5 = (message) => {
|
|
23026
23474
|
throw new AutotaskConfigError(`task_attachments: ${message}`);
|
|
23027
23475
|
};
|
|
23028
|
-
if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
23476
|
+
if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail5("data must be a plain record");
|
|
23029
23477
|
const body = data;
|
|
23030
|
-
for (const field of Object.keys(body)) if (!WRITABLE2.has(field))
|
|
23478
|
+
for (const field of Object.keys(body)) if (!WRITABLE2.has(field)) fail5(`${field} is not a supported create field`);
|
|
23031
23479
|
for (const field of ["attachmentType", "fullPath", "title"]) {
|
|
23032
|
-
if (typeof body[field] !== "string" || body[field].trim() === "")
|
|
23480
|
+
if (typeof body[field] !== "string" || body[field].trim() === "") fail5(`${field} is required and must be a non-empty string`);
|
|
23033
23481
|
}
|
|
23034
|
-
if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish))
|
|
23482
|
+
if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish)) fail5("publish must be an integer from current field metadata");
|
|
23035
23483
|
for (const field of ["data", "contentType"]) {
|
|
23036
|
-
if (body[field] !== void 0 && typeof body[field] !== "string")
|
|
23484
|
+
if (body[field] !== void 0 && typeof body[field] !== "string") fail5(`${field} must be a string`);
|
|
23037
23485
|
}
|
|
23038
23486
|
if (body.attachmentType === "FILE_ATTACHMENT") {
|
|
23039
|
-
if (typeof body.data !== "string" || body.data === "") return
|
|
23040
|
-
if (!isBase64(body.data))
|
|
23487
|
+
if (typeof body.data !== "string" || body.data === "") return fail5("FILE_ATTACHMENT requires non-empty base64 data");
|
|
23488
|
+
if (!isBase64(body.data)) fail5("FILE_ATTACHMENT data must be base64 encoded");
|
|
23041
23489
|
}
|
|
23042
23490
|
if (body.taskID !== void 0) {
|
|
23043
|
-
if (typeof body.taskID !== "number")
|
|
23044
|
-
if (String(parseIdentifier(body.taskID, "taskID")) !== String(parent))
|
|
23491
|
+
if (typeof body.taskID !== "number") fail5("taskID must be a numeric identifier");
|
|
23492
|
+
if (String(parseIdentifier(body.taskID, "taskID")) !== String(parent)) fail5("taskID must match the parentId path argument");
|
|
23045
23493
|
}
|
|
23046
23494
|
if (body.parentAttachmentID !== void 0) {
|
|
23047
|
-
if (typeof body.parentAttachmentID !== "number")
|
|
23495
|
+
if (typeof body.parentAttachmentID !== "number") fail5("parentAttachmentID must be a numeric identifier");
|
|
23048
23496
|
parseIdentifier(body.parentAttachmentID, "parentAttachmentID");
|
|
23049
23497
|
}
|
|
23050
23498
|
}
|
|
23051
23499
|
function admitFileAttachment(resource, data, parentId) {
|
|
23052
23500
|
parseIdentifier(parentId, "parentId");
|
|
23053
|
-
const
|
|
23501
|
+
const fail5 = (message) => {
|
|
23054
23502
|
throw new AutotaskConfigError(`${resource}: ${message}`);
|
|
23055
23503
|
};
|
|
23056
|
-
if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
23504
|
+
if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail5("data must be a plain record");
|
|
23057
23505
|
const body = data;
|
|
23058
23506
|
const reference2 = {
|
|
23059
23507
|
project_attachments: void 0,
|
|
@@ -23066,20 +23514,20 @@ function admitFileAttachment(resource, data, parentId) {
|
|
|
23066
23514
|
configuration_item_attachments: "parentAttachmentID",
|
|
23067
23515
|
configuration_item_note_attachments: void 0
|
|
23068
23516
|
}[resource];
|
|
23069
|
-
for (const field of Object.keys(body)) if (!FILE_WRITABLE.has(field) && field !== reference2)
|
|
23070
|
-
if (body.attachmentType !== "FILE_ATTACHMENT")
|
|
23517
|
+
for (const field of Object.keys(body)) if (!FILE_WRITABLE.has(field) && field !== reference2) fail5(`${field} is not a supported create field`);
|
|
23518
|
+
if (body.attachmentType !== "FILE_ATTACHMENT") fail5("attachmentType must explicitly be FILE_ATTACHMENT; other attachment types are unsupported");
|
|
23071
23519
|
const maxLength = resource === "project_attachments" ? void 0 : 255;
|
|
23072
23520
|
for (const field of ["fullPath", "title"]) {
|
|
23073
23521
|
const value = body[field];
|
|
23074
23522
|
const requirement = `${field} is required and must be a nonblank string${maxLength === void 0 ? "" : ` of at most ${maxLength} characters`}`;
|
|
23075
|
-
if (typeof value !== "string" || value.trim() === "") return
|
|
23076
|
-
if (maxLength !== void 0 && value.length > maxLength)
|
|
23523
|
+
if (typeof value !== "string" || value.trim() === "") return fail5(requirement);
|
|
23524
|
+
if (maxLength !== void 0 && value.length > maxLength) fail5(requirement);
|
|
23077
23525
|
}
|
|
23078
|
-
if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish))
|
|
23079
|
-
if (typeof body.data !== "string" || !isBase64(body.data))
|
|
23526
|
+
if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish)) fail5("publish must be an integer from current field metadata");
|
|
23527
|
+
if (typeof body.data !== "string" || !isBase64(body.data)) fail5("FILE_ATTACHMENT requires nonempty base64 data");
|
|
23080
23528
|
if (reference2 !== void 0 && body[reference2] !== void 0) {
|
|
23081
|
-
if (typeof body[reference2] !== "number")
|
|
23082
|
-
if (parseIdentifier(body[reference2], reference2) === 0)
|
|
23529
|
+
if (typeof body[reference2] !== "number") fail5(`${reference2} must be a numeric identifier`);
|
|
23530
|
+
if (parseIdentifier(body[reference2], reference2) === 0) fail5(`${reference2} must be positive`);
|
|
23083
23531
|
}
|
|
23084
23532
|
}
|
|
23085
23533
|
function admitScopedAttachmentQuery(resource, params) {
|
|
@@ -23938,6 +24386,16 @@ var SIMPLE_RESOURCES = [
|
|
|
23938
24386
|
helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
|
|
23939
24387
|
opForms: { get: "global" }
|
|
23940
24388
|
},
|
|
24389
|
+
{
|
|
24390
|
+
key: "inventory_items",
|
|
24391
|
+
accessor: "inventoryItems",
|
|
24392
|
+
resourcePath: "/V1.0/InventoryItems",
|
|
24393
|
+
deletable: false,
|
|
24394
|
+
udfCapable: false,
|
|
24395
|
+
ops: { query: true, queryAll: false, count: true, get: true, create: true, update: true, delete: false, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
|
|
24396
|
+
helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
|
|
24397
|
+
opForms: { get: "global", create: "global", update: "global" }
|
|
24398
|
+
},
|
|
23941
24399
|
{
|
|
23942
24400
|
key: "inventory_locations",
|
|
23943
24401
|
accessor: "inventoryLocations",
|
|
@@ -24853,7 +25311,7 @@ var GenericResource = class extends BaseResource {
|
|
|
24853
25311
|
if (["company_attachments", "company_note_attachments", "configuration_item_attachments", "configuration_item_note_attachments", "contract_note_attachments", "expense_report_attachments", "project_attachments", "project_note_attachments", "resource_attachments", "sales_order_attachments", "task_attachments", "task_note_attachments"].includes(config.key)) this.getUdfInfo = async () => {
|
|
24854
25312
|
throw new OperationNotSupportedError(config.key, "getUdfInfo");
|
|
24855
25313
|
};
|
|
24856
|
-
if (config.ops?.create === false || isScopedAttachmentResource(config.key) || ["company_attachments", "task_predecessors", "knowledge_base_articles", "inventory_locations"].includes(config.key)) this.createIfNotExists = async () => {
|
|
25314
|
+
if (config.ops?.create === false || isScopedAttachmentResource(config.key) || ["company_attachments", "task_predecessors", "knowledge_base_articles", "inventory_locations", "inventory_items"].includes(config.key)) this.createIfNotExists = async () => {
|
|
24857
25315
|
throw new OperationNotSupportedError(config.key, "createIfNotExists");
|
|
24858
25316
|
};
|
|
24859
25317
|
if (config.key === "knowledge_base_categories") {
|
|
@@ -24946,6 +25404,7 @@ var GenericResource = class extends BaseResource {
|
|
|
24946
25404
|
}
|
|
24947
25405
|
async create(a, b = void 0, c = void 0) {
|
|
24948
25406
|
this.requireOp("create");
|
|
25407
|
+
rejectInventoryFactsOption(isIdentifier(a) ? c : b, `${this.config.key}.create`);
|
|
24949
25408
|
if (isIdentifier(a)) {
|
|
24950
25409
|
if (this.config.opForms?.create === "global") throw new OperationNotSupportedError(this.config.key, "create");
|
|
24951
25410
|
const parentId = this.config.key === "knowledge_base_articles" ? articleParent(a) : a;
|
|
@@ -24968,6 +25427,19 @@ var GenericResource = class extends BaseResource {
|
|
|
24968
25427
|
return this.createScopedRaw(parentId, data2, opts2);
|
|
24969
25428
|
}
|
|
24970
25429
|
if (this.config.opForms?.create === "scoped") throw new OperationNotSupportedError(this.config.key, "create");
|
|
25430
|
+
if (this.config.key === "inventory_items") {
|
|
25431
|
+
const { body, opts: opts2 } = captureInventoryItemCall(a, b, true);
|
|
25432
|
+
const checkedBaseUrl = this.http.baseUrl;
|
|
25433
|
+
try {
|
|
25434
|
+
await guardInventoryItemCreate(this.http, body, checkedBaseUrl, opts2.maxRetries, opts2.expectedInventoryFacts);
|
|
25435
|
+
} catch (error) {
|
|
25436
|
+
if (error instanceof AutotaskError) Object.assign(error, { notSent: true });
|
|
25437
|
+
throw error;
|
|
25438
|
+
}
|
|
25439
|
+
if (opts2.dryRun === true) return this.runCreateDryRun(body);
|
|
25440
|
+
const result = await this.createGlobal(body, opts2, checkedBaseUrl);
|
|
25441
|
+
return this.withPersistedCheck(result, body, opts2, result.id, void 0, checkedBaseUrl);
|
|
25442
|
+
}
|
|
24971
25443
|
const data = this.config.key === "knowledge_base_categories" ? admitKnowledgeBaseCategory(a, true) : this.config.key === "inventory_locations" ? admitInventoryLocation(a, true) : a;
|
|
24972
25444
|
const supplied = b;
|
|
24973
25445
|
const opts = ["knowledge_base_categories", "inventory_locations"].includes(this.config.key) ? snapshotMutationOptions(supplied) : supplied ?? {};
|
|
@@ -24976,6 +25448,7 @@ var GenericResource = class extends BaseResource {
|
|
|
24976
25448
|
}
|
|
24977
25449
|
async update(a, b = void 0, c = void 0, d = void 0) {
|
|
24978
25450
|
this.requireOp("update");
|
|
25451
|
+
rejectInventoryFactsOption(isIdentifier(b) ? d : c, `${this.config.key}.update`);
|
|
24979
25452
|
if (isIdentifier(a) && isIdentifier(b)) {
|
|
24980
25453
|
if (this.config.opForms?.update === "global") throw new OperationNotSupportedError(this.config.key, "update");
|
|
24981
25454
|
const parentId = this.config.key === "knowledge_base_articles" ? articleParent(a) : a;
|
|
@@ -24996,6 +25469,20 @@ var GenericResource = class extends BaseResource {
|
|
|
24996
25469
|
return this.updateScopedRaw(parentId, id2, data2, opts2);
|
|
24997
25470
|
}
|
|
24998
25471
|
if (this.config.opForms?.update === "scoped") throw new OperationNotSupportedError(this.config.key, "update");
|
|
25472
|
+
if (this.config.key === "inventory_items") {
|
|
25473
|
+
const id2 = inventoryItemId(a);
|
|
25474
|
+
const { body, opts: opts2 } = captureInventoryItemCall(b, c, false);
|
|
25475
|
+
const checkedBaseUrl = this.http.baseUrl;
|
|
25476
|
+
const checkCurrent = (current) => checkInventoryItemCurrent(this.http, body, current, id2, checkedBaseUrl, opts2.maxRetries, opts2.expectedInventoryFacts);
|
|
25477
|
+
if (opts2.dryRun === true) return this.runUpdateDryRun(id2, body, opts2, void 0, void 0, { checkCurrent, checkedBaseUrl });
|
|
25478
|
+
try {
|
|
25479
|
+
await checkCurrent(await this.getGlobal(id2, true, opts2.maxRetries, checkedBaseUrl));
|
|
25480
|
+
} catch (error) {
|
|
25481
|
+
if (error instanceof AutotaskError) Object.assign(error, { notSent: true });
|
|
25482
|
+
rethrowInventoryGuardError(error, opts2.expectedInventoryFacts, "inventory_items.update");
|
|
25483
|
+
}
|
|
25484
|
+
return this.updateGlobal(id2, body, opts2, "PATCH", checkedBaseUrl);
|
|
25485
|
+
}
|
|
24999
25486
|
const category = this.config.key === "knowledge_base_categories";
|
|
25000
25487
|
const location = this.config.key === "inventory_locations";
|
|
25001
25488
|
const id = category || location ? parseIdentifier(a, "id") : a;
|
|
@@ -25026,6 +25513,7 @@ var GenericResource = class extends BaseResource {
|
|
|
25026
25513
|
}
|
|
25027
25514
|
async delete(a, b = void 0, c = void 0) {
|
|
25028
25515
|
this.requireOp("delete");
|
|
25516
|
+
rejectInventoryFactsOption(isIdentifier(b) ? c : b, `${this.config.key}.delete`);
|
|
25029
25517
|
if (isIdentifier(a) && isIdentifier(b)) {
|
|
25030
25518
|
if (this.config.opForms?.delete === "global") throw new OperationNotSupportedError(this.config.key, "delete");
|
|
25031
25519
|
const parentId = this.config.key === "knowledge_base_articles" ? articleParent(a) : a;
|
|
@@ -26707,7 +27195,7 @@ function dateBucketLabel(value, bucket) {
|
|
|
26707
27195
|
var queryResourceKeysPromise = null;
|
|
26708
27196
|
function queryResourceKeys() {
|
|
26709
27197
|
if (queryResourceKeysPromise === null) {
|
|
26710
|
-
queryResourceKeysPromise =
|
|
27198
|
+
queryResourceKeysPromise = chunkQXJQIZCT_cjs.loadCapabilityRecords().then((records) => {
|
|
26711
27199
|
const s = /* @__PURE__ */ new Set();
|
|
26712
27200
|
for (const rec of records) if (rec.operation === "query") s.add(rec.resource);
|
|
26713
27201
|
return s;
|
|
@@ -26829,7 +27317,7 @@ function parseTopAndLimit(opts, problems) {
|
|
|
26829
27317
|
return { top, limit };
|
|
26830
27318
|
}
|
|
26831
27319
|
async function checkFieldNames(resourceKey, conditions, opts, problems) {
|
|
26832
|
-
const records = resourceKey === void 0 ? [] : await
|
|
27320
|
+
const records = resourceKey === void 0 ? [] : await chunkQXJQIZCT_cjs.loadCapabilityRecords();
|
|
26833
27321
|
const record = resourceKey === void 0 ? void 0 : records.find((r) => r.resource === resourceKey && r.operation === "query");
|
|
26834
27322
|
if (record === void 0) return void 0;
|
|
26835
27323
|
const strings = (v) => Array.isArray(v) ? v.filter((f) => typeof f === "string" && f.trim() !== "") : [];
|
|
@@ -26938,6 +27426,7 @@ async function aggregate(client, operation, filter, opts = {}) {
|
|
|
26938
27426
|
const labelled = !label || v.groupBy.length === 0 ? void 0 : await labelRows(client, v.resourceKey, top.map((g) => g.key));
|
|
26939
27427
|
const result = {
|
|
26940
27428
|
mode: v.groupBy.length > 0 ? "group" : "sum",
|
|
27429
|
+
...v.resourceKey === "inventory_items" ? { resource: v.resourceKey } : {},
|
|
26941
27430
|
groups: top.map((g, i) => ({ key: labelled?.rows[i] ?? g.key, count: g.count, ...g.sums !== void 0 ? { sums: g.sums } : {} })),
|
|
26942
27431
|
totalGroups: sorted.length,
|
|
26943
27432
|
groupsTruncated: sorted.length > top.length,
|
|
@@ -27324,7 +27813,7 @@ async function uiLink(client, input) {
|
|
|
27324
27813
|
var indexPromise = null;
|
|
27325
27814
|
function operationIndex() {
|
|
27326
27815
|
if (indexPromise === null) {
|
|
27327
|
-
indexPromise =
|
|
27816
|
+
indexPromise = chunkQXJQIZCT_cjs.loadCapabilityRecords().then((records) => new Map(records.map((r) => [r.id, r])));
|
|
27328
27817
|
}
|
|
27329
27818
|
return indexPromise;
|
|
27330
27819
|
}
|
|
@@ -27337,15 +27826,32 @@ async function sanitiseResult(client, result, operation) {
|
|
|
27337
27826
|
{ suggestedAction: "Pass the operation key the result came from \u2014 the registry id, not the resource key." }
|
|
27338
27827
|
);
|
|
27339
27828
|
}
|
|
27340
|
-
const
|
|
27829
|
+
const records = await operationIndex();
|
|
27830
|
+
const record = records.get(operation);
|
|
27341
27831
|
if (record === void 0) {
|
|
27342
27832
|
throw new AutotaskConfigError(
|
|
27343
27833
|
`sanitiseResult: unknown operation "${operation.slice(0, 60)}" \u2014 it is not in the capability registry`,
|
|
27344
27834
|
{ operation, suggestedAction: "List the registry (the ./capabilities subpath) for the exact operation key." }
|
|
27345
27835
|
);
|
|
27346
27836
|
}
|
|
27347
|
-
const
|
|
27348
|
-
|
|
27837
|
+
const names = record.metadata.untrustedFields;
|
|
27838
|
+
const fields = Array.isArray(names) ? names : [];
|
|
27839
|
+
const inventoryAggregate = operation === "operations.aggregate" && result.resource === "inventory_items";
|
|
27840
|
+
const projected = chunkCM5O672I_cjs.deepMarkUntrusted(result, inventoryAggregate ? [...fields, "referenceNumber"] : fields);
|
|
27841
|
+
if (operation === "operations.searchAcrossResources") return wrapReferenceRows(projected, "matches");
|
|
27842
|
+
if (operation === "operations.fetchByIds") return wrapReferenceRows(projected, "value");
|
|
27843
|
+
if (operation === "operations.resolveAny") {
|
|
27844
|
+
const wrapped = wrapReferenceRows(projected, "value");
|
|
27845
|
+
return isRecord2(wrapped.contains) ? { ...wrapped, contains: wrapReferenceRows(wrapped.contains, "matches") } : wrapped;
|
|
27846
|
+
}
|
|
27847
|
+
return projected;
|
|
27848
|
+
}
|
|
27849
|
+
function wrapReferenceRows(result, field) {
|
|
27850
|
+
if (!Array.isArray(result.results)) return result;
|
|
27851
|
+
return { ...result, results: result.results.map((row) => {
|
|
27852
|
+
if (!isRecord2(row) || typeof row.resource !== "string" || !Object.hasOwn(row, field) || !row.resource.split("_").every(Boolean) || camelKey(row.resource) !== "inventoryItems") return row;
|
|
27853
|
+
return { ...row, [field]: chunkCM5O672I_cjs.deepMarkUntrusted(row[field], ["referenceNumber"]) };
|
|
27854
|
+
}) };
|
|
27349
27855
|
}
|
|
27350
27856
|
|
|
27351
27857
|
// src/resources/special/invoices.ts
|
|
@@ -28748,18 +29254,18 @@ async function fetchExpenses(ctx, join, entries) {
|
|
|
28748
29254
|
const gaps = [...task.gaps];
|
|
28749
29255
|
const timeTruncated = ctx.truncatedMonths["timeEntries"];
|
|
28750
29256
|
if (timeTruncated !== void 0 && timeTruncated.length > 0) gaps.push(`time entries truncated in ${timeTruncated.join(", ")}, so a no-contract ticket or task their missing rows reference is not joined`);
|
|
28751
|
-
const
|
|
29257
|
+
const own2 = [
|
|
28752
29258
|
...tasks.ids.length > 0 ? [{ field: "taskID", op: "in", value: tasks.ids }] : [],
|
|
28753
29259
|
...task.projectIds.length > 0 ? [{ field: "projectID", op: "in", value: task.projectIds }] : []
|
|
28754
29260
|
];
|
|
28755
29261
|
const orOf = (keys) => [keys.length === 1 ? keys[0] : { op: "or", items: keys }, ...ctx.windowOn("expenseDate")];
|
|
28756
|
-
const expCond = orOf([{ field: "ticketID", op: "exist" }, ...
|
|
29262
|
+
const expCond = orOf([{ field: "ticketID", op: "exist" }, ...own2]);
|
|
28757
29263
|
const shared = ctx.sharedExpenses;
|
|
28758
29264
|
let raw;
|
|
28759
|
-
if (shared &&
|
|
29265
|
+
if (shared && own2.length === 0) {
|
|
28760
29266
|
raw = { items: [], capped: false, hasMore: false };
|
|
28761
29267
|
} else {
|
|
28762
|
-
const read = await ctx.windowedPart("expenses", "expense_items", "/V1.0/ExpenseItems/query", shared ? orOf(
|
|
29268
|
+
const read = await ctx.windowedPart("expenses", "expense_items", "/V1.0/ExpenseItems/query", shared ? orOf(own2) : expCond, EXPENSE_FIELDS, "expenseDate", EXPENSE_PAGE);
|
|
28763
29269
|
raw = read.part;
|
|
28764
29270
|
raw.items = read.rows;
|
|
28765
29271
|
}
|
|
@@ -29660,16 +30166,16 @@ function latchingHttp(raw, spend) {
|
|
|
29660
30166
|
}
|
|
29661
30167
|
};
|
|
29662
30168
|
observeRecordReadFailures(http, latch);
|
|
29663
|
-
const
|
|
30169
|
+
const fail5 = (err) => {
|
|
29664
30170
|
latch(err);
|
|
29665
30171
|
throw err;
|
|
29666
30172
|
};
|
|
29667
30173
|
http.request = (o) => {
|
|
29668
30174
|
if (fatal) throw fatal;
|
|
29669
30175
|
try {
|
|
29670
|
-
return counted.request({ ...o, signal: o.signal ?? signal }).catch(
|
|
30176
|
+
return counted.request({ ...o, signal: o.signal ?? signal }).catch(fail5);
|
|
29671
30177
|
} catch (err) {
|
|
29672
|
-
return
|
|
30178
|
+
return fail5(err);
|
|
29673
30179
|
}
|
|
29674
30180
|
};
|
|
29675
30181
|
return { http, fatal: () => fatal, signal };
|
|
@@ -31080,7 +31586,7 @@ async function wipHours(client, opts) {
|
|
|
31080
31586
|
} else {
|
|
31081
31587
|
const contractIds = positiveIds2(wipIn.map((e) => e["contractID"]));
|
|
31082
31588
|
gate(chunks2(contractIds.length) + (contractIds.length > 0 ? 1 : 0), "before label reads", { contracts: contractIds.length });
|
|
31083
|
-
const [contracts,
|
|
31589
|
+
const [contracts, types2] = await readTasks(http, [
|
|
31084
31590
|
() => readChunks2(http, "/V1.0/Contracts", contractIds, ["contractType"]),
|
|
31085
31591
|
async () => contractIds.length > 0 ? (await readPicklists(http, "/V1.0/Contracts", OP10)).get("contractType") : void 0
|
|
31086
31592
|
]);
|
|
@@ -31088,7 +31594,7 @@ async function wipHours(client, opts) {
|
|
|
31088
31594
|
const bad = contractIds.filter((id) => typeof typeOf(id) !== "number");
|
|
31089
31595
|
if (bad.length > 0) throw unresolved("contracts", bad);
|
|
31090
31596
|
keyOfEntry = (e) => num(e["contractID"]) > 0 ? typeOf(num(e["contractID"])) : null;
|
|
31091
|
-
for (const [id, label] of
|
|
31597
|
+
for (const [id, label] of types2 ?? []) labels.set(id, { label });
|
|
31092
31598
|
}
|
|
31093
31599
|
const approvalData = entries.some((e) => isApproved(e));
|
|
31094
31600
|
const acc = () => ({ entries: 0, worked: 0, toBill: 0, approved: 0 });
|
|
@@ -31279,7 +31785,7 @@ async function nonChargeableWork(client, opts) {
|
|
|
31279
31785
|
const contractIds = distinctIds(ncLines.map((x) => x.line["contractID"]), 1);
|
|
31280
31786
|
const typed = v.groupBy === "contractType";
|
|
31281
31787
|
gate(chunks3(contractIds.length) + (typed && contractIds.length > 0 ? 1 : 0) + (v.includeUnpostedTime ? 1 : 0), "before label reads", { contracts: contractIds.length });
|
|
31282
|
-
const [contracts,
|
|
31788
|
+
const [contracts, types2] = await readTasks(http, [
|
|
31283
31789
|
() => readChunks3(http, "/V1.0/Contracts", contractIds, [typed ? "contractType" : "contractName"]),
|
|
31284
31790
|
async () => typed && contractIds.length > 0 ? (await readPicklists(http, "/V1.0/Contracts", OP11)).get("contractType") : void 0
|
|
31285
31791
|
]);
|
|
@@ -31290,7 +31796,7 @@ async function nonChargeableWork(client, opts) {
|
|
|
31290
31796
|
if (!typed) return num(line["contractID"]);
|
|
31291
31797
|
return isId(c["contractType"]) ? c["contractType"] : UNRESOLVED;
|
|
31292
31798
|
};
|
|
31293
|
-
if (typed) for (const [id, label] of
|
|
31799
|
+
if (typed) for (const [id, label] of types2 ?? []) labels.set(id, { label });
|
|
31294
31800
|
else for (const [id, r] of contracts) labels.set(Number(id), typeof r["contractName"] === "string" ? { name: r["contractName"] } : {});
|
|
31295
31801
|
}
|
|
31296
31802
|
const cells = /* @__PURE__ */ new Map();
|
|
@@ -31468,8 +31974,37 @@ function bufferResult(buf) {
|
|
|
31468
31974
|
};
|
|
31469
31975
|
}
|
|
31470
31976
|
var PUBLIC_INVOKE_OPTION_KEYS = INVOKE_OPTION_KEYS.filter((key) => key !== "mode");
|
|
31471
|
-
function
|
|
31977
|
+
function snapshotInventoryInvokeOptions(options, operation, mode) {
|
|
31978
|
+
const { descriptors, expectedInventoryFacts: facts } = captureInventoryOptionDescriptors(options);
|
|
31979
|
+
if (Object.getOwnPropertySymbols(descriptors).length > 0) throw new AutotaskConfigError("inventory_items: invoke options must use string keys", { operation });
|
|
31980
|
+
const applyFlag = Object.hasOwn(descriptors, "dryRun") ? descriptors.dryRun : void 0;
|
|
31981
|
+
for (const key of PUBLIC_INVOKE_OPTION_KEYS) {
|
|
31982
|
+
if (key === "expectedInventoryFacts" || Object.hasOwn(descriptors, key)) continue;
|
|
31983
|
+
for (let owner = Object.getPrototypeOf(options); owner !== null && owner !== Object.prototype; owner = Object.getPrototypeOf(owner)) {
|
|
31984
|
+
const descriptor2 = Object.getOwnPropertyDescriptor(owner, key);
|
|
31985
|
+
if (descriptor2 !== void 0) {
|
|
31986
|
+
descriptors[key] = descriptor2;
|
|
31987
|
+
break;
|
|
31988
|
+
}
|
|
31989
|
+
}
|
|
31990
|
+
}
|
|
31991
|
+
const captured = /* @__PURE__ */ Object.create(null);
|
|
31992
|
+
for (const [key, descriptor2] of Object.entries(descriptors)) captured[key] = Object.hasOwn(descriptor2, "value") ? descriptor2.value : void 0;
|
|
31993
|
+
validateInvokeOptions(captured, operation);
|
|
31994
|
+
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 });
|
|
31995
|
+
const applyRequested = applyFlag !== void 0 && Object.hasOwn(applyFlag, "value") && applyFlag.value === false;
|
|
31996
|
+
for (const [key, descriptor2] of Object.entries(descriptors)) {
|
|
31997
|
+
if (key === "expectedInventoryFacts" || Object.hasOwn(descriptor2, "value")) continue;
|
|
31998
|
+
captured[key] = descriptor2.get === void 0 ? void 0 : Reflect.apply(descriptor2.get, options, []);
|
|
31999
|
+
}
|
|
32000
|
+
captured.expectedInventoryFacts = facts;
|
|
32001
|
+
captured.dryRun = applyRequested || captured.dryRun !== false ? captured.dryRun : void 0;
|
|
32002
|
+
return Object.assign(captured, { mode });
|
|
32003
|
+
}
|
|
32004
|
+
function snapshotInvokeOptions(options, operation, mode) {
|
|
32005
|
+
if (operation === "inventory_items.create" || operation === "inventory_items.update") return snapshotInventoryInvokeOptions(options, operation, mode);
|
|
31472
32006
|
if (!isRecord2(options)) throw new AutotaskConfigError("invoke: options must be an object");
|
|
32007
|
+
rejectInventoryFactsOption(options, operation);
|
|
31473
32008
|
const applyFlag = Object.getOwnPropertyDescriptor(options, "dryRun");
|
|
31474
32009
|
const applyRequested = applyFlag !== void 0 && Object.hasOwn(applyFlag, "value") && applyFlag.value === false;
|
|
31475
32010
|
let confirmation;
|
|
@@ -31485,7 +32020,8 @@ function snapshotInvokeOptions(options, mode) {
|
|
|
31485
32020
|
const dryRun = options.dryRun;
|
|
31486
32021
|
const captured = snapshotFields(options, PUBLIC_INVOKE_OPTION_KEYS, {
|
|
31487
32022
|
dryRun: applyRequested || dryRun !== false ? dryRun : void 0,
|
|
31488
|
-
confirm
|
|
32023
|
+
confirm,
|
|
32024
|
+
expectedInventoryFacts: void 0
|
|
31489
32025
|
});
|
|
31490
32026
|
return Object.assign(/* @__PURE__ */ Object.create(null), captured, { mode });
|
|
31491
32027
|
}
|
|
@@ -31501,6 +32037,7 @@ async function resolveRecord(operation) {
|
|
|
31501
32037
|
}
|
|
31502
32038
|
function governPreRequest(record, operation, opts) {
|
|
31503
32039
|
validateInvokeOptions(opts, operation);
|
|
32040
|
+
if (opts.expectedInventoryFacts !== void 0) rejectInventoryFactsOption(opts, operation);
|
|
31504
32041
|
const mode = opts.mode;
|
|
31505
32042
|
if (mode !== void 0 && MODE_BY_EFFECT[record.effect] !== mode) {
|
|
31506
32043
|
throw new AutotaskConfigError(crossModeRefusal(operation, record.effect, mode), { operation });
|
|
@@ -31624,6 +32161,7 @@ var BAG_RIDING_ARGS = {
|
|
|
31624
32161
|
function buildMutationOpts(opts, isWrite) {
|
|
31625
32162
|
const dryRun = isWrite ? opts.dryRun !== false : false;
|
|
31626
32163
|
const mutationOpts = { dryRun };
|
|
32164
|
+
if (opts.expectedInventoryFacts !== void 0) mutationOpts.expectedInventoryFacts = opts.expectedInventoryFacts;
|
|
31627
32165
|
if (isWrite && opts.lastModifiedDate !== void 0) {
|
|
31628
32166
|
mutationOpts.lastModifiedDate = opts.lastModifiedDate;
|
|
31629
32167
|
}
|
|
@@ -31725,6 +32263,10 @@ async function runPreRequestPass(ctx) {
|
|
|
31725
32263
|
}
|
|
31726
32264
|
async function prepareInvocation(client, operation, argsIn, opts, streaming = false) {
|
|
31727
32265
|
const record = await resolveRecord(operation);
|
|
32266
|
+
if (operation === "inventory_items.create" || operation === "inventory_items.update") {
|
|
32267
|
+
governPreRequest(record, operation, opts);
|
|
32268
|
+
snapshotInventoryMutationOptions(opts);
|
|
32269
|
+
}
|
|
31728
32270
|
const resolvedArgs = resolveDispatchArgs(record, argsIn);
|
|
31729
32271
|
const boundedQuery = record.kind === "primitive" && record.operation === "query";
|
|
31730
32272
|
const countedQuery = record.kind === "primitive" && record.operation === "count";
|
|
@@ -31766,14 +32308,16 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
31766
32308
|
return scopeNote !== void 0 && finished !== null && typeof finished === "object" ? { ...finished, scopeNote } : finished;
|
|
31767
32309
|
}
|
|
31768
32310
|
async function invoke(client, operation, args = [], opts = {}) {
|
|
31769
|
-
|
|
32311
|
+
const capturedArgs = captureInventoryInvocationArgs(operation, args);
|
|
32312
|
+
const capturedOpts = snapshotInvokeOptions(opts, operation);
|
|
32313
|
+
return invokeMode(client, operation, capturedArgs(capturedOpts.expectedInventoryFacts === void 0), capturedOpts);
|
|
31770
32314
|
}
|
|
31771
32315
|
async function invokeRead(client, operation, args = [], opts = {}) {
|
|
31772
|
-
return invokeMode(client, operation, args, snapshotInvokeOptions(opts, "read"));
|
|
32316
|
+
return invokeMode(client, operation, args, snapshotInvokeOptions(opts, operation, "read"));
|
|
31773
32317
|
}
|
|
31774
32318
|
async function invokeReadPages(client, operation, args, onPage, opts = {}) {
|
|
31775
32319
|
if (typeof onPage !== "function") throw new AutotaskConfigError("invokeReadPages: onPage must be a function", { operation });
|
|
31776
|
-
const prepared = await prepareInvocation(client, operation, args, snapshotInvokeOptions(opts, "read"), true);
|
|
32320
|
+
const prepared = await prepareInvocation(client, operation, args, snapshotInvokeOptions(opts, operation, "read"), true);
|
|
31777
32321
|
prepared.pageSession.guard();
|
|
31778
32322
|
const consume = prepared.method;
|
|
31779
32323
|
const result = await consume.call(prepared.holder, prepared.callArgs[0], onPage);
|
|
@@ -31781,10 +32325,12 @@ async function invokeReadPages(client, operation, args, onPage, opts = {}) {
|
|
|
31781
32325
|
return prepared.scopeNote === void 0 ? result : { ...result, scopeNote: prepared.scopeNote };
|
|
31782
32326
|
}
|
|
31783
32327
|
async function invokeWrite(client, operation, args = [], opts = {}) {
|
|
31784
|
-
|
|
32328
|
+
const capturedArgs = captureInventoryInvocationArgs(operation, args);
|
|
32329
|
+
const capturedOpts = snapshotInvokeOptions(opts, operation, "write");
|
|
32330
|
+
return invokeMode(client, operation, capturedArgs(capturedOpts.expectedInventoryFacts === void 0), capturedOpts);
|
|
31785
32331
|
}
|
|
31786
32332
|
async function invokeDelete(client, operation, args = [], opts = {}) {
|
|
31787
|
-
return invokeMode(client, operation, args, snapshotInvokeOptions(opts, "delete"));
|
|
32333
|
+
return invokeMode(client, operation, args, snapshotInvokeOptions(opts, operation, "delete"));
|
|
31788
32334
|
}
|
|
31789
32335
|
|
|
31790
32336
|
// src/resources/special/_shared/compositeParts.ts
|
|
@@ -32025,6 +32571,7 @@ exports.fetchByIds = fetchByIds;
|
|
|
32025
32571
|
exports.fieldCatalog = fieldCatalog;
|
|
32026
32572
|
exports.foldFlattenedOpts = foldFlattenedOpts;
|
|
32027
32573
|
exports.formatVendorDetail = formatVendorDetail;
|
|
32574
|
+
exports.inventoryItemGuardFacts = inventoryItemGuardFacts;
|
|
32028
32575
|
exports.invoke = invoke;
|
|
32029
32576
|
exports.invokeDelete = invokeDelete;
|
|
32030
32577
|
exports.invokeRead = invokeRead;
|
|
@@ -32051,6 +32598,7 @@ exports.queryRows = queryRows;
|
|
|
32051
32598
|
exports.readTasks = readTasks;
|
|
32052
32599
|
exports.recurringRevenue = recurringRevenue;
|
|
32053
32600
|
exports.refuse = refuse2;
|
|
32601
|
+
exports.rejectInventoryFactsOption = rejectInventoryFactsOption;
|
|
32054
32602
|
exports.relationshipMap = relationshipMap;
|
|
32055
32603
|
exports.resolveAny = resolveAny;
|
|
32056
32604
|
exports.resolveCompositeNames = resolveCompositeNames;
|