@bike4mind/cli 0.2.20-github-label-crud-operation.18051 → 0.2.20-github-label-crud-operation.18058

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CurationArtifactType
4
- } from "./chunk-2ETI3GBK.js";
4
+ } from "./chunk-DTPBHKQL.js";
5
5
 
6
6
  // ../../b4m-core/packages/services/dist/src/notebookCurationService/artifactExtractor.js
7
7
  var ARTIFACT_TAG_REGEX = /<artifact\s+(.*?)>([\s\S]*?)<\/artifact>/gi;
@@ -7,11 +7,11 @@ import {
7
7
  getSettingsMap,
8
8
  getSettingsValue,
9
9
  secureParameters
10
- } from "./chunk-YVPQAC2Z.js";
10
+ } from "./chunk-DEHCP2AQ.js";
11
11
  import {
12
12
  KnowledgeType,
13
13
  SupportedFabFileMimeTypes
14
- } from "./chunk-2ETI3GBK.js";
14
+ } from "./chunk-DTPBHKQL.js";
15
15
 
16
16
  // ../../b4m-core/packages/services/dist/src/fabFileService/create.js
17
17
  import { z } from "zod";
@@ -13,7 +13,7 @@ import {
13
13
  dayjsConfig_default,
14
14
  extractSnippetMeta,
15
15
  settingsMap
16
- } from "./chunk-2ETI3GBK.js";
16
+ } from "./chunk-DTPBHKQL.js";
17
17
  import {
18
18
  Logger
19
19
  } from "./chunk-OCYRD7D6.js";
@@ -4666,8 +4666,66 @@ function formatPageList(pagesResponse, siteUrl) {
4666
4666
  results
4667
4667
  };
4668
4668
  }
4669
+ function formatPageRestrictions(restrictionsResponse, pageId) {
4670
+ if (!restrictionsResponse || typeof restrictionsResponse !== "object" || restrictionsResponse.error) {
4671
+ return {
4672
+ pageId,
4673
+ hasRestrictions: false,
4674
+ restrictions: []
4675
+ };
4676
+ }
4677
+ const restrictions = [];
4678
+ const operationsMap = {};
4679
+ if (Array.isArray(restrictionsResponse.results)) {
4680
+ for (const item of restrictionsResponse.results) {
4681
+ if (item.operation && item.restrictions) {
4682
+ operationsMap[item.operation] = item;
4683
+ }
4684
+ }
4685
+ } else {
4686
+ for (const operation of RESTRICTION_OPERATIONS) {
4687
+ if (restrictionsResponse[operation]) {
4688
+ operationsMap[operation] = restrictionsResponse[operation];
4689
+ }
4690
+ }
4691
+ }
4692
+ for (const [operation, opData] of Object.entries(operationsMap)) {
4693
+ if (!opData?.restrictions)
4694
+ continue;
4695
+ const subjects = [];
4696
+ const users = opData.restrictions.user?.results || opData.restrictions.user || [];
4697
+ for (const user of users) {
4698
+ subjects.push({
4699
+ type: "user",
4700
+ identifier: user.accountId || user.username || user.key,
4701
+ displayName: user.displayName || user.publicName
4702
+ });
4703
+ }
4704
+ const groups = opData.restrictions.group?.results || opData.restrictions.group || [];
4705
+ for (const group of groups) {
4706
+ subjects.push({
4707
+ type: "group",
4708
+ identifier: group.name || group.id,
4709
+ displayName: group.name
4710
+ });
4711
+ }
4712
+ if (subjects.length > 0) {
4713
+ restrictions.push({
4714
+ operation,
4715
+ subjects
4716
+ });
4717
+ }
4718
+ }
4719
+ return {
4720
+ pageId,
4721
+ hasRestrictions: restrictions.length > 0,
4722
+ restrictions
4723
+ };
4724
+ }
4669
4725
 
4670
4726
  // ../../b4m-core/packages/common/dist/src/confluence/api.js
4727
+ var RESTRICTION_OPERATIONS = ["read", "update"];
4728
+ var RESTRICTION_SUBJECT_TYPES = ["user", "group"];
4671
4729
  var ConfluenceApi = class {
4672
4730
  config;
4673
4731
  constructor(config) {
@@ -4734,11 +4792,15 @@ var ConfluenceApi = class {
4734
4792
  if (response.status === 204) {
4735
4793
  return void 0;
4736
4794
  }
4795
+ const responseText = await response.text();
4796
+ if (!responseText || responseText.trim() === "") {
4797
+ return void 0;
4798
+ }
4737
4799
  const contentType = response.headers.get("content-type") || "";
4738
4800
  if (contentType.includes("application/json")) {
4739
- return await response.json();
4801
+ return JSON.parse(responseText);
4740
4802
  }
4741
- return await response.text();
4803
+ return responseText;
4742
4804
  }
4743
4805
  /**
4744
4806
  * Make v1 API request
@@ -4941,6 +5003,17 @@ var ConfluenceApi = class {
4941
5003
  }
4942
5004
  return formatSpaceResponse(results[0], this.config.siteUrl);
4943
5005
  }
5006
+ /**
5007
+ * Get details about a specific Confluence space by ID (v2 API)
5008
+ */
5009
+ async getSpaceById(params) {
5010
+ const { spaceId } = params;
5011
+ if (!spaceId) {
5012
+ throw new Error("spaceId is required to fetch space details.");
5013
+ }
5014
+ const space = await this.get(`/spaces/${spaceId}`);
5015
+ return formatSpaceResponse(space, this.config.siteUrl);
5016
+ }
4944
5017
  /**
4945
5018
  * Get child pages for a given page
4946
5019
  */
@@ -5176,6 +5249,161 @@ var ConfluenceApi = class {
5176
5249
  throw error;
5177
5250
  }
5178
5251
  }
5252
+ // ============================================================================
5253
+ // Page Restrictions API (v1)
5254
+ // ============================================================================
5255
+ /**
5256
+ * Validate that a user exists by account ID
5257
+ * @throws Error if user does not exist
5258
+ */
5259
+ async validateUserExists(accountId) {
5260
+ try {
5261
+ const user = await this.getV1("/user", { accountId });
5262
+ if (!user || user.error) {
5263
+ throw new Error(`User with account ID "${accountId}" not found.`);
5264
+ }
5265
+ return {
5266
+ accountId: user.accountId,
5267
+ displayName: user.displayName || user.publicName || accountId
5268
+ };
5269
+ } catch (error) {
5270
+ if (error instanceof Error && error.message.includes("not found")) {
5271
+ throw error;
5272
+ }
5273
+ throw new Error(`User with account ID "${accountId}" not found or access denied.`);
5274
+ }
5275
+ }
5276
+ /**
5277
+ * Validate that a group exists by name
5278
+ * @throws Error if group does not exist
5279
+ */
5280
+ async validateGroupExists(groupName) {
5281
+ try {
5282
+ const group = await this.getV1(`/group/${encodeURIComponent(groupName)}`);
5283
+ if (!group || group.error) {
5284
+ throw new Error(`Group "${groupName}" not found.`);
5285
+ }
5286
+ return { name: group.name || groupName };
5287
+ } catch (error) {
5288
+ if (error instanceof Error && error.message.includes("not found")) {
5289
+ throw error;
5290
+ }
5291
+ throw new Error(`Group "${groupName}" not found or access denied.`);
5292
+ }
5293
+ }
5294
+ /**
5295
+ * Get current restrictions for a Confluence page
5296
+ */
5297
+ async getPageRestrictions(params) {
5298
+ const { pageId } = params;
5299
+ if (!pageId) {
5300
+ throw new Error("pageId is required to get page restrictions.");
5301
+ }
5302
+ const result = await this.getV1(`/content/${pageId}/restriction`, {
5303
+ expand: "restrictions.user,restrictions.group"
5304
+ });
5305
+ return formatPageRestrictions(result, pageId);
5306
+ }
5307
+ /**
5308
+ * Add a restriction to a Confluence page
5309
+ * Validates that the user/group exists before applying the restriction.
5310
+ * Automatically includes the current user in restrictions to prevent self-lockout.
5311
+ */
5312
+ async addPageRestriction(params) {
5313
+ const { pageId, operation, restrictionType, subject, skipValidation = false } = params;
5314
+ if (!pageId || !operation || !restrictionType || !subject) {
5315
+ throw new Error("pageId, operation, restrictionType, and subject are required to add a page restriction.");
5316
+ }
5317
+ let subjectDisplayName;
5318
+ if (!skipValidation) {
5319
+ if (restrictionType === "user") {
5320
+ const userInfo = await this.validateUserExists(subject);
5321
+ subjectDisplayName = userInfo.displayName;
5322
+ } else {
5323
+ const groupInfo = await this.validateGroupExists(subject);
5324
+ subjectDisplayName = groupInfo.name;
5325
+ }
5326
+ }
5327
+ const currentUser = await this.getCurrentUser();
5328
+ const currentUserAccountId = currentUser.accountId;
5329
+ if (!currentUserAccountId) {
5330
+ throw new Error("Unable to determine current user account ID. Cannot add restrictions safely.");
5331
+ }
5332
+ const userList = [];
5333
+ userList.push({ accountId: currentUserAccountId });
5334
+ if (restrictionType === "user" && subject !== currentUserAccountId) {
5335
+ userList.push({ accountId: subject });
5336
+ }
5337
+ const restrictionPayload = [
5338
+ {
5339
+ operation,
5340
+ restrictions: {
5341
+ user: userList,
5342
+ ...restrictionType === "group" ? { group: [{ name: subject }] } : {}
5343
+ }
5344
+ }
5345
+ ];
5346
+ await this.postV1(`/content/${pageId}/restriction`, restrictionPayload);
5347
+ return {
5348
+ success: true,
5349
+ pageId,
5350
+ operation,
5351
+ restrictionType,
5352
+ subject,
5353
+ subjectDisplayName
5354
+ };
5355
+ }
5356
+ /**
5357
+ * Remove a restriction from a Confluence page
5358
+ * First checks if the restriction exists to avoid 404 errors
5359
+ */
5360
+ async removePageRestriction(params) {
5361
+ const { pageId, operation, restrictionType, subject } = params;
5362
+ if (!pageId || !operation || !restrictionType || !subject) {
5363
+ throw new Error("pageId, operation, restrictionType, and subject are required to remove a page restriction.");
5364
+ }
5365
+ const currentRestrictions = await this.getPageRestrictions({ pageId });
5366
+ const operationRestriction = currentRestrictions.restrictions.find((r) => r.operation === operation);
5367
+ if (!operationRestriction) {
5368
+ return {
5369
+ success: true,
5370
+ pageId,
5371
+ operation,
5372
+ restrictionType,
5373
+ subject,
5374
+ skipped: true,
5375
+ message: `No ${operation} restrictions exist on this page.`
5376
+ };
5377
+ }
5378
+ const subjectExists = operationRestriction.subjects.some((s) => s.type === restrictionType && s.identifier === subject);
5379
+ if (!subjectExists) {
5380
+ return {
5381
+ success: true,
5382
+ pageId,
5383
+ operation,
5384
+ restrictionType,
5385
+ subject,
5386
+ skipped: true,
5387
+ message: `Restriction for ${restrictionType} "${subject}" on ${operation} operation does not exist.`
5388
+ };
5389
+ }
5390
+ let deletePath;
5391
+ let deleteQuery;
5392
+ if (restrictionType === "user") {
5393
+ deletePath = `/content/${pageId}/restriction/byOperation/${operation}/user`;
5394
+ deleteQuery = { accountId: subject };
5395
+ } else {
5396
+ deletePath = `/content/${pageId}/restriction/byOperation/${operation}/group/${encodeURIComponent(subject)}`;
5397
+ }
5398
+ await this.request("DELETE", deletePath, { query: deleteQuery, useV1: true });
5399
+ return {
5400
+ success: true,
5401
+ pageId,
5402
+ operation,
5403
+ restrictionType,
5404
+ subject
5405
+ };
5406
+ }
5179
5407
  };
5180
5408
 
5181
5409
  // ../../b4m-core/packages/common/dist/src/jira/format.js
@@ -6835,6 +7063,8 @@ export {
6835
7063
  extractSnippetMeta,
6836
7064
  searchSchema,
6837
7065
  LinkedInApi,
7066
+ RESTRICTION_OPERATIONS,
7067
+ RESTRICTION_SUBJECT_TYPES,
6838
7068
  ConfluenceApi,
6839
7069
  formatIssueResponse,
6840
7070
  formatProjectResponse,
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  BadRequestError,
4
4
  secureParameters
5
- } from "./chunk-YVPQAC2Z.js";
5
+ } from "./chunk-DEHCP2AQ.js";
6
6
  import {
7
7
  CompletionApiUsageTransaction,
8
8
  GenericCreditDeductTransaction,
@@ -11,7 +11,7 @@ import {
11
11
  RealtimeVoiceUsageTransaction,
12
12
  TextGenerationUsageTransaction,
13
13
  TransferCreditTransaction
14
- } from "./chunk-2ETI3GBK.js";
14
+ } from "./chunk-DTPBHKQL.js";
15
15
 
16
16
  // ../../b4m-core/packages/services/dist/src/creditService/subtractCredits.js
17
17
  import { z } from "zod";
@@ -6,12 +6,12 @@ import {
6
6
  getSettingsByNames,
7
7
  obfuscateApiKey,
8
8
  secureParameters
9
- } from "./chunk-YVPQAC2Z.js";
9
+ } from "./chunk-DEHCP2AQ.js";
10
10
  import {
11
11
  ApiKeyType,
12
12
  MementoTier,
13
13
  isSupportedEmbeddingModel
14
- } from "./chunk-2ETI3GBK.js";
14
+ } from "./chunk-DTPBHKQL.js";
15
15
 
16
16
  // ../../b4m-core/packages/services/dist/src/apiKeyService/get.js
17
17
  import { z } from "zod";
@@ -2,9 +2,9 @@
2
2
  import {
3
3
  createFabFile,
4
4
  createFabFileSchema
5
- } from "./chunk-KJRFGN2F.js";
6
- import "./chunk-YVPQAC2Z.js";
7
- import "./chunk-2ETI3GBK.js";
5
+ } from "./chunk-A7XLXYFR.js";
6
+ import "./chunk-DEHCP2AQ.js";
7
+ import "./chunk-DTPBHKQL.js";
8
8
  import "./chunk-OCYRD7D6.js";
9
9
  export {
10
10
  createFabFile,
package/dist/index.js CHANGED
@@ -4,12 +4,12 @@ import {
4
4
  getEffectiveApiKey,
5
5
  getOpenWeatherKey,
6
6
  getSerperKey
7
- } from "./chunk-XIHEQATE.js";
7
+ } from "./chunk-J3CEBT64.js";
8
8
  import {
9
9
  ConfigStore
10
10
  } from "./chunk-VFQF2JIT.js";
11
- import "./chunk-CBMYZAO4.js";
12
- import "./chunk-KJRFGN2F.js";
11
+ import "./chunk-HMAM266Q.js";
12
+ import "./chunk-A7XLXYFR.js";
13
13
  import {
14
14
  BFLImageService,
15
15
  BaseStorage,
@@ -21,7 +21,7 @@ import {
21
21
  OpenAIBackend,
22
22
  OpenAIImageService,
23
23
  XAIImageService
24
- } from "./chunk-YVPQAC2Z.js";
24
+ } from "./chunk-DEHCP2AQ.js";
25
25
  import {
26
26
  AiEvents,
27
27
  ApiKeyEvents,
@@ -75,7 +75,7 @@ import {
75
75
  XAI_IMAGE_MODELS,
76
76
  b4mLLMTools,
77
77
  getMcpProviderMetadata
78
- } from "./chunk-2ETI3GBK.js";
78
+ } from "./chunk-DTPBHKQL.js";
79
79
  import {
80
80
  Logger
81
81
  } from "./chunk-OCYRD7D6.js";
@@ -11973,7 +11973,7 @@ import { isAxiosError as isAxiosError2 } from "axios";
11973
11973
  // package.json
11974
11974
  var package_default = {
11975
11975
  name: "@bike4mind/cli",
11976
- version: "0.2.20-github-label-crud-operation.18051+a15de3c31",
11976
+ version: "0.2.20-github-label-crud-operation.18058+c5281d14c",
11977
11977
  type: "module",
11978
11978
  description: "Interactive CLI tool for Bike4Mind with ReAct agents",
11979
11979
  license: "UNLICENSED",
@@ -12080,10 +12080,10 @@ var package_default = {
12080
12080
  },
12081
12081
  devDependencies: {
12082
12082
  "@bike4mind/agents": "0.1.0",
12083
- "@bike4mind/common": "2.44.1-github-label-crud-operation.18051+a15de3c31",
12084
- "@bike4mind/mcp": "1.24.1-github-label-crud-operation.18051+a15de3c31",
12085
- "@bike4mind/services": "2.42.1-github-label-crud-operation.18051+a15de3c31",
12086
- "@bike4mind/utils": "2.2.2-github-label-crud-operation.18051+a15de3c31",
12083
+ "@bike4mind/common": "2.44.1-github-label-crud-operation.18058+c5281d14c",
12084
+ "@bike4mind/mcp": "1.24.1-github-label-crud-operation.18058+c5281d14c",
12085
+ "@bike4mind/services": "2.42.1-github-label-crud-operation.18058+c5281d14c",
12086
+ "@bike4mind/utils": "2.2.2-github-label-crud-operation.18058+c5281d14c",
12087
12087
  "@types/better-sqlite3": "^7.6.13",
12088
12088
  "@types/diff": "^5.0.9",
12089
12089
  "@types/jsonwebtoken": "^9.0.4",
@@ -12100,7 +12100,7 @@ var package_default = {
12100
12100
  optionalDependencies: {
12101
12101
  "@vscode/ripgrep": "^1.17.0"
12102
12102
  },
12103
- gitHead: "a15de3c31aa09b4a09d64f83c96b9a407d0c0eab"
12103
+ gitHead: "c5281d14c7cfdb73f3130f2803f1dcff1f2782b5"
12104
12104
  };
12105
12105
 
12106
12106
  // src/config/constants.ts
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CurationArtifactType
4
- } from "./chunk-2ETI3GBK.js";
4
+ } from "./chunk-DTPBHKQL.js";
5
5
 
6
6
  // ../../b4m-core/packages/services/dist/src/notebookCurationService/llmMarkdownGenerator.js
7
7
  var DEFAULT_OPTIONS = {
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CurationArtifactType
4
- } from "./chunk-2ETI3GBK.js";
4
+ } from "./chunk-DTPBHKQL.js";
5
5
 
6
6
  // ../../b4m-core/packages/services/dist/src/notebookCurationService/markdownGenerator.js
7
7
  var DEFAULT_OPTIONS = {
@@ -2,9 +2,9 @@
2
2
  import {
3
3
  findMostSimilarMemento,
4
4
  getRelevantMementos
5
- } from "./chunk-XIHEQATE.js";
6
- import "./chunk-YVPQAC2Z.js";
7
- import "./chunk-2ETI3GBK.js";
5
+ } from "./chunk-J3CEBT64.js";
6
+ import "./chunk-DEHCP2AQ.js";
7
+ import "./chunk-DTPBHKQL.js";
8
8
  import "./chunk-OCYRD7D6.js";
9
9
  export {
10
10
  findMostSimilarMemento,
@@ -129,8 +129,8 @@ import {
129
129
  validateMermaidSyntax,
130
130
  warmUpSettingsCache,
131
131
  withRetry
132
- } from "./chunk-YVPQAC2Z.js";
133
- import "./chunk-2ETI3GBK.js";
132
+ } from "./chunk-DEHCP2AQ.js";
133
+ import "./chunk-DTPBHKQL.js";
134
134
  import {
135
135
  Logger,
136
136
  NotificationDeduplicator,
@@ -160,6 +160,8 @@ import {
160
160
  QuestResourceSchema,
161
161
  QuestSchema,
162
162
  QuestStatusSchema,
163
+ RESTRICTION_OPERATIONS,
164
+ RESTRICTION_SUBJECT_TYPES,
163
165
  RapidReplyFallbackBehaviors,
164
166
  RapidReplyResponseStylesCommon,
165
167
  RapidReplySettingsSchema,
@@ -306,7 +308,7 @@ import {
306
308
  validateReactArtifactV2,
307
309
  validateSvgArtifactV2,
308
310
  wikiMarkupToAdf
309
- } from "./chunk-2ETI3GBK.js";
311
+ } from "./chunk-DTPBHKQL.js";
310
312
  export {
311
313
  ALL_IMAGE_MODELS,
312
314
  ALL_IMAGE_SIZES,
@@ -468,6 +470,8 @@ export {
468
470
  QuestResourceSchema,
469
471
  QuestSchema,
470
472
  QuestStatusSchema,
473
+ RESTRICTION_OPERATIONS,
474
+ RESTRICTION_SUBJECT_TYPES,
471
475
  RapidReplyFallbackBehaviors,
472
476
  RapidReplyResponseStylesCommon,
473
477
  RapidReplySettingsSchema,
@@ -2,9 +2,9 @@
2
2
  import {
3
3
  SubtractCreditsSchema,
4
4
  subtractCredits
5
- } from "./chunk-CBMYZAO4.js";
6
- import "./chunk-YVPQAC2Z.js";
7
- import "./chunk-2ETI3GBK.js";
5
+ } from "./chunk-HMAM266Q.js";
6
+ import "./chunk-DEHCP2AQ.js";
7
+ import "./chunk-DTPBHKQL.js";
8
8
  import "./chunk-OCYRD7D6.js";
9
9
  export {
10
10
  SubtractCreditsSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bike4mind/cli",
3
- "version": "0.2.20-github-label-crud-operation.18051+a15de3c31",
3
+ "version": "0.2.20-github-label-crud-operation.18058+c5281d14c",
4
4
  "type": "module",
5
5
  "description": "Interactive CLI tool for Bike4Mind with ReAct agents",
6
6
  "license": "UNLICENSED",
@@ -107,10 +107,10 @@
107
107
  },
108
108
  "devDependencies": {
109
109
  "@bike4mind/agents": "0.1.0",
110
- "@bike4mind/common": "2.44.1-github-label-crud-operation.18051+a15de3c31",
111
- "@bike4mind/mcp": "1.24.1-github-label-crud-operation.18051+a15de3c31",
112
- "@bike4mind/services": "2.42.1-github-label-crud-operation.18051+a15de3c31",
113
- "@bike4mind/utils": "2.2.2-github-label-crud-operation.18051+a15de3c31",
110
+ "@bike4mind/common": "2.44.1-github-label-crud-operation.18058+c5281d14c",
111
+ "@bike4mind/mcp": "1.24.1-github-label-crud-operation.18058+c5281d14c",
112
+ "@bike4mind/services": "2.42.1-github-label-crud-operation.18058+c5281d14c",
113
+ "@bike4mind/utils": "2.2.2-github-label-crud-operation.18058+c5281d14c",
114
114
  "@types/better-sqlite3": "^7.6.13",
115
115
  "@types/diff": "^5.0.9",
116
116
  "@types/jsonwebtoken": "^9.0.4",
@@ -127,5 +127,5 @@
127
127
  "optionalDependencies": {
128
128
  "@vscode/ripgrep": "^1.17.0"
129
129
  },
130
- "gitHead": "a15de3c31aa09b4a09d64f83c96b9a407d0c0eab"
130
+ "gitHead": "c5281d14c7cfdb73f3130f2803f1dcff1f2782b5"
131
131
  }