scopes typing rename, filter -> info (#2842)
Renames a lot of the names in scopes that contain the word "filter" with the word "info". The basis here is to reduce confusion in the libraries. Filter as a term is overloaded. It currently means: 1/ the set of scopes that comparisons _must_ pass to succeed; 2/ the pkg and struct that handles comparison logic; and 3/ the set of scopes that compare values in details.ItemInfo instead of in the item's storage or logical path. The third category is the primary overload here, and is better off with a different name. --- #### Does this PR need a docs update or release note? - [x] ⛔ No #### Type of change - [x] 🧹 Tech Debt/Cleanup #### Test Plan - [x] ⚡ Unit test
This commit is contained in:
parent
7b26a7213a
commit
bdc854c1da
@ -79,9 +79,9 @@ func AddExchangeInclude(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddExchangeFilter adds the scope of the provided values to the selector's
|
// AddExchangeInfo adds the scope of the provided values to the selector's
|
||||||
// filter set
|
// filter set
|
||||||
func AddExchangeFilter(
|
func AddExchangeInfo(
|
||||||
sel *selectors.ExchangeRestore,
|
sel *selectors.ExchangeRestore,
|
||||||
v string,
|
v string,
|
||||||
f func(string) []selectors.ExchangeScope,
|
f func(string) []selectors.ExchangeScope,
|
||||||
@ -156,14 +156,14 @@ func FilterExchangeRestoreInfoSelectors(
|
|||||||
sel *selectors.ExchangeRestore,
|
sel *selectors.ExchangeRestore,
|
||||||
opts ExchangeOpts,
|
opts ExchangeOpts,
|
||||||
) {
|
) {
|
||||||
AddExchangeFilter(sel, opts.ContactName, sel.ContactName)
|
AddExchangeInfo(sel, opts.ContactName, sel.ContactName)
|
||||||
AddExchangeFilter(sel, opts.EmailReceivedAfter, sel.MailReceivedAfter)
|
AddExchangeInfo(sel, opts.EmailReceivedAfter, sel.MailReceivedAfter)
|
||||||
AddExchangeFilter(sel, opts.EmailReceivedBefore, sel.MailReceivedBefore)
|
AddExchangeInfo(sel, opts.EmailReceivedBefore, sel.MailReceivedBefore)
|
||||||
AddExchangeFilter(sel, opts.EmailSender, sel.MailSender)
|
AddExchangeInfo(sel, opts.EmailSender, sel.MailSender)
|
||||||
AddExchangeFilter(sel, opts.EmailSubject, sel.MailSubject)
|
AddExchangeInfo(sel, opts.EmailSubject, sel.MailSubject)
|
||||||
AddExchangeFilter(sel, opts.EventOrganizer, sel.EventOrganizer)
|
AddExchangeInfo(sel, opts.EventOrganizer, sel.EventOrganizer)
|
||||||
AddExchangeFilter(sel, opts.EventRecurs, sel.EventRecurs)
|
AddExchangeInfo(sel, opts.EventRecurs, sel.EventRecurs)
|
||||||
AddExchangeFilter(sel, opts.EventStartsAfter, sel.EventStartsAfter)
|
AddExchangeInfo(sel, opts.EventStartsAfter, sel.EventStartsAfter)
|
||||||
AddExchangeFilter(sel, opts.EventStartsBefore, sel.EventStartsBefore)
|
AddExchangeInfo(sel, opts.EventStartsBefore, sel.EventStartsBefore)
|
||||||
AddExchangeFilter(sel, opts.EventSubject, sel.EventSubject)
|
AddExchangeInfo(sel, opts.EventSubject, sel.EventSubject)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,9 +58,9 @@ func ValidateSharePointRestoreFlags(backupID string, opts SharePointOpts) error
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddSharePointFilter adds the scope of the provided values to the selector's
|
// AddSharePointInfo adds the scope of the provided values to the selector's
|
||||||
// filter set
|
// filter set
|
||||||
func AddSharePointFilter(
|
func AddSharePointInfo(
|
||||||
sel *selectors.SharePointRestore,
|
sel *selectors.SharePointRestore,
|
||||||
v string,
|
v string,
|
||||||
f func(string) []selectors.SharePointScope,
|
f func(string) []selectors.SharePointScope,
|
||||||
@ -165,9 +165,9 @@ func FilterSharePointRestoreInfoSelectors(
|
|||||||
sel *selectors.SharePointRestore,
|
sel *selectors.SharePointRestore,
|
||||||
opts SharePointOpts,
|
opts SharePointOpts,
|
||||||
) {
|
) {
|
||||||
AddSharePointFilter(sel, opts.Library, sel.Library)
|
AddSharePointInfo(sel, opts.Library, sel.Library)
|
||||||
AddSharePointFilter(sel, opts.FileCreatedAfter, sel.CreatedAfter)
|
AddSharePointInfo(sel, opts.FileCreatedAfter, sel.CreatedAfter)
|
||||||
AddSharePointFilter(sel, opts.FileCreatedBefore, sel.CreatedBefore)
|
AddSharePointInfo(sel, opts.FileCreatedBefore, sel.CreatedBefore)
|
||||||
AddSharePointFilter(sel, opts.FileModifiedAfter, sel.ModifiedAfter)
|
AddSharePointInfo(sel, opts.FileModifiedAfter, sel.ModifiedAfter)
|
||||||
AddSharePointFilter(sel, opts.FileModifiedBefore, sel.ModifiedBefore)
|
AddSharePointInfo(sel, opts.FileModifiedBefore, sel.ModifiedBefore)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -323,149 +323,149 @@ func (s *exchange) AllData() []ExchangeScope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// -------------------
|
// -------------------
|
||||||
// Filter Factories
|
// Info Factories
|
||||||
|
|
||||||
// ContactName produces one or more exchange contact name filter scopes.
|
// ContactName produces one or more exchange contact name info scopes.
|
||||||
// Matches any contact whose name contains the provided string.
|
// Matches any contact whose name contains the provided string.
|
||||||
// If any slice contains selectors.Any, that slice is reduced to [selectors.Any]
|
// If any slice contains selectors.Any, that slice is reduced to [selectors.Any]
|
||||||
// If any slice contains selectors.None, that slice is reduced to [selectors.None]
|
// If any slice contains selectors.None, that slice is reduced to [selectors.None]
|
||||||
// If any slice is empty, it defaults to [selectors.None]
|
// If any slice is empty, it defaults to [selectors.None]
|
||||||
func (sr *ExchangeRestore) ContactName(senderID string) []ExchangeScope {
|
func (sr *ExchangeRestore) ContactName(senderID string) []ExchangeScope {
|
||||||
return []ExchangeScope{
|
return []ExchangeScope{
|
||||||
makeFilterScope[ExchangeScope](
|
makeInfoScope[ExchangeScope](
|
||||||
ExchangeContact,
|
ExchangeContact,
|
||||||
ExchangeFilterContactName,
|
ExchangeInfoContactName,
|
||||||
[]string{senderID},
|
[]string{senderID},
|
||||||
wrapSliceFilter(filters.In)),
|
wrapSliceFilter(filters.In)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// EventSubject produces one or more exchange event subject filter scopes.
|
// EventSubject produces one or more exchange event subject info scopes.
|
||||||
// Matches any event where the event subject contains one of the provided strings.
|
// Matches any event where the event subject contains one of the provided strings.
|
||||||
// If any slice contains selectors.Any, that slice is reduced to [selectors.Any]
|
// If any slice contains selectors.Any, that slice is reduced to [selectors.Any]
|
||||||
// If any slice contains selectors.None, that slice is reduced to [selectors.None]
|
// If any slice contains selectors.None, that slice is reduced to [selectors.None]
|
||||||
// If any slice is empty, it defaults to [selectors.None]
|
// If any slice is empty, it defaults to [selectors.None]
|
||||||
func (sr *ExchangeRestore) EventOrganizer(organizer string) []ExchangeScope {
|
func (sr *ExchangeRestore) EventOrganizer(organizer string) []ExchangeScope {
|
||||||
return []ExchangeScope{
|
return []ExchangeScope{
|
||||||
makeFilterScope[ExchangeScope](
|
makeInfoScope[ExchangeScope](
|
||||||
ExchangeEvent,
|
ExchangeEvent,
|
||||||
ExchangeFilterEventOrganizer,
|
ExchangeInfoEventOrganizer,
|
||||||
[]string{organizer},
|
[]string{organizer},
|
||||||
wrapSliceFilter(filters.In)),
|
wrapSliceFilter(filters.In)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// EventRecurs produces one or more exchange event recurrence filter scopes.
|
// EventRecurs produces one or more exchange event recurrence info scopes.
|
||||||
// Matches any event if the comparator flag matches the event recurrence flag.
|
// Matches any event if the comparator flag matches the event recurrence flag.
|
||||||
// If any slice contains selectors.Any, that slice is reduced to [selectors.Any]
|
// If any slice contains selectors.Any, that slice is reduced to [selectors.Any]
|
||||||
// If any slice contains selectors.None, that slice is reduced to [selectors.None]
|
// If any slice contains selectors.None, that slice is reduced to [selectors.None]
|
||||||
// If any slice is empty, it defaults to [selectors.None]
|
// If any slice is empty, it defaults to [selectors.None]
|
||||||
func (sr *ExchangeRestore) EventRecurs(recurs string) []ExchangeScope {
|
func (sr *ExchangeRestore) EventRecurs(recurs string) []ExchangeScope {
|
||||||
return []ExchangeScope{
|
return []ExchangeScope{
|
||||||
makeFilterScope[ExchangeScope](
|
makeInfoScope[ExchangeScope](
|
||||||
ExchangeEvent,
|
ExchangeEvent,
|
||||||
ExchangeFilterEventRecurs,
|
ExchangeInfoEventRecurs,
|
||||||
[]string{recurs},
|
[]string{recurs},
|
||||||
wrapFilter(filters.Equal)),
|
wrapFilter(filters.Equal)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// EventStartsAfter produces an exchange event starts-after filter scope.
|
// EventStartsAfter produces an exchange event starts-after info scope.
|
||||||
// Matches any event where the start time is after the timestring.
|
// Matches any event where the start time is after the timestring.
|
||||||
// If the input equals selectors.Any, the scope will match all times.
|
// If the input equals selectors.Any, the scope will match all times.
|
||||||
// If the input is empty or selectors.None, the scope will always fail comparisons.
|
// If the input is empty or selectors.None, the scope will always fail comparisons.
|
||||||
func (sr *ExchangeRestore) EventStartsAfter(timeStrings string) []ExchangeScope {
|
func (sr *ExchangeRestore) EventStartsAfter(timeStrings string) []ExchangeScope {
|
||||||
return []ExchangeScope{
|
return []ExchangeScope{
|
||||||
makeFilterScope[ExchangeScope](
|
makeInfoScope[ExchangeScope](
|
||||||
ExchangeEvent,
|
ExchangeEvent,
|
||||||
ExchangeFilterEventStartsAfter,
|
ExchangeInfoEventStartsAfter,
|
||||||
[]string{timeStrings},
|
[]string{timeStrings},
|
||||||
wrapFilter(filters.Less)),
|
wrapFilter(filters.Less)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// EventStartsBefore produces an exchange event starts-before filter scope.
|
// EventStartsBefore produces an exchange event starts-before info scope.
|
||||||
// Matches any event where the start time is before the timestring.
|
// Matches any event where the start time is before the timestring.
|
||||||
// If the input equals selectors.Any, the scope will match all times.
|
// If the input equals selectors.Any, the scope will match all times.
|
||||||
// If the input is empty or selectors.None, the scope will always fail comparisons.
|
// If the input is empty or selectors.None, the scope will always fail comparisons.
|
||||||
func (sr *ExchangeRestore) EventStartsBefore(timeStrings string) []ExchangeScope {
|
func (sr *ExchangeRestore) EventStartsBefore(timeStrings string) []ExchangeScope {
|
||||||
return []ExchangeScope{
|
return []ExchangeScope{
|
||||||
makeFilterScope[ExchangeScope](
|
makeInfoScope[ExchangeScope](
|
||||||
ExchangeEvent,
|
ExchangeEvent,
|
||||||
ExchangeFilterEventStartsBefore,
|
ExchangeInfoEventStartsBefore,
|
||||||
[]string{timeStrings},
|
[]string{timeStrings},
|
||||||
wrapFilter(filters.Greater)),
|
wrapFilter(filters.Greater)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// EventSubject produces one or more exchange event subject filter scopes.
|
// EventSubject produces one or more exchange event subject info scopes.
|
||||||
// Matches any event where the event subject contains one of the provided strings.
|
// Matches any event where the event subject contains one of the provided strings.
|
||||||
// If any slice contains selectors.Any, that slice is reduced to [selectors.Any]
|
// If any slice contains selectors.Any, that slice is reduced to [selectors.Any]
|
||||||
// If any slice contains selectors.None, that slice is reduced to [selectors.None]
|
// If any slice contains selectors.None, that slice is reduced to [selectors.None]
|
||||||
// If any slice is empty, it defaults to [selectors.None]
|
// If any slice is empty, it defaults to [selectors.None]
|
||||||
func (sr *ExchangeRestore) EventSubject(subject string) []ExchangeScope {
|
func (sr *ExchangeRestore) EventSubject(subject string) []ExchangeScope {
|
||||||
return []ExchangeScope{
|
return []ExchangeScope{
|
||||||
makeFilterScope[ExchangeScope](
|
makeInfoScope[ExchangeScope](
|
||||||
ExchangeEvent,
|
ExchangeEvent,
|
||||||
ExchangeFilterEventSubject,
|
ExchangeInfoEventSubject,
|
||||||
[]string{subject},
|
[]string{subject},
|
||||||
wrapSliceFilter(filters.In)),
|
wrapSliceFilter(filters.In)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MailReceivedAfter produces an exchange mail received-after filter scope.
|
// MailReceivedAfter produces an exchange mail received-after info scope.
|
||||||
// Matches any mail which was received after the timestring.
|
// Matches any mail which was received after the timestring.
|
||||||
// If the input equals selectors.Any, the scope will match all times.
|
// If the input equals selectors.Any, the scope will match all times.
|
||||||
// If the input is empty or selectors.None, the scope will always fail comparisons.
|
// If the input is empty or selectors.None, the scope will always fail comparisons.
|
||||||
func (sr *ExchangeRestore) MailReceivedAfter(timeStrings string) []ExchangeScope {
|
func (sr *ExchangeRestore) MailReceivedAfter(timeStrings string) []ExchangeScope {
|
||||||
return []ExchangeScope{
|
return []ExchangeScope{
|
||||||
makeFilterScope[ExchangeScope](
|
makeInfoScope[ExchangeScope](
|
||||||
ExchangeMail,
|
ExchangeMail,
|
||||||
ExchangeFilterMailReceivedAfter,
|
ExchangeInfoMailReceivedAfter,
|
||||||
[]string{timeStrings},
|
[]string{timeStrings},
|
||||||
wrapFilter(filters.Less)),
|
wrapFilter(filters.Less)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MailReceivedBefore produces an exchange mail received-before filter scope.
|
// MailReceivedBefore produces an exchange mail received-before info scope.
|
||||||
// Matches any mail which was received before the timestring.
|
// Matches any mail which was received before the timestring.
|
||||||
// If the input equals selectors.Any, the scope will match all times.
|
// If the input equals selectors.Any, the scope will match all times.
|
||||||
// If the input is empty or selectors.None, the scope will always fail comparisons.
|
// If the input is empty or selectors.None, the scope will always fail comparisons.
|
||||||
func (sr *ExchangeRestore) MailReceivedBefore(timeStrings string) []ExchangeScope {
|
func (sr *ExchangeRestore) MailReceivedBefore(timeStrings string) []ExchangeScope {
|
||||||
return []ExchangeScope{
|
return []ExchangeScope{
|
||||||
makeFilterScope[ExchangeScope](
|
makeInfoScope[ExchangeScope](
|
||||||
ExchangeMail,
|
ExchangeMail,
|
||||||
ExchangeFilterMailReceivedBefore,
|
ExchangeInfoMailReceivedBefore,
|
||||||
[]string{timeStrings},
|
[]string{timeStrings},
|
||||||
wrapFilter(filters.Greater)),
|
wrapFilter(filters.Greater)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MailSender produces one or more exchange mail sender filter scopes.
|
// MailSender produces one or more exchange mail sender info scopes.
|
||||||
// Matches any mail whose sender contains one of the provided strings.
|
// Matches any mail whose sender contains one of the provided strings.
|
||||||
// If any slice contains selectors.Any, that slice is reduced to [selectors.Any]
|
// If any slice contains selectors.Any, that slice is reduced to [selectors.Any]
|
||||||
// If any slice contains selectors.None, that slice is reduced to [selectors.None]
|
// If any slice contains selectors.None, that slice is reduced to [selectors.None]
|
||||||
// If any slice is empty, it defaults to [selectors.None]
|
// If any slice is empty, it defaults to [selectors.None]
|
||||||
func (sr *ExchangeRestore) MailSender(sender string) []ExchangeScope {
|
func (sr *ExchangeRestore) MailSender(sender string) []ExchangeScope {
|
||||||
return []ExchangeScope{
|
return []ExchangeScope{
|
||||||
makeFilterScope[ExchangeScope](
|
makeInfoScope[ExchangeScope](
|
||||||
ExchangeMail,
|
ExchangeMail,
|
||||||
ExchangeFilterMailSender,
|
ExchangeInfoMailSender,
|
||||||
[]string{sender},
|
[]string{sender},
|
||||||
wrapSliceFilter(filters.In)),
|
wrapSliceFilter(filters.In)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MailSubject produces one or more exchange mail subject line filter scopes.
|
// MailSubject produces one or more exchange mail subject line info scopes.
|
||||||
// Matches any mail whose subject contains one of the provided strings.
|
// Matches any mail whose subject contains one of the provided strings.
|
||||||
// If any slice contains selectors.Any, that slice is reduced to [selectors.Any]
|
// If any slice contains selectors.Any, that slice is reduced to [selectors.Any]
|
||||||
// If any slice contains selectors.None, that slice is reduced to [selectors.None]
|
// If any slice contains selectors.None, that slice is reduced to [selectors.None]
|
||||||
// If any slice is empty, it defaults to [selectors.None]
|
// If any slice is empty, it defaults to [selectors.None]
|
||||||
func (sr *ExchangeRestore) MailSubject(subject string) []ExchangeScope {
|
func (sr *ExchangeRestore) MailSubject(subject string) []ExchangeScope {
|
||||||
return []ExchangeScope{
|
return []ExchangeScope{
|
||||||
makeFilterScope[ExchangeScope](
|
makeInfoScope[ExchangeScope](
|
||||||
ExchangeMail,
|
ExchangeMail,
|
||||||
ExchangeFilterMailSubject,
|
ExchangeInfoMailSubject,
|
||||||
[]string{subject},
|
[]string{subject},
|
||||||
wrapSliceFilter(filters.In)),
|
wrapSliceFilter(filters.In)),
|
||||||
}
|
}
|
||||||
@ -484,6 +484,7 @@ var _ categorizer = ExchangeCategoryUnknown
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
ExchangeCategoryUnknown exchangeCategory = ""
|
ExchangeCategoryUnknown exchangeCategory = ""
|
||||||
|
|
||||||
// types of data identified by exchange
|
// types of data identified by exchange
|
||||||
ExchangeContact exchangeCategory = "ExchangeContact"
|
ExchangeContact exchangeCategory = "ExchangeContact"
|
||||||
ExchangeContactFolder exchangeCategory = "ExchangeContactFolder"
|
ExchangeContactFolder exchangeCategory = "ExchangeContactFolder"
|
||||||
@ -492,20 +493,18 @@ const (
|
|||||||
ExchangeMail exchangeCategory = "ExchangeMail"
|
ExchangeMail exchangeCategory = "ExchangeMail"
|
||||||
ExchangeMailFolder exchangeCategory = "ExchangeMailFolder"
|
ExchangeMailFolder exchangeCategory = "ExchangeMailFolder"
|
||||||
ExchangeUser exchangeCategory = "ExchangeUser"
|
ExchangeUser exchangeCategory = "ExchangeUser"
|
||||||
// append new data cats here
|
|
||||||
|
|
||||||
// filterable topics identified by exchange
|
// data contained within details.ItemInfo
|
||||||
ExchangeFilterMailSender exchangeCategory = "ExchangeFilterMailSender"
|
ExchangeInfoMailSender exchangeCategory = "ExchangeInfoMailSender"
|
||||||
ExchangeFilterMailSubject exchangeCategory = "ExchangeFilterMailSubject"
|
ExchangeInfoMailSubject exchangeCategory = "ExchangeInfoMailSubject"
|
||||||
ExchangeFilterMailReceivedAfter exchangeCategory = "ExchangeFilterMailReceivedAfter"
|
ExchangeInfoMailReceivedAfter exchangeCategory = "ExchangeInfoMailReceivedAfter"
|
||||||
ExchangeFilterMailReceivedBefore exchangeCategory = "ExchangeFilterMailReceivedBefore"
|
ExchangeInfoMailReceivedBefore exchangeCategory = "ExchangeInfoMailReceivedBefore"
|
||||||
ExchangeFilterContactName exchangeCategory = "ExchangeFilterContactName"
|
ExchangeInfoContactName exchangeCategory = "ExchangeInfoContactName"
|
||||||
ExchangeFilterEventOrganizer exchangeCategory = "ExchangeFilterEventOrganizer"
|
ExchangeInfoEventOrganizer exchangeCategory = "ExchangeInfoEventOrganizer"
|
||||||
ExchangeFilterEventRecurs exchangeCategory = "ExchangeFilterEventRecurs"
|
ExchangeInfoEventRecurs exchangeCategory = "ExchangeInfoEventRecurs"
|
||||||
ExchangeFilterEventStartsAfter exchangeCategory = "ExchangeFilterEventStartsAfter"
|
ExchangeInfoEventStartsAfter exchangeCategory = "ExchangeInfoEventStartsAfter"
|
||||||
ExchangeFilterEventStartsBefore exchangeCategory = "ExchangeFilterEventStartsBefore"
|
ExchangeInfoEventStartsBefore exchangeCategory = "ExchangeInfoEventStartsBefore"
|
||||||
ExchangeFilterEventSubject exchangeCategory = "ExchangeFilterEventSubject"
|
ExchangeInfoEventSubject exchangeCategory = "ExchangeInfoEventSubject"
|
||||||
// append new filter cats here
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// exchangeLeafProperties describes common metadata of the leaf categories
|
// exchangeLeafProperties describes common metadata of the leaf categories
|
||||||
@ -535,22 +534,22 @@ func (ec exchangeCategory) String() string {
|
|||||||
// leafCat returns the leaf category of the receiver.
|
// leafCat returns the leaf category of the receiver.
|
||||||
// If the receiver category has multiple leaves (ex: User) or no leaves,
|
// If the receiver category has multiple leaves (ex: User) or no leaves,
|
||||||
// (ex: Unknown), the receiver itself is returned.
|
// (ex: Unknown), the receiver itself is returned.
|
||||||
// If the receiver category is a filter type (ex: ExchangeFilterMailSubject),
|
// If the receiver category is an info type (ex: ExchangeInfoMailSubject),
|
||||||
// returns the category covered by the filter.
|
// returns the category covered by the info.
|
||||||
// Ex: ExchangeContactFolder.leafCat() => ExchangeContact
|
// Ex: ExchangeContactFolder.leafCat() => ExchangeContact
|
||||||
// Ex: ExchangeEvent.leafCat() => ExchangeEvent
|
// Ex: ExchangeEvent.leafCat() => ExchangeEvent
|
||||||
// Ex: ExchangeUser.leafCat() => ExchangeUser
|
// Ex: ExchangeUser.leafCat() => ExchangeUser
|
||||||
func (ec exchangeCategory) leafCat() categorizer {
|
func (ec exchangeCategory) leafCat() categorizer {
|
||||||
switch ec {
|
switch ec {
|
||||||
case ExchangeContact, ExchangeContactFolder, ExchangeFilterContactName:
|
case ExchangeContact, ExchangeContactFolder, ExchangeInfoContactName:
|
||||||
return ExchangeContact
|
return ExchangeContact
|
||||||
|
|
||||||
case ExchangeEvent, ExchangeEventCalendar, ExchangeFilterEventOrganizer, ExchangeFilterEventRecurs,
|
case ExchangeEvent, ExchangeEventCalendar, ExchangeInfoEventOrganizer, ExchangeInfoEventRecurs,
|
||||||
ExchangeFilterEventStartsAfter, ExchangeFilterEventStartsBefore, ExchangeFilterEventSubject:
|
ExchangeInfoEventStartsAfter, ExchangeInfoEventStartsBefore, ExchangeInfoEventSubject:
|
||||||
return ExchangeEvent
|
return ExchangeEvent
|
||||||
|
|
||||||
case ExchangeMail, ExchangeMailFolder, ExchangeFilterMailReceivedAfter,
|
case ExchangeMail, ExchangeMailFolder, ExchangeInfoMailReceivedAfter,
|
||||||
ExchangeFilterMailReceivedBefore, ExchangeFilterMailSender, ExchangeFilterMailSubject:
|
ExchangeInfoMailReceivedBefore, ExchangeInfoMailSender, ExchangeInfoMailSubject:
|
||||||
return ExchangeMail
|
return ExchangeMail
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -652,10 +651,10 @@ func (s ExchangeScope) Matches(cat exchangeCategory, target string) bool {
|
|||||||
return matches(s, cat, target)
|
return matches(s, cat, target)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FilterCategory returns the category enum of the scope filter.
|
// InfoCategory returns the category enum of the scope info.
|
||||||
// If the scope is not a filter type, returns ExchangeUnknownCategory.
|
// If the scope is not an info type, returns ExchangeUnknownCategory.
|
||||||
func (s ExchangeScope) FilterCategory() exchangeCategory {
|
func (s ExchangeScope) InfoCategory() exchangeCategory {
|
||||||
return exchangeCategory(getFilterCategory(s))
|
return exchangeCategory(getInfoCategory(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
// IncludeCategory checks whether the scope includes a certain category of data.
|
// IncludeCategory checks whether the scope includes a certain category of data.
|
||||||
@ -733,7 +732,7 @@ func (s exchange) Reduce(
|
|||||||
errs)
|
errs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// matchesInfo handles the standard behavior when comparing a scope and an ExchangeFilter
|
// matchesInfo handles the standard behavior when comparing a scope and an ExchangeInfo
|
||||||
// returns true if the scope and info match for the provided category.
|
// returns true if the scope and info match for the provided category.
|
||||||
func (s ExchangeScope) matchesInfo(dii details.ItemInfo) bool {
|
func (s ExchangeScope) matchesInfo(dii details.ItemInfo) bool {
|
||||||
info := dii.Exchange
|
info := dii.Exchange
|
||||||
@ -741,35 +740,35 @@ func (s ExchangeScope) matchesInfo(dii details.ItemInfo) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
filterCat := s.FilterCategory()
|
infoCat := s.InfoCategory()
|
||||||
|
|
||||||
cfpc := categoryFromItemType(info.ItemType)
|
cfpc := categoryFromItemType(info.ItemType)
|
||||||
if !typeAndCategoryMatches(filterCat, cfpc) {
|
if !typeAndCategoryMatches(infoCat, cfpc) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
i := ""
|
i := ""
|
||||||
|
|
||||||
switch filterCat {
|
switch infoCat {
|
||||||
case ExchangeFilterContactName:
|
case ExchangeInfoContactName:
|
||||||
i = info.ContactName
|
i = info.ContactName
|
||||||
case ExchangeFilterEventOrganizer:
|
case ExchangeInfoEventOrganizer:
|
||||||
i = info.Organizer
|
i = info.Organizer
|
||||||
case ExchangeFilterEventRecurs:
|
case ExchangeInfoEventRecurs:
|
||||||
i = strconv.FormatBool(info.EventRecurs)
|
i = strconv.FormatBool(info.EventRecurs)
|
||||||
case ExchangeFilterEventStartsAfter, ExchangeFilterEventStartsBefore:
|
case ExchangeInfoEventStartsAfter, ExchangeInfoEventStartsBefore:
|
||||||
i = common.FormatTime(info.EventStart)
|
i = common.FormatTime(info.EventStart)
|
||||||
case ExchangeFilterEventSubject:
|
case ExchangeInfoEventSubject:
|
||||||
i = info.Subject
|
i = info.Subject
|
||||||
case ExchangeFilterMailSender:
|
case ExchangeInfoMailSender:
|
||||||
i = info.Sender
|
i = info.Sender
|
||||||
case ExchangeFilterMailSubject:
|
case ExchangeInfoMailSubject:
|
||||||
i = info.Subject
|
i = info.Subject
|
||||||
case ExchangeFilterMailReceivedAfter, ExchangeFilterMailReceivedBefore:
|
case ExchangeInfoMailReceivedAfter, ExchangeInfoMailReceivedBefore:
|
||||||
i = common.FormatTime(info.Received)
|
i = common.FormatTime(info.Received)
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.Matches(filterCat, i)
|
return s.Matches(infoCat, i)
|
||||||
}
|
}
|
||||||
|
|
||||||
// categoryFromItemType interprets the category represented by the ExchangeInfo
|
// categoryFromItemType interprets the category represented by the ExchangeInfo
|
||||||
|
|||||||
@ -1572,16 +1572,16 @@ func (suite *ExchangeSelectorSuite) TestCategory_PathType() {
|
|||||||
{ExchangeMail, path.EmailCategory},
|
{ExchangeMail, path.EmailCategory},
|
||||||
{ExchangeMailFolder, path.EmailCategory},
|
{ExchangeMailFolder, path.EmailCategory},
|
||||||
{ExchangeUser, path.UnknownCategory},
|
{ExchangeUser, path.UnknownCategory},
|
||||||
{ExchangeFilterMailSender, path.EmailCategory},
|
{ExchangeInfoMailSender, path.EmailCategory},
|
||||||
{ExchangeFilterMailSubject, path.EmailCategory},
|
{ExchangeInfoMailSubject, path.EmailCategory},
|
||||||
{ExchangeFilterMailReceivedAfter, path.EmailCategory},
|
{ExchangeInfoMailReceivedAfter, path.EmailCategory},
|
||||||
{ExchangeFilterMailReceivedBefore, path.EmailCategory},
|
{ExchangeInfoMailReceivedBefore, path.EmailCategory},
|
||||||
{ExchangeFilterContactName, path.ContactsCategory},
|
{ExchangeInfoContactName, path.ContactsCategory},
|
||||||
{ExchangeFilterEventOrganizer, path.EventsCategory},
|
{ExchangeInfoEventOrganizer, path.EventsCategory},
|
||||||
{ExchangeFilterEventRecurs, path.EventsCategory},
|
{ExchangeInfoEventRecurs, path.EventsCategory},
|
||||||
{ExchangeFilterEventStartsAfter, path.EventsCategory},
|
{ExchangeInfoEventStartsAfter, path.EventsCategory},
|
||||||
{ExchangeFilterEventStartsBefore, path.EventsCategory},
|
{ExchangeInfoEventStartsBefore, path.EventsCategory},
|
||||||
{ExchangeFilterEventSubject, path.EventsCategory},
|
{ExchangeInfoEventSubject, path.EventsCategory},
|
||||||
}
|
}
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.cat.String(), func(t *testing.T) {
|
suite.T().Run(test.cat.String(), func(t *testing.T) {
|
||||||
|
|||||||
@ -139,7 +139,7 @@ func stubScope(match string) mockScope {
|
|||||||
|
|
||||||
func stubInfoScope(match string) mockScope {
|
func stubInfoScope(match string) mockScope {
|
||||||
sc := stubScope(match)
|
sc := stubScope(match)
|
||||||
sc[scopeKeyInfoFilter] = filters.Identity("true")
|
sc[scopeKeyInfoCategory] = filters.Identity("true")
|
||||||
|
|
||||||
return sc
|
return sc
|
||||||
}
|
}
|
||||||
|
|||||||
@ -239,57 +239,57 @@ func (s *oneDrive) Items(folders, items []string, opts ...option) []OneDriveScop
|
|||||||
// -------------------
|
// -------------------
|
||||||
// Filter Factories
|
// Filter Factories
|
||||||
|
|
||||||
// CreatedAfter produces a OneDrive item created-after filter scope.
|
// CreatedAfter produces a OneDrive item created-after info scope.
|
||||||
// Matches any item where the created time is after the timestring.
|
// Matches any item where the created time is after the timestring.
|
||||||
// If the input equals selectors.Any, the scope will match all times.
|
// If the input equals selectors.Any, the scope will match all times.
|
||||||
// If the input is empty or selectors.None, the scope will always fail comparisons.
|
// If the input is empty or selectors.None, the scope will always fail comparisons.
|
||||||
func (s *oneDrive) CreatedAfter(timeStrings string) []OneDriveScope {
|
func (s *oneDrive) CreatedAfter(timeStrings string) []OneDriveScope {
|
||||||
return []OneDriveScope{
|
return []OneDriveScope{
|
||||||
makeFilterScope[OneDriveScope](
|
makeInfoScope[OneDriveScope](
|
||||||
OneDriveItem,
|
OneDriveItem,
|
||||||
FileFilterCreatedAfter,
|
FileInfoCreatedAfter,
|
||||||
[]string{timeStrings},
|
[]string{timeStrings},
|
||||||
wrapFilter(filters.Less)),
|
wrapFilter(filters.Less)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatedBefore produces a OneDrive item created-before filter scope.
|
// CreatedBefore produces a OneDrive item created-before info scope.
|
||||||
// Matches any item where the created time is before the timestring.
|
// Matches any item where the created time is before the timestring.
|
||||||
// If the input equals selectors.Any, the scope will match all times.
|
// If the input equals selectors.Any, the scope will match all times.
|
||||||
// If the input is empty or selectors.None, the scope will always fail comparisons.
|
// If the input is empty or selectors.None, the scope will always fail comparisons.
|
||||||
func (s *oneDrive) CreatedBefore(timeStrings string) []OneDriveScope {
|
func (s *oneDrive) CreatedBefore(timeStrings string) []OneDriveScope {
|
||||||
return []OneDriveScope{
|
return []OneDriveScope{
|
||||||
makeFilterScope[OneDriveScope](
|
makeInfoScope[OneDriveScope](
|
||||||
OneDriveItem,
|
OneDriveItem,
|
||||||
FileFilterCreatedBefore,
|
FileInfoCreatedBefore,
|
||||||
[]string{timeStrings},
|
[]string{timeStrings},
|
||||||
wrapFilter(filters.Greater)),
|
wrapFilter(filters.Greater)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ModifiedAfter produces a OneDrive item modified-after filter scope.
|
// ModifiedAfter produces a OneDrive item modified-after info scope.
|
||||||
// Matches any item where the modified time is after the timestring.
|
// Matches any item where the modified time is after the timestring.
|
||||||
// If the input equals selectors.Any, the scope will match all times.
|
// If the input equals selectors.Any, the scope will match all times.
|
||||||
// If the input is empty or selectors.None, the scope will always fail comparisons.
|
// If the input is empty or selectors.None, the scope will always fail comparisons.
|
||||||
func (s *oneDrive) ModifiedAfter(timeStrings string) []OneDriveScope {
|
func (s *oneDrive) ModifiedAfter(timeStrings string) []OneDriveScope {
|
||||||
return []OneDriveScope{
|
return []OneDriveScope{
|
||||||
makeFilterScope[OneDriveScope](
|
makeInfoScope[OneDriveScope](
|
||||||
OneDriveItem,
|
OneDriveItem,
|
||||||
FileFilterModifiedAfter,
|
FileInfoModifiedAfter,
|
||||||
[]string{timeStrings},
|
[]string{timeStrings},
|
||||||
wrapFilter(filters.Less)),
|
wrapFilter(filters.Less)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ModifiedBefore produces a OneDrive item modified-before filter scope.
|
// ModifiedBefore produces a OneDrive item modified-before info scope.
|
||||||
// Matches any item where the modified time is before the timestring.
|
// Matches any item where the modified time is before the timestring.
|
||||||
// If the input equals selectors.Any, the scope will match all times.
|
// If the input equals selectors.Any, the scope will match all times.
|
||||||
// If the input is empty or selectors.None, the scope will always fail comparisons.
|
// If the input is empty or selectors.None, the scope will always fail comparisons.
|
||||||
func (s *oneDrive) ModifiedBefore(timeStrings string) []OneDriveScope {
|
func (s *oneDrive) ModifiedBefore(timeStrings string) []OneDriveScope {
|
||||||
return []OneDriveScope{
|
return []OneDriveScope{
|
||||||
makeFilterScope[OneDriveScope](
|
makeInfoScope[OneDriveScope](
|
||||||
OneDriveItem,
|
OneDriveItem,
|
||||||
FileFilterModifiedBefore,
|
FileInfoModifiedBefore,
|
||||||
[]string{timeStrings},
|
[]string{timeStrings},
|
||||||
wrapFilter(filters.Greater)),
|
wrapFilter(filters.Greater)),
|
||||||
}
|
}
|
||||||
@ -308,16 +308,17 @@ var _ categorizer = OneDriveCategoryUnknown
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
OneDriveCategoryUnknown oneDriveCategory = ""
|
OneDriveCategoryUnknown oneDriveCategory = ""
|
||||||
// types of data identified by OneDrive
|
|
||||||
|
// types of data in OneDrive
|
||||||
OneDriveUser oneDriveCategory = "OneDriveUser"
|
OneDriveUser oneDriveCategory = "OneDriveUser"
|
||||||
OneDriveItem oneDriveCategory = "OneDriveItem"
|
OneDriveItem oneDriveCategory = "OneDriveItem"
|
||||||
OneDriveFolder oneDriveCategory = "OneDriveFolder"
|
OneDriveFolder oneDriveCategory = "OneDriveFolder"
|
||||||
|
|
||||||
// filterable topics identified by OneDrive
|
// details.ItemInfo comparables
|
||||||
FileFilterCreatedAfter oneDriveCategory = "FileFilterCreatedAfter"
|
FileInfoCreatedAfter oneDriveCategory = "FileInfoCreatedAfter"
|
||||||
FileFilterCreatedBefore oneDriveCategory = "FileFilterCreatedBefore"
|
FileInfoCreatedBefore oneDriveCategory = "FileInfoCreatedBefore"
|
||||||
FileFilterModifiedAfter oneDriveCategory = "FileFilterModifiedAfter"
|
FileInfoModifiedAfter oneDriveCategory = "FileInfoModifiedAfter"
|
||||||
FileFilterModifiedBefore oneDriveCategory = "FileFilterModifiedBefore"
|
FileInfoModifiedBefore oneDriveCategory = "FileInfoModifiedBefore"
|
||||||
)
|
)
|
||||||
|
|
||||||
// oneDriveLeafProperties describes common metadata of the leaf categories
|
// oneDriveLeafProperties describes common metadata of the leaf categories
|
||||||
@ -344,8 +345,8 @@ func (c oneDriveCategory) String() string {
|
|||||||
func (c oneDriveCategory) leafCat() categorizer {
|
func (c oneDriveCategory) leafCat() categorizer {
|
||||||
switch c {
|
switch c {
|
||||||
case OneDriveFolder, OneDriveItem,
|
case OneDriveFolder, OneDriveItem,
|
||||||
FileFilterCreatedAfter, FileFilterCreatedBefore,
|
FileInfoCreatedAfter, FileInfoCreatedBefore,
|
||||||
FileFilterModifiedAfter, FileFilterModifiedBefore:
|
FileInfoModifiedAfter, FileInfoModifiedBefore:
|
||||||
return OneDriveItem
|
return OneDriveItem
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,10 +434,10 @@ func (s OneDriveScope) categorizer() categorizer {
|
|||||||
return s.Category()
|
return s.Category()
|
||||||
}
|
}
|
||||||
|
|
||||||
// FilterCategory returns the category enum of the scope filter.
|
// InfoCategory returns the category enum of the scope info.
|
||||||
// If the scope is not a filter type, returns OneDriveUnknownCategory.
|
// If the scope is not an info type, returns OneDriveUnknownCategory.
|
||||||
func (s OneDriveScope) FilterCategory() oneDriveCategory {
|
func (s OneDriveScope) InfoCategory() oneDriveCategory {
|
||||||
return oneDriveCategory(getFilterCategory(s))
|
return oneDriveCategory(getInfoCategory(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
// IncludeCategory checks whether the scope includes a
|
// IncludeCategory checks whether the scope includes a
|
||||||
@ -522,16 +523,16 @@ func (s OneDriveScope) matchesInfo(dii details.ItemInfo) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
filterCat := s.FilterCategory()
|
infoCat := s.InfoCategory()
|
||||||
|
|
||||||
i := ""
|
i := ""
|
||||||
|
|
||||||
switch filterCat {
|
switch infoCat {
|
||||||
case FileFilterCreatedAfter, FileFilterCreatedBefore:
|
case FileInfoCreatedAfter, FileInfoCreatedBefore:
|
||||||
i = common.FormatTime(info.Created)
|
i = common.FormatTime(info.Created)
|
||||||
case FileFilterModifiedAfter, FileFilterModifiedBefore:
|
case FileInfoModifiedAfter, FileInfoModifiedBefore:
|
||||||
i = common.FormatTime(info.Modified)
|
i = common.FormatTime(info.Modified)
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.Matches(filterCat, i)
|
return s.Matches(infoCat, i)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,7 +63,7 @@ func (suite *OneDriveSelectorSuite) TestOneDriveSelector_AllData() {
|
|||||||
}{
|
}{
|
||||||
{"Include Scopes", sel.Includes},
|
{"Include Scopes", sel.Includes},
|
||||||
{"Exclude Scopes", sel.Excludes},
|
{"Exclude Scopes", sel.Excludes},
|
||||||
{"Filter Scopes", sel.Filters},
|
{"info scopes", sel.Filters},
|
||||||
}
|
}
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.Run(test.name, func() {
|
suite.Run(test.name, func() {
|
||||||
@ -348,10 +348,10 @@ func (suite *OneDriveSelectorSuite) TestCategory_PathType() {
|
|||||||
{OneDriveUser, path.UnknownCategory},
|
{OneDriveUser, path.UnknownCategory},
|
||||||
{OneDriveItem, path.FilesCategory},
|
{OneDriveItem, path.FilesCategory},
|
||||||
{OneDriveFolder, path.FilesCategory},
|
{OneDriveFolder, path.FilesCategory},
|
||||||
{FileFilterCreatedAfter, path.FilesCategory},
|
{FileInfoCreatedAfter, path.FilesCategory},
|
||||||
{FileFilterCreatedBefore, path.FilesCategory},
|
{FileInfoCreatedBefore, path.FilesCategory},
|
||||||
{FileFilterModifiedAfter, path.FilesCategory},
|
{FileInfoModifiedAfter, path.FilesCategory},
|
||||||
{FileFilterModifiedBefore, path.FilesCategory},
|
{FileInfoModifiedBefore, path.FilesCategory},
|
||||||
}
|
}
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.cat.String(), func(t *testing.T) {
|
suite.T().Run(test.cat.String(), func(t *testing.T) {
|
||||||
|
|||||||
@ -140,7 +140,7 @@ type (
|
|||||||
categorizer() categorizer
|
categorizer() categorizer
|
||||||
|
|
||||||
// matchesInfo is used to determine if the scope values match a specific DetailsEntry
|
// matchesInfo is used to determine if the scope values match a specific DetailsEntry
|
||||||
// ItemInfo filter. Unlike path filtering, the entry comparison requires service-specific
|
// ItemInfo value. Unlike path comparison, the entry comparison requires service-specific
|
||||||
// context in order for the scope to extract the correct serviceInfo in the entry.
|
// context in order for the scope to extract the correct serviceInfo in the entry.
|
||||||
//
|
//
|
||||||
// Params:
|
// Params:
|
||||||
@ -178,18 +178,18 @@ func makeScope[T scopeT](
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeFilterScope produces a well formatted, typed scope, with properties specifically oriented
|
// makeInfoScope produces a well formatted, typed scope, with properties specifically oriented
|
||||||
// towards identifying filter-type scopes, that ensures all base values are populated.
|
// towards identifying filter-type scopes, that ensures all base values are populated.
|
||||||
func makeFilterScope[T scopeT](
|
func makeInfoScope[T scopeT](
|
||||||
cat, filterCat categorizer,
|
cat, infoCat categorizer,
|
||||||
vs []string,
|
vs []string,
|
||||||
f func([]string) filters.Filter,
|
f func([]string) filters.Filter,
|
||||||
) T {
|
) T {
|
||||||
return T{
|
return T{
|
||||||
scopeKeyCategory: filters.Identity(cat.String()),
|
scopeKeyCategory: filters.Identity(cat.String()),
|
||||||
scopeKeyDataType: filters.Identity(cat.leafCat().String()),
|
scopeKeyDataType: filters.Identity(cat.leafCat().String()),
|
||||||
scopeKeyInfoFilter: filters.Identity(filterCat.String()),
|
scopeKeyInfoCategory: filters.Identity(infoCat.String()),
|
||||||
filterCat.String(): f(clean(vs)),
|
infoCat.String(): f(clean(vs)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,14 +227,14 @@ func matchesAny[T scopeT, C categoryT](s T, cat C, inpts []string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getCategory returns the scope's category value.
|
// getCategory returns the scope's category value.
|
||||||
// if s is a filter-type scope, returns the filter category.
|
// if s is an info-type scope, returns the info category.
|
||||||
func getCategory[T scopeT](s T) string {
|
func getCategory[T scopeT](s T) string {
|
||||||
return s[scopeKeyCategory].Target
|
return s[scopeKeyCategory].Target
|
||||||
}
|
}
|
||||||
|
|
||||||
// getFilterCategory returns the scope's infoFilter category value.
|
// getInfoCategory returns the scope's infoFilter category value.
|
||||||
func getFilterCategory[T scopeT](s T) string {
|
func getInfoCategory[T scopeT](s T) string {
|
||||||
return s[scopeKeyInfoFilter].Target
|
return s[scopeKeyInfoCategory].Target
|
||||||
}
|
}
|
||||||
|
|
||||||
// getCatValue takes the value of s[cat], split it by the standard
|
// getCatValue takes the value of s[cat], split it by the standard
|
||||||
@ -456,8 +456,8 @@ func matchesEntry[T scopeT, C categoryT](
|
|||||||
pathValues map[categorizer][]string,
|
pathValues map[categorizer][]string,
|
||||||
entry details.DetailsEntry,
|
entry details.DetailsEntry,
|
||||||
) bool {
|
) bool {
|
||||||
// filterCategory requires matching against service-specific info values
|
// InfoCategory requires matching against service-specific info values
|
||||||
if len(getFilterCategory(sc)) > 0 {
|
if len(getInfoCategory(sc)) > 0 {
|
||||||
return sc.matchesInfo(entry.ItemInfo)
|
return sc.matchesInfo(entry.ItemInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,9 +38,9 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
scopeKeyCategory = "category"
|
scopeKeyCategory = "category"
|
||||||
scopeKeyInfoFilter = "info_filter"
|
scopeKeyInfoCategory = "details_info_category"
|
||||||
scopeKeyDataType = "type"
|
scopeKeyDataType = "type"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The granularity exprerssed by the scope. Groups imply non-item granularity,
|
// The granularity exprerssed by the scope. Groups imply non-item granularity,
|
||||||
@ -116,7 +116,7 @@ type Selector struct {
|
|||||||
// A slice of exclusion scopes. Exclusions apply globally to all
|
// A slice of exclusion scopes. Exclusions apply globally to all
|
||||||
// inclusions/filters, with any-match behavior.
|
// inclusions/filters, with any-match behavior.
|
||||||
Excludes []scope `json:"exclusions,omitempty"`
|
Excludes []scope `json:"exclusions,omitempty"`
|
||||||
// A slice of filter scopes. All inclusions must also match ALL filters.
|
// A slice of info scopes. All inclusions must also match ALL filters.
|
||||||
Filters []scope `json:"filters,omitempty"`
|
Filters []scope `json:"filters,omitempty"`
|
||||||
// A slice of inclusion scopes. Comparators must match either one of these,
|
// A slice of inclusion scopes. Comparators must match either one of these,
|
||||||
// or all filters, to be included.
|
// or all filters, to be included.
|
||||||
|
|||||||
@ -197,17 +197,17 @@ func (s *SharePointRestore) WebURL(urlSuffixes []string, opts ...option) []Share
|
|||||||
|
|
||||||
scopes = append(
|
scopes = append(
|
||||||
scopes,
|
scopes,
|
||||||
makeFilterScope[SharePointScope](
|
makeInfoScope[SharePointScope](
|
||||||
SharePointLibraryItem,
|
SharePointLibraryItem,
|
||||||
SharePointWebURL,
|
SharePointWebURL,
|
||||||
urlSuffixes,
|
urlSuffixes,
|
||||||
pathFilterFactory(opts...)),
|
pathFilterFactory(opts...)),
|
||||||
makeFilterScope[SharePointScope](
|
makeInfoScope[SharePointScope](
|
||||||
SharePointListItem,
|
SharePointListItem,
|
||||||
SharePointWebURL,
|
SharePointWebURL,
|
||||||
urlSuffixes,
|
urlSuffixes,
|
||||||
pathFilterFactory(opts...)),
|
pathFilterFactory(opts...)),
|
||||||
makeFilterScope[SharePointScope](
|
makeInfoScope[SharePointScope](
|
||||||
SharePointPage,
|
SharePointPage,
|
||||||
SharePointWebURL,
|
SharePointWebURL,
|
||||||
urlSuffixes,
|
urlSuffixes,
|
||||||
@ -276,9 +276,9 @@ func (s *sharePoint) ListItems(lists, items []string, opts ...option) []SharePoi
|
|||||||
// If any slice is empty, it defaults to [selectors.None]
|
// If any slice is empty, it defaults to [selectors.None]
|
||||||
func (s *sharePoint) Library(library string) []SharePointScope {
|
func (s *sharePoint) Library(library string) []SharePointScope {
|
||||||
return []SharePointScope{
|
return []SharePointScope{
|
||||||
makeFilterScope[SharePointScope](
|
makeInfoScope[SharePointScope](
|
||||||
SharePointLibraryItem,
|
SharePointLibraryItem,
|
||||||
SharePointFilterLibraryDrive,
|
SharePointInfoLibraryDrive,
|
||||||
[]string{library},
|
[]string{library},
|
||||||
wrapFilter(filters.Equal)),
|
wrapFilter(filters.Equal)),
|
||||||
}
|
}
|
||||||
@ -352,13 +352,13 @@ func (s *sharePoint) PageItems(pages, items []string, opts ...option) []SharePoi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// -------------------
|
// -------------------
|
||||||
// Filter Factories
|
// ItemInfo Factories
|
||||||
|
|
||||||
func (s *sharePoint) CreatedAfter(timeStrings string) []SharePointScope {
|
func (s *sharePoint) CreatedAfter(timeStrings string) []SharePointScope {
|
||||||
return []SharePointScope{
|
return []SharePointScope{
|
||||||
makeFilterScope[SharePointScope](
|
makeInfoScope[SharePointScope](
|
||||||
SharePointLibraryItem,
|
SharePointLibraryItem,
|
||||||
SharePointFilterCreatedAfter,
|
SharePointInfoCreatedAfter,
|
||||||
[]string{timeStrings},
|
[]string{timeStrings},
|
||||||
wrapFilter(filters.Less)),
|
wrapFilter(filters.Less)),
|
||||||
}
|
}
|
||||||
@ -366,9 +366,9 @@ func (s *sharePoint) CreatedAfter(timeStrings string) []SharePointScope {
|
|||||||
|
|
||||||
func (s *sharePoint) CreatedBefore(timeStrings string) []SharePointScope {
|
func (s *sharePoint) CreatedBefore(timeStrings string) []SharePointScope {
|
||||||
return []SharePointScope{
|
return []SharePointScope{
|
||||||
makeFilterScope[SharePointScope](
|
makeInfoScope[SharePointScope](
|
||||||
SharePointLibraryItem,
|
SharePointLibraryItem,
|
||||||
SharePointFilterCreatedBefore,
|
SharePointInfoCreatedBefore,
|
||||||
[]string{timeStrings},
|
[]string{timeStrings},
|
||||||
wrapFilter(filters.Greater)),
|
wrapFilter(filters.Greater)),
|
||||||
}
|
}
|
||||||
@ -376,9 +376,9 @@ func (s *sharePoint) CreatedBefore(timeStrings string) []SharePointScope {
|
|||||||
|
|
||||||
func (s *sharePoint) ModifiedAfter(timeStrings string) []SharePointScope {
|
func (s *sharePoint) ModifiedAfter(timeStrings string) []SharePointScope {
|
||||||
return []SharePointScope{
|
return []SharePointScope{
|
||||||
makeFilterScope[SharePointScope](
|
makeInfoScope[SharePointScope](
|
||||||
SharePointLibraryItem,
|
SharePointLibraryItem,
|
||||||
SharePointFilterModifiedAfter,
|
SharePointInfoModifiedAfter,
|
||||||
[]string{timeStrings},
|
[]string{timeStrings},
|
||||||
wrapFilter(filters.Less)),
|
wrapFilter(filters.Less)),
|
||||||
}
|
}
|
||||||
@ -386,9 +386,9 @@ func (s *sharePoint) ModifiedAfter(timeStrings string) []SharePointScope {
|
|||||||
|
|
||||||
func (s *sharePoint) ModifiedBefore(timeStrings string) []SharePointScope {
|
func (s *sharePoint) ModifiedBefore(timeStrings string) []SharePointScope {
|
||||||
return []SharePointScope{
|
return []SharePointScope{
|
||||||
makeFilterScope[SharePointScope](
|
makeInfoScope[SharePointScope](
|
||||||
SharePointLibraryItem,
|
SharePointLibraryItem,
|
||||||
SharePointFilterModifiedBefore,
|
SharePointInfoModifiedBefore,
|
||||||
[]string{timeStrings},
|
[]string{timeStrings},
|
||||||
wrapFilter(filters.Greater)),
|
wrapFilter(filters.Greater)),
|
||||||
}
|
}
|
||||||
@ -408,7 +408,7 @@ var _ categorizer = SharePointCategoryUnknown
|
|||||||
const (
|
const (
|
||||||
SharePointCategoryUnknown sharePointCategory = ""
|
SharePointCategoryUnknown sharePointCategory = ""
|
||||||
|
|
||||||
// types of data identified by SharePoint
|
// types of data in SharePoint
|
||||||
SharePointWebURL sharePointCategory = "SharePointWebURL"
|
SharePointWebURL sharePointCategory = "SharePointWebURL"
|
||||||
SharePointSite sharePointCategory = "SharePointSite"
|
SharePointSite sharePointCategory = "SharePointSite"
|
||||||
SharePointList sharePointCategory = "SharePointList"
|
SharePointList sharePointCategory = "SharePointList"
|
||||||
@ -418,14 +418,14 @@ const (
|
|||||||
SharePointPageFolder sharePointCategory = "SharePointPageFolder"
|
SharePointPageFolder sharePointCategory = "SharePointPageFolder"
|
||||||
SharePointPage sharePointCategory = "SharePointPage"
|
SharePointPage sharePointCategory = "SharePointPage"
|
||||||
|
|
||||||
// filterable topics identified by SharePoint
|
// details.itemInfo comparables
|
||||||
SharePointFilterCreatedAfter sharePointCategory = "SharePointFilterCreatedAfter"
|
SharePointInfoCreatedAfter sharePointCategory = "SharePointInfoCreatedAfter"
|
||||||
SharePointFilterCreatedBefore sharePointCategory = "SharePointFilterCreatedBefore"
|
SharePointInfoCreatedBefore sharePointCategory = "SharePointInfoCreatedBefore"
|
||||||
SharePointFilterModifiedAfter sharePointCategory = "SharePointFilterModifiedAfter"
|
SharePointInfoModifiedAfter sharePointCategory = "SharePointInfoModifiedAfter"
|
||||||
SharePointFilterModifiedBefore sharePointCategory = "SharePointFilterModifiedBefore"
|
SharePointInfoModifiedBefore sharePointCategory = "SharePointInfoModifiedBefore"
|
||||||
|
|
||||||
// library drive selection
|
// library drive selection
|
||||||
SharePointFilterLibraryDrive sharePointCategory = "SharePointFilterLibraryDrive"
|
SharePointInfoLibraryDrive sharePointCategory = "SharePointInfoLibraryDrive"
|
||||||
)
|
)
|
||||||
|
|
||||||
// sharePointLeafProperties describes common metadata of the leaf categories
|
// sharePointLeafProperties describes common metadata of the leaf categories
|
||||||
@ -459,9 +459,9 @@ func (c sharePointCategory) String() string {
|
|||||||
// Ex: ServiceUser.leafCat() => ServiceUser
|
// Ex: ServiceUser.leafCat() => ServiceUser
|
||||||
func (c sharePointCategory) leafCat() categorizer {
|
func (c sharePointCategory) leafCat() categorizer {
|
||||||
switch c {
|
switch c {
|
||||||
case SharePointLibraryFolder, SharePointLibraryItem, SharePointFilterLibraryDrive,
|
case SharePointLibraryFolder, SharePointLibraryItem, SharePointInfoLibraryDrive,
|
||||||
SharePointFilterCreatedAfter, SharePointFilterCreatedBefore,
|
SharePointInfoCreatedAfter, SharePointInfoCreatedBefore,
|
||||||
SharePointFilterModifiedAfter, SharePointFilterModifiedBefore:
|
SharePointInfoModifiedAfter, SharePointInfoModifiedBefore:
|
||||||
return SharePointLibraryItem
|
return SharePointLibraryItem
|
||||||
case SharePointList, SharePointListItem:
|
case SharePointList, SharePointListItem:
|
||||||
return SharePointListItem
|
return SharePointListItem
|
||||||
@ -576,10 +576,10 @@ func (s SharePointScope) Matches(cat sharePointCategory, target string) bool {
|
|||||||
return matches(s, cat, target)
|
return matches(s, cat, target)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FilterCategory returns the category enum of the scope filter.
|
// InfoCategory returns the category enum of the scope info.
|
||||||
// If the scope is not a filter type, returns SharePointUnknownCategory.
|
// If the scope is not an info type, returns SharePointUnknownCategory.
|
||||||
func (s SharePointScope) FilterCategory() sharePointCategory {
|
func (s SharePointScope) InfoCategory() sharePointCategory {
|
||||||
return sharePointCategory(getFilterCategory(s))
|
return sharePointCategory(getInfoCategory(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
// IncludeCategory checks whether the scope includes a
|
// IncludeCategory checks whether the scope includes a
|
||||||
@ -667,23 +667,23 @@ func (s sharePoint) Reduce(
|
|||||||
// returns true if the scope and info match for the provided category.
|
// returns true if the scope and info match for the provided category.
|
||||||
func (s SharePointScope) matchesInfo(dii details.ItemInfo) bool {
|
func (s SharePointScope) matchesInfo(dii details.ItemInfo) bool {
|
||||||
var (
|
var (
|
||||||
filterCat = s.FilterCategory()
|
infoCat = s.InfoCategory()
|
||||||
i = ""
|
i = ""
|
||||||
info = dii.SharePoint
|
info = dii.SharePoint
|
||||||
)
|
)
|
||||||
|
|
||||||
if info == nil {
|
if info == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
switch filterCat {
|
switch infoCat {
|
||||||
case SharePointWebURL:
|
case SharePointWebURL:
|
||||||
i = info.WebURL
|
i = info.WebURL
|
||||||
case SharePointFilterCreatedAfter, SharePointFilterCreatedBefore:
|
case SharePointInfoCreatedAfter, SharePointInfoCreatedBefore:
|
||||||
i = common.FormatTime(info.Created)
|
i = common.FormatTime(info.Created)
|
||||||
case SharePointFilterModifiedAfter, SharePointFilterModifiedBefore:
|
case SharePointInfoModifiedAfter, SharePointInfoModifiedBefore:
|
||||||
i = common.FormatTime(info.Modified)
|
i = common.FormatTime(info.Modified)
|
||||||
case SharePointFilterLibraryDrive:
|
case SharePointInfoLibraryDrive:
|
||||||
ds := []string{}
|
ds := []string{}
|
||||||
|
|
||||||
if len(info.DriveName) > 0 {
|
if len(info.DriveName) > 0 {
|
||||||
@ -694,8 +694,8 @@ func (s SharePointScope) matchesInfo(dii details.ItemInfo) bool {
|
|||||||
ds = append(ds, info.DriveID)
|
ds = append(ds, info.DriveID)
|
||||||
}
|
}
|
||||||
|
|
||||||
return matchesAny(s, SharePointFilterLibraryDrive, ds)
|
return matchesAny(s, SharePointInfoLibraryDrive, ds)
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.Matches(filterCat, i)
|
return s.Matches(infoCat, i)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,7 +62,7 @@ func (suite *SharePointSelectorSuite) TestSharePointSelector_AllData() {
|
|||||||
}{
|
}{
|
||||||
{"Include Scopes", sel.Includes},
|
{"Include Scopes", sel.Includes},
|
||||||
{"Exclude Scopes", sel.Excludes},
|
{"Exclude Scopes", sel.Excludes},
|
||||||
{"Filter Scopes", sel.Filters},
|
{"info scopes", sel.Filters},
|
||||||
}
|
}
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
require.Len(t, test.scopesToCheck, 3)
|
require.Len(t, test.scopesToCheck, 3)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user