@uipath/vertical-solutions-tool 1.202.0 → 1.203.0-preview.160

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.
@@ -6863,8 +6863,9 @@ var require_src6 = __commonJS(function(exports) {
6863
6863
  // package.json
6864
6864
  var package_default = {
6865
6865
  name: "@uipath/vertical-solutions-tool",
6866
+ author: "UiPath",
6866
6867
  license: "SEE LICENSE IN LICENSE.txt",
6867
- version: "1.202.0",
6868
+ version: "1.203.0-preview.160",
6868
6869
  description: "Scaffold and generate Vertical Solution projects.",
6869
6870
  private: false,
6870
6871
  repository: {
@@ -6909,7 +6910,7 @@ var package_default = {
6909
6910
  "@uipath/auth": "workspace:*",
6910
6911
  "@uipath/common": "workspace:*",
6911
6912
  "@uipath/filesystem": "workspace:*",
6912
- "@uipath/uipath-typescript": "^1.6.1",
6913
+ "@uipath/uipath-typescript": "^1.7.1",
6913
6914
  "@inquirer/prompts": "^8.3.2",
6914
6915
  "@types/node": "^25.5.2",
6915
6916
  commander: "^14.0.3",
@@ -7431,7 +7432,7 @@ var UUID_PATTERN = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{1
7431
7432
  var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
7432
7433
  var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
7433
7434
  var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
7434
- var PADDED_BASE64_PATTERN = /[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
7435
+ var PADDED_BASE64_PATTERN = /(?<![A-Za-z0-9+/])[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
7435
7436
  var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
7436
7437
  var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
7437
7438
  var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
@@ -7478,7 +7479,7 @@ var QUOTED_LITERAL_PATTERN = new RegExp([
7478
7479
  `(?<![A-Za-z0-9])"(?:[^\\
7479
7480
  ]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
7480
7481
  ].join("|"), "g");
7481
- var JSON_BODY_PATTERN = /[{[][^{}[\]]*[:,][^{}[\]]*[\]}]/g;
7482
+ var JSON_BODY_PATTERN = /[{[][^{}[\]:,]*[:,][^{}[\]]*[\]}]/g;
7482
7483
  var COLLAPSED_BODY = "{…}";
7483
7484
  var COLLAPSED_BODY_MARKER = "\x01body\x01";
7484
7485
  var MAX_BODY_NESTING = 8;
@@ -7493,10 +7494,13 @@ function collapseJsonBodies(text) {
7493
7494
  }
7494
7495
  return out.split(COLLAPSED_BODY_MARKER).join(COLLAPSED_BODY);
7495
7496
  }
7496
- var TRAILING_PROSE_PUNCT = /[.,;:!?)\]}>'"]+$/;
7497
+ var TRAILING_PROSE_PUNCT = `.,;:!?)]}>'"`;
7497
7498
  function peelTrailingPunctuation(match) {
7498
- const trailing = match.match(TRAILING_PROSE_PUNCT)?.[0] ?? "";
7499
- return trailing ? [match.slice(0, -trailing.length), trailing] : [match, ""];
7499
+ let end = match.length;
7500
+ while (end > 0 && TRAILING_PROSE_PUNCT.includes(match[end - 1])) {
7501
+ end -= 1;
7502
+ }
7503
+ return [match.slice(0, end), match.slice(end)];
7500
7504
  }
7501
7505
  function redactUrl(raw) {
7502
7506
  try {
@@ -8198,7 +8202,8 @@ function readRegistryValue(keyPath, valueName) {
8198
8202
  }
8199
8203
  const [error, output] = catchError(() => execFileSync("reg", ["query", keyPath, "/v", valueName], {
8200
8204
  encoding: "utf-8",
8201
- stdio: ["pipe", "pipe", "pipe"]
8205
+ stdio: ["pipe", "pipe", "pipe"],
8206
+ windowsHide: true
8202
8207
  }));
8203
8208
  if (error) {
8204
8209
  return "";
@@ -8880,28 +8885,32 @@ function isPlainRecord(value) {
8880
8885
  const prototype = Object.getPrototypeOf(value);
8881
8886
  return prototype === Object.prototype || prototype === null;
8882
8887
  }
8883
- function extractPagedRows(value) {
8888
+ function splitPagedEnvelope(value) {
8884
8889
  if (Array.isArray(value) || !isPlainRecord(value))
8885
8890
  return null;
8886
- const entries = Object.values(value);
8891
+ const entries = Object.entries(value);
8887
8892
  if (entries.length === 0)
8888
8893
  return null;
8889
- let rows = null;
8890
- let hasScalarSibling = false;
8891
- for (const entry of entries) {
8894
+ let found = null;
8895
+ const meta = Object.create(null);
8896
+ for (const [key, entry] of entries) {
8892
8897
  if (Array.isArray(entry)) {
8893
- if (rows !== null)
8898
+ if (found !== null)
8894
8899
  return null;
8895
- rows = entry;
8900
+ found = { key, rows: entry };
8896
8901
  } else if (entry !== null && typeof entry === "object") {
8897
8902
  return null;
8898
8903
  } else {
8899
- hasScalarSibling = true;
8904
+ meta[key] = entry;
8900
8905
  }
8901
8906
  }
8902
- if (rows === null || !hasScalarSibling)
8907
+ if (found === null || Object.keys(meta).length === 0)
8903
8908
  return null;
8904
- return rows;
8909
+ return { ...found, meta };
8910
+ }
8911
+ function extractPagedRows(value) {
8912
+ const paged = splitPagedEnvelope(value);
8913
+ return paged === null ? null : paged.rows;
8905
8914
  }
8906
8915
  function toLowerCamelCaseKey(key) {
8907
8916
  if (!key)
@@ -9005,6 +9014,9 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
9005
9014
  }
9006
9015
  break;
9007
9016
  }
9017
+ case "markdown":
9018
+ logFn(renderMarkdown(data));
9019
+ break;
9008
9020
  default: {
9009
9021
  const hasData = "Data" in data && data.Data != null;
9010
9022
  const pagedRows = hasData ? extractPagedRows(data.Data) : null;
@@ -9029,6 +9041,10 @@ function logOutput(data, format = "json", tableRowStyle) {
9029
9041
  printOutput(data, format, (msg) => sink.writeOut(`${msg}
9030
9042
  `), needsAsciiSafeJson(sink), styleFn);
9031
9043
  }
9044
+ var PLUMBING_KEYS = new Set(["code", "log"]);
9045
+ function isPlumbingKey(key) {
9046
+ return PLUMBING_KEYS.has(key.toLowerCase());
9047
+ }
9032
9048
  function cellToString(val) {
9033
9049
  return val != null && typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
9034
9050
  }
@@ -9044,7 +9060,7 @@ function wrapText(text, width) {
9044
9060
  function printTable(data, logFn, externalLogValue, tableRowStyle) {
9045
9061
  if (data.length === 0)
9046
9062
  return;
9047
- const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
9063
+ const keys = Object.keys(data[0]).filter((key) => !isPlumbingKey(key));
9048
9064
  const maxWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
9049
9065
  const header = keys.map((key, i) => key.padEnd(maxWidths[i])).join(" | ");
9050
9066
  logFn(header);
@@ -9066,7 +9082,7 @@ function isNonEmptyPlainObject(value) {
9066
9082
  }
9067
9083
  var NESTED_INDENT = " ";
9068
9084
  function printVerticalTable(data, logFn = console.log, externalLogValue) {
9069
- const keys = Object.keys(data).filter((key) => !["code", "log"].includes(key.toLowerCase()));
9085
+ const keys = Object.keys(data).filter((key) => !isPlumbingKey(key));
9070
9086
  if (keys.length === 0)
9071
9087
  return;
9072
9088
  const isBlockValue = (value) => isPlainObjectArray(value) || isNonEmptyPlainObject(value);
@@ -9097,7 +9113,7 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
9097
9113
  function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth, tableRowStyle) {
9098
9114
  if (data.length === 0)
9099
9115
  return;
9100
- const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
9116
+ const keys = Object.keys(data[0]).filter((key) => !isPlumbingKey(key));
9101
9117
  if (keys.length === 0)
9102
9118
  return;
9103
9119
  if (!process.stdout.isTTY) {
@@ -9171,6 +9187,220 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
9171
9187
  logFn(`Log: ${externalLogValue}`);
9172
9188
  }
9173
9189
  }
9190
+ var MARKDOWN_MAX_CELL = 200;
9191
+ var MARKDOWN_MAX_DEPTH = 3;
9192
+ function markdownHeading(depth) {
9193
+ return "#".repeat(Math.min(3 + depth, 6));
9194
+ }
9195
+ var BACKTICK_RUN = /`+/g;
9196
+ function fencedBlock(text) {
9197
+ const first = text.trimStart()[0];
9198
+ const language = first === "<" ? "xml" : first === "{" || first === "[" ? "json" : "";
9199
+ const longestRun = Math.max(0, ...Array.from(text.matchAll(BACKTICK_RUN), (match) => match[0].length));
9200
+ const fence = "`".repeat(Math.max(3, longestRun + 1));
9201
+ return `${fence}${language}
9202
+ ${text}
9203
+ ${fence}`;
9204
+ }
9205
+ function collapseNewlineRuns(text) {
9206
+ return text.split(/(\s+)/).map((part, index) => index % 2 === 1 && part.includes(`
9207
+ `) ? " " : part).join("");
9208
+ }
9209
+ function markdownCell(value) {
9210
+ const text = value instanceof Date ? value.toISOString() : cellToString(value);
9211
+ return collapseNewlineRuns(text).replace(/\|/g, "\\|");
9212
+ }
9213
+ function markdownLabel(key) {
9214
+ return collapseNewlineRuns(key).replace(/[\\`*|]/g, "\\$&");
9215
+ }
9216
+ function withoutPlumbing(record) {
9217
+ const kept = Object.create(null);
9218
+ for (const [key, value] of Object.entries(record)) {
9219
+ if (!isPlumbingKey(key))
9220
+ kept[key] = value;
9221
+ }
9222
+ return kept;
9223
+ }
9224
+ function rowsWithoutPlumbing(rows) {
9225
+ return rows.map((row) => isPlainRecord(row) ? withoutPlumbing(row) : row);
9226
+ }
9227
+ function markdownTable(rows) {
9228
+ const columns = [];
9229
+ const seen = new Set;
9230
+ for (const row of rows) {
9231
+ for (const key of Object.keys(row)) {
9232
+ if (!seen.has(key)) {
9233
+ seen.add(key);
9234
+ columns.push(key);
9235
+ }
9236
+ }
9237
+ }
9238
+ if (columns.length === 0)
9239
+ return null;
9240
+ const cells = rows.map((row) => columns.map((key) => markdownCell(row[key])));
9241
+ if (cells.some((row) => row.some((c) => c.length > MARKDOWN_MAX_CELL))) {
9242
+ return null;
9243
+ }
9244
+ return [
9245
+ `| ${columns.map(markdownLabel).join(" | ")} |`,
9246
+ `| ${columns.map(() => "---").join(" | ")} |`,
9247
+ ...cells.map((row) => `| ${row.join(" | ")} |`)
9248
+ ].join(`
9249
+ `);
9250
+ }
9251
+ function extractMessageSequence(rows) {
9252
+ const messages = [];
9253
+ for (const row of rows) {
9254
+ const message = extractSingleMessage(row);
9255
+ if (message === null)
9256
+ return null;
9257
+ messages.push(message);
9258
+ }
9259
+ return messages.join(`
9260
+
9261
+ `);
9262
+ }
9263
+ function markdownRows(rows, depth) {
9264
+ if (rows.length === 0)
9265
+ return "(none)";
9266
+ if (!isPlainObjectArray(rows)) {
9267
+ return rows.map((item) => `- ${markdownCell(item)}`).join(`
9268
+ `);
9269
+ }
9270
+ const prose = extractMessageSequence(rows);
9271
+ if (prose !== null)
9272
+ return prose;
9273
+ const table = markdownTable(rows);
9274
+ if (table !== null)
9275
+ return table;
9276
+ if (depth >= MARKDOWN_MAX_DEPTH) {
9277
+ return fencedBlock(JSON.stringify(rows, null, 2));
9278
+ }
9279
+ return rows.map((row, index) => [
9280
+ `${markdownHeading(depth)} ${index + 1}`,
9281
+ markdownObject(row, depth + 1)
9282
+ ].join(`
9283
+
9284
+ `)).join(`
9285
+
9286
+ `);
9287
+ }
9288
+ function markdownObject(obj, depth) {
9289
+ const scalars = [];
9290
+ const blocks = [];
9291
+ for (const [key, value] of Object.entries(obj)) {
9292
+ if (value === undefined)
9293
+ continue;
9294
+ const label = markdownLabel(key);
9295
+ if (Array.isArray(value)) {
9296
+ blocks.push(`${markdownHeading(depth)} ${label}
9297
+
9298
+ ${markdownRows(value, depth + 1)}`);
9299
+ } else if (isNonEmptyPlainObject(value)) {
9300
+ const nested = depth < MARKDOWN_MAX_DEPTH ? markdownObject(value, depth + 1) : fencedBlock(JSON.stringify(value, null, 2));
9301
+ if (nested !== "") {
9302
+ blocks.push(`${markdownHeading(depth)} ${label}
9303
+
9304
+ ${nested}`);
9305
+ }
9306
+ } else if (typeof value === "string" && value.includes(`
9307
+ `)) {
9308
+ blocks.push(`**${label}:**
9309
+
9310
+ ${fencedBlock(value)}`);
9311
+ } else {
9312
+ scalars.push(`**${label}:** ${markdownCell(value)}`);
9313
+ }
9314
+ }
9315
+ const sections = scalars.length > 0 ? [scalars.join(`
9316
+ `)] : [];
9317
+ sections.push(...blocks);
9318
+ return sections.join(`
9319
+
9320
+ `);
9321
+ }
9322
+ function extractSingleMessage(payload) {
9323
+ if (!isPlainRecord(payload))
9324
+ return null;
9325
+ const keys = Object.keys(payload);
9326
+ if (keys.length !== 1 || keys[0].toLowerCase() !== "message")
9327
+ return null;
9328
+ const value = payload[keys[0]];
9329
+ return typeof value === "string" ? value : null;
9330
+ }
9331
+ function markdownPayload(payload) {
9332
+ const message = extractSingleMessage(payload);
9333
+ if (message !== null)
9334
+ return message;
9335
+ if (Array.isArray(payload)) {
9336
+ return markdownRows(rowsWithoutPlumbing(payload), 0);
9337
+ }
9338
+ const visible = withoutPlumbing(payload);
9339
+ const paged = splitPagedEnvelope(visible);
9340
+ if (paged !== null) {
9341
+ const meta = markdownObject(paged.meta, 0);
9342
+ const rows = `${markdownHeading(0)} ${markdownLabel(paged.key)}
9343
+
9344
+ ${markdownRows(rowsWithoutPlumbing(paged.rows), 1)}`;
9345
+ return meta === "" ? rows : `${meta}
9346
+
9347
+ ${rows}`;
9348
+ }
9349
+ return markdownObject(visible, 0);
9350
+ }
9351
+ function isPaginationWorthShowing(value) {
9352
+ if (typeof value !== "object" || value === null)
9353
+ return false;
9354
+ const page = value;
9355
+ return page.HasMore === true || typeof page.Offset === "number" && page.Offset > 0;
9356
+ }
9357
+ function markdownEnvelopeNotes(data) {
9358
+ const envelope = data;
9359
+ const notes = [];
9360
+ const warning = envelope.Warning;
9361
+ if (typeof warning === "string" && warning !== "") {
9362
+ notes.push(`> **Warning:** ${warning}`);
9363
+ }
9364
+ const instructions = envelope.Instructions;
9365
+ if (typeof instructions === "string" && instructions !== "") {
9366
+ notes.push(`> ${instructions}`);
9367
+ }
9368
+ const pagination = envelope.Pagination;
9369
+ if (isPaginationWorthShowing(pagination)) {
9370
+ const body = markdownObject(pagination, 1);
9371
+ if (body !== "") {
9372
+ notes.push(`${markdownHeading(0)} Pagination
9373
+
9374
+ ${body}`);
9375
+ }
9376
+ }
9377
+ const log = envelope.Log;
9378
+ if (typeof log === "string" && log !== "") {
9379
+ notes.push(`**Log:** ${log}`);
9380
+ }
9381
+ return notes;
9382
+ }
9383
+ function renderMarkdown(data) {
9384
+ if (data.Result !== RESULTS.Success) {
9385
+ const failure = data;
9386
+ const sections = [`**Failed:** ${failure.Message}`];
9387
+ if (failure.Data != null) {
9388
+ sections.push(markdownPayload(failure.Data));
9389
+ }
9390
+ if (failure.Instructions) {
9391
+ sections.push(`> ${failure.Instructions}`);
9392
+ }
9393
+ return sections.filter((section) => section !== "").join(`
9394
+
9395
+ `);
9396
+ }
9397
+ if (!("Data" in data) || data.Data == null) {
9398
+ return markdownObject(withoutPlumbing(data), 0);
9399
+ }
9400
+ return [markdownPayload(data.Data), ...markdownEnvelopeNotes(data)].filter((section) => section !== "").join(`
9401
+
9402
+ `);
9403
+ }
9174
9404
  function toYaml(data) {
9175
9405
  const codec = getYamlCodec();
9176
9406
  if (!codec) {
@@ -31426,16 +31656,7 @@ var resolveEnvFilePathAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) =
31426
31656
  errorMessage: location.source === "absolute" ? `Environment file not found: ${envFilePath}` : `Unable to locate environment file: ${envFilePath}. Run 'uip login' to authenticate.`
31427
31657
  };
31428
31658
  };
31429
- var loadEnvFileAsync = async ({ envPath }) => {
31430
- const fs2 = getFileSystem();
31431
- const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
31432
- if (!await fs2.exists(absolutePath)) {
31433
- throw new Error(`Environment file not found: ${envPath}`);
31434
- }
31435
- const content = await fs2.readFile(absolutePath, "utf-8");
31436
- if (content === null) {
31437
- throw new Error(`Environment file not found: ${envPath}`);
31438
- }
31659
+ var parseEnvContent = (content) => {
31439
31660
  const env2 = {};
31440
31661
  for (const line of content.split(`
31441
31662
  `)) {
@@ -31456,6 +31677,18 @@ var loadEnvFileAsync = async ({ envPath }) => {
31456
31677
  }
31457
31678
  return env2;
31458
31679
  };
31680
+ var loadEnvFileAsync = async ({ envPath }) => {
31681
+ const fs2 = getFileSystem();
31682
+ const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
31683
+ if (!await fs2.exists(absolutePath)) {
31684
+ throw new Error(`Environment file not found: ${envPath}`);
31685
+ }
31686
+ const content = await fs2.readFile(absolutePath, "utf-8");
31687
+ if (content === null) {
31688
+ throw new Error(`Environment file not found: ${envPath}`);
31689
+ }
31690
+ return parseEnvContent(content);
31691
+ };
31459
31692
  var saveEnvFileAsync = async ({
31460
31693
  envPath,
31461
31694
  data,
@@ -32437,7 +32670,7 @@ var allowsEval2 = cached2(() => {
32437
32670
  return false;
32438
32671
  }
32439
32672
  });
32440
- function isPlainObject4(o) {
32673
+ function isPlainObject$1(o) {
32441
32674
  if (isObject2(o) === false)
32442
32675
  return false;
32443
32676
  const ctor = o.constructor;
@@ -32454,7 +32687,7 @@ function isPlainObject4(o) {
32454
32687
  return true;
32455
32688
  }
32456
32689
  function shallowClone2(o) {
32457
- if (isPlainObject4(o))
32690
+ if (isPlainObject$1(o))
32458
32691
  return { ...o };
32459
32692
  if (Array.isArray(o))
32460
32693
  return [...o];
@@ -32542,7 +32775,7 @@ function omit2(schema, mask) {
32542
32775
  return clone2(schema, def);
32543
32776
  }
32544
32777
  function extend2(schema, shape) {
32545
- if (!isPlainObject4(shape)) {
32778
+ if (!isPlainObject$1(shape)) {
32546
32779
  throw new Error("Invalid input to extend: expected a plain object");
32547
32780
  }
32548
32781
  const checks3 = schema._zod.def.checks;
@@ -32565,7 +32798,7 @@ function extend2(schema, shape) {
32565
32798
  return clone2(schema, def);
32566
32799
  }
32567
32800
  function safeExtend2(schema, shape) {
32568
- if (!isPlainObject4(shape)) {
32801
+ if (!isPlainObject$1(shape)) {
32569
32802
  throw new Error("Invalid input to safeExtend: expected a plain object");
32570
32803
  }
32571
32804
  const def = mergeDefs2(schema._zod.def, {
@@ -32902,6 +33135,7 @@ var string$1 = (params) => {
32902
33135
  const regex2 = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
32903
33136
  return new RegExp(`^${regex2}$`);
32904
33137
  };
33138
+ var boolean$1 = /^(?:true|false)$/i;
32905
33139
  var lowercase2 = /^[^A-Z]*$/;
32906
33140
  var uppercase2 = /^[^a-z]*$/;
32907
33141
  var $ZodCheck2 = /* @__PURE__ */ $constructor2("$ZodCheck", (inst, def) => {
@@ -33570,6 +33804,26 @@ var $ZodJWT2 = /* @__PURE__ */ $constructor2("$ZodJWT", (inst, def) => {
33570
33804
  });
33571
33805
  };
33572
33806
  });
33807
+ var $ZodBoolean2 = /* @__PURE__ */ $constructor2("$ZodBoolean", (inst, def) => {
33808
+ $ZodType2.init(inst, def);
33809
+ inst._zod.pattern = boolean$1;
33810
+ inst._zod.parse = (payload, _ctx) => {
33811
+ if (def.coerce)
33812
+ try {
33813
+ payload.value = Boolean(payload.value);
33814
+ } catch (_) {}
33815
+ const input = payload.value;
33816
+ if (typeof input === "boolean")
33817
+ return payload;
33818
+ payload.issues.push({
33819
+ expected: "boolean",
33820
+ code: "invalid_type",
33821
+ input,
33822
+ inst
33823
+ });
33824
+ return payload;
33825
+ };
33826
+ });
33573
33827
  var $ZodUnknown2 = /* @__PURE__ */ $constructor2("$ZodUnknown", (inst, def) => {
33574
33828
  $ZodType2.init(inst, def);
33575
33829
  inst._zod.parse = (payload) => payload;
@@ -33940,7 +34194,7 @@ function mergeValues2(a, b) {
33940
34194
  if (a instanceof Date && b instanceof Date && +a === +b) {
33941
34195
  return { valid: true, data: a };
33942
34196
  }
33943
- if (isPlainObject4(a) && isPlainObject4(b)) {
34197
+ if (isPlainObject$1(a) && isPlainObject$1(b)) {
33944
34198
  const bKeys = Object.keys(b);
33945
34199
  const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
33946
34200
  const newObj = { ...a, ...b };
@@ -34295,7 +34549,7 @@ function handleRefineResult2(result, payload, input, inst) {
34295
34549
  payload.issues.push(issue2(_iss));
34296
34550
  }
34297
34551
  }
34298
- var _a3;
34552
+ var _a$1;
34299
34553
 
34300
34554
  class $ZodRegistry2 {
34301
34555
  constructor() {
@@ -34340,7 +34594,7 @@ class $ZodRegistry2 {
34340
34594
  function registry3() {
34341
34595
  return new $ZodRegistry2;
34342
34596
  }
34343
- (_a3 = globalThis).__zod_globalRegistry ?? (_a3.__zod_globalRegistry = registry3());
34597
+ (_a$1 = globalThis).__zod_globalRegistry ?? (_a$1.__zod_globalRegistry = registry3());
34344
34598
  var globalRegistry2 = globalThis.__zod_globalRegistry;
34345
34599
  function _string2(Class2, params) {
34346
34600
  return new Class2({
@@ -34585,6 +34839,12 @@ function _isoDuration2(Class2, params) {
34585
34839
  ...normalizeParams2(params)
34586
34840
  });
34587
34841
  }
34842
+ function _boolean2(Class2, params) {
34843
+ return new Class2({
34844
+ type: "boolean",
34845
+ ...normalizeParams2(params)
34846
+ });
34847
+ }
34588
34848
  function _unknown2(Class2) {
34589
34849
  return new Class2({
34590
34850
  type: "unknown"
@@ -34750,7 +35010,7 @@ function initializeContext2(params) {
34750
35010
  };
34751
35011
  }
34752
35012
  function process13(schema, ctx, _params = { path: [], schemaPath: [] }) {
34753
- var _a4;
35013
+ var _a3;
34754
35014
  const def = schema._zod.def;
34755
35015
  const seen = ctx.seen.get(schema);
34756
35016
  if (seen) {
@@ -34798,7 +35058,7 @@ function process13(schema, ctx, _params = { path: [], schemaPath: [] }) {
34798
35058
  delete result.schema.default;
34799
35059
  }
34800
35060
  if (ctx.io === "input" && result.schema._prefault)
34801
- (_a4 = result.schema).default ?? (_a4.default = result.schema._prefault);
35061
+ (_a3 = result.schema).default ?? (_a3.default = result.schema._prefault);
34802
35062
  delete result.schema._prefault;
34803
35063
  const _result = ctx.seen.get(schema);
34804
35064
  return _result.schema;
@@ -35115,6 +35375,9 @@ var stringProcessor2 = (schema, ctx, _json, _params) => {
35115
35375
  }
35116
35376
  }
35117
35377
  };
35378
+ var booleanProcessor2 = (_schema, _ctx, json2, _params) => {
35379
+ json2.type = "boolean";
35380
+ };
35118
35381
  var neverProcessor2 = (_schema, _ctx, json2, _params) => {
35119
35382
  json2.not = {};
35120
35383
  };
@@ -35573,6 +35836,14 @@ var ZodJWT2 = /* @__PURE__ */ $constructor2("ZodJWT", (inst, def) => {
35573
35836
  $ZodJWT2.init(inst, def);
35574
35837
  ZodStringFormat2.init(inst, def);
35575
35838
  });
35839
+ var ZodBoolean2 = /* @__PURE__ */ $constructor2("ZodBoolean", (inst, def) => {
35840
+ $ZodBoolean2.init(inst, def);
35841
+ ZodType2.init(inst, def);
35842
+ inst._zod.processJSONSchema = (ctx, json2, params) => booleanProcessor2(inst, ctx, json2);
35843
+ });
35844
+ function boolean4(params) {
35845
+ return _boolean2(ZodBoolean2, params);
35846
+ }
35576
35847
  var ZodUnknown2 = /* @__PURE__ */ $constructor2("ZodUnknown", (inst, def) => {
35577
35848
  $ZodUnknown2.init(inst, def);
35578
35849
  ZodType2.init(inst, def);
@@ -35883,7 +36154,8 @@ object2({
35883
36154
  secret: string4().optional(),
35884
36155
  clientId: string4().optional(),
35885
36156
  redirectUri: string4().url().optional(),
35886
- scope: string4().optional()
36157
+ scope: string4().optional(),
36158
+ enforceSso: boolean4().optional()
35887
36159
  });
35888
36160
 
35889
36161
  class UiPathConfig {
@@ -35895,6 +36167,7 @@ class UiPathConfig {
35895
36167
  this.clientId = options.clientId;
35896
36168
  this.redirectUri = options.redirectUri;
35897
36169
  this.scope = options.scope;
36170
+ this.enforceSso = options.enforceSso;
35898
36171
  }
35899
36172
  }
35900
36173
 
@@ -36097,6 +36370,7 @@ var TaskType;
36097
36370
  TaskType2["DocumentValidation"] = "DocumentValidationTask";
36098
36371
  TaskType2["DocumentClassification"] = "DocumentClassificationTask";
36099
36372
  TaskType2["DataLabeling"] = "DataLabelingTask";
36373
+ TaskType2["QuickForm"] = "QuickFormTask";
36100
36374
  })(TaskType || (TaskType = {}));
36101
36375
  var TaskPriority;
36102
36376
  (function(TaskPriority2) {
@@ -36209,7 +36483,11 @@ var PROCESS_ENDPOINTS = {
36209
36483
  var QUEUE_ENDPOINTS = {
36210
36484
  GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/QueueDefinitions`,
36211
36485
  GET_ALL: `${ORCHESTRATOR_BASE}/odata/QueueDefinitions/UiPath.Server.Configuration.OData.GetQueuesAcrossFolders`,
36212
- GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/QueueDefinitions(${id})`
36486
+ GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/QueueDefinitions(${id})`,
36487
+ GET_ITEMS: `${ORCHESTRATOR_BASE}/odata/QueueItems`,
36488
+ ADD_ITEM: `${ORCHESTRATOR_BASE}/odata/Queues/UiPathODataSvc.AddQueueItem`,
36489
+ START_TRANSACTION: `${ORCHESTRATOR_BASE}/odata/Queues/UiPathODataSvc.StartTransaction`,
36490
+ SET_TRANSACTION_RESULT: (itemId) => `${ORCHESTRATOR_BASE}/odata/Queues(${itemId})/UiPathODataSvc.SetTransactionResult`
36213
36491
  };
36214
36492
  var JOB_ENDPOINTS = {
36215
36493
  GET_ALL: `${ORCHESTRATOR_BASE}/odata/Jobs`,
@@ -36256,6 +36534,10 @@ var MAESTRO_ENDPOINTS = {
36256
36534
  TRACES: {
36257
36535
  GET_SPANS: (traceId) => `${LLMOPS_BASE}/api/Traces/spans?traceId=${traceId}`
36258
36536
  },
36537
+ BUSINESS_APPS: {
36538
+ COLLECTION: `${PIMS_BASE}/api/v1/business-apps`,
36539
+ BY_ID: (businessAppId) => `${PIMS_BASE}/api/v1/business-apps/${businessAppId}`
36540
+ },
36259
36541
  CASES: {
36260
36542
  GET_CASE_JSON: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/case-json`,
36261
36543
  GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/element-executions/case-instances/${instanceId}`,
@@ -36290,13 +36572,24 @@ var DATA_FABRIC_ENDPOINTS = {
36290
36572
  DELETE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/delete-batch`,
36291
36573
  UPSERT: `${DATAFABRIC_BASE}/api/Entity`,
36292
36574
  DELETE: (entityId) => `${DATAFABRIC_BASE}/api/Entity/${entityId}`,
36293
- UPDATE_METADATA: (entityId) => `${DATAFABRIC_BASE}/api/Entity/${entityId}/metadata`,
36575
+ UPDATE: (entityId) => `${DATAFABRIC_BASE}/api/Entity/${entityId}/metadata`,
36294
36576
  QUERY_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/query`,
36295
36577
  QUERY_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/EntityService/${entityName}/query`,
36296
36578
  BULK_UPLOAD_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/bulk-upload`,
36297
36579
  DOWNLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
36298
36580
  UPLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
36299
- DELETE_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`
36581
+ DELETE_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
36582
+ GET_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/Entity/${entityName}/metadata`,
36583
+ GET_ENTITY_RECORDS_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/EntityService/${entityName}/read`,
36584
+ GET_RECORD_BY_NAME: (entityName, recordId) => `${DATAFABRIC_BASE}/api/v2/EntityService/${entityName}/read/${recordId}`,
36585
+ INSERT_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/EntityService/${entityName}/insert`,
36586
+ BATCH_INSERT_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/EntityService/${entityName}/insert-batch`,
36587
+ UPDATE_RECORD_BY_NAME: (entityName, recordId) => `${DATAFABRIC_BASE}/api/EntityService/${entityName}/update/${recordId}`,
36588
+ UPDATE_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/EntityService/${entityName}/update-batch`,
36589
+ DELETE_RECORD_BY_NAME: (entityName, recordId) => `${DATAFABRIC_BASE}/api/EntityService/${entityName}/delete/${recordId}`,
36590
+ DELETE_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/EntityService/${entityName}/delete-batch`,
36591
+ BULK_UPLOAD_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/EntityService/${entityName}/bulk-upload`,
36592
+ ATTACHMENT_BY_NAME: (entityName, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/${entityName}/${recordId}/${fieldName}`
36300
36593
  },
36301
36594
  CHOICESETS: {
36302
36595
  GET_ALL: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
@@ -36319,7 +36612,8 @@ var DATA_FABRIC_ENDPOINTS = {
36319
36612
  };
36320
36613
  var IDENTITY_ENDPOINTS = {
36321
36614
  TOKEN: `${IDENTITY_BASE}/connect/token`,
36322
- AUTHORIZE: `${IDENTITY_BASE}/connect/authorize`
36615
+ AUTHORIZE: `${IDENTITY_BASE}/connect/authorize`,
36616
+ END_SESSION: `${IDENTITY_BASE}/connect/endsession`
36323
36617
  };
36324
36618
  var TASK_TYPE_ENDPOINTS = {
36325
36619
  [TaskType.Form]: TASK_ENDPOINTS.GET_TASK_FORM_BY_ID,
@@ -36327,7 +36621,8 @@ var TASK_TYPE_ENDPOINTS = {
36327
36621
  [TaskType.DocumentValidation]: TASK_ENDPOINTS.GET_GENERIC_TASK_BY_ID,
36328
36622
  [TaskType.DocumentClassification]: TASK_ENDPOINTS.GET_GENERIC_TASK_BY_ID,
36329
36623
  [TaskType.External]: TASK_ENDPOINTS.GET_GENERIC_TASK_BY_ID,
36330
- [TaskType.DataLabeling]: TASK_ENDPOINTS.GET_GENERIC_TASK_BY_ID
36624
+ [TaskType.DataLabeling]: TASK_ENDPOINTS.GET_GENERIC_TASK_BY_ID,
36625
+ [TaskType.QuickForm]: TASK_ENDPOINTS.GET_GENERIC_TASK_BY_ID
36331
36626
  };
36332
36627
  var ActionCenterEventNames;
36333
36628
  (function(ActionCenterEventNames2) {
@@ -36335,29 +36630,12 @@ var ActionCenterEventNames;
36335
36630
  ActionCenterEventNames2["REFRESHTOKEN"] = "AC.refreshToken";
36336
36631
  })(ActionCenterEventNames || (ActionCenterEventNames = {}));
36337
36632
  var AUTHENTICATION_TIMEOUT = 8000;
36338
- var ALLOWED_HOST_ORIGINS = new Set([
36339
- "https://alpha.uipath.com",
36340
- "https://staging.uipath.com",
36341
- "https://cloud.uipath.com"
36342
- ]);
36343
- function isValidHostOrigin(origin) {
36344
- if (!origin)
36345
- return false;
36346
- if (ALLOWED_HOST_ORIGINS.has(origin))
36347
- return true;
36348
- try {
36349
- return new URL(origin).hostname === "localhost";
36350
- } catch {
36351
- console.warn("isValidHostOrigin: received a malformed origin URL", origin);
36352
- return false;
36353
- }
36354
- }
36355
36633
  function isTokenExpired(tokenInfo) {
36356
36634
  if (!tokenInfo?.expiresAt)
36357
36635
  return true;
36358
36636
  return new Date >= tokenInfo.expiresAt;
36359
36637
  }
36360
- var trustedEmbeddingOrigin = isHostEmbedded && embeddingOrigin && isValidHostOrigin(embeddingOrigin) ? embeddingOrigin : null;
36638
+ var hostEmbeddingOrigin = isHostEmbedded && embeddingOrigin ? embeddingOrigin : null;
36361
36639
  function waitForMessage(filter, signal) {
36362
36640
  return new Promise((resolve2, reject) => {
36363
36641
  const handler = (event) => {
@@ -36426,12 +36704,6 @@ class ActionCenterTokenManager {
36426
36704
  statusCode: HttpStatus.UNAUTHORIZED
36427
36705
  }));
36428
36706
  }
36429
- if (!isValidHostOrigin(parentOrigin)) {
36430
- return Promise.reject(new AuthenticationError({
36431
- message: "Cannot refresh token: basedomain is not a trusted UiPath host origin",
36432
- statusCode: HttpStatus.UNAUTHORIZED
36433
- }));
36434
- }
36435
36707
  const { promise: promise2 } = requestHostToken({
36436
36708
  pinnedOrigin: parentOrigin,
36437
36709
  sendRequest: () => this.sendMessageToParent(ActionCenterEventNames.REFRESHTOKEN, {
@@ -36455,7 +36727,7 @@ class ActionCenterTokenManager {
36455
36727
  }
36456
36728
  }
36457
36729
  sendMessageToParent(eventType, content) {
36458
- if (window.parent && isValidHostOrigin(this.parentOrigin)) {
36730
+ if (window.parent && this.parentOrigin) {
36459
36731
  try {
36460
36732
  window.parent.postMessage({ eventType, content }, this.parentOrigin);
36461
36733
  } catch (error52) {
@@ -36535,7 +36807,7 @@ class EmbeddedTokenManager {
36535
36807
  this.cancelRefresh?.();
36536
36808
  }
36537
36809
  }
36538
- var SDK_VERSION = "1.6.1";
36810
+ var SDK_VERSION = "1.7.1";
36539
36811
  var CLOUD_ROLE_NAME = "uipath-ts-sdk";
36540
36812
  var SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
36541
36813
  var SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
@@ -36601,19 +36873,21 @@ function base64UrlToBase64(value) {
36601
36873
  const base644 = value.replace(BASE64URL_DASH_RE, "+").replace(BASE64URL_UNDERSCORE_RE, "/");
36602
36874
  return base644.padEnd(base644.length + (4 - base644.length % 4) % 4, "=");
36603
36875
  }
36604
- function extractUserIdFromToken(token) {
36876
+ function decodeJwtClaims(token) {
36605
36877
  try {
36606
- const payload = token.split(".")[1];
36878
+ const payload = token?.split(".")[1];
36607
36879
  if (!payload) {
36608
- return "";
36880
+ return;
36609
36881
  }
36610
- const claims = JSON.parse(decodeBase64(base64UrlToBase64(payload)));
36611
- const sub = claims["sub"];
36612
- return typeof sub === "string" && sub ? sub : "";
36882
+ return JSON.parse(decodeBase64(base64UrlToBase64(payload)));
36613
36883
  } catch {
36614
- return "";
36884
+ return;
36615
36885
  }
36616
36886
  }
36887
+ function extractUserIdFromToken(token) {
36888
+ const sub = decodeJwtClaims(token)?.["sub"];
36889
+ return typeof sub === "string" && sub ? sub : "";
36890
+ }
36617
36891
 
36618
36892
  class TokenManager {
36619
36893
  constructor(executionContext, config3, isOAuth = false) {
@@ -36626,8 +36900,8 @@ class TokenManager {
36626
36900
  if (isInActionCenter) {
36627
36901
  this.actionCenterTokenManager = new ActionCenterTokenManager(config3, (tokenInfo) => this.setToken(tokenInfo));
36628
36902
  this.isOAuth = false;
36629
- } else if (trustedEmbeddingOrigin) {
36630
- this.embeddedTokenManager = new EmbeddedTokenManager(trustedEmbeddingOrigin, config3, (tokenInfo) => this.setToken(tokenInfo));
36903
+ } else if (hostEmbeddingOrigin) {
36904
+ this.embeddedTokenManager = new EmbeddedTokenManager(hostEmbeddingOrigin, config3, (tokenInfo) => this.setToken(tokenInfo));
36631
36905
  this.isOAuth = false;
36632
36906
  }
36633
36907
  }
@@ -36738,6 +37012,9 @@ class TokenManager {
36738
37012
  getToken() {
36739
37013
  return this.currentToken?.token;
36740
37014
  }
37015
+ getIdToken() {
37016
+ return this.currentToken?.idToken;
37017
+ }
36741
37018
  hasValidToken() {
36742
37019
  if (!this.currentToken) {
36743
37020
  return false;
@@ -36809,11 +37086,13 @@ class TokenManager {
36809
37086
  token: token.access_token,
36810
37087
  type: "oauth",
36811
37088
  expiresAt: new Date(Date.now() + token.expires_in * 1000),
36812
- refreshToken: token.refresh_token
37089
+ refreshToken: token.refresh_token,
37090
+ idToken: token.id_token ?? tokenInfo.idToken
36813
37091
  });
36814
37092
  return token;
36815
37093
  }
36816
37094
  }
37095
+ var GUID_REGEX$1 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
36817
37096
 
36818
37097
  class AuthService {
36819
37098
  constructor(config3, executionContext) {
@@ -36947,7 +37226,11 @@ class AuthService {
36947
37226
  hasValidToken() {
36948
37227
  return this.tokenManager.hasValidToken();
36949
37228
  }
36950
- logout() {
37229
+ logout(options) {
37230
+ const idTokenHint = options?.endSession ? this.tokenManager.getIdToken() : undefined;
37231
+ if (options?.endSession && isBrowser2 && !idTokenHint) {
37232
+ console.warn("endSession skipped — no OIDC ID token is available for this " + "session. Sign in again to enable it; only local authentication " + "state was cleared.");
37233
+ }
36951
37234
  this.tokenManager.clearToken();
36952
37235
  if (isBrowser2) {
36953
37236
  try {
@@ -36957,6 +37240,12 @@ class AuthService {
36957
37240
  console.warn("Failed to clear OAuth context from session storage", error52);
36958
37241
  }
36959
37242
  }
37243
+ if (options?.endSession && isBrowser2 && idTokenHint) {
37244
+ window.location.href = this._buildEndSessionUrl({
37245
+ idTokenHint,
37246
+ postLogoutRedirectUri: this.config.redirectUri
37247
+ });
37248
+ }
36960
37249
  }
36961
37250
  getToken() {
36962
37251
  if (!this.tokenManager.hasValidToken()) {
@@ -37000,10 +37289,27 @@ class AuthService {
37000
37289
  redirect_uri: params.redirectUri,
37001
37290
  code_challenge: params.codeChallenge,
37002
37291
  code_challenge_method: "S256",
37003
- scope: params.scope + " offline_access",
37292
+ scope: params.scope + " offline_access openid",
37004
37293
  state: params.state || this.generateCodeVerifier().slice(0, 16)
37005
37294
  });
37006
- return `${this.config.baseUrl}/${IDENTITY_ENDPOINTS.AUTHORIZE}?${queryParams.toString()}`;
37295
+ const authorizeUrl = `${this.config.baseUrl}/${IDENTITY_ENDPOINTS.AUTHORIZE}?${queryParams.toString()}`;
37296
+ if (!this.config.enforceSso) {
37297
+ return authorizeUrl;
37298
+ }
37299
+ const orgName = this.config.orgName;
37300
+ if (!GUID_REGEX$1.test(orgName)) {
37301
+ console.warn(`[UiPath SDK] enforceSso was ignored: orgName "${orgName}" is not an organization id. ` + "Pass the organization id (GUID) as orgName to sign in through the org's identity provider.");
37302
+ return authorizeUrl;
37303
+ }
37304
+ return `${authorizeUrl}&acr_values=${encodeURIComponent(`tenant:${orgName}`)}`;
37305
+ }
37306
+ _buildEndSessionUrl(params) {
37307
+ const queryParams = new URLSearchParams;
37308
+ queryParams.set("id_token_hint", params.idTokenHint);
37309
+ if (params.postLogoutRedirectUri) {
37310
+ queryParams.set("post_logout_redirect_uri", params.postLogoutRedirectUri);
37311
+ }
37312
+ return `${this.config.baseUrl}/${IDENTITY_ENDPOINTS.END_SESSION}?${queryParams.toString()}`;
37007
37313
  }
37008
37314
  async _getAccessToken(params) {
37009
37315
  const body = new URLSearchParams({
@@ -37030,7 +37336,8 @@ class AuthService {
37030
37336
  token: token.access_token,
37031
37337
  type: "oauth",
37032
37338
  expiresAt: token.expires_in ? new Date(Date.now() + token.expires_in * 1000) : undefined,
37033
- refreshToken: token.refresh_token
37339
+ refreshToken: token.refresh_token,
37340
+ idToken: token.id_token
37034
37341
  });
37035
37342
  return token;
37036
37343
  }
@@ -37103,9 +37410,18 @@ function validateConfig(config3) {
37103
37410
  function isCompleteConfig(config3) {
37104
37411
  return hasRequiredBaseFields(config3) && hasValidAuthConfig(config3);
37105
37412
  }
37413
+ function compactConfig(config3) {
37414
+ return Object.fromEntries(Object.entries(config3).filter(([, value]) => value !== undefined));
37415
+ }
37106
37416
  function normalizeBaseUrl2(url2) {
37107
37417
  return url2.endsWith("/") ? url2.slice(0, -1) : url2;
37108
37418
  }
37419
+ function missingConfigMessage() {
37420
+ if (isBrowser2) {
37421
+ return "UiPath SDK configuration not found. " + "Ensure @uipath/coded-apps plugin is set up in your bundler to inject configuration during development and build.";
37422
+ }
37423
+ return "UiPath SDK configuration not found. " + "In a UiPath coded function, pass the handler context: new UiPath(ctx). " + "Otherwise pass { baseUrl, orgName, tenantName, secret }, " + "or set UIPATH_BASE_URL, UIPATH_ORG_NAME, UIPATH_TENANT_NAME and UIPATH_ACCESS_TOKEN.";
37424
+ }
37109
37425
  var REGISTRY_KEY2 = Symbol.for("@uipath/sdk-internals-registry");
37110
37426
  var getGlobalStore = () => {
37111
37427
  const globalObj = globalThis;
@@ -37114,6 +37430,7 @@ var getGlobalStore = () => {
37114
37430
  }
37115
37431
  return globalObj[REGISTRY_KEY2];
37116
37432
  };
37433
+ var looksLikeUiPath = (instance) => typeof instance.initialize === "function";
37117
37434
 
37118
37435
  class SDKInternalsRegistry {
37119
37436
  static get store() {
@@ -37125,6 +37442,9 @@ class SDKInternalsRegistry {
37125
37442
  static get(instance) {
37126
37443
  const internals = this.store.get(instance);
37127
37444
  if (!internals) {
37445
+ if (looksLikeUiPath(instance)) {
37446
+ throw new Error("Cannot create a service: the UiPath instance was never configured. " + missingConfigMessage());
37447
+ }
37128
37448
  throw new Error("Invalid SDK instance. Make sure to pass a valid UiPath instance to the service constructor.");
37129
37449
  }
37130
37450
  return internals;
@@ -37142,6 +37462,10 @@ var UiPathMetaTags;
37142
37462
  UiPathMetaTags2["APP_BASE"] = "uipath:app-base";
37143
37463
  UiPathMetaTags2["FOLDER_KEY"] = "uipath:folder-key";
37144
37464
  })(UiPathMetaTags || (UiPathMetaTags = {}));
37465
+ var UiPathElementIds;
37466
+ (function(UiPathElementIds2) {
37467
+ UiPathElementIds2["RESOURCE_OVERRIDES"] = "uipath-overrides";
37468
+ })(UiPathElementIds || (UiPathElementIds = {}));
37145
37469
  function getMetaTagContent(name) {
37146
37470
  if (!isBrowser2)
37147
37471
  return;
@@ -37162,7 +37486,54 @@ function loadFromMetaTags() {
37162
37486
  const hasAnyValue = Object.values(config3).some(Boolean);
37163
37487
  return hasAnyValue ? config3 : null;
37164
37488
  }
37489
+ function readEnv(name) {
37490
+ const globals = globalThis;
37491
+ try {
37492
+ const fromNode = globals.process?.env?.[name];
37493
+ if (fromNode)
37494
+ return fromNode;
37495
+ } catch {}
37496
+ try {
37497
+ const fromDeno = globals.Deno?.env?.get?.(name);
37498
+ if (fromDeno)
37499
+ return fromDeno;
37500
+ } catch {}
37501
+ return;
37502
+ }
37503
+ var UiPathEnvVars = {
37504
+ BASE_URL: "UIPATH_BASE_URL",
37505
+ ORG_NAME: "UIPATH_ORG_NAME",
37506
+ TENANT_NAME: "UIPATH_TENANT_NAME",
37507
+ ACCESS_TOKEN: "UIPATH_ACCESS_TOKEN"
37508
+ };
37509
+ function loadFromEnvironment() {
37510
+ if (isBrowser2)
37511
+ return null;
37512
+ const config3 = {
37513
+ baseUrl: readEnv(UiPathEnvVars.BASE_URL),
37514
+ orgName: readEnv(UiPathEnvVars.ORG_NAME),
37515
+ tenantName: readEnv(UiPathEnvVars.TENANT_NAME),
37516
+ secret: readEnv(UiPathEnvVars.ACCESS_TOKEN)
37517
+ };
37518
+ return Object.values(config3).some(Boolean) ? config3 : null;
37519
+ }
37520
+ function isFunctionContext(value) {
37521
+ return "platform" in value || "robot" in value;
37522
+ }
37523
+ function configFromFunctionContext(context) {
37524
+ const { platform, robot } = context;
37525
+ if (!platform)
37526
+ return null;
37527
+ const config3 = {
37528
+ baseUrl: platform.baseUrl,
37529
+ orgName: platform.orgId,
37530
+ tenantName: platform.tenantId,
37531
+ secret: robot?.accessToken ?? undefined
37532
+ };
37533
+ return Object.values(config3).some(Boolean) ? config3 : null;
37534
+ }
37165
37535
  var _UiPath_instances;
37536
+ var _a3;
37166
37537
  var _UiPath_config;
37167
37538
  var _UiPath_authService;
37168
37539
  var _UiPath_initialized;
@@ -37171,6 +37542,7 @@ var _UiPath_metaFolderKey;
37171
37542
  var _UiPath_metaOrgId;
37172
37543
  var _UiPath_metaTenantId;
37173
37544
  var _UiPath_initializeWithConfig;
37545
+ var _UiPath_mergeConfigSources;
37174
37546
  var _UiPath_loadConfig;
37175
37547
  var UiPath$1 = class UiPath {
37176
37548
  constructor(config3) {
@@ -37182,15 +37554,16 @@ var UiPath$1 = class UiPath {
37182
37554
  _UiPath_metaFolderKey.set(this, undefined);
37183
37555
  _UiPath_metaOrgId.set(this, undefined);
37184
37556
  _UiPath_metaTenantId.set(this, undefined);
37557
+ const resolved = config3 && isFunctionContext(config3) ? configFromFunctionContext(config3) ?? undefined : config3;
37185
37558
  const configFromMetaTags = loadFromMetaTags();
37186
37559
  __classPrivateFieldSet(this, _UiPath_metaFolderKey, configFromMetaTags?.folderKey, "f");
37187
37560
  __classPrivateFieldSet(this, _UiPath_metaOrgId, configFromMetaTags?.orgName, "f");
37188
37561
  __classPrivateFieldSet(this, _UiPath_metaTenantId, configFromMetaTags?.tenantName, "f");
37189
- const mergedConfig = config3 ? { ...configFromMetaTags, ...config3 } : configFromMetaTags;
37562
+ const mergedConfig = __classPrivateFieldGet(_a3, _a3, "m", _UiPath_mergeConfigSources).call(_a3, configFromMetaTags, resolved);
37190
37563
  if (mergedConfig && isCompleteConfig(mergedConfig)) {
37191
37564
  __classPrivateFieldGet(this, _UiPath_instances, "m", _UiPath_initializeWithConfig).call(this, mergedConfig);
37192
- } else if (config3) {
37193
- __classPrivateFieldSet(this, _UiPath_partialConfig, config3, "f");
37565
+ } else if (resolved) {
37566
+ __classPrivateFieldSet(this, _UiPath_partialConfig, resolved, "f");
37194
37567
  }
37195
37568
  }
37196
37569
  async initialize() {
@@ -37255,18 +37628,18 @@ var UiPath$1 = class UiPath {
37255
37628
  destroy() {
37256
37629
  __classPrivateFieldGet(this, _UiPath_authService, "f")?.getTokenManager()?.destroy();
37257
37630
  }
37258
- logout() {
37631
+ logout(options) {
37259
37632
  if (__classPrivateFieldGet(this, _UiPath_config, "f") && hasSecretConfig(__classPrivateFieldGet(this, _UiPath_config, "f"))) {
37260
37633
  return;
37261
37634
  }
37262
- __classPrivateFieldGet(this, _UiPath_authService, "f")?.logout();
37635
+ __classPrivateFieldGet(this, _UiPath_authService, "f")?.logout(options);
37263
37636
  __classPrivateFieldSet(this, _UiPath_initialized, false, "f");
37264
37637
  }
37265
37638
  updateToken(tokenInfo) {
37266
37639
  __classPrivateFieldGet(this, _UiPath_authService, "f")?.updateToken(tokenInfo);
37267
37640
  }
37268
37641
  };
37269
- _UiPath_config = new WeakMap, _UiPath_authService = new WeakMap, _UiPath_initialized = new WeakMap, _UiPath_partialConfig = new WeakMap, _UiPath_metaFolderKey = new WeakMap, _UiPath_metaOrgId = new WeakMap, _UiPath_metaTenantId = new WeakMap, _UiPath_instances = new WeakSet, _UiPath_initializeWithConfig = function _UiPath_initializeWithConfig2(config3) {
37642
+ _a3 = UiPath$1, _UiPath_config = new WeakMap, _UiPath_authService = new WeakMap, _UiPath_initialized = new WeakMap, _UiPath_partialConfig = new WeakMap, _UiPath_metaFolderKey = new WeakMap, _UiPath_metaOrgId = new WeakMap, _UiPath_metaTenantId = new WeakMap, _UiPath_instances = new WeakSet, _UiPath_initializeWithConfig = function _UiPath_initializeWithConfig2(config3) {
37270
37643
  validateConfig(config3);
37271
37644
  const hasSecretAuth = hasSecretConfig(config3);
37272
37645
  const hasOAuthAuth = hasOAuthConfig(config3);
@@ -37277,7 +37650,8 @@ _UiPath_config = new WeakMap, _UiPath_authService = new WeakMap, _UiPath_initial
37277
37650
  secret: hasSecretAuth ? config3.secret : undefined,
37278
37651
  clientId: hasOAuthAuth ? config3.clientId : undefined,
37279
37652
  redirectUri: hasOAuthAuth ? config3.redirectUri : undefined,
37280
- scope: hasOAuthAuth ? config3.scope : undefined
37653
+ scope: hasOAuthAuth ? config3.scope : undefined,
37654
+ enforceSso: config3.enforceSso
37281
37655
  });
37282
37656
  const executionContext = new ExecutionContext;
37283
37657
  __classPrivateFieldSet(this, _UiPath_authService, new AuthService(internalConfig, executionContext), "f");
@@ -37303,18 +37677,35 @@ _UiPath_config = new WeakMap, _UiPath_authService = new WeakMap, _UiPath_initial
37303
37677
  redirectUri: hasOAuthAuth ? config3.redirectUri : undefined
37304
37678
  });
37305
37679
  trackEvent("Sdk.Auth");
37306
- if (hasSecretAuth || isInActionCenter || trustedEmbeddingOrigin) {
37680
+ if (hasSecretAuth || isInActionCenter || hostEmbeddingOrigin) {
37307
37681
  __classPrivateFieldGet(this, _UiPath_authService, "f").authenticateWithSecret(config3.secret ?? "");
37308
37682
  __classPrivateFieldSet(this, _UiPath_initialized, true, "f");
37309
37683
  }
37684
+ }, _UiPath_mergeConfigSources = function _UiPath_mergeConfigSources2(metaConfig, config3) {
37685
+ const layers = [loadFromEnvironment(), metaConfig, config3].filter((layer) => Boolean(layer)).map((layer) => compactConfig(layer));
37686
+ if (layers.length === 0)
37687
+ return;
37688
+ const merged = layers.reduce((acc, layer) => ({ ...acc, ...layer }), {});
37689
+ const namesSecret = config3 ? hasSecretConfig(config3) : false;
37690
+ const namesOAuth = Boolean(config3?.clientId || config3?.redirectUri || config3?.scope);
37691
+ if (namesSecret !== namesOAuth) {
37692
+ if (namesSecret) {
37693
+ delete merged.clientId;
37694
+ delete merged.redirectUri;
37695
+ delete merged.scope;
37696
+ } else {
37697
+ delete merged.secret;
37698
+ }
37699
+ }
37700
+ return merged;
37310
37701
  }, _UiPath_loadConfig = function _UiPath_loadConfig2() {
37311
37702
  const metaConfig = loadFromMetaTags();
37312
37703
  __classPrivateFieldSet(this, _UiPath_metaFolderKey, metaConfig?.folderKey, "f");
37313
37704
  __classPrivateFieldSet(this, _UiPath_metaOrgId, metaConfig?.orgName, "f");
37314
37705
  __classPrivateFieldSet(this, _UiPath_metaTenantId, metaConfig?.tenantName, "f");
37315
- const merged = { ...metaConfig, ...__classPrivateFieldGet(this, _UiPath_partialConfig, "f") };
37316
- if (!isCompleteConfig(merged)) {
37317
- throw new Error("UiPath SDK configuration not found. " + "Ensure @uipath/coded-apps plugin is set up in your bundler to inject configuration during development and build.");
37706
+ const merged = __classPrivateFieldGet(_a3, _a3, "m", _UiPath_mergeConfigSources).call(_a3, metaConfig, __classPrivateFieldGet(this, _UiPath_partialConfig, "f"));
37707
+ if (!merged || !isCompleteConfig(merged)) {
37708
+ throw new Error(missingConfigMessage());
37318
37709
  }
37319
37710
  return merged;
37320
37711
  };
@@ -37492,8 +37883,177 @@ var RESPONSE_TYPES = {
37492
37883
  JSON: "json",
37493
37884
  TEXT: "text",
37494
37885
  BLOB: "blob",
37495
- ARRAYBUFFER: "arraybuffer"
37886
+ ARRAYBUFFER: "arraybuffer",
37887
+ STREAM: "stream"
37496
37888
  };
37889
+ function createParams(paramsObj = {}) {
37890
+ const params = {};
37891
+ for (const [key, value] of Object.entries(paramsObj)) {
37892
+ if (value !== undefined && value !== null) {
37893
+ params[key] = value;
37894
+ }
37895
+ }
37896
+ return params;
37897
+ }
37898
+ function toSearchParams(params) {
37899
+ const searchParams = new URLSearchParams;
37900
+ if (!params)
37901
+ return searchParams;
37902
+ for (const [key, value] of Object.entries(params)) {
37903
+ if (value === undefined || value === null)
37904
+ continue;
37905
+ if (Array.isArray(value)) {
37906
+ value.forEach((item) => {
37907
+ if (item !== undefined && item !== null)
37908
+ searchParams.append(key, String(item));
37909
+ });
37910
+ } else {
37911
+ searchParams.append(key, String(value));
37912
+ }
37913
+ }
37914
+ return searchParams;
37915
+ }
37916
+ var DEFAULT_RETRYABLE_STATUS_CODES = [408, 429, 500, 502, 503, 504];
37917
+ var DEFAULT_RETRY_METHODS = ["GET", "HEAD", "PUT", "DELETE", "OPTIONS"];
37918
+ var DEFAULT_RETRY_OPTIONS = {
37919
+ maxRetries: 2,
37920
+ initialDelayMs: 500,
37921
+ backoffStrategy: "exponential",
37922
+ backoffFactor: 2,
37923
+ backoffMaxDelayMs: 30000,
37924
+ retryableStatusCodes: DEFAULT_RETRYABLE_STATUS_CODES,
37925
+ retryMethods: DEFAULT_RETRY_METHODS,
37926
+ retryNetworkErrors: true,
37927
+ respectRetryAfter: true,
37928
+ maxRetryAfterMs: Infinity
37929
+ };
37930
+ var DEFAULT_API_CLIENT_RETRY = {
37931
+ ...DEFAULT_RETRY_OPTIONS,
37932
+ maxRetries: 0
37933
+ };
37934
+ function resolveRetryOptions(settings, defaults = DEFAULT_RETRY_OPTIONS) {
37935
+ if (!settings)
37936
+ return defaults;
37937
+ const { retryDelay, useExponentialBackoff, ...live } = settings;
37938
+ const resolved = { ...defaults };
37939
+ for (const [key, value] of Object.entries(live)) {
37940
+ if (value !== undefined) {
37941
+ resolved[key] = value;
37942
+ }
37943
+ }
37944
+ if (retryDelay !== undefined && live.initialDelayMs === undefined) {
37945
+ resolved.initialDelayMs = retryDelay;
37946
+ }
37947
+ if (useExponentialBackoff !== undefined && live.backoffStrategy === undefined) {
37948
+ resolved.backoffStrategy = useExponentialBackoff ? "exponential" : "constant";
37949
+ }
37950
+ return resolved;
37951
+ }
37952
+ function computeBackoffDelay(attempt, settings) {
37953
+ const base = Math.max(0, settings.initialDelayMs);
37954
+ let delay;
37955
+ switch (settings.backoffStrategy) {
37956
+ case "constant":
37957
+ delay = base;
37958
+ break;
37959
+ case "linear":
37960
+ delay = base * (attempt + 1);
37961
+ break;
37962
+ default:
37963
+ delay = base * Math.pow(settings.backoffFactor, attempt);
37964
+ }
37965
+ return Math.min(delay, settings.backoffMaxDelayMs);
37966
+ }
37967
+ function parseRetryAfter(value, now = Date.now()) {
37968
+ const trimmed = value?.trim();
37969
+ if (!trimmed)
37970
+ return;
37971
+ const seconds = Number(trimmed);
37972
+ if (Number.isFinite(seconds))
37973
+ return Math.max(0, seconds * 1000);
37974
+ const date6 = Date.parse(trimmed);
37975
+ if (Number.isNaN(date6))
37976
+ return;
37977
+ return Math.max(0, date6 - now);
37978
+ }
37979
+ function wait(durationMs) {
37980
+ return new Promise((resolve2) => setTimeout(resolve2, Math.max(0, durationMs)));
37981
+ }
37982
+ var RETRY_AFTER = "retry-after";
37983
+ function createAttemptSignal(timeoutMs, external2) {
37984
+ if (timeoutMs === undefined || !Number.isFinite(timeoutMs))
37985
+ return { signal: external2, dispose: () => {} };
37986
+ const controller = new AbortController;
37987
+ const timer = setTimeout(() => controller.abort(new Error(`Request timeout after ${timeoutMs}ms`)), timeoutMs);
37988
+ const onExternalAbort = () => controller.abort(external2?.reason);
37989
+ if (external2) {
37990
+ if (external2.aborted) {
37991
+ controller.abort(external2.reason);
37992
+ } else {
37993
+ external2.addEventListener("abort", onExternalAbort);
37994
+ }
37995
+ }
37996
+ return {
37997
+ signal: controller.signal,
37998
+ dispose: () => {
37999
+ clearTimeout(timer);
38000
+ external2?.removeEventListener("abort", onExternalAbort);
38001
+ }
38002
+ };
38003
+ }
38004
+ function delayBeforeRetry(durationMs, signal) {
38005
+ if (!signal)
38006
+ return wait(durationMs);
38007
+ if (signal.aborted)
38008
+ return Promise.reject(signal.reason);
38009
+ return new Promise((resolve2, reject) => {
38010
+ const onAbort = () => {
38011
+ clearTimeout(timer);
38012
+ reject(signal.reason);
38013
+ };
38014
+ const timer = setTimeout(() => {
38015
+ signal.removeEventListener("abort", onAbort);
38016
+ resolve2();
38017
+ }, Math.max(0, durationMs));
38018
+ signal.addEventListener("abort", onAbort);
38019
+ });
38020
+ }
38021
+ async function fetchWithRetry(url2, init, options) {
38022
+ const settings = options.retry;
38023
+ const method = (init.method ?? "GET").toUpperCase();
38024
+ const retriesAllowed = settings.retryMethods.includes(method) ? Math.max(0, settings.maxRetries) : 0;
38025
+ let attempt = 0;
38026
+ for (;; ) {
38027
+ const { signal, dispose } = createAttemptSignal(options.timeoutMs, options.signal);
38028
+ let response;
38029
+ let failure;
38030
+ try {
38031
+ response = await fetch(url2, { ...init, signal });
38032
+ } catch (error52) {
38033
+ failure = error52;
38034
+ } finally {
38035
+ dispose();
38036
+ }
38037
+ if (options.signal?.aborted && failure !== undefined)
38038
+ throw failure;
38039
+ if (response && !settings.retryableStatusCodes.includes(response.status))
38040
+ return response;
38041
+ if (failure !== undefined && !settings.retryNetworkErrors)
38042
+ throw failure;
38043
+ if (attempt >= retriesAllowed) {
38044
+ if (response)
38045
+ return response;
38046
+ throw failure;
38047
+ }
38048
+ const retryAfter = settings.respectRetryAfter && response ? parseRetryAfter(response.headers.get(RETRY_AFTER)) : undefined;
38049
+ const delay = retryAfter !== undefined ? Math.min(retryAfter, settings.maxRetryAfterMs) : computeBackoffDelay(attempt, settings);
38050
+ response?.body?.cancel().catch((error52) => {
38051
+ console.warn("[UiPath SDK] Could not release a discarded response body:", error52);
38052
+ });
38053
+ await delayBeforeRetry(delay, options.signal);
38054
+ attempt++;
38055
+ }
38056
+ }
37497
38057
 
37498
38058
  class ApiClient {
37499
38059
  constructor(config3, executionContext, tokenManager, clientConfig = {}) {
@@ -37528,28 +38088,16 @@ class ApiClient {
37528
38088
  [UIPATH_TRACEPARENT_ID]: traceparentValue,
37529
38089
  ...options.headers
37530
38090
  };
37531
- const searchParams = new URLSearchParams;
37532
- if (options.params) {
37533
- Object.entries(options.params).forEach(([key, value]) => {
37534
- if (Array.isArray(value)) {
37535
- value.forEach((item) => searchParams.append(key, String(item)));
37536
- } else {
37537
- searchParams.append(key, String(value));
37538
- }
37539
- });
37540
- }
38091
+ const searchParams = toSearchParams(options.params);
37541
38092
  const fullUrl = searchParams.toString() ? `${url2}?${searchParams.toString()}` : url2;
37542
38093
  let body = undefined;
37543
38094
  if (options.body) {
37544
38095
  body = isFormData ? options.body : JSON.stringify(options.body);
37545
38096
  }
38097
+ const retrySettings = resolveRetryOptions(options.retry ?? options.retryOptions, DEFAULT_API_CLIENT_RETRY);
38098
+ const timeoutMs = options.timeoutMs ?? options.timeoutOptions?.timeout;
37546
38099
  try {
37547
- const response = await fetch(fullUrl, {
37548
- method,
37549
- headers,
37550
- body,
37551
- signal: options.signal
37552
- });
38100
+ const response = await fetchWithRetry(fullUrl, { method, headers, body }, { retry: retrySettings, timeoutMs, signal: options.signal });
37553
38101
  if (!response.ok) {
37554
38102
  const errorInfo = await errorResponseParser.parse(response);
37555
38103
  throw ErrorFactory.createFromHttpStatus(response.status, errorInfo);
@@ -38265,36 +38813,36 @@ function createEntityMethods(entityData, service) {
38265
38813
  async insertRecord(data, options) {
38266
38814
  if (!entityData.id)
38267
38815
  throw new Error("Entity ID is undefined");
38268
- return service.insertRecordById(entityData.id, data, options);
38816
+ return service.insertRecord({ id: entityData.id }, data, options);
38269
38817
  },
38270
38818
  async insertRecords(data, options) {
38271
38819
  if (!entityData.id)
38272
38820
  throw new Error("Entity ID is undefined");
38273
- return service.insertRecordsById(entityData.id, data, options);
38821
+ return service.insertRecords({ id: entityData.id }, data, options);
38274
38822
  },
38275
38823
  async updateRecord(recordId, data, options) {
38276
38824
  if (!entityData.id)
38277
38825
  throw new Error("Entity ID is undefined");
38278
38826
  if (!recordId)
38279
38827
  throw new Error("Record ID is undefined");
38280
- return service.updateRecordById(entityData.id, recordId, data, options);
38828
+ return service.updateRecord({ id: entityData.id }, recordId, data, options);
38281
38829
  },
38282
38830
  async updateRecords(data, options) {
38283
38831
  if (!entityData.id)
38284
38832
  throw new Error("Entity ID is undefined");
38285
- return service.updateRecordsById(entityData.id, data, options);
38833
+ return service.updateRecords({ id: entityData.id }, data, options);
38286
38834
  },
38287
38835
  async deleteRecords(recordIds, options) {
38288
38836
  if (!entityData.id)
38289
38837
  throw new Error("Entity ID is undefined");
38290
- return service.deleteRecordsById(entityData.id, recordIds, options);
38838
+ return service.deleteRecords({ id: entityData.id }, recordIds, options);
38291
38839
  },
38292
38840
  async deleteRecord(recordId, options) {
38293
38841
  if (!entityData.id)
38294
38842
  throw new Error("Entity ID is undefined");
38295
38843
  if (!recordId)
38296
38844
  throw new Error("Record ID is undefined");
38297
- return service.deleteRecordById(entityData.id, recordId, options);
38845
+ return service.deleteRecord({ id: entityData.id }, recordId, options);
38298
38846
  },
38299
38847
  async getAllRecords(options) {
38300
38848
  if (!entityData.id)
@@ -38311,27 +38859,27 @@ function createEntityMethods(entityData, service) {
38311
38859
  async downloadAttachment(recordId, fieldName, options) {
38312
38860
  if (!entityData.id)
38313
38861
  throw new Error("Entity ID is undefined");
38314
- return service.downloadAttachment(entityData.id, recordId, fieldName, options);
38862
+ return service.downloadAttachment({ id: entityData.id }, recordId, fieldName, options);
38315
38863
  },
38316
38864
  async uploadAttachment(recordId, fieldName, file2, options) {
38317
38865
  if (!entityData.id)
38318
38866
  throw new Error("Entity ID is undefined");
38319
- return service.uploadAttachment(entityData.id, recordId, fieldName, file2, options);
38867
+ return service.uploadAttachment({ id: entityData.id }, recordId, fieldName, file2, options);
38320
38868
  },
38321
38869
  async deleteAttachment(recordId, fieldName, options) {
38322
38870
  if (!entityData.id)
38323
38871
  throw new Error("Entity ID is undefined");
38324
- return service.deleteAttachment(entityData.id, recordId, fieldName, options);
38872
+ return service.deleteAttachment({ id: entityData.id }, recordId, fieldName, options);
38325
38873
  },
38326
38874
  async queryRecords(options) {
38327
38875
  if (!entityData.id)
38328
38876
  throw new Error("Entity ID is undefined");
38329
- return service.queryRecordsById(entityData.id, options);
38877
+ return service.queryRecords({ id: entityData.id }, options);
38330
38878
  },
38331
38879
  async importRecords(file2, options) {
38332
38880
  if (!entityData.id)
38333
38881
  throw new Error("Entity ID is undefined");
38334
- return service.importRecordsById(entityData.id, file2, options);
38882
+ return service.importRecords({ id: entityData.id }, file2, options);
38335
38883
  },
38336
38884
  async insert(data, options) {
38337
38885
  return this.insertRecord(data, options);
@@ -38407,6 +38955,15 @@ var EntityAggregateFunction;
38407
38955
  EntityAggregateFunction2["Min"] = "MIN";
38408
38956
  EntityAggregateFunction2["Max"] = "MAX";
38409
38957
  })(EntityAggregateFunction || (EntityAggregateFunction = {}));
38958
+ var EntityHavingOperator;
38959
+ (function(EntityHavingOperator2) {
38960
+ EntityHavingOperator2["Equals"] = "=";
38961
+ EntityHavingOperator2["NotEquals"] = "!=";
38962
+ EntityHavingOperator2["GreaterThan"] = ">";
38963
+ EntityHavingOperator2["GreaterThanOrEqual"] = ">=";
38964
+ EntityHavingOperator2["LessThan"] = "<";
38965
+ EntityHavingOperator2["LessThanOrEqual"] = "<=";
38966
+ })(EntityHavingOperator || (EntityHavingOperator = {}));
38410
38967
  var EntityType;
38411
38968
  (function(EntityType2) {
38412
38969
  EntityType2["Entity"] = "Entity";
@@ -38437,15 +38994,6 @@ var JoinType;
38437
38994
  JoinType2["LeftJoin"] = "LeftJoin";
38438
38995
  JoinType2["InnerJoin"] = "InnerJoin";
38439
38996
  })(JoinType || (JoinType = {}));
38440
- function createParams(paramsObj = {}) {
38441
- const params = {};
38442
- for (const [key, value] of Object.entries(paramsObj)) {
38443
- if (value !== undefined && value !== null) {
38444
- params[key] = value;
38445
- }
38446
- }
38447
- return params;
38448
- }
38449
38997
  var EntityFieldConstraint;
38450
38998
  (function(EntityFieldConstraint2) {
38451
38999
  EntityFieldConstraint2["LengthLimit"] = "lengthLimit";
@@ -38584,95 +39132,84 @@ function toWireJoin(join2, baseEntityName) {
38584
39132
  }
38585
39133
  };
38586
39134
  }
39135
+ function unwrapEntityRef(entityRef, callerLabel) {
39136
+ const { id, name } = entityRef ?? {};
39137
+ if (id && name) {
39138
+ throw new ValidationError3({
39139
+ message: `${callerLabel}: entityRef must supply exactly one of 'id' or 'name', not both.`
39140
+ });
39141
+ }
39142
+ if (id) {
39143
+ return { byId: true, identifier: id };
39144
+ }
39145
+ if (name) {
39146
+ return { byId: false, identifier: name };
39147
+ }
39148
+ throw new ValidationError3({
39149
+ message: `${callerLabel}: entityRef must supply exactly one of 'id' or 'name'.`
39150
+ });
39151
+ }
38587
39152
 
38588
39153
  class EntityService extends BaseService {
38589
39154
  async getById(id, options) {
38590
- const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(id), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
38591
- const metadata = transformData(response.data, EntityMap);
38592
- this.applyFieldMappings(metadata);
38593
- return createEntityWithMethods(metadata, this);
39155
+ return this.fetchEntityMetadata(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(id), options?.folderKey);
39156
+ }
39157
+ async getByName(entityName, options) {
39158
+ return this.fetchEntityMetadata(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_NAME(entityName), options?.folderKey);
38594
39159
  }
38595
39160
  async getAllRecords(entityId, options) {
38596
- const { folderKey, ...rest } = options ?? {};
38597
- const downstreamOptions = options === undefined ? undefined : rest;
38598
- return PaginationHelpers.getAll({
38599
- serviceAccess: this.createPaginationServiceAccess(),
38600
- getEndpoint: () => DATA_FABRIC_ENDPOINTS.ENTITY.GET_ENTITY_RECORDS(entityId),
38601
- headers: createHeaders({ [FOLDER_KEY]: folderKey }),
38602
- pagination: {
38603
- paginationType: PaginationType.OFFSET,
38604
- itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
38605
- totalCountField: ENTITY_PAGINATION.TOTAL_COUNT_FIELD,
38606
- paginationParams: {
38607
- pageSizeParam: ENTITY_OFFSET_PARAMS.PAGE_SIZE_PARAM,
38608
- offsetParam: ENTITY_OFFSET_PARAMS.OFFSET_PARAM,
38609
- countParam: ENTITY_OFFSET_PARAMS.COUNT_PARAM
38610
- }
38611
- },
38612
- excludeFromPrefix: ["expansionLevel"]
38613
- }, downstreamOptions);
39161
+ return this.getRecordsImpl(true, entityId, options);
39162
+ }
39163
+ async getRecordsByName(entityName, options) {
39164
+ return this.getRecordsImpl(false, entityName, options);
38614
39165
  }
38615
39166
  async getRecordById(entityId, recordId, options = {}) {
38616
- const params = createParams({
38617
- expansionLevel: options.expansionLevel
38618
- });
38619
- const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_RECORD_BY_ID(entityId, recordId), { params, headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
38620
- return response.data;
39167
+ return this.getRecordImpl(true, entityId, recordId, options);
39168
+ }
39169
+ async getRecordByName(entityName, recordId, options = {}) {
39170
+ return this.getRecordImpl(false, entityName, recordId, options);
39171
+ }
39172
+ async insertRecord(entityRef, data, options = {}) {
39173
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.insertRecord");
39174
+ return this.insertRecordImpl(byId, identifier, data, options);
38621
39175
  }
38622
39176
  async insertRecordById(id, data, options = {}) {
38623
- const params = createParams({
38624
- expansionLevel: options.expansionLevel
38625
- });
38626
- const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.INSERT_BY_ID(id), data, {
38627
- params,
38628
- headers: createHeaders({ [FOLDER_KEY]: options.folderKey })
38629
- });
38630
- return response.data;
39177
+ return this.insertRecordImpl(true, id, data, options);
39178
+ }
39179
+ async insertRecords(entityRef, data, options = {}) {
39180
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.insertRecords");
39181
+ return this.insertRecordsImpl(byId, identifier, data, options);
38631
39182
  }
38632
39183
  async insertRecordsById(id, data, options = {}) {
38633
- const params = createParams({
38634
- expansionLevel: options.expansionLevel,
38635
- failOnFirst: options.failOnFirst
38636
- });
38637
- const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.BATCH_INSERT_BY_ID(id), data, {
38638
- params,
38639
- headers: createHeaders({ [FOLDER_KEY]: options.folderKey })
38640
- });
38641
- return response.data;
39184
+ return this.insertRecordsImpl(true, id, data, options);
39185
+ }
39186
+ async updateRecord(entityRef, recordId, data, options = {}) {
39187
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.updateRecord");
39188
+ return this.updateRecordImpl(byId, identifier, recordId, data, options);
38642
39189
  }
38643
39190
  async updateRecordById(entityId, recordId, data, options = {}) {
38644
- const params = createParams({
38645
- expansionLevel: options.expansionLevel
38646
- });
38647
- const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_RECORD_BY_ID(entityId, recordId), data, {
38648
- params,
38649
- headers: createHeaders({ [FOLDER_KEY]: options.folderKey })
38650
- });
38651
- return response.data;
39191
+ return this.updateRecordImpl(true, entityId, recordId, data, options);
39192
+ }
39193
+ async updateRecords(entityRef, data, options = {}) {
39194
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.updateRecords");
39195
+ return this.updateRecordsImpl(byId, identifier, data, options);
38652
39196
  }
38653
39197
  async updateRecordsById(id, data, options = {}) {
38654
- const params = createParams({
38655
- expansionLevel: options.expansionLevel,
38656
- failOnFirst: options.failOnFirst
38657
- });
38658
- const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_BY_ID(id), data, {
38659
- params,
38660
- headers: createHeaders({ [FOLDER_KEY]: options.folderKey })
38661
- });
38662
- return response.data;
39198
+ return this.updateRecordsImpl(true, id, data, options);
39199
+ }
39200
+ async deleteRecords(entityRef, recordIds, options = {}) {
39201
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.deleteRecords");
39202
+ return this.deleteRecordsImpl(byId, identifier, recordIds, options);
38663
39203
  }
38664
39204
  async deleteRecordsById(id, recordIds, options = {}) {
38665
- const params = createParams({
38666
- failOnFirst: options.failOnFirst
38667
- });
38668
- const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_BY_ID(id), recordIds, {
38669
- params,
38670
- headers: createHeaders({ [FOLDER_KEY]: options.folderKey })
38671
- });
38672
- return response.data;
39205
+ return this.deleteRecordsImpl(true, id, recordIds, options);
39206
+ }
39207
+ async deleteRecord(entityRef, recordId, options) {
39208
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.deleteRecord");
39209
+ return this.deleteRecordImpl(byId, identifier, recordId, options);
38673
39210
  }
38674
39211
  async deleteRecordById(entityId, recordId, options) {
38675
- await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_RECORD_BY_ID(entityId, recordId), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
39212
+ return this.deleteRecordImpl(true, entityId, recordId, options);
38676
39213
  }
38677
39214
  async getAll(options) {
38678
39215
  const endpoint = !options?.folderKey && options?.includeFolderEntities ? DATA_FABRIC_ENDPOINTS.ENTITY.GET_ALL_V2 : DATA_FABRIC_ENDPOINTS.ENTITY.GET_ALL;
@@ -38684,62 +39221,30 @@ class EntityService extends BaseService {
38684
39221
  });
38685
39222
  return entities;
38686
39223
  }
39224
+ async queryRecords(entityRef, options) {
39225
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.queryRecords");
39226
+ return this.queryRecordsImpl(byId, identifier, options);
39227
+ }
38687
39228
  async queryRecordsById(id, options) {
38688
- if (options?.joins && options.joins.length > MAX_QUERY_JOINS) {
38689
- throw new ValidationError3({
38690
- message: `A maximum of ${MAX_QUERY_JOINS} joins is supported per query (received ${options.joins.length})`
38691
- });
38692
- }
38693
- if (options?.joins && options.joins.length > 0 && !options.selectedFields?.length && !options.aggregates?.length) {
38694
- throw new ValidationError3({
38695
- message: 'Join queries require selectedFields or aggregates — reference fields as "<EntityName>.<FieldName>" (e.g. "Customer.name")'
38696
- });
38697
- }
38698
- const { folderKey, expansionLevel, ...rest } = options ?? {};
38699
- let getEndpoint = () => DATA_FABRIC_ENDPOINTS.ENTITY.QUERY_BY_ID(id);
38700
- if (options?.joins && options.joins.length > 0) {
38701
- const baseEntityName = await this.resolveEntityName(id, folderKey);
38702
- rest.joins = options.joins.map((join2) => toWireJoin(join2, baseEntityName));
38703
- getEndpoint = () => DATA_FABRIC_ENDPOINTS.ENTITY.QUERY_BY_NAME(baseEntityName);
38704
- }
38705
- const downstreamOptions = options === undefined ? undefined : rest;
38706
- return PaginationHelpers.getAll({
38707
- serviceAccess: this.createPaginationServiceAccess(),
38708
- getEndpoint,
38709
- method: HTTP_METHODS.POST,
38710
- headers: createHeaders({ [FOLDER_KEY]: folderKey }),
38711
- queryParams: createParams({ expansionLevel }),
38712
- pagination: {
38713
- paginationType: PaginationType.OFFSET,
38714
- itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
38715
- totalCountField: ENTITY_PAGINATION.TOTAL_COUNT_FIELD,
38716
- paginationParams: {
38717
- pageSizeParam: ENTITY_OFFSET_PARAMS.PAGE_SIZE_PARAM,
38718
- offsetParam: ENTITY_OFFSET_PARAMS.OFFSET_PARAM,
38719
- countParam: ENTITY_OFFSET_PARAMS.COUNT_PARAM
38720
- }
38721
- },
38722
- excludeFromPrefix: ["filterGroup", "selectedFields", "sortOptions", "aggregates", "groupBy", "joins"]
38723
- }, downstreamOptions);
39229
+ return this.queryRecordsImpl(true, id, options);
39230
+ }
39231
+ async importRecords(entityRef, file2, options) {
39232
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.importRecords");
39233
+ return this.importRecordsImpl(byId, identifier, file2, options);
38724
39234
  }
38725
39235
  async importRecordsById(id, file2, options) {
38726
- const formData = new FormData;
38727
- if (file2 instanceof Uint8Array) {
38728
- formData.append("file", new Blob([file2.buffer]));
38729
- } else {
38730
- formData.append("file", file2);
38731
- }
38732
- const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.BULK_UPLOAD_BY_ID(id), formData, { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
38733
- return response.data;
39236
+ return this.importRecordsImpl(true, id, file2, options);
38734
39237
  }
38735
- async downloadAttachment(entityId, recordId, fieldName, options) {
38736
- const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.DOWNLOAD_ATTACHMENT(entityId, recordId, fieldName), {
39238
+ async downloadAttachment(entityRef, recordId, fieldName, options) {
39239
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.downloadAttachment");
39240
+ const response = await this.get(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.DOWNLOAD_ATTACHMENT(identifier, recordId, fieldName) : DATA_FABRIC_ENDPOINTS.ENTITY.ATTACHMENT_BY_NAME(identifier, recordId, fieldName), {
38737
39241
  responseType: RESPONSE_TYPES.BLOB,
38738
39242
  headers: createHeaders({ [FOLDER_KEY]: options?.folderKey })
38739
39243
  });
38740
39244
  return response.data;
38741
39245
  }
38742
- async uploadAttachment(entityId, recordId, fieldName, file2, options) {
39246
+ async uploadAttachment(entityRef, recordId, fieldName, file2, options) {
39247
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.uploadAttachment");
38743
39248
  const formData = new FormData;
38744
39249
  if (file2 instanceof Uint8Array) {
38745
39250
  formData.append("file", new Blob([file2.buffer]));
@@ -38747,14 +39252,15 @@ class EntityService extends BaseService {
38747
39252
  formData.append("file", file2);
38748
39253
  }
38749
39254
  const params = createParams({ expansionLevel: options?.expansionLevel });
38750
- const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityId, recordId, fieldName), formData, {
39255
+ const response = await this.post(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(identifier, recordId, fieldName) : DATA_FABRIC_ENDPOINTS.ENTITY.ATTACHMENT_BY_NAME(identifier, recordId, fieldName), formData, {
38751
39256
  params,
38752
39257
  headers: createHeaders({ [FOLDER_KEY]: options?.folderKey })
38753
39258
  });
38754
39259
  return response.data;
38755
39260
  }
38756
- async deleteAttachment(entityId, recordId, fieldName, options) {
38757
- const response = await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_ATTACHMENT(entityId, recordId, fieldName), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
39261
+ async deleteAttachment(entityRef, recordId, fieldName, options) {
39262
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.deleteAttachment");
39263
+ const response = await this.delete(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_ATTACHMENT(identifier, recordId, fieldName) : DATA_FABRIC_ENDPOINTS.ENTITY.ATTACHMENT_BY_NAME(identifier, recordId, fieldName), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
38758
39264
  return response.data;
38759
39265
  }
38760
39266
  async getRecordsById(entityId, options) {
@@ -38791,11 +39297,16 @@ class EntityService extends BaseService {
38791
39297
  const opts = options ?? {};
38792
39298
  const hasSchemaChanges = !!(opts.addFields?.length || opts.removeFields?.length || opts.updateFields?.length);
38793
39299
  const hasMetadataChanges = opts.displayName !== undefined || opts.description !== undefined || opts.isRbacEnabled !== undefined;
39300
+ if (!hasSchemaChanges && !hasMetadataChanges) {
39301
+ throw new ValidationError3({
39302
+ message: "updateById requires at least one change — pass addFields, removeFields, updateFields, displayName, description, or isRbacEnabled."
39303
+ });
39304
+ }
38794
39305
  if (hasSchemaChanges) {
38795
39306
  await this.applySchemaUpdate(id, opts);
38796
39307
  }
38797
39308
  if (hasMetadataChanges) {
38798
- await this.patch(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_METADATA(id), {
39309
+ await this.patch(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE(id), {
38799
39310
  ...opts.displayName !== undefined && { displayName: opts.displayName },
38800
39311
  ...opts.description !== undefined && { description: opts.description },
38801
39312
  ...opts.isRbacEnabled !== undefined && { isRbacEnabled: opts.isRbacEnabled }
@@ -38808,10 +39319,24 @@ class EntityService extends BaseService {
38808
39319
  const raw = entityResponse.data;
38809
39320
  let fields = (raw.fields ?? []).filter((f) => !f.isSystemField && !f.isPrimaryKey);
38810
39321
  if (options.removeFields?.length) {
39322
+ const existingNames = new Set(fields.map((f) => f.name));
39323
+ const missing = options.removeFields.filter((r) => !existingNames.has(r.name)).map((r) => r.name);
39324
+ if (missing.length) {
39325
+ throw new ValidationError3({
39326
+ message: `Cannot remove field(s) — no matching non-system field found for name(s): ${missing.join(", ")}.`
39327
+ });
39328
+ }
38811
39329
  const removeSet = new Set(options.removeFields.map((r) => r.name));
38812
39330
  fields = fields.filter((f) => !removeSet.has(f.name));
38813
39331
  }
38814
39332
  if (options.updateFields?.length) {
39333
+ const existingIds = new Set(fields.map((f) => f.id));
39334
+ const missing = options.updateFields.filter((u) => !existingIds.has(u.id)).map((u) => u.id);
39335
+ if (missing.length) {
39336
+ throw new ValidationError3({
39337
+ message: `Cannot update field(s) — no matching non-system field found for id(s): ${missing.join(", ")}.`
39338
+ });
39339
+ }
38815
39340
  const updateMap = new Map(options.updateFields.map((u) => [u.id, u]));
38816
39341
  fields = fields.map((f) => {
38817
39342
  const update = updateMap.get(f.id ?? "");
@@ -39061,40 +39586,185 @@ class EntityService extends BaseService {
39061
39586
  return {};
39062
39587
  }
39063
39588
  }
39589
+ async fetchEntityMetadata(endpoint, folderKey) {
39590
+ const response = await this.get(endpoint, { headers: createHeaders({ [FOLDER_KEY]: folderKey }) });
39591
+ const metadata = transformData(response.data, EntityMap);
39592
+ this.applyFieldMappings(metadata);
39593
+ return createEntityWithMethods(metadata, this);
39594
+ }
39595
+ getRecordsImpl(byId, identifier, options) {
39596
+ const { folderKey, ...rest } = options ?? {};
39597
+ const downstreamOptions = options === undefined ? undefined : rest;
39598
+ return PaginationHelpers.getAll({
39599
+ serviceAccess: this.createPaginationServiceAccess(),
39600
+ getEndpoint: () => byId ? DATA_FABRIC_ENDPOINTS.ENTITY.GET_ENTITY_RECORDS(identifier) : DATA_FABRIC_ENDPOINTS.ENTITY.GET_ENTITY_RECORDS_BY_NAME(identifier),
39601
+ headers: createHeaders({ [FOLDER_KEY]: folderKey }),
39602
+ pagination: {
39603
+ paginationType: PaginationType.OFFSET,
39604
+ itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
39605
+ totalCountField: ENTITY_PAGINATION.TOTAL_COUNT_FIELD,
39606
+ paginationParams: {
39607
+ pageSizeParam: ENTITY_OFFSET_PARAMS.PAGE_SIZE_PARAM,
39608
+ offsetParam: ENTITY_OFFSET_PARAMS.OFFSET_PARAM,
39609
+ countParam: ENTITY_OFFSET_PARAMS.COUNT_PARAM
39610
+ }
39611
+ },
39612
+ excludeFromPrefix: ["expansionLevel"]
39613
+ }, downstreamOptions);
39614
+ }
39615
+ async getRecordImpl(byId, identifier, recordId, options) {
39616
+ const params = createParams({ expansionLevel: options.expansionLevel });
39617
+ const response = await this.get(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.GET_RECORD_BY_ID(identifier, recordId) : DATA_FABRIC_ENDPOINTS.ENTITY.GET_RECORD_BY_NAME(identifier, recordId), { params, headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
39618
+ return response.data;
39619
+ }
39620
+ async insertRecordImpl(byId, identifier, data, options) {
39621
+ const params = createParams({ expansionLevel: options.expansionLevel });
39622
+ const response = await this.post(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.INSERT_BY_ID(identifier) : DATA_FABRIC_ENDPOINTS.ENTITY.INSERT_BY_NAME(identifier), data, { params, headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
39623
+ return response.data;
39624
+ }
39625
+ async insertRecordsImpl(byId, identifier, data, options) {
39626
+ const params = createParams({ expansionLevel: options.expansionLevel, failOnFirst: options.failOnFirst });
39627
+ const response = await this.post(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.BATCH_INSERT_BY_ID(identifier) : DATA_FABRIC_ENDPOINTS.ENTITY.BATCH_INSERT_BY_NAME(identifier), data, { params, headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
39628
+ return response.data;
39629
+ }
39630
+ async updateRecordImpl(byId, identifier, recordId, data, options) {
39631
+ const params = createParams({ expansionLevel: options.expansionLevel });
39632
+ const response = await this.post(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_RECORD_BY_ID(identifier, recordId) : DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_RECORD_BY_NAME(identifier, recordId), data, { params, headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
39633
+ return response.data;
39634
+ }
39635
+ async updateRecordsImpl(byId, identifier, data, options) {
39636
+ const params = createParams({ expansionLevel: options.expansionLevel, failOnFirst: options.failOnFirst });
39637
+ const response = await this.post(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_BY_ID(identifier) : DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_BY_NAME(identifier), data, { params, headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
39638
+ return response.data;
39639
+ }
39640
+ async deleteRecordsImpl(byId, identifier, recordIds, options) {
39641
+ const params = createParams({ failOnFirst: options.failOnFirst });
39642
+ const response = await this.post(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_BY_ID(identifier) : DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_BY_NAME(identifier), recordIds, { params, headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
39643
+ return response.data;
39644
+ }
39645
+ async deleteRecordImpl(byId, identifier, recordId, options) {
39646
+ await this.delete(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_RECORD_BY_ID(identifier, recordId) : DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_RECORD_BY_NAME(identifier, recordId), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
39647
+ }
39648
+ async queryRecordsImpl(byId, identifier, options) {
39649
+ if (options?.joins && options.joins.length > MAX_QUERY_JOINS) {
39650
+ throw new ValidationError3({
39651
+ message: `A maximum of ${MAX_QUERY_JOINS} joins is supported per query (received ${options.joins.length})`
39652
+ });
39653
+ }
39654
+ if (options?.joins && options.joins.length > 0 && !options.selectedFields?.length && !options.aggregates?.length) {
39655
+ throw new ValidationError3({
39656
+ message: 'Join queries require selectedFields or aggregates — reference fields as "<EntityName>.<FieldName>" (e.g. "Customer.name")'
39657
+ });
39658
+ }
39659
+ if (options?.havingFilter && (!options.aggregates?.length || !options.groupBy?.length)) {
39660
+ throw new ValidationError3({
39661
+ message: "havingFilter requires aggregates and groupBy — conditions reference declared aggregate aliases; use filterGroup for row-level conditions"
39662
+ });
39663
+ }
39664
+ const { folderKey, expansionLevel, ...rest } = options ?? {};
39665
+ let getEndpoint = () => byId ? DATA_FABRIC_ENDPOINTS.ENTITY.QUERY_BY_ID(identifier) : DATA_FABRIC_ENDPOINTS.ENTITY.QUERY_BY_NAME(identifier);
39666
+ if (options?.joins && options.joins.length > 0) {
39667
+ const baseEntityName = byId ? await this.resolveEntityName(identifier, folderKey) : identifier;
39668
+ rest.joins = options.joins.map((join2) => toWireJoin(join2, baseEntityName));
39669
+ getEndpoint = () => DATA_FABRIC_ENDPOINTS.ENTITY.QUERY_BY_NAME(baseEntityName);
39670
+ }
39671
+ const downstreamOptions = options === undefined ? undefined : rest;
39672
+ return PaginationHelpers.getAll({
39673
+ serviceAccess: this.createPaginationServiceAccess(),
39674
+ getEndpoint,
39675
+ method: HTTP_METHODS.POST,
39676
+ headers: createHeaders({ [FOLDER_KEY]: folderKey }),
39677
+ queryParams: createParams({ expansionLevel }),
39678
+ pagination: {
39679
+ paginationType: PaginationType.OFFSET,
39680
+ itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
39681
+ totalCountField: ENTITY_PAGINATION.TOTAL_COUNT_FIELD,
39682
+ paginationParams: {
39683
+ pageSizeParam: ENTITY_OFFSET_PARAMS.PAGE_SIZE_PARAM,
39684
+ offsetParam: ENTITY_OFFSET_PARAMS.OFFSET_PARAM,
39685
+ countParam: ENTITY_OFFSET_PARAMS.COUNT_PARAM
39686
+ }
39687
+ },
39688
+ excludeFromPrefix: ["filterGroup", "selectedFields", "sortOptions", "aggregates", "groupBy", "joins", "havingFilter"]
39689
+ }, downstreamOptions);
39690
+ }
39691
+ async importRecordsImpl(byId, identifier, file2, options) {
39692
+ const formData = new FormData;
39693
+ if (file2 instanceof Uint8Array) {
39694
+ formData.append("file", new Blob([file2.buffer]));
39695
+ } else {
39696
+ formData.append("file", file2);
39697
+ }
39698
+ const response = await this.post(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.BULK_UPLOAD_BY_ID(identifier) : DATA_FABRIC_ENDPOINTS.ENTITY.BULK_UPLOAD_BY_NAME(identifier), formData, { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
39699
+ return response.data;
39700
+ }
39064
39701
  }
39065
39702
  __decorate([
39066
39703
  track("Entities.GetById")
39067
39704
  ], EntityService.prototype, "getById", null);
39705
+ __decorate([
39706
+ track("Entities.GetByName")
39707
+ ], EntityService.prototype, "getByName", null);
39068
39708
  __decorate([
39069
39709
  track("Entities.GetAllRecords")
39070
39710
  ], EntityService.prototype, "getAllRecords", null);
39711
+ __decorate([
39712
+ track("Entities.GetRecordsByName")
39713
+ ], EntityService.prototype, "getRecordsByName", null);
39071
39714
  __decorate([
39072
39715
  track("Entities.GetRecordById")
39073
39716
  ], EntityService.prototype, "getRecordById", null);
39717
+ __decorate([
39718
+ track("Entities.GetRecordByName")
39719
+ ], EntityService.prototype, "getRecordByName", null);
39720
+ __decorate([
39721
+ track("Entities.InsertRecord")
39722
+ ], EntityService.prototype, "insertRecord", null);
39074
39723
  __decorate([
39075
39724
  track("Entities.InsertRecordById")
39076
39725
  ], EntityService.prototype, "insertRecordById", null);
39726
+ __decorate([
39727
+ track("Entities.InsertRecords")
39728
+ ], EntityService.prototype, "insertRecords", null);
39077
39729
  __decorate([
39078
39730
  track("Entities.InsertRecordsById")
39079
39731
  ], EntityService.prototype, "insertRecordsById", null);
39732
+ __decorate([
39733
+ track("Entities.UpdateRecord")
39734
+ ], EntityService.prototype, "updateRecord", null);
39080
39735
  __decorate([
39081
39736
  track("Entities.UpdateRecordById")
39082
39737
  ], EntityService.prototype, "updateRecordById", null);
39738
+ __decorate([
39739
+ track("Entities.UpdateRecords")
39740
+ ], EntityService.prototype, "updateRecords", null);
39083
39741
  __decorate([
39084
39742
  track("Entities.UpdateRecordsById")
39085
39743
  ], EntityService.prototype, "updateRecordsById", null);
39744
+ __decorate([
39745
+ track("Entities.DeleteRecords")
39746
+ ], EntityService.prototype, "deleteRecords", null);
39086
39747
  __decorate([
39087
39748
  track("Entities.DeleteRecordsById")
39088
39749
  ], EntityService.prototype, "deleteRecordsById", null);
39750
+ __decorate([
39751
+ track("Entities.DeleteRecord")
39752
+ ], EntityService.prototype, "deleteRecord", null);
39089
39753
  __decorate([
39090
39754
  track("Entities.DeleteRecordById")
39091
39755
  ], EntityService.prototype, "deleteRecordById", null);
39092
39756
  __decorate([
39093
39757
  track("Entities.GetAll")
39094
39758
  ], EntityService.prototype, "getAll", null);
39759
+ __decorate([
39760
+ track("Entities.QueryRecords")
39761
+ ], EntityService.prototype, "queryRecords", null);
39095
39762
  __decorate([
39096
39763
  track("Entities.QueryRecordsById")
39097
39764
  ], EntityService.prototype, "queryRecordsById", null);
39765
+ __decorate([
39766
+ track("Entities.ImportRecords")
39767
+ ], EntityService.prototype, "importRecords", null);
39098
39768
  __decorate([
39099
39769
  track("Entities.ImportRecordsById")
39100
39770
  ], EntityService.prototype, "importRecordsById", null);
@@ -40538,6 +41208,74 @@ function validateName(resourceType, name) {
40538
41208
  }
40539
41209
  return trimmed;
40540
41210
  }
41211
+ var GUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
41212
+ function isPlainObject4(value) {
41213
+ return typeof value === "object" && value !== null && !Array.isArray(value);
41214
+ }
41215
+ function asResourceOverrides(value) {
41216
+ if (!isPlainObject4(value))
41217
+ return;
41218
+ const table = {};
41219
+ for (const [key, properties] of Object.entries(value)) {
41220
+ if (!isPlainObject4(properties))
41221
+ continue;
41222
+ const bag = {};
41223
+ for (const [property, propertyValue] of Object.entries(properties)) {
41224
+ if (typeof propertyValue === "string")
41225
+ bag[property] = propertyValue;
41226
+ }
41227
+ table[key] = bag;
41228
+ }
41229
+ return Object.keys(table).length > 0 ? table : undefined;
41230
+ }
41231
+ function readFromDocument() {
41232
+ if (!isBrowser2)
41233
+ return;
41234
+ const text = document.getElementById(UiPathElementIds.RESOURCE_OVERRIDES)?.textContent;
41235
+ if (!text)
41236
+ return;
41237
+ try {
41238
+ return asResourceOverrides(JSON.parse(text));
41239
+ } catch (error52) {
41240
+ console.warn(`[UiPath SDK] Failed to parse <script id="${UiPathElementIds.RESOURCE_OVERRIDES}"> as JSON — proceeding without overrides:`, error52);
41241
+ return;
41242
+ }
41243
+ }
41244
+ var table;
41245
+ var loaded = false;
41246
+ var pageOverrides = () => {
41247
+ if (!loaded) {
41248
+ loaded = true;
41249
+ table = readFromDocument();
41250
+ }
41251
+ return table;
41252
+ };
41253
+ var RESOURCE_OVERWRITES_KEY = Symbol.for("uipath.resourceOverwrites.v1");
41254
+ function readOverrides() {
41255
+ const slot2 = globalThis[RESOURCE_OVERWRITES_KEY];
41256
+ const source = typeof slot2 === "function" ? slot2 : pageOverrides;
41257
+ try {
41258
+ return source();
41259
+ } catch (error52) {
41260
+ console.warn("[UiPath SDK] Override source threw — proceeding without overrides:", error52);
41261
+ return;
41262
+ }
41263
+ }
41264
+ function resolveOverride(resourceType, name, folderPath) {
41265
+ const table2 = readOverrides();
41266
+ if (!table2)
41267
+ return;
41268
+ const bindingType = resourceType.toLowerCase();
41269
+ const scopedKey = folderPath ? `${bindingType}.${name}.${folderPath}` : undefined;
41270
+ const unscopedKey = `${bindingType}.${name}`;
41271
+ const entry = (scopedKey && table2[scopedKey]) ?? table2[unscopedKey];
41272
+ if (!entry)
41273
+ return;
41274
+ return {
41275
+ name: entry.name,
41276
+ folderPath: entry.folderPath
41277
+ };
41278
+ }
40541
41279
  var SINGLE_QUOTE_RE = /'/g;
40542
41280
 
40543
41281
  class FolderScopedService extends BaseService {
@@ -40554,20 +41292,23 @@ class FolderScopedService extends BaseService {
40554
41292
  }
40555
41293
  return response.data?.value;
40556
41294
  }
40557
- async getByNameLookup(resourceType, endpoint, name, options, transform3, responseFieldMap) {
41295
+ async getByNameLookup(resourceType, endpoint, name, options, transform3, responseFieldMap, callerLabel) {
40558
41296
  const validatedName = validateName(resourceType, name);
40559
41297
  const { folderId, folderKey, folderPath, ...queryOptions } = options;
41298
+ const override = resolveOverride(resourceType, validatedName, folderPath);
41299
+ const resolvedName = override?.name ?? validatedName;
41300
+ const resolvedFolderPath = override?.folderPath ?? folderPath;
40560
41301
  const headers = resolveFolderHeaders({
40561
41302
  folderId,
40562
41303
  folderKey,
40563
- folderPath,
40564
- resourceType: `${resourceType}.getByName`,
41304
+ folderPath: resolvedFolderPath,
41305
+ resourceType: callerLabel ?? `${resourceType}.getByName`,
40565
41306
  fallbackFolderKey: this.config.folderKey
40566
41307
  });
40567
41308
  const apiFieldOptions = responseFieldMap ? transformOptions(queryOptions, responseFieldMap) : queryOptions;
40568
41309
  const apiOptions = {
40569
41310
  ...addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions)),
40570
- $filter: `Name eq '${validatedName.replace(SINGLE_QUOTE_RE, "''")}'`,
41311
+ $filter: `Name eq '${resolvedName.replace(SINGLE_QUOTE_RE, "''")}'`,
40571
41312
  $top: "1"
40572
41313
  };
40573
41314
  const response = await this.get(endpoint, {
@@ -40576,12 +41317,48 @@ class FolderScopedService extends BaseService {
40576
41317
  });
40577
41318
  const items = response.data?.value;
40578
41319
  if (!items?.length) {
40579
- const folderHint = describeFolderForError(folderId, folderKey, folderPath);
41320
+ const folderHint = describeFolderForError(folderId, folderKey, resolvedFolderPath);
40580
41321
  throw new NotFoundError({
40581
- message: `${resourceType} '${validatedName}' not found${folderHint}.`
41322
+ message: `${resourceType} '${resolvedName}' not found${folderHint}.`
40582
41323
  });
40583
41324
  }
40584
- return transform3(items[0]);
41325
+ return {
41326
+ result: transform3(items[0]),
41327
+ effectiveFolder: { folderId, folderKey, folderPath: resolvedFolderPath }
41328
+ };
41329
+ }
41330
+ async getByKeyLookup(resourceType, endpoint, key, options, transform3, responseFieldMap, callerLabel) {
41331
+ const label = callerLabel ?? `${resourceType}.getByKey`;
41332
+ const trimmedKey = key?.trim();
41333
+ if (!trimmedKey || !GUID_REGEX.test(trimmedKey)) {
41334
+ throw new ValidationError3({ message: `${label}: key must be a GUID.` });
41335
+ }
41336
+ const { folderId, folderKey, folderPath, ...queryOptions } = options;
41337
+ const headers = resolveFolderHeaders({
41338
+ folderId,
41339
+ folderKey,
41340
+ folderPath,
41341
+ resourceType: label,
41342
+ fallbackFolderKey: this.config.folderKey
41343
+ });
41344
+ const apiFieldOptions = responseFieldMap ? transformOptions(queryOptions, responseFieldMap) : queryOptions;
41345
+ const apiOptions = {
41346
+ ...addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions)),
41347
+ $filter: `Key eq ${trimmedKey}`,
41348
+ $top: "1"
41349
+ };
41350
+ const response = await this.get(endpoint, {
41351
+ headers,
41352
+ params: apiOptions
41353
+ });
41354
+ const items = response.data?.value;
41355
+ if (!items?.length) {
41356
+ throw new NotFoundError({ message: `${resourceType} with key '${trimmedKey}' not found.` });
41357
+ }
41358
+ return {
41359
+ result: transform3(items[0]),
41360
+ effectiveFolder: { folderId, folderKey, folderPath }
41361
+ };
40585
41362
  }
40586
41363
  }
40587
41364
  function describeFolderForError(folderId, folderKey, folderPath) {
@@ -40612,12 +41389,16 @@ class TaskService extends FolderScopedService {
40612
41389
  };
40613
41390
  }
40614
41391
  async create(task, folderId) {
41392
+ if (task.type === TaskType.QuickForm && !task.taskSchemaKey) {
41393
+ throw new ValidationError3({ message: "taskSchemaKey is required when creating a QuickForm task." });
41394
+ }
40615
41395
  const headers = createHeaders({ [FOLDER_ID]: folderId });
40616
- const externalTask = {
40617
- ...task,
40618
- type: TaskType.External
40619
- };
40620
- const response = await this.post(TASK_ENDPOINTS.CREATE_GENERIC_TASK, externalTask, { headers });
41396
+ const { labels, type, ...rest } = task;
41397
+ const payload = { ...rest, type: type ?? TaskType.External };
41398
+ if (labels?.length) {
41399
+ payload.tags = labels.map((label) => ({ name: label, displayName: label, displayValue: label }));
41400
+ }
41401
+ const response = await this.post(TASK_ENDPOINTS.CREATE_GENERIC_TASK, payload, { headers });
40621
41402
  const normalizedData = transformData(response.data, TaskMap);
40622
41403
  const transformedData = applyDataTransforms(normalizedData, { field: "status", valueMap: TaskStatusMap });
40623
41404
  return createTaskWithMethods(transformedData, this);
@@ -41249,6 +42030,35 @@ var AssetValueType;
41249
42030
  AssetValueType2["Credential"] = "Credential";
41250
42031
  AssetValueType2["Secret"] = "Secret";
41251
42032
  })(AssetValueType || (AssetValueType = {}));
42033
+ async function resolveRefToId(ref, resolvers, callerLabel) {
42034
+ if (!ref) {
42035
+ throw new ValidationError3({
42036
+ message: `${callerLabel}: ref must supply exactly one of 'id', 'name', or 'key'.`
42037
+ });
42038
+ }
42039
+ if ("id" in ref && ref.id != null) {
42040
+ return { id: ref.id, effectiveFolder: {} };
42041
+ }
42042
+ const stringVariants = [
42043
+ { variant: "name", resolver: resolvers.byName },
42044
+ { variant: "key", resolver: resolvers.byKey }
42045
+ ];
42046
+ for (const { variant, resolver } of stringVariants) {
42047
+ const value = ref[variant];
42048
+ if (!value)
42049
+ continue;
42050
+ if (!resolver) {
42051
+ throw new ValidationError3({
42052
+ message: `${callerLabel}: this method does not support lookup by '${variant}'.`
42053
+ });
42054
+ }
42055
+ const { id, folderId, folderKey, folderPath } = await resolver(value);
42056
+ return { id, effectiveFolder: { folderId, folderKey, folderPath } };
42057
+ }
42058
+ throw new ValidationError3({
42059
+ message: `${callerLabel}: ref must supply exactly one of 'id', 'name', or 'key'.`
42060
+ });
42061
+ }
41252
42062
  var AssetMap = {
41253
42063
  creationTime: "createdTime",
41254
42064
  lastModificationTime: "lastModifiedTime"
@@ -41287,7 +42097,41 @@ class AssetService extends FolderScopedService {
41287
42097
  return transformedAsset;
41288
42098
  }
41289
42099
  async getByName(name, options = {}) {
41290
- return this.getByNameLookup("Asset", ASSET_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), AssetMap), AssetMap);
42100
+ const { result } = await this.getByNameLookup("Asset", ASSET_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), AssetMap), AssetMap);
42101
+ return result;
42102
+ }
42103
+ async getByKey(key, options = {}) {
42104
+ const { result } = await this.getByKeyLookup("Asset", ASSET_ENDPOINTS.GET_BY_FOLDER, key, options, (raw) => transformData(pascalToCamelCaseKeys(raw), AssetMap), AssetMap);
42105
+ return result;
42106
+ }
42107
+ async updateValue(assetRef, newValue, options) {
42108
+ if (newValue === null || newValue === undefined) {
42109
+ throw new ValidationError3({ message: "newValue is required for updateValue" });
42110
+ }
42111
+ let preFetched;
42112
+ const { id, effectiveFolder } = await resolveRefToId(assetRef, {
42113
+ byName: async (name) => {
42114
+ const { result: asset, effectiveFolder: folder } = await this.getByNameLookup("Asset", ASSET_ENDPOINTS.GET_BY_FOLDER, name, { folderId: options?.folderId, folderKey: options?.folderKey, folderPath: options?.folderPath }, (raw) => transformData(pascalToCamelCaseKeys(raw), AssetMap), AssetMap, "Assets.updateValue");
42115
+ preFetched = asset;
42116
+ return { id: asset.id, ...folder };
42117
+ },
42118
+ byKey: async (key) => {
42119
+ const { result: asset, effectiveFolder: folder } = await this.getByKeyLookup("Asset", ASSET_ENDPOINTS.GET_BY_FOLDER, key, { folderId: options?.folderId, folderKey: options?.folderKey, folderPath: options?.folderPath }, (raw) => transformData(pascalToCamelCaseKeys(raw), AssetMap), AssetMap, "Assets.updateValue");
42120
+ preFetched = asset;
42121
+ return { id: asset.id, ...folder };
42122
+ }
42123
+ }, "Assets.updateValue");
42124
+ if (id <= 0) {
42125
+ throw new ValidationError3({ message: "Assets.updateValue: assetRef.id must be a positive number." });
42126
+ }
42127
+ const headers = resolveFolderHeaders({
42128
+ folderId: effectiveFolder.folderId ?? options?.folderId,
42129
+ folderKey: effectiveFolder.folderKey ?? options?.folderKey,
42130
+ folderPath: effectiveFolder.folderPath ?? options?.folderPath,
42131
+ resourceType: "Assets.updateValue",
42132
+ fallbackFolderKey: this.config.folderKey
42133
+ });
42134
+ await this.updateValueByResolvedId(id, newValue, headers, preFetched);
41291
42135
  }
41292
42136
  async updateValueById(id, newValue, options) {
41293
42137
  if (!id) {
@@ -41303,19 +42147,30 @@ class AssetService extends FolderScopedService {
41303
42147
  resourceType: "Assets.updateValueById",
41304
42148
  fallbackFolderKey: this.config.folderKey
41305
42149
  });
41306
- const existingResponse = await this.get(ASSET_ENDPOINTS.GET_BY_ID(id), { headers });
41307
- const existing = existingResponse.data;
41308
- const valueField = resolveValueField(id, existing.ValueType, newValue);
42150
+ await this.updateValueByResolvedId(id, newValue, headers);
42151
+ }
42152
+ async updateValueByResolvedId(id, newValue, headers, preFetched) {
42153
+ const shape = preFetched ?? await this.fetchAssetShape(id, headers);
42154
+ const valueField = resolveValueField(id, shape.valueType, newValue);
41309
42155
  const body = {
41310
42156
  Id: id,
41311
- Name: existing.Name,
41312
- ValueScope: existing.ValueScope,
41313
- ValueType: existing.ValueType,
41314
- Description: existing.Description,
42157
+ Name: shape.name,
42158
+ ValueScope: shape.valueScope,
42159
+ ValueType: shape.valueType,
42160
+ Description: shape.description,
41315
42161
  [valueField]: newValue
41316
42162
  };
41317
42163
  await this.put(ASSET_ENDPOINTS.GET_BY_ID(id), body, { headers });
41318
42164
  }
42165
+ async fetchAssetShape(id, headers) {
42166
+ const response = await this.get(ASSET_ENDPOINTS.GET_BY_ID(id), { headers });
42167
+ return {
42168
+ name: response.data.Name,
42169
+ valueScope: response.data.ValueScope,
42170
+ valueType: response.data.ValueType,
42171
+ description: response.data.Description
42172
+ };
42173
+ }
41319
42174
  }
41320
42175
  __decorate([
41321
42176
  track("Assets.GetAll")
@@ -41326,6 +42181,12 @@ __decorate([
41326
42181
  __decorate([
41327
42182
  track("Assets.GetByName")
41328
42183
  ], AssetService.prototype, "getByName", null);
42184
+ __decorate([
42185
+ track("Assets.GetByKey")
42186
+ ], AssetService.prototype, "getByKey", null);
42187
+ __decorate([
42188
+ track("Assets.UpdateValue")
42189
+ ], AssetService.prototype, "updateValue", null);
41329
42190
  __decorate([
41330
42191
  track("Assets.UpdateValueById")
41331
42192
  ], AssetService.prototype, "updateValueById", null);
@@ -41354,7 +42215,7 @@ function resolveValueField(id, valueType, newValue) {
41354
42215
  return "BoolValue";
41355
42216
  default:
41356
42217
  throw new ValidationError3({
41357
- message: `updateValueById only supports Text, Integer, or Bool assets; asset ${id} has valueType ${valueType}`
42218
+ message: `Asset ${id} has valueType ${valueType}; only Text, Integer, and Bool are supported`
41358
42219
  });
41359
42220
  }
41360
42221
  }
@@ -41382,7 +42243,8 @@ class BucketService extends FolderScopedService {
41382
42243
  return pascalToCamelCaseKeys(response.data);
41383
42244
  }
41384
42245
  async getByName(name, options = {}) {
41385
- return this.getByNameLookup("Bucket", BUCKET_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => pascalToCamelCaseKeys(raw));
42246
+ const { result } = await this.getByNameLookup("Bucket", BUCKET_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => pascalToCamelCaseKeys(raw));
42247
+ return result;
41386
42248
  }
41387
42249
  async getAll(options) {
41388
42250
  const transformBucketResponse = (bucket) => pascalToCamelCaseKeys(bucket);
@@ -42249,7 +43111,8 @@ class ProcessService extends FolderScopedService {
42249
43111
  return transformedProcess;
42250
43112
  }
42251
43113
  async getByName(name, options = {}) {
42252
- return this.getByNameLookup("Process", PROCESS_ENDPOINTS.GET_ALL, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), ProcessMap), ProcessMap);
43114
+ const { result } = await this.getByNameLookup("Process", PROCESS_ENDPOINTS.GET_ALL, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), ProcessMap), ProcessMap);
43115
+ return result;
42253
43116
  }
42254
43117
  }
42255
43118
  __decorate([
@@ -42264,21 +43127,112 @@ __decorate([
42264
43127
  __decorate([
42265
43128
  track("Processes.GetByName")
42266
43129
  ], ProcessService.prototype, "getByName", null);
43130
+ var QueuePriority;
43131
+ (function(QueuePriority2) {
43132
+ QueuePriority2["High"] = "High";
43133
+ QueuePriority2["Normal"] = "Normal";
43134
+ QueuePriority2["Low"] = "Low";
43135
+ })(QueuePriority || (QueuePriority = {}));
43136
+ var QueueItemStatus;
43137
+ (function(QueueItemStatus2) {
43138
+ QueueItemStatus2["New"] = "New";
43139
+ QueueItemStatus2["InProgress"] = "InProgress";
43140
+ QueueItemStatus2["Failed"] = "Failed";
43141
+ QueueItemStatus2["Successful"] = "Successful";
43142
+ QueueItemStatus2["Abandoned"] = "Abandoned";
43143
+ QueueItemStatus2["Retried"] = "Retried";
43144
+ QueueItemStatus2["Deleted"] = "Deleted";
43145
+ })(QueueItemStatus || (QueueItemStatus = {}));
43146
+ var QueueItemReviewStatus;
43147
+ (function(QueueItemReviewStatus2) {
43148
+ QueueItemReviewStatus2["None"] = "None";
43149
+ QueueItemReviewStatus2["InReview"] = "InReview";
43150
+ QueueItemReviewStatus2["Verified"] = "Verified";
43151
+ QueueItemReviewStatus2["Retried"] = "Retried";
43152
+ })(QueueItemReviewStatus || (QueueItemReviewStatus = {}));
43153
+ var QueueExceptionType;
43154
+ (function(QueueExceptionType2) {
43155
+ QueueExceptionType2["ApplicationException"] = "ApplicationException";
43156
+ QueueExceptionType2["BusinessException"] = "BusinessException";
43157
+ })(QueueExceptionType || (QueueExceptionType = {}));
43158
+ var QueueTransactionOutcome;
43159
+ (function(QueueTransactionOutcome2) {
43160
+ QueueTransactionOutcome2["Successful"] = "Successful";
43161
+ QueueTransactionOutcome2["Failed"] = "Failed";
43162
+ })(QueueTransactionOutcome || (QueueTransactionOutcome = {}));
43163
+ function createQueueMethods(queueData, service) {
43164
+ return {
43165
+ async getAllItems(options) {
43166
+ if (!queueData.id)
43167
+ throw new ValidationError3({ message: "Queue ID is undefined" });
43168
+ if (!queueData.folderId)
43169
+ throw new ValidationError3({ message: "Folder ID is undefined" });
43170
+ return service.getAllItems(queueData.id, { ...options, folderId: queueData.folderId });
43171
+ },
43172
+ async insertItem(specificData, options) {
43173
+ if (!queueData.name)
43174
+ throw new ValidationError3({ message: "Queue name is undefined" });
43175
+ if (!queueData.folderId)
43176
+ throw new ValidationError3({ message: "Folder ID is undefined" });
43177
+ return service.insertItemByName(queueData.name, specificData, { ...options, folderId: queueData.folderId });
43178
+ },
43179
+ async startTransaction() {
43180
+ if (!queueData.name)
43181
+ throw new ValidationError3({ message: "Queue name is undefined" });
43182
+ if (!queueData.folderId)
43183
+ throw new ValidationError3({ message: "Folder ID is undefined" });
43184
+ return service.startTransaction({ name: queueData.name }, { folderId: queueData.folderId });
43185
+ },
43186
+ async completeTransaction(itemId, outcome, options) {
43187
+ if (!queueData.folderId)
43188
+ throw new ValidationError3({ message: "Folder ID is undefined" });
43189
+ return service.completeTransaction(itemId, outcome, { ...options, folderId: queueData.folderId });
43190
+ }
43191
+ };
43192
+ }
43193
+ function createQueueWithMethods(queueData, service) {
43194
+ return Object.assign({}, queueData, createQueueMethods(queueData, service));
43195
+ }
42267
43196
  var QueueMap = {
42268
43197
  creationTime: "createdTime",
42269
43198
  organizationUnitId: "folderId",
42270
43199
  organizationUnitFullyQualifiedName: "folderName"
42271
43200
  };
43201
+ var QueueItemMap = {
43202
+ queueDefinitionId: "queueId",
43203
+ creationTime: "createdTime",
43204
+ organizationUnitId: "folderId",
43205
+ organizationUnitFullyQualifiedName: "folderName",
43206
+ startProcessing: "processingStartTime",
43207
+ endProcessing: "processingEndTime",
43208
+ processingException: "processingError"
43209
+ };
43210
+ var QueueItemProcessingErrorMap = {
43211
+ creationTime: "createdTime"
43212
+ };
43213
+ function transformQueueItem(queueItem) {
43214
+ const { SpecificContent, Output, SpecificData: _sd, OutputData: _od, ...rest } = queueItem;
43215
+ const transformed = transformData(pascalToCamelCaseKeys(rest), QueueItemMap);
43216
+ if (transformed.processingError) {
43217
+ transformed.processingError = transformData(transformed.processingError, QueueItemProcessingErrorMap);
43218
+ }
43219
+ transformed.specificData = SpecificContent ?? null;
43220
+ transformed.outputData = Output ?? null;
43221
+ return transformed;
43222
+ }
42272
43223
 
42273
43224
  class QueueService extends FolderScopedService {
42274
43225
  async getAll(options) {
42275
- const transformQueueResponse = (queue) => transformData(pascalToCamelCaseKeys(queue), QueueMap);
42276
- const apiOptions = options ? transformOptions(options, QueueMap) : options;
43226
+ const { folderId, folderKey, folderPath, ...queryOptions } = options ?? {};
43227
+ const hasFolderScope = folderId !== undefined || !!folderKey?.trim() || !!folderPath?.trim();
43228
+ const headers = hasFolderScope ? resolveFolderHeaders({ folderId, folderKey, folderPath, resourceType: "Queues.getAll" }) : undefined;
43229
+ const apiOptions = transformOptions(queryOptions, QueueMap);
42277
43230
  return PaginationHelpers.getAll({
42278
43231
  serviceAccess: this.createPaginationServiceAccess(),
42279
- getEndpoint: (folderId) => folderId ? QUEUE_ENDPOINTS.GET_BY_FOLDER : QUEUE_ENDPOINTS.GET_ALL,
43232
+ getEndpoint: () => hasFolderScope ? QUEUE_ENDPOINTS.GET_BY_FOLDER : QUEUE_ENDPOINTS.GET_ALL,
42280
43233
  getByFolderEndpoint: QUEUE_ENDPOINTS.GET_BY_FOLDER,
42281
- transformFn: transformQueueResponse,
43234
+ headers,
43235
+ transformFn: (queue) => createQueueWithMethods(transformData(pascalToCamelCaseKeys(queue), QueueMap), this),
42282
43236
  pagination: {
42283
43237
  paginationType: PaginationType.OFFSET,
42284
43238
  itemsField: ODATA_PAGINATION.ITEMS_FIELD,
@@ -42291,15 +43245,176 @@ class QueueService extends FolderScopedService {
42291
43245
  }
42292
43246
  }, apiOptions);
42293
43247
  }
42294
- async getById(id, folderId, options = {}) {
42295
- const headers = createHeaders({ [FOLDER_ID]: folderId });
42296
- const apiFieldOptions = transformOptions(options, QueueMap);
43248
+ async getById(id, folderIdOrOptions, options = {}) {
43249
+ if (typeof folderIdOrOptions === "number") {
43250
+ const headers2 = createHeaders({ [FOLDER_ID]: folderIdOrOptions });
43251
+ const apiFieldOptions2 = transformOptions(options, QueueMap);
43252
+ const apiOptions2 = addPrefixToKeys(apiFieldOptions2, ODATA_PREFIX, Object.keys(apiFieldOptions2));
43253
+ const response2 = await this.get(QUEUE_ENDPOINTS.GET_BY_ID(id), {
43254
+ headers: headers2,
43255
+ params: apiOptions2
43256
+ });
43257
+ return transformData(pascalToCamelCaseKeys(response2.data), QueueMap);
43258
+ }
43259
+ const { folderId, folderKey, folderPath, ...queryOptions } = folderIdOrOptions ?? {};
43260
+ const headers = resolveFolderHeaders({
43261
+ folderId,
43262
+ folderKey,
43263
+ folderPath,
43264
+ resourceType: "Queues.getById",
43265
+ fallbackFolderKey: this.config.folderKey
43266
+ });
43267
+ const apiFieldOptions = transformOptions(queryOptions, QueueMap);
42297
43268
  const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
42298
43269
  const response = await this.get(QUEUE_ENDPOINTS.GET_BY_ID(id), {
42299
43270
  headers,
42300
43271
  params: apiOptions
42301
43272
  });
42302
- return transformData(pascalToCamelCaseKeys(response.data), QueueMap);
43273
+ const rawQueue = transformData(pascalToCamelCaseKeys(response.data), QueueMap);
43274
+ return createQueueWithMethods(rawQueue, this);
43275
+ }
43276
+ async getByName(name, options = {}) {
43277
+ const { result } = await this.getByNameLookup("Queue", QUEUE_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => createQueueWithMethods(transformData(pascalToCamelCaseKeys(raw), QueueMap), this), QueueMap);
43278
+ return result;
43279
+ }
43280
+ async getByKey(key, options = {}) {
43281
+ const trimmedKey = key?.trim();
43282
+ if (!trimmedKey || !GUID_REGEX.test(trimmedKey)) {
43283
+ throw new ValidationError3({ message: "key must be a GUID for getByKey" });
43284
+ }
43285
+ const { folderId, folderKey, folderPath, ...queryOptions } = options;
43286
+ const headers = resolveFolderHeaders({
43287
+ folderId,
43288
+ folderKey,
43289
+ folderPath,
43290
+ resourceType: "Queues.getByKey",
43291
+ fallbackFolderKey: this.config.folderKey
43292
+ });
43293
+ const apiFieldOptions = transformOptions(queryOptions, QueueMap);
43294
+ const apiOptions = {
43295
+ ...addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions)),
43296
+ $filter: `Key eq ${trimmedKey}`,
43297
+ $top: "1"
43298
+ };
43299
+ const response = await this.get(QUEUE_ENDPOINTS.GET_BY_FOLDER, { headers, params: apiOptions });
43300
+ const items = response.data?.value;
43301
+ if (!items?.length) {
43302
+ throw new NotFoundError({ message: `Queue with key '${trimmedKey}' not found.` });
43303
+ }
43304
+ return createQueueWithMethods(transformData(pascalToCamelCaseKeys(items[0]), QueueMap), this);
43305
+ }
43306
+ async getAllItems(queueId, options) {
43307
+ if (!queueId) {
43308
+ throw new ValidationError3({ message: "queueId is required for getAllItems" });
43309
+ }
43310
+ const { folderId, folderKey, folderPath, filter, ...restOptions } = options ?? {};
43311
+ const headers = resolveFolderHeaders({
43312
+ folderId,
43313
+ folderKey,
43314
+ folderPath,
43315
+ resourceType: "Queues.getAllItems",
43316
+ fallbackFolderKey: this.config.folderKey
43317
+ });
43318
+ const mergedFilter = filter ? `(${filter}) and queueId eq ${queueId}` : `queueId eq ${queueId}`;
43319
+ const apiOptions = transformOptions({ ...restOptions, filter: mergedFilter }, QueueItemMap);
43320
+ return PaginationHelpers.getAll({
43321
+ serviceAccess: this.createPaginationServiceAccess(),
43322
+ getEndpoint: () => QUEUE_ENDPOINTS.GET_ITEMS,
43323
+ getByFolderEndpoint: QUEUE_ENDPOINTS.GET_ITEMS,
43324
+ headers,
43325
+ transformFn: transformQueueItem,
43326
+ pagination: {
43327
+ paginationType: PaginationType.OFFSET,
43328
+ itemsField: ODATA_PAGINATION.ITEMS_FIELD,
43329
+ totalCountField: ODATA_PAGINATION.TOTAL_COUNT_FIELD,
43330
+ paginationParams: {
43331
+ pageSizeParam: ODATA_OFFSET_PARAMS.PAGE_SIZE_PARAM,
43332
+ offsetParam: ODATA_OFFSET_PARAMS.OFFSET_PARAM,
43333
+ countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM
43334
+ }
43335
+ }
43336
+ }, apiOptions);
43337
+ }
43338
+ async insertItemByName(queueName, specificData, options = {}) {
43339
+ if (!queueName) {
43340
+ throw new ValidationError3({ message: "queueName is required for insertItemByName" });
43341
+ }
43342
+ const headers = resolveFolderHeaders({
43343
+ folderId: options.folderId,
43344
+ folderKey: options.folderKey,
43345
+ folderPath: options.folderPath,
43346
+ resourceType: "Queues.insertItemByName",
43347
+ fallbackFolderKey: this.config.folderKey
43348
+ });
43349
+ const response = await this.post(QUEUE_ENDPOINTS.ADD_ITEM, {
43350
+ itemData: {
43351
+ Name: queueName,
43352
+ Priority: options.priority ?? QueuePriority.Normal,
43353
+ Reference: options.reference,
43354
+ Progress: options.progress,
43355
+ DeferDate: options.deferDate?.toISOString(),
43356
+ DueDate: options.dueDate?.toISOString(),
43357
+ RiskSlaDate: options.riskSlaDate?.toISOString(),
43358
+ SpecificContent: specificData
43359
+ }
43360
+ }, { headers });
43361
+ return transformQueueItem(response.data);
43362
+ }
43363
+ async startTransaction(queue, options = {}) {
43364
+ const headers = resolveFolderHeaders({
43365
+ folderId: options.folderId,
43366
+ folderKey: options.folderKey,
43367
+ folderPath: options.folderPath,
43368
+ resourceType: "Queues.startTransaction",
43369
+ fallbackFolderKey: this.config.folderKey
43370
+ });
43371
+ let queueName;
43372
+ if (queue?.name) {
43373
+ queueName = queue.name;
43374
+ } else if (queue?.id != null) {
43375
+ queueName = await this.resolveQueueName(queue.id, headers);
43376
+ } else {
43377
+ throw new ValidationError3({ message: "queue id or name is required for startTransaction" });
43378
+ }
43379
+ const response = await this.post(QUEUE_ENDPOINTS.START_TRANSACTION, {
43380
+ transactionData: { Name: queueName }
43381
+ }, { headers });
43382
+ if (!response.data || typeof response.data !== "object") {
43383
+ return null;
43384
+ }
43385
+ return transformQueueItem(response.data);
43386
+ }
43387
+ async completeTransaction(itemId, outcome, options = {}) {
43388
+ if (!itemId) {
43389
+ throw new ValidationError3({ message: "itemId is required for completeTransaction" });
43390
+ }
43391
+ const headers = resolveFolderHeaders({
43392
+ folderId: options.folderId,
43393
+ folderKey: options.folderKey,
43394
+ folderPath: options.folderPath,
43395
+ resourceType: "Queues.completeTransaction",
43396
+ fallbackFolderKey: this.config.folderKey
43397
+ });
43398
+ const transactionResult = {
43399
+ IsSuccessful: outcome === QueueTransactionOutcome.Successful,
43400
+ ProcessingException: options.processingError && {
43401
+ Reason: options.processingError.reason,
43402
+ Details: options.processingError.details,
43403
+ Type: options.processingError.type,
43404
+ AssociatedImageFilePath: options.processingError.associatedImageFilePath
43405
+ },
43406
+ DeferDate: options.deferDate?.toISOString(),
43407
+ DueDate: options.dueDate?.toISOString(),
43408
+ Progress: options.progress,
43409
+ OperationId: options.operationId,
43410
+ Output: options.outputData,
43411
+ Analytics: options.analytics
43412
+ };
43413
+ await this.post(QUEUE_ENDPOINTS.SET_TRANSACTION_RESULT(itemId), { transactionResult }, { headers });
43414
+ }
43415
+ async resolveQueueName(queueId, headers) {
43416
+ const response = await this.get(QUEUE_ENDPOINTS.GET_BY_ID(queueId), { headers, params: { $select: "Name" } });
43417
+ return response.data.Name;
42303
43418
  }
42304
43419
  }
42305
43420
  __decorate([
@@ -42308,6 +43423,24 @@ __decorate([
42308
43423
  __decorate([
42309
43424
  track("Queues.GetById")
42310
43425
  ], QueueService.prototype, "getById", null);
43426
+ __decorate([
43427
+ track("Queues.GetByName")
43428
+ ], QueueService.prototype, "getByName", null);
43429
+ __decorate([
43430
+ track("Queues.GetByKey")
43431
+ ], QueueService.prototype, "getByKey", null);
43432
+ __decorate([
43433
+ track("Queues.GetAllItems")
43434
+ ], QueueService.prototype, "getAllItems", null);
43435
+ __decorate([
43436
+ track("Queues.InsertItemByName")
43437
+ ], QueueService.prototype, "insertItemByName", null);
43438
+ __decorate([
43439
+ track("Queues.StartTransaction")
43440
+ ], QueueService.prototype, "startTransaction", null);
43441
+ __decorate([
43442
+ track("Queues.CompleteTransaction")
43443
+ ], QueueService.prototype, "completeTransaction", null);
42311
43444
  var TaskCatalogMap = {
42312
43445
  creationTime: "createdTime",
42313
43446
  lastModificationTime: "lastModifiedTime"
@@ -42354,7 +43487,8 @@ class TaskCatalogService extends FolderScopedService {
42354
43487
  return transformData(pascalToCamelCaseKeys(response.data), TaskCatalogMap);
42355
43488
  }
42356
43489
  async getByName(name, options = {}) {
42357
- return this.getByNameLookup("TaskCatalog", TASK_CATALOG_ENDPOINTS.GET_ALL, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), TaskCatalogMap), TaskCatalogMap);
43490
+ const { result } = await this.getByNameLookup("TaskCatalog", TASK_CATALOG_ENDPOINTS.GET_ALL, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), TaskCatalogMap), TaskCatalogMap);
43491
+ return result;
42358
43492
  }
42359
43493
  async create(name, options = {}) {
42360
43494
  if (!name) {
@@ -42378,7 +43512,7 @@ class TaskCatalogService extends FolderScopedService {
42378
43512
  throw new ValidationError3({ message: "name is required for updateByName" });
42379
43513
  }
42380
43514
  const { folderId, folderKey, folderPath } = options;
42381
- const current = await this.getByNameLookup("TaskCatalog", TASK_CATALOG_ENDPOINTS.GET_ALL, name, { folderId, folderKey, folderPath }, (raw) => transformData(pascalToCamelCaseKeys(raw), TaskCatalogMap), TaskCatalogMap);
43515
+ const { result: current } = await this.getByNameLookup("TaskCatalog", TASK_CATALOG_ENDPOINTS.GET_ALL, name, { folderId, folderKey, folderPath }, (raw) => transformData(pascalToCamelCaseKeys(raw), TaskCatalogMap), TaskCatalogMap);
42382
43516
  return this.update(current, options);
42383
43517
  }
42384
43518
  async update(current, options) {
@@ -42523,6 +43657,13 @@ var AgentMap = {
42523
43657
  var UserSettingsMap = {
42524
43658
  ...CommonFieldMap
42525
43659
  };
43660
+ var ConnectionState;
43661
+ (function(ConnectionState2) {
43662
+ ConnectionState2["Enabled"] = "Enabled";
43663
+ ConnectionState2["Disabled"] = "Disabled";
43664
+ ConnectionState2["Expired"] = "Expired";
43665
+ ConnectionState2["Failed"] = "Failed";
43666
+ })(ConnectionState || (ConnectionState = {}));
42526
43667
  var FeedbackStatus;
42527
43668
  (function(FeedbackStatus2) {
42528
43669
  FeedbackStatus2[FeedbackStatus2["Pending"] = 0] = "Pending";
@@ -43409,4 +44550,4 @@ var registerCommands = async (program2) => {
43409
44550
 
43410
44551
  export { Command, metadata, registerCommands };
43411
44552
 
43412
- //# debugId=AA8CC418A164893E64756E2164756E21
44553
+ //# debugId=C52E7100F1D99EB864756E2164756E21