Skip to content
Merged
Prev Previous commit
Next Next commit
Merge branch 'v4' into feature/export-collections
  • Loading branch information
StorytellerCZ committed May 4, 2024
commit be61b3d636e7b30726a9e8dcb6120bde33be5e69
21 changes: 20 additions & 1 deletion History.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,26 @@

## v4.0.0

* Collections are now directly exported from the package [#344](https://github.com/Meteor-Community-Packages/meteor-roles/pull/344) [@storytellercz](https://github.com/sponsors/StorytellerCZ)
* BREAKING: Synchronous functions are now available only on client side
* BREAKING: Migration functions for past versions are no longer available
* UI Helpers now use `console.debug` for debugging messages
* `RolesCollection` and `RoleAssignmentsCollection` can now be exported in addition to being accessed via `Meteor.roles` and `Meteor.roleAssignment`

## v3.6.2

* Fixed TypeScript definition to play nice with Meteor definition [#389](https://github.com/Meteor-Community-Packages/meteor-roles/pull/389) [@bruceborrett](https://github.com/sponsors/bruceborrett)

## v3.6.1

* Added types for async functions [#386](https://github.com/Meteor-Community-Packages/meteor-roles/pull/386) [@storytellercz](https://github.com/sponsors/StorytellerCZ)
* Updated docs with async functions [@storytellercz](https://github.com/sponsors/StorytellerCZ)
* Updated `zodern:types` to v1.0.11

## v3.6.0

* Added async versions of functions [#361](https://github.com/Meteor-Community-Packages/meteor-roles/pull/361) [#378](https://github.com/Meteor-Community-Packages/meteor-roles/pull/378) [@bratelefant](https://github.com/bratelefant) [@storytellercz](https://github.com/sponsors/StorytellerCZ) [@jankapunkt](https://github.com/sponsors/jankapunkt)
* Added missing types [#383](https://github.com/Meteor-Community-Packages/meteor-roles/pull/383) [@storytellercz](https://github.com/sponsors/StorytellerCZ)
* Add complete test suite [#375](https://github.com/Meteor-Community-Packages/meteor-roles/pull/375) [@jankapunkt](https://github.com/sponsors/jankapunkt) [#380](https://github.com/Meteor-Community-Packages/meteor-roles/pull/380) [@bratelefant](https://github.com/bratelefant)

## v3.5.1

Expand Down
9 changes: 5 additions & 4 deletions package.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

Package.describe({
summary: 'Authorization package for Meteor',
version: '4.0.0',
version: '4.0.0-alpha.3',
git: 'https://github.com/Meteor-Community-Packages/meteor-roles.git',
name: 'alanning:roles'
})

Package.onUse(function (api) {
api.versionsFrom(['2.8.0'])
api.versionsFrom(['2.8.1', '3.0-rc.0'])

const both = ['client', 'server']

Expand All @@ -27,8 +27,9 @@ Package.onUse(function (api) {

api.export(['Roles', 'RolesCollection', 'RoleAssignmentCollection'])

api.addFiles('roles/roles_common.js', both)
api.mainModule('roles/roles_server.js', 'server')
api.addFiles('roles/roles_client.js', 'client')
api.addFiles('roles/roles_common_async.js', both)
api.addFiles('roles/roles_server.js', 'server')
api.addFiles([
'roles/client/debug.js',
'roles/client/uiHelpers.js',
Expand Down
12 changes: 0 additions & 12 deletions roles/roles_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,6 @@ import { Meteor } from 'meteor/meteor'
* @module Roles
*/

export const RolesCollection = new Mongo.Collection('roles')

if (!Meteor.roles) {
Meteor.roles = RolesCollection
}

export const RoleAssignmentCollection = new Mongo.Collection('role-assignment')

if (!Meteor.roleAssignment) {
Meteor.roleAssignment = RoleAssignmentCollection
}

/**
* @class Roles
*/
Expand Down
11 changes: 7 additions & 4 deletions roles/roles_server.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
/* global Meteor, Roles */
import { RolesCollection, RoleAssignmentCollection } from './roles_common'
import { Meteor } from 'meteor/meteor'

const indexFnAssignment = Meteor.roleAssignment.createIndexAsync.bind(Meteor.roleAssignment)
const indexFnRoles = Meteor.roles.createIndexAsync.bind(Meteor.roles)

const indexes = [
{ 'user._id': 1, 'inheritedRoles._id': 1, scope: 1 },
{ 'user._id': 1, 'role._id': 1, scope: 1 },
{ 'role._id': 1 },
{ scope: 1, 'user._id': 1, 'inheritedRoles._id': 1 }, // Adding userId and roleId might speed up other queries depending on the first index
{ 'inheritedRoles._id': 1 }
].forEach(index => RoleAssignmentCollection.createIndexAsync(index))
RolesCollection.createIndexAsync({ 'children._id': 1 })
]
indexes.forEach(index => indexFnAssignment(index))
indexFnRoles({ 'children._id': 1 })

/*
* Publish logged-in user's roles so client-side checks can work.
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.