bruce-models 7.1.90 → 7.1.92

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.
@@ -2905,9 +2905,22 @@
2905
2905
  EStatus["Denied"] = "Denied";
2906
2906
  EStatus["Cancelled"] = "Cancelled";
2907
2907
  EStatus["Sent"] = "Sent";
2908
- EStatus["NotSent"] = "NotSent";
2908
+ EStatus["NotSent"] = "Not sent";
2909
2909
  EStatus["Accepted"] = "Accepted";
2910
2910
  })(EStatus = AccountInvite.EStatus || (AccountInvite.EStatus = {}));
2911
+ /**
2912
+ * Returns whether an invite is still awaiting a response from its recipient.
2913
+ * Expiry is held as a timestamp rather than a status, so it is checked separately.
2914
+ * @param invite
2915
+ * @returns
2916
+ */
2917
+ function IsPending(invite) {
2918
+ if (!invite || invite.IsExpired) {
2919
+ return false;
2920
+ }
2921
+ return invite.Status === EStatus.Sent || invite.Status === EStatus.NotSent;
2922
+ }
2923
+ AccountInvite.IsPending = IsPending;
2911
2924
  /**
2912
2925
  * Possible invite methods.
2913
2926
  */
@@ -2952,22 +2965,61 @@
2952
2965
  */
2953
2966
  function GetList(params) {
2954
2967
  return __awaiter(this, void 0, void 0, function* () {
2955
- let { api, accountId, userId, req } = params;
2968
+ let { api, accountId, userId, status, expired, expandUsers, expandGroups, pageSize, pageIndex, req } = params;
2956
2969
  if (!api) {
2957
2970
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
2958
2971
  }
2959
2972
  const urlParams = new URLSearchParams();
2960
2973
  if (accountId) {
2961
- urlParams.append("accountId", accountId);
2974
+ urlParams.append("Account", accountId);
2962
2975
  }
2963
2976
  if (userId) {
2964
- urlParams.append("userId", userId);
2977
+ urlParams.append("User", userId);
2965
2978
  }
2966
- const res = yield api.GET("invites?" + urlParams.toString(), exports.Api.PrepReqParams(req));
2967
- return res;
2979
+ if (status === null || status === void 0 ? void 0 : status.length) {
2980
+ urlParams.append("Status", status.join(","));
2981
+ }
2982
+ if (expired !== undefined && expired !== null) {
2983
+ urlParams.append("Expired", expired ? "true" : "false");
2984
+ }
2985
+ const expand = [];
2986
+ if (expandUsers) {
2987
+ expand.push("user");
2988
+ }
2989
+ if (expandGroups) {
2990
+ expand.push("group");
2991
+ }
2992
+ if (expand.length) {
2993
+ urlParams.append("Expand", expand.join(","));
2994
+ }
2995
+ if (pageSize !== undefined && pageSize !== null) {
2996
+ urlParams.append("PageSize", String(pageSize));
2997
+ }
2998
+ if (pageIndex !== undefined && pageIndex !== null) {
2999
+ urlParams.append("PageIndex", String(pageIndex));
3000
+ }
3001
+ const res = yield api.GET("v3/accountInvites?" + urlParams.toString(), exports.Api.PrepReqParams(req));
3002
+ return {
3003
+ invites: res.Items || [],
3004
+ totalCount: res.TotalCount,
3005
+ hasNextPage: res.HasNextPage,
3006
+ userGroups: res.UserGroup
3007
+ };
2968
3008
  });
2969
3009
  }
2970
3010
  AccountInvite.GetList = GetList;
3011
+ /**
3012
+ * Returns the number of invites matching the criteria, without fetching any.
3013
+ * @param params
3014
+ * @returns
3015
+ */
3016
+ function GetCount(params) {
3017
+ return __awaiter(this, void 0, void 0, function* () {
3018
+ const res = yield GetList(Object.assign(Object.assign({}, params), { pageSize: -1, pageIndex: -1 }));
3019
+ return res.totalCount || 0;
3020
+ });
3021
+ }
3022
+ AccountInvite.GetCount = GetCount;
2971
3023
  /**
2972
3024
  * Updates an invite's status.
2973
3025
  * Once an invite is accepted or denied it cannot be changed.
@@ -2976,19 +3028,37 @@
2976
3028
  */
2977
3029
  function Update(params) {
2978
3030
  return __awaiter(this, void 0, void 0, function* () {
2979
- let { api, code, status, user, req } = params;
3031
+ let { api, code, id, status, groupIds, user, req } = params;
2980
3032
  if (!api) {
2981
3033
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
2982
3034
  }
2983
- const res = yield api.POST("invite/update", {
3035
+ if (!code && !id) {
3036
+ throw new Error("Either an invite ID or InviteCode must be provided.");
3037
+ }
3038
+ const invite = yield api.POST("v3/accountInvite", {
3039
+ ID: id,
2984
3040
  InviteCode: code,
2985
3041
  Status: status,
3042
+ "UserGroup.ID": groupIds,
2986
3043
  User: user
2987
3044
  }, exports.Api.PrepReqParams(req));
2988
- return res;
3045
+ return {
3046
+ invite: invite
3047
+ };
2989
3048
  });
2990
3049
  }
2991
3050
  AccountInvite.Update = Update;
3051
+ /**
3052
+ * Cancels a pending invite. Requires the session to be an account owner or admin.
3053
+ * @param params
3054
+ * @returns
3055
+ */
3056
+ function Cancel(params) {
3057
+ return __awaiter(this, void 0, void 0, function* () {
3058
+ return Update(Object.assign(Object.assign({}, params), { status: EStatus.Cancelled }));
3059
+ });
3060
+ }
3061
+ AccountInvite.Cancel = Cancel;
2992
3062
  /**
2993
3063
  * Creates a new invite.
2994
3064
  * Please validate the response invitation records to ensure the desired contact method was used and worked.
@@ -2998,13 +3068,31 @@
2998
3068
  */
2999
3069
  function Create(params) {
3000
3070
  return __awaiter(this, void 0, void 0, function* () {
3001
- let { api, accountId, login, userId, email, mobile, emailTemplateKey, groupIds, req, inviteMethod } = params;
3071
+ let { api, accountId, login, userId, email, mobile, emailTemplateKey, groupIds, req, inviteMethod, pending } = params;
3002
3072
  if (!api) {
3003
3073
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
3004
3074
  }
3005
3075
  if (!(groupIds === null || groupIds === void 0 ? void 0 : groupIds.length)) {
3006
3076
  throw new Error("At least one User Group ID must be provided.");
3007
3077
  }
3078
+ if (pending) {
3079
+ const res = yield api.POST("v3/createAccountInvite", {
3080
+ Account: accountId,
3081
+ Username: login,
3082
+ Email: email,
3083
+ Mobile: mobile,
3084
+ "User.ID": userId,
3085
+ "UserGroup.ID": groupIds,
3086
+ "Email.Template": emailTemplateKey,
3087
+ Method: inviteMethod
3088
+ }, exports.Api.PrepReqParams(req));
3089
+ return {
3090
+ warnings: res.Warning,
3091
+ user: res["Invited.User"],
3092
+ invite: res,
3093
+ manualInviteCode: res.InviteCode
3094
+ };
3095
+ }
3008
3096
  const res = yield api.POST("invite/new", {
3009
3097
  accountId,
3010
3098
  login,
@@ -17442,6 +17530,96 @@
17442
17530
  ImportLcc.ImportEntities = ImportEntities;
17443
17531
  })(exports.ImportLcc || (exports.ImportLcc = {}));
17444
17532
 
17533
+ (function (ImportTif) {
17534
+ /**
17535
+ * A few vertical CRSs a user is likely to be choosing between. Any EPSG vertical code is
17536
+ * accepted, so this is a convenience rather than the permitted set.
17537
+ */
17538
+ let EVerticalDatum;
17539
+ (function (EVerticalDatum) {
17540
+ // Heights are already on the ellipsoid, or the source is not elevation.
17541
+ EVerticalDatum[EVerticalDatum["None"] = 0] = "None";
17542
+ EVerticalDatum[EVerticalDatum["NAVD88"] = 5703] = "NAVD88";
17543
+ EVerticalDatum[EVerticalDatum["EGM96"] = 5773] = "EGM96";
17544
+ EVerticalDatum[EVerticalDatum["EGM2008"] = 3855] = "EGM2008";
17545
+ EVerticalDatum[EVerticalDatum["NZVD2016"] = 7839] = "NZVD2016";
17546
+ })(EVerticalDatum = ImportTif.EVerticalDatum || (ImportTif.EVerticalDatum = {}));
17547
+ /**
17548
+ * Reads an analysis out of a completed Pending Action.
17549
+ * @param action the completed analyze action
17550
+ * @returns the result, or null when the action carries none
17551
+ */
17552
+ function ReadAnalysis(action) {
17553
+ if (!(action === null || action === void 0 ? void 0 : action.Result)) {
17554
+ return null;
17555
+ }
17556
+ try {
17557
+ const parsed = typeof action.Result === "string" ? JSON.parse(action.Result) : action.Result;
17558
+ // A successful action wraps its answer; older ones returned it bare.
17559
+ const result = (parsed === null || parsed === void 0 ? void 0 : parsed.success) && (parsed === null || parsed === void 0 ? void 0 : parsed.result) ? parsed.result : parsed;
17560
+ return result && typeof result === "object" ? result : null;
17561
+ }
17562
+ catch (_a) {
17563
+ return null;
17564
+ }
17565
+ }
17566
+ ImportTif.ReadAnalysis = ReadAnalysis;
17567
+ /**
17568
+ * Whether the user has to be asked what the heights are referenced to.
17569
+ * @param analysis the analysis result
17570
+ * @returns true for elevation that declares no vertical CRS
17571
+ */
17572
+ function NeedsVerticalDatum(analysis) {
17573
+ if (!analysis) {
17574
+ return false;
17575
+ }
17576
+ return (analysis.type === exports.Tileset.EType.Terrain) && (analysis.verticalDeclared !== true);
17577
+ }
17578
+ ImportTif.NeedsVerticalDatum = NeedsVerticalDatum;
17579
+ /**
17580
+ * Whether the user has to be asked which CRS the source is in.
17581
+ * @param analysis the analysis result
17582
+ * @returns true when no horizontal CRS could be resolved at all
17583
+ */
17584
+ function NeedsHorizontalCrs(analysis) {
17585
+ if (!analysis) {
17586
+ return false;
17587
+ }
17588
+ return !(analysis.epsg && analysis.epsg > 0);
17589
+ }
17590
+ ImportTif.NeedsHorizontalCrs = NeedsHorizontalCrs;
17591
+ /**
17592
+ * Starts an analysis of an uploaded raster.
17593
+ * @param params
17594
+ * @returns the Pending Action to poll
17595
+ */
17596
+ function Analyze(params) {
17597
+ return __awaiter(this, void 0, void 0, function* () {
17598
+ let { api, analyze, req: reqParams } = params;
17599
+ if (!api) {
17600
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
17601
+ }
17602
+ return api.POST("import/analyze/tif", analyze, exports.Api.PrepReqParams(reqParams));
17603
+ });
17604
+ }
17605
+ ImportTif.Analyze = Analyze;
17606
+ /**
17607
+ * Imports an analysed raster: the API creates the tileset and starts generating it.
17608
+ * @param params
17609
+ * @returns the created tileset and the Pending Action to poll
17610
+ */
17611
+ function Import(params) {
17612
+ return __awaiter(this, void 0, void 0, function* () {
17613
+ let { api, fileImport, req: reqParams } = params;
17614
+ if (!api) {
17615
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
17616
+ }
17617
+ return api.POST("import/tif", fileImport, exports.Api.PrepReqParams(reqParams));
17618
+ });
17619
+ }
17620
+ ImportTif.Import = Import;
17621
+ })(exports.ImportTif || (exports.ImportTif = {}));
17622
+
17445
17623
  (function (ImportedFile) {
17446
17624
  /**
17447
17625
  * Returns cache identifier for a imported file record.
@@ -18713,7 +18891,13 @@
18713
18891
 
18714
18892
  window["${resultId}"] = Invoke(window["${argsId}"], window["${contextId}"]);
18715
18893
  }
18716
- invoke();
18894
+ // Called with a receiver, not bare. The API builds index.jsc by
18895
+ // wrapping the plugin's index.js in a controller shell that
18896
+ // assigns 'this.Init = ...', and under "use strict" a bare call
18897
+ // leaves 'this' undefined, so every plugin would die on that
18898
+ // line before its own code ran. A throwaway object satisfies
18899
+ // the shell without giving the plugin the global scope back.
18900
+ invoke.call({});
18717
18901
  `;
18718
18902
  try {
18719
18903
  // 'eval2 = eval' stops the linter from complaining about using eval.
@@ -18792,6 +18976,24 @@
18792
18976
  * and nothing downstream reports that it happened.
18793
18977
  */
18794
18978
  const STRICT_INCOMPATIBLE_KEYWORDS = ["$ref", "$defs", "allOf", "not"];
18979
+ /** Depth beyond which a schema is refused as unverifiable rather than assumed clean. */
18980
+ const MAX_SCHEMA_DEPTH = 32;
18981
+ /**
18982
+ * Keys whose values are author-named property maps rather than schemas.
18983
+ *
18984
+ * Everything under them is a name the author chose, so a property legitimately
18985
+ * called "not" or "allOf" is not a keyword and must not be matched as one.
18986
+ */
18987
+ const PROPERTY_NAME_HOLDERS = ["properties", "patternProperties", "definitions", "dependentSchemas"];
18988
+ /**
18989
+ * Shortest timeout the host can actually apply.
18990
+ *
18991
+ * It converts the declared value to seconds by integer division, so anything
18992
+ * below this truncates to zero.
18993
+ */
18994
+ const MIN_TIMEOUT_MS = 1000;
18995
+ /** Longest timeout an account may declare. */
18996
+ const MAX_TIMEOUT_MS = 120000;
18795
18997
  /**
18796
18998
  * Side effects an AI Tool may declare.
18797
18999
  *
@@ -18807,9 +19009,14 @@
18807
19009
  * @returns the offending keyword, or null
18808
19010
  */
18809
19011
  function findStrictModeViolation(node, depth = 0) {
18810
- if (!node || typeof node !== "object" || depth > 32) {
19012
+ if (!node || typeof node !== "object") {
18811
19013
  return null;
18812
19014
  }
19015
+ if (depth > MAX_SCHEMA_DEPTH) {
19016
+ // Returning "clean" here would let a $ref nested past the cap through
19017
+ // as verified, which is the exact thing this walk exists to catch.
19018
+ return `a schema nested deeper than ${MAX_SCHEMA_DEPTH} levels, which cannot be checked`;
19019
+ }
18813
19020
  if (Array.isArray(node)) {
18814
19021
  for (const child of node) {
18815
19022
  const nested = findStrictModeViolation(child, depth + 1);
@@ -18819,11 +19026,28 @@
18819
19026
  }
18820
19027
  return null;
18821
19028
  }
19029
+ // A keyword only counts at a schema position. Under "properties" and
19030
+ // friends the field names are chosen by the author, so a property
19031
+ // legitimately called "not" or "allOf" is a name, not a keyword.
18822
19032
  for (const key of Object.keys(node)) {
18823
19033
  if (STRICT_INCOMPATIBLE_KEYWORDS.includes(key)) {
18824
19034
  return key;
18825
19035
  }
18826
- const nested = findStrictModeViolation(node[key], depth + 1);
19036
+ }
19037
+ for (const key of Object.keys(node)) {
19038
+ const child = node[key];
19039
+ if (PROPERTY_NAME_HOLDERS.includes(key)) {
19040
+ if (child && typeof child === "object" && !Array.isArray(child)) {
19041
+ for (const name of Object.keys(child)) {
19042
+ const nested = findStrictModeViolation(child[name], depth + 2);
19043
+ if (nested) {
19044
+ return nested;
19045
+ }
19046
+ }
19047
+ }
19048
+ continue;
19049
+ }
19050
+ const nested = findStrictModeViolation(child, depth + 1);
18827
19051
  if (nested) {
18828
19052
  return nested;
18829
19053
  }
@@ -18863,9 +19087,14 @@
18863
19087
  // tool does. The description is the only thing the agent can select on:
18864
19088
  // without one it is registered but never chosen, and nothing reports that.
18865
19089
  const description = typeof tool.description === "string" ? tool.description.trim() : "";
18866
- if (!description && !((_c = plugin.Name) !== null && _c !== void 0 ? _c : "").trim()) {
18867
- return "An AI Tool needs a description. Set Settings.tool.description, or fill in the plugin's "
18868
- + "Name and Description the agent has nothing else to choose the tool on.";
19090
+ // The fallback is "Name: Description", so a plugin with only a Name yields
19091
+ // a description of a few words. That satisfied the old check while leaving
19092
+ // the agent almost nothing to select on -- and since Save is disabled while
19093
+ // Name is empty, the old check could never fire at all.
19094
+ if (!description && !((_c = plugin.Description) !== null && _c !== void 0 ? _c : "").trim()) {
19095
+ return "An AI Tool needs a description saying what it does and when to use it. Set "
19096
+ + "Settings.tool.description, or fill in the plugin's Description — the tool name is "
19097
+ + "an opaque ID, so this is the only thing the agent can choose it on.";
18869
19098
  }
18870
19099
  if (!isPlainObject(tool.inputSchema)) {
18871
19100
  return "Settings.tool.inputSchema is missing or is not an object.";
@@ -18890,6 +19119,21 @@
18890
19119
  }
18891
19120
  }
18892
19121
  if (annotations.timeoutMs !== undefined) {
19122
+ if (typeof annotations.timeoutMs === "number"
19123
+ && isFinite(annotations.timeoutMs)
19124
+ && annotations.timeoutMs > 0
19125
+ && annotations.timeoutMs < MIN_TIMEOUT_MS) {
19126
+ // The host converts this to seconds by integer division, so
19127
+ // anything under a second becomes no wait at all -- the opposite
19128
+ // of a short timeout, and the tool then fails on every call.
19129
+ return `timeoutMs is ${annotations.timeoutMs}ms, but the shortest timeout the host can `
19130
+ + `apply is ${MIN_TIMEOUT_MS}ms. A smaller value would be rounded down to no wait at all.`;
19131
+ }
19132
+ if (typeof annotations.timeoutMs === "number"
19133
+ && isFinite(annotations.timeoutMs)
19134
+ && annotations.timeoutMs > MAX_TIMEOUT_MS) {
19135
+ return `timeoutMs is ${annotations.timeoutMs}ms, above the maximum of ${MAX_TIMEOUT_MS}ms.`;
19136
+ }
18893
19137
  if (typeof annotations.timeoutMs !== "number"
18894
19138
  || !isFinite(annotations.timeoutMs)
18895
19139
  || annotations.timeoutMs <= 0) {
@@ -22893,7 +23137,7 @@
22893
23137
  })(exports.UrlUtils || (exports.UrlUtils = {}));
22894
23138
 
22895
23139
  // This is updated with the package.json version on build.
22896
- const VERSION = "7.1.90";
23140
+ const VERSION = "7.1.92";
22897
23141
 
22898
23142
  exports.VERSION = VERSION;
22899
23143
  exports.AbstractApi = AbstractApi;