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