<commit_before>(function () {
  "use strict";

  angular
    .module("mnPermissions", [])
    .provider("mnPermissions", mnPermissionsProvider);

  function mnPermissionsProvider() {

    this.$get = ["$http", "$timeout", "$q", "$rootScope", "mnBucketsService", "$parse", mnPermissionsFacatory];
    this.set = set;
    this.setBucketSpecific = setBucketSpecific;

    var bucketSpecificPermissions = [function (name) {
      return [
        "cluster.bucket[" + name + "].settings!write",
        "cluster.bucket[" + name + "].data!write",
        "cluster.bucket[" + name + "].recovery!write",
        "cluster.bucket[" + name + "].settings!read",
        "cluster.bucket[" + name + "].data!read",
        "cluster.bucket[" + name + "].data.docs!read",
        "cluster.bucket[" + name + "].recovery!read",
        "cluster.bucket[" + name + "].views!read",
        "cluster.bucket[" + name + "].views!write",
        "cluster.bucket[" + name + "].stats!read",
        "cluster.bucket[" + name + "]!flush",
        "cluster.bucket[" + name + "]!delete",
        "cluster.bucket[" + name + "]!compact",
        "cluster.bucket[" + name + "].views!compact",
        "cluster.bucket[" + name + "].xdcr!read",
        "cluster.bucket[" + name + "].xdcr!write",
        "cluster.bucket[" + name + "].xdcr!execute"
      ];
    }];

    var interestingPermissions = [
      "cluster.buckets!create",
      "cluster.nodes!write",
      "cluster.pools!read",
      "cluster.server_groups!read",
      "cluster.server_groups!write",
      "cluster.settings!read",
      "cluster.settings!write",
      "cluster.stats!read",
      "cluster.tasks!read",
      "cluster.indexes!read",
      "cluster.admin.internal!all",
      "cluster.xdcr.settings!read",
      "cluster.xdcr.settings!write",
      "cluster.xdcr.remote_clusters!read",
      "cluster.xdcr.remote_clusters!write",
      "cluster.admin.security!read",
      "cluster.admin.logs!read",
      "cluster.admin.settings!read",
      "cluster.admin.settings!write",
      "cluster.logs!read",
      "cluster.pools!write",
      "cluster.indexes!write",
      "cluster.admin.security!write",
      "cluster.samples!read",
      "cluster.nodes!read"
    ];

    function getAll() {
      return _.clone(interestingPermissions);
    }

    function set(permission) {
      if (!_.contains(interestingPermissions, permission)) {
        interestingPermissions.push(permission);
      }
      return this;
    }

    function setBucketSpecific(func) {
      if (angular.isFunction(func)) {
        bucketSpecificPermissions.push(func);
      }
      return this;
    }

    function generateBucketPermissions(bucketName) {
      return bucketSpecificPermissions.reduce(function (acc, getChunk) {
        return acc.concat(getChunk(bucketName));
      }, []);
    }

    function mnPermissionsFacatory($http, $timeout, $q, $rootScope, mnBucketsService, $parse) {
      var mnPermissions = {
        clear: clear,
        set: set,
        setBucketSpecific: setBucketSpecific,
        get: doCheck,
        check: check,
        getFresh: getFresh,
        export: {
          data: {},
          cluster: {},
          default: {
            all: undefined,
            membase: undefined
          }
        }
      };

      var cached;

      interestingPermissions.push(generateBucketPermissions("."));

      return mnPermissions;

      function clear() {
        delete $rootScope.rbac;<commit_msg>MB-24288: set/setBucketSpecific can be used only during configuration stage<commit_after>(function () {
  "use strict";

  angular
    .module("mnPermissions", [])
    .provider("mnPermissions", mnPermissionsProvider);

  function mnPermissionsProvider() {

    this.$get = ["$http", "$timeout", "$q", "$rootScope", "mnBucketsService", "$parse", mnPermissionsFacatory];
    this.set = set;
    this.setBucketSpecific = setBucketSpecific;

    var bucketSpecificPermissions = [function (name) {
      return [
        "cluster.bucket[" + name + "].settings!write",
        "cluster.bucket[" + name + "].data!write",
        "cluster.bucket[" + name + "].recovery!write",
        "cluster.bucket[" + name + "].settings!read",
        "cluster.bucket[" + name + "].data!read",
        "cluster.bucket[" + name + "].data.docs!read",
        "cluster.bucket[" + name + "].recovery!read",
        "cluster.bucket[" + name + "].views!read",
        "cluster.bucket[" + name + "].views!write",
        "cluster.bucket[" + name + "].stats!read",
        "cluster.bucket[" + name + "]!flush",
        "cluster.bucket[" + name + "]!delete",
        "cluster.bucket[" + name + "]!compact",
        "cluster.bucket[" + name + "].views!compact",
        "cluster.bucket[" + name + "].xdcr!read",
        "cluster.bucket[" + name + "].xdcr!write",
        "cluster.bucket[" + name + "].xdcr!execute"
      ];
    }];

    var interestingPermissions = [
      "cluster.buckets!create",
      "cluster.nodes!write",
      "cluster.pools!read",
      "cluster.server_groups!read",
      "cluster.server_groups!write",
      "cluster.settings!read",
      "cluster.settings!write",
      "cluster.stats!read",
      "cluster.tasks!read",
      "cluster.indexes!read",
      "cluster.admin.internal!all",
      "cluster.xdcr.settings!read",
      "cluster.xdcr.settings!write",
      "cluster.xdcr.remote_clusters!read",
      "cluster.xdcr.remote_clusters!write",
      "cluster.admin.security!read",
      "cluster.admin.logs!read",
      "cluster.admin.settings!read",
      "cluster.admin.settings!write",
      "cluster.logs!read",
      "cluster.pools!write",
      "cluster.indexes!write",
      "cluster.admin.security!write",
      "cluster.samples!read",
      "cluster.nodes!read"
    ];

    function getAll() {
      return _.clone(interestingPermissions);
    }

    function set(permission) {
      if (!_.contains(interestingPermissions, permission)) {
        interestingPermissions.push(permission);
      }
      return this;
    }

    function setBucketSpecific(func) {
      if (angular.isFunction(func)) {
        bucketSpecificPermissions.push(func);
      }
      return this;
    }

    function generateBucketPermissions(bucketName) {
      return bucketSpecificPermissions.reduce(function (acc, getChunk) {
        return acc.concat(getChunk(bucketName));
      }, []);
    }

    function mnPermissionsFacatory($http, $timeout, $q, $rootScope, mnBucketsService, $parse) {
      var mnPermissions = {
        clear: clear,
        get: doCheck,
        check: check,
        getFresh: getFresh,
        export: {
          data: {},
          cluster: {},
          default: {
            all: undefined,
            membase: undefined
          }
        }
      };

      var cached;

      interestingPermissions.push(generateBucketPermissions("."));

      return mnPermissions;

      function clear() {
        delete $rootScope.rbac;
{'fraction_non_alphanumeric': 0.15642215134821688, 'fraction_numerical': 0.0007248477819657872, 'mean_word_length': 2.59135866736075, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6263708', 'n_tokens_mistral': 2059, 'n_tokens_neox': 2029, 'n_words': 341}