bruce-models 7.1.91 → 7.1.93

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.
@@ -2943,9 +2943,22 @@ var AccountInvite;
2943
2943
  EStatus["Denied"] = "Denied";
2944
2944
  EStatus["Cancelled"] = "Cancelled";
2945
2945
  EStatus["Sent"] = "Sent";
2946
- EStatus["NotSent"] = "NotSent";
2946
+ EStatus["NotSent"] = "Not sent";
2947
2947
  EStatus["Accepted"] = "Accepted";
2948
2948
  })(EStatus = AccountInvite.EStatus || (AccountInvite.EStatus = {}));
2949
+ /**
2950
+ * Returns whether an invite is still awaiting a response from its recipient.
2951
+ * Expiry is held as a timestamp rather than a status, so it is checked separately.
2952
+ * @param invite
2953
+ * @returns
2954
+ */
2955
+ function IsPending(invite) {
2956
+ if (!invite || invite.IsExpired) {
2957
+ return false;
2958
+ }
2959
+ return invite.Status === EStatus.Sent || invite.Status === EStatus.NotSent;
2960
+ }
2961
+ AccountInvite.IsPending = IsPending;
2949
2962
  /**
2950
2963
  * Possible invite methods.
2951
2964
  */
@@ -2990,22 +3003,61 @@ var AccountInvite;
2990
3003
  */
2991
3004
  function GetList(params) {
2992
3005
  return __awaiter(this, void 0, void 0, function* () {
2993
- let { api, accountId, userId, req } = params;
3006
+ let { api, accountId, userId, status, expired, expandUsers, expandGroups, pageSize, pageIndex, req } = params;
2994
3007
  if (!api) {
2995
3008
  api = ENVIRONMENT.Api().GetGuardianApi();
2996
3009
  }
2997
3010
  const urlParams = new URLSearchParams();
2998
3011
  if (accountId) {
2999
- urlParams.append("accountId", accountId);
3012
+ urlParams.append("Account", accountId);
3000
3013
  }
3001
3014
  if (userId) {
3002
- urlParams.append("userId", userId);
3015
+ urlParams.append("User", userId);
3003
3016
  }
3004
- const res = yield api.GET("invites?" + urlParams.toString(), Api.PrepReqParams(req));
3005
- return res;
3017
+ if (status === null || status === void 0 ? void 0 : status.length) {
3018
+ urlParams.append("Status", status.join(","));
3019
+ }
3020
+ if (expired !== undefined && expired !== null) {
3021
+ urlParams.append("Expired", expired ? "true" : "false");
3022
+ }
3023
+ const expand = [];
3024
+ if (expandUsers) {
3025
+ expand.push("user");
3026
+ }
3027
+ if (expandGroups) {
3028
+ expand.push("group");
3029
+ }
3030
+ if (expand.length) {
3031
+ urlParams.append("Expand", expand.join(","));
3032
+ }
3033
+ if (pageSize !== undefined && pageSize !== null) {
3034
+ urlParams.append("PageSize", String(pageSize));
3035
+ }
3036
+ if (pageIndex !== undefined && pageIndex !== null) {
3037
+ urlParams.append("PageIndex", String(pageIndex));
3038
+ }
3039
+ const res = yield api.GET("v3/accountInvites?" + urlParams.toString(), Api.PrepReqParams(req));
3040
+ return {
3041
+ invites: res.Items || [],
3042
+ totalCount: res.TotalCount,
3043
+ hasNextPage: res.HasNextPage,
3044
+ userGroups: res.UserGroup
3045
+ };
3006
3046
  });
3007
3047
  }
3008
3048
  AccountInvite.GetList = GetList;
3049
+ /**
3050
+ * Returns the number of invites matching the criteria, without fetching any.
3051
+ * @param params
3052
+ * @returns
3053
+ */
3054
+ function GetCount(params) {
3055
+ return __awaiter(this, void 0, void 0, function* () {
3056
+ const res = yield GetList(Object.assign(Object.assign({}, params), { pageSize: -1, pageIndex: -1 }));
3057
+ return res.totalCount || 0;
3058
+ });
3059
+ }
3060
+ AccountInvite.GetCount = GetCount;
3009
3061
  /**
3010
3062
  * Updates an invite's status.
3011
3063
  * Once an invite is accepted or denied it cannot be changed.
@@ -3014,19 +3066,37 @@ var AccountInvite;
3014
3066
  */
3015
3067
  function Update(params) {
3016
3068
  return __awaiter(this, void 0, void 0, function* () {
3017
- let { api, code, status, user, req } = params;
3069
+ let { api, code, id, status, groupIds, user, req } = params;
3018
3070
  if (!api) {
3019
3071
  api = ENVIRONMENT.Api().GetGuardianApi();
3020
3072
  }
3021
- const res = yield api.POST("invite/update", {
3073
+ if (!code && !id) {
3074
+ throw new Error("Either an invite ID or InviteCode must be provided.");
3075
+ }
3076
+ const invite = yield api.POST("v3/accountInvite", {
3077
+ ID: id,
3022
3078
  InviteCode: code,
3023
3079
  Status: status,
3080
+ "UserGroup.ID": groupIds,
3024
3081
  User: user
3025
3082
  }, Api.PrepReqParams(req));
3026
- return res;
3083
+ return {
3084
+ invite: invite
3085
+ };
3027
3086
  });
3028
3087
  }
3029
3088
  AccountInvite.Update = Update;
3089
+ /**
3090
+ * Cancels a pending invite. Requires the session to be an account owner or admin.
3091
+ * @param params
3092
+ * @returns
3093
+ */
3094
+ function Cancel(params) {
3095
+ return __awaiter(this, void 0, void 0, function* () {
3096
+ return Update(Object.assign(Object.assign({}, params), { status: EStatus.Cancelled }));
3097
+ });
3098
+ }
3099
+ AccountInvite.Cancel = Cancel;
3030
3100
  /**
3031
3101
  * Creates a new invite.
3032
3102
  * Please validate the response invitation records to ensure the desired contact method was used and worked.
@@ -3036,13 +3106,31 @@ var AccountInvite;
3036
3106
  */
3037
3107
  function Create(params) {
3038
3108
  return __awaiter(this, void 0, void 0, function* () {
3039
- let { api, accountId, login, userId, email, mobile, emailTemplateKey, groupIds, req, inviteMethod } = params;
3109
+ let { api, accountId, login, userId, email, mobile, emailTemplateKey, groupIds, req, inviteMethod, pending } = params;
3040
3110
  if (!api) {
3041
3111
  api = ENVIRONMENT.Api().GetGuardianApi();
3042
3112
  }
3043
3113
  if (!(groupIds === null || groupIds === void 0 ? void 0 : groupIds.length)) {
3044
3114
  throw new Error("At least one User Group ID must be provided.");
3045
3115
  }
3116
+ if (pending) {
3117
+ const res = yield api.POST("v3/createAccountInvite", {
3118
+ Account: accountId,
3119
+ Username: login,
3120
+ Email: email,
3121
+ Mobile: mobile,
3122
+ "User.ID": userId,
3123
+ "UserGroup.ID": groupIds,
3124
+ "Email.Template": emailTemplateKey,
3125
+ Method: inviteMethod
3126
+ }, Api.PrepReqParams(req));
3127
+ return {
3128
+ warnings: res.Warning,
3129
+ user: res["Invited.User"],
3130
+ invite: res,
3131
+ manualInviteCode: res.InviteCode
3132
+ };
3133
+ }
3046
3134
  const res = yield api.POST("invite/new", {
3047
3135
  accountId,
3048
3136
  login,
@@ -19085,7 +19173,13 @@ var Plugin;
19085
19173
 
19086
19174
  window["${resultId}"] = Invoke(window["${argsId}"], window["${contextId}"]);
19087
19175
  }
19088
- invoke();
19176
+ // Called with a receiver, not bare. The API builds index.jsc by
19177
+ // wrapping the plugin's index.js in a controller shell that
19178
+ // assigns 'this.Init = ...', and under "use strict" a bare call
19179
+ // leaves 'this' undefined, so every plugin would die on that
19180
+ // line before its own code ran. A throwaway object satisfies
19181
+ // the shell without giving the plugin the global scope back.
19182
+ invoke.call({});
19089
19183
  `;
19090
19184
  try {
19091
19185
  // 'eval2 = eval' stops the linter from complaining about using eval.
@@ -19165,6 +19259,24 @@ var PluginAiTool;
19165
19259
  * and nothing downstream reports that it happened.
19166
19260
  */
19167
19261
  const STRICT_INCOMPATIBLE_KEYWORDS = ["$ref", "$defs", "allOf", "not"];
19262
+ /** Depth beyond which a schema is refused as unverifiable rather than assumed clean. */
19263
+ const MAX_SCHEMA_DEPTH = 32;
19264
+ /**
19265
+ * Keys whose values are author-named property maps rather than schemas.
19266
+ *
19267
+ * Everything under them is a name the author chose, so a property legitimately
19268
+ * called "not" or "allOf" is not a keyword and must not be matched as one.
19269
+ */
19270
+ const PROPERTY_NAME_HOLDERS = ["properties", "patternProperties", "definitions", "dependentSchemas"];
19271
+ /**
19272
+ * Shortest timeout the host can actually apply.
19273
+ *
19274
+ * It converts the declared value to seconds by integer division, so anything
19275
+ * below this truncates to zero.
19276
+ */
19277
+ const MIN_TIMEOUT_MS = 1000;
19278
+ /** Longest timeout an account may declare. */
19279
+ const MAX_TIMEOUT_MS = 120000;
19168
19280
  /**
19169
19281
  * Side effects an AI Tool may declare.
19170
19282
  *
@@ -19180,9 +19292,14 @@ var PluginAiTool;
19180
19292
  * @returns the offending keyword, or null
19181
19293
  */
19182
19294
  function findStrictModeViolation(node, depth = 0) {
19183
- if (!node || typeof node !== "object" || depth > 32) {
19295
+ if (!node || typeof node !== "object") {
19184
19296
  return null;
19185
19297
  }
19298
+ if (depth > MAX_SCHEMA_DEPTH) {
19299
+ // Returning "clean" here would let a $ref nested past the cap through
19300
+ // as verified, which is the exact thing this walk exists to catch.
19301
+ return `a schema nested deeper than ${MAX_SCHEMA_DEPTH} levels, which cannot be checked`;
19302
+ }
19186
19303
  if (Array.isArray(node)) {
19187
19304
  for (const child of node) {
19188
19305
  const nested = findStrictModeViolation(child, depth + 1);
@@ -19192,11 +19309,28 @@ var PluginAiTool;
19192
19309
  }
19193
19310
  return null;
19194
19311
  }
19312
+ // A keyword only counts at a schema position. Under "properties" and
19313
+ // friends the field names are chosen by the author, so a property
19314
+ // legitimately called "not" or "allOf" is a name, not a keyword.
19195
19315
  for (const key of Object.keys(node)) {
19196
19316
  if (STRICT_INCOMPATIBLE_KEYWORDS.includes(key)) {
19197
19317
  return key;
19198
19318
  }
19199
- const nested = findStrictModeViolation(node[key], depth + 1);
19319
+ }
19320
+ for (const key of Object.keys(node)) {
19321
+ const child = node[key];
19322
+ if (PROPERTY_NAME_HOLDERS.includes(key)) {
19323
+ if (child && typeof child === "object" && !Array.isArray(child)) {
19324
+ for (const name of Object.keys(child)) {
19325
+ const nested = findStrictModeViolation(child[name], depth + 2);
19326
+ if (nested) {
19327
+ return nested;
19328
+ }
19329
+ }
19330
+ }
19331
+ continue;
19332
+ }
19333
+ const nested = findStrictModeViolation(child, depth + 1);
19200
19334
  if (nested) {
19201
19335
  return nested;
19202
19336
  }
@@ -19236,9 +19370,14 @@ var PluginAiTool;
19236
19370
  // tool does. The description is the only thing the agent can select on:
19237
19371
  // without one it is registered but never chosen, and nothing reports that.
19238
19372
  const description = typeof tool.description === "string" ? tool.description.trim() : "";
19239
- if (!description && !((_c = plugin.Name) !== null && _c !== void 0 ? _c : "").trim()) {
19240
- return "An AI Tool needs a description. Set Settings.tool.description, or fill in the plugin's "
19241
- + "Name and Description the agent has nothing else to choose the tool on.";
19373
+ // The fallback is "Name: Description", so a plugin with only a Name yields
19374
+ // a description of a few words. That satisfied the old check while leaving
19375
+ // the agent almost nothing to select on -- and since Save is disabled while
19376
+ // Name is empty, the old check could never fire at all.
19377
+ if (!description && !((_c = plugin.Description) !== null && _c !== void 0 ? _c : "").trim()) {
19378
+ return "An AI Tool needs a description saying what it does and when to use it. Set "
19379
+ + "Settings.tool.description, or fill in the plugin's Description — the tool name is "
19380
+ + "an opaque ID, so this is the only thing the agent can choose it on.";
19242
19381
  }
19243
19382
  if (!isPlainObject(tool.inputSchema)) {
19244
19383
  return "Settings.tool.inputSchema is missing or is not an object.";
@@ -19263,6 +19402,21 @@ var PluginAiTool;
19263
19402
  }
19264
19403
  }
19265
19404
  if (annotations.timeoutMs !== undefined) {
19405
+ if (typeof annotations.timeoutMs === "number"
19406
+ && isFinite(annotations.timeoutMs)
19407
+ && annotations.timeoutMs > 0
19408
+ && annotations.timeoutMs < MIN_TIMEOUT_MS) {
19409
+ // The host converts this to seconds by integer division, so
19410
+ // anything under a second becomes no wait at all -- the opposite
19411
+ // of a short timeout, and the tool then fails on every call.
19412
+ return `timeoutMs is ${annotations.timeoutMs}ms, but the shortest timeout the host can `
19413
+ + `apply is ${MIN_TIMEOUT_MS}ms. A smaller value would be rounded down to no wait at all.`;
19414
+ }
19415
+ if (typeof annotations.timeoutMs === "number"
19416
+ && isFinite(annotations.timeoutMs)
19417
+ && annotations.timeoutMs > MAX_TIMEOUT_MS) {
19418
+ return `timeoutMs is ${annotations.timeoutMs}ms, above the maximum of ${MAX_TIMEOUT_MS}ms.`;
19419
+ }
19266
19420
  if (typeof annotations.timeoutMs !== "number"
19267
19421
  || !isFinite(annotations.timeoutMs)
19268
19422
  || annotations.timeoutMs <= 0) {
@@ -23362,7 +23516,7 @@ var UrlUtils;
23362
23516
  })(UrlUtils || (UrlUtils = {}));
23363
23517
 
23364
23518
  // This is updated with the package.json version on build.
23365
- const VERSION = "7.1.91";
23519
+ const VERSION = "7.1.93";
23366
23520
 
23367
23521
  export { VERSION, Account, AccountAudit, AccountConcept, AccountFeatures, AccountInvite, AccountLimits, AccountTemplate, AccountType, AnnDocument, AbstractApi, Api, ApiGetters, BruceApi, GlobalApi, GuardianApi, Assembly, Calculator, ChangeSet, ClientFile, ClientFileValueMap, Bounds, BruceEvent, BruceVariable, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, GeoJson, Geometry, LRUCache, UTC, CustomForm, DashboardView, DataFeed, DataLab, DataLabGroup, DataSource, DataTransform, Comment, Entity, EntityAttachment, EntityAttachmentType, EntityAttribute, EntityComment, EntityCoords, EntityHistoricData, EntityLink, EntityLod, EntityLodCategory, EntityRelation, EntityRelationType, EntitySource, EntityTableView, EntityTag, EntityType, EntityTypeRelation, EntityTypeTrigger, Ontology, OntologyDocument, ENVIRONMENT, ExportBrz, ExportCsv, ExportNsx, ExportUsd, Hexbin, ImportAssembly, ImportCad, ImportCsv, ImportGeoJson, ImportJson, ImportKml, ImportLcc, ImportTif, ImportedFile, Uploader, Markup, UIMarkup, NAVIGATOR_CHAT_EVENT_ENTITY_HIGHLIGHT_APPLIED, NAVIGATOR_CHAT_EVENT_SCENE_CONTEXT_PREFETCHED, NavigatorChatClient, NavigatorMcpWebSocketClient, Plugin, PluginAiTool, ProgramKey, MenuItem, ProjectView, ProjectViewBookmark, ProjectViewBookmarkGroup, ProjectViewLegacy, ProjectViewLegacyBookmark, ProjectViewLegacyTile, ProjectViewTile, ZoomControl, Scenario, HostingLocation, MessageBroker, PendingAction, RecordChangeFeed, Style, Tileset, Tracking, Permission, Session, User, UserGroup, UserMfaMethod, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils };
23368
23522
  //# sourceMappingURL=bruce-models.es5.js.map