2021-02-22 13:08:47 +00:00
|
|
|
package view
|
|
|
|
|
|
|
|
import (
|
2023-10-19 10:19:10 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/repository/project"
|
2023-12-08 14:30:55 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/zerrors"
|
2021-02-22 13:08:47 +00:00
|
|
|
)
|
|
|
|
|
2023-10-19 10:19:10 +00:00
|
|
|
func ProjectByIDQuery(id, instanceID string, latestSequence uint64) (*eventstore.SearchQueryBuilder, error) {
|
2021-02-22 13:08:47 +00:00
|
|
|
if id == "" {
|
2023-12-08 14:30:55 +00:00
|
|
|
return nil, zerrors.ThrowPreconditionFailed(nil, "EVENT-dke74", "Errors.Project.ProjectIDMissing")
|
2021-02-22 13:08:47 +00:00
|
|
|
}
|
2023-10-19 10:19:10 +00:00
|
|
|
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
|
|
|
|
InstanceID(instanceID).
|
|
|
|
AwaitOpenTransactions().
|
|
|
|
SequenceGreater(latestSequence).
|
2022-04-19 06:26:12 +00:00
|
|
|
AddQuery().
|
2023-10-19 10:19:10 +00:00
|
|
|
AggregateTypes(project.AggregateType).
|
|
|
|
AggregateIDs(id).
|
|
|
|
EventTypes(
|
|
|
|
project.ProjectAddedType,
|
|
|
|
project.ProjectChangedType,
|
|
|
|
project.ProjectDeactivatedType,
|
|
|
|
project.ProjectReactivatedType,
|
|
|
|
project.ProjectRemovedType,
|
|
|
|
project.OIDCConfigAddedType,
|
|
|
|
project.ApplicationRemovedType,
|
2023-04-28 14:28:13 +00:00
|
|
|
).
|
2023-10-19 10:19:10 +00:00
|
|
|
Builder(), nil
|
2021-02-22 13:08:47 +00:00
|
|
|
}
|