diff --git a/.gitignore b/.gitignore
index ef40db5c..96dd691a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,10 +25,10 @@ server.crt
server.key
private_key.pem
public_key.pem
-# Sendgrid test email folders
-internal/httpserve/handlers/fixtures/emails/*
+
+# emails tests
+emails/*
fixtures/emails/*
-pkg/httpsling/testdata/*
# Packages
*.7z
diff --git a/Taskfile.yaml b/Taskfile.yaml
index d3ef7c9f..c91d5183 100644
--- a/Taskfile.yaml
+++ b/Taskfile.yaml
@@ -113,7 +113,7 @@ tasks:
cmds:
- task: compose:redis
- task: compose:fga
- - task: compose:kafka
+ - task: compose:riverboat
- task: run-api
run-api:
diff --git a/cmd/serve.go b/cmd/serve.go
index 9c81c8ca..70795e60 100644
--- a/cmd/serve.go
+++ b/cmd/serve.go
@@ -6,8 +6,8 @@ import (
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/theopenlane/beacon/otelx"
+ "github.com/theopenlane/riverboat/pkg/riverqueue"
- dbx "github.com/theopenlane/dbx/pkg/dbxclient"
"github.com/theopenlane/iam/fgax"
"github.com/theopenlane/utils/cache"
@@ -49,15 +49,12 @@ func serve(ctx context.Context) error {
serverOpts = append(serverOpts,
serveropts.WithConfigProvider(&config.ConfigProviderWithRefresh{}),
serveropts.WithHTTPS(),
- serveropts.WithEmailManager(),
- serveropts.WithTaskManager(),
+ serveropts.WithEmailConfig(),
serveropts.WithMiddleware(),
serveropts.WithRateLimiter(),
serveropts.WithSecureMW(),
serveropts.WithCacheHeaders(),
serveropts.WithCORS(),
- serveropts.WithAnalytics(),
- serveropts.WithEventPublisher(),
)
so := serveropts.NewServerOptions(serverOpts, k.String("config"))
@@ -97,13 +94,6 @@ func serve(ctx context.Context) error {
serveropts.WithSessionManager(redisClient),
)
- // Setup DBx client
- if so.Config.Settings.DBx.Enabled {
- gc := so.Config.Settings.DBx.NewDefaultClient()
-
- entOpts = append(entOpts, ent.DBx(gc.(*dbx.Client)))
- }
-
// add otp manager, after redis is setup
so.AddServerOptions(
serveropts.WithOTP(),
@@ -113,32 +103,36 @@ func serve(ctx context.Context) error {
entOpts = append(
entOpts,
ent.Authz(*fgaClient),
- ent.Emails(so.Config.Handler.EmailManager),
- ent.Marionette(so.Config.Handler.TaskMan),
- ent.Analytics(so.Config.Handler.AnalyticsClient),
ent.TOTP(so.Config.Handler.OTPManager),
ent.TokenManager(so.Config.Handler.TokenManager),
ent.SessionConfig(so.Config.Handler.SessionConfig),
ent.EntConfig(&so.Config.Settings.EntConfig),
+ ent.Emailer(&so.Config.Settings.Email),
)
// Setup DB connection
- entdbClient, dbConfig, err := entdb.NewMultiDriverDBClient(ctx, so.Config.Settings.DB, entOpts)
+ log.Info().Interface("db", so.Config.Settings.DB).Msg("connecting to database")
+
+ jobOpts := []riverqueue.Option{
+ riverqueue.WithConnectionURI(so.Config.Settings.JobQueue.ConnectionURI),
+ }
+
+ dbClient, err := entdb.New(ctx, so.Config.Settings.DB, jobOpts, entOpts...)
if err != nil {
return err
}
- defer entdbClient.Close()
+ defer dbClient.CloseAll() // nolint: errcheck
// Add Driver to the Handlers Config
- so.Config.Handler.DBClient = entdbClient
+ so.Config.Handler.DBClient = dbClient
// Add redis client to Handlers Config
so.Config.Handler.RedisClient = redisClient
// add ready checks
so.AddServerOptions(
- serveropts.WithReadyChecks(dbConfig, fgaClient, redisClient),
+ serveropts.WithReadyChecks(dbClient.Config, fgaClient, redisClient, dbClient.Job),
)
// add auth options
@@ -154,7 +148,7 @@ func serve(ctx context.Context) error {
srv := server.NewServer(so.Config)
// Setup Graph API Handlers
- so.AddServerOptions(serveropts.WithGraphRoute(srv, entdbClient))
+ so.AddServerOptions(serveropts.WithGraphRoute(srv, dbClient))
if err := srv.StartEchoServer(ctx); err != nil {
log.Error().Err(err).Msg("failed to run server")
diff --git a/config/.env.example b/config/.env.example
index 3cdc16dd..4c13354d 100644
--- a/config/.env.example
+++ b/config/.env.example
@@ -85,7 +85,7 @@ CORE_AUTHZ_CREDENTIALS_ISSUER=""
CORE_AUTHZ_CREDENTIALS_SCOPES=""
CORE_DB_DEBUG="false"
CORE_DB_DATABASENAME="openlane"
-CORE_DB_DRIVERNAME="libsql"
+CORE_DB_DRIVERNAME="pgx"
CORE_DB_MULTIWRITE="false"
CORE_DB_PRIMARYDBSOURCE="file:openlane.db"
CORE_DB_SECONDARYDBSOURCE="file:backup.db"
@@ -93,10 +93,8 @@ CORE_DB_CACHETTL="1s"
CORE_DB_RUNMIGRATIONS="true"
CORE_DB_MIGRATIONPROVIDER="atlas"
CORE_DB_ENABLEHISTORY="false"
-CORE_DBX_ENABLED="true"
-CORE_DBX_BASEURL="http://localhost:1337"
-CORE_DBX_ENDPOINT="query"
-CORE_DBX_DEBUG="false"
+CORE_JOBQUEUE_CONNECTIONURI=""
+CORE_JOBQUEUE_RUNMIGRATIONS="false"
CORE_REDIS_ENABLED="true"
CORE_REDIS_ADDRESS="localhost:6379"
CORE_REDIS_NAME="openlane"
@@ -121,24 +119,22 @@ CORE_TRACER_OTLP_CERTIFICATE=""
CORE_TRACER_OTLP_HEADERS=""
CORE_TRACER_OTLP_COMPRESSION=""
CORE_TRACER_OTLP_TIMEOUT="10s"
-CORE_EMAIL_SENDGRIDAPIKEY=""
-CORE_EMAIL_FROMEMAIL="no-reply@theopenlane.io"
-CORE_EMAIL_TESTING="true"
-CORE_EMAIL_ARCHIVE=""
-CORE_EMAIL_LISTID=""
-CORE_EMAIL_ADMINEMAIL="admins@theopenlane.io"
-CORE_EMAIL_CONSOLEURL_CONSOLEBASE="https://console.theopenlane.io"
-CORE_EMAIL_CONSOLEURL_VERIFY="/verify"
-CORE_EMAIL_CONSOLEURL_INVITE="/invite"
-CORE_EMAIL_CONSOLEURL_RESET="/password-reset"
-CORE_EMAIL_MARKETINGURL_MARKETINGBASE="https://www.theopenlane.io"
-CORE_EMAIL_MARKETINGURL_SUBSCRIBERVERIFY="/verify"
+CORE_EMAIL_COMPANYNAME=""
+CORE_EMAIL_COMPANYADDRESS=""
+CORE_EMAIL_CORPORATION=""
+CORE_EMAIL_FROMEMAIL=""
+CORE_EMAIL_SUPPORTEMAIL=""
+CORE_EMAIL_LOGOURL=""
+CORE_EMAIL_URLS_ROOT=""
+CORE_EMAIL_URLS_PRODUCT=""
+CORE_EMAIL_URLS_DOCS=""
+CORE_EMAIL_URLS_VERIFY=""
+CORE_EMAIL_URLS_INVITE=""
+CORE_EMAIL_URLS_RESET=""
+CORE_EMAIL_URLS_VERIFYSUBSCRIBER=""
CORE_SESSIONS_SIGNINGKEY="my-signing-secret"
CORE_SESSIONS_ENCRYPTIONKEY="encryptionsecret"
CORE_SESSIONS_DOMAIN=""
-CORE_POSTHOG_ENABLED="false"
-CORE_POSTHOG_APIKEY=""
-CORE_POSTHOG_HOST="https://app.posthog.com"
CORE_TOTP_ENABLED="true"
CORE_TOTP_CODELENGTH="6"
CORE_TOTP_ISSUER=""
@@ -150,8 +146,3 @@ CORE_RATELIMIT_ENABLED="false"
CORE_RATELIMIT_LIMIT="10"
CORE_RATELIMIT_BURST="30"
CORE_RATELIMIT_EXPIRES="10m"
-CORE_PUBLISHERCONFIG_ENABLED="false"
-CORE_PUBLISHERCONFIG_APPNAME="openlane"
-CORE_PUBLISHERCONFIG_ADDRESS="localhost:10000"
-CORE_PUBLISHERCONFIG_ADDRESSES="[localhost:10000]"
-CORE_PUBLISHERCONFIG_DEBUG="false"
diff --git a/config/config-dev.example.yaml b/config/config-dev.example.yaml
index d57fcefa..4f3e2ab1 100644
--- a/config/config-dev.example.yaml
+++ b/config/config-dev.example.yaml
@@ -9,14 +9,24 @@ server:
# tls settings
tls:
enabled: false
+
+# dbx settings
+dbx:
+ enabled: false
+
# db settings
db:
debug: true
- driverName: postgres
+ driverName: pgx
primaryDbSource: "postgres://postgres:password@0.0.0.0:5432/core?sslmode=disable"
multiWrite: false
migrationProvider: "goose"
+ runMigrations: true
enableHistory: true
+
+jobQueue:
+ connectionURI: "postgres://postgres:password@0.0.0.0:5432/jobs?sslmode=disable"
+
# auth settings
auth:
enabled: true
@@ -48,6 +58,7 @@ auth:
relyingPartyId: "localhost"
requestOrigins:
- "http://localhost:3001"
+
# authz settings
authz:
enabled: true
@@ -61,22 +72,22 @@ authz:
sessions:
encryptionKey: encryptionsecret
signingKey: my-signing-secret
+
# email settings
email:
- testing: true
- archive: "fixtures/email"
- sendGridApiKey: "SG.FakeAPIKey"
- consoleUrl:
- consoleBase: "http://localhost:17608/"
-# analytics settings
-posthog:
- enabled: false
- apiKey: "phc_FakeKey"
-publisherConfig:
- appName: openlane
- addresses:
- - localhost:10000
- enabled: true
+ companyAddress: 5150 Broadway St · San Antonio, TX 78209
+ companyName: Openlane
+ corporation: theopenlane, Inc.
+ fromEmail: no-reply@mail.theopenlane.io
+ supportEmail: support@theopenlane.io
+ urls:
+ verifySubscriber: https://www.theopenlane.io/subscribe
+ verify: https://console.theopenlane.io/verify
+ reset: https://console.theopenlane.io/password-reset
+ invite: https://console.theopenlane.io/invite
+ root: https://www.theopenlane.io
+ docs: https://docs.theopenlane.io
+ product: https://console.theopenlane.io
entConfig:
entityTypes:
diff --git a/config/config.example.yaml b/config/config.example.yaml
index 593ff8d9..90e936f0 100644
--- a/config/config.example.yaml
+++ b/config/config.example.yaml
@@ -55,49 +55,57 @@ db:
cacheTTL: 1000000000
databaseName: openlane
debug: false
- driverName: libsql
+ driverName: pgx
enableHistory: false
migrationProvider: atlas
multiWrite: false
primaryDbSource: file:openlane.db
runMigrations: true
secondaryDbSource: file:backup.db
-dbx:
- baseUrl: http://localhost:1337
- debug: false
- enabled: true
- endpoint: query
email:
- adminEmail: admins@theopenlane.io
- archive: ""
- consoleUrl:
- consoleBase: https://console.theopenlane.io
- invite: /invite
- reset: /password-reset
- verify: /verify
- fromEmail: no-reply@theopenlane.io
- listId: ""
- marketingUrl:
- marketingBase: https://www.theopenlane.io
- subscriberVerify: /verify
- sendGridApiKey: ""
- testing: true
+ companyAddress: ""
+ companyName: ""
+ corporation: ""
+ fromEmail: ""
+ logoURL: ""
+ supportEmail: ""
+ urls:
+ docs: ""
+ invite: ""
+ product: ""
+ reset: ""
+ root: ""
+ verify: ""
+ verifySubscriber: ""
entConfig:
entityTypes: null
flags:
useListObjectServices: false
useListUserService: true
-posthog:
- apiKey: ""
- enabled: false
- host: https://app.posthog.com
-publisherConfig:
- address: localhost:10000
- addresses:
- - localhost:10000
- appName: openlane
- debug: false
- enabled: false
+jobQueue:
+ connectionURI: ""
+ riverConf:
+ AdvisoryLockPrefix: 0
+ CancelledJobRetentionPeriod: 0
+ CompletedJobRetentionPeriod: 0
+ DiscardedJobRetentionPeriod: 0
+ ErrorHandler: null
+ FetchCooldown: 0
+ FetchPollInterval: 0
+ ID: ""
+ JobCleanerTimeout: 0
+ JobTimeout: 0
+ Logger: null
+ MaxAttempts: 0
+ PeriodicJobs: null
+ PollOnly: false
+ Queues: null
+ ReindexerSchedule: null
+ RescueStuckJobsAfter: 0
+ RetryPolicy: null
+ TestOnly: false
+ Workers: null
+ runMigrations: false
ratelimit:
burst: 30
enabled: false
diff --git a/config/config.go b/config/config.go
index 51527cc2..4364a940 100644
--- a/config/config.go
+++ b/config/config.go
@@ -11,12 +11,12 @@ import (
"github.com/knadh/koanf/v2"
"github.com/mcuadros/go-defaults"
"github.com/theopenlane/beacon/otelx"
- dbx "github.com/theopenlane/dbx/pkg/dbxclient"
+ "github.com/theopenlane/emailtemplates"
"github.com/theopenlane/entx"
"github.com/theopenlane/iam/fgax"
+ "github.com/theopenlane/riverboat/pkg/riverqueue"
"github.com/theopenlane/iam/totp"
- "github.com/theopenlane/utils/emails"
"github.com/theopenlane/iam/sessions"
"github.com/theopenlane/iam/tokens"
@@ -25,8 +25,6 @@ import (
"github.com/theopenlane/core/internal/ent/entconfig"
"github.com/theopenlane/core/internal/httpserve/handlers"
- "github.com/theopenlane/core/pkg/analytics/posthog"
- "github.com/theopenlane/core/pkg/events/kafka/kafkaconfig"
"github.com/theopenlane/core/pkg/middleware/cachecontrol"
"github.com/theopenlane/core/pkg/middleware/cors"
"github.com/theopenlane/core/pkg/middleware/mime"
@@ -53,24 +51,20 @@ type Config struct {
Authz fgax.Config `json:"authz" koanf:"authz"`
// DB contains the database configuration for the ent client
DB entx.Config `json:"db" koanf:"db"`
- // DBx contains the dbx client configuration
- DBx dbx.Config `json:"dbx" koanf:"dbx"`
+ // JobQueue contains the configuration for the job queue (river) client
+ JobQueue riverqueue.Config `json:"jobQueue" koanf:"jobQueue"`
// Redis contains the redis configuration for the key-value store
Redis cache.Config `json:"redis" koanf:"redis"`
// Tracer contains the tracing config for opentelemetry
Tracer otelx.Config `json:"tracer" koanf:"tracer"`
// Email contains email sending configuration for the server
- Email emails.Config `json:"email" koanf:"email"`
+ Email emailtemplates.Config `json:"email" koanf:"email"`
// Sessions config for user sessions and cookies
Sessions sessions.Config `json:"sessions" koanf:"sessions"`
- // PostHog contains the configuration for the PostHog analytics
- PostHog posthog.Config `json:"posthog" koanf:"posthog"`
// TOTP contains the configuration for the TOTP provider
TOTP totp.Config `json:"totp" koanf:"totp"`
// Ratelimit contains the configuration for the rate limiter
Ratelimit ratelimit.Config `json:"ratelimit" koanf:"ratelimit"`
- // EventPublisher contains the configuration for the event publisher
- Events kafkaconfig.Config `json:"publisherConfig" koanf:"publisherConfig"`
}
// Server settings for the echo server
diff --git a/config/configmap.yaml b/config/configmap.yaml
index 7936c4f1..16f51141 100644
--- a/config/configmap.yaml
+++ b/config/configmap.yaml
@@ -97,7 +97,7 @@ data:
CORE_AUTHZ_CREDENTIALS_SCOPES: {{ .Values.core.authz.credentials.scopes }}
CORE_DB_DEBUG: {{ .Values.core.db.debug | default false }}
CORE_DB_DATABASENAME: {{ .Values.core.db.databaseName | default "openlane" }}
- CORE_DB_DRIVERNAME: {{ .Values.core.db.driverName | default "libsql" }}
+ CORE_DB_DRIVERNAME: {{ .Values.core.db.driverName | default "pgx" }}
CORE_DB_MULTIWRITE: {{ .Values.core.db.multiWrite | default false }}
CORE_DB_PRIMARYDBSOURCE: {{ .Values.core.db.primaryDbSource | default "file:openlane.db" }}
CORE_DB_SECONDARYDBSOURCE: {{ .Values.core.db.secondaryDbSource | default "file:backup.db" }}
@@ -105,10 +105,8 @@ data:
CORE_DB_RUNMIGRATIONS: {{ .Values.core.db.runMigrations | default true }}
CORE_DB_MIGRATIONPROVIDER: {{ .Values.core.db.migrationProvider | default "atlas" }}
CORE_DB_ENABLEHISTORY: {{ .Values.core.db.enableHistory | default false }}
- CORE_DBX_ENABLED: {{ .Values.core.dbx.enabled | default true }}
- CORE_DBX_BASEURL: {{ .Values.core.dbx.baseUrl | default "http://localhost:1337" }}
- CORE_DBX_ENDPOINT: {{ .Values.core.dbx.endpoint | default "query" }}
- CORE_DBX_DEBUG: {{ .Values.core.dbx.debug | default false }}
+ CORE_JOBQUEUE_CONNECTIONURI: {{ .Values.core.jobQueue.connectionURI }}
+ CORE_JOBQUEUE_RUNMIGRATIONS: {{ .Values.core.jobQueue.runMigrations | default false }}
CORE_REDIS_ENABLED: {{ .Values.core.redis.enabled | default true }}
CORE_REDIS_ADDRESS: {{ .Values.core.redis.address | default "localhost:6379" }}
CORE_REDIS_NAME: {{ .Values.core.redis.name | default "openlane" }}
@@ -133,24 +131,22 @@ data:
CORE_TRACER_OTLP_HEADERS: {{ .Values.core.tracer.otlp.headers }}
CORE_TRACER_OTLP_COMPRESSION: {{ .Values.core.tracer.otlp.compression }}
CORE_TRACER_OTLP_TIMEOUT: {{ .Values.core.tracer.otlp.timeout | default "10s" }}
- CORE_EMAIL_SENDGRIDAPIKEY: {{ .Values.core.email.sendGridApiKey }}
- CORE_EMAIL_FROMEMAIL: {{ .Values.core.email.fromEmail | default "no-reply@theopenlane.io" }}
- CORE_EMAIL_TESTING: {{ .Values.core.email.testing | default true }}
- CORE_EMAIL_ARCHIVE: {{ .Values.core.email.archive }}
- CORE_EMAIL_LISTID: {{ .Values.core.email.listId }}
- CORE_EMAIL_ADMINEMAIL: {{ .Values.core.email.adminEmail | default "admins@theopenlane.io" }}
- CORE_EMAIL_CONSOLEURL_CONSOLEBASE: {{ .Values.core.email.consoleUrl.consoleBase | default "https://console.theopenlane.io" }}
- CORE_EMAIL_CONSOLEURL_VERIFY: {{ .Values.core.email.consoleUrl.verify | default "/verify" }}
- CORE_EMAIL_CONSOLEURL_INVITE: {{ .Values.core.email.consoleUrl.invite | default "/invite" }}
- CORE_EMAIL_CONSOLEURL_RESET: {{ .Values.core.email.consoleUrl.reset | default "/password-reset" }}
- CORE_EMAIL_MARKETINGURL_MARKETINGBASE: {{ .Values.core.email.marketingUrl.marketingBase | default "https://www.theopenlane.io" }}
- CORE_EMAIL_MARKETINGURL_SUBSCRIBERVERIFY: {{ .Values.core.email.marketingUrl.subscriberVerify | default "/verify" }}
+ CORE_EMAIL_COMPANYNAME: {{ .Values.core.email.companyName }}
+ CORE_EMAIL_COMPANYADDRESS: {{ .Values.core.email.companyAddress }}
+ CORE_EMAIL_CORPORATION: {{ .Values.core.email.corporation }}
+ CORE_EMAIL_FROMEMAIL: {{ .Values.core.email.fromEmail }}
+ CORE_EMAIL_SUPPORTEMAIL: {{ .Values.core.email.supportEmail }}
+ CORE_EMAIL_LOGOURL: {{ .Values.core.email.logoURL }}
+ CORE_EMAIL_URLS_ROOT: {{ .Values.core.email.urls.root }}
+ CORE_EMAIL_URLS_PRODUCT: {{ .Values.core.email.urls.product }}
+ CORE_EMAIL_URLS_DOCS: {{ .Values.core.email.urls.docs }}
+ CORE_EMAIL_URLS_VERIFY: {{ .Values.core.email.urls.verify }}
+ CORE_EMAIL_URLS_INVITE: {{ .Values.core.email.urls.invite }}
+ CORE_EMAIL_URLS_RESET: {{ .Values.core.email.urls.reset }}
+ CORE_EMAIL_URLS_VERIFYSUBSCRIBER: {{ .Values.core.email.urls.verifySubscriber }}
CORE_SESSIONS_SIGNINGKEY: {{ .Values.core.sessions.signingKey | default "my-signing-secret" }}
CORE_SESSIONS_ENCRYPTIONKEY: {{ .Values.core.sessions.encryptionKey | default "encryptionsecret" }}
CORE_SESSIONS_DOMAIN: {{ .Values.core.sessions.domain }}
- CORE_POSTHOG_ENABLED: {{ .Values.core.posthog.enabled | default false }}
- CORE_POSTHOG_APIKEY: {{ .Values.core.posthog.apiKey }}
- CORE_POSTHOG_HOST: {{ .Values.core.posthog.host | default "https://app.posthog.com" }}
CORE_TOTP_ENABLED: {{ .Values.core.totp.enabled | default true }}
CORE_TOTP_CODELENGTH: {{ .Values.core.totp.codeLength | default 6 }}
CORE_TOTP_ISSUER: {{ .Values.core.totp.issuer }}
@@ -162,8 +158,3 @@ data:
CORE_RATELIMIT_LIMIT: {{ .Values.core.ratelimit.limit | default 10 }}
CORE_RATELIMIT_BURST: {{ .Values.core.ratelimit.burst | default 30 }}
CORE_RATELIMIT_EXPIRES: {{ .Values.core.ratelimit.expires | default "10m" }}
- CORE_PUBLISHERCONFIG_ENABLED: {{ .Values.core.publisherConfig.enabled | default false }}
- CORE_PUBLISHERCONFIG_APPNAME: {{ .Values.core.publisherConfig.appName | default "openlane" }}
- CORE_PUBLISHERCONFIG_ADDRESS: {{ .Values.core.publisherConfig.address | default "localhost:10000" }}
- CORE_PUBLISHERCONFIG_ADDRESSES: {{ .Values.core.publisherConfig.addresses | default "localhost:10000" }}
- CORE_PUBLISHERCONFIG_DEBUG: {{ .Values.core.publisherConfig.debug | default false }}
diff --git a/db/README.md b/db/README.md
index b3d837ae..04d088a3 100644
--- a/db/README.md
+++ b/db/README.md
@@ -26,7 +26,7 @@
```yaml
db:
debug: true
- driver_name: postgres
+ driver_name: pgx # or `postgres` to use lib/pg instead
primary_db_source: "postgres://postgres:password@postgres:5432?sslmode=disable"
run_migrations: true
```
diff --git a/docker/Taskfile.yaml b/docker/Taskfile.yaml
index 3b9bced7..9c5c5802 100644
--- a/docker/Taskfile.yaml
+++ b/docker/Taskfile.yaml
@@ -18,7 +18,7 @@ tasks:
desc: brings up the compose environment for the core server
deps: [build]
cmds:
- - "docker compose -f ./docker/docker-compose-redis.yml -f ./docker/docker-compose-fga.yml -f ./docker/docker-compose-kafka.yml -f ./docker/docker-compose.yml -p core up -d"
+ - "docker compose -f ./docker/docker-compose-redis.yml -f ./docker/docker-compose-fga.yml -f ./docker/docker-compose-riverboat.yml -f ./docker/docker-compose.yml -p core up -d"
core:down:
dir: ..
@@ -51,6 +51,23 @@ tasks:
cmds:
- "docker compose -p redis down"
+ riverboat:
+ dir: ..
+ desc: brings up the compose environment for riverboat
+ env:
+ RIVERBOAT_TAG: "{{.RIVERBOAT_TAG}}"
+ vars:
+ RIVERBOAT_TAG:
+ sh: "uname=$(uname -m); if [ $uname = 'x86_64' ]; then echo 'amd64-latest'; else echo 'arm64-latest'; fi"
+ cmds:
+ - "docker compose -f ./docker/docker-compose-riverboat.yml -p riverboat up -d"
+
+ riverboat:down:
+ dir: ..
+ desc: brings the riverboat compose environment down
+ cmds:
+ - docker compose -p riverboat down
+
postgres:
dir: ..
desc: brings up the compose environment for postgres development
diff --git a/docker/all-in-one/Dockerfile.all-in-one b/docker/all-in-one/Dockerfile.all-in-one
index 3c434501..31dbad6d 100644
--- a/docker/all-in-one/Dockerfile.all-in-one
+++ b/docker/all-in-one/Dockerfile.all-in-one
@@ -17,6 +17,9 @@ COPY --from=builder /go/bin/core /bin/core
# Copy the dbx binary
COPY --from=ghcr.io/theopenlane/dbx:5-35840501 /bin/dbx /bin/dbx
+# Copy the riverboat binary
+COPY --from=ghcr.io/theopenlane/riverboat:amd64-latest /bin/riverboat /bin/riverboat
+
# Copy redis binary
COPY --from=redis:7.4.0 /usr/local/bin/redis-server /bin/redis-server
diff --git a/docker/all-in-one/docker_entrypoint.sh b/docker/all-in-one/docker_entrypoint.sh
index 34128e5d..510ea1bc 100644
--- a/docker/all-in-one/docker_entrypoint.sh
+++ b/docker/all-in-one/docker_entrypoint.sh
@@ -19,5 +19,8 @@ if [ $CORE_DBX_ENABLED = "true" ]; then
/bin/dbx serve --debug --pretty &!
fi
+# run the riverboat service in the background
+/bin/riverboat serve --debug --pretty &!
+
# run the core service in the foreground
/bin/core serve --debug --pretty
\ No newline at end of file
diff --git a/docker/docker-compose-pg.yml b/docker/docker-compose-pg.yml
index 6e10c78a..bba5e6fa 100644
--- a/docker/docker-compose-pg.yml
+++ b/docker/docker-compose-pg.yml
@@ -11,7 +11,7 @@ services:
volumes:
- ./pg-init-scripts:/docker-entrypoint-initdb.d
healthcheck:
- test: ["CMD-SHELL", "pg_isready -U postgres"]
+ test: [ "CMD-SHELL", "pg_isready -U postgres" ]
interval: 5s
timeout: 5s
retries: 5
@@ -19,7 +19,7 @@ services:
- default
postgres-exporter:
- image: wrouesnel/postgres_exporter:v0.8.0
+ image: quay.io/prometheuscommunity/postgres-exporter:latest
restart: always
environment:
- DATA_SOURCE_URI=postgres:5432/openfga?sslmode=disable
diff --git a/docker/docker-compose-riverboat.yml b/docker/docker-compose-riverboat.yml
new file mode 100644
index 00000000..19bfcd59
--- /dev/null
+++ b/docker/docker-compose-riverboat.yml
@@ -0,0 +1,18 @@
+services:
+ riverboat:
+ # the taskfile will set the tag based on the architecture, if you are running on x86_64 it will use the amd64-latest tag
+ # if you run without the taskfile and the env var set it will default to arm64-latest
+ # image: ghcr.io/theopenlane/riverboat:${RIVERBOAT_TAG:-arm64-latest}
+ image: ghcr.io/theopenlane/riverboat:arm64-78-90832455
+ container_name: riverboat
+ environment:
+ # this needs to use host.docker.internal since it is a seperate docker-compose file
+ - RIVERBOAT_JOBQUEUE_DATABASEHOST=postgres://postgres:password@host.docker.internal:5432/jobs?sslmode=disable
+ - RIVERBOAT_RUNMIGRATIONS=true
+ command:
+ - serve
+ - --debug
+ - --pretty
+ networks:
+ - default
+ restart: unless-stopped # allow it to keep trying if postgres is not up yet
diff --git a/docker/pg-init-scripts/init.sql b/docker/pg-init-scripts/init.sql
index d3c4dca5..82f98ac9 100644
--- a/docker/pg-init-scripts/init.sql
+++ b/docker/pg-init-scripts/init.sql
@@ -4,4 +4,8 @@ GRANT ALL PRIVILEGES ON DATABASE openfga TO postgres;
CREATE DATABASE core;
-GRANT ALL PRIVILEGES ON DATABASE core TO postgres;
\ No newline at end of file
+GRANT ALL PRIVILEGES ON DATABASE core TO postgres;
+
+CREATE DATABASE jobs;
+
+GRANT ALL PRIVILEGES ON DATABASE jobs TO postgres;
\ No newline at end of file
diff --git a/go.mod b/go.mod
index 7a4f4b62..24d96935 100644
--- a/go.mod
+++ b/go.mod
@@ -8,13 +8,11 @@ require (
entgo.io/ent v0.14.1
github.com/99designs/gqlgen v0.17.54
github.com/99designs/keyring v1.2.2
- github.com/IBM/sarama v1.43.3
github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2
github.com/Yamashou/gqlgenc v0.25.2
github.com/alicebob/miniredis/v2 v2.33.0
github.com/alitto/pond v1.9.2
github.com/brianvoe/gofakeit/v7 v7.0.4
- github.com/cenkalti/backoff/v4 v4.3.0
github.com/dustinkirkland/golang-petname v0.0.0-20240428194347-eebcea082ee0
github.com/gertd/go-pluralize v0.2.1
github.com/getkin/kin-openapi v0.127.0
@@ -27,6 +25,7 @@ require (
github.com/hashicorp/go-multierror v1.1.1
github.com/invopop/jsonschema v0.12.0
github.com/invopop/yaml v0.3.1
+ github.com/jackc/pgx/v5 v5.7.1
github.com/knadh/koanf/parsers/yaml v0.1.0
github.com/knadh/koanf/providers/env v1.0.0
github.com/knadh/koanf/providers/file v1.1.0
@@ -39,27 +38,28 @@ require (
github.com/nyaruka/phonenumbers v1.4.0
github.com/oklog/ulid/v2 v2.1.0
github.com/openfga/go-sdk v0.6.1
- github.com/panta/machineid v1.0.2
github.com/pkg/errors v0.9.1
- github.com/posthog/posthog-go v1.2.24
github.com/pressly/goose/v3 v3.22.1
github.com/prometheus/client_golang v1.20.4
- github.com/rShetty/asyncwait v0.0.0-20180203043142-1e02703eb90e
github.com/ravilushqa/otelgqlgen v0.17.0
github.com/redis/go-redis/v9 v9.6.1
+ github.com/riverqueue/river v0.12.1
+ github.com/riverqueue/river/riverdriver/riverpgxv5 v0.12.1
github.com/rs/zerolog v1.33.0
github.com/samber/lo v1.47.0
github.com/spf13/cobra v1.8.1
github.com/stoewer/go-strcase v1.3.0
github.com/stretchr/testify v1.9.0
github.com/theopenlane/beacon v0.1.0
- github.com/theopenlane/dbx v0.1.2
github.com/theopenlane/echo-prometheus v0.1.0
github.com/theopenlane/echox v0.2.0
- github.com/theopenlane/entx v0.2.1
+ github.com/theopenlane/emailtemplates v0.1.1
+ github.com/theopenlane/entx v0.2.2
github.com/theopenlane/gqlgen-plugins v0.2.0
github.com/theopenlane/httpsling v0.2.1
github.com/theopenlane/iam v0.2.0
+ github.com/theopenlane/newman v0.1.1
+ github.com/theopenlane/riverboat v0.0.4
github.com/theopenlane/utils v0.2.1
github.com/vektah/gqlparser/v2 v2.5.17
github.com/wundergraph/graphql-go-tools v1.67.4
@@ -86,11 +86,13 @@ require (
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 // indirect
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
+ github.com/aymerick/douceur v0.2.0 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/boombuler/barcode v1.0.2 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
+ github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/coder/websocket v1.8.12 // indirect
@@ -105,9 +107,6 @@ require (
github.com/docker/go-units v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/dvsekhvalnov/jose2go v1.7.0 // indirect
- github.com/eapache/go-resiliency v1.7.0 // indirect
- github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect
- github.com/eapache/queue v1.1.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/envoyproxy/protoc-gen-validate v1.1.0 // indirect
github.com/fatih/color v1.17.0 // indirect
@@ -128,7 +127,6 @@ require (
github.com/goccy/go-json v0.10.3 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
- github.com/golang/snappy v0.0.4 // indirect
github.com/google/cel-go v0.21.0 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-github/v64 v64.0.0 // indirect
@@ -137,24 +135,18 @@ require (
github.com/google/s2a-go v0.1.8 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
+ github.com/gorilla/css v1.0.1 // indirect
github.com/gorilla/securecookie v1.1.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
- github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/hcl/v2 v2.22.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
- github.com/jackc/pgx/v5 v5.7.1 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
- github.com/jcmturner/aescts/v2 v2.0.0 // indirect
- github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
- github.com/jcmturner/gofork v1.7.6 // indirect
- github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect
- github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/karlseguin/ccache/v3 v3.0.5 // indirect
github.com/klauspost/compress v1.17.9 // indirect
@@ -171,6 +163,7 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mfridman/interpolate v0.0.2 // indirect
+ github.com/microcosm-cc/bluemonday v1.0.27 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/hashstructure v1.1.0 // indirect
@@ -193,21 +186,21 @@ require (
github.com/ory/dockertest v3.3.5+incompatible // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/perimeterx/marshmallow v1.1.5 // indirect
- github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/pquerna/otp v1.4.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.57.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
- github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
+ github.com/resend/resend-go/v2 v2.11.0 // indirect
+ github.com/riverqueue/river/riverdriver v0.12.1 // indirect
+ github.com/riverqueue/river/rivershared v0.12.1 // indirect
+ github.com/riverqueue/river/rivertype v0.12.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/segmentio/asm v1.2.0 // indirect
- github.com/sendgrid/rest v2.6.9+incompatible // indirect
- github.com/sendgrid/sendgrid-go v3.16.0+incompatible // indirect
github.com/sethvargo/go-retry v0.3.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sosodev/duration v1.3.1 // indirect
@@ -218,6 +211,11 @@ require (
github.com/spf13/viper v1.19.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
+ github.com/theopenlane/dbx v0.1.2 // indirect
+ github.com/tidwall/gjson v1.17.3 // indirect
+ github.com/tidwall/match v1.1.1 // indirect
+ github.com/tidwall/pretty v1.2.1 // indirect
+ github.com/tidwall/sjson v1.2.5 // indirect
github.com/tursodatabase/libsql-client-go v0.0.0-20240902231107-85af5b9d094d // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/urfave/cli/v2 v2.27.4 // indirect
@@ -242,6 +240,7 @@ require (
go.opentelemetry.io/otel/sdk v1.30.0 // indirect
go.opentelemetry.io/otel/trace v1.30.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
+ go.uber.org/goleak v1.3.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e // indirect
diff --git a/go.sum b/go.sum
index 12143563..a3a33692 100644
--- a/go.sum
+++ b/go.sum
@@ -32,8 +32,6 @@ github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg6
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
-github.com/IBM/sarama v1.43.3 h1:Yj6L2IaNvb2mRBop39N7mmJAHBVY3dTPncr3qGVkxPA=
-github.com/IBM/sarama v1.43.3/go.mod h1:FVIRaLrhK3Cla/9FfRF5X9Zua2KpS3SYIXxhac1H+FQ=
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw=
@@ -62,6 +60,8 @@ github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
+github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
+github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
@@ -126,12 +126,6 @@ github.com/dustinkirkland/golang-petname v0.0.0-20240428194347-eebcea082ee0 h1:a
github.com/dustinkirkland/golang-petname v0.0.0-20240428194347-eebcea082ee0/go.mod h1:8AuBTZBRSFqEYBPYULd+NN474/zZBLP+6WeT5S9xlAc=
github.com/dvsekhvalnov/jose2go v1.7.0 h1:bnQc8+GMnidJZA8zc6lLEAb4xNrIqHwO+9TzqvtQZPo=
github.com/dvsekhvalnov/jose2go v1.7.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU=
-github.com/eapache/go-resiliency v1.7.0 h1:n3NRTnBn5N0Cbi/IeOHuQn9s2UwVUH7Ga0ZWcP+9JTA=
-github.com/eapache/go-resiliency v1.7.0/go.mod h1:5yPzW0MIvSe0JDsv0v+DvcjEv2FyD6iZYSs1ZI+iQho=
-github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 h1:Oy0F4ALJ04o5Qqpdz8XLIpNA3WM/iSIXqxtqo7UGVws=
-github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3/go.mod h1:YvSRo5mw33fLEx1+DlK6L2VV43tJt5Eyel9n9XBcR+0=
-github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
-github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
@@ -144,8 +138,6 @@ github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
-github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
-github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
@@ -213,8 +205,6 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
-github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
-github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/cel-go v0.21.0 h1:cl6uW/gxN+Hy50tNYvI691+sXxioCnstFzLp2WO4GCI=
github.com/google/cel-go v0.21.0/go.mod h1:rHUlWCcBKgyEk+eV03RPdZUekPp6YcJwV0FxuUksYxc=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
@@ -247,10 +237,10 @@ github.com/googleapis/enterprise-certificate-proxy v0.3.4 h1:XYIDZApgAnrN1c855gT
github.com/googleapis/enterprise-certificate-proxy v0.3.4/go.mod h1:YKe7cfqYXjKGpGvmSg28/fFvhNzinZQm8DGnaburhGA=
github.com/googleapis/gax-go/v2 v2.13.0 h1:yitjD5f7jQHhyDsnhKEBU52NdvvdSeGzlAnDPT0hH1s=
github.com/googleapis/gax-go/v2 v2.13.0/go.mod h1:Z/fvTZXF8/uw7Xu5GuslPw+bplx6SS338j1Is2S+B7A=
-github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
+github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
+github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0=
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo=
-github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gotestyourself/gotestyourself v2.2.0+incompatible h1:AQwinXlbQR2HvPjQZOmDhRqsv5mZf+Jb1RnSLxcqZcI=
@@ -268,9 +258,6 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU=
github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk=
-github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
-github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
-github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
@@ -285,6 +272,8 @@ github.com/invopop/jsonschema v0.12.0 h1:6ovsNSuvn9wEQVOyc72aycBMVQFKz7cPdMJn10C
github.com/invopop/jsonschema v0.12.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0=
github.com/invopop/yaml v0.3.1 h1:f0+ZpmhfBSS4MhG+4HYseMdJhoeeopbSKbq5Rpeelso=
github.com/invopop/yaml v0.3.1/go.mod h1:PMOp3nn4/12yEZUFfmOuNHJsZToEEOwoWsT+D81KkeA=
+github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa h1:s+4MhCQ6YrzisK6hFJUX53drDT4UsSW3DEhKn0ifuHw=
+github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa/go.mod h1:a/s9Lp5W7n/DD0VrVoyJ00FbP2ytTPDVOivvn2bMlds=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
@@ -295,18 +284,6 @@ github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jarcoal/httpmock v1.3.1 h1:iUx3whfZWVf3jT01hQTO/Eo5sAYtB2/rqaUuOtpInww=
github.com/jarcoal/httpmock v1.3.1/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg=
-github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8=
-github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs=
-github.com/jcmturner/dnsutils/v2 v2.0.0 h1:lltnkeZGL0wILNvrNiVCR6Ro5PGU/SeBvVO/8c/iPbo=
-github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM=
-github.com/jcmturner/gofork v1.7.6 h1:QH0l3hzAU1tfT3rZCnW5zXl+orbkNMMRGJfdJjHVETg=
-github.com/jcmturner/gofork v1.7.6/go.mod h1:1622LH6i/EZqLloHfE7IeZ0uEJwMSUyQ/nDd82IeqRo=
-github.com/jcmturner/goidentity/v6 v6.0.1 h1:VKnZd2oEIMorCTsFBnJWbExfNN7yZr3EhJAxwOkZg6o=
-github.com/jcmturner/goidentity/v6 v6.0.1/go.mod h1:X1YW3bgtvwAXju7V3LCIMpY0Gbxyjn/mY9zx4tFonSg=
-github.com/jcmturner/gokrb5/v8 v8.4.4 h1:x1Sv4HaTpepFkXbt2IkL29DXRf8sOfZXo8eRKh687T8=
-github.com/jcmturner/gokrb5/v8 v8.4.4/go.mod h1:1btQEpgT6k+unzCwX1KdWMEwPPkkgBtP+F6aCACiMrs=
-github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZY=
-github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc=
github.com/jensneuse/diffview v1.0.0 h1:4b6FQJ7y3295JUHU3tRko6euyEboL825ZsXeZZM47Z4=
github.com/jensneuse/diffview v1.0.0/go.mod h1:i6IacuD8LnEaPuiyzMHA+Wfz5mAuycMOf3R/orUY9y4=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
@@ -370,6 +347,8 @@ github.com/mcuadros/go-defaults v1.2.0 h1:FODb8WSf0uGaY8elWJAkoLL0Ri6AlZ1bFlenk5
github.com/mcuadros/go-defaults v1.2.0/go.mod h1:WEZtHEVIGYVDqkKSWBdWKUVdRyKlMfulPaGDWIVeCWY=
github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY=
github.com/mfridman/interpolate v0.0.2/go.mod h1:p+7uk6oE07mpE/Ik1b8EckO0O4ZXiGAfshKBWLUM9Xg=
+github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
+github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
@@ -423,22 +402,16 @@ github.com/openfga/openfga v1.6.1 h1:I4xlmmaFbi1Z2otdZs22D6kr3O1n4WFQLjFZeJQmEkE
github.com/openfga/openfga v1.6.1/go.mod h1:nfldf6oWZWKOXKc8NHy7VDWUd3wil8JtXLSh89aARng=
github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA=
github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs=
-github.com/panta/machineid v1.0.2 h1:LVYeEq1hZ+FwcM+/H6eB8KfXM2R5b2h1SWdnWwZ0OQw=
-github.com/panta/machineid v1.0.2/go.mod h1:AROj156fsca3R3rNw3q9h8xFkos25W9P0ZG9gu+3Uf0=
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s=
github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw=
-github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
-github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/posthog/posthog-go v1.2.24 h1:A+iG4saBJemo++VDlcWovbYf8KFFNUfrCoJtsc40RPA=
-github.com/posthog/posthog-go v1.2.24/go.mod h1:uYC2l1Yktc8E+9FAHJ9QZG4vQf/NHJPD800Hsm7DzoM=
github.com/pquerna/otp v1.4.0 h1:wZvl1TIVxKRThZIBiwOOHOGP/1+nZyWBil9Y2XNEDzg=
github.com/pquerna/otp v1.4.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1AEg=
github.com/pressly/goose/v3 v3.22.1 h1:2zICEfr1O3yTP9BRZMGPj7qFxQ+ik6yeo+z1LMuioLc=
@@ -452,19 +425,31 @@ github.com/prometheus/common v0.57.0 h1:Ro/rKjwdq9mZn1K5QPctzh+MA4Lp0BuYk5ZZEVho
github.com/prometheus/common v0.57.0/go.mod h1:7uRPFSUTbfZWsJ7MHY56sqt7hLQu3bxXHDnNhl8E9qI=
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
-github.com/rShetty/asyncwait v0.0.0-20180203043142-1e02703eb90e h1:JGv2d5lATeXBDtgpLKS7emfoBGh8H+LNDqm94kRozIc=
-github.com/rShetty/asyncwait v0.0.0-20180203043142-1e02703eb90e/go.mod h1:YNFw1n0p4qcSXP3vvmzYGzFIeCukWn2NGmwWrYBPQS8=
github.com/ravilushqa/otelgqlgen v0.17.0 h1:bLwQfKqtj9P24QpjM2sc1ipBm5Fqv2u7DKN5LIpj3g8=
github.com/ravilushqa/otelgqlgen v0.17.0/go.mod h1:orOIikuYsay1y3CmLgd5gsHcT9EsnXwNKmkAplzzYXQ=
-github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM=
-github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4=
github.com/redis/go-redis/v9 v9.6.1/go.mod h1:0C0c6ycQsdpVNQpxb1njEQIqkx5UcsM8FJCQLgE9+RA=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
+github.com/resend/resend-go/v2 v2.11.0 h1:Ja5eXizUCbvyLgbiP8sFsJW/UN1b7d6IEUqi80IlgiU=
+github.com/resend/resend-go/v2 v2.11.0/go.mod h1:ihnxc7wPpSgans8RV8d8dIF4hYWVsqMK5KxXAr9LIos=
+github.com/riverqueue/river v0.12.1 h1:TS3FVioPStlvb7yj1dYgtgX+zn/3JkLdPn+S6qNBcZ0=
+github.com/riverqueue/river v0.12.1/go.mod h1:j7O42JlHo76YgXkAFX66E63Ke890/oSUUlui/ImyLuU=
+github.com/riverqueue/river/riverdriver v0.12.1 h1:MqAh6mw9h/m/nNXImJTXXtCefTDPdmZSlgsUdSYUHe0=
+github.com/riverqueue/river/riverdriver v0.12.1/go.mod h1:E4hf4wPidG0xYrwsez4R9u4LvLdjlDu9m4iJFpb1DfQ=
+github.com/riverqueue/river/riverdriver/riverdatabasesql v0.12.1 h1:E2pYemeaaiqOqr1x1Cq872IdulGu5z/iIHChqxPJwfA=
+github.com/riverqueue/river/riverdriver/riverdatabasesql v0.12.1/go.mod h1:+5DVUCfdPS3ZtsRm4V0GzQfXJI9MsFvq3BNqW/Nei3E=
+github.com/riverqueue/river/riverdriver/riverpgxv5 v0.12.1 h1:stodaBk+GKMU4Uwoj2tShG5L/EK/E5gWOQwZhsJ65QY=
+github.com/riverqueue/river/riverdriver/riverpgxv5 v0.12.1/go.mod h1:kwV0SdmvBYOj3hsI4sn3tQQQ5NqXrq68yDvKb1Jms1E=
+github.com/riverqueue/river/rivershared v0.12.1 h1:7y03CM6iYrSoT1k6ylneTIoK74qQ27yi1aoT3dozU6Y=
+github.com/riverqueue/river/rivershared v0.12.1/go.mod h1:IpJ63Jz/Rx61nKhJ45K9IdJR0VEHf3qnFlEPI9l11HM=
+github.com/riverqueue/river/rivertype v0.12.1 h1:iTciVhZ/yQQQBMAouivPrSlrQH8MEK5uCVtzu3eITu8=
+github.com/riverqueue/river/rivertype v0.12.1/go.mod h1:3WRQEDlLKZky/vGwFcZC3uKjC+/8izE6ucHwCsuir98=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
+github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
+github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
@@ -482,10 +467,6 @@ github.com/sebdah/goldie/v2 v2.5.3 h1:9ES/mNN+HNUbNWpVAlrzuZ7jE+Nrczbj8uFRjM7624
github.com/sebdah/goldie/v2 v2.5.3/go.mod h1:oZ9fp0+se1eapSRjfYbsV/0Hqhbuu3bJVvKI/NNtssI=
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
-github.com/sendgrid/rest v2.6.9+incompatible h1:1EyIcsNdn9KIisLW50MKwmSRSK+ekueiEMJ7NEoxJo0=
-github.com/sendgrid/rest v2.6.9+incompatible/go.mod h1:kXX7q3jZtJXK5c5qK83bSGMdV6tsOE70KbHoqJls4lE=
-github.com/sendgrid/sendgrid-go v3.16.0+incompatible h1:i8eE6IMkiCy7vusSdacHHSBUpXyTcTXy/Rl9N9aZ/Qw=
-github.com/sendgrid/sendgrid-go v3.16.0+incompatible/go.mod h1:QRQt+LX/NmgVEvmdRw0VT/QgUn499+iza2FnDca9fg8=
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah2SE=
@@ -514,7 +495,6 @@ github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpE
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
-github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
@@ -532,16 +512,32 @@ github.com/theopenlane/echo-prometheus v0.1.0 h1:1zMejBVHe5w4zLHS+k5FV9S/46QBiwO
github.com/theopenlane/echo-prometheus v0.1.0/go.mod h1:Eiiv1ZLXKMsteQ3T+H1tFfSSZuXSvQfZp95qr5hmGkA=
github.com/theopenlane/echox v0.2.0 h1:s9DJJrsLOSPsXVfgmQxgXmSVtxzztBnSmcVX4ax7tIM=
github.com/theopenlane/echox v0.2.0/go.mod h1:nfxwQpwvqYYI/pFHJKDs3/HLvjYKEGCih4XDgLSma64=
-github.com/theopenlane/entx v0.2.1 h1:hzNard/EpyiL/u990cM3x64f1Z2s8aMnkBD2bpcznig=
-github.com/theopenlane/entx v0.2.1/go.mod h1:JBQx4pOkpz+lfF7cAxDisae3+qNfxCQMaixE8iLtUWc=
+github.com/theopenlane/emailtemplates v0.1.1 h1:TMjGDokp4BKpghWMxfNlElqI3jaggwBf7XceENxyCJY=
+github.com/theopenlane/emailtemplates v0.1.1/go.mod h1:ZVTSMr+jKZZDH1IDTYBzR5nF/FPGt+IAPOJmet/WPi8=
+github.com/theopenlane/entx v0.2.2 h1:tUYxJQbG/W7kyCOF836GfLLB3agbdElxXV2qwlKA6L4=
+github.com/theopenlane/entx v0.2.2/go.mod h1:6TA516nQJ3p/Cn7QlbVouKpui2XPipj8OXb9/5iGDB8=
github.com/theopenlane/gqlgen-plugins v0.2.0 h1:0Kb2oJ3zcNlOCqveRjqeUVlwc8SMiLI7e4ii52hTkl8=
github.com/theopenlane/gqlgen-plugins v0.2.0/go.mod h1:PrZIGyqAr/Hqrka3UFOS6kquBl2TvL5vhZOL3d48/bU=
github.com/theopenlane/httpsling v0.2.1 h1:fWK6emqVOv/al4TamApcf/rNHfpWmobWl5nnxJr/9/A=
github.com/theopenlane/httpsling v0.2.1/go.mod h1:17xyZnSgSHHZISpYxqBhbztSNxz9ihZrmjyce3ShfRc=
github.com/theopenlane/iam v0.2.0 h1:TGFk4ToN6XVKQXJvyA2cNiVQfWmDnpDD9oV2B2qJndk=
github.com/theopenlane/iam v0.2.0/go.mod h1:8nPT57sPCoOzf5QeSbfEonDkZBTQpwIYnN8L8ibJbW8=
+github.com/theopenlane/newman v0.1.1 h1:pxGPRcy8kXQplfv4Sp1N3XUkWmx/scZvp7oj+y2l8wI=
+github.com/theopenlane/newman v0.1.1/go.mod h1:A37pInKEYsdvUmjQzTDv7x5T4KhMxoFW105DA3XvH4Y=
+github.com/theopenlane/riverboat v0.0.4 h1:4ADdCMIyArm3a8gW7EwmCbpX+Ti8hKHHgK6M79KS3YI=
+github.com/theopenlane/riverboat v0.0.4/go.mod h1:yvXaeXRnPGe8xHj08K6SlUHGQAnR72mDxK5VFFpu6sY=
github.com/theopenlane/utils v0.2.1 h1:T6VfvOQDcAXBa1NFVL4QCsCbHvVQkp6Tl4hGJVd7TwQ=
github.com/theopenlane/utils v0.2.1/go.mod h1:ydEtwhmEvkVt3KKmNqiQiSY5b3rKH7U4umZ3QbFDsxU=
+github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
+github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94=
+github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
+github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
+github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
+github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
+github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
+github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
+github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
+github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
github.com/tursodatabase/libsql-client-go v0.0.0-20240902231107-85af5b9d094d h1:dOMI4+zEbDI37KGb0TI44GUAwxHF9cMsIoDTJ7UmgfU=
github.com/tursodatabase/libsql-client-go v0.0.0-20240902231107-85af5b9d094d/go.mod h1:l8xTsYB90uaVdMHXMCxKKLSgw5wLYBwBKKefNIUnm9s=
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
@@ -566,7 +562,6 @@ github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
-github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
github.com/zclconf/go-cty v1.15.0 h1:tTCRWxsexYUmtt/wVxgDClUe+uQusuI443uL6e+5sXQ=
@@ -613,8 +608,6 @@ gocloud.dev v0.39.0 h1:EYABYGhAalPUaMrbSKOr5lejxoxvXj99nE8XFtsDgds=
gocloud.dev v0.39.0/go.mod h1:drz+VyYNBvrMTW0KZiBAYEdl8lbNZx+OQ7oQvdrFmSQ=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
-golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@@ -623,7 +616,6 @@ golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e/go.mod h1:akd2r19cwCdwSwWeId
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
-golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -631,13 +623,7 @@ golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73r
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
-golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
-golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
-golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
-golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
-golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
@@ -646,7 +632,6 @@ golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbht
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -654,29 +639,19 @@ golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
-golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
-golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
@@ -686,11 +661,8 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
-golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.25.0 h1:oFU9pkj/iJgs+0DT+VMHrx+oBKs/LJMV+Uvg78sl+fE=
golang.org/x/tools v0.25.0/go.mod h1:/vtpO8WL1N9cQC3FN5zPqb//fRXskFHbLKk4OW1Q7rg=
-golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 h1:LLhsEBxRTBLuKlQxFBYUOU8xyFgXv6cOTp2HASDlsDk=
golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
@@ -734,7 +706,6 @@ gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
-gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/internal/ent/entc.go b/internal/ent/entc.go
index 511ed7bb..0fabe6ac 100644
--- a/internal/ent/entc.go
+++ b/internal/ent/entc.go
@@ -11,22 +11,21 @@ import (
"entgo.io/contrib/entgql"
"entgo.io/ent/entc"
"entgo.io/ent/entc/gen"
+ "github.com/theopenlane/emailtemplates"
"github.com/theopenlane/iam/entfga"
"github.com/theopenlane/iam/fgax"
"gocloud.dev/secrets"
- dbx "github.com/theopenlane/dbx/pkg/dbxclient"
"github.com/theopenlane/entx"
"github.com/theopenlane/entx/genhooks"
"github.com/theopenlane/entx/history"
"github.com/theopenlane/iam/totp"
- "github.com/theopenlane/utils/emails"
- "github.com/theopenlane/utils/marionette"
"github.com/theopenlane/core/internal/ent/entconfig"
- "github.com/theopenlane/core/pkg/analytics"
"github.com/theopenlane/iam/sessions"
"github.com/theopenlane/iam/tokens"
+
+ _ "github.com/jackc/pgx/v5"
)
const (
@@ -75,6 +74,9 @@ func main() {
gen.FeatureNamedEdges,
gen.FeatureSchemaConfig,
gen.FeatureIntercept,
+ gen.FeatureModifier,
+ // this is disabled because it is not compatible with the entcache driver
+ // gen.FeatureExecQuery,
},
},
entc.Dependency(
@@ -98,25 +100,13 @@ func main() {
entc.DependencyType(&sessions.SessionConfig{}),
),
entc.Dependency(
- entc.DependencyName("Emails"),
- entc.DependencyType(&emails.EmailManager{}),
- ),
- entc.Dependency(
- entc.DependencyName("Marionette"),
- entc.DependencyType(&marionette.TaskManager{}),
- ),
- entc.Dependency(
- entc.DependencyName("Analytics"),
- entc.DependencyType(&analytics.EventManager{}),
+ entc.DependencyName("Emailer"),
+ entc.DependencyType(&emailtemplates.Config{}),
),
entc.Dependency(
entc.DependencyName("TOTP"),
entc.DependencyType(&totp.Manager{}),
),
- entc.Dependency(
- entc.DependencyName("DBx"),
- entc.DependencyType(&dbx.Client{}),
- ),
entc.TemplateDir("./internal/ent/templates"),
entc.Extensions(
gqlExt,
diff --git a/internal/ent/generated/apitoken/where.go b/internal/ent/generated/apitoken/where.go
index af0f16f8..6ea18e5e 100644
--- a/internal/ent/generated/apitoken/where.go
+++ b/internal/ent/generated/apitoken/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/apitoken_delete.go b/internal/ent/generated/apitoken_delete.go
index 49ca1734..d31c9ac8 100644
--- a/internal/ent/generated/apitoken_delete.go
+++ b/internal/ent/generated/apitoken_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/apitoken"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// APITokenDelete is the builder for deleting a APIToken entity.
diff --git a/internal/ent/generated/apitoken_query.go b/internal/ent/generated/apitoken_query.go
index a97c6032..09c91c08 100644
--- a/internal/ent/generated/apitoken_query.go
+++ b/internal/ent/generated/apitoken_query.go
@@ -13,10 +13,9 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/apitoken"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// APITokenQuery is the builder for querying APIToken entities.
@@ -27,8 +26,8 @@ type APITokenQuery struct {
inters []Interceptor
predicates []predicate.APIToken
withOwner *OrganizationQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*APIToken) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -284,8 +283,9 @@ func (atq *APITokenQuery) Clone() *APITokenQuery {
predicates: append([]predicate.APIToken{}, atq.predicates...),
withOwner: atq.withOwner.Clone(),
// clone intermediate query.
- sql: atq.sql.Clone(),
- path: atq.path,
+ sql: atq.sql.Clone(),
+ path: atq.path,
+ modifiers: append([]func(*sql.Selector){}, atq.modifiers...),
}
}
@@ -530,6 +530,9 @@ func (atq *APITokenQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(atq.schemaConfig.APIToken)
ctx = internal.NewSchemaConfigContext(ctx, atq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range atq.modifiers {
+ m(selector)
+ }
for _, p := range atq.predicates {
p(selector)
}
@@ -547,6 +550,12 @@ func (atq *APITokenQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (atq *APITokenQuery) Modify(modifiers ...func(s *sql.Selector)) *APITokenSelect {
+ atq.modifiers = append(atq.modifiers, modifiers...)
+ return atq.Select()
+}
+
// APITokenGroupBy is the group-by builder for APIToken entities.
type APITokenGroupBy struct {
selector
@@ -636,3 +645,9 @@ func (ats *APITokenSelect) sqlScan(ctx context.Context, root *APITokenQuery, v a
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ats *APITokenSelect) Modify(modifiers ...func(s *sql.Selector)) *APITokenSelect {
+ ats.modifiers = append(ats.modifiers, modifiers...)
+ return ats
+}
diff --git a/internal/ent/generated/apitoken_update.go b/internal/ent/generated/apitoken_update.go
index 4e1dad31..61c0ccb9 100644
--- a/internal/ent/generated/apitoken_update.go
+++ b/internal/ent/generated/apitoken_update.go
@@ -13,17 +13,17 @@ import (
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/apitoken"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// APITokenUpdate is the builder for updating APIToken entities.
type APITokenUpdate struct {
config
- hooks []Hook
- mutation *APITokenMutation
+ hooks []Hook
+ mutation *APITokenMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the APITokenUpdate builder.
@@ -307,6 +307,12 @@ func (atu *APITokenUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (atu *APITokenUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *APITokenUpdate {
+ atu.modifiers = append(atu.modifiers, modifiers...)
+ return atu
+}
+
func (atu *APITokenUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := atu.check(); err != nil {
return n, err
@@ -425,6 +431,7 @@ func (atu *APITokenUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = atu.schemaConfig.APIToken
ctx = internal.NewSchemaConfigContext(ctx, atu.schemaConfig)
+ _spec.AddModifiers(atu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, atu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{apitoken.Label}
@@ -440,9 +447,10 @@ func (atu *APITokenUpdate) sqlSave(ctx context.Context) (n int, err error) {
// APITokenUpdateOne is the builder for updating a single APIToken entity.
type APITokenUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *APITokenMutation
+ fields []string
+ hooks []Hook
+ mutation *APITokenMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -733,6 +741,12 @@ func (atuo *APITokenUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (atuo *APITokenUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *APITokenUpdateOne {
+ atuo.modifiers = append(atuo.modifiers, modifiers...)
+ return atuo
+}
+
func (atuo *APITokenUpdateOne) sqlSave(ctx context.Context) (_node *APIToken, err error) {
if err := atuo.check(); err != nil {
return _node, err
@@ -868,6 +882,7 @@ func (atuo *APITokenUpdateOne) sqlSave(ctx context.Context) (_node *APIToken, er
}
_spec.Node.Schema = atuo.schemaConfig.APIToken
ctx = internal.NewSchemaConfigContext(ctx, atuo.schemaConfig)
+ _spec.AddModifiers(atuo.modifiers...)
_node = &APIToken{config: atuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/client.go b/internal/ent/generated/client.go
index d24bba1d..895911ac 100644
--- a/internal/ent/generated/client.go
+++ b/internal/ent/generated/client.go
@@ -9,7 +9,10 @@ import (
"log"
"reflect"
+ "ariga.io/entcache"
"github.com/theopenlane/core/internal/ent/generated/migrate"
+ "github.com/theopenlane/entx"
+ "github.com/theopenlane/riverboat/pkg/riverqueue"
"entgo.io/ent"
"entgo.io/ent/dialect"
@@ -73,17 +76,16 @@ import (
"github.com/theopenlane/core/internal/ent/generated/webauthn"
"github.com/theopenlane/core/internal/ent/generated/webhook"
"github.com/theopenlane/core/internal/ent/generated/webhookhistory"
- "github.com/theopenlane/core/pkg/analytics"
- "github.com/theopenlane/dbx/pkg/dbxclient"
+ "github.com/theopenlane/emailtemplates"
"github.com/theopenlane/iam/entfga"
"github.com/theopenlane/iam/fgax"
"github.com/theopenlane/iam/sessions"
"github.com/theopenlane/iam/tokens"
"github.com/theopenlane/iam/totp"
- "github.com/theopenlane/utils/emails"
- "github.com/theopenlane/utils/marionette"
"gocloud.dev/secrets"
+ stdsql "database/sql"
+
"github.com/theopenlane/core/internal/ent/generated/internal"
)
@@ -207,6 +209,12 @@ type Client struct {
// WebhookHistory is the client for interacting with the WebhookHistory builders.
WebhookHistory *WebhookHistoryClient
+ // Config is the db client configuration
+ Config *entx.EntClientConfig
+
+ // Job is the job client to insert jobs into the queue.
+ Job riverqueue.JobClient
+
// authzActivated determines if the authz hooks have already been activated
authzActivated bool
}
@@ -315,11 +323,11 @@ type (
Authz fgax.Client
TokenManager *tokens.TokenManager
SessionConfig *sessions.SessionConfig
- Emails *emails.EmailManager
- Marionette *marionette.TaskManager
- Analytics *analytics.EventManager
+ Emailer *emailtemplates.Config
TOTP *totp.Manager
- DBx *dbxclient.Client
+ // Job is the job client to insert jobs into the queue.
+ Job riverqueue.JobClient
+
// schemaConfig contains alternative names for all tables.
schemaConfig SchemaConfig
}
@@ -400,24 +408,10 @@ func SessionConfig(v *sessions.SessionConfig) Option {
}
}
-// Emails configures the Emails.
-func Emails(v *emails.EmailManager) Option {
+// Emailer configures the Emailer.
+func Emailer(v *emailtemplates.Config) Option {
return func(c *config) {
- c.Emails = v
- }
-}
-
-// Marionette configures the Marionette.
-func Marionette(v *marionette.TaskManager) Option {
- return func(c *config) {
- c.Marionette = v
- }
-}
-
-// Analytics configures the Analytics.
-func Analytics(v *analytics.EventManager) Option {
- return func(c *config) {
- c.Analytics = v
+ c.Emailer = v
}
}
@@ -428,13 +422,6 @@ func TOTP(v *totp.Manager) Option {
}
}
-// DBx configures the DBx.
-func DBx(v *dbxclient.Client) Option {
- return func(c *config) {
- c.DBx = v
- }
-}
-
// Open opens a database/sql.DB specified by the driver name and
// the data source name, and returns a new client attached to it.
// Optional parameters can be added for configuring the client.
@@ -673,6 +660,58 @@ func (c *Client) Intercept(interceptors ...Interceptor) {
}
}
+// CloseAll closes the all database client connections
+func (c *Client) CloseAll() error {
+ if err := c.Job.Close(); err != nil {
+ return err
+ }
+
+ return c.Close()
+}
+
+// Dialect returns the driver dialect.
+func (c *Client) Dialect() string {
+ return c.driver.Dialect()
+}
+
+// Driver returns the underlying driver.
+func (c *Client) Driver() dialect.Driver {
+ return c.driver
+}
+
+// DB returns the underlying *sql.DB.
+func (c *Client) DB() *stdsql.DB {
+ switch c.driver.(type) {
+ case *sql.Driver: // default
+ return c.driver.(*sql.Driver).DB()
+ case *entcache.Driver: // when using entcache we need to unwrap the driver
+ return c.driver.(*entcache.Driver).Driver.(*sql.Driver).DB()
+ case *dialect.DebugDriver: // when the ent debug driver is used
+ driver := c.driver.(*dialect.DebugDriver)
+
+ switch driver.Driver.(type) {
+ case *sql.Driver: // default
+ return driver.Driver.(*sql.Driver).DB()
+ case *entcache.Driver: // when using entcache we need to unwrap the driver
+ return driver.Driver.(*entcache.Driver).Driver.(*sql.Driver).DB()
+ default:
+ panic(fmt.Sprintf("ent: unknown driver type: %T", driver))
+ }
+ default:
+ panic(fmt.Sprintf("ent: unknown driver type: %T", c.driver))
+ }
+}
+
+// WithJobClient adds the job client to the database client based on the configuration.
+func (c *Client) WithJobClient() {
+ c.Job = NewJobClient(c.config)
+}
+
+// NewJobClient returns a new job client based on the configuration.
+func NewJobClient(c config) riverqueue.JobClient {
+ return c.Job
+}
+
// Mutate implements the ent.Mutator interface.
func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
switch m := m.(type) {
@@ -11096,6 +11135,18 @@ type (
}
)
+// Job option added by the client template to add the job client.
+func Job(ctx context.Context, opts ...riverqueue.Option) Option {
+ return func(c *config) {
+ var err error
+
+ c.Job, err = riverqueue.New(ctx, opts...)
+ if err != nil {
+ panic(err)
+ }
+ }
+}
+
// SchemaConfig represents alternative schema names for all tables
// that can be passed at runtime.
type SchemaConfig = internal.SchemaConfig
diff --git a/internal/ent/generated/contact/where.go b/internal/ent/generated/contact/where.go
index e4419ecc..f6a6345f 100644
--- a/internal/ent/generated/contact/where.go
+++ b/internal/ent/generated/contact/where.go
@@ -7,10 +7,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/contact_delete.go b/internal/ent/generated/contact_delete.go
index bbaa1c10..59c7b545 100644
--- a/internal/ent/generated/contact_delete.go
+++ b/internal/ent/generated/contact_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/contact"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ContactDelete is the builder for deleting a Contact entity.
diff --git a/internal/ent/generated/contact_query.go b/internal/ent/generated/contact_query.go
index e719ffbd..ae15e034 100644
--- a/internal/ent/generated/contact_query.go
+++ b/internal/ent/generated/contact_query.go
@@ -15,10 +15,9 @@ import (
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/contact"
"github.com/theopenlane/core/internal/ent/generated/entity"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// ContactQuery is the builder for querying Contact entities.
@@ -30,8 +29,8 @@ type ContactQuery struct {
predicates []predicate.Contact
withOwner *OrganizationQuery
withEntities *EntityQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*Contact) error
+ modifiers []func(*sql.Selector)
withNamedEntities map[string]*EntityQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
@@ -314,8 +313,9 @@ func (cq *ContactQuery) Clone() *ContactQuery {
withOwner: cq.withOwner.Clone(),
withEntities: cq.withEntities.Clone(),
// clone intermediate query.
- sql: cq.sql.Clone(),
- path: cq.path,
+ sql: cq.sql.Clone(),
+ path: cq.path,
+ modifiers: append([]func(*sql.Selector){}, cq.modifiers...),
}
}
@@ -648,6 +648,9 @@ func (cq *ContactQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(cq.schemaConfig.Contact)
ctx = internal.NewSchemaConfigContext(ctx, cq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range cq.modifiers {
+ m(selector)
+ }
for _, p := range cq.predicates {
p(selector)
}
@@ -665,6 +668,12 @@ func (cq *ContactQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (cq *ContactQuery) Modify(modifiers ...func(s *sql.Selector)) *ContactSelect {
+ cq.modifiers = append(cq.modifiers, modifiers...)
+ return cq.Select()
+}
+
// WithNamedEntities tells the query-builder to eager-load the nodes that are connected to the "entities"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (cq *ContactQuery) WithNamedEntities(name string, opts ...func(*EntityQuery)) *ContactQuery {
@@ -768,3 +777,9 @@ func (cs *ContactSelect) sqlScan(ctx context.Context, root *ContactQuery, v any)
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (cs *ContactSelect) Modify(modifiers ...func(s *sql.Selector)) *ContactSelect {
+ cs.modifiers = append(cs.modifiers, modifiers...)
+ return cs
+}
diff --git a/internal/ent/generated/contact_update.go b/internal/ent/generated/contact_update.go
index bec47945..3617c2cf 100644
--- a/internal/ent/generated/contact_update.go
+++ b/internal/ent/generated/contact_update.go
@@ -14,18 +14,18 @@ import (
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/contact"
"github.com/theopenlane/core/internal/ent/generated/entity"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// ContactUpdate is the builder for updating Contact entities.
type ContactUpdate struct {
config
- hooks []Hook
- mutation *ContactMutation
+ hooks []Hook
+ mutation *ContactMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the ContactUpdate builder.
@@ -396,6 +396,12 @@ func (cu *ContactUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (cu *ContactUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ContactUpdate {
+ cu.modifiers = append(cu.modifiers, modifiers...)
+ return cu
+}
+
func (cu *ContactUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := cu.check(); err != nil {
return n, err
@@ -566,6 +572,7 @@ func (cu *ContactUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = cu.schemaConfig.Contact
ctx = internal.NewSchemaConfigContext(ctx, cu.schemaConfig)
+ _spec.AddModifiers(cu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{contact.Label}
@@ -581,9 +588,10 @@ func (cu *ContactUpdate) sqlSave(ctx context.Context) (n int, err error) {
// ContactUpdateOne is the builder for updating a single Contact entity.
type ContactUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *ContactMutation
+ fields []string
+ hooks []Hook
+ mutation *ContactMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -961,6 +969,12 @@ func (cuo *ContactUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (cuo *ContactUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ContactUpdateOne {
+ cuo.modifiers = append(cuo.modifiers, modifiers...)
+ return cuo
+}
+
func (cuo *ContactUpdateOne) sqlSave(ctx context.Context) (_node *Contact, err error) {
if err := cuo.check(); err != nil {
return _node, err
@@ -1148,6 +1162,7 @@ func (cuo *ContactUpdateOne) sqlSave(ctx context.Context) (_node *Contact, err e
}
_spec.Node.Schema = cuo.schemaConfig.Contact
ctx = internal.NewSchemaConfigContext(ctx, cuo.schemaConfig)
+ _spec.AddModifiers(cuo.modifiers...)
_node = &Contact{config: cuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/contacthistory_delete.go b/internal/ent/generated/contacthistory_delete.go
index c8b3b300..2224bc3b 100644
--- a/internal/ent/generated/contacthistory_delete.go
+++ b/internal/ent/generated/contacthistory_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/contacthistory"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ContactHistoryDelete is the builder for deleting a ContactHistory entity.
diff --git a/internal/ent/generated/contacthistory_query.go b/internal/ent/generated/contacthistory_query.go
index 2ee44ec9..644aec85 100644
--- a/internal/ent/generated/contacthistory_query.go
+++ b/internal/ent/generated/contacthistory_query.go
@@ -13,9 +13,8 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/contacthistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ContactHistoryQuery is the builder for querying ContactHistory entities.
@@ -25,8 +24,8 @@ type ContactHistoryQuery struct {
order []contacthistory.OrderOption
inters []Interceptor
predicates []predicate.ContactHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*ContactHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -256,8 +255,9 @@ func (chq *ContactHistoryQuery) Clone() *ContactHistoryQuery {
inters: append([]Interceptor{}, chq.inters...),
predicates: append([]predicate.ContactHistory{}, chq.predicates...),
// clone intermediate query.
- sql: chq.sql.Clone(),
- path: chq.path,
+ sql: chq.sql.Clone(),
+ path: chq.path,
+ modifiers: append([]func(*sql.Selector){}, chq.modifiers...),
}
}
@@ -448,6 +448,9 @@ func (chq *ContactHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(chq.schemaConfig.ContactHistory)
ctx = internal.NewSchemaConfigContext(ctx, chq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range chq.modifiers {
+ m(selector)
+ }
for _, p := range chq.predicates {
p(selector)
}
@@ -465,6 +468,12 @@ func (chq *ContactHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (chq *ContactHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *ContactHistorySelect {
+ chq.modifiers = append(chq.modifiers, modifiers...)
+ return chq.Select()
+}
+
// ContactHistoryGroupBy is the group-by builder for ContactHistory entities.
type ContactHistoryGroupBy struct {
selector
@@ -554,3 +563,9 @@ func (chs *ContactHistorySelect) sqlScan(ctx context.Context, root *ContactHisto
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (chs *ContactHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *ContactHistorySelect {
+ chs.modifiers = append(chs.modifiers, modifiers...)
+ return chs
+}
diff --git a/internal/ent/generated/contacthistory_update.go b/internal/ent/generated/contacthistory_update.go
index 5ea81c0b..ee23dfc7 100644
--- a/internal/ent/generated/contacthistory_update.go
+++ b/internal/ent/generated/contacthistory_update.go
@@ -13,17 +13,17 @@ import (
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/contacthistory"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// ContactHistoryUpdate is the builder for updating ContactHistory entities.
type ContactHistoryUpdate struct {
config
- hooks []Hook
- mutation *ContactHistoryMutation
+ hooks []Hook
+ mutation *ContactHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the ContactHistoryUpdate builder.
@@ -327,6 +327,12 @@ func (chu *ContactHistoryUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (chu *ContactHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ContactHistoryUpdate {
+ chu.modifiers = append(chu.modifiers, modifiers...)
+ return chu
+}
+
func (chu *ContactHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := chu.check(); err != nil {
return n, err
@@ -427,6 +433,7 @@ func (chu *ContactHistoryUpdate) sqlSave(ctx context.Context) (n int, err error)
}
_spec.Node.Schema = chu.schemaConfig.ContactHistory
ctx = internal.NewSchemaConfigContext(ctx, chu.schemaConfig)
+ _spec.AddModifiers(chu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, chu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{contacthistory.Label}
@@ -442,9 +449,10 @@ func (chu *ContactHistoryUpdate) sqlSave(ctx context.Context) (n int, err error)
// ContactHistoryUpdateOne is the builder for updating a single ContactHistory entity.
type ContactHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *ContactHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *ContactHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -755,6 +763,12 @@ func (chuo *ContactHistoryUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (chuo *ContactHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ContactHistoryUpdateOne {
+ chuo.modifiers = append(chuo.modifiers, modifiers...)
+ return chuo
+}
+
func (chuo *ContactHistoryUpdateOne) sqlSave(ctx context.Context) (_node *ContactHistory, err error) {
if err := chuo.check(); err != nil {
return _node, err
@@ -872,6 +886,7 @@ func (chuo *ContactHistoryUpdateOne) sqlSave(ctx context.Context) (_node *Contac
}
_spec.Node.Schema = chuo.schemaConfig.ContactHistory
ctx = internal.NewSchemaConfigContext(ctx, chuo.schemaConfig)
+ _spec.AddModifiers(chuo.modifiers...)
_node = &ContactHistory{config: chuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/documentdata/where.go b/internal/ent/generated/documentdata/where.go
index 6e207896..f8c11217 100644
--- a/internal/ent/generated/documentdata/where.go
+++ b/internal/ent/generated/documentdata/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/documentdata_delete.go b/internal/ent/generated/documentdata_delete.go
index 2ed342b8..45fe3cc1 100644
--- a/internal/ent/generated/documentdata_delete.go
+++ b/internal/ent/generated/documentdata_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/documentdata"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// DocumentDataDelete is the builder for deleting a DocumentData entity.
diff --git a/internal/ent/generated/documentdata_query.go b/internal/ent/generated/documentdata_query.go
index b7f55324..a236c713 100644
--- a/internal/ent/generated/documentdata_query.go
+++ b/internal/ent/generated/documentdata_query.go
@@ -15,11 +15,10 @@ import (
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/documentdata"
"github.com/theopenlane/core/internal/ent/generated/entity"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/template"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// DocumentDataQuery is the builder for querying DocumentData entities.
@@ -32,8 +31,8 @@ type DocumentDataQuery struct {
withOwner *OrganizationQuery
withTemplate *TemplateQuery
withEntity *EntityQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*DocumentData) error
+ modifiers []func(*sql.Selector)
withNamedEntity map[string]*EntityQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
@@ -342,8 +341,9 @@ func (ddq *DocumentDataQuery) Clone() *DocumentDataQuery {
withTemplate: ddq.withTemplate.Clone(),
withEntity: ddq.withEntity.Clone(),
// clone intermediate query.
- sql: ddq.sql.Clone(),
- path: ddq.path,
+ sql: ddq.sql.Clone(),
+ path: ddq.path,
+ modifiers: append([]func(*sql.Selector){}, ddq.modifiers...),
}
}
@@ -726,6 +726,9 @@ func (ddq *DocumentDataQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(ddq.schemaConfig.DocumentData)
ctx = internal.NewSchemaConfigContext(ctx, ddq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range ddq.modifiers {
+ m(selector)
+ }
for _, p := range ddq.predicates {
p(selector)
}
@@ -743,6 +746,12 @@ func (ddq *DocumentDataQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ddq *DocumentDataQuery) Modify(modifiers ...func(s *sql.Selector)) *DocumentDataSelect {
+ ddq.modifiers = append(ddq.modifiers, modifiers...)
+ return ddq.Select()
+}
+
// WithNamedEntity tells the query-builder to eager-load the nodes that are connected to the "entity"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (ddq *DocumentDataQuery) WithNamedEntity(name string, opts ...func(*EntityQuery)) *DocumentDataQuery {
@@ -846,3 +855,9 @@ func (dds *DocumentDataSelect) sqlScan(ctx context.Context, root *DocumentDataQu
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (dds *DocumentDataSelect) Modify(modifiers ...func(s *sql.Selector)) *DocumentDataSelect {
+ dds.modifiers = append(dds.modifiers, modifiers...)
+ return dds
+}
diff --git a/internal/ent/generated/documentdata_update.go b/internal/ent/generated/documentdata_update.go
index f8e47efe..c890a400 100644
--- a/internal/ent/generated/documentdata_update.go
+++ b/internal/ent/generated/documentdata_update.go
@@ -15,18 +15,18 @@ import (
"github.com/theopenlane/core/internal/ent/customtypes"
"github.com/theopenlane/core/internal/ent/generated/documentdata"
"github.com/theopenlane/core/internal/ent/generated/entity"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/template"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// DocumentDataUpdate is the builder for updating DocumentData entities.
type DocumentDataUpdate struct {
config
- hooks []Hook
- mutation *DocumentDataMutation
+ hooks []Hook
+ mutation *DocumentDataMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the DocumentDataUpdate builder.
@@ -283,6 +283,12 @@ func (ddu *DocumentDataUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ddu *DocumentDataUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *DocumentDataUpdate {
+ ddu.modifiers = append(ddu.modifiers, modifiers...)
+ return ddu
+}
+
func (ddu *DocumentDataUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := ddu.check(); err != nil {
return n, err
@@ -451,6 +457,7 @@ func (ddu *DocumentDataUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = ddu.schemaConfig.DocumentData
ctx = internal.NewSchemaConfigContext(ctx, ddu.schemaConfig)
+ _spec.AddModifiers(ddu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, ddu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{documentdata.Label}
@@ -466,9 +473,10 @@ func (ddu *DocumentDataUpdate) sqlSave(ctx context.Context) (n int, err error) {
// DocumentDataUpdateOne is the builder for updating a single DocumentData entity.
type DocumentDataUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *DocumentDataMutation
+ fields []string
+ hooks []Hook
+ mutation *DocumentDataMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -732,6 +740,12 @@ func (dduo *DocumentDataUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (dduo *DocumentDataUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *DocumentDataUpdateOne {
+ dduo.modifiers = append(dduo.modifiers, modifiers...)
+ return dduo
+}
+
func (dduo *DocumentDataUpdateOne) sqlSave(ctx context.Context) (_node *DocumentData, err error) {
if err := dduo.check(); err != nil {
return _node, err
@@ -917,6 +931,7 @@ func (dduo *DocumentDataUpdateOne) sqlSave(ctx context.Context) (_node *Document
}
_spec.Node.Schema = dduo.schemaConfig.DocumentData
ctx = internal.NewSchemaConfigContext(ctx, dduo.schemaConfig)
+ _spec.AddModifiers(dduo.modifiers...)
_node = &DocumentData{config: dduo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/documentdatahistory_delete.go b/internal/ent/generated/documentdatahistory_delete.go
index b80ad8f3..8fd149a4 100644
--- a/internal/ent/generated/documentdatahistory_delete.go
+++ b/internal/ent/generated/documentdatahistory_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/documentdatahistory"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// DocumentDataHistoryDelete is the builder for deleting a DocumentDataHistory entity.
diff --git a/internal/ent/generated/documentdatahistory_query.go b/internal/ent/generated/documentdatahistory_query.go
index 6a93d465..9c614476 100644
--- a/internal/ent/generated/documentdatahistory_query.go
+++ b/internal/ent/generated/documentdatahistory_query.go
@@ -13,9 +13,8 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/documentdatahistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// DocumentDataHistoryQuery is the builder for querying DocumentDataHistory entities.
@@ -25,8 +24,8 @@ type DocumentDataHistoryQuery struct {
order []documentdatahistory.OrderOption
inters []Interceptor
predicates []predicate.DocumentDataHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*DocumentDataHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -256,8 +255,9 @@ func (ddhq *DocumentDataHistoryQuery) Clone() *DocumentDataHistoryQuery {
inters: append([]Interceptor{}, ddhq.inters...),
predicates: append([]predicate.DocumentDataHistory{}, ddhq.predicates...),
// clone intermediate query.
- sql: ddhq.sql.Clone(),
- path: ddhq.path,
+ sql: ddhq.sql.Clone(),
+ path: ddhq.path,
+ modifiers: append([]func(*sql.Selector){}, ddhq.modifiers...),
}
}
@@ -448,6 +448,9 @@ func (ddhq *DocumentDataHistoryQuery) sqlQuery(ctx context.Context) *sql.Selecto
t1.Schema(ddhq.schemaConfig.DocumentDataHistory)
ctx = internal.NewSchemaConfigContext(ctx, ddhq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range ddhq.modifiers {
+ m(selector)
+ }
for _, p := range ddhq.predicates {
p(selector)
}
@@ -465,6 +468,12 @@ func (ddhq *DocumentDataHistoryQuery) sqlQuery(ctx context.Context) *sql.Selecto
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ddhq *DocumentDataHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *DocumentDataHistorySelect {
+ ddhq.modifiers = append(ddhq.modifiers, modifiers...)
+ return ddhq.Select()
+}
+
// DocumentDataHistoryGroupBy is the group-by builder for DocumentDataHistory entities.
type DocumentDataHistoryGroupBy struct {
selector
@@ -554,3 +563,9 @@ func (ddhs *DocumentDataHistorySelect) sqlScan(ctx context.Context, root *Docume
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ddhs *DocumentDataHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *DocumentDataHistorySelect {
+ ddhs.modifiers = append(ddhs.modifiers, modifiers...)
+ return ddhs
+}
diff --git a/internal/ent/generated/documentdatahistory_update.go b/internal/ent/generated/documentdatahistory_update.go
index d4bc603f..3f9dd87e 100644
--- a/internal/ent/generated/documentdatahistory_update.go
+++ b/internal/ent/generated/documentdatahistory_update.go
@@ -14,16 +14,16 @@ import (
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/customtypes"
"github.com/theopenlane/core/internal/ent/generated/documentdatahistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// DocumentDataHistoryUpdate is the builder for updating DocumentDataHistory entities.
type DocumentDataHistoryUpdate struct {
config
- hooks []Hook
- mutation *DocumentDataHistoryMutation
+ hooks []Hook
+ mutation *DocumentDataHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the DocumentDataHistoryUpdate builder.
@@ -209,6 +209,12 @@ func (ddhu *DocumentDataHistoryUpdate) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ddhu *DocumentDataHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *DocumentDataHistoryUpdate {
+ ddhu.modifiers = append(ddhu.modifiers, modifiers...)
+ return ddhu
+}
+
func (ddhu *DocumentDataHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(documentdatahistory.Table, documentdatahistory.Columns, sqlgraph.NewFieldSpec(documentdatahistory.FieldID, field.TypeString))
if ps := ddhu.mutation.predicates; len(ps) > 0 {
@@ -276,6 +282,7 @@ func (ddhu *DocumentDataHistoryUpdate) sqlSave(ctx context.Context) (n int, err
}
_spec.Node.Schema = ddhu.schemaConfig.DocumentDataHistory
ctx = internal.NewSchemaConfigContext(ctx, ddhu.schemaConfig)
+ _spec.AddModifiers(ddhu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, ddhu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{documentdatahistory.Label}
@@ -291,9 +298,10 @@ func (ddhu *DocumentDataHistoryUpdate) sqlSave(ctx context.Context) (n int, err
// DocumentDataHistoryUpdateOne is the builder for updating a single DocumentDataHistory entity.
type DocumentDataHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *DocumentDataHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *DocumentDataHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -486,6 +494,12 @@ func (ddhuo *DocumentDataHistoryUpdateOne) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ddhuo *DocumentDataHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *DocumentDataHistoryUpdateOne {
+ ddhuo.modifiers = append(ddhuo.modifiers, modifiers...)
+ return ddhuo
+}
+
func (ddhuo *DocumentDataHistoryUpdateOne) sqlSave(ctx context.Context) (_node *DocumentDataHistory, err error) {
_spec := sqlgraph.NewUpdateSpec(documentdatahistory.Table, documentdatahistory.Columns, sqlgraph.NewFieldSpec(documentdatahistory.FieldID, field.TypeString))
id, ok := ddhuo.mutation.ID()
@@ -570,6 +584,7 @@ func (ddhuo *DocumentDataHistoryUpdateOne) sqlSave(ctx context.Context) (_node *
}
_spec.Node.Schema = ddhuo.schemaConfig.DocumentDataHistory
ctx = internal.NewSchemaConfigContext(ctx, ddhuo.schemaConfig)
+ _spec.AddModifiers(ddhuo.modifiers...)
_node = &DocumentDataHistory{config: ddhuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/emailverificationtoken/where.go b/internal/ent/generated/emailverificationtoken/where.go
index e2c24a44..2b4a841a 100644
--- a/internal/ent/generated/emailverificationtoken/where.go
+++ b/internal/ent/generated/emailverificationtoken/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/emailverificationtoken_delete.go b/internal/ent/generated/emailverificationtoken_delete.go
index b3ff7635..b7b75f3a 100644
--- a/internal/ent/generated/emailverificationtoken_delete.go
+++ b/internal/ent/generated/emailverificationtoken_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/emailverificationtoken"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EmailVerificationTokenDelete is the builder for deleting a EmailVerificationToken entity.
diff --git a/internal/ent/generated/emailverificationtoken_query.go b/internal/ent/generated/emailverificationtoken_query.go
index 2838dd8c..e16a670b 100644
--- a/internal/ent/generated/emailverificationtoken_query.go
+++ b/internal/ent/generated/emailverificationtoken_query.go
@@ -13,10 +13,9 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/emailverificationtoken"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/user"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// EmailVerificationTokenQuery is the builder for querying EmailVerificationToken entities.
@@ -27,8 +26,8 @@ type EmailVerificationTokenQuery struct {
inters []Interceptor
predicates []predicate.EmailVerificationToken
withOwner *UserQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*EmailVerificationToken) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -284,8 +283,9 @@ func (evtq *EmailVerificationTokenQuery) Clone() *EmailVerificationTokenQuery {
predicates: append([]predicate.EmailVerificationToken{}, evtq.predicates...),
withOwner: evtq.withOwner.Clone(),
// clone intermediate query.
- sql: evtq.sql.Clone(),
- path: evtq.path,
+ sql: evtq.sql.Clone(),
+ path: evtq.path,
+ modifiers: append([]func(*sql.Selector){}, evtq.modifiers...),
}
}
@@ -530,6 +530,9 @@ func (evtq *EmailVerificationTokenQuery) sqlQuery(ctx context.Context) *sql.Sele
t1.Schema(evtq.schemaConfig.EmailVerificationToken)
ctx = internal.NewSchemaConfigContext(ctx, evtq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range evtq.modifiers {
+ m(selector)
+ }
for _, p := range evtq.predicates {
p(selector)
}
@@ -547,6 +550,12 @@ func (evtq *EmailVerificationTokenQuery) sqlQuery(ctx context.Context) *sql.Sele
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (evtq *EmailVerificationTokenQuery) Modify(modifiers ...func(s *sql.Selector)) *EmailVerificationTokenSelect {
+ evtq.modifiers = append(evtq.modifiers, modifiers...)
+ return evtq.Select()
+}
+
// EmailVerificationTokenGroupBy is the group-by builder for EmailVerificationToken entities.
type EmailVerificationTokenGroupBy struct {
selector
@@ -636,3 +645,9 @@ func (evts *EmailVerificationTokenSelect) sqlScan(ctx context.Context, root *Ema
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (evts *EmailVerificationTokenSelect) Modify(modifiers ...func(s *sql.Selector)) *EmailVerificationTokenSelect {
+ evts.modifiers = append(evts.modifiers, modifiers...)
+ return evts
+}
diff --git a/internal/ent/generated/emailverificationtoken_update.go b/internal/ent/generated/emailverificationtoken_update.go
index 9514d7e8..4c25fab4 100644
--- a/internal/ent/generated/emailverificationtoken_update.go
+++ b/internal/ent/generated/emailverificationtoken_update.go
@@ -12,17 +12,17 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/emailverificationtoken"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/user"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// EmailVerificationTokenUpdate is the builder for updating EmailVerificationToken entities.
type EmailVerificationTokenUpdate struct {
config
- hooks []Hook
- mutation *EmailVerificationTokenMutation
+ hooks []Hook
+ mutation *EmailVerificationTokenMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the EmailVerificationTokenUpdate builder.
@@ -246,6 +246,12 @@ func (evtu *EmailVerificationTokenUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (evtu *EmailVerificationTokenUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EmailVerificationTokenUpdate {
+ evtu.modifiers = append(evtu.modifiers, modifiers...)
+ return evtu
+}
+
func (evtu *EmailVerificationTokenUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := evtu.check(); err != nil {
return n, err
@@ -333,6 +339,7 @@ func (evtu *EmailVerificationTokenUpdate) sqlSave(ctx context.Context) (n int, e
}
_spec.Node.Schema = evtu.schemaConfig.EmailVerificationToken
ctx = internal.NewSchemaConfigContext(ctx, evtu.schemaConfig)
+ _spec.AddModifiers(evtu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, evtu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{emailverificationtoken.Label}
@@ -348,9 +355,10 @@ func (evtu *EmailVerificationTokenUpdate) sqlSave(ctx context.Context) (n int, e
// EmailVerificationTokenUpdateOne is the builder for updating a single EmailVerificationToken entity.
type EmailVerificationTokenUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *EmailVerificationTokenMutation
+ fields []string
+ hooks []Hook
+ mutation *EmailVerificationTokenMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -581,6 +589,12 @@ func (evtuo *EmailVerificationTokenUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (evtuo *EmailVerificationTokenUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EmailVerificationTokenUpdateOne {
+ evtuo.modifiers = append(evtuo.modifiers, modifiers...)
+ return evtuo
+}
+
func (evtuo *EmailVerificationTokenUpdateOne) sqlSave(ctx context.Context) (_node *EmailVerificationToken, err error) {
if err := evtuo.check(); err != nil {
return _node, err
@@ -685,6 +699,7 @@ func (evtuo *EmailVerificationTokenUpdateOne) sqlSave(ctx context.Context) (_nod
}
_spec.Node.Schema = evtuo.schemaConfig.EmailVerificationToken
ctx = internal.NewSchemaConfigContext(ctx, evtuo.schemaConfig)
+ _spec.AddModifiers(evtuo.modifiers...)
_node = &EmailVerificationToken{config: evtuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/entitlement/where.go b/internal/ent/generated/entitlement/where.go
index 79c5f510..4dd20643 100644
--- a/internal/ent/generated/entitlement/where.go
+++ b/internal/ent/generated/entitlement/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/entitlement_delete.go b/internal/ent/generated/entitlement_delete.go
index 42e07cf5..2ef9b32a 100644
--- a/internal/ent/generated/entitlement_delete.go
+++ b/internal/ent/generated/entitlement_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/entitlement"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EntitlementDelete is the builder for deleting a Entitlement entity.
diff --git a/internal/ent/generated/entitlement_query.go b/internal/ent/generated/entitlement_query.go
index 366050d2..f9df7744 100644
--- a/internal/ent/generated/entitlement_query.go
+++ b/internal/ent/generated/entitlement_query.go
@@ -16,10 +16,9 @@ import (
"github.com/theopenlane/core/internal/ent/generated/entitlement"
"github.com/theopenlane/core/internal/ent/generated/entitlementplan"
"github.com/theopenlane/core/internal/ent/generated/event"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// EntitlementQuery is the builder for querying Entitlement entities.
@@ -33,8 +32,8 @@ type EntitlementQuery struct {
withPlan *EntitlementPlanQuery
withOrganization *OrganizationQuery
withEvents *EventQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*Entitlement) error
+ modifiers []func(*sql.Selector)
withNamedEvents map[string]*EventQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
@@ -369,8 +368,9 @@ func (eq *EntitlementQuery) Clone() *EntitlementQuery {
withOrganization: eq.withOrganization.Clone(),
withEvents: eq.withEvents.Clone(),
// clone intermediate query.
- sql: eq.sql.Clone(),
- path: eq.path,
+ sql: eq.sql.Clone(),
+ path: eq.path,
+ modifiers: append([]func(*sql.Selector){}, eq.modifiers...),
}
}
@@ -803,6 +803,9 @@ func (eq *EntitlementQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(eq.schemaConfig.Entitlement)
ctx = internal.NewSchemaConfigContext(ctx, eq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range eq.modifiers {
+ m(selector)
+ }
for _, p := range eq.predicates {
p(selector)
}
@@ -820,6 +823,12 @@ func (eq *EntitlementQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (eq *EntitlementQuery) Modify(modifiers ...func(s *sql.Selector)) *EntitlementSelect {
+ eq.modifiers = append(eq.modifiers, modifiers...)
+ return eq.Select()
+}
+
// WithNamedEvents tells the query-builder to eager-load the nodes that are connected to the "events"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (eq *EntitlementQuery) WithNamedEvents(name string, opts ...func(*EventQuery)) *EntitlementQuery {
@@ -923,3 +932,9 @@ func (es *EntitlementSelect) sqlScan(ctx context.Context, root *EntitlementQuery
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (es *EntitlementSelect) Modify(modifiers ...func(s *sql.Selector)) *EntitlementSelect {
+ es.modifiers = append(es.modifiers, modifiers...)
+ return es
+}
diff --git a/internal/ent/generated/entitlement_update.go b/internal/ent/generated/entitlement_update.go
index b1e92a62..e9ba7fab 100644
--- a/internal/ent/generated/entitlement_update.go
+++ b/internal/ent/generated/entitlement_update.go
@@ -14,17 +14,17 @@ import (
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/entitlement"
"github.com/theopenlane/core/internal/ent/generated/event"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// EntitlementUpdate is the builder for updating Entitlement entities.
type EntitlementUpdate struct {
config
- hooks []Hook
- mutation *EntitlementMutation
+ hooks []Hook
+ mutation *EntitlementMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the EntitlementUpdate builder.
@@ -341,6 +341,12 @@ func (eu *EntitlementUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (eu *EntitlementUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EntitlementUpdate {
+ eu.modifiers = append(eu.modifiers, modifiers...)
+ return eu
+}
+
func (eu *EntitlementUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := eu.check(); err != nil {
return n, err
@@ -499,6 +505,7 @@ func (eu *EntitlementUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = eu.schemaConfig.Entitlement
ctx = internal.NewSchemaConfigContext(ctx, eu.schemaConfig)
+ _spec.AddModifiers(eu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, eu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{entitlement.Label}
@@ -514,9 +521,10 @@ func (eu *EntitlementUpdate) sqlSave(ctx context.Context) (n int, err error) {
// EntitlementUpdateOne is the builder for updating a single Entitlement entity.
type EntitlementUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *EntitlementMutation
+ fields []string
+ hooks []Hook
+ mutation *EntitlementMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -840,6 +848,12 @@ func (euo *EntitlementUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (euo *EntitlementUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EntitlementUpdateOne {
+ euo.modifiers = append(euo.modifiers, modifiers...)
+ return euo
+}
+
func (euo *EntitlementUpdateOne) sqlSave(ctx context.Context) (_node *Entitlement, err error) {
if err := euo.check(); err != nil {
return _node, err
@@ -1015,6 +1029,7 @@ func (euo *EntitlementUpdateOne) sqlSave(ctx context.Context) (_node *Entitlemen
}
_spec.Node.Schema = euo.schemaConfig.Entitlement
ctx = internal.NewSchemaConfigContext(ctx, euo.schemaConfig)
+ _spec.AddModifiers(euo.modifiers...)
_node = &Entitlement{config: euo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/entitlementhistory_delete.go b/internal/ent/generated/entitlementhistory_delete.go
index e0dbba10..431e20b8 100644
--- a/internal/ent/generated/entitlementhistory_delete.go
+++ b/internal/ent/generated/entitlementhistory_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/entitlementhistory"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EntitlementHistoryDelete is the builder for deleting a EntitlementHistory entity.
diff --git a/internal/ent/generated/entitlementhistory_query.go b/internal/ent/generated/entitlementhistory_query.go
index a883fcb1..620057d3 100644
--- a/internal/ent/generated/entitlementhistory_query.go
+++ b/internal/ent/generated/entitlementhistory_query.go
@@ -13,9 +13,8 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/entitlementhistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EntitlementHistoryQuery is the builder for querying EntitlementHistory entities.
@@ -25,8 +24,8 @@ type EntitlementHistoryQuery struct {
order []entitlementhistory.OrderOption
inters []Interceptor
predicates []predicate.EntitlementHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*EntitlementHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -256,8 +255,9 @@ func (ehq *EntitlementHistoryQuery) Clone() *EntitlementHistoryQuery {
inters: append([]Interceptor{}, ehq.inters...),
predicates: append([]predicate.EntitlementHistory{}, ehq.predicates...),
// clone intermediate query.
- sql: ehq.sql.Clone(),
- path: ehq.path,
+ sql: ehq.sql.Clone(),
+ path: ehq.path,
+ modifiers: append([]func(*sql.Selector){}, ehq.modifiers...),
}
}
@@ -448,6 +448,9 @@ func (ehq *EntitlementHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector
t1.Schema(ehq.schemaConfig.EntitlementHistory)
ctx = internal.NewSchemaConfigContext(ctx, ehq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range ehq.modifiers {
+ m(selector)
+ }
for _, p := range ehq.predicates {
p(selector)
}
@@ -465,6 +468,12 @@ func (ehq *EntitlementHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ehq *EntitlementHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *EntitlementHistorySelect {
+ ehq.modifiers = append(ehq.modifiers, modifiers...)
+ return ehq.Select()
+}
+
// EntitlementHistoryGroupBy is the group-by builder for EntitlementHistory entities.
type EntitlementHistoryGroupBy struct {
selector
@@ -554,3 +563,9 @@ func (ehs *EntitlementHistorySelect) sqlScan(ctx context.Context, root *Entitlem
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ehs *EntitlementHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *EntitlementHistorySelect {
+ ehs.modifiers = append(ehs.modifiers, modifiers...)
+ return ehs
+}
diff --git a/internal/ent/generated/entitlementhistory_update.go b/internal/ent/generated/entitlementhistory_update.go
index 232691d8..2f6fce4a 100644
--- a/internal/ent/generated/entitlementhistory_update.go
+++ b/internal/ent/generated/entitlementhistory_update.go
@@ -13,16 +13,16 @@ import (
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/entitlementhistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EntitlementHistoryUpdate is the builder for updating EntitlementHistory entities.
type EntitlementHistoryUpdate struct {
config
- hooks []Hook
- mutation *EntitlementHistoryMutation
+ hooks []Hook
+ mutation *EntitlementHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the EntitlementHistoryUpdate builder.
@@ -276,6 +276,12 @@ func (ehu *EntitlementHistoryUpdate) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ehu *EntitlementHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EntitlementHistoryUpdate {
+ ehu.modifiers = append(ehu.modifiers, modifiers...)
+ return ehu
+}
+
func (ehu *EntitlementHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(entitlementhistory.Table, entitlementhistory.Columns, sqlgraph.NewFieldSpec(entitlementhistory.FieldID, field.TypeString))
if ps := ehu.mutation.predicates; len(ps) > 0 {
@@ -361,6 +367,7 @@ func (ehu *EntitlementHistoryUpdate) sqlSave(ctx context.Context) (n int, err er
}
_spec.Node.Schema = ehu.schemaConfig.EntitlementHistory
ctx = internal.NewSchemaConfigContext(ctx, ehu.schemaConfig)
+ _spec.AddModifiers(ehu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, ehu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{entitlementhistory.Label}
@@ -376,9 +383,10 @@ func (ehu *EntitlementHistoryUpdate) sqlSave(ctx context.Context) (n int, err er
// EntitlementHistoryUpdateOne is the builder for updating a single EntitlementHistory entity.
type EntitlementHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *EntitlementHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *EntitlementHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -639,6 +647,12 @@ func (ehuo *EntitlementHistoryUpdateOne) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ehuo *EntitlementHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EntitlementHistoryUpdateOne {
+ ehuo.modifiers = append(ehuo.modifiers, modifiers...)
+ return ehuo
+}
+
func (ehuo *EntitlementHistoryUpdateOne) sqlSave(ctx context.Context) (_node *EntitlementHistory, err error) {
_spec := sqlgraph.NewUpdateSpec(entitlementhistory.Table, entitlementhistory.Columns, sqlgraph.NewFieldSpec(entitlementhistory.FieldID, field.TypeString))
id, ok := ehuo.mutation.ID()
@@ -741,6 +755,7 @@ func (ehuo *EntitlementHistoryUpdateOne) sqlSave(ctx context.Context) (_node *En
}
_spec.Node.Schema = ehuo.schemaConfig.EntitlementHistory
ctx = internal.NewSchemaConfigContext(ctx, ehuo.schemaConfig)
+ _spec.AddModifiers(ehuo.modifiers...)
_node = &EntitlementHistory{config: ehuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/entitlementplan/where.go b/internal/ent/generated/entitlementplan/where.go
index 33a98bd9..1e2eb202 100644
--- a/internal/ent/generated/entitlementplan/where.go
+++ b/internal/ent/generated/entitlementplan/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/entitlementplan_delete.go b/internal/ent/generated/entitlementplan_delete.go
index 9a924900..dd06150e 100644
--- a/internal/ent/generated/entitlementplan_delete.go
+++ b/internal/ent/generated/entitlementplan_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/entitlementplan"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EntitlementPlanDelete is the builder for deleting a EntitlementPlan entity.
diff --git a/internal/ent/generated/entitlementplan_query.go b/internal/ent/generated/entitlementplan_query.go
index cb2c0480..0bf19035 100644
--- a/internal/ent/generated/entitlementplan_query.go
+++ b/internal/ent/generated/entitlementplan_query.go
@@ -18,10 +18,9 @@ import (
"github.com/theopenlane/core/internal/ent/generated/entitlementplanfeature"
"github.com/theopenlane/core/internal/ent/generated/event"
"github.com/theopenlane/core/internal/ent/generated/feature"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// EntitlementPlanQuery is the builder for querying EntitlementPlan entities.
@@ -36,8 +35,8 @@ type EntitlementPlanQuery struct {
withBaseFeatures *FeatureQuery
withEvents *EventQuery
withFeatures *EntitlementPlanFeatureQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*EntitlementPlan) error
+ modifiers []func(*sql.Selector)
withNamedEntitlements map[string]*EntitlementQuery
withNamedBaseFeatures map[string]*FeatureQuery
withNamedEvents map[string]*EventQuery
@@ -401,8 +400,9 @@ func (epq *EntitlementPlanQuery) Clone() *EntitlementPlanQuery {
withEvents: epq.withEvents.Clone(),
withFeatures: epq.withFeatures.Clone(),
// clone intermediate query.
- sql: epq.sql.Clone(),
- path: epq.path,
+ sql: epq.sql.Clone(),
+ path: epq.path,
+ modifiers: append([]func(*sql.Selector){}, epq.modifiers...),
}
}
@@ -935,6 +935,9 @@ func (epq *EntitlementPlanQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(epq.schemaConfig.EntitlementPlan)
ctx = internal.NewSchemaConfigContext(ctx, epq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range epq.modifiers {
+ m(selector)
+ }
for _, p := range epq.predicates {
p(selector)
}
@@ -952,6 +955,12 @@ func (epq *EntitlementPlanQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (epq *EntitlementPlanQuery) Modify(modifiers ...func(s *sql.Selector)) *EntitlementPlanSelect {
+ epq.modifiers = append(epq.modifiers, modifiers...)
+ return epq.Select()
+}
+
// WithNamedEntitlements tells the query-builder to eager-load the nodes that are connected to the "entitlements"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (epq *EntitlementPlanQuery) WithNamedEntitlements(name string, opts ...func(*EntitlementQuery)) *EntitlementPlanQuery {
@@ -1097,3 +1106,9 @@ func (eps *EntitlementPlanSelect) sqlScan(ctx context.Context, root *Entitlement
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (eps *EntitlementPlanSelect) Modify(modifiers ...func(s *sql.Selector)) *EntitlementPlanSelect {
+ eps.modifiers = append(eps.modifiers, modifiers...)
+ return eps
+}
diff --git a/internal/ent/generated/entitlementplan_update.go b/internal/ent/generated/entitlementplan_update.go
index b614fb66..e01e1d38 100644
--- a/internal/ent/generated/entitlementplan_update.go
+++ b/internal/ent/generated/entitlementplan_update.go
@@ -17,17 +17,17 @@ import (
"github.com/theopenlane/core/internal/ent/generated/entitlementplanfeature"
"github.com/theopenlane/core/internal/ent/generated/event"
"github.com/theopenlane/core/internal/ent/generated/feature"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// EntitlementPlanUpdate is the builder for updating EntitlementPlan entities.
type EntitlementPlanUpdate struct {
config
- hooks []Hook
- mutation *EntitlementPlanMutation
+ hooks []Hook
+ mutation *EntitlementPlanMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the EntitlementPlanUpdate builder.
@@ -410,6 +410,12 @@ func (epu *EntitlementPlanUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (epu *EntitlementPlanUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EntitlementPlanUpdate {
+ epu.modifiers = append(epu.modifiers, modifiers...)
+ return epu
+}
+
func (epu *EntitlementPlanUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := epu.check(); err != nil {
return n, err
@@ -727,6 +733,7 @@ func (epu *EntitlementPlanUpdate) sqlSave(ctx context.Context) (n int, err error
}
_spec.Node.Schema = epu.schemaConfig.EntitlementPlan
ctx = internal.NewSchemaConfigContext(ctx, epu.schemaConfig)
+ _spec.AddModifiers(epu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, epu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{entitlementplan.Label}
@@ -742,9 +749,10 @@ func (epu *EntitlementPlanUpdate) sqlSave(ctx context.Context) (n int, err error
// EntitlementPlanUpdateOne is the builder for updating a single EntitlementPlan entity.
type EntitlementPlanUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *EntitlementPlanMutation
+ fields []string
+ hooks []Hook
+ mutation *EntitlementPlanMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -1134,6 +1142,12 @@ func (epuo *EntitlementPlanUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (epuo *EntitlementPlanUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EntitlementPlanUpdateOne {
+ epuo.modifiers = append(epuo.modifiers, modifiers...)
+ return epuo
+}
+
func (epuo *EntitlementPlanUpdateOne) sqlSave(ctx context.Context) (_node *EntitlementPlan, err error) {
if err := epuo.check(); err != nil {
return _node, err
@@ -1468,6 +1482,7 @@ func (epuo *EntitlementPlanUpdateOne) sqlSave(ctx context.Context) (_node *Entit
}
_spec.Node.Schema = epuo.schemaConfig.EntitlementPlan
ctx = internal.NewSchemaConfigContext(ctx, epuo.schemaConfig)
+ _spec.AddModifiers(epuo.modifiers...)
_node = &EntitlementPlan{config: epuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/entitlementplanfeature/where.go b/internal/ent/generated/entitlementplanfeature/where.go
index 863c09ba..c7bb3457 100644
--- a/internal/ent/generated/entitlementplanfeature/where.go
+++ b/internal/ent/generated/entitlementplanfeature/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/entitlementplanfeature_delete.go b/internal/ent/generated/entitlementplanfeature_delete.go
index 6e065c5c..370baf79 100644
--- a/internal/ent/generated/entitlementplanfeature_delete.go
+++ b/internal/ent/generated/entitlementplanfeature_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/entitlementplanfeature"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EntitlementPlanFeatureDelete is the builder for deleting a EntitlementPlanFeature entity.
diff --git a/internal/ent/generated/entitlementplanfeature_query.go b/internal/ent/generated/entitlementplanfeature_query.go
index b8e66c21..d66eacf8 100644
--- a/internal/ent/generated/entitlementplanfeature_query.go
+++ b/internal/ent/generated/entitlementplanfeature_query.go
@@ -17,10 +17,9 @@ import (
"github.com/theopenlane/core/internal/ent/generated/entitlementplanfeature"
"github.com/theopenlane/core/internal/ent/generated/event"
"github.com/theopenlane/core/internal/ent/generated/feature"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// EntitlementPlanFeatureQuery is the builder for querying EntitlementPlanFeature entities.
@@ -34,8 +33,8 @@ type EntitlementPlanFeatureQuery struct {
withPlan *EntitlementPlanQuery
withFeature *FeatureQuery
withEvents *EventQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*EntitlementPlanFeature) error
+ modifiers []func(*sql.Selector)
withNamedEvents map[string]*EventQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
@@ -370,8 +369,9 @@ func (epfq *EntitlementPlanFeatureQuery) Clone() *EntitlementPlanFeatureQuery {
withFeature: epfq.withFeature.Clone(),
withEvents: epfq.withEvents.Clone(),
// clone intermediate query.
- sql: epfq.sql.Clone(),
- path: epfq.path,
+ sql: epfq.sql.Clone(),
+ path: epfq.path,
+ modifiers: append([]func(*sql.Selector){}, epfq.modifiers...),
}
}
@@ -804,6 +804,9 @@ func (epfq *EntitlementPlanFeatureQuery) sqlQuery(ctx context.Context) *sql.Sele
t1.Schema(epfq.schemaConfig.EntitlementPlanFeature)
ctx = internal.NewSchemaConfigContext(ctx, epfq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range epfq.modifiers {
+ m(selector)
+ }
for _, p := range epfq.predicates {
p(selector)
}
@@ -821,6 +824,12 @@ func (epfq *EntitlementPlanFeatureQuery) sqlQuery(ctx context.Context) *sql.Sele
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (epfq *EntitlementPlanFeatureQuery) Modify(modifiers ...func(s *sql.Selector)) *EntitlementPlanFeatureSelect {
+ epfq.modifiers = append(epfq.modifiers, modifiers...)
+ return epfq.Select()
+}
+
// WithNamedEvents tells the query-builder to eager-load the nodes that are connected to the "events"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (epfq *EntitlementPlanFeatureQuery) WithNamedEvents(name string, opts ...func(*EventQuery)) *EntitlementPlanFeatureQuery {
@@ -924,3 +933,9 @@ func (epfs *EntitlementPlanFeatureSelect) sqlScan(ctx context.Context, root *Ent
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (epfs *EntitlementPlanFeatureSelect) Modify(modifiers ...func(s *sql.Selector)) *EntitlementPlanFeatureSelect {
+ epfs.modifiers = append(epfs.modifiers, modifiers...)
+ return epfs
+}
diff --git a/internal/ent/generated/entitlementplanfeature_update.go b/internal/ent/generated/entitlementplanfeature_update.go
index 8dbbdcc2..be2369a1 100644
--- a/internal/ent/generated/entitlementplanfeature_update.go
+++ b/internal/ent/generated/entitlementplanfeature_update.go
@@ -14,17 +14,17 @@ import (
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/entitlementplanfeature"
"github.com/theopenlane/core/internal/ent/generated/event"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// EntitlementPlanFeatureUpdate is the builder for updating EntitlementPlanFeature entities.
type EntitlementPlanFeatureUpdate struct {
config
- hooks []Hook
- mutation *EntitlementPlanFeatureMutation
+ hooks []Hook
+ mutation *EntitlementPlanFeatureMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the EntitlementPlanFeatureUpdate builder.
@@ -265,6 +265,12 @@ func (epfu *EntitlementPlanFeatureUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (epfu *EntitlementPlanFeatureUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EntitlementPlanFeatureUpdate {
+ epfu.modifiers = append(epfu.modifiers, modifiers...)
+ return epfu
+}
+
func (epfu *EntitlementPlanFeatureUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := epfu.check(); err != nil {
return n, err
@@ -405,6 +411,7 @@ func (epfu *EntitlementPlanFeatureUpdate) sqlSave(ctx context.Context) (n int, e
}
_spec.Node.Schema = epfu.schemaConfig.EntitlementPlanFeature
ctx = internal.NewSchemaConfigContext(ctx, epfu.schemaConfig)
+ _spec.AddModifiers(epfu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, epfu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{entitlementplanfeature.Label}
@@ -420,9 +427,10 @@ func (epfu *EntitlementPlanFeatureUpdate) sqlSave(ctx context.Context) (n int, e
// EntitlementPlanFeatureUpdateOne is the builder for updating a single EntitlementPlanFeature entity.
type EntitlementPlanFeatureUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *EntitlementPlanFeatureMutation
+ fields []string
+ hooks []Hook
+ mutation *EntitlementPlanFeatureMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -670,6 +678,12 @@ func (epfuo *EntitlementPlanFeatureUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (epfuo *EntitlementPlanFeatureUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EntitlementPlanFeatureUpdateOne {
+ epfuo.modifiers = append(epfuo.modifiers, modifiers...)
+ return epfuo
+}
+
func (epfuo *EntitlementPlanFeatureUpdateOne) sqlSave(ctx context.Context) (_node *EntitlementPlanFeature, err error) {
if err := epfuo.check(); err != nil {
return _node, err
@@ -827,6 +841,7 @@ func (epfuo *EntitlementPlanFeatureUpdateOne) sqlSave(ctx context.Context) (_nod
}
_spec.Node.Schema = epfuo.schemaConfig.EntitlementPlanFeature
ctx = internal.NewSchemaConfigContext(ctx, epfuo.schemaConfig)
+ _spec.AddModifiers(epfuo.modifiers...)
_node = &EntitlementPlanFeature{config: epfuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/entitlementplanfeaturehistory_delete.go b/internal/ent/generated/entitlementplanfeaturehistory_delete.go
index 4b749b0d..dbf8fdef 100644
--- a/internal/ent/generated/entitlementplanfeaturehistory_delete.go
+++ b/internal/ent/generated/entitlementplanfeaturehistory_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/entitlementplanfeaturehistory"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EntitlementPlanFeatureHistoryDelete is the builder for deleting a EntitlementPlanFeatureHistory entity.
diff --git a/internal/ent/generated/entitlementplanfeaturehistory_query.go b/internal/ent/generated/entitlementplanfeaturehistory_query.go
index 9e56a048..188398e0 100644
--- a/internal/ent/generated/entitlementplanfeaturehistory_query.go
+++ b/internal/ent/generated/entitlementplanfeaturehistory_query.go
@@ -13,9 +13,8 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/entitlementplanfeaturehistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EntitlementPlanFeatureHistoryQuery is the builder for querying EntitlementPlanFeatureHistory entities.
@@ -25,8 +24,8 @@ type EntitlementPlanFeatureHistoryQuery struct {
order []entitlementplanfeaturehistory.OrderOption
inters []Interceptor
predicates []predicate.EntitlementPlanFeatureHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*EntitlementPlanFeatureHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -256,8 +255,9 @@ func (epfhq *EntitlementPlanFeatureHistoryQuery) Clone() *EntitlementPlanFeature
inters: append([]Interceptor{}, epfhq.inters...),
predicates: append([]predicate.EntitlementPlanFeatureHistory{}, epfhq.predicates...),
// clone intermediate query.
- sql: epfhq.sql.Clone(),
- path: epfhq.path,
+ sql: epfhq.sql.Clone(),
+ path: epfhq.path,
+ modifiers: append([]func(*sql.Selector){}, epfhq.modifiers...),
}
}
@@ -448,6 +448,9 @@ func (epfhq *EntitlementPlanFeatureHistoryQuery) sqlQuery(ctx context.Context) *
t1.Schema(epfhq.schemaConfig.EntitlementPlanFeatureHistory)
ctx = internal.NewSchemaConfigContext(ctx, epfhq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range epfhq.modifiers {
+ m(selector)
+ }
for _, p := range epfhq.predicates {
p(selector)
}
@@ -465,6 +468,12 @@ func (epfhq *EntitlementPlanFeatureHistoryQuery) sqlQuery(ctx context.Context) *
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (epfhq *EntitlementPlanFeatureHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *EntitlementPlanFeatureHistorySelect {
+ epfhq.modifiers = append(epfhq.modifiers, modifiers...)
+ return epfhq.Select()
+}
+
// EntitlementPlanFeatureHistoryGroupBy is the group-by builder for EntitlementPlanFeatureHistory entities.
type EntitlementPlanFeatureHistoryGroupBy struct {
selector
@@ -554,3 +563,9 @@ func (epfhs *EntitlementPlanFeatureHistorySelect) sqlScan(ctx context.Context, r
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (epfhs *EntitlementPlanFeatureHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *EntitlementPlanFeatureHistorySelect {
+ epfhs.modifiers = append(epfhs.modifiers, modifiers...)
+ return epfhs
+}
diff --git a/internal/ent/generated/entitlementplanfeaturehistory_update.go b/internal/ent/generated/entitlementplanfeaturehistory_update.go
index a1ed7ce3..ff56cb0b 100644
--- a/internal/ent/generated/entitlementplanfeaturehistory_update.go
+++ b/internal/ent/generated/entitlementplanfeaturehistory_update.go
@@ -13,16 +13,16 @@ import (
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/entitlementplanfeaturehistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EntitlementPlanFeatureHistoryUpdate is the builder for updating EntitlementPlanFeatureHistory entities.
type EntitlementPlanFeatureHistoryUpdate struct {
config
- hooks []Hook
- mutation *EntitlementPlanFeatureHistoryMutation
+ hooks []Hook
+ mutation *EntitlementPlanFeatureHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the EntitlementPlanFeatureHistoryUpdate builder.
@@ -200,6 +200,12 @@ func (epfhu *EntitlementPlanFeatureHistoryUpdate) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (epfhu *EntitlementPlanFeatureHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EntitlementPlanFeatureHistoryUpdate {
+ epfhu.modifiers = append(epfhu.modifiers, modifiers...)
+ return epfhu
+}
+
func (epfhu *EntitlementPlanFeatureHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(entitlementplanfeaturehistory.Table, entitlementplanfeaturehistory.Columns, sqlgraph.NewFieldSpec(entitlementplanfeaturehistory.FieldID, field.TypeString))
if ps := epfhu.mutation.predicates; len(ps) > 0 {
@@ -267,6 +273,7 @@ func (epfhu *EntitlementPlanFeatureHistoryUpdate) sqlSave(ctx context.Context) (
}
_spec.Node.Schema = epfhu.schemaConfig.EntitlementPlanFeatureHistory
ctx = internal.NewSchemaConfigContext(ctx, epfhu.schemaConfig)
+ _spec.AddModifiers(epfhu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, epfhu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{entitlementplanfeaturehistory.Label}
@@ -282,9 +289,10 @@ func (epfhu *EntitlementPlanFeatureHistoryUpdate) sqlSave(ctx context.Context) (
// EntitlementPlanFeatureHistoryUpdateOne is the builder for updating a single EntitlementPlanFeatureHistory entity.
type EntitlementPlanFeatureHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *EntitlementPlanFeatureHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *EntitlementPlanFeatureHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -469,6 +477,12 @@ func (epfhuo *EntitlementPlanFeatureHistoryUpdateOne) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (epfhuo *EntitlementPlanFeatureHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EntitlementPlanFeatureHistoryUpdateOne {
+ epfhuo.modifiers = append(epfhuo.modifiers, modifiers...)
+ return epfhuo
+}
+
func (epfhuo *EntitlementPlanFeatureHistoryUpdateOne) sqlSave(ctx context.Context) (_node *EntitlementPlanFeatureHistory, err error) {
_spec := sqlgraph.NewUpdateSpec(entitlementplanfeaturehistory.Table, entitlementplanfeaturehistory.Columns, sqlgraph.NewFieldSpec(entitlementplanfeaturehistory.FieldID, field.TypeString))
id, ok := epfhuo.mutation.ID()
@@ -553,6 +567,7 @@ func (epfhuo *EntitlementPlanFeatureHistoryUpdateOne) sqlSave(ctx context.Contex
}
_spec.Node.Schema = epfhuo.schemaConfig.EntitlementPlanFeatureHistory
ctx = internal.NewSchemaConfigContext(ctx, epfhuo.schemaConfig)
+ _spec.AddModifiers(epfhuo.modifiers...)
_node = &EntitlementPlanFeatureHistory{config: epfhuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/entitlementplanhistory_delete.go b/internal/ent/generated/entitlementplanhistory_delete.go
index de0815b9..1c2d22e8 100644
--- a/internal/ent/generated/entitlementplanhistory_delete.go
+++ b/internal/ent/generated/entitlementplanhistory_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/entitlementplanhistory"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EntitlementPlanHistoryDelete is the builder for deleting a EntitlementPlanHistory entity.
diff --git a/internal/ent/generated/entitlementplanhistory_query.go b/internal/ent/generated/entitlementplanhistory_query.go
index 3a44a407..be998fb8 100644
--- a/internal/ent/generated/entitlementplanhistory_query.go
+++ b/internal/ent/generated/entitlementplanhistory_query.go
@@ -13,9 +13,8 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/entitlementplanhistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EntitlementPlanHistoryQuery is the builder for querying EntitlementPlanHistory entities.
@@ -25,8 +24,8 @@ type EntitlementPlanHistoryQuery struct {
order []entitlementplanhistory.OrderOption
inters []Interceptor
predicates []predicate.EntitlementPlanHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*EntitlementPlanHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -256,8 +255,9 @@ func (ephq *EntitlementPlanHistoryQuery) Clone() *EntitlementPlanHistoryQuery {
inters: append([]Interceptor{}, ephq.inters...),
predicates: append([]predicate.EntitlementPlanHistory{}, ephq.predicates...),
// clone intermediate query.
- sql: ephq.sql.Clone(),
- path: ephq.path,
+ sql: ephq.sql.Clone(),
+ path: ephq.path,
+ modifiers: append([]func(*sql.Selector){}, ephq.modifiers...),
}
}
@@ -448,6 +448,9 @@ func (ephq *EntitlementPlanHistoryQuery) sqlQuery(ctx context.Context) *sql.Sele
t1.Schema(ephq.schemaConfig.EntitlementPlanHistory)
ctx = internal.NewSchemaConfigContext(ctx, ephq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range ephq.modifiers {
+ m(selector)
+ }
for _, p := range ephq.predicates {
p(selector)
}
@@ -465,6 +468,12 @@ func (ephq *EntitlementPlanHistoryQuery) sqlQuery(ctx context.Context) *sql.Sele
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ephq *EntitlementPlanHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *EntitlementPlanHistorySelect {
+ ephq.modifiers = append(ephq.modifiers, modifiers...)
+ return ephq.Select()
+}
+
// EntitlementPlanHistoryGroupBy is the group-by builder for EntitlementPlanHistory entities.
type EntitlementPlanHistoryGroupBy struct {
selector
@@ -554,3 +563,9 @@ func (ephs *EntitlementPlanHistorySelect) sqlScan(ctx context.Context, root *Ent
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ephs *EntitlementPlanHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *EntitlementPlanHistorySelect {
+ ephs.modifiers = append(ephs.modifiers, modifiers...)
+ return ephs
+}
diff --git a/internal/ent/generated/entitlementplanhistory_update.go b/internal/ent/generated/entitlementplanhistory_update.go
index 095466cc..cebb881d 100644
--- a/internal/ent/generated/entitlementplanhistory_update.go
+++ b/internal/ent/generated/entitlementplanhistory_update.go
@@ -13,16 +13,16 @@ import (
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/entitlementplanhistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EntitlementPlanHistoryUpdate is the builder for updating EntitlementPlanHistory entities.
type EntitlementPlanHistoryUpdate struct {
config
- hooks []Hook
- mutation *EntitlementPlanHistoryMutation
+ hooks []Hook
+ mutation *EntitlementPlanHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the EntitlementPlanHistoryUpdate builder.
@@ -240,6 +240,12 @@ func (ephu *EntitlementPlanHistoryUpdate) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ephu *EntitlementPlanHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EntitlementPlanHistoryUpdate {
+ ephu.modifiers = append(ephu.modifiers, modifiers...)
+ return ephu
+}
+
func (ephu *EntitlementPlanHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(entitlementplanhistory.Table, entitlementplanhistory.Columns, sqlgraph.NewFieldSpec(entitlementplanhistory.FieldID, field.TypeString))
if ps := ephu.mutation.predicates; len(ps) > 0 {
@@ -319,6 +325,7 @@ func (ephu *EntitlementPlanHistoryUpdate) sqlSave(ctx context.Context) (n int, e
}
_spec.Node.Schema = ephu.schemaConfig.EntitlementPlanHistory
ctx = internal.NewSchemaConfigContext(ctx, ephu.schemaConfig)
+ _spec.AddModifiers(ephu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, ephu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{entitlementplanhistory.Label}
@@ -334,9 +341,10 @@ func (ephu *EntitlementPlanHistoryUpdate) sqlSave(ctx context.Context) (n int, e
// EntitlementPlanHistoryUpdateOne is the builder for updating a single EntitlementPlanHistory entity.
type EntitlementPlanHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *EntitlementPlanHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *EntitlementPlanHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -561,6 +569,12 @@ func (ephuo *EntitlementPlanHistoryUpdateOne) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ephuo *EntitlementPlanHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EntitlementPlanHistoryUpdateOne {
+ ephuo.modifiers = append(ephuo.modifiers, modifiers...)
+ return ephuo
+}
+
func (ephuo *EntitlementPlanHistoryUpdateOne) sqlSave(ctx context.Context) (_node *EntitlementPlanHistory, err error) {
_spec := sqlgraph.NewUpdateSpec(entitlementplanhistory.Table, entitlementplanhistory.Columns, sqlgraph.NewFieldSpec(entitlementplanhistory.FieldID, field.TypeString))
id, ok := ephuo.mutation.ID()
@@ -657,6 +671,7 @@ func (ephuo *EntitlementPlanHistoryUpdateOne) sqlSave(ctx context.Context) (_nod
}
_spec.Node.Schema = ephuo.schemaConfig.EntitlementPlanHistory
ctx = internal.NewSchemaConfigContext(ctx, ephuo.schemaConfig)
+ _spec.AddModifiers(ephuo.modifiers...)
_node = &EntitlementPlanHistory{config: ephuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/entity/where.go b/internal/ent/generated/entity/where.go
index dd821670..86122203 100644
--- a/internal/ent/generated/entity/where.go
+++ b/internal/ent/generated/entity/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/entity_delete.go b/internal/ent/generated/entity_delete.go
index f457caec..c366c348 100644
--- a/internal/ent/generated/entity_delete.go
+++ b/internal/ent/generated/entity_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/entity"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EntityDelete is the builder for deleting a Entity entity.
diff --git a/internal/ent/generated/entity_query.go b/internal/ent/generated/entity_query.go
index 07c36285..ab1e57bd 100644
--- a/internal/ent/generated/entity_query.go
+++ b/internal/ent/generated/entity_query.go
@@ -18,11 +18,10 @@ import (
"github.com/theopenlane/core/internal/ent/generated/entity"
"github.com/theopenlane/core/internal/ent/generated/entitytype"
"github.com/theopenlane/core/internal/ent/generated/file"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/note"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// EntityQuery is the builder for querying Entity entities.
@@ -39,8 +38,8 @@ type EntityQuery struct {
withFiles *FileQuery
withEntityType *EntityTypeQuery
withFKs bool
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*Entity) error
+ modifiers []func(*sql.Selector)
withNamedContacts map[string]*ContactQuery
withNamedDocuments map[string]*DocumentDataQuery
withNamedNotes map[string]*NoteQuery
@@ -430,8 +429,9 @@ func (eq *EntityQuery) Clone() *EntityQuery {
withFiles: eq.withFiles.Clone(),
withEntityType: eq.withEntityType.Clone(),
// clone intermediate query.
- sql: eq.sql.Clone(),
- path: eq.path,
+ sql: eq.sql.Clone(),
+ path: eq.path,
+ modifiers: append([]func(*sql.Selector){}, eq.modifiers...),
}
}
@@ -1051,6 +1051,9 @@ func (eq *EntityQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(eq.schemaConfig.Entity)
ctx = internal.NewSchemaConfigContext(ctx, eq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range eq.modifiers {
+ m(selector)
+ }
for _, p := range eq.predicates {
p(selector)
}
@@ -1068,6 +1071,12 @@ func (eq *EntityQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (eq *EntityQuery) Modify(modifiers ...func(s *sql.Selector)) *EntitySelect {
+ eq.modifiers = append(eq.modifiers, modifiers...)
+ return eq.Select()
+}
+
// WithNamedContacts tells the query-builder to eager-load the nodes that are connected to the "contacts"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (eq *EntityQuery) WithNamedContacts(name string, opts ...func(*ContactQuery)) *EntityQuery {
@@ -1213,3 +1222,9 @@ func (es *EntitySelect) sqlScan(ctx context.Context, root *EntityQuery, v any) e
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (es *EntitySelect) Modify(modifiers ...func(s *sql.Selector)) *EntitySelect {
+ es.modifiers = append(es.modifiers, modifiers...)
+ return es
+}
diff --git a/internal/ent/generated/entity_update.go b/internal/ent/generated/entity_update.go
index 07a2a632..bba3c1f6 100644
--- a/internal/ent/generated/entity_update.go
+++ b/internal/ent/generated/entity_update.go
@@ -17,18 +17,18 @@ import (
"github.com/theopenlane/core/internal/ent/generated/entity"
"github.com/theopenlane/core/internal/ent/generated/entitytype"
"github.com/theopenlane/core/internal/ent/generated/file"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/note"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// EntityUpdate is the builder for updating Entity entities.
type EntityUpdate struct {
config
- hooks []Hook
- mutation *EntityMutation
+ hooks []Hook
+ mutation *EntityMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the EntityUpdate builder.
@@ -503,6 +503,12 @@ func (eu *EntityUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (eu *EntityUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EntityUpdate {
+ eu.modifiers = append(eu.modifiers, modifiers...)
+ return eu
+}
+
func (eu *EntityUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := eu.check(); err != nil {
return n, err
@@ -847,6 +853,7 @@ func (eu *EntityUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = eu.schemaConfig.Entity
ctx = internal.NewSchemaConfigContext(ctx, eu.schemaConfig)
+ _spec.AddModifiers(eu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, eu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{entity.Label}
@@ -862,9 +869,10 @@ func (eu *EntityUpdate) sqlSave(ctx context.Context) (n int, err error) {
// EntityUpdateOne is the builder for updating a single Entity entity.
type EntityUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *EntityMutation
+ fields []string
+ hooks []Hook
+ mutation *EntityMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -1346,6 +1354,12 @@ func (euo *EntityUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (euo *EntityUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EntityUpdateOne {
+ euo.modifiers = append(euo.modifiers, modifiers...)
+ return euo
+}
+
func (euo *EntityUpdateOne) sqlSave(ctx context.Context) (_node *Entity, err error) {
if err := euo.check(); err != nil {
return _node, err
@@ -1707,6 +1721,7 @@ func (euo *EntityUpdateOne) sqlSave(ctx context.Context) (_node *Entity, err err
}
_spec.Node.Schema = euo.schemaConfig.Entity
ctx = internal.NewSchemaConfigContext(ctx, euo.schemaConfig)
+ _spec.AddModifiers(euo.modifiers...)
_node = &Entity{config: euo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/entityhistory_delete.go b/internal/ent/generated/entityhistory_delete.go
index 5788c516..a506f334 100644
--- a/internal/ent/generated/entityhistory_delete.go
+++ b/internal/ent/generated/entityhistory_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/entityhistory"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EntityHistoryDelete is the builder for deleting a EntityHistory entity.
diff --git a/internal/ent/generated/entityhistory_query.go b/internal/ent/generated/entityhistory_query.go
index bf735bdf..78c13c83 100644
--- a/internal/ent/generated/entityhistory_query.go
+++ b/internal/ent/generated/entityhistory_query.go
@@ -13,9 +13,8 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/entityhistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EntityHistoryQuery is the builder for querying EntityHistory entities.
@@ -25,8 +24,8 @@ type EntityHistoryQuery struct {
order []entityhistory.OrderOption
inters []Interceptor
predicates []predicate.EntityHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*EntityHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -256,8 +255,9 @@ func (ehq *EntityHistoryQuery) Clone() *EntityHistoryQuery {
inters: append([]Interceptor{}, ehq.inters...),
predicates: append([]predicate.EntityHistory{}, ehq.predicates...),
// clone intermediate query.
- sql: ehq.sql.Clone(),
- path: ehq.path,
+ sql: ehq.sql.Clone(),
+ path: ehq.path,
+ modifiers: append([]func(*sql.Selector){}, ehq.modifiers...),
}
}
@@ -448,6 +448,9 @@ func (ehq *EntityHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(ehq.schemaConfig.EntityHistory)
ctx = internal.NewSchemaConfigContext(ctx, ehq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range ehq.modifiers {
+ m(selector)
+ }
for _, p := range ehq.predicates {
p(selector)
}
@@ -465,6 +468,12 @@ func (ehq *EntityHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ehq *EntityHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *EntityHistorySelect {
+ ehq.modifiers = append(ehq.modifiers, modifiers...)
+ return ehq.Select()
+}
+
// EntityHistoryGroupBy is the group-by builder for EntityHistory entities.
type EntityHistoryGroupBy struct {
selector
@@ -554,3 +563,9 @@ func (ehs *EntityHistorySelect) sqlScan(ctx context.Context, root *EntityHistory
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ehs *EntityHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *EntityHistorySelect {
+ ehs.modifiers = append(ehs.modifiers, modifiers...)
+ return ehs
+}
diff --git a/internal/ent/generated/entityhistory_update.go b/internal/ent/generated/entityhistory_update.go
index 240c58e8..c36975db 100644
--- a/internal/ent/generated/entityhistory_update.go
+++ b/internal/ent/generated/entityhistory_update.go
@@ -13,16 +13,16 @@ import (
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/entityhistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EntityHistoryUpdate is the builder for updating EntityHistory entities.
type EntityHistoryUpdate struct {
config
- hooks []Hook
- mutation *EntityHistoryMutation
+ hooks []Hook
+ mutation *EntityHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the EntityHistoryUpdate builder.
@@ -306,6 +306,12 @@ func (ehu *EntityHistoryUpdate) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ehu *EntityHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EntityHistoryUpdate {
+ ehu.modifiers = append(ehu.modifiers, modifiers...)
+ return ehu
+}
+
func (ehu *EntityHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(entityhistory.Table, entityhistory.Columns, sqlgraph.NewFieldSpec(entityhistory.FieldID, field.TypeString))
if ps := ehu.mutation.predicates; len(ps) > 0 {
@@ -408,6 +414,7 @@ func (ehu *EntityHistoryUpdate) sqlSave(ctx context.Context) (n int, err error)
}
_spec.Node.Schema = ehu.schemaConfig.EntityHistory
ctx = internal.NewSchemaConfigContext(ctx, ehu.schemaConfig)
+ _spec.AddModifiers(ehu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, ehu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{entityhistory.Label}
@@ -423,9 +430,10 @@ func (ehu *EntityHistoryUpdate) sqlSave(ctx context.Context) (n int, err error)
// EntityHistoryUpdateOne is the builder for updating a single EntityHistory entity.
type EntityHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *EntityHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *EntityHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -716,6 +724,12 @@ func (ehuo *EntityHistoryUpdateOne) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ehuo *EntityHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EntityHistoryUpdateOne {
+ ehuo.modifiers = append(ehuo.modifiers, modifiers...)
+ return ehuo
+}
+
func (ehuo *EntityHistoryUpdateOne) sqlSave(ctx context.Context) (_node *EntityHistory, err error) {
_spec := sqlgraph.NewUpdateSpec(entityhistory.Table, entityhistory.Columns, sqlgraph.NewFieldSpec(entityhistory.FieldID, field.TypeString))
id, ok := ehuo.mutation.ID()
@@ -835,6 +849,7 @@ func (ehuo *EntityHistoryUpdateOne) sqlSave(ctx context.Context) (_node *EntityH
}
_spec.Node.Schema = ehuo.schemaConfig.EntityHistory
ctx = internal.NewSchemaConfigContext(ctx, ehuo.schemaConfig)
+ _spec.AddModifiers(ehuo.modifiers...)
_node = &EntityHistory{config: ehuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/entitytype/where.go b/internal/ent/generated/entitytype/where.go
index 384911c1..83722a48 100644
--- a/internal/ent/generated/entitytype/where.go
+++ b/internal/ent/generated/entitytype/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/entitytype_delete.go b/internal/ent/generated/entitytype_delete.go
index c7e14c0d..5d451774 100644
--- a/internal/ent/generated/entitytype_delete.go
+++ b/internal/ent/generated/entitytype_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/entitytype"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EntityTypeDelete is the builder for deleting a EntityType entity.
diff --git a/internal/ent/generated/entitytype_query.go b/internal/ent/generated/entitytype_query.go
index 935fcda6..15ac5a45 100644
--- a/internal/ent/generated/entitytype_query.go
+++ b/internal/ent/generated/entitytype_query.go
@@ -15,10 +15,9 @@ import (
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/entity"
"github.com/theopenlane/core/internal/ent/generated/entitytype"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// EntityTypeQuery is the builder for querying EntityType entities.
@@ -30,8 +29,8 @@ type EntityTypeQuery struct {
predicates []predicate.EntityType
withOwner *OrganizationQuery
withEntities *EntityQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*EntityType) error
+ modifiers []func(*sql.Selector)
withNamedEntities map[string]*EntityQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
@@ -314,8 +313,9 @@ func (etq *EntityTypeQuery) Clone() *EntityTypeQuery {
withOwner: etq.withOwner.Clone(),
withEntities: etq.withEntities.Clone(),
// clone intermediate query.
- sql: etq.sql.Clone(),
- path: etq.path,
+ sql: etq.sql.Clone(),
+ path: etq.path,
+ modifiers: append([]func(*sql.Selector){}, etq.modifiers...),
}
}
@@ -617,6 +617,9 @@ func (etq *EntityTypeQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(etq.schemaConfig.EntityType)
ctx = internal.NewSchemaConfigContext(ctx, etq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range etq.modifiers {
+ m(selector)
+ }
for _, p := range etq.predicates {
p(selector)
}
@@ -634,6 +637,12 @@ func (etq *EntityTypeQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (etq *EntityTypeQuery) Modify(modifiers ...func(s *sql.Selector)) *EntityTypeSelect {
+ etq.modifiers = append(etq.modifiers, modifiers...)
+ return etq.Select()
+}
+
// WithNamedEntities tells the query-builder to eager-load the nodes that are connected to the "entities"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (etq *EntityTypeQuery) WithNamedEntities(name string, opts ...func(*EntityQuery)) *EntityTypeQuery {
@@ -737,3 +746,9 @@ func (ets *EntityTypeSelect) sqlScan(ctx context.Context, root *EntityTypeQuery,
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ets *EntityTypeSelect) Modify(modifiers ...func(s *sql.Selector)) *EntityTypeSelect {
+ ets.modifiers = append(ets.modifiers, modifiers...)
+ return ets
+}
diff --git a/internal/ent/generated/entitytype_update.go b/internal/ent/generated/entitytype_update.go
index c26b4911..30f6a26a 100644
--- a/internal/ent/generated/entitytype_update.go
+++ b/internal/ent/generated/entitytype_update.go
@@ -14,17 +14,17 @@ import (
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/entity"
"github.com/theopenlane/core/internal/ent/generated/entitytype"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// EntityTypeUpdate is the builder for updating EntityType entities.
type EntityTypeUpdate struct {
config
- hooks []Hook
- mutation *EntityTypeMutation
+ hooks []Hook
+ mutation *EntityTypeMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the EntityTypeUpdate builder.
@@ -266,6 +266,12 @@ func (etu *EntityTypeUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (etu *EntityTypeUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EntityTypeUpdate {
+ etu.modifiers = append(etu.modifiers, modifiers...)
+ return etu
+}
+
func (etu *EntityTypeUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := etu.check(); err != nil {
return n, err
@@ -403,6 +409,7 @@ func (etu *EntityTypeUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = etu.schemaConfig.EntityType
ctx = internal.NewSchemaConfigContext(ctx, etu.schemaConfig)
+ _spec.AddModifiers(etu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, etu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{entitytype.Label}
@@ -418,9 +425,10 @@ func (etu *EntityTypeUpdate) sqlSave(ctx context.Context) (n int, err error) {
// EntityTypeUpdateOne is the builder for updating a single EntityType entity.
type EntityTypeUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *EntityTypeMutation
+ fields []string
+ hooks []Hook
+ mutation *EntityTypeMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -669,6 +677,12 @@ func (etuo *EntityTypeUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (etuo *EntityTypeUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EntityTypeUpdateOne {
+ etuo.modifiers = append(etuo.modifiers, modifiers...)
+ return etuo
+}
+
func (etuo *EntityTypeUpdateOne) sqlSave(ctx context.Context) (_node *EntityType, err error) {
if err := etuo.check(); err != nil {
return _node, err
@@ -823,6 +837,7 @@ func (etuo *EntityTypeUpdateOne) sqlSave(ctx context.Context) (_node *EntityType
}
_spec.Node.Schema = etuo.schemaConfig.EntityType
ctx = internal.NewSchemaConfigContext(ctx, etuo.schemaConfig)
+ _spec.AddModifiers(etuo.modifiers...)
_node = &EntityType{config: etuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/entitytypehistory_delete.go b/internal/ent/generated/entitytypehistory_delete.go
index 41260007..130846be 100644
--- a/internal/ent/generated/entitytypehistory_delete.go
+++ b/internal/ent/generated/entitytypehistory_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/entitytypehistory"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EntityTypeHistoryDelete is the builder for deleting a EntityTypeHistory entity.
diff --git a/internal/ent/generated/entitytypehistory_query.go b/internal/ent/generated/entitytypehistory_query.go
index 61328ac0..be2485d8 100644
--- a/internal/ent/generated/entitytypehistory_query.go
+++ b/internal/ent/generated/entitytypehistory_query.go
@@ -13,9 +13,8 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/entitytypehistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EntityTypeHistoryQuery is the builder for querying EntityTypeHistory entities.
@@ -25,8 +24,8 @@ type EntityTypeHistoryQuery struct {
order []entitytypehistory.OrderOption
inters []Interceptor
predicates []predicate.EntityTypeHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*EntityTypeHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -256,8 +255,9 @@ func (ethq *EntityTypeHistoryQuery) Clone() *EntityTypeHistoryQuery {
inters: append([]Interceptor{}, ethq.inters...),
predicates: append([]predicate.EntityTypeHistory{}, ethq.predicates...),
// clone intermediate query.
- sql: ethq.sql.Clone(),
- path: ethq.path,
+ sql: ethq.sql.Clone(),
+ path: ethq.path,
+ modifiers: append([]func(*sql.Selector){}, ethq.modifiers...),
}
}
@@ -448,6 +448,9 @@ func (ethq *EntityTypeHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector
t1.Schema(ethq.schemaConfig.EntityTypeHistory)
ctx = internal.NewSchemaConfigContext(ctx, ethq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range ethq.modifiers {
+ m(selector)
+ }
for _, p := range ethq.predicates {
p(selector)
}
@@ -465,6 +468,12 @@ func (ethq *EntityTypeHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ethq *EntityTypeHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *EntityTypeHistorySelect {
+ ethq.modifiers = append(ethq.modifiers, modifiers...)
+ return ethq.Select()
+}
+
// EntityTypeHistoryGroupBy is the group-by builder for EntityTypeHistory entities.
type EntityTypeHistoryGroupBy struct {
selector
@@ -554,3 +563,9 @@ func (eths *EntityTypeHistorySelect) sqlScan(ctx context.Context, root *EntityTy
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (eths *EntityTypeHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *EntityTypeHistorySelect {
+ eths.modifiers = append(eths.modifiers, modifiers...)
+ return eths
+}
diff --git a/internal/ent/generated/entitytypehistory_update.go b/internal/ent/generated/entitytypehistory_update.go
index 90437d71..c5bce8fc 100644
--- a/internal/ent/generated/entitytypehistory_update.go
+++ b/internal/ent/generated/entitytypehistory_update.go
@@ -13,16 +13,16 @@ import (
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/entitytypehistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EntityTypeHistoryUpdate is the builder for updating EntityTypeHistory entities.
type EntityTypeHistoryUpdate struct {
config
- hooks []Hook
- mutation *EntityTypeHistoryMutation
+ hooks []Hook
+ mutation *EntityTypeHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the EntityTypeHistoryUpdate builder.
@@ -202,6 +202,12 @@ func (ethu *EntityTypeHistoryUpdate) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ethu *EntityTypeHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EntityTypeHistoryUpdate {
+ ethu.modifiers = append(ethu.modifiers, modifiers...)
+ return ethu
+}
+
func (ethu *EntityTypeHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(entitytypehistory.Table, entitytypehistory.Columns, sqlgraph.NewFieldSpec(entitytypehistory.FieldID, field.TypeString))
if ps := ethu.mutation.predicates; len(ps) > 0 {
@@ -266,6 +272,7 @@ func (ethu *EntityTypeHistoryUpdate) sqlSave(ctx context.Context) (n int, err er
}
_spec.Node.Schema = ethu.schemaConfig.EntityTypeHistory
ctx = internal.NewSchemaConfigContext(ctx, ethu.schemaConfig)
+ _spec.AddModifiers(ethu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, ethu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{entitytypehistory.Label}
@@ -281,9 +288,10 @@ func (ethu *EntityTypeHistoryUpdate) sqlSave(ctx context.Context) (n int, err er
// EntityTypeHistoryUpdateOne is the builder for updating a single EntityTypeHistory entity.
type EntityTypeHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *EntityTypeHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *EntityTypeHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -470,6 +478,12 @@ func (ethuo *EntityTypeHistoryUpdateOne) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ethuo *EntityTypeHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EntityTypeHistoryUpdateOne {
+ ethuo.modifiers = append(ethuo.modifiers, modifiers...)
+ return ethuo
+}
+
func (ethuo *EntityTypeHistoryUpdateOne) sqlSave(ctx context.Context) (_node *EntityTypeHistory, err error) {
_spec := sqlgraph.NewUpdateSpec(entitytypehistory.Table, entitytypehistory.Columns, sqlgraph.NewFieldSpec(entitytypehistory.FieldID, field.TypeString))
id, ok := ethuo.mutation.ID()
@@ -551,6 +565,7 @@ func (ethuo *EntityTypeHistoryUpdateOne) sqlSave(ctx context.Context) (_node *En
}
_spec.Node.Schema = ethuo.schemaConfig.EntityTypeHistory
ctx = internal.NewSchemaConfigContext(ctx, ethuo.schemaConfig)
+ _spec.AddModifiers(ethuo.modifiers...)
_node = &EntityTypeHistory{config: ethuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/event/where.go b/internal/ent/generated/event/where.go
index a868af1c..13843421 100644
--- a/internal/ent/generated/event/where.go
+++ b/internal/ent/generated/event/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/event_delete.go b/internal/ent/generated/event_delete.go
index 45ecc74f..61569dea 100644
--- a/internal/ent/generated/event_delete.go
+++ b/internal/ent/generated/event_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/event"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EventDelete is the builder for deleting a Event entity.
diff --git a/internal/ent/generated/event_query.go b/internal/ent/generated/event_query.go
index 239e00d9..db90128a 100644
--- a/internal/ent/generated/event_query.go
+++ b/internal/ent/generated/event_query.go
@@ -21,6 +21,7 @@ import (
"github.com/theopenlane/core/internal/ent/generated/groupmembership"
"github.com/theopenlane/core/internal/ent/generated/hush"
"github.com/theopenlane/core/internal/ent/generated/integration"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/invite"
"github.com/theopenlane/core/internal/ent/generated/ohauthtootoken"
"github.com/theopenlane/core/internal/ent/generated/organization"
@@ -30,8 +31,6 @@ import (
"github.com/theopenlane/core/internal/ent/generated/subscriber"
"github.com/theopenlane/core/internal/ent/generated/user"
"github.com/theopenlane/core/internal/ent/generated/webhook"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// EventQuery is the builder for querying Event entities.
@@ -57,8 +56,8 @@ type EventQuery struct {
withEntitlement *EntitlementQuery
withWebhook *WebhookQuery
withSubscriber *SubscriberQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*Event) error
+ modifiers []func(*sql.Selector)
withNamedUser map[string]*UserQuery
withNamedGroup map[string]*GroupQuery
withNamedIntegration map[string]*IntegrationQuery
@@ -720,8 +719,9 @@ func (eq *EventQuery) Clone() *EventQuery {
withWebhook: eq.withWebhook.Clone(),
withSubscriber: eq.withSubscriber.Clone(),
// clone intermediate query.
- sql: eq.sql.Clone(),
- path: eq.path,
+ sql: eq.sql.Clone(),
+ path: eq.path,
+ modifiers: append([]func(*sql.Selector){}, eq.modifiers...),
}
}
@@ -2322,6 +2322,9 @@ func (eq *EventQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(eq.schemaConfig.Event)
ctx = internal.NewSchemaConfigContext(ctx, eq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range eq.modifiers {
+ m(selector)
+ }
for _, p := range eq.predicates {
p(selector)
}
@@ -2339,6 +2342,12 @@ func (eq *EventQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (eq *EventQuery) Modify(modifiers ...func(s *sql.Selector)) *EventSelect {
+ eq.modifiers = append(eq.modifiers, modifiers...)
+ return eq.Select()
+}
+
// WithNamedUser tells the query-builder to eager-load the nodes that are connected to the "user"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (eq *EventQuery) WithNamedUser(name string, opts ...func(*UserQuery)) *EventQuery {
@@ -2652,3 +2661,9 @@ func (es *EventSelect) sqlScan(ctx context.Context, root *EventQuery, v any) err
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (es *EventSelect) Modify(modifiers ...func(s *sql.Selector)) *EventSelect {
+ es.modifiers = append(es.modifiers, modifiers...)
+ return es
+}
diff --git a/internal/ent/generated/event_update.go b/internal/ent/generated/event_update.go
index 84a20542..de9ee438 100644
--- a/internal/ent/generated/event_update.go
+++ b/internal/ent/generated/event_update.go
@@ -21,6 +21,7 @@ import (
"github.com/theopenlane/core/internal/ent/generated/groupmembership"
"github.com/theopenlane/core/internal/ent/generated/hush"
"github.com/theopenlane/core/internal/ent/generated/integration"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/invite"
"github.com/theopenlane/core/internal/ent/generated/ohauthtootoken"
"github.com/theopenlane/core/internal/ent/generated/organization"
@@ -30,15 +31,14 @@ import (
"github.com/theopenlane/core/internal/ent/generated/subscriber"
"github.com/theopenlane/core/internal/ent/generated/user"
"github.com/theopenlane/core/internal/ent/generated/webhook"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// EventUpdate is the builder for updating Event entities.
type EventUpdate struct {
config
- hooks []Hook
- mutation *EventMutation
+ hooks []Hook
+ mutation *EventMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the EventUpdate builder.
@@ -786,6 +786,12 @@ func (eu *EventUpdate) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (eu *EventUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EventUpdate {
+ eu.modifiers = append(eu.modifiers, modifiers...)
+ return eu
+}
+
func (eu *EventUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(event.Table, event.Columns, sqlgraph.NewFieldSpec(event.FieldID, field.TypeString))
if ps := eu.mutation.predicates; len(ps) > 0 {
@@ -1615,6 +1621,7 @@ func (eu *EventUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = eu.schemaConfig.Event
ctx = internal.NewSchemaConfigContext(ctx, eu.schemaConfig)
+ _spec.AddModifiers(eu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, eu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{event.Label}
@@ -1630,9 +1637,10 @@ func (eu *EventUpdate) sqlSave(ctx context.Context) (n int, err error) {
// EventUpdateOne is the builder for updating a single Event entity.
type EventUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *EventMutation
+ fields []string
+ hooks []Hook
+ mutation *EventMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -2387,6 +2395,12 @@ func (euo *EventUpdateOne) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (euo *EventUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EventUpdateOne {
+ euo.modifiers = append(euo.modifiers, modifiers...)
+ return euo
+}
+
func (euo *EventUpdateOne) sqlSave(ctx context.Context) (_node *Event, err error) {
_spec := sqlgraph.NewUpdateSpec(event.Table, event.Columns, sqlgraph.NewFieldSpec(event.FieldID, field.TypeString))
id, ok := euo.mutation.ID()
@@ -3233,6 +3247,7 @@ func (euo *EventUpdateOne) sqlSave(ctx context.Context) (_node *Event, err error
}
_spec.Node.Schema = euo.schemaConfig.Event
ctx = internal.NewSchemaConfigContext(ctx, euo.schemaConfig)
+ _spec.AddModifiers(euo.modifiers...)
_node = &Event{config: euo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/eventhistory_delete.go b/internal/ent/generated/eventhistory_delete.go
index 7f3bde90..24cd628b 100644
--- a/internal/ent/generated/eventhistory_delete.go
+++ b/internal/ent/generated/eventhistory_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/eventhistory"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EventHistoryDelete is the builder for deleting a EventHistory entity.
diff --git a/internal/ent/generated/eventhistory_query.go b/internal/ent/generated/eventhistory_query.go
index 2ac2038d..454b77ea 100644
--- a/internal/ent/generated/eventhistory_query.go
+++ b/internal/ent/generated/eventhistory_query.go
@@ -12,9 +12,8 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/eventhistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EventHistoryQuery is the builder for querying EventHistory entities.
@@ -24,8 +23,8 @@ type EventHistoryQuery struct {
order []eventhistory.OrderOption
inters []Interceptor
predicates []predicate.EventHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*EventHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -255,8 +254,9 @@ func (ehq *EventHistoryQuery) Clone() *EventHistoryQuery {
inters: append([]Interceptor{}, ehq.inters...),
predicates: append([]predicate.EventHistory{}, ehq.predicates...),
// clone intermediate query.
- sql: ehq.sql.Clone(),
- path: ehq.path,
+ sql: ehq.sql.Clone(),
+ path: ehq.path,
+ modifiers: append([]func(*sql.Selector){}, ehq.modifiers...),
}
}
@@ -441,6 +441,9 @@ func (ehq *EventHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(ehq.schemaConfig.EventHistory)
ctx = internal.NewSchemaConfigContext(ctx, ehq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range ehq.modifiers {
+ m(selector)
+ }
for _, p := range ehq.predicates {
p(selector)
}
@@ -458,6 +461,12 @@ func (ehq *EventHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ehq *EventHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *EventHistorySelect {
+ ehq.modifiers = append(ehq.modifiers, modifiers...)
+ return ehq.Select()
+}
+
// EventHistoryGroupBy is the group-by builder for EventHistory entities.
type EventHistoryGroupBy struct {
selector
@@ -547,3 +556,9 @@ func (ehs *EventHistorySelect) sqlScan(ctx context.Context, root *EventHistoryQu
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ehs *EventHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *EventHistorySelect {
+ ehs.modifiers = append(ehs.modifiers, modifiers...)
+ return ehs
+}
diff --git a/internal/ent/generated/eventhistory_update.go b/internal/ent/generated/eventhistory_update.go
index 3ba762ad..e5ea8894 100644
--- a/internal/ent/generated/eventhistory_update.go
+++ b/internal/ent/generated/eventhistory_update.go
@@ -13,16 +13,16 @@ import (
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/eventhistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// EventHistoryUpdate is the builder for updating EventHistory entities.
type EventHistoryUpdate struct {
config
- hooks []Hook
- mutation *EventHistoryMutation
+ hooks []Hook
+ mutation *EventHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the EventHistoryUpdate builder.
@@ -188,6 +188,12 @@ func (ehu *EventHistoryUpdate) defaults() {
}
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ehu *EventHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EventHistoryUpdate {
+ ehu.modifiers = append(ehu.modifiers, modifiers...)
+ return ehu
+}
+
func (ehu *EventHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(eventhistory.Table, eventhistory.Columns, sqlgraph.NewFieldSpec(eventhistory.FieldID, field.TypeString))
if ps := ehu.mutation.predicates; len(ps) > 0 {
@@ -252,6 +258,7 @@ func (ehu *EventHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = ehu.schemaConfig.EventHistory
ctx = internal.NewSchemaConfigContext(ctx, ehu.schemaConfig)
+ _spec.AddModifiers(ehu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, ehu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{eventhistory.Label}
@@ -267,9 +274,10 @@ func (ehu *EventHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
// EventHistoryUpdateOne is the builder for updating a single EventHistory entity.
type EventHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *EventHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *EventHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -442,6 +450,12 @@ func (ehuo *EventHistoryUpdateOne) defaults() {
}
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ehuo *EventHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EventHistoryUpdateOne {
+ ehuo.modifiers = append(ehuo.modifiers, modifiers...)
+ return ehuo
+}
+
func (ehuo *EventHistoryUpdateOne) sqlSave(ctx context.Context) (_node *EventHistory, err error) {
_spec := sqlgraph.NewUpdateSpec(eventhistory.Table, eventhistory.Columns, sqlgraph.NewFieldSpec(eventhistory.FieldID, field.TypeString))
id, ok := ehuo.mutation.ID()
@@ -523,6 +537,7 @@ func (ehuo *EventHistoryUpdateOne) sqlSave(ctx context.Context) (_node *EventHis
}
_spec.Node.Schema = ehuo.schemaConfig.EventHistory
ctx = internal.NewSchemaConfigContext(ctx, ehuo.schemaConfig)
+ _spec.AddModifiers(ehuo.modifiers...)
_node = &EventHistory{config: ehuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/feature/where.go b/internal/ent/generated/feature/where.go
index fad74545..ed671473 100644
--- a/internal/ent/generated/feature/where.go
+++ b/internal/ent/generated/feature/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/feature_delete.go b/internal/ent/generated/feature_delete.go
index 7fd6db1b..cb7e9b68 100644
--- a/internal/ent/generated/feature_delete.go
+++ b/internal/ent/generated/feature_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/feature"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// FeatureDelete is the builder for deleting a Feature entity.
diff --git a/internal/ent/generated/feature_query.go b/internal/ent/generated/feature_query.go
index 113ccc13..c87558f3 100644
--- a/internal/ent/generated/feature_query.go
+++ b/internal/ent/generated/feature_query.go
@@ -17,10 +17,9 @@ import (
"github.com/theopenlane/core/internal/ent/generated/entitlementplanfeature"
"github.com/theopenlane/core/internal/ent/generated/event"
"github.com/theopenlane/core/internal/ent/generated/feature"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// FeatureQuery is the builder for querying Feature entities.
@@ -34,8 +33,8 @@ type FeatureQuery struct {
withPlans *EntitlementPlanQuery
withEvents *EventQuery
withFeatures *EntitlementPlanFeatureQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*Feature) error
+ modifiers []func(*sql.Selector)
withNamedPlans map[string]*EntitlementPlanQuery
withNamedEvents map[string]*EventQuery
withNamedFeatures map[string]*EntitlementPlanFeatureQuery
@@ -372,8 +371,9 @@ func (fq *FeatureQuery) Clone() *FeatureQuery {
withEvents: fq.withEvents.Clone(),
withFeatures: fq.withFeatures.Clone(),
// clone intermediate query.
- sql: fq.sql.Clone(),
- path: fq.path,
+ sql: fq.sql.Clone(),
+ path: fq.path,
+ modifiers: append([]func(*sql.Selector){}, fq.modifiers...),
}
}
@@ -850,6 +850,9 @@ func (fq *FeatureQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(fq.schemaConfig.Feature)
ctx = internal.NewSchemaConfigContext(ctx, fq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range fq.modifiers {
+ m(selector)
+ }
for _, p := range fq.predicates {
p(selector)
}
@@ -867,6 +870,12 @@ func (fq *FeatureQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (fq *FeatureQuery) Modify(modifiers ...func(s *sql.Selector)) *FeatureSelect {
+ fq.modifiers = append(fq.modifiers, modifiers...)
+ return fq.Select()
+}
+
// WithNamedPlans tells the query-builder to eager-load the nodes that are connected to the "plans"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (fq *FeatureQuery) WithNamedPlans(name string, opts ...func(*EntitlementPlanQuery)) *FeatureQuery {
@@ -998,3 +1007,9 @@ func (fs *FeatureSelect) sqlScan(ctx context.Context, root *FeatureQuery, v any)
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (fs *FeatureSelect) Modify(modifiers ...func(s *sql.Selector)) *FeatureSelect {
+ fs.modifiers = append(fs.modifiers, modifiers...)
+ return fs
+}
diff --git a/internal/ent/generated/feature_update.go b/internal/ent/generated/feature_update.go
index a4c08470..22487f06 100644
--- a/internal/ent/generated/feature_update.go
+++ b/internal/ent/generated/feature_update.go
@@ -16,17 +16,17 @@ import (
"github.com/theopenlane/core/internal/ent/generated/entitlementplanfeature"
"github.com/theopenlane/core/internal/ent/generated/event"
"github.com/theopenlane/core/internal/ent/generated/feature"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// FeatureUpdate is the builder for updating Feature entities.
type FeatureUpdate struct {
config
- hooks []Hook
- mutation *FeatureMutation
+ hooks []Hook
+ mutation *FeatureMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the FeatureUpdate builder.
@@ -387,6 +387,12 @@ func (fu *FeatureUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (fu *FeatureUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *FeatureUpdate {
+ fu.modifiers = append(fu.modifiers, modifiers...)
+ return fu
+}
+
func (fu *FeatureUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := fu.check(); err != nil {
return n, err
@@ -659,6 +665,7 @@ func (fu *FeatureUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = fu.schemaConfig.Feature
ctx = internal.NewSchemaConfigContext(ctx, fu.schemaConfig)
+ _spec.AddModifiers(fu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, fu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{feature.Label}
@@ -674,9 +681,10 @@ func (fu *FeatureUpdate) sqlSave(ctx context.Context) (n int, err error) {
// FeatureUpdateOne is the builder for updating a single Feature entity.
type FeatureUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *FeatureMutation
+ fields []string
+ hooks []Hook
+ mutation *FeatureMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -1044,6 +1052,12 @@ func (fuo *FeatureUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (fuo *FeatureUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *FeatureUpdateOne {
+ fuo.modifiers = append(fuo.modifiers, modifiers...)
+ return fuo
+}
+
func (fuo *FeatureUpdateOne) sqlSave(ctx context.Context) (_node *Feature, err error) {
if err := fuo.check(); err != nil {
return _node, err
@@ -1333,6 +1347,7 @@ func (fuo *FeatureUpdateOne) sqlSave(ctx context.Context) (_node *Feature, err e
}
_spec.Node.Schema = fuo.schemaConfig.Feature
ctx = internal.NewSchemaConfigContext(ctx, fuo.schemaConfig)
+ _spec.AddModifiers(fuo.modifiers...)
_node = &Feature{config: fuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/featurehistory_delete.go b/internal/ent/generated/featurehistory_delete.go
index 005e330b..c069f54b 100644
--- a/internal/ent/generated/featurehistory_delete.go
+++ b/internal/ent/generated/featurehistory_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/featurehistory"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// FeatureHistoryDelete is the builder for deleting a FeatureHistory entity.
diff --git a/internal/ent/generated/featurehistory_query.go b/internal/ent/generated/featurehistory_query.go
index 4cc193e5..15d24a60 100644
--- a/internal/ent/generated/featurehistory_query.go
+++ b/internal/ent/generated/featurehistory_query.go
@@ -13,9 +13,8 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/featurehistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// FeatureHistoryQuery is the builder for querying FeatureHistory entities.
@@ -25,8 +24,8 @@ type FeatureHistoryQuery struct {
order []featurehistory.OrderOption
inters []Interceptor
predicates []predicate.FeatureHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*FeatureHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -256,8 +255,9 @@ func (fhq *FeatureHistoryQuery) Clone() *FeatureHistoryQuery {
inters: append([]Interceptor{}, fhq.inters...),
predicates: append([]predicate.FeatureHistory{}, fhq.predicates...),
// clone intermediate query.
- sql: fhq.sql.Clone(),
- path: fhq.path,
+ sql: fhq.sql.Clone(),
+ path: fhq.path,
+ modifiers: append([]func(*sql.Selector){}, fhq.modifiers...),
}
}
@@ -448,6 +448,9 @@ func (fhq *FeatureHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(fhq.schemaConfig.FeatureHistory)
ctx = internal.NewSchemaConfigContext(ctx, fhq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range fhq.modifiers {
+ m(selector)
+ }
for _, p := range fhq.predicates {
p(selector)
}
@@ -465,6 +468,12 @@ func (fhq *FeatureHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (fhq *FeatureHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *FeatureHistorySelect {
+ fhq.modifiers = append(fhq.modifiers, modifiers...)
+ return fhq.Select()
+}
+
// FeatureHistoryGroupBy is the group-by builder for FeatureHistory entities.
type FeatureHistoryGroupBy struct {
selector
@@ -554,3 +563,9 @@ func (fhs *FeatureHistorySelect) sqlScan(ctx context.Context, root *FeatureHisto
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (fhs *FeatureHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *FeatureHistorySelect {
+ fhs.modifiers = append(fhs.modifiers, modifiers...)
+ return fhs
+}
diff --git a/internal/ent/generated/featurehistory_update.go b/internal/ent/generated/featurehistory_update.go
index c4eab127..20885acb 100644
--- a/internal/ent/generated/featurehistory_update.go
+++ b/internal/ent/generated/featurehistory_update.go
@@ -13,16 +13,16 @@ import (
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/featurehistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// FeatureHistoryUpdate is the builder for updating FeatureHistory entities.
type FeatureHistoryUpdate struct {
config
- hooks []Hook
- mutation *FeatureHistoryMutation
+ hooks []Hook
+ mutation *FeatureHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the FeatureHistoryUpdate builder.
@@ -254,6 +254,12 @@ func (fhu *FeatureHistoryUpdate) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (fhu *FeatureHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *FeatureHistoryUpdate {
+ fhu.modifiers = append(fhu.modifiers, modifiers...)
+ return fhu
+}
+
func (fhu *FeatureHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(featurehistory.Table, featurehistory.Columns, sqlgraph.NewFieldSpec(featurehistory.FieldID, field.TypeString))
if ps := fhu.mutation.predicates; len(ps) > 0 {
@@ -336,6 +342,7 @@ func (fhu *FeatureHistoryUpdate) sqlSave(ctx context.Context) (n int, err error)
}
_spec.Node.Schema = fhu.schemaConfig.FeatureHistory
ctx = internal.NewSchemaConfigContext(ctx, fhu.schemaConfig)
+ _spec.AddModifiers(fhu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, fhu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{featurehistory.Label}
@@ -351,9 +358,10 @@ func (fhu *FeatureHistoryUpdate) sqlSave(ctx context.Context) (n int, err error)
// FeatureHistoryUpdateOne is the builder for updating a single FeatureHistory entity.
type FeatureHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *FeatureHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *FeatureHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -592,6 +600,12 @@ func (fhuo *FeatureHistoryUpdateOne) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (fhuo *FeatureHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *FeatureHistoryUpdateOne {
+ fhuo.modifiers = append(fhuo.modifiers, modifiers...)
+ return fhuo
+}
+
func (fhuo *FeatureHistoryUpdateOne) sqlSave(ctx context.Context) (_node *FeatureHistory, err error) {
_spec := sqlgraph.NewUpdateSpec(featurehistory.Table, featurehistory.Columns, sqlgraph.NewFieldSpec(featurehistory.FieldID, field.TypeString))
id, ok := fhuo.mutation.ID()
@@ -691,6 +705,7 @@ func (fhuo *FeatureHistoryUpdateOne) sqlSave(ctx context.Context) (_node *Featur
}
_spec.Node.Schema = fhuo.schemaConfig.FeatureHistory
ctx = internal.NewSchemaConfigContext(ctx, fhuo.schemaConfig)
+ _spec.AddModifiers(fhuo.modifiers...)
_node = &FeatureHistory{config: fhuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/file/where.go b/internal/ent/generated/file/where.go
index 8dd77f9f..adef8082 100644
--- a/internal/ent/generated/file/where.go
+++ b/internal/ent/generated/file/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/file_delete.go b/internal/ent/generated/file_delete.go
index a96d36c2..8b212732 100644
--- a/internal/ent/generated/file_delete.go
+++ b/internal/ent/generated/file_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/file"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// FileDelete is the builder for deleting a File entity.
diff --git a/internal/ent/generated/file_query.go b/internal/ent/generated/file_query.go
index cff92ff3..9b2304bd 100644
--- a/internal/ent/generated/file_query.go
+++ b/internal/ent/generated/file_query.go
@@ -15,11 +15,10 @@ import (
"github.com/theopenlane/core/internal/ent/generated/entity"
"github.com/theopenlane/core/internal/ent/generated/file"
"github.com/theopenlane/core/internal/ent/generated/group"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/user"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// FileQuery is the builder for querying File entities.
@@ -34,8 +33,8 @@ type FileQuery struct {
withEntity *EntityQuery
withGroup *GroupQuery
withFKs bool
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*File) error
+ modifiers []func(*sql.Selector)
withNamedOrganization map[string]*OrganizationQuery
withNamedEntity map[string]*EntityQuery
withNamedGroup map[string]*GroupQuery
@@ -372,8 +371,9 @@ func (fq *FileQuery) Clone() *FileQuery {
withEntity: fq.withEntity.Clone(),
withGroup: fq.withGroup.Clone(),
// clone intermediate query.
- sql: fq.sql.Clone(),
- path: fq.path,
+ sql: fq.sql.Clone(),
+ path: fq.path,
+ modifiers: append([]func(*sql.Selector){}, fq.modifiers...),
}
}
@@ -883,6 +883,9 @@ func (fq *FileQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(fq.schemaConfig.File)
ctx = internal.NewSchemaConfigContext(ctx, fq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range fq.modifiers {
+ m(selector)
+ }
for _, p := range fq.predicates {
p(selector)
}
@@ -900,6 +903,12 @@ func (fq *FileQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (fq *FileQuery) Modify(modifiers ...func(s *sql.Selector)) *FileSelect {
+ fq.modifiers = append(fq.modifiers, modifiers...)
+ return fq.Select()
+}
+
// WithNamedOrganization tells the query-builder to eager-load the nodes that are connected to the "organization"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (fq *FileQuery) WithNamedOrganization(name string, opts ...func(*OrganizationQuery)) *FileQuery {
@@ -1031,3 +1040,9 @@ func (fs *FileSelect) sqlScan(ctx context.Context, root *FileQuery, v any) error
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (fs *FileSelect) Modify(modifiers ...func(s *sql.Selector)) *FileSelect {
+ fs.modifiers = append(fs.modifiers, modifiers...)
+ return fs
+}
diff --git a/internal/ent/generated/file_update.go b/internal/ent/generated/file_update.go
index f7862815..9da63496 100644
--- a/internal/ent/generated/file_update.go
+++ b/internal/ent/generated/file_update.go
@@ -15,18 +15,18 @@ import (
"github.com/theopenlane/core/internal/ent/generated/entity"
"github.com/theopenlane/core/internal/ent/generated/file"
"github.com/theopenlane/core/internal/ent/generated/group"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/user"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// FileUpdate is the builder for updating File entities.
type FileUpdate struct {
config
- hooks []Hook
- mutation *FileMutation
+ hooks []Hook
+ mutation *FileMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the FileUpdate builder.
@@ -438,6 +438,12 @@ func (fu *FileUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (fu *FileUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *FileUpdate {
+ fu.modifiers = append(fu.modifiers, modifiers...)
+ return fu
+}
+
func (fu *FileUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := fu.check(); err != nil {
return n, err
@@ -701,6 +707,7 @@ func (fu *FileUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = fu.schemaConfig.File
ctx = internal.NewSchemaConfigContext(ctx, fu.schemaConfig)
+ _spec.AddModifiers(fu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, fu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{file.Label}
@@ -716,9 +723,10 @@ func (fu *FileUpdate) sqlSave(ctx context.Context) (n int, err error) {
// FileUpdateOne is the builder for updating a single File entity.
type FileUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *FileMutation
+ fields []string
+ hooks []Hook
+ mutation *FileMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -1137,6 +1145,12 @@ func (fuo *FileUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (fuo *FileUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *FileUpdateOne {
+ fuo.modifiers = append(fuo.modifiers, modifiers...)
+ return fuo
+}
+
func (fuo *FileUpdateOne) sqlSave(ctx context.Context) (_node *File, err error) {
if err := fuo.check(); err != nil {
return _node, err
@@ -1417,6 +1431,7 @@ func (fuo *FileUpdateOne) sqlSave(ctx context.Context) (_node *File, err error)
}
_spec.Node.Schema = fuo.schemaConfig.File
ctx = internal.NewSchemaConfigContext(ctx, fuo.schemaConfig)
+ _spec.AddModifiers(fuo.modifiers...)
_node = &File{config: fuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/filehistory_delete.go b/internal/ent/generated/filehistory_delete.go
index acb09214..309ed305 100644
--- a/internal/ent/generated/filehistory_delete.go
+++ b/internal/ent/generated/filehistory_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/filehistory"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// FileHistoryDelete is the builder for deleting a FileHistory entity.
diff --git a/internal/ent/generated/filehistory_query.go b/internal/ent/generated/filehistory_query.go
index 43a12d7e..1183efb0 100644
--- a/internal/ent/generated/filehistory_query.go
+++ b/internal/ent/generated/filehistory_query.go
@@ -12,9 +12,8 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/filehistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// FileHistoryQuery is the builder for querying FileHistory entities.
@@ -24,8 +23,8 @@ type FileHistoryQuery struct {
order []filehistory.OrderOption
inters []Interceptor
predicates []predicate.FileHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*FileHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -255,8 +254,9 @@ func (fhq *FileHistoryQuery) Clone() *FileHistoryQuery {
inters: append([]Interceptor{}, fhq.inters...),
predicates: append([]predicate.FileHistory{}, fhq.predicates...),
// clone intermediate query.
- sql: fhq.sql.Clone(),
- path: fhq.path,
+ sql: fhq.sql.Clone(),
+ path: fhq.path,
+ modifiers: append([]func(*sql.Selector){}, fhq.modifiers...),
}
}
@@ -441,6 +441,9 @@ func (fhq *FileHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(fhq.schemaConfig.FileHistory)
ctx = internal.NewSchemaConfigContext(ctx, fhq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range fhq.modifiers {
+ m(selector)
+ }
for _, p := range fhq.predicates {
p(selector)
}
@@ -458,6 +461,12 @@ func (fhq *FileHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (fhq *FileHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *FileHistorySelect {
+ fhq.modifiers = append(fhq.modifiers, modifiers...)
+ return fhq.Select()
+}
+
// FileHistoryGroupBy is the group-by builder for FileHistory entities.
type FileHistoryGroupBy struct {
selector
@@ -547,3 +556,9 @@ func (fhs *FileHistorySelect) sqlScan(ctx context.Context, root *FileHistoryQuer
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (fhs *FileHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *FileHistorySelect {
+ fhs.modifiers = append(fhs.modifiers, modifiers...)
+ return fhs
+}
diff --git a/internal/ent/generated/filehistory_update.go b/internal/ent/generated/filehistory_update.go
index a944c19c..99bce930 100644
--- a/internal/ent/generated/filehistory_update.go
+++ b/internal/ent/generated/filehistory_update.go
@@ -13,16 +13,16 @@ import (
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/filehistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// FileHistoryUpdate is the builder for updating FileHistory entities.
type FileHistoryUpdate struct {
config
- hooks []Hook
- mutation *FileHistoryMutation
+ hooks []Hook
+ mutation *FileHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the FileHistoryUpdate builder.
@@ -285,6 +285,12 @@ func (fhu *FileHistoryUpdate) defaults() {
}
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (fhu *FileHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *FileHistoryUpdate {
+ fhu.modifiers = append(fhu.modifiers, modifiers...)
+ return fhu
+}
+
func (fhu *FileHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(filehistory.Table, filehistory.Columns, sqlgraph.NewFieldSpec(filehistory.FieldID, field.TypeString))
if ps := fhu.mutation.predicates; len(ps) > 0 {
@@ -373,6 +379,7 @@ func (fhu *FileHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = fhu.schemaConfig.FileHistory
ctx = internal.NewSchemaConfigContext(ctx, fhu.schemaConfig)
+ _spec.AddModifiers(fhu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, fhu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{filehistory.Label}
@@ -388,9 +395,10 @@ func (fhu *FileHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
// FileHistoryUpdateOne is the builder for updating a single FileHistory entity.
type FileHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *FileHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *FileHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -660,6 +668,12 @@ func (fhuo *FileHistoryUpdateOne) defaults() {
}
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (fhuo *FileHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *FileHistoryUpdateOne {
+ fhuo.modifiers = append(fhuo.modifiers, modifiers...)
+ return fhuo
+}
+
func (fhuo *FileHistoryUpdateOne) sqlSave(ctx context.Context) (_node *FileHistory, err error) {
_spec := sqlgraph.NewUpdateSpec(filehistory.Table, filehistory.Columns, sqlgraph.NewFieldSpec(filehistory.FieldID, field.TypeString))
id, ok := fhuo.mutation.ID()
@@ -765,6 +779,7 @@ func (fhuo *FileHistoryUpdateOne) sqlSave(ctx context.Context) (_node *FileHisto
}
_spec.Node.Schema = fhuo.schemaConfig.FileHistory
ctx = internal.NewSchemaConfigContext(ctx, fhuo.schemaConfig)
+ _spec.AddModifiers(fhuo.modifiers...)
_node = &FileHistory{config: fhuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/group/where.go b/internal/ent/generated/group/where.go
index f6c2a0e0..2b19521e 100644
--- a/internal/ent/generated/group/where.go
+++ b/internal/ent/generated/group/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/group_delete.go b/internal/ent/generated/group_delete.go
index 79a1738e..ca864fb3 100644
--- a/internal/ent/generated/group_delete.go
+++ b/internal/ent/generated/group_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/group"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// GroupDelete is the builder for deleting a Group entity.
diff --git a/internal/ent/generated/group_query.go b/internal/ent/generated/group_query.go
index 28892575..91a48bd6 100644
--- a/internal/ent/generated/group_query.go
+++ b/internal/ent/generated/group_query.go
@@ -19,11 +19,10 @@ import (
"github.com/theopenlane/core/internal/ent/generated/groupmembership"
"github.com/theopenlane/core/internal/ent/generated/groupsetting"
"github.com/theopenlane/core/internal/ent/generated/integration"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/user"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// GroupQuery is the builder for querying Group entities.
@@ -40,8 +39,8 @@ type GroupQuery struct {
withIntegrations *IntegrationQuery
withFiles *FileQuery
withMembers *GroupMembershipQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*Group) error
+ modifiers []func(*sql.Selector)
withNamedUsers map[string]*UserQuery
withNamedEvents map[string]*EventQuery
withNamedIntegrations map[string]*IntegrationQuery
@@ -458,8 +457,9 @@ func (gq *GroupQuery) Clone() *GroupQuery {
withFiles: gq.withFiles.Clone(),
withMembers: gq.withMembers.Clone(),
// clone intermediate query.
- sql: gq.sql.Clone(),
- path: gq.path,
+ sql: gq.sql.Clone(),
+ path: gq.path,
+ modifiers: append([]func(*sql.Selector){}, gq.modifiers...),
}
}
@@ -1126,6 +1126,9 @@ func (gq *GroupQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(gq.schemaConfig.Group)
ctx = internal.NewSchemaConfigContext(ctx, gq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range gq.modifiers {
+ m(selector)
+ }
for _, p := range gq.predicates {
p(selector)
}
@@ -1143,6 +1146,12 @@ func (gq *GroupQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (gq *GroupQuery) Modify(modifiers ...func(s *sql.Selector)) *GroupSelect {
+ gq.modifiers = append(gq.modifiers, modifiers...)
+ return gq.Select()
+}
+
// WithNamedUsers tells the query-builder to eager-load the nodes that are connected to the "users"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (gq *GroupQuery) WithNamedUsers(name string, opts ...func(*UserQuery)) *GroupQuery {
@@ -1302,3 +1311,9 @@ func (gs *GroupSelect) sqlScan(ctx context.Context, root *GroupQuery, v any) err
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (gs *GroupSelect) Modify(modifiers ...func(s *sql.Selector)) *GroupSelect {
+ gs.modifiers = append(gs.modifiers, modifiers...)
+ return gs
+}
diff --git a/internal/ent/generated/group_update.go b/internal/ent/generated/group_update.go
index 49a36234..102b67bc 100644
--- a/internal/ent/generated/group_update.go
+++ b/internal/ent/generated/group_update.go
@@ -18,18 +18,18 @@ import (
"github.com/theopenlane/core/internal/ent/generated/groupmembership"
"github.com/theopenlane/core/internal/ent/generated/groupsetting"
"github.com/theopenlane/core/internal/ent/generated/integration"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/user"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// GroupUpdate is the builder for updating Group entities.
type GroupUpdate struct {
config
- hooks []Hook
- mutation *GroupMutation
+ hooks []Hook
+ mutation *GroupMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the GroupUpdate builder.
@@ -514,6 +514,12 @@ func (gu *GroupUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (gu *GroupUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GroupUpdate {
+ gu.modifiers = append(gu.modifiers, modifiers...)
+ return gu
+}
+
func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := gu.check(); err != nil {
return n, err
@@ -916,6 +922,7 @@ func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = gu.schemaConfig.Group
ctx = internal.NewSchemaConfigContext(ctx, gu.schemaConfig)
+ _spec.AddModifiers(gu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, gu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{group.Label}
@@ -931,9 +938,10 @@ func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) {
// GroupUpdateOne is the builder for updating a single Group entity.
type GroupUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *GroupMutation
+ fields []string
+ hooks []Hook
+ mutation *GroupMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -1425,6 +1433,12 @@ func (guo *GroupUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (guo *GroupUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GroupUpdateOne {
+ guo.modifiers = append(guo.modifiers, modifiers...)
+ return guo
+}
+
func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error) {
if err := guo.check(); err != nil {
return _node, err
@@ -1844,6 +1858,7 @@ func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error
}
_spec.Node.Schema = guo.schemaConfig.Group
ctx = internal.NewSchemaConfigContext(ctx, guo.schemaConfig)
+ _spec.AddModifiers(guo.modifiers...)
_node = &Group{config: guo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/grouphistory_delete.go b/internal/ent/generated/grouphistory_delete.go
index 6cdf24e7..61ffebd1 100644
--- a/internal/ent/generated/grouphistory_delete.go
+++ b/internal/ent/generated/grouphistory_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/grouphistory"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// GroupHistoryDelete is the builder for deleting a GroupHistory entity.
diff --git a/internal/ent/generated/grouphistory_query.go b/internal/ent/generated/grouphistory_query.go
index 3a413ac1..9d5ba28d 100644
--- a/internal/ent/generated/grouphistory_query.go
+++ b/internal/ent/generated/grouphistory_query.go
@@ -13,9 +13,8 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/grouphistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// GroupHistoryQuery is the builder for querying GroupHistory entities.
@@ -25,8 +24,8 @@ type GroupHistoryQuery struct {
order []grouphistory.OrderOption
inters []Interceptor
predicates []predicate.GroupHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*GroupHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -256,8 +255,9 @@ func (ghq *GroupHistoryQuery) Clone() *GroupHistoryQuery {
inters: append([]Interceptor{}, ghq.inters...),
predicates: append([]predicate.GroupHistory{}, ghq.predicates...),
// clone intermediate query.
- sql: ghq.sql.Clone(),
- path: ghq.path,
+ sql: ghq.sql.Clone(),
+ path: ghq.path,
+ modifiers: append([]func(*sql.Selector){}, ghq.modifiers...),
}
}
@@ -448,6 +448,9 @@ func (ghq *GroupHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(ghq.schemaConfig.GroupHistory)
ctx = internal.NewSchemaConfigContext(ctx, ghq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range ghq.modifiers {
+ m(selector)
+ }
for _, p := range ghq.predicates {
p(selector)
}
@@ -465,6 +468,12 @@ func (ghq *GroupHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ghq *GroupHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *GroupHistorySelect {
+ ghq.modifiers = append(ghq.modifiers, modifiers...)
+ return ghq.Select()
+}
+
// GroupHistoryGroupBy is the group-by builder for GroupHistory entities.
type GroupHistoryGroupBy struct {
selector
@@ -554,3 +563,9 @@ func (ghs *GroupHistorySelect) sqlScan(ctx context.Context, root *GroupHistoryQu
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ghs *GroupHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *GroupHistorySelect {
+ ghs.modifiers = append(ghs.modifiers, modifiers...)
+ return ghs
+}
diff --git a/internal/ent/generated/grouphistory_update.go b/internal/ent/generated/grouphistory_update.go
index 2a34ebed..e327caa8 100644
--- a/internal/ent/generated/grouphistory_update.go
+++ b/internal/ent/generated/grouphistory_update.go
@@ -13,16 +13,16 @@ import (
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/grouphistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// GroupHistoryUpdate is the builder for updating GroupHistory entities.
type GroupHistoryUpdate struct {
config
- hooks []Hook
- mutation *GroupHistoryMutation
+ hooks []Hook
+ mutation *GroupHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the GroupHistoryUpdate builder.
@@ -276,6 +276,12 @@ func (ghu *GroupHistoryUpdate) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ghu *GroupHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GroupHistoryUpdate {
+ ghu.modifiers = append(ghu.modifiers, modifiers...)
+ return ghu
+}
+
func (ghu *GroupHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(grouphistory.Table, grouphistory.Columns, sqlgraph.NewFieldSpec(grouphistory.FieldID, field.TypeString))
if ps := ghu.mutation.predicates; len(ps) > 0 {
@@ -361,6 +367,7 @@ func (ghu *GroupHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = ghu.schemaConfig.GroupHistory
ctx = internal.NewSchemaConfigContext(ctx, ghu.schemaConfig)
+ _spec.AddModifiers(ghu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, ghu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{grouphistory.Label}
@@ -376,9 +383,10 @@ func (ghu *GroupHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
// GroupHistoryUpdateOne is the builder for updating a single GroupHistory entity.
type GroupHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *GroupHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *GroupHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -639,6 +647,12 @@ func (ghuo *GroupHistoryUpdateOne) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ghuo *GroupHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GroupHistoryUpdateOne {
+ ghuo.modifiers = append(ghuo.modifiers, modifiers...)
+ return ghuo
+}
+
func (ghuo *GroupHistoryUpdateOne) sqlSave(ctx context.Context) (_node *GroupHistory, err error) {
_spec := sqlgraph.NewUpdateSpec(grouphistory.Table, grouphistory.Columns, sqlgraph.NewFieldSpec(grouphistory.FieldID, field.TypeString))
id, ok := ghuo.mutation.ID()
@@ -741,6 +755,7 @@ func (ghuo *GroupHistoryUpdateOne) sqlSave(ctx context.Context) (_node *GroupHis
}
_spec.Node.Schema = ghuo.schemaConfig.GroupHistory
ctx = internal.NewSchemaConfigContext(ctx, ghuo.schemaConfig)
+ _spec.AddModifiers(ghuo.modifiers...)
_node = &GroupHistory{config: ghuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/groupmembership/where.go b/internal/ent/generated/groupmembership/where.go
index b7782af5..72f91018 100644
--- a/internal/ent/generated/groupmembership/where.go
+++ b/internal/ent/generated/groupmembership/where.go
@@ -7,10 +7,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/groupmembership_delete.go b/internal/ent/generated/groupmembership_delete.go
index 42aba15a..10e72bd1 100644
--- a/internal/ent/generated/groupmembership_delete.go
+++ b/internal/ent/generated/groupmembership_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/groupmembership"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// GroupMembershipDelete is the builder for deleting a GroupMembership entity.
diff --git a/internal/ent/generated/groupmembership_query.go b/internal/ent/generated/groupmembership_query.go
index 47bf00ed..eb183aa0 100644
--- a/internal/ent/generated/groupmembership_query.go
+++ b/internal/ent/generated/groupmembership_query.go
@@ -16,10 +16,9 @@ import (
"github.com/theopenlane/core/internal/ent/generated/event"
"github.com/theopenlane/core/internal/ent/generated/group"
"github.com/theopenlane/core/internal/ent/generated/groupmembership"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/user"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// GroupMembershipQuery is the builder for querying GroupMembership entities.
@@ -32,8 +31,8 @@ type GroupMembershipQuery struct {
withGroup *GroupQuery
withUser *UserQuery
withEvents *EventQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*GroupMembership) error
+ modifiers []func(*sql.Selector)
withNamedEvents map[string]*EventQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
@@ -342,8 +341,9 @@ func (gmq *GroupMembershipQuery) Clone() *GroupMembershipQuery {
withUser: gmq.withUser.Clone(),
withEvents: gmq.withEvents.Clone(),
// clone intermediate query.
- sql: gmq.sql.Clone(),
- path: gmq.path,
+ sql: gmq.sql.Clone(),
+ path: gmq.path,
+ modifiers: append([]func(*sql.Selector){}, gmq.modifiers...),
}
}
@@ -726,6 +726,9 @@ func (gmq *GroupMembershipQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(gmq.schemaConfig.GroupMembership)
ctx = internal.NewSchemaConfigContext(ctx, gmq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range gmq.modifiers {
+ m(selector)
+ }
for _, p := range gmq.predicates {
p(selector)
}
@@ -743,6 +746,12 @@ func (gmq *GroupMembershipQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (gmq *GroupMembershipQuery) Modify(modifiers ...func(s *sql.Selector)) *GroupMembershipSelect {
+ gmq.modifiers = append(gmq.modifiers, modifiers...)
+ return gmq.Select()
+}
+
// WithNamedEvents tells the query-builder to eager-load the nodes that are connected to the "events"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (gmq *GroupMembershipQuery) WithNamedEvents(name string, opts ...func(*EventQuery)) *GroupMembershipQuery {
@@ -846,3 +855,9 @@ func (gms *GroupMembershipSelect) sqlScan(ctx context.Context, root *GroupMember
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (gms *GroupMembershipSelect) Modify(modifiers ...func(s *sql.Selector)) *GroupMembershipSelect {
+ gms.modifiers = append(gms.modifiers, modifiers...)
+ return gms
+}
diff --git a/internal/ent/generated/groupmembership_update.go b/internal/ent/generated/groupmembership_update.go
index c1cff6cc..f59f2521 100644
--- a/internal/ent/generated/groupmembership_update.go
+++ b/internal/ent/generated/groupmembership_update.go
@@ -13,17 +13,17 @@ import (
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/event"
"github.com/theopenlane/core/internal/ent/generated/groupmembership"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// GroupMembershipUpdate is the builder for updating GroupMembership entities.
type GroupMembershipUpdate struct {
config
- hooks []Hook
- mutation *GroupMembershipMutation
+ hooks []Hook
+ mutation *GroupMembershipMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the GroupMembershipUpdate builder.
@@ -217,6 +217,12 @@ func (gmu *GroupMembershipUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (gmu *GroupMembershipUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GroupMembershipUpdate {
+ gmu.modifiers = append(gmu.modifiers, modifiers...)
+ return gmu
+}
+
func (gmu *GroupMembershipUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := gmu.check(); err != nil {
return n, err
@@ -312,6 +318,7 @@ func (gmu *GroupMembershipUpdate) sqlSave(ctx context.Context) (n int, err error
}
_spec.Node.Schema = gmu.schemaConfig.GroupMembership
ctx = internal.NewSchemaConfigContext(ctx, gmu.schemaConfig)
+ _spec.AddModifiers(gmu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, gmu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{groupmembership.Label}
@@ -327,9 +334,10 @@ func (gmu *GroupMembershipUpdate) sqlSave(ctx context.Context) (n int, err error
// GroupMembershipUpdateOne is the builder for updating a single GroupMembership entity.
type GroupMembershipUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *GroupMembershipMutation
+ fields []string
+ hooks []Hook
+ mutation *GroupMembershipMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -530,6 +538,12 @@ func (gmuo *GroupMembershipUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (gmuo *GroupMembershipUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GroupMembershipUpdateOne {
+ gmuo.modifiers = append(gmuo.modifiers, modifiers...)
+ return gmuo
+}
+
func (gmuo *GroupMembershipUpdateOne) sqlSave(ctx context.Context) (_node *GroupMembership, err error) {
if err := gmuo.check(); err != nil {
return _node, err
@@ -642,6 +656,7 @@ func (gmuo *GroupMembershipUpdateOne) sqlSave(ctx context.Context) (_node *Group
}
_spec.Node.Schema = gmuo.schemaConfig.GroupMembership
ctx = internal.NewSchemaConfigContext(ctx, gmuo.schemaConfig)
+ _spec.AddModifiers(gmuo.modifiers...)
_node = &GroupMembership{config: gmuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/groupmembershiphistory_delete.go b/internal/ent/generated/groupmembershiphistory_delete.go
index 889800f8..2218c1fd 100644
--- a/internal/ent/generated/groupmembershiphistory_delete.go
+++ b/internal/ent/generated/groupmembershiphistory_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/groupmembershiphistory"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// GroupMembershipHistoryDelete is the builder for deleting a GroupMembershipHistory entity.
diff --git a/internal/ent/generated/groupmembershiphistory_query.go b/internal/ent/generated/groupmembershiphistory_query.go
index f9b7976d..0c0bb936 100644
--- a/internal/ent/generated/groupmembershiphistory_query.go
+++ b/internal/ent/generated/groupmembershiphistory_query.go
@@ -13,9 +13,8 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/groupmembershiphistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// GroupMembershipHistoryQuery is the builder for querying GroupMembershipHistory entities.
@@ -25,8 +24,8 @@ type GroupMembershipHistoryQuery struct {
order []groupmembershiphistory.OrderOption
inters []Interceptor
predicates []predicate.GroupMembershipHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*GroupMembershipHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -256,8 +255,9 @@ func (gmhq *GroupMembershipHistoryQuery) Clone() *GroupMembershipHistoryQuery {
inters: append([]Interceptor{}, gmhq.inters...),
predicates: append([]predicate.GroupMembershipHistory{}, gmhq.predicates...),
// clone intermediate query.
- sql: gmhq.sql.Clone(),
- path: gmhq.path,
+ sql: gmhq.sql.Clone(),
+ path: gmhq.path,
+ modifiers: append([]func(*sql.Selector){}, gmhq.modifiers...),
}
}
@@ -448,6 +448,9 @@ func (gmhq *GroupMembershipHistoryQuery) sqlQuery(ctx context.Context) *sql.Sele
t1.Schema(gmhq.schemaConfig.GroupMembershipHistory)
ctx = internal.NewSchemaConfigContext(ctx, gmhq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range gmhq.modifiers {
+ m(selector)
+ }
for _, p := range gmhq.predicates {
p(selector)
}
@@ -465,6 +468,12 @@ func (gmhq *GroupMembershipHistoryQuery) sqlQuery(ctx context.Context) *sql.Sele
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (gmhq *GroupMembershipHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *GroupMembershipHistorySelect {
+ gmhq.modifiers = append(gmhq.modifiers, modifiers...)
+ return gmhq.Select()
+}
+
// GroupMembershipHistoryGroupBy is the group-by builder for GroupMembershipHistory entities.
type GroupMembershipHistoryGroupBy struct {
selector
@@ -554,3 +563,9 @@ func (gmhs *GroupMembershipHistorySelect) sqlScan(ctx context.Context, root *Gro
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (gmhs *GroupMembershipHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *GroupMembershipHistorySelect {
+ gmhs.modifiers = append(gmhs.modifiers, modifiers...)
+ return gmhs
+}
diff --git a/internal/ent/generated/groupmembershiphistory_update.go b/internal/ent/generated/groupmembershiphistory_update.go
index bf945918..f0af99e1 100644
--- a/internal/ent/generated/groupmembershiphistory_update.go
+++ b/internal/ent/generated/groupmembershiphistory_update.go
@@ -12,17 +12,17 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/groupmembershiphistory"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// GroupMembershipHistoryUpdate is the builder for updating GroupMembershipHistory entities.
type GroupMembershipHistoryUpdate struct {
config
- hooks []Hook
- mutation *GroupMembershipHistoryMutation
+ hooks []Hook
+ mutation *GroupMembershipHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the GroupMembershipHistoryUpdate builder.
@@ -174,6 +174,12 @@ func (gmhu *GroupMembershipHistoryUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (gmhu *GroupMembershipHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GroupMembershipHistoryUpdate {
+ gmhu.modifiers = append(gmhu.modifiers, modifiers...)
+ return gmhu
+}
+
func (gmhu *GroupMembershipHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := gmhu.check(); err != nil {
return n, err
@@ -224,6 +230,7 @@ func (gmhu *GroupMembershipHistoryUpdate) sqlSave(ctx context.Context) (n int, e
}
_spec.Node.Schema = gmhu.schemaConfig.GroupMembershipHistory
ctx = internal.NewSchemaConfigContext(ctx, gmhu.schemaConfig)
+ _spec.AddModifiers(gmhu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, gmhu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{groupmembershiphistory.Label}
@@ -239,9 +246,10 @@ func (gmhu *GroupMembershipHistoryUpdate) sqlSave(ctx context.Context) (n int, e
// GroupMembershipHistoryUpdateOne is the builder for updating a single GroupMembershipHistory entity.
type GroupMembershipHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *GroupMembershipHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *GroupMembershipHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -400,6 +408,12 @@ func (gmhuo *GroupMembershipHistoryUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (gmhuo *GroupMembershipHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GroupMembershipHistoryUpdateOne {
+ gmhuo.modifiers = append(gmhuo.modifiers, modifiers...)
+ return gmhuo
+}
+
func (gmhuo *GroupMembershipHistoryUpdateOne) sqlSave(ctx context.Context) (_node *GroupMembershipHistory, err error) {
if err := gmhuo.check(); err != nil {
return _node, err
@@ -467,6 +481,7 @@ func (gmhuo *GroupMembershipHistoryUpdateOne) sqlSave(ctx context.Context) (_nod
}
_spec.Node.Schema = gmhuo.schemaConfig.GroupMembershipHistory
ctx = internal.NewSchemaConfigContext(ctx, gmhuo.schemaConfig)
+ _spec.AddModifiers(gmhuo.modifiers...)
_node = &GroupMembershipHistory{config: gmhuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/groupsetting/where.go b/internal/ent/generated/groupsetting/where.go
index 237e8faf..8ec5c969 100644
--- a/internal/ent/generated/groupsetting/where.go
+++ b/internal/ent/generated/groupsetting/where.go
@@ -7,10 +7,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/groupsetting_delete.go b/internal/ent/generated/groupsetting_delete.go
index 8f4ef9f2..cfaa7ca7 100644
--- a/internal/ent/generated/groupsetting_delete.go
+++ b/internal/ent/generated/groupsetting_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/groupsetting"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// GroupSettingDelete is the builder for deleting a GroupSetting entity.
diff --git a/internal/ent/generated/groupsetting_query.go b/internal/ent/generated/groupsetting_query.go
index 95248e61..abf87cc5 100644
--- a/internal/ent/generated/groupsetting_query.go
+++ b/internal/ent/generated/groupsetting_query.go
@@ -14,9 +14,8 @@ import (
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/group"
"github.com/theopenlane/core/internal/ent/generated/groupsetting"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// GroupSettingQuery is the builder for querying GroupSetting entities.
@@ -27,8 +26,8 @@ type GroupSettingQuery struct {
inters []Interceptor
predicates []predicate.GroupSetting
withGroup *GroupQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*GroupSetting) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -284,8 +283,9 @@ func (gsq *GroupSettingQuery) Clone() *GroupSettingQuery {
predicates: append([]predicate.GroupSetting{}, gsq.predicates...),
withGroup: gsq.withGroup.Clone(),
// clone intermediate query.
- sql: gsq.sql.Clone(),
- path: gsq.path,
+ sql: gsq.sql.Clone(),
+ path: gsq.path,
+ modifiers: append([]func(*sql.Selector){}, gsq.modifiers...),
}
}
@@ -530,6 +530,9 @@ func (gsq *GroupSettingQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(gsq.schemaConfig.GroupSetting)
ctx = internal.NewSchemaConfigContext(ctx, gsq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range gsq.modifiers {
+ m(selector)
+ }
for _, p := range gsq.predicates {
p(selector)
}
@@ -547,6 +550,12 @@ func (gsq *GroupSettingQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (gsq *GroupSettingQuery) Modify(modifiers ...func(s *sql.Selector)) *GroupSettingSelect {
+ gsq.modifiers = append(gsq.modifiers, modifiers...)
+ return gsq.Select()
+}
+
// GroupSettingGroupBy is the group-by builder for GroupSetting entities.
type GroupSettingGroupBy struct {
selector
@@ -636,3 +645,9 @@ func (gss *GroupSettingSelect) sqlScan(ctx context.Context, root *GroupSettingQu
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (gss *GroupSettingSelect) Modify(modifiers ...func(s *sql.Selector)) *GroupSettingSelect {
+ gss.modifiers = append(gss.modifiers, modifiers...)
+ return gss
+}
diff --git a/internal/ent/generated/groupsetting_update.go b/internal/ent/generated/groupsetting_update.go
index 15deaaa4..0357c3a2 100644
--- a/internal/ent/generated/groupsetting_update.go
+++ b/internal/ent/generated/groupsetting_update.go
@@ -14,17 +14,17 @@ import (
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/group"
"github.com/theopenlane/core/internal/ent/generated/groupsetting"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// GroupSettingUpdate is the builder for updating GroupSetting entities.
type GroupSettingUpdate struct {
config
- hooks []Hook
- mutation *GroupSettingMutation
+ hooks []Hook
+ mutation *GroupSettingMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the GroupSettingUpdate builder.
@@ -284,6 +284,12 @@ func (gsu *GroupSettingUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (gsu *GroupSettingUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GroupSettingUpdate {
+ gsu.modifiers = append(gsu.modifiers, modifiers...)
+ return gsu
+}
+
func (gsu *GroupSettingUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := gsu.check(); err != nil {
return n, err
@@ -388,6 +394,7 @@ func (gsu *GroupSettingUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = gsu.schemaConfig.GroupSetting
ctx = internal.NewSchemaConfigContext(ctx, gsu.schemaConfig)
+ _spec.AddModifiers(gsu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, gsu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{groupsetting.Label}
@@ -403,9 +410,10 @@ func (gsu *GroupSettingUpdate) sqlSave(ctx context.Context) (n int, err error) {
// GroupSettingUpdateOne is the builder for updating a single GroupSetting entity.
type GroupSettingUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *GroupSettingMutation
+ fields []string
+ hooks []Hook
+ mutation *GroupSettingMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -672,6 +680,12 @@ func (gsuo *GroupSettingUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (gsuo *GroupSettingUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GroupSettingUpdateOne {
+ gsuo.modifiers = append(gsuo.modifiers, modifiers...)
+ return gsuo
+}
+
func (gsuo *GroupSettingUpdateOne) sqlSave(ctx context.Context) (_node *GroupSetting, err error) {
if err := gsuo.check(); err != nil {
return _node, err
@@ -793,6 +807,7 @@ func (gsuo *GroupSettingUpdateOne) sqlSave(ctx context.Context) (_node *GroupSet
}
_spec.Node.Schema = gsuo.schemaConfig.GroupSetting
ctx = internal.NewSchemaConfigContext(ctx, gsuo.schemaConfig)
+ _spec.AddModifiers(gsuo.modifiers...)
_node = &GroupSetting{config: gsuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/groupsettinghistory_delete.go b/internal/ent/generated/groupsettinghistory_delete.go
index 040b76b2..8034a7d6 100644
--- a/internal/ent/generated/groupsettinghistory_delete.go
+++ b/internal/ent/generated/groupsettinghistory_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/groupsettinghistory"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// GroupSettingHistoryDelete is the builder for deleting a GroupSettingHistory entity.
diff --git a/internal/ent/generated/groupsettinghistory_query.go b/internal/ent/generated/groupsettinghistory_query.go
index 05246edf..5215e81f 100644
--- a/internal/ent/generated/groupsettinghistory_query.go
+++ b/internal/ent/generated/groupsettinghistory_query.go
@@ -13,9 +13,8 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/groupsettinghistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// GroupSettingHistoryQuery is the builder for querying GroupSettingHistory entities.
@@ -25,8 +24,8 @@ type GroupSettingHistoryQuery struct {
order []groupsettinghistory.OrderOption
inters []Interceptor
predicates []predicate.GroupSettingHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*GroupSettingHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -256,8 +255,9 @@ func (gshq *GroupSettingHistoryQuery) Clone() *GroupSettingHistoryQuery {
inters: append([]Interceptor{}, gshq.inters...),
predicates: append([]predicate.GroupSettingHistory{}, gshq.predicates...),
// clone intermediate query.
- sql: gshq.sql.Clone(),
- path: gshq.path,
+ sql: gshq.sql.Clone(),
+ path: gshq.path,
+ modifiers: append([]func(*sql.Selector){}, gshq.modifiers...),
}
}
@@ -448,6 +448,9 @@ func (gshq *GroupSettingHistoryQuery) sqlQuery(ctx context.Context) *sql.Selecto
t1.Schema(gshq.schemaConfig.GroupSettingHistory)
ctx = internal.NewSchemaConfigContext(ctx, gshq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range gshq.modifiers {
+ m(selector)
+ }
for _, p := range gshq.predicates {
p(selector)
}
@@ -465,6 +468,12 @@ func (gshq *GroupSettingHistoryQuery) sqlQuery(ctx context.Context) *sql.Selecto
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (gshq *GroupSettingHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *GroupSettingHistorySelect {
+ gshq.modifiers = append(gshq.modifiers, modifiers...)
+ return gshq.Select()
+}
+
// GroupSettingHistoryGroupBy is the group-by builder for GroupSettingHistory entities.
type GroupSettingHistoryGroupBy struct {
selector
@@ -554,3 +563,9 @@ func (gshs *GroupSettingHistorySelect) sqlScan(ctx context.Context, root *GroupS
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (gshs *GroupSettingHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *GroupSettingHistorySelect {
+ gshs.modifiers = append(gshs.modifiers, modifiers...)
+ return gshs
+}
diff --git a/internal/ent/generated/groupsettinghistory_update.go b/internal/ent/generated/groupsettinghistory_update.go
index 62887657..692aa6c2 100644
--- a/internal/ent/generated/groupsettinghistory_update.go
+++ b/internal/ent/generated/groupsettinghistory_update.go
@@ -13,17 +13,17 @@ import (
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/groupsettinghistory"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// GroupSettingHistoryUpdate is the builder for updating GroupSettingHistory entities.
type GroupSettingHistoryUpdate struct {
config
- hooks []Hook
- mutation *GroupSettingHistoryMutation
+ hooks []Hook
+ mutation *GroupSettingHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the GroupSettingHistoryUpdate builder.
@@ -272,6 +272,12 @@ func (gshu *GroupSettingHistoryUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (gshu *GroupSettingHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GroupSettingHistoryUpdate {
+ gshu.modifiers = append(gshu.modifiers, modifiers...)
+ return gshu
+}
+
func (gshu *GroupSettingHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := gshu.check(); err != nil {
return n, err
@@ -354,6 +360,7 @@ func (gshu *GroupSettingHistoryUpdate) sqlSave(ctx context.Context) (n int, err
}
_spec.Node.Schema = gshu.schemaConfig.GroupSettingHistory
ctx = internal.NewSchemaConfigContext(ctx, gshu.schemaConfig)
+ _spec.AddModifiers(gshu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, gshu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{groupsettinghistory.Label}
@@ -369,9 +376,10 @@ func (gshu *GroupSettingHistoryUpdate) sqlSave(ctx context.Context) (n int, err
// GroupSettingHistoryUpdateOne is the builder for updating a single GroupSettingHistory entity.
type GroupSettingHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *GroupSettingHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *GroupSettingHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -627,6 +635,12 @@ func (gshuo *GroupSettingHistoryUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (gshuo *GroupSettingHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GroupSettingHistoryUpdateOne {
+ gshuo.modifiers = append(gshuo.modifiers, modifiers...)
+ return gshuo
+}
+
func (gshuo *GroupSettingHistoryUpdateOne) sqlSave(ctx context.Context) (_node *GroupSettingHistory, err error) {
if err := gshuo.check(); err != nil {
return _node, err
@@ -726,6 +740,7 @@ func (gshuo *GroupSettingHistoryUpdateOne) sqlSave(ctx context.Context) (_node *
}
_spec.Node.Schema = gshuo.schemaConfig.GroupSettingHistory
ctx = internal.NewSchemaConfigContext(ctx, gshuo.schemaConfig)
+ _spec.AddModifiers(gshuo.modifiers...)
_node = &GroupSettingHistory{config: gshuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/hush/where.go b/internal/ent/generated/hush/where.go
index f9e21616..b83b97ab 100644
--- a/internal/ent/generated/hush/where.go
+++ b/internal/ent/generated/hush/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/hush_delete.go b/internal/ent/generated/hush_delete.go
index 922990fe..50048407 100644
--- a/internal/ent/generated/hush_delete.go
+++ b/internal/ent/generated/hush_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/hush"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// HushDelete is the builder for deleting a Hush entity.
diff --git a/internal/ent/generated/hush_query.go b/internal/ent/generated/hush_query.go
index d81bb6ef..00a9c4fc 100644
--- a/internal/ent/generated/hush_query.go
+++ b/internal/ent/generated/hush_query.go
@@ -15,10 +15,9 @@ import (
"github.com/theopenlane/core/internal/ent/generated/event"
"github.com/theopenlane/core/internal/ent/generated/hush"
"github.com/theopenlane/core/internal/ent/generated/integration"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// HushQuery is the builder for querying Hush entities.
@@ -31,8 +30,8 @@ type HushQuery struct {
withIntegrations *IntegrationQuery
withOrganization *OrganizationQuery
withEvents *EventQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*Hush) error
+ modifiers []func(*sql.Selector)
withNamedIntegrations map[string]*IntegrationQuery
withNamedOrganization map[string]*OrganizationQuery
withNamedEvents map[string]*EventQuery
@@ -343,8 +342,9 @@ func (hq *HushQuery) Clone() *HushQuery {
withOrganization: hq.withOrganization.Clone(),
withEvents: hq.withEvents.Clone(),
// clone intermediate query.
- sql: hq.sql.Clone(),
- path: hq.path,
+ sql: hq.sql.Clone(),
+ path: hq.path,
+ modifiers: append([]func(*sql.Selector){}, hq.modifiers...),
}
}
@@ -797,6 +797,9 @@ func (hq *HushQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(hq.schemaConfig.Hush)
ctx = internal.NewSchemaConfigContext(ctx, hq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range hq.modifiers {
+ m(selector)
+ }
for _, p := range hq.predicates {
p(selector)
}
@@ -814,6 +817,12 @@ func (hq *HushQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (hq *HushQuery) Modify(modifiers ...func(s *sql.Selector)) *HushSelect {
+ hq.modifiers = append(hq.modifiers, modifiers...)
+ return hq.Select()
+}
+
// WithNamedIntegrations tells the query-builder to eager-load the nodes that are connected to the "integrations"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (hq *HushQuery) WithNamedIntegrations(name string, opts ...func(*IntegrationQuery)) *HushQuery {
@@ -945,3 +954,9 @@ func (hs *HushSelect) sqlScan(ctx context.Context, root *HushQuery, v any) error
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (hs *HushSelect) Modify(modifiers ...func(s *sql.Selector)) *HushSelect {
+ hs.modifiers = append(hs.modifiers, modifiers...)
+ return hs
+}
diff --git a/internal/ent/generated/hush_update.go b/internal/ent/generated/hush_update.go
index 7c052386..b1fb061c 100644
--- a/internal/ent/generated/hush_update.go
+++ b/internal/ent/generated/hush_update.go
@@ -14,17 +14,17 @@ import (
"github.com/theopenlane/core/internal/ent/generated/event"
"github.com/theopenlane/core/internal/ent/generated/hush"
"github.com/theopenlane/core/internal/ent/generated/integration"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// HushUpdate is the builder for updating Hush entities.
type HushUpdate struct {
config
- hooks []Hook
- mutation *HushMutation
+ hooks []Hook
+ mutation *HushMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the HushUpdate builder.
@@ -324,6 +324,12 @@ func (hu *HushUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (hu *HushUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *HushUpdate {
+ hu.modifiers = append(hu.modifiers, modifiers...)
+ return hu
+}
+
func (hu *HushUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := hu.check(); err != nil {
return n, err
@@ -533,6 +539,7 @@ func (hu *HushUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = hu.schemaConfig.Hush
ctx = internal.NewSchemaConfigContext(ctx, hu.schemaConfig)
+ _spec.AddModifiers(hu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, hu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{hush.Label}
@@ -548,9 +555,10 @@ func (hu *HushUpdate) sqlSave(ctx context.Context) (n int, err error) {
// HushUpdateOne is the builder for updating a single Hush entity.
type HushUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *HushMutation
+ fields []string
+ hooks []Hook
+ mutation *HushMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -857,6 +865,12 @@ func (huo *HushUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (huo *HushUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *HushUpdateOne {
+ huo.modifiers = append(huo.modifiers, modifiers...)
+ return huo
+}
+
func (huo *HushUpdateOne) sqlSave(ctx context.Context) (_node *Hush, err error) {
if err := huo.check(); err != nil {
return _node, err
@@ -1083,6 +1097,7 @@ func (huo *HushUpdateOne) sqlSave(ctx context.Context) (_node *Hush, err error)
}
_spec.Node.Schema = huo.schemaConfig.Hush
ctx = internal.NewSchemaConfigContext(ctx, huo.schemaConfig)
+ _spec.AddModifiers(huo.modifiers...)
_node = &Hush{config: huo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/hushhistory_delete.go b/internal/ent/generated/hushhistory_delete.go
index c57caa10..0cddaa95 100644
--- a/internal/ent/generated/hushhistory_delete.go
+++ b/internal/ent/generated/hushhistory_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/hushhistory"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// HushHistoryDelete is the builder for deleting a HushHistory entity.
diff --git a/internal/ent/generated/hushhistory_query.go b/internal/ent/generated/hushhistory_query.go
index f1f0c2c8..f2e6f533 100644
--- a/internal/ent/generated/hushhistory_query.go
+++ b/internal/ent/generated/hushhistory_query.go
@@ -12,9 +12,8 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/hushhistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// HushHistoryQuery is the builder for querying HushHistory entities.
@@ -24,8 +23,8 @@ type HushHistoryQuery struct {
order []hushhistory.OrderOption
inters []Interceptor
predicates []predicate.HushHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*HushHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -255,8 +254,9 @@ func (hhq *HushHistoryQuery) Clone() *HushHistoryQuery {
inters: append([]Interceptor{}, hhq.inters...),
predicates: append([]predicate.HushHistory{}, hhq.predicates...),
// clone intermediate query.
- sql: hhq.sql.Clone(),
- path: hhq.path,
+ sql: hhq.sql.Clone(),
+ path: hhq.path,
+ modifiers: append([]func(*sql.Selector){}, hhq.modifiers...),
}
}
@@ -441,6 +441,9 @@ func (hhq *HushHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(hhq.schemaConfig.HushHistory)
ctx = internal.NewSchemaConfigContext(ctx, hhq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range hhq.modifiers {
+ m(selector)
+ }
for _, p := range hhq.predicates {
p(selector)
}
@@ -458,6 +461,12 @@ func (hhq *HushHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (hhq *HushHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *HushHistorySelect {
+ hhq.modifiers = append(hhq.modifiers, modifiers...)
+ return hhq.Select()
+}
+
// HushHistoryGroupBy is the group-by builder for HushHistory entities.
type HushHistoryGroupBy struct {
selector
@@ -547,3 +556,9 @@ func (hhs *HushHistorySelect) sqlScan(ctx context.Context, root *HushHistoryQuer
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (hhs *HushHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *HushHistorySelect {
+ hhs.modifiers = append(hhs.modifiers, modifiers...)
+ return hhs
+}
diff --git a/internal/ent/generated/hushhistory_update.go b/internal/ent/generated/hushhistory_update.go
index e337e8e0..5dce29ea 100644
--- a/internal/ent/generated/hushhistory_update.go
+++ b/internal/ent/generated/hushhistory_update.go
@@ -12,16 +12,16 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/hushhistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// HushHistoryUpdate is the builder for updating HushHistory entities.
type HushHistoryUpdate struct {
config
- hooks []Hook
- mutation *HushHistoryMutation
+ hooks []Hook
+ mutation *HushHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the HushHistoryUpdate builder.
@@ -197,6 +197,12 @@ func (hhu *HushHistoryUpdate) defaults() {
}
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (hhu *HushHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *HushHistoryUpdate {
+ hhu.modifiers = append(hhu.modifiers, modifiers...)
+ return hhu
+}
+
func (hhu *HushHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(hushhistory.Table, hushhistory.Columns, sqlgraph.NewFieldSpec(hushhistory.FieldID, field.TypeString))
if ps := hhu.mutation.predicates; len(ps) > 0 {
@@ -262,6 +268,7 @@ func (hhu *HushHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = hhu.schemaConfig.HushHistory
ctx = internal.NewSchemaConfigContext(ctx, hhu.schemaConfig)
+ _spec.AddModifiers(hhu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, hhu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{hushhistory.Label}
@@ -277,9 +284,10 @@ func (hhu *HushHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
// HushHistoryUpdateOne is the builder for updating a single HushHistory entity.
type HushHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *HushHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *HushHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -462,6 +470,12 @@ func (hhuo *HushHistoryUpdateOne) defaults() {
}
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (hhuo *HushHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *HushHistoryUpdateOne {
+ hhuo.modifiers = append(hhuo.modifiers, modifiers...)
+ return hhuo
+}
+
func (hhuo *HushHistoryUpdateOne) sqlSave(ctx context.Context) (_node *HushHistory, err error) {
_spec := sqlgraph.NewUpdateSpec(hushhistory.Table, hushhistory.Columns, sqlgraph.NewFieldSpec(hushhistory.FieldID, field.TypeString))
id, ok := hhuo.mutation.ID()
@@ -544,6 +558,7 @@ func (hhuo *HushHistoryUpdateOne) sqlSave(ctx context.Context) (_node *HushHisto
}
_spec.Node.Schema = hhuo.schemaConfig.HushHistory
ctx = internal.NewSchemaConfigContext(ctx, hhuo.schemaConfig)
+ _spec.AddModifiers(hhuo.modifiers...)
_node = &HushHistory{config: hhuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/integration/where.go b/internal/ent/generated/integration/where.go
index 4dc32d50..ecdf9778 100644
--- a/internal/ent/generated/integration/where.go
+++ b/internal/ent/generated/integration/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/integration_delete.go b/internal/ent/generated/integration_delete.go
index 390234d0..64ac9519 100644
--- a/internal/ent/generated/integration_delete.go
+++ b/internal/ent/generated/integration_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/integration"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// IntegrationDelete is the builder for deleting a Integration entity.
diff --git a/internal/ent/generated/integration_query.go b/internal/ent/generated/integration_query.go
index ce24efb9..8613450c 100644
--- a/internal/ent/generated/integration_query.go
+++ b/internal/ent/generated/integration_query.go
@@ -16,12 +16,11 @@ import (
"github.com/theopenlane/core/internal/ent/generated/event"
"github.com/theopenlane/core/internal/ent/generated/hush"
"github.com/theopenlane/core/internal/ent/generated/integration"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/ohauthtootoken"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/webhook"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// IntegrationQuery is the builder for querying Integration entities.
@@ -37,8 +36,8 @@ type IntegrationQuery struct {
withEvents *EventQuery
withWebhooks *WebhookQuery
withFKs bool
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*Integration) error
+ modifiers []func(*sql.Selector)
withNamedSecrets map[string]*HushQuery
withNamedOauth2tokens map[string]*OhAuthTooTokenQuery
withNamedEvents map[string]*EventQuery
@@ -402,8 +401,9 @@ func (iq *IntegrationQuery) Clone() *IntegrationQuery {
withEvents: iq.withEvents.Clone(),
withWebhooks: iq.withWebhooks.Clone(),
// clone intermediate query.
- sql: iq.sql.Clone(),
- path: iq.path,
+ sql: iq.sql.Clone(),
+ path: iq.path,
+ modifiers: append([]func(*sql.Selector){}, iq.modifiers...),
}
}
@@ -1004,6 +1004,9 @@ func (iq *IntegrationQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(iq.schemaConfig.Integration)
ctx = internal.NewSchemaConfigContext(ctx, iq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range iq.modifiers {
+ m(selector)
+ }
for _, p := range iq.predicates {
p(selector)
}
@@ -1021,6 +1024,12 @@ func (iq *IntegrationQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (iq *IntegrationQuery) Modify(modifiers ...func(s *sql.Selector)) *IntegrationSelect {
+ iq.modifiers = append(iq.modifiers, modifiers...)
+ return iq.Select()
+}
+
// WithNamedSecrets tells the query-builder to eager-load the nodes that are connected to the "secrets"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (iq *IntegrationQuery) WithNamedSecrets(name string, opts ...func(*HushQuery)) *IntegrationQuery {
@@ -1166,3 +1175,9 @@ func (is *IntegrationSelect) sqlScan(ctx context.Context, root *IntegrationQuery
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (is *IntegrationSelect) Modify(modifiers ...func(s *sql.Selector)) *IntegrationSelect {
+ is.modifiers = append(is.modifiers, modifiers...)
+ return is
+}
diff --git a/internal/ent/generated/integration_update.go b/internal/ent/generated/integration_update.go
index 25e1ec7d..8debcbe7 100644
--- a/internal/ent/generated/integration_update.go
+++ b/internal/ent/generated/integration_update.go
@@ -15,19 +15,19 @@ import (
"github.com/theopenlane/core/internal/ent/generated/event"
"github.com/theopenlane/core/internal/ent/generated/hush"
"github.com/theopenlane/core/internal/ent/generated/integration"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/ohauthtootoken"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/webhook"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// IntegrationUpdate is the builder for updating Integration entities.
type IntegrationUpdate struct {
config
- hooks []Hook
- mutation *IntegrationMutation
+ hooks []Hook
+ mutation *IntegrationMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the IntegrationUpdate builder.
@@ -417,6 +417,12 @@ func (iu *IntegrationUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (iu *IntegrationUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *IntegrationUpdate {
+ iu.modifiers = append(iu.modifiers, modifiers...)
+ return iu
+}
+
func (iu *IntegrationUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := iu.check(); err != nil {
return n, err
@@ -710,6 +716,7 @@ func (iu *IntegrationUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = iu.schemaConfig.Integration
ctx = internal.NewSchemaConfigContext(ctx, iu.schemaConfig)
+ _spec.AddModifiers(iu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, iu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{integration.Label}
@@ -725,9 +732,10 @@ func (iu *IntegrationUpdate) sqlSave(ctx context.Context) (n int, err error) {
// IntegrationUpdateOne is the builder for updating a single Integration entity.
type IntegrationUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *IntegrationMutation
+ fields []string
+ hooks []Hook
+ mutation *IntegrationMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -1124,6 +1132,12 @@ func (iuo *IntegrationUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (iuo *IntegrationUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *IntegrationUpdateOne {
+ iuo.modifiers = append(iuo.modifiers, modifiers...)
+ return iuo
+}
+
func (iuo *IntegrationUpdateOne) sqlSave(ctx context.Context) (_node *Integration, err error) {
if err := iuo.check(); err != nil {
return _node, err
@@ -1434,6 +1448,7 @@ func (iuo *IntegrationUpdateOne) sqlSave(ctx context.Context) (_node *Integratio
}
_spec.Node.Schema = iuo.schemaConfig.Integration
ctx = internal.NewSchemaConfigContext(ctx, iuo.schemaConfig)
+ _spec.AddModifiers(iuo.modifiers...)
_node = &Integration{config: iuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/integrationhistory_delete.go b/internal/ent/generated/integrationhistory_delete.go
index 9d1a4269..257ad003 100644
--- a/internal/ent/generated/integrationhistory_delete.go
+++ b/internal/ent/generated/integrationhistory_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/integrationhistory"
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// IntegrationHistoryDelete is the builder for deleting a IntegrationHistory entity.
diff --git a/internal/ent/generated/integrationhistory_query.go b/internal/ent/generated/integrationhistory_query.go
index f69220b5..14d08741 100644
--- a/internal/ent/generated/integrationhistory_query.go
+++ b/internal/ent/generated/integrationhistory_query.go
@@ -13,9 +13,8 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/integrationhistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// IntegrationHistoryQuery is the builder for querying IntegrationHistory entities.
@@ -25,8 +24,8 @@ type IntegrationHistoryQuery struct {
order []integrationhistory.OrderOption
inters []Interceptor
predicates []predicate.IntegrationHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*IntegrationHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -256,8 +255,9 @@ func (ihq *IntegrationHistoryQuery) Clone() *IntegrationHistoryQuery {
inters: append([]Interceptor{}, ihq.inters...),
predicates: append([]predicate.IntegrationHistory{}, ihq.predicates...),
// clone intermediate query.
- sql: ihq.sql.Clone(),
- path: ihq.path,
+ sql: ihq.sql.Clone(),
+ path: ihq.path,
+ modifiers: append([]func(*sql.Selector){}, ihq.modifiers...),
}
}
@@ -448,6 +448,9 @@ func (ihq *IntegrationHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector
t1.Schema(ihq.schemaConfig.IntegrationHistory)
ctx = internal.NewSchemaConfigContext(ctx, ihq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range ihq.modifiers {
+ m(selector)
+ }
for _, p := range ihq.predicates {
p(selector)
}
@@ -465,6 +468,12 @@ func (ihq *IntegrationHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ihq *IntegrationHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *IntegrationHistorySelect {
+ ihq.modifiers = append(ihq.modifiers, modifiers...)
+ return ihq.Select()
+}
+
// IntegrationHistoryGroupBy is the group-by builder for IntegrationHistory entities.
type IntegrationHistoryGroupBy struct {
selector
@@ -554,3 +563,9 @@ func (ihs *IntegrationHistorySelect) sqlScan(ctx context.Context, root *Integrat
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ihs *IntegrationHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *IntegrationHistorySelect {
+ ihs.modifiers = append(ihs.modifiers, modifiers...)
+ return ihs
+}
diff --git a/internal/ent/generated/integrationhistory_update.go b/internal/ent/generated/integrationhistory_update.go
index 53ffbfd6..68ec18ee 100644
--- a/internal/ent/generated/integrationhistory_update.go
+++ b/internal/ent/generated/integrationhistory_update.go
@@ -13,16 +13,16 @@ import (
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/integrationhistory"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// IntegrationHistoryUpdate is the builder for updating IntegrationHistory entities.
type IntegrationHistoryUpdate struct {
config
- hooks []Hook
- mutation *IntegrationHistoryMutation
+ hooks []Hook
+ mutation *IntegrationHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the IntegrationHistoryUpdate builder.
@@ -242,6 +242,12 @@ func (ihu *IntegrationHistoryUpdate) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ihu *IntegrationHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *IntegrationHistoryUpdate {
+ ihu.modifiers = append(ihu.modifiers, modifiers...)
+ return ihu
+}
+
func (ihu *IntegrationHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(integrationhistory.Table, integrationhistory.Columns, sqlgraph.NewFieldSpec(integrationhistory.FieldID, field.TypeString))
if ps := ihu.mutation.predicates; len(ps) > 0 {
@@ -318,6 +324,7 @@ func (ihu *IntegrationHistoryUpdate) sqlSave(ctx context.Context) (n int, err er
}
_spec.Node.Schema = ihu.schemaConfig.IntegrationHistory
ctx = internal.NewSchemaConfigContext(ctx, ihu.schemaConfig)
+ _spec.AddModifiers(ihu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, ihu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{integrationhistory.Label}
@@ -333,9 +340,10 @@ func (ihu *IntegrationHistoryUpdate) sqlSave(ctx context.Context) (n int, err er
// IntegrationHistoryUpdateOne is the builder for updating a single IntegrationHistory entity.
type IntegrationHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *IntegrationHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *IntegrationHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -562,6 +570,12 @@ func (ihuo *IntegrationHistoryUpdateOne) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ihuo *IntegrationHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *IntegrationHistoryUpdateOne {
+ ihuo.modifiers = append(ihuo.modifiers, modifiers...)
+ return ihuo
+}
+
func (ihuo *IntegrationHistoryUpdateOne) sqlSave(ctx context.Context) (_node *IntegrationHistory, err error) {
_spec := sqlgraph.NewUpdateSpec(integrationhistory.Table, integrationhistory.Columns, sqlgraph.NewFieldSpec(integrationhistory.FieldID, field.TypeString))
id, ok := ihuo.mutation.ID()
@@ -655,6 +669,7 @@ func (ihuo *IntegrationHistoryUpdateOne) sqlSave(ctx context.Context) (_node *In
}
_spec.Node.Schema = ihuo.schemaConfig.IntegrationHistory
ctx = internal.NewSchemaConfigContext(ctx, ihuo.schemaConfig)
+ _spec.AddModifiers(ihuo.modifiers...)
_node = &IntegrationHistory{config: ihuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/invite/where.go b/internal/ent/generated/invite/where.go
index 783d11ea..1a04abef 100644
--- a/internal/ent/generated/invite/where.go
+++ b/internal/ent/generated/invite/where.go
@@ -7,10 +7,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/invite_delete.go b/internal/ent/generated/invite_delete.go
index d48e52cc..d9813373 100644
--- a/internal/ent/generated/invite_delete.go
+++ b/internal/ent/generated/invite_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/invite"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// InviteDelete is the builder for deleting a Invite entity.
diff --git a/internal/ent/generated/invite_query.go b/internal/ent/generated/invite_query.go
index 3895c12c..e5c1ba54 100644
--- a/internal/ent/generated/invite_query.go
+++ b/internal/ent/generated/invite_query.go
@@ -14,11 +14,10 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/event"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/invite"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// InviteQuery is the builder for querying Invite entities.
@@ -30,8 +29,8 @@ type InviteQuery struct {
predicates []predicate.Invite
withOwner *OrganizationQuery
withEvents *EventQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*Invite) error
+ modifiers []func(*sql.Selector)
withNamedEvents map[string]*EventQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
@@ -314,8 +313,9 @@ func (iq *InviteQuery) Clone() *InviteQuery {
withOwner: iq.withOwner.Clone(),
withEvents: iq.withEvents.Clone(),
// clone intermediate query.
- sql: iq.sql.Clone(),
- path: iq.path,
+ sql: iq.sql.Clone(),
+ path: iq.path,
+ modifiers: append([]func(*sql.Selector){}, iq.modifiers...),
}
}
@@ -648,6 +648,9 @@ func (iq *InviteQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(iq.schemaConfig.Invite)
ctx = internal.NewSchemaConfigContext(ctx, iq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range iq.modifiers {
+ m(selector)
+ }
for _, p := range iq.predicates {
p(selector)
}
@@ -665,6 +668,12 @@ func (iq *InviteQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (iq *InviteQuery) Modify(modifiers ...func(s *sql.Selector)) *InviteSelect {
+ iq.modifiers = append(iq.modifiers, modifiers...)
+ return iq.Select()
+}
+
// WithNamedEvents tells the query-builder to eager-load the nodes that are connected to the "events"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (iq *InviteQuery) WithNamedEvents(name string, opts ...func(*EventQuery)) *InviteQuery {
@@ -768,3 +777,9 @@ func (is *InviteSelect) sqlScan(ctx context.Context, root *InviteQuery, v any) e
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (is *InviteSelect) Modify(modifiers ...func(s *sql.Selector)) *InviteSelect {
+ is.modifiers = append(is.modifiers, modifiers...)
+ return is
+}
diff --git a/internal/ent/generated/invite_update.go b/internal/ent/generated/invite_update.go
index f6fbe138..016c87b2 100644
--- a/internal/ent/generated/invite_update.go
+++ b/internal/ent/generated/invite_update.go
@@ -12,19 +12,19 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/event"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/invite"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// InviteUpdate is the builder for updating Invite entities.
type InviteUpdate struct {
config
- hooks []Hook
- mutation *InviteMutation
+ hooks []Hook
+ mutation *InviteMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the InviteUpdate builder.
@@ -338,6 +338,12 @@ func (iu *InviteUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (iu *InviteUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *InviteUpdate {
+ iu.modifiers = append(iu.modifiers, modifiers...)
+ return iu
+}
+
func (iu *InviteUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := iu.check(); err != nil {
return n, err
@@ -488,6 +494,7 @@ func (iu *InviteUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = iu.schemaConfig.Invite
ctx = internal.NewSchemaConfigContext(ctx, iu.schemaConfig)
+ _spec.AddModifiers(iu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, iu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{invite.Label}
@@ -503,9 +510,10 @@ func (iu *InviteUpdate) sqlSave(ctx context.Context) (n int, err error) {
// InviteUpdateOne is the builder for updating a single Invite entity.
type InviteUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *InviteMutation
+ fields []string
+ hooks []Hook
+ mutation *InviteMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -826,6 +834,12 @@ func (iuo *InviteUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (iuo *InviteUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *InviteUpdateOne {
+ iuo.modifiers = append(iuo.modifiers, modifiers...)
+ return iuo
+}
+
func (iuo *InviteUpdateOne) sqlSave(ctx context.Context) (_node *Invite, err error) {
if err := iuo.check(); err != nil {
return _node, err
@@ -993,6 +1007,7 @@ func (iuo *InviteUpdateOne) sqlSave(ctx context.Context) (_node *Invite, err err
}
_spec.Node.Schema = iuo.schemaConfig.Invite
ctx = internal.NewSchemaConfigContext(ctx, iuo.schemaConfig)
+ _spec.AddModifiers(iuo.modifiers...)
_node = &Invite{config: iuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/note/where.go b/internal/ent/generated/note/where.go
index 99a04e3a..fbe552e5 100644
--- a/internal/ent/generated/note/where.go
+++ b/internal/ent/generated/note/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/note_delete.go b/internal/ent/generated/note_delete.go
index cb5ca1cc..d7ec81ec 100644
--- a/internal/ent/generated/note_delete.go
+++ b/internal/ent/generated/note_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/note"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// NoteDelete is the builder for deleting a Note entity.
diff --git a/internal/ent/generated/note_query.go b/internal/ent/generated/note_query.go
index 692af3fb..61e5b205 100644
--- a/internal/ent/generated/note_query.go
+++ b/internal/ent/generated/note_query.go
@@ -13,11 +13,10 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/entity"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/note"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// NoteQuery is the builder for querying Note entities.
@@ -30,8 +29,8 @@ type NoteQuery struct {
withOwner *OrganizationQuery
withEntity *EntityQuery
withFKs bool
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*Note) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -313,8 +312,9 @@ func (nq *NoteQuery) Clone() *NoteQuery {
withOwner: nq.withOwner.Clone(),
withEntity: nq.withEntity.Clone(),
// clone intermediate query.
- sql: nq.sql.Clone(),
- path: nq.path,
+ sql: nq.sql.Clone(),
+ path: nq.path,
+ modifiers: append([]func(*sql.Selector){}, nq.modifiers...),
}
}
@@ -616,6 +616,9 @@ func (nq *NoteQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(nq.schemaConfig.Note)
ctx = internal.NewSchemaConfigContext(ctx, nq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range nq.modifiers {
+ m(selector)
+ }
for _, p := range nq.predicates {
p(selector)
}
@@ -633,6 +636,12 @@ func (nq *NoteQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (nq *NoteQuery) Modify(modifiers ...func(s *sql.Selector)) *NoteSelect {
+ nq.modifiers = append(nq.modifiers, modifiers...)
+ return nq.Select()
+}
+
// NoteGroupBy is the group-by builder for Note entities.
type NoteGroupBy struct {
selector
@@ -722,3 +731,9 @@ func (ns *NoteSelect) sqlScan(ctx context.Context, root *NoteQuery, v any) error
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ns *NoteSelect) Modify(modifiers ...func(s *sql.Selector)) *NoteSelect {
+ ns.modifiers = append(ns.modifiers, modifiers...)
+ return ns
+}
diff --git a/internal/ent/generated/note_update.go b/internal/ent/generated/note_update.go
index 9d8d86a3..b05d2cc7 100644
--- a/internal/ent/generated/note_update.go
+++ b/internal/ent/generated/note_update.go
@@ -13,18 +13,18 @@ import (
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/entity"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/note"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// NoteUpdate is the builder for updating Note entities.
type NoteUpdate struct {
config
- hooks []Hook
- mutation *NoteMutation
+ hooks []Hook
+ mutation *NoteMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the NoteUpdate builder.
@@ -255,6 +255,12 @@ func (nu *NoteUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (nu *NoteUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *NoteUpdate {
+ nu.modifiers = append(nu.modifiers, modifiers...)
+ return nu
+}
+
func (nu *NoteUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := nu.check(); err != nil {
return n, err
@@ -375,6 +381,7 @@ func (nu *NoteUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = nu.schemaConfig.Note
ctx = internal.NewSchemaConfigContext(ctx, nu.schemaConfig)
+ _spec.AddModifiers(nu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, nu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{note.Label}
@@ -390,9 +397,10 @@ func (nu *NoteUpdate) sqlSave(ctx context.Context) (n int, err error) {
// NoteUpdateOne is the builder for updating a single Note entity.
type NoteUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *NoteMutation
+ fields []string
+ hooks []Hook
+ mutation *NoteMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -630,6 +638,12 @@ func (nuo *NoteUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (nuo *NoteUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *NoteUpdateOne {
+ nuo.modifiers = append(nuo.modifiers, modifiers...)
+ return nuo
+}
+
func (nuo *NoteUpdateOne) sqlSave(ctx context.Context) (_node *Note, err error) {
if err := nuo.check(); err != nil {
return _node, err
@@ -767,6 +781,7 @@ func (nuo *NoteUpdateOne) sqlSave(ctx context.Context) (_node *Note, err error)
}
_spec.Node.Schema = nuo.schemaConfig.Note
ctx = internal.NewSchemaConfigContext(ctx, nuo.schemaConfig)
+ _spec.AddModifiers(nuo.modifiers...)
_node = &Note{config: nuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/notehistory_delete.go b/internal/ent/generated/notehistory_delete.go
index 8a147cd9..a36fc8f6 100644
--- a/internal/ent/generated/notehistory_delete.go
+++ b/internal/ent/generated/notehistory_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/notehistory"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// NoteHistoryDelete is the builder for deleting a NoteHistory entity.
diff --git a/internal/ent/generated/notehistory_query.go b/internal/ent/generated/notehistory_query.go
index 14264de1..c4a1324a 100644
--- a/internal/ent/generated/notehistory_query.go
+++ b/internal/ent/generated/notehistory_query.go
@@ -12,10 +12,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/notehistory"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// NoteHistoryQuery is the builder for querying NoteHistory entities.
@@ -25,8 +24,8 @@ type NoteHistoryQuery struct {
order []notehistory.OrderOption
inters []Interceptor
predicates []predicate.NoteHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*NoteHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -256,8 +255,9 @@ func (nhq *NoteHistoryQuery) Clone() *NoteHistoryQuery {
inters: append([]Interceptor{}, nhq.inters...),
predicates: append([]predicate.NoteHistory{}, nhq.predicates...),
// clone intermediate query.
- sql: nhq.sql.Clone(),
- path: nhq.path,
+ sql: nhq.sql.Clone(),
+ path: nhq.path,
+ modifiers: append([]func(*sql.Selector){}, nhq.modifiers...),
}
}
@@ -448,6 +448,9 @@ func (nhq *NoteHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(nhq.schemaConfig.NoteHistory)
ctx = internal.NewSchemaConfigContext(ctx, nhq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range nhq.modifiers {
+ m(selector)
+ }
for _, p := range nhq.predicates {
p(selector)
}
@@ -465,6 +468,12 @@ func (nhq *NoteHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (nhq *NoteHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *NoteHistorySelect {
+ nhq.modifiers = append(nhq.modifiers, modifiers...)
+ return nhq.Select()
+}
+
// NoteHistoryGroupBy is the group-by builder for NoteHistory entities.
type NoteHistoryGroupBy struct {
selector
@@ -554,3 +563,9 @@ func (nhs *NoteHistorySelect) sqlScan(ctx context.Context, root *NoteHistoryQuer
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (nhs *NoteHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *NoteHistorySelect {
+ nhs.modifiers = append(nhs.modifiers, modifiers...)
+ return nhs
+}
diff --git a/internal/ent/generated/notehistory_update.go b/internal/ent/generated/notehistory_update.go
index 2ac6f8ad..ce584292 100644
--- a/internal/ent/generated/notehistory_update.go
+++ b/internal/ent/generated/notehistory_update.go
@@ -12,17 +12,17 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/notehistory"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// NoteHistoryUpdate is the builder for updating NoteHistory entities.
type NoteHistoryUpdate struct {
config
- hooks []Hook
- mutation *NoteHistoryMutation
+ hooks []Hook
+ mutation *NoteHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the NoteHistoryUpdate builder.
@@ -202,6 +202,12 @@ func (nhu *NoteHistoryUpdate) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (nhu *NoteHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *NoteHistoryUpdate {
+ nhu.modifiers = append(nhu.modifiers, modifiers...)
+ return nhu
+}
+
func (nhu *NoteHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(notehistory.Table, notehistory.Columns, sqlgraph.NewFieldSpec(notehistory.FieldID, field.TypeString))
if ps := nhu.mutation.predicates; len(ps) > 0 {
@@ -266,6 +272,7 @@ func (nhu *NoteHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = nhu.schemaConfig.NoteHistory
ctx = internal.NewSchemaConfigContext(ctx, nhu.schemaConfig)
+ _spec.AddModifiers(nhu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, nhu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{notehistory.Label}
@@ -281,9 +288,10 @@ func (nhu *NoteHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
// NoteHistoryUpdateOne is the builder for updating a single NoteHistory entity.
type NoteHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *NoteHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *NoteHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -470,6 +478,12 @@ func (nhuo *NoteHistoryUpdateOne) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (nhuo *NoteHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *NoteHistoryUpdateOne {
+ nhuo.modifiers = append(nhuo.modifiers, modifiers...)
+ return nhuo
+}
+
func (nhuo *NoteHistoryUpdateOne) sqlSave(ctx context.Context) (_node *NoteHistory, err error) {
_spec := sqlgraph.NewUpdateSpec(notehistory.Table, notehistory.Columns, sqlgraph.NewFieldSpec(notehistory.FieldID, field.TypeString))
id, ok := nhuo.mutation.ID()
@@ -551,6 +565,7 @@ func (nhuo *NoteHistoryUpdateOne) sqlSave(ctx context.Context) (_node *NoteHisto
}
_spec.Node.Schema = nhuo.schemaConfig.NoteHistory
ctx = internal.NewSchemaConfigContext(ctx, nhuo.schemaConfig)
+ _spec.AddModifiers(nhuo.modifiers...)
_node = &NoteHistory{config: nhuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/oauthprovider/where.go b/internal/ent/generated/oauthprovider/where.go
index 84c88ef7..8ede9fa1 100644
--- a/internal/ent/generated/oauthprovider/where.go
+++ b/internal/ent/generated/oauthprovider/where.go
@@ -8,9 +8,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/theopenlane/core/internal/ent/customtypes"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/oauthprovider_delete.go b/internal/ent/generated/oauthprovider_delete.go
index 0359812f..7483b119 100644
--- a/internal/ent/generated/oauthprovider_delete.go
+++ b/internal/ent/generated/oauthprovider_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/oauthprovider"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// OauthProviderDelete is the builder for deleting a OauthProvider entity.
diff --git a/internal/ent/generated/oauthprovider_query.go b/internal/ent/generated/oauthprovider_query.go
index 0b9d0a97..cb459fa3 100644
--- a/internal/ent/generated/oauthprovider_query.go
+++ b/internal/ent/generated/oauthprovider_query.go
@@ -12,11 +12,10 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/oauthprovider"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// OauthProviderQuery is the builder for querying OauthProvider entities.
@@ -27,8 +26,8 @@ type OauthProviderQuery struct {
inters []Interceptor
predicates []predicate.OauthProvider
withOwner *OrganizationQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*OauthProvider) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -284,8 +283,9 @@ func (opq *OauthProviderQuery) Clone() *OauthProviderQuery {
predicates: append([]predicate.OauthProvider{}, opq.predicates...),
withOwner: opq.withOwner.Clone(),
// clone intermediate query.
- sql: opq.sql.Clone(),
- path: opq.path,
+ sql: opq.sql.Clone(),
+ path: opq.path,
+ modifiers: append([]func(*sql.Selector){}, opq.modifiers...),
}
}
@@ -530,6 +530,9 @@ func (opq *OauthProviderQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(opq.schemaConfig.OauthProvider)
ctx = internal.NewSchemaConfigContext(ctx, opq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range opq.modifiers {
+ m(selector)
+ }
for _, p := range opq.predicates {
p(selector)
}
@@ -547,6 +550,12 @@ func (opq *OauthProviderQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (opq *OauthProviderQuery) Modify(modifiers ...func(s *sql.Selector)) *OauthProviderSelect {
+ opq.modifiers = append(opq.modifiers, modifiers...)
+ return opq.Select()
+}
+
// OauthProviderGroupBy is the group-by builder for OauthProvider entities.
type OauthProviderGroupBy struct {
selector
@@ -636,3 +645,9 @@ func (ops *OauthProviderSelect) sqlScan(ctx context.Context, root *OauthProvider
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ops *OauthProviderSelect) Modify(modifiers ...func(s *sql.Selector)) *OauthProviderSelect {
+ ops.modifiers = append(ops.modifiers, modifiers...)
+ return ops
+}
diff --git a/internal/ent/generated/oauthprovider_update.go b/internal/ent/generated/oauthprovider_update.go
index ae5f7973..b62615de 100644
--- a/internal/ent/generated/oauthprovider_update.go
+++ b/internal/ent/generated/oauthprovider_update.go
@@ -13,18 +13,18 @@ import (
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/customtypes"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/oauthprovider"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// OauthProviderUpdate is the builder for updating OauthProvider entities.
type OauthProviderUpdate struct {
config
- hooks []Hook
- mutation *OauthProviderMutation
+ hooks []Hook
+ mutation *OauthProviderMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the OauthProviderUpdate builder.
@@ -344,6 +344,12 @@ func (opu *OauthProviderUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (opu *OauthProviderUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *OauthProviderUpdate {
+ opu.modifiers = append(opu.modifiers, modifiers...)
+ return opu
+}
+
func (opu *OauthProviderUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := opu.check(); err != nil {
return n, err
@@ -460,6 +466,7 @@ func (opu *OauthProviderUpdate) sqlSave(ctx context.Context) (n int, err error)
}
_spec.Node.Schema = opu.schemaConfig.OauthProvider
ctx = internal.NewSchemaConfigContext(ctx, opu.schemaConfig)
+ _spec.AddModifiers(opu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, opu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{oauthprovider.Label}
@@ -475,9 +482,10 @@ func (opu *OauthProviderUpdate) sqlSave(ctx context.Context) (n int, err error)
// OauthProviderUpdateOne is the builder for updating a single OauthProvider entity.
type OauthProviderUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *OauthProviderMutation
+ fields []string
+ hooks []Hook
+ mutation *OauthProviderMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -804,6 +812,12 @@ func (opuo *OauthProviderUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (opuo *OauthProviderUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *OauthProviderUpdateOne {
+ opuo.modifiers = append(opuo.modifiers, modifiers...)
+ return opuo
+}
+
func (opuo *OauthProviderUpdateOne) sqlSave(ctx context.Context) (_node *OauthProvider, err error) {
if err := opuo.check(); err != nil {
return _node, err
@@ -937,6 +951,7 @@ func (opuo *OauthProviderUpdateOne) sqlSave(ctx context.Context) (_node *OauthPr
}
_spec.Node.Schema = opuo.schemaConfig.OauthProvider
ctx = internal.NewSchemaConfigContext(ctx, opuo.schemaConfig)
+ _spec.AddModifiers(opuo.modifiers...)
_node = &OauthProvider{config: opuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/oauthproviderhistory_delete.go b/internal/ent/generated/oauthproviderhistory_delete.go
index 9ad5c3e4..743da923 100644
--- a/internal/ent/generated/oauthproviderhistory_delete.go
+++ b/internal/ent/generated/oauthproviderhistory_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/oauthproviderhistory"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// OauthProviderHistoryDelete is the builder for deleting a OauthProviderHistory entity.
diff --git a/internal/ent/generated/oauthproviderhistory_query.go b/internal/ent/generated/oauthproviderhistory_query.go
index 6181b964..f4410002 100644
--- a/internal/ent/generated/oauthproviderhistory_query.go
+++ b/internal/ent/generated/oauthproviderhistory_query.go
@@ -12,10 +12,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/oauthproviderhistory"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// OauthProviderHistoryQuery is the builder for querying OauthProviderHistory entities.
@@ -25,8 +24,8 @@ type OauthProviderHistoryQuery struct {
order []oauthproviderhistory.OrderOption
inters []Interceptor
predicates []predicate.OauthProviderHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*OauthProviderHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -256,8 +255,9 @@ func (ophq *OauthProviderHistoryQuery) Clone() *OauthProviderHistoryQuery {
inters: append([]Interceptor{}, ophq.inters...),
predicates: append([]predicate.OauthProviderHistory{}, ophq.predicates...),
// clone intermediate query.
- sql: ophq.sql.Clone(),
- path: ophq.path,
+ sql: ophq.sql.Clone(),
+ path: ophq.path,
+ modifiers: append([]func(*sql.Selector){}, ophq.modifiers...),
}
}
@@ -448,6 +448,9 @@ func (ophq *OauthProviderHistoryQuery) sqlQuery(ctx context.Context) *sql.Select
t1.Schema(ophq.schemaConfig.OauthProviderHistory)
ctx = internal.NewSchemaConfigContext(ctx, ophq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range ophq.modifiers {
+ m(selector)
+ }
for _, p := range ophq.predicates {
p(selector)
}
@@ -465,6 +468,12 @@ func (ophq *OauthProviderHistoryQuery) sqlQuery(ctx context.Context) *sql.Select
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ophq *OauthProviderHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *OauthProviderHistorySelect {
+ ophq.modifiers = append(ophq.modifiers, modifiers...)
+ return ophq.Select()
+}
+
// OauthProviderHistoryGroupBy is the group-by builder for OauthProviderHistory entities.
type OauthProviderHistoryGroupBy struct {
selector
@@ -554,3 +563,9 @@ func (ophs *OauthProviderHistorySelect) sqlScan(ctx context.Context, root *Oauth
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ophs *OauthProviderHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *OauthProviderHistorySelect {
+ ophs.modifiers = append(ophs.modifiers, modifiers...)
+ return ophs
+}
diff --git a/internal/ent/generated/oauthproviderhistory_update.go b/internal/ent/generated/oauthproviderhistory_update.go
index 508b14b3..e522d544 100644
--- a/internal/ent/generated/oauthproviderhistory_update.go
+++ b/internal/ent/generated/oauthproviderhistory_update.go
@@ -13,17 +13,17 @@ import (
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/customtypes"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/oauthproviderhistory"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// OauthProviderHistoryUpdate is the builder for updating OauthProviderHistory entities.
type OauthProviderHistoryUpdate struct {
config
- hooks []Hook
- mutation *OauthProviderHistoryMutation
+ hooks []Hook
+ mutation *OauthProviderHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the OauthProviderHistoryUpdate builder.
@@ -322,6 +322,12 @@ func (ophu *OauthProviderHistoryUpdate) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ophu *OauthProviderHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *OauthProviderHistoryUpdate {
+ ophu.modifiers = append(ophu.modifiers, modifiers...)
+ return ophu
+}
+
func (ophu *OauthProviderHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(oauthproviderhistory.Table, oauthproviderhistory.Columns, sqlgraph.NewFieldSpec(oauthproviderhistory.FieldID, field.TypeString))
if ps := ophu.mutation.predicates; len(ps) > 0 {
@@ -413,6 +419,7 @@ func (ophu *OauthProviderHistoryUpdate) sqlSave(ctx context.Context) (n int, err
}
_spec.Node.Schema = ophu.schemaConfig.OauthProviderHistory
ctx = internal.NewSchemaConfigContext(ctx, ophu.schemaConfig)
+ _spec.AddModifiers(ophu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, ophu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{oauthproviderhistory.Label}
@@ -428,9 +435,10 @@ func (ophu *OauthProviderHistoryUpdate) sqlSave(ctx context.Context) (n int, err
// OauthProviderHistoryUpdateOne is the builder for updating a single OauthProviderHistory entity.
type OauthProviderHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *OauthProviderHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *OauthProviderHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -736,6 +744,12 @@ func (ophuo *OauthProviderHistoryUpdateOne) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ophuo *OauthProviderHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *OauthProviderHistoryUpdateOne {
+ ophuo.modifiers = append(ophuo.modifiers, modifiers...)
+ return ophuo
+}
+
func (ophuo *OauthProviderHistoryUpdateOne) sqlSave(ctx context.Context) (_node *OauthProviderHistory, err error) {
_spec := sqlgraph.NewUpdateSpec(oauthproviderhistory.Table, oauthproviderhistory.Columns, sqlgraph.NewFieldSpec(oauthproviderhistory.FieldID, field.TypeString))
id, ok := ophuo.mutation.ID()
@@ -844,6 +858,7 @@ func (ophuo *OauthProviderHistoryUpdateOne) sqlSave(ctx context.Context) (_node
}
_spec.Node.Schema = ophuo.schemaConfig.OauthProviderHistory
ctx = internal.NewSchemaConfigContext(ctx, ophuo.schemaConfig)
+ _spec.AddModifiers(ophuo.modifiers...)
_node = &OauthProviderHistory{config: ophuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/ohauthtootoken/where.go b/internal/ent/generated/ohauthtootoken/where.go
index 1f815d62..055e5fe9 100644
--- a/internal/ent/generated/ohauthtootoken/where.go
+++ b/internal/ent/generated/ohauthtootoken/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/ohauthtootoken_delete.go b/internal/ent/generated/ohauthtootoken_delete.go
index c2f2a102..551b4fdf 100644
--- a/internal/ent/generated/ohauthtootoken_delete.go
+++ b/internal/ent/generated/ohauthtootoken_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/ohauthtootoken"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// OhAuthTooTokenDelete is the builder for deleting a OhAuthTooToken entity.
diff --git a/internal/ent/generated/ohauthtootoken_query.go b/internal/ent/generated/ohauthtootoken_query.go
index a84f39a4..61c66f39 100644
--- a/internal/ent/generated/ohauthtootoken_query.go
+++ b/internal/ent/generated/ohauthtootoken_query.go
@@ -14,10 +14,9 @@ import (
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/event"
"github.com/theopenlane/core/internal/ent/generated/integration"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/ohauthtootoken"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// OhAuthTooTokenQuery is the builder for querying OhAuthTooToken entities.
@@ -29,8 +28,8 @@ type OhAuthTooTokenQuery struct {
predicates []predicate.OhAuthTooToken
withIntegration *IntegrationQuery
withEvents *EventQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*OhAuthTooToken) error
+ modifiers []func(*sql.Selector)
withNamedIntegration map[string]*IntegrationQuery
withNamedEvents map[string]*EventQuery
// intermediate query (i.e. traversal path).
@@ -314,8 +313,9 @@ func (oattq *OhAuthTooTokenQuery) Clone() *OhAuthTooTokenQuery {
withIntegration: oattq.withIntegration.Clone(),
withEvents: oattq.withEvents.Clone(),
// clone intermediate query.
- sql: oattq.sql.Clone(),
- path: oattq.path,
+ sql: oattq.sql.Clone(),
+ path: oattq.path,
+ modifiers: append([]func(*sql.Selector){}, oattq.modifiers...),
}
}
@@ -680,6 +680,9 @@ func (oattq *OhAuthTooTokenQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(oattq.schemaConfig.OhAuthTooToken)
ctx = internal.NewSchemaConfigContext(ctx, oattq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range oattq.modifiers {
+ m(selector)
+ }
for _, p := range oattq.predicates {
p(selector)
}
@@ -697,6 +700,12 @@ func (oattq *OhAuthTooTokenQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (oattq *OhAuthTooTokenQuery) Modify(modifiers ...func(s *sql.Selector)) *OhAuthTooTokenSelect {
+ oattq.modifiers = append(oattq.modifiers, modifiers...)
+ return oattq.Select()
+}
+
// WithNamedIntegration tells the query-builder to eager-load the nodes that are connected to the "integration"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (oattq *OhAuthTooTokenQuery) WithNamedIntegration(name string, opts ...func(*IntegrationQuery)) *OhAuthTooTokenQuery {
@@ -814,3 +823,9 @@ func (oatts *OhAuthTooTokenSelect) sqlScan(ctx context.Context, root *OhAuthTooT
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (oatts *OhAuthTooTokenSelect) Modify(modifiers ...func(s *sql.Selector)) *OhAuthTooTokenSelect {
+ oatts.modifiers = append(oatts.modifiers, modifiers...)
+ return oatts
+}
diff --git a/internal/ent/generated/ohauthtootoken_update.go b/internal/ent/generated/ohauthtootoken_update.go
index 735ab6d0..e71be300 100644
--- a/internal/ent/generated/ohauthtootoken_update.go
+++ b/internal/ent/generated/ohauthtootoken_update.go
@@ -14,17 +14,17 @@ import (
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/event"
"github.com/theopenlane/core/internal/ent/generated/integration"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/ohauthtootoken"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// OhAuthTooTokenUpdate is the builder for updating OhAuthTooToken entities.
type OhAuthTooTokenUpdate struct {
config
- hooks []Hook
- mutation *OhAuthTooTokenMutation
+ hooks []Hook
+ mutation *OhAuthTooTokenMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the OhAuthTooTokenUpdate builder.
@@ -370,6 +370,12 @@ func (oattu *OhAuthTooTokenUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (oattu *OhAuthTooTokenUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *OhAuthTooTokenUpdate {
+ oattu.modifiers = append(oattu.modifiers, modifiers...)
+ return oattu
+}
+
func (oattu *OhAuthTooTokenUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := oattu.check(); err != nil {
return n, err
@@ -551,6 +557,7 @@ func (oattu *OhAuthTooTokenUpdate) sqlSave(ctx context.Context) (n int, err erro
}
_spec.Node.Schema = oattu.schemaConfig.OhAuthTooToken
ctx = internal.NewSchemaConfigContext(ctx, oattu.schemaConfig)
+ _spec.AddModifiers(oattu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, oattu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{ohauthtootoken.Label}
@@ -566,9 +573,10 @@ func (oattu *OhAuthTooTokenUpdate) sqlSave(ctx context.Context) (n int, err erro
// OhAuthTooTokenUpdateOne is the builder for updating a single OhAuthTooToken entity.
type OhAuthTooTokenUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *OhAuthTooTokenMutation
+ fields []string
+ hooks []Hook
+ mutation *OhAuthTooTokenMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetTags sets the "tags" field.
@@ -921,6 +929,12 @@ func (oattuo *OhAuthTooTokenUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (oattuo *OhAuthTooTokenUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *OhAuthTooTokenUpdateOne {
+ oattuo.modifiers = append(oattuo.modifiers, modifiers...)
+ return oattuo
+}
+
func (oattuo *OhAuthTooTokenUpdateOne) sqlSave(ctx context.Context) (_node *OhAuthTooToken, err error) {
if err := oattuo.check(); err != nil {
return _node, err
@@ -1119,6 +1133,7 @@ func (oattuo *OhAuthTooTokenUpdateOne) sqlSave(ctx context.Context) (_node *OhAu
}
_spec.Node.Schema = oattuo.schemaConfig.OhAuthTooToken
ctx = internal.NewSchemaConfigContext(ctx, oattuo.schemaConfig)
+ _spec.AddModifiers(oattuo.modifiers...)
_node = &OhAuthTooToken{config: oattuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/organization/where.go b/internal/ent/generated/organization/where.go
index 38608d45..b54d762c 100644
--- a/internal/ent/generated/organization/where.go
+++ b/internal/ent/generated/organization/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/organization_delete.go b/internal/ent/generated/organization_delete.go
index bf8efe1b..e7486d3b 100644
--- a/internal/ent/generated/organization_delete.go
+++ b/internal/ent/generated/organization_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// OrganizationDelete is the builder for deleting a Organization entity.
diff --git a/internal/ent/generated/organization_query.go b/internal/ent/generated/organization_query.go
index 8381f4b8..ff470192 100644
--- a/internal/ent/generated/organization_query.go
+++ b/internal/ent/generated/organization_query.go
@@ -27,6 +27,7 @@ import (
"github.com/theopenlane/core/internal/ent/generated/group"
"github.com/theopenlane/core/internal/ent/generated/hush"
"github.com/theopenlane/core/internal/ent/generated/integration"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/invite"
"github.com/theopenlane/core/internal/ent/generated/note"
"github.com/theopenlane/core/internal/ent/generated/oauthprovider"
@@ -39,8 +40,6 @@ import (
"github.com/theopenlane/core/internal/ent/generated/template"
"github.com/theopenlane/core/internal/ent/generated/user"
"github.com/theopenlane/core/internal/ent/generated/webhook"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// OrganizationQuery is the builder for querying Organization entities.
@@ -77,8 +76,8 @@ type OrganizationQuery struct {
withContacts *ContactQuery
withNotes *NoteQuery
withMembers *OrgMembershipQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*Organization) error
+ modifiers []func(*sql.Selector)
withNamedChildren map[string]*OrganizationQuery
withNamedGroups map[string]*GroupQuery
withNamedTemplates map[string]*TemplateQuery
@@ -1035,8 +1034,9 @@ func (oq *OrganizationQuery) Clone() *OrganizationQuery {
withNotes: oq.withNotes.Clone(),
withMembers: oq.withMembers.Clone(),
// clone intermediate query.
- sql: oq.sql.Clone(),
- path: oq.path,
+ sql: oq.sql.Clone(),
+ path: oq.path,
+ modifiers: append([]func(*sql.Selector){}, oq.modifiers...),
}
}
@@ -2897,6 +2897,9 @@ func (oq *OrganizationQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(oq.schemaConfig.Organization)
ctx = internal.NewSchemaConfigContext(ctx, oq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range oq.modifiers {
+ m(selector)
+ }
for _, p := range oq.predicates {
p(selector)
}
@@ -2914,6 +2917,12 @@ func (oq *OrganizationQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (oq *OrganizationQuery) Modify(modifiers ...func(s *sql.Selector)) *OrganizationSelect {
+ oq.modifiers = append(oq.modifiers, modifiers...)
+ return oq.Select()
+}
+
// WithNamedChildren tells the query-builder to eager-load the nodes that are connected to the "children"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (oq *OrganizationQuery) WithNamedChildren(name string, opts ...func(*OrganizationQuery)) *OrganizationQuery {
@@ -3353,3 +3362,9 @@ func (os *OrganizationSelect) sqlScan(ctx context.Context, root *OrganizationQue
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (os *OrganizationSelect) Modify(modifiers ...func(s *sql.Selector)) *OrganizationSelect {
+ os.modifiers = append(os.modifiers, modifiers...)
+ return os
+}
diff --git a/internal/ent/generated/organization_update.go b/internal/ent/generated/organization_update.go
index 6ae350d5..7dfecf03 100644
--- a/internal/ent/generated/organization_update.go
+++ b/internal/ent/generated/organization_update.go
@@ -26,6 +26,7 @@ import (
"github.com/theopenlane/core/internal/ent/generated/group"
"github.com/theopenlane/core/internal/ent/generated/hush"
"github.com/theopenlane/core/internal/ent/generated/integration"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/invite"
"github.com/theopenlane/core/internal/ent/generated/note"
"github.com/theopenlane/core/internal/ent/generated/oauthprovider"
@@ -38,15 +39,14 @@ import (
"github.com/theopenlane/core/internal/ent/generated/template"
"github.com/theopenlane/core/internal/ent/generated/user"
"github.com/theopenlane/core/internal/ent/generated/webhook"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// OrganizationUpdate is the builder for updating Organization entities.
type OrganizationUpdate struct {
config
- hooks []Hook
- mutation *OrganizationMutation
+ hooks []Hook
+ mutation *OrganizationMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the OrganizationUpdate builder.
@@ -1219,6 +1219,12 @@ func (ou *OrganizationUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ou *OrganizationUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *OrganizationUpdate {
+ ou.modifiers = append(ou.modifiers, modifiers...)
+ return ou
+}
+
func (ou *OrganizationUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := ou.check(); err != nil {
return n, err
@@ -2550,6 +2556,7 @@ func (ou *OrganizationUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = ou.schemaConfig.Organization
ctx = internal.NewSchemaConfigContext(ctx, ou.schemaConfig)
+ _spec.AddModifiers(ou.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, ou.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{organization.Label}
@@ -2565,9 +2572,10 @@ func (ou *OrganizationUpdate) sqlSave(ctx context.Context) (n int, err error) {
// OrganizationUpdateOne is the builder for updating a single Organization entity.
type OrganizationUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *OrganizationMutation
+ fields []string
+ hooks []Hook
+ mutation *OrganizationMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -3747,6 +3755,12 @@ func (ouo *OrganizationUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ouo *OrganizationUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *OrganizationUpdateOne {
+ ouo.modifiers = append(ouo.modifiers, modifiers...)
+ return ouo
+}
+
func (ouo *OrganizationUpdateOne) sqlSave(ctx context.Context) (_node *Organization, err error) {
if err := ouo.check(); err != nil {
return _node, err
@@ -5095,6 +5109,7 @@ func (ouo *OrganizationUpdateOne) sqlSave(ctx context.Context) (_node *Organizat
}
_spec.Node.Schema = ouo.schemaConfig.Organization
ctx = internal.NewSchemaConfigContext(ctx, ouo.schemaConfig)
+ _spec.AddModifiers(ouo.modifiers...)
_node = &Organization{config: ouo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/organizationhistory_delete.go b/internal/ent/generated/organizationhistory_delete.go
index 3c04f27e..fc6e383e 100644
--- a/internal/ent/generated/organizationhistory_delete.go
+++ b/internal/ent/generated/organizationhistory_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organizationhistory"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// OrganizationHistoryDelete is the builder for deleting a OrganizationHistory entity.
diff --git a/internal/ent/generated/organizationhistory_query.go b/internal/ent/generated/organizationhistory_query.go
index d142f65e..7e78c17b 100644
--- a/internal/ent/generated/organizationhistory_query.go
+++ b/internal/ent/generated/organizationhistory_query.go
@@ -12,10 +12,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organizationhistory"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// OrganizationHistoryQuery is the builder for querying OrganizationHistory entities.
@@ -25,8 +24,8 @@ type OrganizationHistoryQuery struct {
order []organizationhistory.OrderOption
inters []Interceptor
predicates []predicate.OrganizationHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*OrganizationHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -256,8 +255,9 @@ func (ohq *OrganizationHistoryQuery) Clone() *OrganizationHistoryQuery {
inters: append([]Interceptor{}, ohq.inters...),
predicates: append([]predicate.OrganizationHistory{}, ohq.predicates...),
// clone intermediate query.
- sql: ohq.sql.Clone(),
- path: ohq.path,
+ sql: ohq.sql.Clone(),
+ path: ohq.path,
+ modifiers: append([]func(*sql.Selector){}, ohq.modifiers...),
}
}
@@ -448,6 +448,9 @@ func (ohq *OrganizationHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector
t1.Schema(ohq.schemaConfig.OrganizationHistory)
ctx = internal.NewSchemaConfigContext(ctx, ohq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range ohq.modifiers {
+ m(selector)
+ }
for _, p := range ohq.predicates {
p(selector)
}
@@ -465,6 +468,12 @@ func (ohq *OrganizationHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ohq *OrganizationHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *OrganizationHistorySelect {
+ ohq.modifiers = append(ohq.modifiers, modifiers...)
+ return ohq.Select()
+}
+
// OrganizationHistoryGroupBy is the group-by builder for OrganizationHistory entities.
type OrganizationHistoryGroupBy struct {
selector
@@ -554,3 +563,9 @@ func (ohs *OrganizationHistorySelect) sqlScan(ctx context.Context, root *Organiz
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ohs *OrganizationHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *OrganizationHistorySelect {
+ ohs.modifiers = append(ohs.modifiers, modifiers...)
+ return ohs
+}
diff --git a/internal/ent/generated/organizationhistory_update.go b/internal/ent/generated/organizationhistory_update.go
index 751b4655..58f68d7f 100644
--- a/internal/ent/generated/organizationhistory_update.go
+++ b/internal/ent/generated/organizationhistory_update.go
@@ -12,17 +12,17 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organizationhistory"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// OrganizationHistoryUpdate is the builder for updating OrganizationHistory entities.
type OrganizationHistoryUpdate struct {
config
- hooks []Hook
- mutation *OrganizationHistoryMutation
+ hooks []Hook
+ mutation *OrganizationHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the OrganizationHistoryUpdate builder.
@@ -250,6 +250,12 @@ func (ohu *OrganizationHistoryUpdate) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ohu *OrganizationHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *OrganizationHistoryUpdate {
+ ohu.modifiers = append(ohu.modifiers, modifiers...)
+ return ohu
+}
+
func (ohu *OrganizationHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(organizationhistory.Table, organizationhistory.Columns, sqlgraph.NewFieldSpec(organizationhistory.FieldID, field.TypeString))
if ps := ohu.mutation.predicates; len(ps) > 0 {
@@ -332,6 +338,7 @@ func (ohu *OrganizationHistoryUpdate) sqlSave(ctx context.Context) (n int, err e
}
_spec.Node.Schema = ohu.schemaConfig.OrganizationHistory
ctx = internal.NewSchemaConfigContext(ctx, ohu.schemaConfig)
+ _spec.AddModifiers(ohu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, ohu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{organizationhistory.Label}
@@ -347,9 +354,10 @@ func (ohu *OrganizationHistoryUpdate) sqlSave(ctx context.Context) (n int, err e
// OrganizationHistoryUpdateOne is the builder for updating a single OrganizationHistory entity.
type OrganizationHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *OrganizationHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *OrganizationHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -584,6 +592,12 @@ func (ohuo *OrganizationHistoryUpdateOne) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ohuo *OrganizationHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *OrganizationHistoryUpdateOne {
+ ohuo.modifiers = append(ohuo.modifiers, modifiers...)
+ return ohuo
+}
+
func (ohuo *OrganizationHistoryUpdateOne) sqlSave(ctx context.Context) (_node *OrganizationHistory, err error) {
_spec := sqlgraph.NewUpdateSpec(organizationhistory.Table, organizationhistory.Columns, sqlgraph.NewFieldSpec(organizationhistory.FieldID, field.TypeString))
id, ok := ohuo.mutation.ID()
@@ -683,6 +697,7 @@ func (ohuo *OrganizationHistoryUpdateOne) sqlSave(ctx context.Context) (_node *O
}
_spec.Node.Schema = ohuo.schemaConfig.OrganizationHistory
ctx = internal.NewSchemaConfigContext(ctx, ohuo.schemaConfig)
+ _spec.AddModifiers(ohuo.modifiers...)
_node = &OrganizationHistory{config: ohuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/organizationsetting/where.go b/internal/ent/generated/organizationsetting/where.go
index ae03af07..0ca88600 100644
--- a/internal/ent/generated/organizationsetting/where.go
+++ b/internal/ent/generated/organizationsetting/where.go
@@ -7,10 +7,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/organizationsetting_delete.go b/internal/ent/generated/organizationsetting_delete.go
index f4de5b59..73091577 100644
--- a/internal/ent/generated/organizationsetting_delete.go
+++ b/internal/ent/generated/organizationsetting_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organizationsetting"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// OrganizationSettingDelete is the builder for deleting a OrganizationSetting entity.
diff --git a/internal/ent/generated/organizationsetting_query.go b/internal/ent/generated/organizationsetting_query.go
index a421bc8b..ab764de4 100644
--- a/internal/ent/generated/organizationsetting_query.go
+++ b/internal/ent/generated/organizationsetting_query.go
@@ -12,11 +12,10 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/organizationsetting"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// OrganizationSettingQuery is the builder for querying OrganizationSetting entities.
@@ -27,8 +26,8 @@ type OrganizationSettingQuery struct {
inters []Interceptor
predicates []predicate.OrganizationSetting
withOrganization *OrganizationQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*OrganizationSetting) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -284,8 +283,9 @@ func (osq *OrganizationSettingQuery) Clone() *OrganizationSettingQuery {
predicates: append([]predicate.OrganizationSetting{}, osq.predicates...),
withOrganization: osq.withOrganization.Clone(),
// clone intermediate query.
- sql: osq.sql.Clone(),
- path: osq.path,
+ sql: osq.sql.Clone(),
+ path: osq.path,
+ modifiers: append([]func(*sql.Selector){}, osq.modifiers...),
}
}
@@ -530,6 +530,9 @@ func (osq *OrganizationSettingQuery) sqlQuery(ctx context.Context) *sql.Selector
t1.Schema(osq.schemaConfig.OrganizationSetting)
ctx = internal.NewSchemaConfigContext(ctx, osq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range osq.modifiers {
+ m(selector)
+ }
for _, p := range osq.predicates {
p(selector)
}
@@ -547,6 +550,12 @@ func (osq *OrganizationSettingQuery) sqlQuery(ctx context.Context) *sql.Selector
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (osq *OrganizationSettingQuery) Modify(modifiers ...func(s *sql.Selector)) *OrganizationSettingSelect {
+ osq.modifiers = append(osq.modifiers, modifiers...)
+ return osq.Select()
+}
+
// OrganizationSettingGroupBy is the group-by builder for OrganizationSetting entities.
type OrganizationSettingGroupBy struct {
selector
@@ -636,3 +645,9 @@ func (oss *OrganizationSettingSelect) sqlScan(ctx context.Context, root *Organiz
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (oss *OrganizationSettingSelect) Modify(modifiers ...func(s *sql.Selector)) *OrganizationSettingSelect {
+ oss.modifiers = append(oss.modifiers, modifiers...)
+ return oss
+}
diff --git a/internal/ent/generated/organizationsetting_update.go b/internal/ent/generated/organizationsetting_update.go
index ce2afe97..269d2367 100644
--- a/internal/ent/generated/organizationsetting_update.go
+++ b/internal/ent/generated/organizationsetting_update.go
@@ -12,19 +12,19 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/organizationsetting"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// OrganizationSettingUpdate is the builder for updating OrganizationSetting entities.
type OrganizationSettingUpdate struct {
config
- hooks []Hook
- mutation *OrganizationSettingMutation
+ hooks []Hook
+ mutation *OrganizationSettingMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the OrganizationSettingUpdate builder.
@@ -364,6 +364,12 @@ func (osu *OrganizationSettingUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (osu *OrganizationSettingUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *OrganizationSettingUpdate {
+ osu.modifiers = append(osu.modifiers, modifiers...)
+ return osu
+}
+
func (osu *OrganizationSettingUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := osu.check(); err != nil {
return n, err
@@ -497,6 +503,7 @@ func (osu *OrganizationSettingUpdate) sqlSave(ctx context.Context) (n int, err e
}
_spec.Node.Schema = osu.schemaConfig.OrganizationSetting
ctx = internal.NewSchemaConfigContext(ctx, osu.schemaConfig)
+ _spec.AddModifiers(osu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, osu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{organizationsetting.Label}
@@ -512,9 +519,10 @@ func (osu *OrganizationSettingUpdate) sqlSave(ctx context.Context) (n int, err e
// OrganizationSettingUpdateOne is the builder for updating a single OrganizationSetting entity.
type OrganizationSettingUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *OrganizationSettingMutation
+ fields []string
+ hooks []Hook
+ mutation *OrganizationSettingMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -861,6 +869,12 @@ func (osuo *OrganizationSettingUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (osuo *OrganizationSettingUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *OrganizationSettingUpdateOne {
+ osuo.modifiers = append(osuo.modifiers, modifiers...)
+ return osuo
+}
+
func (osuo *OrganizationSettingUpdateOne) sqlSave(ctx context.Context) (_node *OrganizationSetting, err error) {
if err := osuo.check(); err != nil {
return _node, err
@@ -1011,6 +1025,7 @@ func (osuo *OrganizationSettingUpdateOne) sqlSave(ctx context.Context) (_node *O
}
_spec.Node.Schema = osuo.schemaConfig.OrganizationSetting
ctx = internal.NewSchemaConfigContext(ctx, osuo.schemaConfig)
+ _spec.AddModifiers(osuo.modifiers...)
_node = &OrganizationSetting{config: osuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/organizationsettinghistory_delete.go b/internal/ent/generated/organizationsettinghistory_delete.go
index aac25370..190603a7 100644
--- a/internal/ent/generated/organizationsettinghistory_delete.go
+++ b/internal/ent/generated/organizationsettinghistory_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organizationsettinghistory"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// OrganizationSettingHistoryDelete is the builder for deleting a OrganizationSettingHistory entity.
diff --git a/internal/ent/generated/organizationsettinghistory_query.go b/internal/ent/generated/organizationsettinghistory_query.go
index 7572b040..1bdadceb 100644
--- a/internal/ent/generated/organizationsettinghistory_query.go
+++ b/internal/ent/generated/organizationsettinghistory_query.go
@@ -12,10 +12,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organizationsettinghistory"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// OrganizationSettingHistoryQuery is the builder for querying OrganizationSettingHistory entities.
@@ -25,8 +24,8 @@ type OrganizationSettingHistoryQuery struct {
order []organizationsettinghistory.OrderOption
inters []Interceptor
predicates []predicate.OrganizationSettingHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*OrganizationSettingHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -256,8 +255,9 @@ func (oshq *OrganizationSettingHistoryQuery) Clone() *OrganizationSettingHistory
inters: append([]Interceptor{}, oshq.inters...),
predicates: append([]predicate.OrganizationSettingHistory{}, oshq.predicates...),
// clone intermediate query.
- sql: oshq.sql.Clone(),
- path: oshq.path,
+ sql: oshq.sql.Clone(),
+ path: oshq.path,
+ modifiers: append([]func(*sql.Selector){}, oshq.modifiers...),
}
}
@@ -448,6 +448,9 @@ func (oshq *OrganizationSettingHistoryQuery) sqlQuery(ctx context.Context) *sql.
t1.Schema(oshq.schemaConfig.OrganizationSettingHistory)
ctx = internal.NewSchemaConfigContext(ctx, oshq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range oshq.modifiers {
+ m(selector)
+ }
for _, p := range oshq.predicates {
p(selector)
}
@@ -465,6 +468,12 @@ func (oshq *OrganizationSettingHistoryQuery) sqlQuery(ctx context.Context) *sql.
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (oshq *OrganizationSettingHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *OrganizationSettingHistorySelect {
+ oshq.modifiers = append(oshq.modifiers, modifiers...)
+ return oshq.Select()
+}
+
// OrganizationSettingHistoryGroupBy is the group-by builder for OrganizationSettingHistory entities.
type OrganizationSettingHistoryGroupBy struct {
selector
@@ -554,3 +563,9 @@ func (oshs *OrganizationSettingHistorySelect) sqlScan(ctx context.Context, root
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (oshs *OrganizationSettingHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *OrganizationSettingHistorySelect {
+ oshs.modifiers = append(oshs.modifiers, modifiers...)
+ return oshs
+}
diff --git a/internal/ent/generated/organizationsettinghistory_update.go b/internal/ent/generated/organizationsettinghistory_update.go
index 2205caaf..3d085d49 100644
--- a/internal/ent/generated/organizationsettinghistory_update.go
+++ b/internal/ent/generated/organizationsettinghistory_update.go
@@ -12,18 +12,18 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organizationsettinghistory"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// OrganizationSettingHistoryUpdate is the builder for updating OrganizationSettingHistory entities.
type OrganizationSettingHistoryUpdate struct {
config
- hooks []Hook
- mutation *OrganizationSettingHistoryMutation
+ hooks []Hook
+ mutation *OrganizationSettingHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the OrganizationSettingHistoryUpdate builder.
@@ -337,6 +337,12 @@ func (oshu *OrganizationSettingHistoryUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (oshu *OrganizationSettingHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *OrganizationSettingHistoryUpdate {
+ oshu.modifiers = append(oshu.modifiers, modifiers...)
+ return oshu
+}
+
func (oshu *OrganizationSettingHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := oshu.check(); err != nil {
return n, err
@@ -448,6 +454,7 @@ func (oshu *OrganizationSettingHistoryUpdate) sqlSave(ctx context.Context) (n in
}
_spec.Node.Schema = oshu.schemaConfig.OrganizationSettingHistory
ctx = internal.NewSchemaConfigContext(ctx, oshu.schemaConfig)
+ _spec.AddModifiers(oshu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, oshu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{organizationsettinghistory.Label}
@@ -463,9 +470,10 @@ func (oshu *OrganizationSettingHistoryUpdate) sqlSave(ctx context.Context) (n in
// OrganizationSettingHistoryUpdateOne is the builder for updating a single OrganizationSettingHistory entity.
type OrganizationSettingHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *OrganizationSettingHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *OrganizationSettingHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -786,6 +794,12 @@ func (oshuo *OrganizationSettingHistoryUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (oshuo *OrganizationSettingHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *OrganizationSettingHistoryUpdateOne {
+ oshuo.modifiers = append(oshuo.modifiers, modifiers...)
+ return oshuo
+}
+
func (oshuo *OrganizationSettingHistoryUpdateOne) sqlSave(ctx context.Context) (_node *OrganizationSettingHistory, err error) {
if err := oshuo.check(); err != nil {
return _node, err
@@ -914,6 +928,7 @@ func (oshuo *OrganizationSettingHistoryUpdateOne) sqlSave(ctx context.Context) (
}
_spec.Node.Schema = oshuo.schemaConfig.OrganizationSettingHistory
ctx = internal.NewSchemaConfigContext(ctx, oshuo.schemaConfig)
+ _spec.AddModifiers(oshuo.modifiers...)
_node = &OrganizationSettingHistory{config: oshuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/orgmembership/where.go b/internal/ent/generated/orgmembership/where.go
index ed90a6de..9eb5c5c3 100644
--- a/internal/ent/generated/orgmembership/where.go
+++ b/internal/ent/generated/orgmembership/where.go
@@ -7,10 +7,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/orgmembership_delete.go b/internal/ent/generated/orgmembership_delete.go
index d4fd3044..37b3d34f 100644
--- a/internal/ent/generated/orgmembership_delete.go
+++ b/internal/ent/generated/orgmembership_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/orgmembership"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// OrgMembershipDelete is the builder for deleting a OrgMembership entity.
diff --git a/internal/ent/generated/orgmembership_query.go b/internal/ent/generated/orgmembership_query.go
index 7b68cfa4..90357840 100644
--- a/internal/ent/generated/orgmembership_query.go
+++ b/internal/ent/generated/orgmembership_query.go
@@ -14,12 +14,11 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/event"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/orgmembership"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/user"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// OrgMembershipQuery is the builder for querying OrgMembership entities.
@@ -32,8 +31,8 @@ type OrgMembershipQuery struct {
withOrganization *OrganizationQuery
withUser *UserQuery
withEvents *EventQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*OrgMembership) error
+ modifiers []func(*sql.Selector)
withNamedEvents map[string]*EventQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
@@ -342,8 +341,9 @@ func (omq *OrgMembershipQuery) Clone() *OrgMembershipQuery {
withUser: omq.withUser.Clone(),
withEvents: omq.withEvents.Clone(),
// clone intermediate query.
- sql: omq.sql.Clone(),
- path: omq.path,
+ sql: omq.sql.Clone(),
+ path: omq.path,
+ modifiers: append([]func(*sql.Selector){}, omq.modifiers...),
}
}
@@ -726,6 +726,9 @@ func (omq *OrgMembershipQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(omq.schemaConfig.OrgMembership)
ctx = internal.NewSchemaConfigContext(ctx, omq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range omq.modifiers {
+ m(selector)
+ }
for _, p := range omq.predicates {
p(selector)
}
@@ -743,6 +746,12 @@ func (omq *OrgMembershipQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (omq *OrgMembershipQuery) Modify(modifiers ...func(s *sql.Selector)) *OrgMembershipSelect {
+ omq.modifiers = append(omq.modifiers, modifiers...)
+ return omq.Select()
+}
+
// WithNamedEvents tells the query-builder to eager-load the nodes that are connected to the "events"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (omq *OrgMembershipQuery) WithNamedEvents(name string, opts ...func(*EventQuery)) *OrgMembershipQuery {
@@ -846,3 +855,9 @@ func (oms *OrgMembershipSelect) sqlScan(ctx context.Context, root *OrgMembership
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (oms *OrgMembershipSelect) Modify(modifiers ...func(s *sql.Selector)) *OrgMembershipSelect {
+ oms.modifiers = append(oms.modifiers, modifiers...)
+ return oms
+}
diff --git a/internal/ent/generated/orgmembership_update.go b/internal/ent/generated/orgmembership_update.go
index 07b91c24..bcf350c2 100644
--- a/internal/ent/generated/orgmembership_update.go
+++ b/internal/ent/generated/orgmembership_update.go
@@ -12,18 +12,18 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/event"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/orgmembership"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// OrgMembershipUpdate is the builder for updating OrgMembership entities.
type OrgMembershipUpdate struct {
config
- hooks []Hook
- mutation *OrgMembershipMutation
+ hooks []Hook
+ mutation *OrgMembershipMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the OrgMembershipUpdate builder.
@@ -217,6 +217,12 @@ func (omu *OrgMembershipUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (omu *OrgMembershipUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *OrgMembershipUpdate {
+ omu.modifiers = append(omu.modifiers, modifiers...)
+ return omu
+}
+
func (omu *OrgMembershipUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := omu.check(); err != nil {
return n, err
@@ -312,6 +318,7 @@ func (omu *OrgMembershipUpdate) sqlSave(ctx context.Context) (n int, err error)
}
_spec.Node.Schema = omu.schemaConfig.OrgMembership
ctx = internal.NewSchemaConfigContext(ctx, omu.schemaConfig)
+ _spec.AddModifiers(omu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, omu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{orgmembership.Label}
@@ -327,9 +334,10 @@ func (omu *OrgMembershipUpdate) sqlSave(ctx context.Context) (n int, err error)
// OrgMembershipUpdateOne is the builder for updating a single OrgMembership entity.
type OrgMembershipUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *OrgMembershipMutation
+ fields []string
+ hooks []Hook
+ mutation *OrgMembershipMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -530,6 +538,12 @@ func (omuo *OrgMembershipUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (omuo *OrgMembershipUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *OrgMembershipUpdateOne {
+ omuo.modifiers = append(omuo.modifiers, modifiers...)
+ return omuo
+}
+
func (omuo *OrgMembershipUpdateOne) sqlSave(ctx context.Context) (_node *OrgMembership, err error) {
if err := omuo.check(); err != nil {
return _node, err
@@ -642,6 +656,7 @@ func (omuo *OrgMembershipUpdateOne) sqlSave(ctx context.Context) (_node *OrgMemb
}
_spec.Node.Schema = omuo.schemaConfig.OrgMembership
ctx = internal.NewSchemaConfigContext(ctx, omuo.schemaConfig)
+ _spec.AddModifiers(omuo.modifiers...)
_node = &OrgMembership{config: omuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/orgmembershiphistory_delete.go b/internal/ent/generated/orgmembershiphistory_delete.go
index a058c0a2..30fff537 100644
--- a/internal/ent/generated/orgmembershiphistory_delete.go
+++ b/internal/ent/generated/orgmembershiphistory_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/orgmembershiphistory"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// OrgMembershipHistoryDelete is the builder for deleting a OrgMembershipHistory entity.
diff --git a/internal/ent/generated/orgmembershiphistory_query.go b/internal/ent/generated/orgmembershiphistory_query.go
index c3de6520..88bed41a 100644
--- a/internal/ent/generated/orgmembershiphistory_query.go
+++ b/internal/ent/generated/orgmembershiphistory_query.go
@@ -12,10 +12,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/orgmembershiphistory"
"github.com/theopenlane/core/internal/ent/generated/predicate"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// OrgMembershipHistoryQuery is the builder for querying OrgMembershipHistory entities.
@@ -25,8 +24,8 @@ type OrgMembershipHistoryQuery struct {
order []orgmembershiphistory.OrderOption
inters []Interceptor
predicates []predicate.OrgMembershipHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*OrgMembershipHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -256,8 +255,9 @@ func (omhq *OrgMembershipHistoryQuery) Clone() *OrgMembershipHistoryQuery {
inters: append([]Interceptor{}, omhq.inters...),
predicates: append([]predicate.OrgMembershipHistory{}, omhq.predicates...),
// clone intermediate query.
- sql: omhq.sql.Clone(),
- path: omhq.path,
+ sql: omhq.sql.Clone(),
+ path: omhq.path,
+ modifiers: append([]func(*sql.Selector){}, omhq.modifiers...),
}
}
@@ -448,6 +448,9 @@ func (omhq *OrgMembershipHistoryQuery) sqlQuery(ctx context.Context) *sql.Select
t1.Schema(omhq.schemaConfig.OrgMembershipHistory)
ctx = internal.NewSchemaConfigContext(ctx, omhq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range omhq.modifiers {
+ m(selector)
+ }
for _, p := range omhq.predicates {
p(selector)
}
@@ -465,6 +468,12 @@ func (omhq *OrgMembershipHistoryQuery) sqlQuery(ctx context.Context) *sql.Select
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (omhq *OrgMembershipHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *OrgMembershipHistorySelect {
+ omhq.modifiers = append(omhq.modifiers, modifiers...)
+ return omhq.Select()
+}
+
// OrgMembershipHistoryGroupBy is the group-by builder for OrgMembershipHistory entities.
type OrgMembershipHistoryGroupBy struct {
selector
@@ -554,3 +563,9 @@ func (omhs *OrgMembershipHistorySelect) sqlScan(ctx context.Context, root *OrgMe
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (omhs *OrgMembershipHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *OrgMembershipHistorySelect {
+ omhs.modifiers = append(omhs.modifiers, modifiers...)
+ return omhs
+}
diff --git a/internal/ent/generated/orgmembershiphistory_update.go b/internal/ent/generated/orgmembershiphistory_update.go
index ebca180f..253e4389 100644
--- a/internal/ent/generated/orgmembershiphistory_update.go
+++ b/internal/ent/generated/orgmembershiphistory_update.go
@@ -11,18 +11,18 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/orgmembershiphistory"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// OrgMembershipHistoryUpdate is the builder for updating OrgMembershipHistory entities.
type OrgMembershipHistoryUpdate struct {
config
- hooks []Hook
- mutation *OrgMembershipHistoryMutation
+ hooks []Hook
+ mutation *OrgMembershipHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the OrgMembershipHistoryUpdate builder.
@@ -174,6 +174,12 @@ func (omhu *OrgMembershipHistoryUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (omhu *OrgMembershipHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *OrgMembershipHistoryUpdate {
+ omhu.modifiers = append(omhu.modifiers, modifiers...)
+ return omhu
+}
+
func (omhu *OrgMembershipHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := omhu.check(); err != nil {
return n, err
@@ -224,6 +230,7 @@ func (omhu *OrgMembershipHistoryUpdate) sqlSave(ctx context.Context) (n int, err
}
_spec.Node.Schema = omhu.schemaConfig.OrgMembershipHistory
ctx = internal.NewSchemaConfigContext(ctx, omhu.schemaConfig)
+ _spec.AddModifiers(omhu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, omhu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{orgmembershiphistory.Label}
@@ -239,9 +246,10 @@ func (omhu *OrgMembershipHistoryUpdate) sqlSave(ctx context.Context) (n int, err
// OrgMembershipHistoryUpdateOne is the builder for updating a single OrgMembershipHistory entity.
type OrgMembershipHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *OrgMembershipHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *OrgMembershipHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -400,6 +408,12 @@ func (omhuo *OrgMembershipHistoryUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (omhuo *OrgMembershipHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *OrgMembershipHistoryUpdateOne {
+ omhuo.modifiers = append(omhuo.modifiers, modifiers...)
+ return omhuo
+}
+
func (omhuo *OrgMembershipHistoryUpdateOne) sqlSave(ctx context.Context) (_node *OrgMembershipHistory, err error) {
if err := omhuo.check(); err != nil {
return _node, err
@@ -467,6 +481,7 @@ func (omhuo *OrgMembershipHistoryUpdateOne) sqlSave(ctx context.Context) (_node
}
_spec.Node.Schema = omhuo.schemaConfig.OrgMembershipHistory
ctx = internal.NewSchemaConfigContext(ctx, omhuo.schemaConfig)
+ _spec.AddModifiers(omhuo.modifiers...)
_node = &OrgMembershipHistory{config: omhuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/passwordresettoken/where.go b/internal/ent/generated/passwordresettoken/where.go
index f443ff6a..4e2257bf 100644
--- a/internal/ent/generated/passwordresettoken/where.go
+++ b/internal/ent/generated/passwordresettoken/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/passwordresettoken_delete.go b/internal/ent/generated/passwordresettoken_delete.go
index 5873b491..77bc9fa9 100644
--- a/internal/ent/generated/passwordresettoken_delete.go
+++ b/internal/ent/generated/passwordresettoken_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/passwordresettoken"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// PasswordResetTokenDelete is the builder for deleting a PasswordResetToken entity.
diff --git a/internal/ent/generated/passwordresettoken_query.go b/internal/ent/generated/passwordresettoken_query.go
index 76224304..60606b4c 100644
--- a/internal/ent/generated/passwordresettoken_query.go
+++ b/internal/ent/generated/passwordresettoken_query.go
@@ -12,11 +12,10 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/passwordresettoken"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/user"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// PasswordResetTokenQuery is the builder for querying PasswordResetToken entities.
@@ -27,8 +26,8 @@ type PasswordResetTokenQuery struct {
inters []Interceptor
predicates []predicate.PasswordResetToken
withOwner *UserQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*PasswordResetToken) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -284,8 +283,9 @@ func (prtq *PasswordResetTokenQuery) Clone() *PasswordResetTokenQuery {
predicates: append([]predicate.PasswordResetToken{}, prtq.predicates...),
withOwner: prtq.withOwner.Clone(),
// clone intermediate query.
- sql: prtq.sql.Clone(),
- path: prtq.path,
+ sql: prtq.sql.Clone(),
+ path: prtq.path,
+ modifiers: append([]func(*sql.Selector){}, prtq.modifiers...),
}
}
@@ -530,6 +530,9 @@ func (prtq *PasswordResetTokenQuery) sqlQuery(ctx context.Context) *sql.Selector
t1.Schema(prtq.schemaConfig.PasswordResetToken)
ctx = internal.NewSchemaConfigContext(ctx, prtq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range prtq.modifiers {
+ m(selector)
+ }
for _, p := range prtq.predicates {
p(selector)
}
@@ -547,6 +550,12 @@ func (prtq *PasswordResetTokenQuery) sqlQuery(ctx context.Context) *sql.Selector
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (prtq *PasswordResetTokenQuery) Modify(modifiers ...func(s *sql.Selector)) *PasswordResetTokenSelect {
+ prtq.modifiers = append(prtq.modifiers, modifiers...)
+ return prtq.Select()
+}
+
// PasswordResetTokenGroupBy is the group-by builder for PasswordResetToken entities.
type PasswordResetTokenGroupBy struct {
selector
@@ -636,3 +645,9 @@ func (prts *PasswordResetTokenSelect) sqlScan(ctx context.Context, root *Passwor
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (prts *PasswordResetTokenSelect) Modify(modifiers ...func(s *sql.Selector)) *PasswordResetTokenSelect {
+ prts.modifiers = append(prts.modifiers, modifiers...)
+ return prts
+}
diff --git a/internal/ent/generated/passwordresettoken_update.go b/internal/ent/generated/passwordresettoken_update.go
index d6afcdf0..18d742d7 100644
--- a/internal/ent/generated/passwordresettoken_update.go
+++ b/internal/ent/generated/passwordresettoken_update.go
@@ -11,18 +11,18 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/passwordresettoken"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/user"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// PasswordResetTokenUpdate is the builder for updating PasswordResetToken entities.
type PasswordResetTokenUpdate struct {
config
- hooks []Hook
- mutation *PasswordResetTokenMutation
+ hooks []Hook
+ mutation *PasswordResetTokenMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the PasswordResetTokenUpdate builder.
@@ -246,6 +246,12 @@ func (prtu *PasswordResetTokenUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (prtu *PasswordResetTokenUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PasswordResetTokenUpdate {
+ prtu.modifiers = append(prtu.modifiers, modifiers...)
+ return prtu
+}
+
func (prtu *PasswordResetTokenUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := prtu.check(); err != nil {
return n, err
@@ -333,6 +339,7 @@ func (prtu *PasswordResetTokenUpdate) sqlSave(ctx context.Context) (n int, err e
}
_spec.Node.Schema = prtu.schemaConfig.PasswordResetToken
ctx = internal.NewSchemaConfigContext(ctx, prtu.schemaConfig)
+ _spec.AddModifiers(prtu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, prtu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{passwordresettoken.Label}
@@ -348,9 +355,10 @@ func (prtu *PasswordResetTokenUpdate) sqlSave(ctx context.Context) (n int, err e
// PasswordResetTokenUpdateOne is the builder for updating a single PasswordResetToken entity.
type PasswordResetTokenUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *PasswordResetTokenMutation
+ fields []string
+ hooks []Hook
+ mutation *PasswordResetTokenMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -581,6 +589,12 @@ func (prtuo *PasswordResetTokenUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (prtuo *PasswordResetTokenUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PasswordResetTokenUpdateOne {
+ prtuo.modifiers = append(prtuo.modifiers, modifiers...)
+ return prtuo
+}
+
func (prtuo *PasswordResetTokenUpdateOne) sqlSave(ctx context.Context) (_node *PasswordResetToken, err error) {
if err := prtuo.check(); err != nil {
return _node, err
@@ -685,6 +699,7 @@ func (prtuo *PasswordResetTokenUpdateOne) sqlSave(ctx context.Context) (_node *P
}
_spec.Node.Schema = prtuo.schemaConfig.PasswordResetToken
ctx = internal.NewSchemaConfigContext(ctx, prtuo.schemaConfig)
+ _spec.AddModifiers(prtuo.modifiers...)
_node = &PasswordResetToken{config: prtuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/personalaccesstoken/where.go b/internal/ent/generated/personalaccesstoken/where.go
index 9baa0e63..c5c4f2df 100644
--- a/internal/ent/generated/personalaccesstoken/where.go
+++ b/internal/ent/generated/personalaccesstoken/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/personalaccesstoken_delete.go b/internal/ent/generated/personalaccesstoken_delete.go
index 67aa96c2..553edc59 100644
--- a/internal/ent/generated/personalaccesstoken_delete.go
+++ b/internal/ent/generated/personalaccesstoken_delete.go
@@ -8,10 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/personalaccesstoken"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// PersonalAccessTokenDelete is the builder for deleting a PersonalAccessToken entity.
diff --git a/internal/ent/generated/personalaccesstoken_query.go b/internal/ent/generated/personalaccesstoken_query.go
index 4cddeb74..0e9c1291 100644
--- a/internal/ent/generated/personalaccesstoken_query.go
+++ b/internal/ent/generated/personalaccesstoken_query.go
@@ -14,12 +14,11 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/event"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/personalaccesstoken"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/user"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// PersonalAccessTokenQuery is the builder for querying PersonalAccessToken entities.
@@ -32,8 +31,8 @@ type PersonalAccessTokenQuery struct {
withOwner *UserQuery
withOrganizations *OrganizationQuery
withEvents *EventQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*PersonalAccessToken) error
+ modifiers []func(*sql.Selector)
withNamedOrganizations map[string]*OrganizationQuery
withNamedEvents map[string]*EventQuery
// intermediate query (i.e. traversal path).
@@ -343,8 +342,9 @@ func (patq *PersonalAccessTokenQuery) Clone() *PersonalAccessTokenQuery {
withOrganizations: patq.withOrganizations.Clone(),
withEvents: patq.withEvents.Clone(),
// clone intermediate query.
- sql: patq.sql.Clone(),
- path: patq.path,
+ sql: patq.sql.Clone(),
+ path: patq.path,
+ modifiers: append([]func(*sql.Selector){}, patq.modifiers...),
}
}
@@ -767,6 +767,9 @@ func (patq *PersonalAccessTokenQuery) sqlQuery(ctx context.Context) *sql.Selecto
t1.Schema(patq.schemaConfig.PersonalAccessToken)
ctx = internal.NewSchemaConfigContext(ctx, patq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range patq.modifiers {
+ m(selector)
+ }
for _, p := range patq.predicates {
p(selector)
}
@@ -784,6 +787,12 @@ func (patq *PersonalAccessTokenQuery) sqlQuery(ctx context.Context) *sql.Selecto
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (patq *PersonalAccessTokenQuery) Modify(modifiers ...func(s *sql.Selector)) *PersonalAccessTokenSelect {
+ patq.modifiers = append(patq.modifiers, modifiers...)
+ return patq.Select()
+}
+
// WithNamedOrganizations tells the query-builder to eager-load the nodes that are connected to the "organizations"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (patq *PersonalAccessTokenQuery) WithNamedOrganizations(name string, opts ...func(*OrganizationQuery)) *PersonalAccessTokenQuery {
@@ -901,3 +910,9 @@ func (pats *PersonalAccessTokenSelect) sqlScan(ctx context.Context, root *Person
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (pats *PersonalAccessTokenSelect) Modify(modifiers ...func(s *sql.Selector)) *PersonalAccessTokenSelect {
+ pats.modifiers = append(pats.modifiers, modifiers...)
+ return pats
+}
diff --git a/internal/ent/generated/personalaccesstoken_update.go b/internal/ent/generated/personalaccesstoken_update.go
index eb1c7410..9b54debd 100644
--- a/internal/ent/generated/personalaccesstoken_update.go
+++ b/internal/ent/generated/personalaccesstoken_update.go
@@ -13,19 +13,19 @@ import (
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/event"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/personalaccesstoken"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/user"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// PersonalAccessTokenUpdate is the builder for updating PersonalAccessToken entities.
type PersonalAccessTokenUpdate struct {
config
- hooks []Hook
- mutation *PersonalAccessTokenMutation
+ hooks []Hook
+ mutation *PersonalAccessTokenMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the PersonalAccessTokenUpdate builder.
@@ -373,6 +373,12 @@ func (patu *PersonalAccessTokenUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (patu *PersonalAccessTokenUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PersonalAccessTokenUpdate {
+ patu.modifiers = append(patu.modifiers, modifiers...)
+ return patu
+}
+
func (patu *PersonalAccessTokenUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := patu.check(); err != nil {
return n, err
@@ -587,6 +593,7 @@ func (patu *PersonalAccessTokenUpdate) sqlSave(ctx context.Context) (n int, err
}
_spec.Node.Schema = patu.schemaConfig.PersonalAccessToken
ctx = internal.NewSchemaConfigContext(ctx, patu.schemaConfig)
+ _spec.AddModifiers(patu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, patu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{personalaccesstoken.Label}
@@ -602,9 +609,10 @@ func (patu *PersonalAccessTokenUpdate) sqlSave(ctx context.Context) (n int, err
// PersonalAccessTokenUpdateOne is the builder for updating a single PersonalAccessToken entity.
type PersonalAccessTokenUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *PersonalAccessTokenMutation
+ fields []string
+ hooks []Hook
+ mutation *PersonalAccessTokenMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -959,6 +967,12 @@ func (patuo *PersonalAccessTokenUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (patuo *PersonalAccessTokenUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PersonalAccessTokenUpdateOne {
+ patuo.modifiers = append(patuo.modifiers, modifiers...)
+ return patuo
+}
+
func (patuo *PersonalAccessTokenUpdateOne) sqlSave(ctx context.Context) (_node *PersonalAccessToken, err error) {
if err := patuo.check(); err != nil {
return _node, err
@@ -1190,6 +1204,7 @@ func (patuo *PersonalAccessTokenUpdateOne) sqlSave(ctx context.Context) (_node *
}
_spec.Node.Schema = patuo.schemaConfig.PersonalAccessToken
ctx = internal.NewSchemaConfigContext(ctx, patuo.schemaConfig)
+ _spec.AddModifiers(patuo.modifiers...)
_node = &PersonalAccessToken{config: patuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/subscriber/where.go b/internal/ent/generated/subscriber/where.go
index 252afd78..23ed6971 100644
--- a/internal/ent/generated/subscriber/where.go
+++ b/internal/ent/generated/subscriber/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/subscriber_delete.go b/internal/ent/generated/subscriber_delete.go
index 789a43a5..c3e0d0a9 100644
--- a/internal/ent/generated/subscriber_delete.go
+++ b/internal/ent/generated/subscriber_delete.go
@@ -8,9 +8,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/subscriber"
)
diff --git a/internal/ent/generated/subscriber_query.go b/internal/ent/generated/subscriber_query.go
index 6c153dcf..2be99c03 100644
--- a/internal/ent/generated/subscriber_query.go
+++ b/internal/ent/generated/subscriber_query.go
@@ -14,11 +14,10 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/event"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/subscriber"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// SubscriberQuery is the builder for querying Subscriber entities.
@@ -30,8 +29,8 @@ type SubscriberQuery struct {
predicates []predicate.Subscriber
withOwner *OrganizationQuery
withEvents *EventQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*Subscriber) error
+ modifiers []func(*sql.Selector)
withNamedEvents map[string]*EventQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
@@ -314,8 +313,9 @@ func (sq *SubscriberQuery) Clone() *SubscriberQuery {
withOwner: sq.withOwner.Clone(),
withEvents: sq.withEvents.Clone(),
// clone intermediate query.
- sql: sq.sql.Clone(),
- path: sq.path,
+ sql: sq.sql.Clone(),
+ path: sq.path,
+ modifiers: append([]func(*sql.Selector){}, sq.modifiers...),
}
}
@@ -648,6 +648,9 @@ func (sq *SubscriberQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(sq.schemaConfig.Subscriber)
ctx = internal.NewSchemaConfigContext(ctx, sq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range sq.modifiers {
+ m(selector)
+ }
for _, p := range sq.predicates {
p(selector)
}
@@ -665,6 +668,12 @@ func (sq *SubscriberQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (sq *SubscriberQuery) Modify(modifiers ...func(s *sql.Selector)) *SubscriberSelect {
+ sq.modifiers = append(sq.modifiers, modifiers...)
+ return sq.Select()
+}
+
// WithNamedEvents tells the query-builder to eager-load the nodes that are connected to the "events"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (sq *SubscriberQuery) WithNamedEvents(name string, opts ...func(*EventQuery)) *SubscriberQuery {
@@ -768,3 +777,9 @@ func (ss *SubscriberSelect) sqlScan(ctx context.Context, root *SubscriberQuery,
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ss *SubscriberSelect) Modify(modifiers ...func(s *sql.Selector)) *SubscriberSelect {
+ ss.modifiers = append(ss.modifiers, modifiers...)
+ return ss
+}
diff --git a/internal/ent/generated/subscriber_update.go b/internal/ent/generated/subscriber_update.go
index 94545785..31c0a181 100644
--- a/internal/ent/generated/subscriber_update.go
+++ b/internal/ent/generated/subscriber_update.go
@@ -13,18 +13,18 @@ import (
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/event"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/subscriber"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// SubscriberUpdate is the builder for updating Subscriber entities.
type SubscriberUpdate struct {
config
- hooks []Hook
- mutation *SubscriberMutation
+ hooks []Hook
+ mutation *SubscriberMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the SubscriberUpdate builder.
@@ -377,6 +377,12 @@ func (su *SubscriberUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (su *SubscriberUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SubscriberUpdate {
+ su.modifiers = append(su.modifiers, modifiers...)
+ return su
+}
+
func (su *SubscriberUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := su.check(); err != nil {
return n, err
@@ -538,6 +544,7 @@ func (su *SubscriberUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = su.schemaConfig.Subscriber
ctx = internal.NewSchemaConfigContext(ctx, su.schemaConfig)
+ _spec.AddModifiers(su.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{subscriber.Label}
@@ -553,9 +560,10 @@ func (su *SubscriberUpdate) sqlSave(ctx context.Context) (n int, err error) {
// SubscriberUpdateOne is the builder for updating a single Subscriber entity.
type SubscriberUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *SubscriberMutation
+ fields []string
+ hooks []Hook
+ mutation *SubscriberMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -915,6 +923,12 @@ func (suo *SubscriberUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (suo *SubscriberUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SubscriberUpdateOne {
+ suo.modifiers = append(suo.modifiers, modifiers...)
+ return suo
+}
+
func (suo *SubscriberUpdateOne) sqlSave(ctx context.Context) (_node *Subscriber, err error) {
if err := suo.check(); err != nil {
return _node, err
@@ -1093,6 +1107,7 @@ func (suo *SubscriberUpdateOne) sqlSave(ctx context.Context) (_node *Subscriber,
}
_spec.Node.Schema = suo.schemaConfig.Subscriber
ctx = internal.NewSchemaConfigContext(ctx, suo.schemaConfig)
+ _spec.AddModifiers(suo.modifiers...)
_node = &Subscriber{config: suo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/template/where.go b/internal/ent/generated/template/where.go
index 0be975c4..b02211c0 100644
--- a/internal/ent/generated/template/where.go
+++ b/internal/ent/generated/template/where.go
@@ -7,10 +7,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/template_delete.go b/internal/ent/generated/template_delete.go
index a74406f8..031adf08 100644
--- a/internal/ent/generated/template_delete.go
+++ b/internal/ent/generated/template_delete.go
@@ -8,9 +8,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/template"
)
diff --git a/internal/ent/generated/template_query.go b/internal/ent/generated/template_query.go
index 7c96f1fb..c8e264b3 100644
--- a/internal/ent/generated/template_query.go
+++ b/internal/ent/generated/template_query.go
@@ -14,11 +14,10 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/documentdata"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/template"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// TemplateQuery is the builder for querying Template entities.
@@ -30,8 +29,8 @@ type TemplateQuery struct {
predicates []predicate.Template
withOwner *OrganizationQuery
withDocuments *DocumentDataQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*Template) error
+ modifiers []func(*sql.Selector)
withNamedDocuments map[string]*DocumentDataQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
@@ -314,8 +313,9 @@ func (tq *TemplateQuery) Clone() *TemplateQuery {
withOwner: tq.withOwner.Clone(),
withDocuments: tq.withDocuments.Clone(),
// clone intermediate query.
- sql: tq.sql.Clone(),
- path: tq.path,
+ sql: tq.sql.Clone(),
+ path: tq.path,
+ modifiers: append([]func(*sql.Selector){}, tq.modifiers...),
}
}
@@ -616,6 +616,9 @@ func (tq *TemplateQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(tq.schemaConfig.Template)
ctx = internal.NewSchemaConfigContext(ctx, tq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range tq.modifiers {
+ m(selector)
+ }
for _, p := range tq.predicates {
p(selector)
}
@@ -633,6 +636,12 @@ func (tq *TemplateQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (tq *TemplateQuery) Modify(modifiers ...func(s *sql.Selector)) *TemplateSelect {
+ tq.modifiers = append(tq.modifiers, modifiers...)
+ return tq.Select()
+}
+
// WithNamedDocuments tells the query-builder to eager-load the nodes that are connected to the "documents"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (tq *TemplateQuery) WithNamedDocuments(name string, opts ...func(*DocumentDataQuery)) *TemplateQuery {
@@ -736,3 +745,9 @@ func (ts *TemplateSelect) sqlScan(ctx context.Context, root *TemplateQuery, v an
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ts *TemplateSelect) Modify(modifiers ...func(s *sql.Selector)) *TemplateSelect {
+ ts.modifiers = append(ts.modifiers, modifiers...)
+ return ts
+}
diff --git a/internal/ent/generated/template_update.go b/internal/ent/generated/template_update.go
index 0d4a98fc..3eb6e6c3 100644
--- a/internal/ent/generated/template_update.go
+++ b/internal/ent/generated/template_update.go
@@ -14,19 +14,19 @@ import (
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/customtypes"
"github.com/theopenlane/core/internal/ent/generated/documentdata"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/template"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// TemplateUpdate is the builder for updating Template entities.
type TemplateUpdate struct {
config
- hooks []Hook
- mutation *TemplateMutation
+ hooks []Hook
+ mutation *TemplateMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the TemplateUpdate builder.
@@ -325,6 +325,12 @@ func (tu *TemplateUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (tu *TemplateUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *TemplateUpdate {
+ tu.modifiers = append(tu.modifiers, modifiers...)
+ return tu
+}
+
func (tu *TemplateUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := tu.check(); err != nil {
return n, err
@@ -480,6 +486,7 @@ func (tu *TemplateUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = tu.schemaConfig.Template
ctx = internal.NewSchemaConfigContext(ctx, tu.schemaConfig)
+ _spec.AddModifiers(tu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, tu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{template.Label}
@@ -495,9 +502,10 @@ func (tu *TemplateUpdate) sqlSave(ctx context.Context) (n int, err error) {
// TemplateUpdateOne is the builder for updating a single Template entity.
type TemplateUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *TemplateMutation
+ fields []string
+ hooks []Hook
+ mutation *TemplateMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -803,6 +811,12 @@ func (tuo *TemplateUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (tuo *TemplateUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *TemplateUpdateOne {
+ tuo.modifiers = append(tuo.modifiers, modifiers...)
+ return tuo
+}
+
func (tuo *TemplateUpdateOne) sqlSave(ctx context.Context) (_node *Template, err error) {
if err := tuo.check(); err != nil {
return _node, err
@@ -975,6 +989,7 @@ func (tuo *TemplateUpdateOne) sqlSave(ctx context.Context) (_node *Template, err
}
_spec.Node.Schema = tuo.schemaConfig.Template
ctx = internal.NewSchemaConfigContext(ctx, tuo.schemaConfig)
+ _spec.AddModifiers(tuo.modifiers...)
_node = &Template{config: tuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/templatehistory_delete.go b/internal/ent/generated/templatehistory_delete.go
index 508586c3..bf3f117c 100644
--- a/internal/ent/generated/templatehistory_delete.go
+++ b/internal/ent/generated/templatehistory_delete.go
@@ -8,9 +8,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/templatehistory"
)
diff --git a/internal/ent/generated/templatehistory_query.go b/internal/ent/generated/templatehistory_query.go
index a09687e5..7e791793 100644
--- a/internal/ent/generated/templatehistory_query.go
+++ b/internal/ent/generated/templatehistory_query.go
@@ -12,10 +12,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/templatehistory"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// TemplateHistoryQuery is the builder for querying TemplateHistory entities.
@@ -25,8 +24,8 @@ type TemplateHistoryQuery struct {
order []templatehistory.OrderOption
inters []Interceptor
predicates []predicate.TemplateHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*TemplateHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -256,8 +255,9 @@ func (thq *TemplateHistoryQuery) Clone() *TemplateHistoryQuery {
inters: append([]Interceptor{}, thq.inters...),
predicates: append([]predicate.TemplateHistory{}, thq.predicates...),
// clone intermediate query.
- sql: thq.sql.Clone(),
- path: thq.path,
+ sql: thq.sql.Clone(),
+ path: thq.path,
+ modifiers: append([]func(*sql.Selector){}, thq.modifiers...),
}
}
@@ -448,6 +448,9 @@ func (thq *TemplateHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(thq.schemaConfig.TemplateHistory)
ctx = internal.NewSchemaConfigContext(ctx, thq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range thq.modifiers {
+ m(selector)
+ }
for _, p := range thq.predicates {
p(selector)
}
@@ -465,6 +468,12 @@ func (thq *TemplateHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (thq *TemplateHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *TemplateHistorySelect {
+ thq.modifiers = append(thq.modifiers, modifiers...)
+ return thq.Select()
+}
+
// TemplateHistoryGroupBy is the group-by builder for TemplateHistory entities.
type TemplateHistoryGroupBy struct {
selector
@@ -554,3 +563,9 @@ func (ths *TemplateHistorySelect) sqlScan(ctx context.Context, root *TemplateHis
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ths *TemplateHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *TemplateHistorySelect {
+ ths.modifiers = append(ths.modifiers, modifiers...)
+ return ths
+}
diff --git a/internal/ent/generated/templatehistory_update.go b/internal/ent/generated/templatehistory_update.go
index 57e4b5f1..85c01960 100644
--- a/internal/ent/generated/templatehistory_update.go
+++ b/internal/ent/generated/templatehistory_update.go
@@ -13,18 +13,18 @@ import (
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/customtypes"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/templatehistory"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// TemplateHistoryUpdate is the builder for updating TemplateHistory entities.
type TemplateHistoryUpdate struct {
config
- hooks []Hook
- mutation *TemplateHistoryMutation
+ hooks []Hook
+ mutation *TemplateHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the TemplateHistoryUpdate builder.
@@ -266,6 +266,12 @@ func (thu *TemplateHistoryUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (thu *TemplateHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *TemplateHistoryUpdate {
+ thu.modifiers = append(thu.modifiers, modifiers...)
+ return thu
+}
+
func (thu *TemplateHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := thu.check(); err != nil {
return n, err
@@ -351,6 +357,7 @@ func (thu *TemplateHistoryUpdate) sqlSave(ctx context.Context) (n int, err error
}
_spec.Node.Schema = thu.schemaConfig.TemplateHistory
ctx = internal.NewSchemaConfigContext(ctx, thu.schemaConfig)
+ _spec.AddModifiers(thu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, thu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{templatehistory.Label}
@@ -366,9 +373,10 @@ func (thu *TemplateHistoryUpdate) sqlSave(ctx context.Context) (n int, err error
// TemplateHistoryUpdateOne is the builder for updating a single TemplateHistory entity.
type TemplateHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *TemplateHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *TemplateHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -617,6 +625,12 @@ func (thuo *TemplateHistoryUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (thuo *TemplateHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *TemplateHistoryUpdateOne {
+ thuo.modifiers = append(thuo.modifiers, modifiers...)
+ return thuo
+}
+
func (thuo *TemplateHistoryUpdateOne) sqlSave(ctx context.Context) (_node *TemplateHistory, err error) {
if err := thuo.check(); err != nil {
return _node, err
@@ -719,6 +733,7 @@ func (thuo *TemplateHistoryUpdateOne) sqlSave(ctx context.Context) (_node *Templ
}
_spec.Node.Schema = thuo.schemaConfig.TemplateHistory
ctx = internal.NewSchemaConfigContext(ctx, thuo.schemaConfig)
+ _spec.AddModifiers(thuo.modifiers...)
_node = &TemplateHistory{config: thuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/tfasetting/where.go b/internal/ent/generated/tfasetting/where.go
index 9ba527ec..2da2fdd6 100644
--- a/internal/ent/generated/tfasetting/where.go
+++ b/internal/ent/generated/tfasetting/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/tfasetting_delete.go b/internal/ent/generated/tfasetting_delete.go
index 07677330..2e11e785 100644
--- a/internal/ent/generated/tfasetting_delete.go
+++ b/internal/ent/generated/tfasetting_delete.go
@@ -8,9 +8,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/tfasetting"
)
diff --git a/internal/ent/generated/tfasetting_query.go b/internal/ent/generated/tfasetting_query.go
index c61206e9..0d730b19 100644
--- a/internal/ent/generated/tfasetting_query.go
+++ b/internal/ent/generated/tfasetting_query.go
@@ -11,11 +11,10 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/tfasetting"
"github.com/theopenlane/core/internal/ent/generated/user"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// TFASettingQuery is the builder for querying TFASetting entities.
@@ -26,8 +25,8 @@ type TFASettingQuery struct {
inters []Interceptor
predicates []predicate.TFASetting
withOwner *UserQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*TFASetting) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -283,8 +282,9 @@ func (tsq *TFASettingQuery) Clone() *TFASettingQuery {
predicates: append([]predicate.TFASetting{}, tsq.predicates...),
withOwner: tsq.withOwner.Clone(),
// clone intermediate query.
- sql: tsq.sql.Clone(),
- path: tsq.path,
+ sql: tsq.sql.Clone(),
+ path: tsq.path,
+ modifiers: append([]func(*sql.Selector){}, tsq.modifiers...),
}
}
@@ -523,6 +523,9 @@ func (tsq *TFASettingQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(tsq.schemaConfig.TFASetting)
ctx = internal.NewSchemaConfigContext(ctx, tsq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range tsq.modifiers {
+ m(selector)
+ }
for _, p := range tsq.predicates {
p(selector)
}
@@ -540,6 +543,12 @@ func (tsq *TFASettingQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (tsq *TFASettingQuery) Modify(modifiers ...func(s *sql.Selector)) *TFASettingSelect {
+ tsq.modifiers = append(tsq.modifiers, modifiers...)
+ return tsq.Select()
+}
+
// TFASettingGroupBy is the group-by builder for TFASetting entities.
type TFASettingGroupBy struct {
selector
@@ -629,3 +638,9 @@ func (tss *TFASettingSelect) sqlScan(ctx context.Context, root *TFASettingQuery,
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (tss *TFASettingSelect) Modify(modifiers ...func(s *sql.Selector)) *TFASettingSelect {
+ tss.modifiers = append(tss.modifiers, modifiers...)
+ return tss
+}
diff --git a/internal/ent/generated/tfasetting_update.go b/internal/ent/generated/tfasetting_update.go
index 6e3c475e..eb0a4c17 100644
--- a/internal/ent/generated/tfasetting_update.go
+++ b/internal/ent/generated/tfasetting_update.go
@@ -12,18 +12,18 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/tfasetting"
"github.com/theopenlane/core/internal/ent/generated/user"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// TFASettingUpdate is the builder for updating TFASetting entities.
type TFASettingUpdate struct {
config
- hooks []Hook
- mutation *TFASettingMutation
+ hooks []Hook
+ mutation *TFASettingMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the TFASettingUpdate builder.
@@ -312,6 +312,12 @@ func (tsu *TFASettingUpdate) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (tsu *TFASettingUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *TFASettingUpdate {
+ tsu.modifiers = append(tsu.modifiers, modifiers...)
+ return tsu
+}
+
func (tsu *TFASettingUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(tfasetting.Table, tfasetting.Columns, sqlgraph.NewFieldSpec(tfasetting.FieldID, field.TypeString))
if ps := tsu.mutation.predicates; len(ps) > 0 {
@@ -433,6 +439,7 @@ func (tsu *TFASettingUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = tsu.schemaConfig.TFASetting
ctx = internal.NewSchemaConfigContext(ctx, tsu.schemaConfig)
+ _spec.AddModifiers(tsu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, tsu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{tfasetting.Label}
@@ -448,9 +455,10 @@ func (tsu *TFASettingUpdate) sqlSave(ctx context.Context) (n int, err error) {
// TFASettingUpdateOne is the builder for updating a single TFASetting entity.
type TFASettingUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *TFASettingMutation
+ fields []string
+ hooks []Hook
+ mutation *TFASettingMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -746,6 +754,12 @@ func (tsuo *TFASettingUpdateOne) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (tsuo *TFASettingUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *TFASettingUpdateOne {
+ tsuo.modifiers = append(tsuo.modifiers, modifiers...)
+ return tsuo
+}
+
func (tsuo *TFASettingUpdateOne) sqlSave(ctx context.Context) (_node *TFASetting, err error) {
_spec := sqlgraph.NewUpdateSpec(tfasetting.Table, tfasetting.Columns, sqlgraph.NewFieldSpec(tfasetting.FieldID, field.TypeString))
id, ok := tsuo.mutation.ID()
@@ -884,6 +898,7 @@ func (tsuo *TFASettingUpdateOne) sqlSave(ctx context.Context) (_node *TFASetting
}
_spec.Node.Schema = tsuo.schemaConfig.TFASetting
ctx = internal.NewSchemaConfigContext(ctx, tsuo.schemaConfig)
+ _spec.AddModifiers(tsuo.modifiers...)
_node = &TFASetting{config: tsuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/user/where.go b/internal/ent/generated/user/where.go
index e706a01b..ff33e670 100644
--- a/internal/ent/generated/user/where.go
+++ b/internal/ent/generated/user/where.go
@@ -7,10 +7,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/user_delete.go b/internal/ent/generated/user_delete.go
index 956f7db1..fd37a4f9 100644
--- a/internal/ent/generated/user_delete.go
+++ b/internal/ent/generated/user_delete.go
@@ -8,9 +8,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/user"
)
diff --git a/internal/ent/generated/user_query.go b/internal/ent/generated/user_query.go
index 31bdd4cc..5b23c428 100644
--- a/internal/ent/generated/user_query.go
+++ b/internal/ent/generated/user_query.go
@@ -18,6 +18,7 @@ import (
"github.com/theopenlane/core/internal/ent/generated/file"
"github.com/theopenlane/core/internal/ent/generated/group"
"github.com/theopenlane/core/internal/ent/generated/groupmembership"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/orgmembership"
"github.com/theopenlane/core/internal/ent/generated/passwordresettoken"
@@ -27,8 +28,6 @@ import (
"github.com/theopenlane/core/internal/ent/generated/user"
"github.com/theopenlane/core/internal/ent/generated/usersetting"
"github.com/theopenlane/core/internal/ent/generated/webauthn"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// UserQuery is the builder for querying User entities.
@@ -50,8 +49,8 @@ type UserQuery struct {
withEvents *EventQuery
withGroupMemberships *GroupMembershipQuery
withOrgMemberships *OrgMembershipQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*User) error
+ modifiers []func(*sql.Selector)
withNamedPersonalAccessTokens map[string]*PersonalAccessTokenQuery
withNamedTfaSettings map[string]*TFASettingQuery
withNamedEmailVerificationTokens map[string]*EmailVerificationTokenQuery
@@ -604,8 +603,9 @@ func (uq *UserQuery) Clone() *UserQuery {
withGroupMemberships: uq.withGroupMemberships.Clone(),
withOrgMemberships: uq.withOrgMemberships.Clone(),
// clone intermediate query.
- sql: uq.sql.Clone(),
- path: uq.path,
+ sql: uq.sql.Clone(),
+ path: uq.path,
+ modifiers: append([]func(*sql.Selector){}, uq.modifiers...),
}
}
@@ -1565,6 +1565,9 @@ func (uq *UserQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(uq.schemaConfig.User)
ctx = internal.NewSchemaConfigContext(ctx, uq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range uq.modifiers {
+ m(selector)
+ }
for _, p := range uq.predicates {
p(selector)
}
@@ -1582,6 +1585,12 @@ func (uq *UserQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (uq *UserQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSelect {
+ uq.modifiers = append(uq.modifiers, modifiers...)
+ return uq.Select()
+}
+
// WithNamedPersonalAccessTokens tells the query-builder to eager-load the nodes that are connected to the "personal_access_tokens"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (uq *UserQuery) WithNamedPersonalAccessTokens(name string, opts ...func(*PersonalAccessTokenQuery)) *UserQuery {
@@ -1825,3 +1834,9 @@ func (us *UserSelect) sqlScan(ctx context.Context, root *UserQuery, v any) error
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (us *UserSelect) Modify(modifiers ...func(s *sql.Selector)) *UserSelect {
+ us.modifiers = append(us.modifiers, modifiers...)
+ return us
+}
diff --git a/internal/ent/generated/user_update.go b/internal/ent/generated/user_update.go
index 7422429c..c84de6b4 100644
--- a/internal/ent/generated/user_update.go
+++ b/internal/ent/generated/user_update.go
@@ -17,6 +17,7 @@ import (
"github.com/theopenlane/core/internal/ent/generated/file"
"github.com/theopenlane/core/internal/ent/generated/group"
"github.com/theopenlane/core/internal/ent/generated/groupmembership"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/orgmembership"
"github.com/theopenlane/core/internal/ent/generated/passwordresettoken"
@@ -27,15 +28,14 @@ import (
"github.com/theopenlane/core/internal/ent/generated/usersetting"
"github.com/theopenlane/core/internal/ent/generated/webauthn"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// UserUpdate is the builder for updating User entities.
type UserUpdate struct {
config
- hooks []Hook
- mutation *UserMutation
+ hooks []Hook
+ mutation *UserMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the UserUpdate builder.
@@ -862,6 +862,12 @@ func (uu *UserUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (uu *UserUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserUpdate {
+ uu.modifiers = append(uu.modifiers, modifiers...)
+ return uu
+}
+
func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := uu.check(); err != nil {
return n, err
@@ -1581,6 +1587,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = uu.schemaConfig.User
ctx = internal.NewSchemaConfigContext(ctx, uu.schemaConfig)
+ _spec.AddModifiers(uu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{user.Label}
@@ -1596,9 +1603,10 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) {
// UserUpdateOne is the builder for updating a single User entity.
type UserUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *UserMutation
+ fields []string
+ hooks []Hook
+ mutation *UserMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -2432,6 +2440,12 @@ func (uuo *UserUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (uuo *UserUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserUpdateOne {
+ uuo.modifiers = append(uuo.modifiers, modifiers...)
+ return uuo
+}
+
func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) {
if err := uuo.check(); err != nil {
return _node, err
@@ -3168,6 +3182,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error)
}
_spec.Node.Schema = uuo.schemaConfig.User
ctx = internal.NewSchemaConfigContext(ctx, uuo.schemaConfig)
+ _spec.AddModifiers(uuo.modifiers...)
_node = &User{config: uuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/userhistory_delete.go b/internal/ent/generated/userhistory_delete.go
index 8b138712..a7deeb39 100644
--- a/internal/ent/generated/userhistory_delete.go
+++ b/internal/ent/generated/userhistory_delete.go
@@ -8,9 +8,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/userhistory"
)
diff --git a/internal/ent/generated/userhistory_query.go b/internal/ent/generated/userhistory_query.go
index bb594e7a..f9e0d3a5 100644
--- a/internal/ent/generated/userhistory_query.go
+++ b/internal/ent/generated/userhistory_query.go
@@ -11,10 +11,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/userhistory"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// UserHistoryQuery is the builder for querying UserHistory entities.
@@ -24,8 +23,8 @@ type UserHistoryQuery struct {
order []userhistory.OrderOption
inters []Interceptor
predicates []predicate.UserHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*UserHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -255,8 +254,9 @@ func (uhq *UserHistoryQuery) Clone() *UserHistoryQuery {
inters: append([]Interceptor{}, uhq.inters...),
predicates: append([]predicate.UserHistory{}, uhq.predicates...),
// clone intermediate query.
- sql: uhq.sql.Clone(),
- path: uhq.path,
+ sql: uhq.sql.Clone(),
+ path: uhq.path,
+ modifiers: append([]func(*sql.Selector){}, uhq.modifiers...),
}
}
@@ -441,6 +441,9 @@ func (uhq *UserHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(uhq.schemaConfig.UserHistory)
ctx = internal.NewSchemaConfigContext(ctx, uhq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range uhq.modifiers {
+ m(selector)
+ }
for _, p := range uhq.predicates {
p(selector)
}
@@ -458,6 +461,12 @@ func (uhq *UserHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (uhq *UserHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *UserHistorySelect {
+ uhq.modifiers = append(uhq.modifiers, modifiers...)
+ return uhq.Select()
+}
+
// UserHistoryGroupBy is the group-by builder for UserHistory entities.
type UserHistoryGroupBy struct {
selector
@@ -547,3 +556,9 @@ func (uhs *UserHistorySelect) sqlScan(ctx context.Context, root *UserHistoryQuer
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (uhs *UserHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *UserHistorySelect {
+ uhs.modifiers = append(uhs.modifiers, modifiers...)
+ return uhs
+}
diff --git a/internal/ent/generated/userhistory_update.go b/internal/ent/generated/userhistory_update.go
index 603ea634..cf9e444c 100644
--- a/internal/ent/generated/userhistory_update.go
+++ b/internal/ent/generated/userhistory_update.go
@@ -12,18 +12,18 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/userhistory"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// UserHistoryUpdate is the builder for updating UserHistory entities.
type UserHistoryUpdate struct {
config
- hooks []Hook
- mutation *UserHistoryMutation
+ hooks []Hook
+ mutation *UserHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the UserHistoryUpdate builder.
@@ -392,6 +392,12 @@ func (uhu *UserHistoryUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (uhu *UserHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserHistoryUpdate {
+ uhu.modifiers = append(uhu.modifiers, modifiers...)
+ return uhu
+}
+
func (uhu *UserHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := uhu.check(); err != nil {
return n, err
@@ -513,6 +519,7 @@ func (uhu *UserHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = uhu.schemaConfig.UserHistory
ctx = internal.NewSchemaConfigContext(ctx, uhu.schemaConfig)
+ _spec.AddModifiers(uhu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, uhu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{userhistory.Label}
@@ -528,9 +535,10 @@ func (uhu *UserHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
// UserHistoryUpdateOne is the builder for updating a single UserHistory entity.
type UserHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *UserHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *UserHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -906,6 +914,12 @@ func (uhuo *UserHistoryUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (uhuo *UserHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserHistoryUpdateOne {
+ uhuo.modifiers = append(uhuo.modifiers, modifiers...)
+ return uhuo
+}
+
func (uhuo *UserHistoryUpdateOne) sqlSave(ctx context.Context) (_node *UserHistory, err error) {
if err := uhuo.check(); err != nil {
return _node, err
@@ -1044,6 +1058,7 @@ func (uhuo *UserHistoryUpdateOne) sqlSave(ctx context.Context) (_node *UserHisto
}
_spec.Node.Schema = uhuo.schemaConfig.UserHistory
ctx = internal.NewSchemaConfigContext(ctx, uhuo.schemaConfig)
+ _spec.AddModifiers(uhuo.modifiers...)
_node = &UserHistory{config: uhuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/usersetting/where.go b/internal/ent/generated/usersetting/where.go
index e4148c6f..ac7d07c7 100644
--- a/internal/ent/generated/usersetting/where.go
+++ b/internal/ent/generated/usersetting/where.go
@@ -7,10 +7,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/usersetting_delete.go b/internal/ent/generated/usersetting_delete.go
index a65a110b..05f48d84 100644
--- a/internal/ent/generated/usersetting_delete.go
+++ b/internal/ent/generated/usersetting_delete.go
@@ -8,9 +8,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/usersetting"
)
diff --git a/internal/ent/generated/usersetting_query.go b/internal/ent/generated/usersetting_query.go
index 3232e0bb..37548612 100644
--- a/internal/ent/generated/usersetting_query.go
+++ b/internal/ent/generated/usersetting_query.go
@@ -12,12 +12,11 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/user"
"github.com/theopenlane/core/internal/ent/generated/usersetting"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// UserSettingQuery is the builder for querying UserSetting entities.
@@ -30,8 +29,8 @@ type UserSettingQuery struct {
withUser *UserQuery
withDefaultOrg *OrganizationQuery
withFKs bool
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*UserSetting) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -313,8 +312,9 @@ func (usq *UserSettingQuery) Clone() *UserSettingQuery {
withUser: usq.withUser.Clone(),
withDefaultOrg: usq.withDefaultOrg.Clone(),
// clone intermediate query.
- sql: usq.sql.Clone(),
- path: usq.path,
+ sql: usq.sql.Clone(),
+ path: usq.path,
+ modifiers: append([]func(*sql.Selector){}, usq.modifiers...),
}
}
@@ -616,6 +616,9 @@ func (usq *UserSettingQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(usq.schemaConfig.UserSetting)
ctx = internal.NewSchemaConfigContext(ctx, usq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range usq.modifiers {
+ m(selector)
+ }
for _, p := range usq.predicates {
p(selector)
}
@@ -633,6 +636,12 @@ func (usq *UserSettingQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (usq *UserSettingQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSettingSelect {
+ usq.modifiers = append(usq.modifiers, modifiers...)
+ return usq.Select()
+}
+
// UserSettingGroupBy is the group-by builder for UserSetting entities.
type UserSettingGroupBy struct {
selector
@@ -722,3 +731,9 @@ func (uss *UserSettingSelect) sqlScan(ctx context.Context, root *UserSettingQuer
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (uss *UserSettingSelect) Modify(modifiers ...func(s *sql.Selector)) *UserSettingSelect {
+ uss.modifiers = append(uss.modifiers, modifiers...)
+ return uss
+}
diff --git a/internal/ent/generated/usersetting_update.go b/internal/ent/generated/usersetting_update.go
index 15fe6094..f16f726d 100644
--- a/internal/ent/generated/usersetting_update.go
+++ b/internal/ent/generated/usersetting_update.go
@@ -12,20 +12,20 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/user"
"github.com/theopenlane/core/internal/ent/generated/usersetting"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// UserSettingUpdate is the builder for updating UserSetting entities.
type UserSettingUpdate struct {
config
- hooks []Hook
- mutation *UserSettingMutation
+ hooks []Hook
+ mutation *UserSettingMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the UserSettingUpdate builder.
@@ -379,6 +379,12 @@ func (usu *UserSettingUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (usu *UserSettingUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserSettingUpdate {
+ usu.modifiers = append(usu.modifiers, modifiers...)
+ return usu
+}
+
func (usu *UserSettingUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := usu.check(); err != nil {
return n, err
@@ -535,6 +541,7 @@ func (usu *UserSettingUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = usu.schemaConfig.UserSetting
ctx = internal.NewSchemaConfigContext(ctx, usu.schemaConfig)
+ _spec.AddModifiers(usu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, usu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{usersetting.Label}
@@ -550,9 +557,10 @@ func (usu *UserSettingUpdate) sqlSave(ctx context.Context) (n int, err error) {
// UserSettingUpdateOne is the builder for updating a single UserSetting entity.
type UserSettingUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *UserSettingMutation
+ fields []string
+ hooks []Hook
+ mutation *UserSettingMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -913,6 +921,12 @@ func (usuo *UserSettingUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (usuo *UserSettingUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserSettingUpdateOne {
+ usuo.modifiers = append(usuo.modifiers, modifiers...)
+ return usuo
+}
+
func (usuo *UserSettingUpdateOne) sqlSave(ctx context.Context) (_node *UserSetting, err error) {
if err := usuo.check(); err != nil {
return _node, err
@@ -1086,6 +1100,7 @@ func (usuo *UserSettingUpdateOne) sqlSave(ctx context.Context) (_node *UserSetti
}
_spec.Node.Schema = usuo.schemaConfig.UserSetting
ctx = internal.NewSchemaConfigContext(ctx, usuo.schemaConfig)
+ _spec.AddModifiers(usuo.modifiers...)
_node = &UserSetting{config: usuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/usersettinghistory_delete.go b/internal/ent/generated/usersettinghistory_delete.go
index c56acd28..5dc671d3 100644
--- a/internal/ent/generated/usersettinghistory_delete.go
+++ b/internal/ent/generated/usersettinghistory_delete.go
@@ -8,9 +8,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/usersettinghistory"
)
diff --git a/internal/ent/generated/usersettinghistory_query.go b/internal/ent/generated/usersettinghistory_query.go
index b3885890..2b67911a 100644
--- a/internal/ent/generated/usersettinghistory_query.go
+++ b/internal/ent/generated/usersettinghistory_query.go
@@ -11,10 +11,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/usersettinghistory"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// UserSettingHistoryQuery is the builder for querying UserSettingHistory entities.
@@ -24,8 +23,8 @@ type UserSettingHistoryQuery struct {
order []usersettinghistory.OrderOption
inters []Interceptor
predicates []predicate.UserSettingHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*UserSettingHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -255,8 +254,9 @@ func (ushq *UserSettingHistoryQuery) Clone() *UserSettingHistoryQuery {
inters: append([]Interceptor{}, ushq.inters...),
predicates: append([]predicate.UserSettingHistory{}, ushq.predicates...),
// clone intermediate query.
- sql: ushq.sql.Clone(),
- path: ushq.path,
+ sql: ushq.sql.Clone(),
+ path: ushq.path,
+ modifiers: append([]func(*sql.Selector){}, ushq.modifiers...),
}
}
@@ -441,6 +441,9 @@ func (ushq *UserSettingHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector
t1.Schema(ushq.schemaConfig.UserSettingHistory)
ctx = internal.NewSchemaConfigContext(ctx, ushq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range ushq.modifiers {
+ m(selector)
+ }
for _, p := range ushq.predicates {
p(selector)
}
@@ -458,6 +461,12 @@ func (ushq *UserSettingHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ushq *UserSettingHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSettingHistorySelect {
+ ushq.modifiers = append(ushq.modifiers, modifiers...)
+ return ushq.Select()
+}
+
// UserSettingHistoryGroupBy is the group-by builder for UserSettingHistory entities.
type UserSettingHistoryGroupBy struct {
selector
@@ -547,3 +556,9 @@ func (ushs *UserSettingHistorySelect) sqlScan(ctx context.Context, root *UserSet
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ushs *UserSettingHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *UserSettingHistorySelect {
+ ushs.modifiers = append(ushs.modifiers, modifiers...)
+ return ushs
+}
diff --git a/internal/ent/generated/usersettinghistory_update.go b/internal/ent/generated/usersettinghistory_update.go
index ae8b900d..83d3dcde 100644
--- a/internal/ent/generated/usersettinghistory_update.go
+++ b/internal/ent/generated/usersettinghistory_update.go
@@ -12,18 +12,18 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/usersettinghistory"
"github.com/theopenlane/core/pkg/enums"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// UserSettingHistoryUpdate is the builder for updating UserSettingHistory entities.
type UserSettingHistoryUpdate struct {
config
- hooks []Hook
- mutation *UserSettingHistoryMutation
+ hooks []Hook
+ mutation *UserSettingHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the UserSettingHistoryUpdate builder.
@@ -335,6 +335,12 @@ func (ushu *UserSettingHistoryUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ushu *UserSettingHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserSettingHistoryUpdate {
+ ushu.modifiers = append(ushu.modifiers, modifiers...)
+ return ushu
+}
+
func (ushu *UserSettingHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := ushu.check(); err != nil {
return n, err
@@ -438,6 +444,7 @@ func (ushu *UserSettingHistoryUpdate) sqlSave(ctx context.Context) (n int, err e
}
_spec.Node.Schema = ushu.schemaConfig.UserSettingHistory
ctx = internal.NewSchemaConfigContext(ctx, ushu.schemaConfig)
+ _spec.AddModifiers(ushu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, ushu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{usersettinghistory.Label}
@@ -453,9 +460,10 @@ func (ushu *UserSettingHistoryUpdate) sqlSave(ctx context.Context) (n int, err e
// UserSettingHistoryUpdateOne is the builder for updating a single UserSettingHistory entity.
type UserSettingHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *UserSettingHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *UserSettingHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -774,6 +782,12 @@ func (ushuo *UserSettingHistoryUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (ushuo *UserSettingHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserSettingHistoryUpdateOne {
+ ushuo.modifiers = append(ushuo.modifiers, modifiers...)
+ return ushuo
+}
+
func (ushuo *UserSettingHistoryUpdateOne) sqlSave(ctx context.Context) (_node *UserSettingHistory, err error) {
if err := ushuo.check(); err != nil {
return _node, err
@@ -894,6 +908,7 @@ func (ushuo *UserSettingHistoryUpdateOne) sqlSave(ctx context.Context) (_node *U
}
_spec.Node.Schema = ushuo.schemaConfig.UserSettingHistory
ctx = internal.NewSchemaConfigContext(ctx, ushuo.schemaConfig)
+ _spec.AddModifiers(ushuo.modifiers...)
_node = &UserSettingHistory{config: ushuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/webauthn/where.go b/internal/ent/generated/webauthn/where.go
index 49cf8f6d..8a630df7 100644
--- a/internal/ent/generated/webauthn/where.go
+++ b/internal/ent/generated/webauthn/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/webauthn_delete.go b/internal/ent/generated/webauthn_delete.go
index a5ea715d..9527c316 100644
--- a/internal/ent/generated/webauthn_delete.go
+++ b/internal/ent/generated/webauthn_delete.go
@@ -8,9 +8,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/webauthn"
)
diff --git a/internal/ent/generated/webauthn_query.go b/internal/ent/generated/webauthn_query.go
index 79231a83..f2806c85 100644
--- a/internal/ent/generated/webauthn_query.go
+++ b/internal/ent/generated/webauthn_query.go
@@ -11,11 +11,10 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/user"
"github.com/theopenlane/core/internal/ent/generated/webauthn"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// WebauthnQuery is the builder for querying Webauthn entities.
@@ -26,8 +25,8 @@ type WebauthnQuery struct {
inters []Interceptor
predicates []predicate.Webauthn
withOwner *UserQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*Webauthn) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -283,8 +282,9 @@ func (wq *WebauthnQuery) Clone() *WebauthnQuery {
predicates: append([]predicate.Webauthn{}, wq.predicates...),
withOwner: wq.withOwner.Clone(),
// clone intermediate query.
- sql: wq.sql.Clone(),
- path: wq.path,
+ sql: wq.sql.Clone(),
+ path: wq.path,
+ modifiers: append([]func(*sql.Selector){}, wq.modifiers...),
}
}
@@ -523,6 +523,9 @@ func (wq *WebauthnQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(wq.schemaConfig.Webauthn)
ctx = internal.NewSchemaConfigContext(ctx, wq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range wq.modifiers {
+ m(selector)
+ }
for _, p := range wq.predicates {
p(selector)
}
@@ -540,6 +543,12 @@ func (wq *WebauthnQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (wq *WebauthnQuery) Modify(modifiers ...func(s *sql.Selector)) *WebauthnSelect {
+ wq.modifiers = append(wq.modifiers, modifiers...)
+ return wq.Select()
+}
+
// WebauthnGroupBy is the group-by builder for Webauthn entities.
type WebauthnGroupBy struct {
selector
@@ -629,3 +638,9 @@ func (ws *WebauthnSelect) sqlScan(ctx context.Context, root *WebauthnQuery, v an
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ws *WebauthnSelect) Modify(modifiers ...func(s *sql.Selector)) *WebauthnSelect {
+ ws.modifiers = append(ws.modifiers, modifiers...)
+ return ws
+}
diff --git a/internal/ent/generated/webauthn_update.go b/internal/ent/generated/webauthn_update.go
index 8fc97f7c..602970a9 100644
--- a/internal/ent/generated/webauthn_update.go
+++ b/internal/ent/generated/webauthn_update.go
@@ -12,18 +12,18 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/user"
"github.com/theopenlane/core/internal/ent/generated/webauthn"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// WebauthnUpdate is the builder for updating Webauthn entities.
type WebauthnUpdate struct {
config
- hooks []Hook
- mutation *WebauthnMutation
+ hooks []Hook
+ mutation *WebauthnMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the WebauthnUpdate builder.
@@ -281,6 +281,12 @@ func (wu *WebauthnUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (wu *WebauthnUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WebauthnUpdate {
+ wu.modifiers = append(wu.modifiers, modifiers...)
+ return wu
+}
+
func (wu *WebauthnUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := wu.check(); err != nil {
return n, err
@@ -396,6 +402,7 @@ func (wu *WebauthnUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = wu.schemaConfig.Webauthn
ctx = internal.NewSchemaConfigContext(ctx, wu.schemaConfig)
+ _spec.AddModifiers(wu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, wu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{webauthn.Label}
@@ -411,9 +418,10 @@ func (wu *WebauthnUpdate) sqlSave(ctx context.Context) (n int, err error) {
// WebauthnUpdateOne is the builder for updating a single Webauthn entity.
type WebauthnUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *WebauthnMutation
+ fields []string
+ hooks []Hook
+ mutation *WebauthnMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -678,6 +686,12 @@ func (wuo *WebauthnUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (wuo *WebauthnUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WebauthnUpdateOne {
+ wuo.modifiers = append(wuo.modifiers, modifiers...)
+ return wuo
+}
+
func (wuo *WebauthnUpdateOne) sqlSave(ctx context.Context) (_node *Webauthn, err error) {
if err := wuo.check(); err != nil {
return _node, err
@@ -810,6 +824,7 @@ func (wuo *WebauthnUpdateOne) sqlSave(ctx context.Context) (_node *Webauthn, err
}
_spec.Node.Schema = wuo.schemaConfig.Webauthn
ctx = internal.NewSchemaConfigContext(ctx, wuo.schemaConfig)
+ _spec.AddModifiers(wuo.modifiers...)
_node = &Webauthn{config: wuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/webhook/where.go b/internal/ent/generated/webhook/where.go
index 3a721a19..9aee5f55 100644
--- a/internal/ent/generated/webhook/where.go
+++ b/internal/ent/generated/webhook/where.go
@@ -7,9 +7,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
)
// ID filters vertices based on their ID field.
diff --git a/internal/ent/generated/webhook_delete.go b/internal/ent/generated/webhook_delete.go
index 650be70b..5d1e7975 100644
--- a/internal/ent/generated/webhook_delete.go
+++ b/internal/ent/generated/webhook_delete.go
@@ -8,9 +8,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/webhook"
)
diff --git a/internal/ent/generated/webhook_query.go b/internal/ent/generated/webhook_query.go
index 0fe9911c..f19652ea 100644
--- a/internal/ent/generated/webhook_query.go
+++ b/internal/ent/generated/webhook_query.go
@@ -14,11 +14,10 @@ import (
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/event"
"github.com/theopenlane/core/internal/ent/generated/integration"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/webhook"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// WebhookQuery is the builder for querying Webhook entities.
@@ -31,8 +30,8 @@ type WebhookQuery struct {
withOwner *OrganizationQuery
withEvents *EventQuery
withIntegrations *IntegrationQuery
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*Webhook) error
+ modifiers []func(*sql.Selector)
withNamedEvents map[string]*EventQuery
withNamedIntegrations map[string]*IntegrationQuery
// intermediate query (i.e. traversal path).
@@ -342,8 +341,9 @@ func (wq *WebhookQuery) Clone() *WebhookQuery {
withEvents: wq.withEvents.Clone(),
withIntegrations: wq.withIntegrations.Clone(),
// clone intermediate query.
- sql: wq.sql.Clone(),
- path: wq.path,
+ sql: wq.sql.Clone(),
+ path: wq.path,
+ modifiers: append([]func(*sql.Selector){}, wq.modifiers...),
}
}
@@ -758,6 +758,9 @@ func (wq *WebhookQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(wq.schemaConfig.Webhook)
ctx = internal.NewSchemaConfigContext(ctx, wq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range wq.modifiers {
+ m(selector)
+ }
for _, p := range wq.predicates {
p(selector)
}
@@ -775,6 +778,12 @@ func (wq *WebhookQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (wq *WebhookQuery) Modify(modifiers ...func(s *sql.Selector)) *WebhookSelect {
+ wq.modifiers = append(wq.modifiers, modifiers...)
+ return wq.Select()
+}
+
// WithNamedEvents tells the query-builder to eager-load the nodes that are connected to the "events"
// edge with the given name. The optional arguments are used to configure the query builder of the edge.
func (wq *WebhookQuery) WithNamedEvents(name string, opts ...func(*EventQuery)) *WebhookQuery {
@@ -892,3 +901,9 @@ func (ws *WebhookSelect) sqlScan(ctx context.Context, root *WebhookQuery, v any)
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (ws *WebhookSelect) Modify(modifiers ...func(s *sql.Selector)) *WebhookSelect {
+ ws.modifiers = append(ws.modifiers, modifiers...)
+ return ws
+}
diff --git a/internal/ent/generated/webhook_update.go b/internal/ent/generated/webhook_update.go
index d881d3f7..fd9449ce 100644
--- a/internal/ent/generated/webhook_update.go
+++ b/internal/ent/generated/webhook_update.go
@@ -14,18 +14,18 @@ import (
"entgo.io/ent/schema/field"
"github.com/theopenlane/core/internal/ent/generated/event"
"github.com/theopenlane/core/internal/ent/generated/integration"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/webhook"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// WebhookUpdate is the builder for updating Webhook entities.
type WebhookUpdate struct {
config
- hooks []Hook
- mutation *WebhookMutation
+ hooks []Hook
+ mutation *WebhookMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the WebhookUpdate builder.
@@ -470,6 +470,12 @@ func (wu *WebhookUpdate) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (wu *WebhookUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WebhookUpdate {
+ wu.modifiers = append(wu.modifiers, modifiers...)
+ return wu
+}
+
func (wu *WebhookUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := wu.check(); err != nil {
return n, err
@@ -706,6 +712,7 @@ func (wu *WebhookUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Node.Schema = wu.schemaConfig.Webhook
ctx = internal.NewSchemaConfigContext(ctx, wu.schemaConfig)
+ _spec.AddModifiers(wu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, wu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{webhook.Label}
@@ -721,9 +728,10 @@ func (wu *WebhookUpdate) sqlSave(ctx context.Context) (n int, err error) {
// WebhookUpdateOne is the builder for updating a single Webhook entity.
type WebhookUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *WebhookMutation
+ fields []string
+ hooks []Hook
+ mutation *WebhookMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -1175,6 +1183,12 @@ func (wuo *WebhookUpdateOne) check() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (wuo *WebhookUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WebhookUpdateOne {
+ wuo.modifiers = append(wuo.modifiers, modifiers...)
+ return wuo
+}
+
func (wuo *WebhookUpdateOne) sqlSave(ctx context.Context) (_node *Webhook, err error) {
if err := wuo.check(); err != nil {
return _node, err
@@ -1428,6 +1442,7 @@ func (wuo *WebhookUpdateOne) sqlSave(ctx context.Context) (_node *Webhook, err e
}
_spec.Node.Schema = wuo.schemaConfig.Webhook
ctx = internal.NewSchemaConfigContext(ctx, wuo.schemaConfig)
+ _spec.AddModifiers(wuo.modifiers...)
_node = &Webhook{config: wuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/generated/webhookhistory_delete.go b/internal/ent/generated/webhookhistory_delete.go
index fb8c8560..d38f62ff 100644
--- a/internal/ent/generated/webhookhistory_delete.go
+++ b/internal/ent/generated/webhookhistory_delete.go
@@ -8,9 +8,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
- "github.com/theopenlane/core/internal/ent/generated/predicate"
-
"github.com/theopenlane/core/internal/ent/generated/internal"
+ "github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/webhookhistory"
)
diff --git a/internal/ent/generated/webhookhistory_query.go b/internal/ent/generated/webhookhistory_query.go
index 7d640d33..de401ddd 100644
--- a/internal/ent/generated/webhookhistory_query.go
+++ b/internal/ent/generated/webhookhistory_query.go
@@ -12,10 +12,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/webhookhistory"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// WebhookHistoryQuery is the builder for querying WebhookHistory entities.
@@ -25,8 +24,8 @@ type WebhookHistoryQuery struct {
order []webhookhistory.OrderOption
inters []Interceptor
predicates []predicate.WebhookHistory
- modifiers []func(*sql.Selector)
loadTotal []func(context.Context, []*WebhookHistory) error
+ modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -256,8 +255,9 @@ func (whq *WebhookHistoryQuery) Clone() *WebhookHistoryQuery {
inters: append([]Interceptor{}, whq.inters...),
predicates: append([]predicate.WebhookHistory{}, whq.predicates...),
// clone intermediate query.
- sql: whq.sql.Clone(),
- path: whq.path,
+ sql: whq.sql.Clone(),
+ path: whq.path,
+ modifiers: append([]func(*sql.Selector){}, whq.modifiers...),
}
}
@@ -448,6 +448,9 @@ func (whq *WebhookHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
t1.Schema(whq.schemaConfig.WebhookHistory)
ctx = internal.NewSchemaConfigContext(ctx, whq.schemaConfig)
selector.WithContext(ctx)
+ for _, m := range whq.modifiers {
+ m(selector)
+ }
for _, p := range whq.predicates {
p(selector)
}
@@ -465,6 +468,12 @@ func (whq *WebhookHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
+// Modify adds a query modifier for attaching custom logic to queries.
+func (whq *WebhookHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *WebhookHistorySelect {
+ whq.modifiers = append(whq.modifiers, modifiers...)
+ return whq.Select()
+}
+
// WebhookHistoryGroupBy is the group-by builder for WebhookHistory entities.
type WebhookHistoryGroupBy struct {
selector
@@ -554,3 +563,9 @@ func (whs *WebhookHistorySelect) sqlScan(ctx context.Context, root *WebhookHisto
defer rows.Close()
return sql.ScanSlice(rows, v)
}
+
+// Modify adds a query modifier for attaching custom logic to queries.
+func (whs *WebhookHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *WebhookHistorySelect {
+ whs.modifiers = append(whs.modifiers, modifiers...)
+ return whs
+}
diff --git a/internal/ent/generated/webhookhistory_update.go b/internal/ent/generated/webhookhistory_update.go
index 6ba309d9..0c6ece96 100644
--- a/internal/ent/generated/webhookhistory_update.go
+++ b/internal/ent/generated/webhookhistory_update.go
@@ -12,17 +12,17 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
+ "github.com/theopenlane/core/internal/ent/generated/internal"
"github.com/theopenlane/core/internal/ent/generated/predicate"
"github.com/theopenlane/core/internal/ent/generated/webhookhistory"
-
- "github.com/theopenlane/core/internal/ent/generated/internal"
)
// WebhookHistoryUpdate is the builder for updating WebhookHistory entities.
type WebhookHistoryUpdate struct {
config
- hooks []Hook
- mutation *WebhookHistoryMutation
+ hooks []Hook
+ mutation *WebhookHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the WebhookHistoryUpdate builder.
@@ -369,6 +369,12 @@ func (whu *WebhookHistoryUpdate) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (whu *WebhookHistoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WebhookHistoryUpdate {
+ whu.modifiers = append(whu.modifiers, modifiers...)
+ return whu
+}
+
func (whu *WebhookHistoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(webhookhistory.Table, webhookhistory.Columns, sqlgraph.NewFieldSpec(webhookhistory.FieldID, field.TypeString))
if ps := whu.mutation.predicates; len(ps) > 0 {
@@ -484,6 +490,7 @@ func (whu *WebhookHistoryUpdate) sqlSave(ctx context.Context) (n int, err error)
}
_spec.Node.Schema = whu.schemaConfig.WebhookHistory
ctx = internal.NewSchemaConfigContext(ctx, whu.schemaConfig)
+ _spec.AddModifiers(whu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, whu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{webhookhistory.Label}
@@ -499,9 +506,10 @@ func (whu *WebhookHistoryUpdate) sqlSave(ctx context.Context) (n int, err error)
// WebhookHistoryUpdateOne is the builder for updating a single WebhookHistory entity.
type WebhookHistoryUpdateOne struct {
config
- fields []string
- hooks []Hook
- mutation *WebhookHistoryMutation
+ fields []string
+ hooks []Hook
+ mutation *WebhookHistoryMutation
+ modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
@@ -855,6 +863,12 @@ func (whuo *WebhookHistoryUpdateOne) defaults() error {
return nil
}
+// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
+func (whuo *WebhookHistoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WebhookHistoryUpdateOne {
+ whuo.modifiers = append(whuo.modifiers, modifiers...)
+ return whuo
+}
+
func (whuo *WebhookHistoryUpdateOne) sqlSave(ctx context.Context) (_node *WebhookHistory, err error) {
_spec := sqlgraph.NewUpdateSpec(webhookhistory.Table, webhookhistory.Columns, sqlgraph.NewFieldSpec(webhookhistory.FieldID, field.TypeString))
id, ok := whuo.mutation.ID()
@@ -987,6 +1001,7 @@ func (whuo *WebhookHistoryUpdateOne) sqlSave(ctx context.Context) (_node *Webhoo
}
_spec.Node.Schema = whuo.schemaConfig.WebhookHistory
ctx = internal.NewSchemaConfigContext(ctx, whuo.schemaConfig)
+ _spec.AddModifiers(whuo.modifiers...)
_node = &WebhookHistory{config: whuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/internal/ent/hooks/apitoken.go b/internal/ent/hooks/apitoken.go
index 221c31f7..1edc7293 100644
--- a/internal/ent/hooks/apitoken.go
+++ b/internal/ent/hooks/apitoken.go
@@ -17,16 +17,16 @@ import (
// HookCreateAPIToken runs on api token mutations and sets the owner id
func HookCreateAPIToken() ent.Hook {
return hook.On(func(next ent.Mutator) ent.Mutator {
- return hook.APITokenFunc(func(ctx context.Context, mutation *generated.APITokenMutation) (generated.Value, error) {
+ return hook.APITokenFunc(func(ctx context.Context, m *generated.APITokenMutation) (generated.Value, error) {
orgID, err := auth.GetOrganizationIDFromContext(ctx)
if err != nil {
return nil, err
}
// set organization on the token
- mutation.SetOwnerID(orgID)
+ m.SetOwnerID(orgID)
- retVal, err := next.Mutate(ctx, mutation)
+ retVal, err := next.Mutate(ctx, m)
if err != nil {
return nil, err
}
@@ -44,7 +44,7 @@ func HookCreateAPIToken() ent.Hook {
// create the relationship tuples if we have any
if len(tuples) > 0 {
- if _, err := mutation.Authz.WriteTupleKeys(ctx, tuples, nil); err != nil {
+ if _, err := m.Authz.WriteTupleKeys(ctx, tuples, nil); err != nil {
log.Error().Err(err).Msg("failed to create relationship tuple")
return nil, err
@@ -59,8 +59,8 @@ func HookCreateAPIToken() ent.Hook {
// HookUpdateAPIToken runs on api token update and redacts the token
func HookUpdateAPIToken() ent.Hook {
return hook.On(func(next ent.Mutator) ent.Mutator {
- return hook.APITokenFunc(func(ctx context.Context, mutation *generated.APITokenMutation) (generated.Value, error) {
- retVal, err := next.Mutate(ctx, mutation)
+ return hook.APITokenFunc(func(ctx context.Context, m *generated.APITokenMutation) (generated.Value, error) {
+ retVal, err := next.Mutate(ctx, m)
if err != nil {
return nil, err
}
@@ -74,7 +74,7 @@ func HookUpdateAPIToken() ent.Hook {
at.Token = redacted
// create the relationship tuples in fga for the token
- newScopes, err := getNewScopes(ctx, mutation)
+ newScopes, err := getNewScopes(ctx, m)
if err != nil {
return at, err
}
@@ -86,7 +86,7 @@ func HookUpdateAPIToken() ent.Hook {
// create the relationship tuples if we have any
if len(tuples) > 0 {
- if _, err := mutation.Authz.WriteTupleKeys(ctx, tuples, nil); err != nil {
+ if _, err := m.Authz.WriteTupleKeys(ctx, tuples, nil); err != nil {
log.Error().Err(err).Msg("failed to create relationship tuple")
return nil, err
@@ -131,13 +131,13 @@ func createScopeTuples(scopes []string, orgID, tokenID string) (tuples []fgax.Tu
// getNewScopes returns the new scopes that were added to the token during an update
// NOTE: there is an AppendedScopes on the mutation, but this is not populated
// so calculating the new scopes for now
-func getNewScopes(ctx context.Context, mutation *generated.APITokenMutation) ([]string, error) {
- scopes, ok := mutation.Scopes()
+func getNewScopes(ctx context.Context, m *generated.APITokenMutation) ([]string, error) {
+ scopes, ok := m.Scopes()
if !ok {
return nil, nil
}
- oldScopes, err := mutation.OldScopes(ctx)
+ oldScopes, err := m.OldScopes(ctx)
if err != nil {
return nil, err
}
diff --git a/internal/ent/hooks/emailverificationtoken.go b/internal/ent/hooks/emailverificationtoken.go
index 70820a63..96ad931e 100644
--- a/internal/ent/hooks/emailverificationtoken.go
+++ b/internal/ent/hooks/emailverificationtoken.go
@@ -13,13 +13,13 @@ import (
// HookEmailVerificationToken runs on email verification mutations and sets expires
func HookEmailVerificationToken() ent.Hook {
return hook.On(func(next ent.Mutator) ent.Mutator {
- return hook.EmailVerificationTokenFunc(func(ctx context.Context, mutation *generated.EmailVerificationTokenMutation) (generated.Value, error) {
- expires, _ := mutation.TTL()
+ return hook.EmailVerificationTokenFunc(func(ctx context.Context, m *generated.EmailVerificationTokenMutation) (generated.Value, error) {
+ expires, _ := m.TTL()
if expires.IsZero() {
- mutation.SetTTL(time.Now().UTC().Add(time.Hour * 24 * 7)) //nolint:mnd
+ m.SetTTL(time.Now().UTC().Add(time.Hour * 24 * 7)) //nolint:mnd
}
- return next.Mutate(ctx, mutation)
+ return next.Mutate(ctx, m)
})
}, ent.OpCreate)
}
diff --git a/internal/ent/hooks/entitlement.go b/internal/ent/hooks/entitlement.go
index 383eb28b..84711097 100644
--- a/internal/ent/hooks/entitlement.go
+++ b/internal/ent/hooks/entitlement.go
@@ -11,14 +11,14 @@ import (
func HookEntitlement() ent.Hook {
return hook.On(func(next ent.Mutator) ent.Mutator {
- return hook.EntitlementFunc(func(ctx context.Context, mutation *generated.EntitlementMutation) (generated.Value, error) {
+ return hook.EntitlementFunc(func(ctx context.Context, m *generated.EntitlementMutation) (generated.Value, error) {
// set the expires flag if the expires_at field is set
- expiresAt, ok := mutation.ExpiresAt()
+ expiresAt, ok := m.ExpiresAt()
if ok && !expiresAt.IsZero() {
- mutation.SetExpires(true)
+ m.SetExpires(true)
}
- retVal, err := next.Mutate(ctx, mutation)
+ retVal, err := next.Mutate(ctx, m)
if err != nil {
return nil, err
}
diff --git a/internal/ent/hooks/entitlementplan.go b/internal/ent/hooks/entitlementplan.go
index 567afa56..50d8f199 100644
--- a/internal/ent/hooks/entitlementplan.go
+++ b/internal/ent/hooks/entitlementplan.go
@@ -11,19 +11,19 @@ import (
func HookEntitlementPlan() ent.Hook {
return hook.On(func(next ent.Mutator) ent.Mutator {
- return hook.EntitlementPlanFunc(func(ctx context.Context, mutation *generated.EntitlementPlanMutation) (generated.Value, error) {
+ return hook.EntitlementPlanFunc(func(ctx context.Context, m *generated.EntitlementPlanMutation) (generated.Value, error) {
// set the display name if it is not set
- if mutation.Op() == ent.OpCreate {
- displayName, _ := mutation.DisplayName()
+ if m.Op() == ent.OpCreate {
+ displayName, _ := m.DisplayName()
if displayName == "" {
- name, ok := mutation.Name()
+ name, ok := m.Name()
if ok {
- mutation.SetDisplayName(name)
+ m.SetDisplayName(name)
}
}
}
- retVal, err := next.Mutate(ctx, mutation)
+ retVal, err := next.Mutate(ctx, m)
if err != nil {
return nil, err
}
diff --git a/internal/ent/hooks/entity.go b/internal/ent/hooks/entity.go
index f738827c..4b3a8aa0 100644
--- a/internal/ent/hooks/entity.go
+++ b/internal/ent/hooks/entity.go
@@ -15,10 +15,10 @@ import (
// HookEntityCreate runs on entity mutations to set default values that are not provided
func HookEntityCreate() ent.Hook {
return hook.On(func(next ent.Mutator) ent.Mutator {
- return hook.EntityFunc(func(ctx context.Context, mutation *generated.EntityMutation) (generated.Value, error) {
+ return hook.EntityFunc(func(ctx context.Context, m *generated.EntityMutation) (generated.Value, error) {
// require either a display name or a name
- displayName, _ := mutation.DisplayName()
- name, _ := mutation.Name()
+ displayName, _ := m.DisplayName()
+ name, _ := m.Name()
// exit early if we have no name
if displayName == "" && name == "" {
@@ -27,16 +27,16 @@ func HookEntityCreate() ent.Hook {
// set display name based on name if it isn't set
if displayName == "" {
- mutation.SetDisplayName(name)
+ m.SetDisplayName(name)
}
// set unique name based on display name if it isn't set
if name == "" {
uniqueName := fmt.Sprintf("%s-%s", displayName, ulids.New().String())
- mutation.SetName(uniqueName)
+ m.SetName(uniqueName)
}
- return next.Mutate(ctx, mutation)
+ return next.Mutate(ctx, m)
})
}, ent.OpCreate)
}
diff --git a/internal/ent/hooks/feature.go b/internal/ent/hooks/feature.go
index 9c6c84e0..f31e5dd9 100644
--- a/internal/ent/hooks/feature.go
+++ b/internal/ent/hooks/feature.go
@@ -11,19 +11,19 @@ import (
func HookFeature() ent.Hook {
return hook.On(func(next ent.Mutator) ent.Mutator {
- return hook.FeatureFunc(func(ctx context.Context, mutation *generated.FeatureMutation) (generated.Value, error) {
+ return hook.FeatureFunc(func(ctx context.Context, m *generated.FeatureMutation) (generated.Value, error) {
// set the display name if it is not set
- if mutation.Op() == ent.OpCreate {
- displayName, _ := mutation.DisplayName()
+ if m.Op() == ent.OpCreate {
+ displayName, _ := m.DisplayName()
if displayName == "" {
- name, ok := mutation.Name()
+ name, ok := m.Name()
if ok {
- mutation.SetDisplayName(name)
+ m.SetDisplayName(name)
}
}
}
- retVal, err := next.Mutate(ctx, mutation)
+ retVal, err := next.Mutate(ctx, m)
if err != nil {
return nil, err
}
diff --git a/internal/ent/hooks/group.go b/internal/ent/hooks/group.go
index 4ed6b0be..48f36d73 100644
--- a/internal/ent/hooks/group.go
+++ b/internal/ent/hooks/group.go
@@ -20,36 +20,36 @@ import (
// HookGroup runs on group mutations to set default values that are not provided
func HookGroup() ent.Hook {
return hook.On(func(next ent.Mutator) ent.Mutator {
- return hook.GroupFunc(func(ctx context.Context, mutation *generated.GroupMutation) (generated.Value, error) {
- if name, ok := mutation.Name(); ok {
- displayName, _ := mutation.DisplayName()
+ return hook.GroupFunc(func(ctx context.Context, m *generated.GroupMutation) (generated.Value, error) {
+ if name, ok := m.Name(); ok {
+ displayName, _ := m.DisplayName()
if displayName == "" {
- mutation.SetDisplayName(name)
+ m.SetDisplayName(name)
}
}
- if mutation.Op().Is(ent.OpCreate) {
+ if m.Op().Is(ent.OpCreate) {
// if this is empty generate a default group setting schema
- settingID, _ := mutation.SettingID()
+ settingID, _ := m.SettingID()
if settingID == "" {
// sets up default group settings using schema defaults
- groupSettingID, err := defaultGroupSettings(ctx, mutation)
+ groupSettingID, err := defaultGroupSettings(ctx, m)
if err != nil {
return nil, err
}
// add the group setting ID to the input
- mutation.SetSettingID(groupSettingID)
+ m.SetSettingID(groupSettingID)
}
}
- if name, ok := mutation.Name(); ok {
+ if name, ok := m.Name(); ok {
url := gravatar.New(name, nil)
- mutation.SetGravatarLogoURL(url)
+ m.SetGravatarLogoURL(url)
}
- return next.Mutate(ctx, mutation)
+ return next.Mutate(ctx, m)
})
}, ent.OpCreate|ent.OpUpdateOne)
}
@@ -173,10 +173,10 @@ func groupDeleteHook(ctx context.Context, m *generated.GroupMutation) error {
}
// defaultGroupSettings creates the default group settings for a new group
-func defaultGroupSettings(ctx context.Context, group *generated.GroupMutation) (string, error) {
+func defaultGroupSettings(ctx context.Context, m *generated.GroupMutation) (string, error) {
input := generated.CreateGroupSettingInput{}
- groupSetting, err := group.Client().GroupSetting.Create().SetInput(input).Save(ctx)
+ groupSetting, err := m.Client().GroupSetting.Create().SetInput(input).Save(ctx)
if err != nil {
return "", err
}
diff --git a/internal/ent/hooks/groupmembers.go b/internal/ent/hooks/groupmembers.go
index 5ee2231a..cd030676 100644
--- a/internal/ent/hooks/groupmembers.go
+++ b/internal/ent/hooks/groupmembers.go
@@ -5,8 +5,6 @@ import (
"entgo.io/ent"
- ph "github.com/posthog/posthog-go"
-
"github.com/theopenlane/core/internal/ent/generated"
"github.com/theopenlane/core/internal/ent/generated/hook"
"github.com/theopenlane/core/internal/ent/generated/orgmembership"
@@ -14,26 +12,26 @@ import (
func HookGroupMembers() ent.Hook {
return hook.On(func(next ent.Mutator) ent.Mutator {
- return hook.GroupMembershipFunc(func(ctx context.Context, mutation *generated.GroupMembershipMutation) (generated.Value, error) {
+ return hook.GroupMembershipFunc(func(ctx context.Context, m *generated.GroupMembershipMutation) (generated.Value, error) {
// check role, if its not set the default is member
- userID, ok := mutation.UserID()
+ userID, ok := m.UserID()
if !ok {
- return next.Mutate(ctx, mutation)
+ return next.Mutate(ctx, m)
}
- groupID, ok := mutation.GroupID()
+ groupID, ok := m.GroupID()
if !ok {
- return next.Mutate(ctx, mutation)
+ return next.Mutate(ctx, m)
}
- group, err := mutation.Client().Group.Get(ctx, groupID)
+ group, err := m.Client().Group.Get(ctx, groupID)
if err != nil {
// group not found, let the default validation handle it
- return next.Mutate(ctx, mutation)
+ return next.Mutate(ctx, m)
}
// ensure user is a member of the organization
- exists, err := mutation.Client().OrgMembership.Query().
+ exists, err := m.Client().OrgMembership.Query().
Where(orgmembership.UserID(userID)).
Where(orgmembership.OrganizationID(group.OwnerID)).
Exist(ctx)
@@ -45,16 +43,7 @@ func HookGroupMembers() ent.Hook {
return nil, ErrUserNotInOrg
}
- role, _ := mutation.Role()
-
- props := ph.NewProperties().
- Set("group_id", groupID).
- Set("user_id", userID).
- Set("role", role)
-
- mutation.Analytics.Event("group_membership", props)
-
- return next.Mutate(ctx, mutation)
+ return next.Mutate(ctx, m)
})
}, ent.OpCreate)
}
diff --git a/internal/ent/hooks/helpers.go b/internal/ent/hooks/helpers.go
index 4e08395e..4692b85b 100644
--- a/internal/ent/hooks/helpers.go
+++ b/internal/ent/hooks/helpers.go
@@ -9,6 +9,6 @@ import (
// isDeleteOp checks if the mutation is a deletion operation.
// which includes soft delete, delete, and delete one.
-func isDeleteOp(ctx context.Context, mutation ent.Mutation) bool {
- return entx.CheckIsSoftDelete(ctx) || mutation.Op().Is(ent.OpDelete) || mutation.Op().Is(ent.OpDeleteOne)
+func isDeleteOp(ctx context.Context, m ent.Mutation) bool {
+ return entx.CheckIsSoftDelete(ctx) || m.Op().Is(ent.OpDelete) || m.Op().Is(ent.OpDeleteOne)
}
diff --git a/internal/ent/hooks/invite.go b/internal/ent/hooks/invite.go
index 285ff4ed..81579929 100644
--- a/internal/ent/hooks/invite.go
+++ b/internal/ent/hooks/invite.go
@@ -4,16 +4,15 @@ import (
"context"
"entgo.io/ent"
- ph "github.com/posthog/posthog-go"
"github.com/rs/zerolog/log"
+ "github.com/theopenlane/emailtemplates"
"github.com/theopenlane/iam/auth"
"github.com/theopenlane/iam/tokens"
- "github.com/theopenlane/utils/emails"
- "github.com/theopenlane/utils/marionette"
- "github.com/theopenlane/utils/sendgrid"
"github.com/theopenlane/utils/ulids"
+ "github.com/theopenlane/riverboat/pkg/jobs"
+
"github.com/theopenlane/core/internal/ent/generated"
"github.com/theopenlane/core/internal/ent/generated/hook"
"github.com/theopenlane/core/internal/ent/generated/invite"
@@ -47,12 +46,12 @@ func HookInvite() ent.Hook {
return nil, err
}
- // check if the invite already exists
- existingInvite, err := getInvite(ctx, m)
-
// attempt to do the mutation for a new user invite
var retValue ent.Value
+ // check if the invite already exists
+ existingInvite, err := getInvite(ctx, m)
+
// if the invite exists, update the token and resend
if existingInvite != nil && err == nil {
log.Info().Msg("invitation for user already exists")
@@ -72,33 +71,11 @@ func HookInvite() ent.Hook {
}
}
- // non-blocking queued email
+ // queue the email to be sent
if err := createInviteToSend(ctx, m); err != nil {
log.Error().Err(err).Msg("error sending email to user")
}
- orgID, _ := m.OwnerID()
- org, _ := m.Client().Organization.Get(ctx, orgID)
- reqID, _ := m.RequestorID()
- requestor, _ := m.Client().User.Get(ctx, reqID)
- email, _ := m.Recipient()
- role, _ := m.Role()
-
- props := ph.NewProperties().
- Set("organization_id", orgID).
- Set("organization_name", org.Name).
- Set("requestor_id", reqID).
- Set("recipient_email", email).
- Set("recipient_role", role)
-
- // if we have the requestor, add their name and email to the properties
- if requestor != nil {
- props.Set("requestor_name", requestor.FirstName).
- Set("requestor_email", requestor.Email)
- }
-
- m.Analytics.Event("organization_invite_created", props)
-
return retValue, err
})
}, ent.OpCreate)
@@ -170,27 +147,12 @@ func HookInviteAccepted() ent.Hook {
return retValue, err
}
- invite := &emails.Invite{
- OrgName: org.Name,
- Recipient: recipient,
- Role: string(role),
+ invite := emailtemplates.InviteTemplateData{
+ OrganizationName: org.Name,
+ Role: string(role),
}
- props := ph.NewProperties().
- Set("organization_id", org.ID).
- Set("organization_name", org.Name).
- Set("acceptor_email", recipient).
- Set("acceptor_id", userID)
-
- m.Analytics.Event("organization_invite_accepted", props)
-
- // send an email to recipient notifying them they've been added to an organization
- if err := m.Marionette.Queue(marionette.TaskFunc(func(ctx context.Context) error {
- return sendOrgAccepted(ctx, m, invite)
- }), marionette.WithErrorf("could not send invitation email to user %s", recipient),
- ); err != nil {
- log.Error().Err(err).Msg("unable to queue email for sending")
-
+ if err := createOrgInviteAcceptedToSend(ctx, m, recipient, invite); err != nil {
return retValue, err
}
@@ -275,7 +237,7 @@ func createInviteToSend(ctx context.Context, m *generated.InviteMutation) error
orgID, _ := m.OwnerID()
reqID, _ := m.RequestorID()
token, _ := m.Token()
- email, _ := m.Recipient()
+ emailAddress, _ := m.Recipient()
role, _ := m.Role()
org, err := m.Client().Organization.Get(ctx, orgID)
@@ -288,70 +250,56 @@ func createInviteToSend(ctx context.Context, m *generated.InviteMutation) error
return err
}
- invite := &emails.Invite{
- OrgName: org.Name,
- Token: token,
- Requestor: requestor.FirstName,
- Recipient: email,
- Role: string(role),
+ invite := emailtemplates.InviteTemplateData{
+ InviterName: requestor.FirstName,
+ OrganizationName: org.Name,
+ Role: string(role),
}
- if err := m.Marionette.Queue(marionette.TaskFunc(func(ctx context.Context) error {
- return sendOrgInvitationEmail(ctx, m, invite)
- }), marionette.WithErrorf("could not send invitation email to user %s", email),
- ); err != nil {
- log.Error().Err(err).Msg("unable to queue email for sending")
-
- return err
- }
-
- return nil
-}
-
-// sendOrgInvitationEmail composes the email metadata and sends via email manager
-func sendOrgInvitationEmail(ctx context.Context, m *generated.InviteMutation, i *emails.Invite) (err error) {
- data := emails.InviteData{
- InviterName: i.Requestor,
- OrgName: i.OrgName,
- EmailData: emails.EmailData{
- Sender: m.Emails.MustFromContact(),
- Recipient: sendgrid.Contact{
- Email: i.Recipient,
- },
- },
- }
+ email, err := m.Emailer.NewInviteEmail(emailtemplates.Recipient{
+ Email: emailAddress,
+ }, invite, token)
+ if err != nil {
+ log.Error().Err(err).Msg("error rendering email")
- if data.InviteURL, err = m.Emails.InviteURL(i.Token); err != nil {
return err
}
- msg, err := emails.InviteEmail(data)
+ // send the email
+ _, err = m.Job.Insert(ctx, jobs.EmailArgs{
+ Message: *email,
+ }, nil)
if err != nil {
+ log.Error().Err(err).Msg("error queueing email verification")
+
return err
}
- return m.Emails.Send(msg)
+ return nil
}
-// sendOrgAccepted composes the email metadata to notify the user they've been joined to the org
-func sendOrgAccepted(ctx context.Context, m *generated.InviteMutation, i *emails.Invite) (err error) {
- data := emails.InviteData{
- InviterName: i.Requestor,
- OrgName: i.OrgName,
- EmailData: emails.EmailData{
- Sender: m.Emails.MustFromContact(),
- Recipient: sendgrid.Contact{
- Email: i.Recipient,
- },
- },
+// createOrgInviteAcceptedToSend composes the email metadata and queues the email to be sent
+func createOrgInviteAcceptedToSend(ctx context.Context, m *generated.InviteMutation, recipient string, i emailtemplates.InviteTemplateData) error {
+ email, err := m.Emailer.NewInviteAcceptedEmail(emailtemplates.Recipient{
+ Email: recipient,
+ }, i)
+ if err != nil {
+ log.Error().Err(err).Msg("error rendering email")
+
+ return err
}
- msg, err := emails.InviteAccepted(data)
+ // send the email
+ _, err = m.Job.Insert(ctx, jobs.EmailArgs{
+ Message: *email,
+ }, nil)
if err != nil {
+ log.Error().Err(err).Msg("error queueing email verification")
+
return err
}
- return m.Emails.Send(msg)
+ return nil
}
var maxAttempts = 5
diff --git a/internal/ent/hooks/organization.go b/internal/ent/hooks/organization.go
index f7a2b6f0..af1e8c46 100644
--- a/internal/ent/hooks/organization.go
+++ b/internal/ent/hooks/organization.go
@@ -7,13 +7,12 @@ import (
"entgo.io/ent"
"github.com/rs/zerolog/log"
- dbx "github.com/theopenlane/dbx/pkg/dbxclient"
- dbxenums "github.com/theopenlane/dbx/pkg/enums"
"github.com/theopenlane/entx"
"github.com/theopenlane/iam/auth"
"github.com/theopenlane/iam/fgax"
"github.com/theopenlane/utils/gravatar"
- "github.com/theopenlane/utils/marionette"
+
+ "github.com/theopenlane/riverboat/pkg/jobs"
"github.com/theopenlane/core/internal/ent/generated"
"github.com/theopenlane/core/internal/ent/generated/hook"
@@ -25,33 +24,33 @@ import (
// HookOrganization runs on org mutations to set default values that are not provided
func HookOrganization() ent.Hook {
return hook.On(func(next ent.Mutator) ent.Mutator {
- return hook.OrganizationFunc(func(ctx context.Context, mutation *generated.OrganizationMutation) (generated.Value, error) {
+ return hook.OrganizationFunc(func(ctx context.Context, m *generated.OrganizationMutation) (generated.Value, error) {
// if this is a soft delete, skip this hook
if entx.CheckIsSoftDelete(ctx) {
- return next.Mutate(ctx, mutation)
+ return next.Mutate(ctx, m)
}
- if mutation.Op().Is(ent.OpCreate) {
+ if m.Op().Is(ent.OpCreate) {
// generate a default org setting schema if not provided
- if err := createOrgSettings(ctx, mutation); err != nil {
+ if err := createOrgSettings(ctx, m); err != nil {
return nil, err
}
// check if this is a child org, error if parent org is a personal org
- if err := personalOrgNoChildren(ctx, mutation); err != nil {
+ if err := personalOrgNoChildren(ctx, m); err != nil {
return nil, err
}
}
// set default display name and avatar if not provided
- setDefaultsOnMutations(mutation)
+ setDefaultsOnMutations(m)
- v, err := next.Mutate(ctx, mutation)
+ v, err := next.Mutate(ctx, m)
if err != nil {
return v, err
}
- if mutation.Op().Is(ent.OpCreate) {
+ if m.Op().Is(ent.OpCreate) {
orgCreated, ok := v.(*generated.Organization)
if !ok {
return nil, err
@@ -59,12 +58,12 @@ func HookOrganization() ent.Hook {
// create the admin organization member if not using an API token (which is not associated with a user)
// otherwise add the API token for admin access to the newly created organization
- if err := createOrgMemberOwner(ctx, orgCreated.ID, mutation); err != nil {
+ if err := createOrgMemberOwner(ctx, orgCreated.ID, m); err != nil {
return v, err
}
// create the database, if the org has a dedicated db and dbx is available
- if orgCreated.DedicatedDb && mutation.DBx != nil {
+ if orgCreated.DedicatedDb {
settings, err := orgCreated.Setting(ctx)
if err != nil {
log.Error().Err(err).Msg("unable to get organization settings")
@@ -72,13 +71,11 @@ func HookOrganization() ent.Hook {
return nil, err
}
- if err := mutation.Marionette.Queue(marionette.TaskFunc(func(ctx context.Context) error {
- return createDatabase(ctx, orgCreated.ID, settings.GeoLocation.String(), mutation)
- }), marionette.WithErrorf("could not send create the database for %s", orgCreated.Name),
- ); err != nil {
- log.Error().Err(err).Msg("unable to queue database creation")
-
- return v, err
+ if _, err := m.Job.Insert(ctx, jobs.DatabaseArgs{
+ OrganizationID: orgCreated.ID,
+ Location: settings.GeoLocation.String(),
+ }, nil); err != nil {
+ return nil, err
}
}
@@ -86,13 +83,13 @@ func HookOrganization() ent.Hook {
// if the org is not a personal org, as personal orgs are created during registration
// and sessions are already set
if !orgCreated.PersonalOrg {
- as := newAuthSession(mutation.SessionConfig, mutation.TokenManager)
+ as := newAuthSession(m.SessionConfig, m.TokenManager)
if err := updateUserAuthSession(ctx, as, orgCreated.ID); err != nil {
return v, err
}
- if err := postCreation(ctx, orgCreated, mutation); err != nil {
+ if err := postCreation(ctx, orgCreated, m); err != nil {
return v, err
}
}
@@ -106,29 +103,29 @@ func HookOrganization() ent.Hook {
// HookOrganizationDelete runs on org delete mutations to ensure the org can be deleted
func HookOrganizationDelete() ent.Hook {
return hook.On(func(next ent.Mutator) ent.Mutator {
- return hook.OrganizationFunc(func(ctx context.Context, mutation *generated.OrganizationMutation) (generated.Value, error) {
+ return hook.OrganizationFunc(func(ctx context.Context, m *generated.OrganizationMutation) (generated.Value, error) {
// by pass checks on invite or pre-allowed request
// this includes things like the edge-cleanup on user deletion
if _, allow := privacy.DecisionFromContext(ctx); allow {
- return next.Mutate(ctx, mutation)
+ return next.Mutate(ctx, m)
}
// ensure it's a soft delete or a hard delete, otherwise skip this hook
- if !isDeleteOp(ctx, mutation) {
- return next.Mutate(ctx, mutation)
+ if !isDeleteOp(ctx, m) {
+ return next.Mutate(ctx, m)
}
// validate the organization can be deleted
- if err := validateDeletion(ctx, mutation); err != nil {
+ if err := validateDeletion(ctx, m); err != nil {
return nil, err
}
- v, err := next.Mutate(ctx, mutation)
+ v, err := next.Mutate(ctx, m)
if err != nil {
return v, err
}
- newOrgID, err := updateUserDefaultOrgOnDelete(ctx, mutation)
+ newOrgID, err := updateUserDefaultOrgOnDelete(ctx, m)
// if we got an error, return it
// if we didn't get a new org id, keep going and don't
// update the session cookie
@@ -137,7 +134,7 @@ func HookOrganizationDelete() ent.Hook {
}
// if the deleted org was the current org, update the session cookie
- as := newAuthSession(mutation.SessionConfig, mutation.TokenManager)
+ as := newAuthSession(m.SessionConfig, m.TokenManager)
if err := updateUserAuthSession(ctx, as, newOrgID); err != nil {
return v, err
@@ -149,25 +146,25 @@ func HookOrganizationDelete() ent.Hook {
}
// setDefaultsOnMutations sets default values on mutations that are not provided
-func setDefaultsOnMutations(mutation *generated.OrganizationMutation) {
- if name, ok := mutation.Name(); ok {
- if displayName, ok := mutation.DisplayName(); ok {
+func setDefaultsOnMutations(m *generated.OrganizationMutation) {
+ if name, ok := m.Name(); ok {
+ if displayName, ok := m.DisplayName(); ok {
if displayName == "" {
- mutation.SetDisplayName(name)
+ m.SetDisplayName(name)
}
}
url := gravatar.New(name, nil)
- mutation.SetAvatarRemoteURL(url)
+ m.SetAvatarRemoteURL(url)
}
}
// createOrgSettings creates the default organization settings for a new org
-func createOrgSettings(ctx context.Context, mutation *generated.OrganizationMutation) error {
+func createOrgSettings(ctx context.Context, m *generated.OrganizationMutation) error {
// if this is empty generate a default org setting schema
- if _, exists := mutation.SettingID(); !exists {
+ if _, exists := m.SettingID(); !exists {
// sets up default org settings using schema defaults
- orgSettingID, err := defaultOrganizationSettings(ctx, mutation)
+ orgSettingID, err := defaultOrganizationSettings(ctx, m)
if err != nil {
log.Error().Err(err).Msg("error creating default organization settings")
@@ -175,27 +172,27 @@ func createOrgSettings(ctx context.Context, mutation *generated.OrganizationMuta
}
// add the org setting ID to the input
- mutation.SetSettingID(orgSettingID)
+ m.SetSettingID(orgSettingID)
}
return nil
}
// createEntityTypes creates the default entity types for a new org
-func createEntityTypes(ctx context.Context, orgID string, mutation *generated.OrganizationMutation) error {
- if len(mutation.EntConfig.EntityTypes) == 0 {
+func createEntityTypes(ctx context.Context, orgID string, m *generated.OrganizationMutation) error {
+ if len(m.EntConfig.EntityTypes) == 0 {
return nil
}
- builders := make([]*generated.EntityTypeCreate, 0, len(mutation.EntConfig.EntityTypes))
- for _, entityType := range mutation.EntConfig.EntityTypes {
- builders = append(builders, mutation.Client().EntityType.Create().
+ builders := make([]*generated.EntityTypeCreate, 0, len(m.EntConfig.EntityTypes))
+ for _, entityType := range m.EntConfig.EntityTypes {
+ builders = append(builders, m.Client().EntityType.Create().
SetName(entityType).
SetOwnerID(orgID),
)
}
- if err := mutation.Client().EntityType.CreateBulk(builders...).Exec(ctx); err != nil {
+ if err := m.Client().EntityType.CreateBulk(builders...).Exec(ctx); err != nil {
log.Error().Err(err).Msg("error creating entity types")
return err
@@ -205,7 +202,7 @@ func createEntityTypes(ctx context.Context, orgID string, mutation *generated.Or
}
// postCreation runs after an organization is created to perform additional setup
-func postCreation(ctx context.Context, orgCreated *generated.Organization, mutation *generated.OrganizationMutation) error {
+func postCreation(ctx context.Context, orgCreated *generated.Organization, m *generated.OrganizationMutation) error {
// capture the original org id, ignore error as this will not be set in all cases
originalOrg, _ := auth.GetOrganizationIDFromContext(ctx) // nolint: errcheck
@@ -215,7 +212,7 @@ func postCreation(ctx context.Context, orgCreated *generated.Organization, mutat
}
// create default entity types, if configured
- if err := createEntityTypes(ctx, orgCreated.ID, mutation); err != nil {
+ if err := createEntityTypes(ctx, orgCreated.ID, m); err != nil {
return err
}
@@ -230,14 +227,14 @@ func postCreation(ctx context.Context, orgCreated *generated.Organization, mutat
}
// validateDeletion ensures the organization can be deleted
-func validateDeletion(ctx context.Context, mutation *generated.OrganizationMutation) error {
- deletedID, ok := mutation.ID()
+func validateDeletion(ctx context.Context, m *generated.OrganizationMutation) error {
+ deletedID, ok := m.ID()
if !ok {
return nil
}
// do not allow deletion of personal orgs, these are deleted when the user is deleted
- deletedOrg, err := mutation.Client().Organization.Get(ctx, deletedID)
+ deletedOrg, err := m.Client().Organization.Get(ctx, deletedID)
if err != nil {
return err
}
@@ -252,19 +249,19 @@ func validateDeletion(ctx context.Context, mutation *generated.OrganizationMutat
}
// updateUserDefaultOrgOnDelete updates the user's default org if the org being deleted is the user's default org
-func updateUserDefaultOrgOnDelete(ctx context.Context, mutation *generated.OrganizationMutation) (string, error) {
+func updateUserDefaultOrgOnDelete(ctx context.Context, m *generated.OrganizationMutation) (string, error) {
currentUserID, err := auth.GetUserIDFromContext(ctx)
if err != nil {
return "", err
}
// check if this organization is the user's default org
- deletedOrgID, ok := mutation.ID()
+ deletedOrgID, ok := m.ID()
if !ok {
return "", nil
}
- return checkAndUpdateDefaultOrg(ctx, currentUserID, deletedOrgID, mutation.Client())
+ return checkAndUpdateDefaultOrg(ctx, currentUserID, deletedOrgID, m.Client())
}
// checkAndUpdateDefaultOrg checks if the old organization is the user's default org and updates it if needed
@@ -308,40 +305,11 @@ func checkAndUpdateDefaultOrg(ctx context.Context, userID string, oldOrgID strin
return userSetting.Edges.DefaultOrg.ID, nil
}
-// createDatabase creates a new database for the organization
-func createDatabase(ctx context.Context, orgID, geo string, mutation *generated.OrganizationMutation) error {
- // set default geo if not provided
- if geo == "" {
- geo = enums.Amer.String()
- }
-
- input := dbx.CreateDatabaseInput{
- OrganizationID: orgID,
- Geo: &geo,
- Provider: &dbxenums.Turso,
- }
-
- log.Debug().
- Str("org", input.OrganizationID).
- Str("geo", *input.Geo).
- Str("provider", input.Provider.String()).
- Msg("creating database")
-
- if _, err := mutation.DBx.CreateDatabase(ctx, input); err != nil {
- log.Error().Err(err).Msg("error creating database")
-
- return err
- }
-
- // create the database
- return nil
-}
-
// defaultOrganizationSettings creates the default organizations settings for a new org
-func defaultOrganizationSettings(ctx context.Context, mutation *generated.OrganizationMutation) (string, error) {
+func defaultOrganizationSettings(ctx context.Context, m *generated.OrganizationMutation) (string, error) {
input := generated.CreateOrganizationSettingInput{}
- organizationSetting, err := mutation.Client().OrganizationSetting.Create().SetInput(input).Save(ctx)
+ organizationSetting, err := m.Client().OrganizationSetting.Create().SetInput(input).Save(ctx)
if err != nil {
return "", err
}
@@ -351,12 +319,12 @@ func defaultOrganizationSettings(ctx context.Context, mutation *generated.Organi
// personalOrgNoChildren checks if the mutation is for a child org, and if so returns an error
// if the parent org is a personal org
-func personalOrgNoChildren(ctx context.Context, mutation *generated.OrganizationMutation) error {
+func personalOrgNoChildren(ctx context.Context, m *generated.OrganizationMutation) error {
// check if this is a child org, error if parent org is a personal org
- parentOrgID, ok := mutation.ParentID()
+ parentOrgID, ok := m.ParentID()
if ok {
// check if parent org is a personal org
- parentOrg, err := mutation.Client().Organization.Get(ctx, parentOrgID)
+ parentOrg, err := m.Client().Organization.Get(ctx, parentOrgID)
if err != nil {
return err
}
diff --git a/internal/ent/hooks/orgmembers.go b/internal/ent/hooks/orgmembers.go
index 9d73e965..3b8c2575 100644
--- a/internal/ent/hooks/orgmembers.go
+++ b/internal/ent/hooks/orgmembers.go
@@ -6,7 +6,6 @@ import (
"entgo.io/ent"
"github.com/99designs/gqlgen/graphql"
- ph "github.com/posthog/posthog-go"
"github.com/rs/zerolog/log"
"github.com/theopenlane/iam/auth"
@@ -19,14 +18,14 @@ import (
func HookOrgMembers() ent.Hook {
return hook.On(func(next ent.Mutator) ent.Mutator {
- return hook.OrgMembershipFunc(func(ctx context.Context, mutation *generated.OrgMembershipMutation) (generated.Value, error) {
+ return hook.OrgMembershipFunc(func(ctx context.Context, m *generated.OrgMembershipMutation) (generated.Value, error) {
// check role, if its not set the default is member
- role, _ := mutation.Role()
+ role, _ := m.Role()
if role == enums.RoleOwner {
- return next.Mutate(ctx, mutation)
+ return next.Mutate(ctx, m)
}
- orgID, exists := mutation.OrganizationID()
+ orgID, exists := m.OrganizationID()
if !exists || orgID == "" {
var err error
// get the organization based on authorized context if its not set
@@ -36,11 +35,11 @@ func HookOrgMembers() ent.Hook {
}
// set organization id in mutation
- mutation.SetOrganizationID(orgID)
+ m.SetOrganizationID(orgID)
}
// get the organization
- org, err := mutation.Client().Organization.Get(ctx, orgID)
+ org, err := m.Client().Organization.Get(ctx, orgID)
if err != nil {
log.Error().Err(err).Msg("failed to get organization")
@@ -52,45 +51,16 @@ func HookOrgMembers() ent.Hook {
return nil, ErrPersonalOrgsNoMembers
}
- retValue, err := next.Mutate(ctx, mutation)
+ retValue, err := next.Mutate(ctx, m)
if err != nil {
return nil, err
}
// check to see if the default org needs to be updated for the user
- if err := updateOrgMemberDefaultOrgOnCreate(ctx, mutation, orgID); err != nil {
+ if err := updateOrgMemberDefaultOrgOnCreate(ctx, m, orgID); err != nil {
return retValue, err
}
- if userID, ok := mutation.UserID(); ok {
- role, _ := mutation.Role()
-
- // allow the user to be pulled directly with a GET User, which is not allowed by default
- // the traverser will not allow this, so we need to create a new context
- allowCtx := privacy.DecisionContext(ctx, privacy.Allow)
-
- user, err := mutation.Client().User.Get(allowCtx, userID)
- if err != nil {
- log.Error().Err(err).Msg("failed to get user")
-
- return nil, err
- }
-
- orgName, err := auth.GetOrganizationNameFromContext(ctx)
- if err != nil {
- log.Error().Err(err).Msg("failed to get organization name from context")
-
- return nil, err
- }
-
- props := ph.NewProperties().
- Set("organization_name", orgName).
- Set("user_name", user.FirstName+user.LastName).
- Set("join_role", role.String())
-
- mutation.Analytics.Event("org_membership", props)
- }
-
return retValue, err
})
}, ent.OpCreate)
@@ -99,35 +69,35 @@ func HookOrgMembers() ent.Hook {
// HookOrgMembersDelete is a hook that runs during the delete operation of an org membership
func HookOrgMembersDelete() ent.Hook {
return hook.On(func(next ent.Mutator) ent.Mutator {
- return hook.OrgMembershipFunc(func(ctx context.Context, mutation *generated.OrgMembershipMutation) (generated.Value, error) {
+ return hook.OrgMembershipFunc(func(ctx context.Context, m *generated.OrgMembershipMutation) (generated.Value, error) {
// we only want to do this on direct deleteOrgMembership operations
// deleteOrganization will be handled by the organization hook
rootFieldCtx := graphql.GetRootFieldContext(ctx)
if rootFieldCtx == nil || rootFieldCtx.Object != "deleteOrgMembership" {
- return next.Mutate(ctx, mutation)
+ return next.Mutate(ctx, m)
}
// get the existing org membership
- id, ok := mutation.ID()
+ id, ok := m.ID()
if !ok {
return nil, fmt.Errorf("%w: %s", ErrInvalidInput, "id is required")
}
// get the org membership
- orgMembership, err := mutation.Client().OrgMembership.Get(ctx, id)
+ orgMembership, err := m.Client().OrgMembership.Get(ctx, id)
if err != nil {
return nil, err
}
// execute the delete operation
- retValue, err := next.Mutate(ctx, mutation)
+ retValue, err := next.Mutate(ctx, m)
if err != nil {
return nil, err
}
// check to see if the default org needs to be updated for the user
allowCtx := privacy.DecisionContext(ctx, privacy.Allow)
- if _, err = checkAndUpdateDefaultOrg(allowCtx, orgMembership.UserID, orgMembership.OrganizationID, mutation.Client()); err != nil {
+ if _, err = checkAndUpdateDefaultOrg(allowCtx, orgMembership.UserID, orgMembership.OrganizationID, m.Client()); err != nil {
return nil, err
}
@@ -138,9 +108,9 @@ func HookOrgMembersDelete() ent.Hook {
// updateOrgMemberDefaultOrgOnCreate updates the user's default org if the user has no default org or
// the default org is their personal org
-func updateOrgMemberDefaultOrgOnCreate(ctx context.Context, mutation *generated.OrgMembershipMutation, orgID string) error {
+func updateOrgMemberDefaultOrgOnCreate(ctx context.Context, m *generated.OrgMembershipMutation, orgID string) error {
// get the user id from the mutation, this is a required field
- userID, ok := mutation.UserID()
+ userID, ok := m.UserID()
if !ok {
// this should never happen because the mutation should have already failed
return fmt.Errorf("%w: %s", ErrInvalidInput, "user id is required")
@@ -150,5 +120,5 @@ func updateOrgMemberDefaultOrgOnCreate(ctx context.Context, mutation *generated.
// to update the default org
allowCtx := privacy.DecisionContext(ctx, privacy.Allow)
- return updateDefaultOrgIfPersonal(allowCtx, userID, orgID, mutation.Client())
+ return updateDefaultOrgIfPersonal(allowCtx, userID, orgID, m.Client())
}
diff --git a/internal/ent/hooks/passwordresettoken.go b/internal/ent/hooks/passwordresettoken.go
index 06d1b793..787ee4c3 100644
--- a/internal/ent/hooks/passwordresettoken.go
+++ b/internal/ent/hooks/passwordresettoken.go
@@ -13,13 +13,13 @@ import (
// HookPasswordResetToken runs on reset token mutations and sets expires
func HookPasswordResetToken() ent.Hook {
return hook.On(func(next ent.Mutator) ent.Mutator {
- return hook.PasswordResetTokenFunc(func(ctx context.Context, mutation *generated.PasswordResetTokenMutation) (generated.Value, error) {
- expires, _ := mutation.TTL()
+ return hook.PasswordResetTokenFunc(func(ctx context.Context, m *generated.PasswordResetTokenMutation) (generated.Value, error) {
+ expires, _ := m.TTL()
if expires.IsZero() {
- mutation.SetTTL(time.Now().UTC().Add(time.Minute * 15).Truncate(time.Microsecond)) //nolint:mnd
+ m.SetTTL(time.Now().UTC().Add(time.Minute * 15).Truncate(time.Microsecond)) //nolint:mnd
}
- return next.Mutate(ctx, mutation)
+ return next.Mutate(ctx, m)
})
}, ent.OpCreate)
}
diff --git a/internal/ent/hooks/personalaccesstoken.go b/internal/ent/hooks/personalaccesstoken.go
index a252b407..e83ad3ff 100644
--- a/internal/ent/hooks/personalaccesstoken.go
+++ b/internal/ent/hooks/personalaccesstoken.go
@@ -18,16 +18,16 @@ const (
// HookCreatePersonalAccessToken runs on access token mutations and sets the owner id
func HookCreatePersonalAccessToken() ent.Hook {
return hook.On(func(next ent.Mutator) ent.Mutator {
- return hook.PersonalAccessTokenFunc(func(ctx context.Context, mutation *generated.PersonalAccessTokenMutation) (generated.Value, error) {
+ return hook.PersonalAccessTokenFunc(func(ctx context.Context, m *generated.PersonalAccessTokenMutation) (generated.Value, error) {
userID, err := auth.GetUserIDFromContext(ctx)
if err != nil {
return nil, err
}
// set user on the token
- mutation.SetOwnerID(userID)
+ m.SetOwnerID(userID)
- return next.Mutate(ctx, mutation)
+ return next.Mutate(ctx, m)
})
}, ent.OpCreate)
}
@@ -35,14 +35,14 @@ func HookCreatePersonalAccessToken() ent.Hook {
// HookUpdatePersonalAccessToken runs on access token update and redacts the token
func HookUpdatePersonalAccessToken() ent.Hook {
return hook.On(func(next ent.Mutator) ent.Mutator {
- return hook.PersonalAccessTokenFunc(func(ctx context.Context, mutation *generated.PersonalAccessTokenMutation) (generated.Value, error) {
+ return hook.PersonalAccessTokenFunc(func(ctx context.Context, m *generated.PersonalAccessTokenMutation) (generated.Value, error) {
// do not allow user to be changed
- _, ok := mutation.OwnerID()
+ _, ok := m.OwnerID()
if ok {
- mutation.ClearOwner()
+ m.ClearOwner()
}
- retVal, err := next.Mutate(ctx, mutation)
+ retVal, err := next.Mutate(ctx, m)
if err != nil {
return nil, err
}
diff --git a/internal/ent/hooks/subscriber.go b/internal/ent/hooks/subscriber.go
index d19f0ff9..9ab56632 100644
--- a/internal/ent/hooks/subscriber.go
+++ b/internal/ent/hooks/subscriber.go
@@ -5,11 +5,10 @@ import (
"entgo.io/ent"
- "github.com/theopenlane/utils/emails"
- "github.com/theopenlane/utils/marionette"
- "github.com/theopenlane/utils/sendgrid"
-
+ "github.com/rs/zerolog/log"
+ "github.com/theopenlane/emailtemplates"
"github.com/theopenlane/iam/tokens"
+ "github.com/theopenlane/riverboat/pkg/jobs"
"github.com/theopenlane/core/internal/ent/generated"
"github.com/theopenlane/core/internal/ent/generated/hook"
@@ -45,9 +44,10 @@ func HookSubscriber() ent.Hook {
// queueSubscriberEmail queues the email to be sent to the subscriber
func queueSubscriberEmail(ctx context.Context, m *generated.SubscriberMutation) error {
// Get the details from the mutation, these will never be empty because they are set in the hook
+ // or are required fields
orgID, _ := m.OwnerID()
tok, _ := m.Token()
- email, _ := m.Email()
+ e, _ := m.Email()
// Get the organization name
org, err := m.Client().Organization.Get(ctx, orgID)
@@ -55,44 +55,26 @@ func queueSubscriberEmail(ctx context.Context, m *generated.SubscriberMutation)
return err
}
- // send emails via Marionette as to not create blocking operations in the server
- if err := m.Marionette.Queue(marionette.TaskFunc(func(ctx context.Context) error {
- return sendSubscriberEmail(m, org.Name, tok)
- }), marionette.WithRetries(3), //nolint:mnd
- marionette.WithErrorf("could not send subscriber verification email to user %s", email),
- ); err != nil {
- return err
- }
-
- return nil
-}
-
-// sendSubscriberEmail sends an email to confirm a user's subscription
-func sendSubscriberEmail(m *generated.SubscriberMutation, orgName, token string) error {
- e, _ := m.Email()
-
- data := emails.SubscriberEmailData{
- OrgName: orgName,
- EmailData: emails.EmailData{
- Sender: m.Emails.MustFromContact(),
- Recipient: sendgrid.Contact{
- Email: e,
- },
- },
- }
+ email, err := m.Emailer.NewSubscriberEmail(emailtemplates.Recipient{
+ Email: e,
+ }, org.Name, tok)
+ if err != nil {
+ log.Error().Err(err).Msg("error rendering email")
- var err error
- if data.VerifySubscriberURL, err = m.Emails.SubscriberVerifyURL(token); err != nil {
return err
}
- msg, err := emails.SubscribeEmail(data)
+ // send the email via the job queue
+ _, err = m.Job.Insert(ctx, jobs.EmailArgs{
+ Message: *email,
+ }, nil)
if err != nil {
+ log.Error().Err(err).Msg("error queueing email verification")
+
return err
}
- // Send the email
- return m.Emails.Send(msg)
+ return nil
}
// createVerificationToken creates a new email verification token for the user
diff --git a/internal/ent/hooks/tfasettings.go b/internal/ent/hooks/tfasettings.go
index 70bd8f00..d89ae283 100644
--- a/internal/ent/hooks/tfasettings.go
+++ b/internal/ent/hooks/tfasettings.go
@@ -18,31 +18,31 @@ import (
func HookEnableTFA() ent.Hook {
return hook.On(func(next ent.Mutator) ent.Mutator {
- return hook.TFASettingFunc(func(ctx context.Context, mutation *generated.TFASettingMutation) (generated.Value, error) {
+ return hook.TFASettingFunc(func(ctx context.Context, m *generated.TFASettingMutation) (generated.Value, error) {
// once verified, create recovery codes
- verified, ok := mutation.Verified()
+ verified, ok := m.Verified()
// if recovery codes are cleared, generate new ones
gtx := graphql.GetOperationContext(ctx)
regenBackupCodes, _ := gtx.Variables["input"].(map[string]interface{})["regenBackupCodes"].(bool)
if (ok && verified) || regenBackupCodes {
- u, err := constructTOTPUser(ctx, mutation)
+ u, err := constructTOTPUser(ctx, m)
if err != nil {
return nil, err
}
- u.TFASecret, err = mutation.TOTP.TOTPManager.TOTPSecret(u)
+ u.TFASecret, err = m.TOTP.TOTPManager.TOTPSecret(u)
if err != nil {
return nil, err
}
- codes := mutation.TOTP.TOTPManager.GenerateRecoveryCodes()
- mutation.SetRecoveryCodes(codes)
+ codes := m.TOTP.TOTPManager.GenerateRecoveryCodes()
+ m.SetRecoveryCodes(codes)
if verified {
// update user settings
- _, err := mutation.Client().UserSetting.Update().
+ _, err := m.Client().UserSetting.Update().
Where(usersetting.UserID(u.ID)).
SetIsTfaEnabled(true). // set tfa enabled to true
Save(ctx)
@@ -52,14 +52,14 @@ func HookEnableTFA() ent.Hook {
}
}
- return next.Mutate(ctx, mutation)
+ return next.Mutate(ctx, m)
})
}, ent.OpUpdate|ent.OpUpdateOne)
}
// constructTOTPUser constructs a TOTP user object from the mutation
-func constructTOTPUser(ctx context.Context, mutation *generated.TFASettingMutation) (*totp.User, error) {
- userID, ok := mutation.OwnerID()
+func constructTOTPUser(ctx context.Context, m *generated.TFASettingMutation) (*totp.User, error) {
+ userID, ok := m.OwnerID()
if !ok {
var err error
@@ -74,7 +74,7 @@ func constructTOTPUser(ctx context.Context, mutation *generated.TFASettingMutati
}
// get the user object
- user, err := mutation.Client().User.Get(ctx, userID)
+ user, err := m.Client().User.Get(ctx, userID)
if err != nil {
return nil, err
}
@@ -86,9 +86,9 @@ func constructTOTPUser(ctx context.Context, mutation *generated.TFASettingMutati
}
// set the TFA settings
- u.IsEmailOTPAllowed, _ = mutation.EmailOtpAllowed()
- u.IsPhoneOTPAllowed, _ = mutation.PhoneOtpAllowed()
- u.IsTOTPAllowed, _ = mutation.TotpAllowed()
+ u.IsEmailOTPAllowed, _ = m.EmailOtpAllowed()
+ u.IsPhoneOTPAllowed, _ = m.PhoneOtpAllowed()
+ u.IsTOTPAllowed, _ = m.TotpAllowed()
// setup account name fields
u.Email = sql.NullString{
diff --git a/internal/ent/hooks/user.go b/internal/ent/hooks/user.go
index 3ede3b9f..395f5955 100644
--- a/internal/ent/hooks/user.go
+++ b/internal/ent/hooks/user.go
@@ -30,8 +30,8 @@ const (
// HookUser runs on user mutations validate and hash the password and set default values that are not provided
func HookUser() ent.Hook {
return hook.On(func(next ent.Mutator) ent.Mutator {
- return hook.UserFunc(func(ctx context.Context, mutation *generated.UserMutation) (generated.Value, error) {
- if password, ok := mutation.Password(); ok {
+ return hook.UserFunc(func(ctx context.Context, m *generated.UserMutation) (generated.Value, error) {
+ if password, ok := m.Password(); ok {
// validate password before its encrypted
if passwd.Strength(password) < passwd.Moderate {
return nil, auth.ErrPasswordTooWeak
@@ -42,37 +42,37 @@ func HookUser() ent.Hook {
return nil, err
}
- mutation.SetPassword(hash)
+ m.SetPassword(hash)
}
- if email, ok := mutation.Email(); ok {
+ if email, ok := m.Email(); ok {
// use the email without the domain as the display name, if not provided on creation
- if mutation.Op().Is(ent.OpCreate) {
- displayName, _ := mutation.DisplayName()
+ if m.Op().Is(ent.OpCreate) {
+ displayName, _ := m.DisplayName()
if displayName == "" {
displayName := strings.Split(email, "@")[0]
- mutation.SetDisplayName(displayName)
+ m.SetDisplayName(displayName)
}
}
}
// user settings are required, if this is empty generate a default setting schema
- if mutation.Op().Is(ent.OpCreate) {
- settingID, _ := mutation.SettingID()
+ if m.Op().Is(ent.OpCreate) {
+ settingID, _ := m.SettingID()
if settingID == "" {
// sets up default user settings using schema defaults
- userSettingID, err := defaultUserSettings(ctx, mutation)
+ userSettingID, err := defaultUserSettings(ctx, m)
if err != nil {
return nil, err
}
// add the user setting ID to the input
- mutation.SetSettingID(userSettingID)
+ m.SetSettingID(userSettingID)
}
}
- v, err := next.Mutate(ctx, mutation)
+ v, err := next.Mutate(ctx, m)
if err != nil {
return nil, err
}
@@ -82,11 +82,11 @@ func HookUser() ent.Hook {
return nil, err
}
- if mutation.Op().Is(ent.OpCreate) {
+ if m.Op().Is(ent.OpCreate) {
userCreated.Sub = userCreated.ID
// set the subject to the user id
- if _, err := mutation.Client().User.
+ if _, err := m.Client().User.
UpdateOneID(userCreated.ID).
SetSub(userCreated.Sub).
Save(ctx); err != nil {
@@ -94,7 +94,7 @@ func HookUser() ent.Hook {
}
// when a user is created, we create a personal user org
- setting, err := createPersonalOrg(ctx, mutation.Client(), userCreated)
+ setting, err := createPersonalOrg(ctx, m.Client(), userCreated)
if err != nil {
return nil, err
}
@@ -110,29 +110,29 @@ func HookUser() ent.Hook {
// HookDeleteUser runs on user deletions to clean up personal organizations
func HookDeleteUser() ent.Hook {
return func(next ent.Mutator) ent.Mutator {
- return hook.UserFunc(func(ctx context.Context, mutation *generated.UserMutation) (generated.Value, error) {
- if mutation.Op().Is(ent.OpDelete|ent.OpDeleteOne) || entx.CheckIsSoftDelete(ctx) {
- userID, _ := mutation.ID()
+ return hook.UserFunc(func(ctx context.Context, m *generated.UserMutation) (generated.Value, error) {
+ if m.Op().Is(ent.OpDelete|ent.OpDeleteOne) || entx.CheckIsSoftDelete(ctx) {
+ userID, _ := m.ID()
// get the personal org id
- user, err := mutation.Client().User.Get(ctx, userID)
+ user, err := m.Client().User.Get(ctx, userID)
if err != nil {
return nil, err
}
- personalOrgIDs, err := mutation.Client().User.QueryOrganizations(user).Where(organization.PersonalOrg(true)).IDs(ctx)
+ personalOrgIDs, err := m.Client().User.QueryOrganizations(user).Where(organization.PersonalOrg(true)).IDs(ctx)
if err != nil {
return nil, err
}
// run the mutation first
- v, err := next.Mutate(ctx, mutation)
+ v, err := next.Mutate(ctx, m)
if err != nil {
return nil, err
}
// cleanup personal org(s)
allowCtx := privacy.DecisionContext(ctx, privacy.Allow)
- if _, err := mutation.Client().
+ if _, err := m.Client().
Organization.
Delete().
Where(organization.IDIn(personalOrgIDs...)).
@@ -143,7 +143,7 @@ func HookDeleteUser() ent.Hook {
return v, err
}
- return next.Mutate(ctx, mutation)
+ return next.Mutate(ctx, m)
})
}
}
diff --git a/internal/ent/hooks/usersettings.go b/internal/ent/hooks/usersettings.go
index c880f715..707ddccb 100644
--- a/internal/ent/hooks/usersettings.go
+++ b/internal/ent/hooks/usersettings.go
@@ -23,33 +23,33 @@ import (
// HookUserSetting runs on user settings mutations and validates input on update
func HookUserSetting() ent.Hook {
return hook.On(func(next ent.Mutator) ent.Mutator {
- return hook.UserSettingFunc(func(ctx context.Context, mutation *generated.UserSettingMutation) (generated.Value, error) {
- org, ok := mutation.DefaultOrgID()
- if ok && !allowDefaultOrgUpdate(ctx, mutation, org) {
+ return hook.UserSettingFunc(func(ctx context.Context, m *generated.UserSettingMutation) (generated.Value, error) {
+ org, ok := m.DefaultOrgID()
+ if ok && !allowDefaultOrgUpdate(ctx, m, org) {
return nil, rout.InvalidField(rout.ErrOrganizationNotFound)
}
// delete tfa setting if tfa is disabled
- tfaEnabled, ok := mutation.IsTfaEnabled()
+ tfaEnabled, ok := m.IsTfaEnabled()
if ok && !tfaEnabled {
userID, err := auth.GetUserIDFromContext(ctx)
if err != nil {
return nil, err
}
- _, err = mutation.Client().TFASetting.Delete().Where(tfasetting.OwnerID(userID)).Exec(ctx)
+ _, err = m.Client().TFASetting.Delete().Where(tfasetting.OwnerID(userID)).Exec(ctx)
if err != nil {
return nil, err
}
}
- return next.Mutate(ctx, mutation)
+ return next.Mutate(ctx, m)
})
}, ent.OpUpdate|ent.OpUpdateOne)
}
// allowDefaultOrgUpdate checks if the user has access to the organization being updated as their default org
-func allowDefaultOrgUpdate(ctx context.Context, mutation *generated.UserSettingMutation, orgID string) bool {
+func allowDefaultOrgUpdate(ctx context.Context, m *generated.UserSettingMutation, orgID string) bool {
// allow if explicitly allowed
if _, allow := privacy.DecisionFromContext(ctx); allow {
return true
@@ -62,9 +62,9 @@ func allowDefaultOrgUpdate(ctx context.Context, mutation *generated.UserSettingM
// ensure user has access to the organization
// the ID is always set on update
- userSettingID, _ := mutation.ID()
+ userSettingID, _ := m.ID()
- owner, err := mutation.Client().
+ owner, err := m.Client().
User.
Query().
Where(
@@ -81,7 +81,7 @@ func allowDefaultOrgUpdate(ctx context.Context, mutation *generated.UserSettingM
ObjectID: orgID,
}
- allow, err := mutation.Authz.CheckOrgReadAccess(ctx, req)
+ allow, err := m.Authz.CheckOrgReadAccess(ctx, req)
if err != nil {
return false
}
diff --git a/internal/ent/templates/client.tmpl b/internal/ent/templates/client.tmpl
new file mode 100644
index 00000000..dc7a88aa
--- /dev/null
+++ b/internal/ent/templates/client.tmpl
@@ -0,0 +1,76 @@
+{{/* A template for adding additional client fields/options. */}}
+
+{{- define "import/additional/stdsql" -}}
+ stdsql "database/sql"
+{{- end -}}
+
+
+{{ define "client/additional/driver/dialect" }}
+ // Dialect returns the driver dialect.
+ func(c *Client) Dialect() string {
+ return c.driver.Dialect()
+ }
+
+ // Driver returns the underlying driver.
+ func(c *Client) Driver() dialect.Driver {
+ return c.driver
+ }
+
+ // DB returns the underlying *sql.DB.
+ func (c *Client) DB() *stdsql.DB {
+ switch c.driver.(type) {
+ case *sql.Driver: // default
+ return c.driver.( *sql.Driver).DB()
+ case *entcache.Driver: // when using entcache we need to unwrap the driver
+ return c.driver.(*entcache.Driver).Driver.(*sql.Driver).DB()
+ case *dialect.DebugDriver: // when the ent debug driver is used
+ driver := c.driver.(*dialect.DebugDriver)
+
+ switch driver.Driver.(type) {
+ case *sql.Driver: // default
+ return driver.Driver.(*sql.Driver).DB()
+ case *entcache.Driver: // when using entcache we need to unwrap the driver
+ return driver.Driver.(*entcache.Driver).Driver.(*sql.Driver).DB()
+ default:
+ panic(fmt.Sprintf("ent: unknown driver type: %T", driver))
+ }
+ default:
+ panic(fmt.Sprintf("ent: unknown driver type: %T", c.driver))
+ }
+ }
+{{ end }}
+
+{{ define "client/additional/close" }}
+// CloseAll closes the all database client connections
+func (c *Client) CloseAll() error {
+ if err := c.Job.Close(); err != nil {
+ return err
+ }
+
+ return c.Close()
+}
+{{ end }}
+
+{{ define "client/fields/additional/config" }}
+ // Config is the db client configuration
+ Config *entx.EntClientConfig
+{{ end }}
+
+{{ define "client/fields/additional/job" }}
+ // Job is the job client to insert jobs into the queue.
+ Job riverqueue.JobClient
+{{ end }}
+
+{{ define "client/additional/job" }}
+// WithJobClient adds the job client to the database client based on the configuration.
+func (c *Client) WithJobClient() {
+ c.Job = NewJobClient(c.config)
+}
+
+// NewJobClient returns a new job client based on the configuration.
+func NewJobClient(c config) riverqueue.JobClient {
+ return c.Job
+}
+{{ end }}
+
+
diff --git a/internal/ent/templates/config.tmpl b/internal/ent/templates/config.tmpl
new file mode 100644
index 00000000..8519906c
--- /dev/null
+++ b/internal/ent/templates/config.tmpl
@@ -0,0 +1,20 @@
+{{/* A template for adding additional config fields/options. */}}
+
+{{ define "config/fields/job" -}}
+ // Job is the job client to insert jobs into the queue.
+ Job riverqueue.JobClient
+{{ end }}
+
+{{ define "config/options/job" }}
+ // Job option added by the client template to add the job client.
+ func Job(ctx context.Context, opts ...riverqueue.Option) Option {
+ return func(c *config) {
+ var err error
+
+ c.Job, err = riverqueue.New(ctx, opts...)
+ if err != nil {
+ panic(err)
+ }
+ }
+ }
+{{ end }}
diff --git a/internal/entdb/client.go b/internal/entdb/client.go
index ea868a89..342ba287 100644
--- a/internal/entdb/client.go
+++ b/internal/entdb/client.go
@@ -13,12 +13,15 @@ import (
"github.com/pressly/goose/v3"
"github.com/rs/zerolog/log"
"github.com/theopenlane/entx"
+ "github.com/theopenlane/riverboat/pkg/riverqueue"
"github.com/theopenlane/utils/testutils"
migratedb "github.com/theopenlane/core/db"
ent "github.com/theopenlane/core/internal/ent/generated"
"github.com/theopenlane/core/internal/ent/interceptors"
+
+ _ "github.com/jackc/pgx/v5/stdlib" // add pgx driver
)
const (
@@ -35,8 +38,8 @@ type client struct {
sc *ent.Client
}
-// NewMultiDriverDBClient returns a ent client with a primary and secondary, if configured, write database
-func NewMultiDriverDBClient(ctx context.Context, c entx.Config, opts []ent.Option) (*ent.Client, *entx.EntClientConfig, error) {
+// New returns a ent client with a primary and secondary, if configured, write database
+func New(ctx context.Context, c entx.Config, jobOpts []riverqueue.Option, opts ...ent.Option) (*ent.Client, error) {
client := &client{
config: &c,
}
@@ -49,7 +52,7 @@ func NewMultiDriverDBClient(ctx context.Context, c entx.Config, opts []ent.Optio
entConfig, err := entx.NewDBConfig(c, dbOpts...)
if err != nil {
- return nil, nil, err
+ return nil, err
}
// Decorates the sql.Driver with entcache.Driver on the primaryDB
@@ -65,7 +68,7 @@ func NewMultiDriverDBClient(ctx context.Context, c entx.Config, opts []ent.Optio
if err := client.runMigrations(ctx); err != nil {
log.Error().Err(err).Msg("failed running migrations")
- return nil, nil, err
+ return nil, err
}
}
@@ -85,7 +88,7 @@ func NewMultiDriverDBClient(ctx context.Context, c entx.Config, opts []ent.Optio
if err := client.runMigrations(ctx); err != nil {
log.Error().Err(err).Msg("failed running migrations")
- return nil, nil, err
+ return nil, err
}
}
@@ -97,6 +100,9 @@ func NewMultiDriverDBClient(ctx context.Context, c entx.Config, opts []ent.Optio
cOpts = append(cOpts, opts...)
+ // add job client to the config
+ cOpts = append(cOpts, ent.Job(ctx, jobOpts...))
+
if c.Debug {
cOpts = append(cOpts,
ent.Log(log.Print),
@@ -105,19 +111,24 @@ func NewMultiDriverDBClient(ctx context.Context, c entx.Config, opts []ent.Optio
)
}
- ec := ent.NewClient(cOpts...)
+ db := ent.NewClient(cOpts...)
+
+ db.Config = entConfig
// add authz hooks
- ec.WithAuthz()
+ db.WithAuthz()
+
+ // add job client to the client
+ db.WithJobClient()
if c.EnableHistory {
// add history hooks
- ec.WithHistory()
+ db.WithHistory()
}
- ec.Intercept(interceptors.QueryLogger())
+ db.Intercept(interceptors.QueryLogger())
- return ec, entConfig, nil
+ return db, nil
}
// runMigrations runs the migrations based on the configured migration provider on startup
@@ -212,7 +223,7 @@ func NewTestFixture() *testutils.TestFixture {
}
// NewTestClient creates a entdb client that can be used for TEST purposes ONLY
-func NewTestClient(ctx context.Context, ctr *testutils.TestFixture, entOpts []ent.Option) (*ent.Client, error) {
+func NewTestClient(ctx context.Context, ctr *testutils.TestFixture, jobOpts []riverqueue.Option, entOpts []ent.Option) (*ent.Client, error) {
dbconf := entx.Config{
Debug: true,
DriverName: ctr.Dialect,
@@ -221,18 +232,21 @@ func NewTestClient(ctx context.Context, ctr *testutils.TestFixture, entOpts []en
CacheTTL: 0 * time.Second, // do not cache results in tests
}
- // Create the ent client
+ // Create the db client
var db *ent.Client
// Retry the connection to the database to ensure it is up and running
var err error
+ // run migrations for tests
+ jobOpts = append(jobOpts, riverqueue.WithRunMigrations(true))
+
// If a test container is used, retry the connection to the database to ensure it is up and running
if ctr.Pool != nil {
err = ctr.Pool.Retry(func() error {
log.Info().Msg("connecting to database...")
- db, _, err = NewMultiDriverDBClient(ctx, dbconf, entOpts)
+ db, err = New(ctx, dbconf, jobOpts, entOpts...)
if err != nil {
log.Info().Err(err).Msg("retrying connection to database...")
}
@@ -240,7 +254,7 @@ func NewTestClient(ctx context.Context, ctr *testutils.TestFixture, entOpts []en
return err
})
} else {
- db, _, err = NewMultiDriverDBClient(ctx, dbconf, entOpts)
+ db, err = New(ctx, dbconf, jobOpts, entOpts...)
}
if err != nil {
diff --git a/internal/graphapi/analytics.go b/internal/graphapi/analytics.go
deleted file mode 100644
index b11c8b32..00000000
--- a/internal/graphapi/analytics.go
+++ /dev/null
@@ -1,223 +0,0 @@
-package graphapi
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "strings"
-
- ph "github.com/posthog/posthog-go"
- "github.com/rs/zerolog/log"
- "github.com/theopenlane/utils/slack"
-
- ent "github.com/theopenlane/core/internal/ent/generated"
- "github.com/theopenlane/core/internal/ent/generated/integration"
- "github.com/theopenlane/core/internal/ent/generated/webhook"
- "github.com/theopenlane/core/pkg/events/soiree"
-)
-
-// CreateEvent creates an event for the mutation with the properties
-func CreateEvent(ctx context.Context, c *ent.Client, m ent.Mutation, v ent.Value) {
- pool := soiree.NewPondPool(100, 1000)
- e := soiree.NewEventPool(soiree.WithPool(pool))
-
- out, err := parseValue(v)
- if err != nil {
- return
- }
-
- obj := strings.ToLower(m.Type())
- action := getOp(m)
-
- // debug log the event
- log.Debug().Str("object", obj).Str("action", action).Msg("tracking event")
-
- event := fmt.Sprintf("%s.%sd", obj, action)
- e.EnsureTopic(event)
-
- id, ok := out["id"]
- if !ok {
- // keep going
- return
- }
-
- i, ok := id.(string)
- if !ok {
- // keep going
- return
- }
-
- // Set properties for the event
- // all events will have the id
- props := ph.NewProperties().
- Set(fmt.Sprintf("%s_id", obj), i)
-
- payload := map[string]string{"key": "value"}
- sEvent := soiree.NewBaseEvent(event, payload)
-
- // set the name if it exists
- name, ok := out["name"]
- if ok {
- props.Set(fmt.Sprintf("%s_name", obj), name)
- payload["name"] = name.(string)
- }
-
- // set the first name if it exists
- fName, ok := out["first_name"]
- if ok {
- props.Set("first_name", fName)
- payload["first_name"] = fName.(string)
- }
-
- // set the last name if it exists
- lName, ok := out["last_name"]
- if ok {
- props.Set("last_name", lName)
- payload["last_name"] = lName.(string)
- }
-
- // set the email if it exists
- email, ok := out["email"]
- if ok {
- props.Set("email", email)
- payload["email"] = email.(string)
- }
-
- authprovider, ok := out["auth_provider"]
- if ok {
- props.Set("auth_provider", authprovider)
- payload["auth_provider"] = authprovider.(string)
- }
-
- userCreatedListener := userCreatedListener(ctx, c, sEvent)
- orgCreatedListener := orgCreatedListener(ctx, c, sEvent)
-
- _, err = e.On("user.created", userCreatedListener)
- if err != nil {
- return
- }
-
- _, err = e.On("organization.created", orgCreatedListener)
- if err != nil {
- return
- }
-
- e.Emit(event, payload)
-
- c.Analytics.Event(event, props)
-
- // debug log the event
- log.Debug().Str("event", event).
- Interface("props", props).
- Msg("event tracked")
-}
-
-// trackedEvent returns true if the mutation should be a tracked event
-// for now, lets just track high level create and delete events
-// TODO: make these configurable by integration
-func TrackedEvent(m ent.Mutation) bool {
- switch m.Type() {
- case "User", "Organization", "Group", "Subscriber":
- switch getOp(m) {
- case ActionCreate, ActionDelete:
- return true
- }
- return false
- }
-
- return false
-}
-
-// getOp returns the string action for the mutation
-func getOp(m ent.Mutation) string {
- switch m.Op() {
- case ent.OpCreate:
- return ActionCreate
- case ent.OpUpdate, ent.OpUpdateOne:
- return ActionUpdate
- case ent.OpDelete, ent.OpDeleteOne:
- return ActionDelete
- default:
- return ""
- }
-}
-
-// parseValue returns a map of the ent.Value
-func parseValue(v ent.Value) (map[string]interface{}, error) {
- out, err := json.Marshal(v)
- if err != nil {
- return nil, err
- }
-
- var valMap map[string]interface{}
-
- if err := json.Unmarshal(out, &valMap); err != nil {
- return nil, err
- }
-
- return valMap, nil
-}
-
-// userCreatedListener is a listener for the user created event
-func userCreatedListener(ctx context.Context, c *ent.Client, sEvent *soiree.BaseEvent) func(evt soiree.Event) error {
- return func(evt soiree.Event) error {
- integrationWithWebhook, err := c.Integration.Query().WithWebhooks().Where(
- integration.KindEQ("slack")).QueryWebhooks().Where(
- webhook.EnabledEQ(true)).All(ctx)
- if err != nil {
- return err
- }
-
- for _, w := range integrationWithWebhook {
- retrieve := sEvent.Payload().(map[string]string)
-
- payload := slack.Payload{
- Text: fmt.Sprintf("A user with the following details has been created:\nName: %s\nFirst Name: %s\nLast Name: %s\nEmail: %s\nAuth Provider: %s",
- retrieve["name"],
- retrieve["first_name"],
- retrieve["last_name"],
- retrieve["email"],
- retrieve["auth_provider"]),
- }
-
- slackMessage := slack.New(w.DestinationURL)
- if err := slackMessage.Post(context.Background(), &payload); err != nil {
- return err
- }
-
- }
- return nil
- }
-}
-
-// orgCreatedListener is a listener for the organization created event
-func orgCreatedListener(ctx context.Context, c *ent.Client, sEvent *soiree.BaseEvent) func(evt soiree.Event) error {
- return func(evt soiree.Event) error {
- integrationWithWebhook, err := c.Integration.Query().WithWebhooks().Where(
- integration.KindEQ("slack")).QueryWebhooks().Where(
- webhook.EnabledEQ(true)).All(ctx)
- if err != nil {
- return err
- }
-
- for _, w := range integrationWithWebhook {
- retrieve := sEvent.Payload().(map[string]string)
-
- payload := slack.Payload{
- Text: fmt.Sprintf("A user with the following details has been created:\nName: %s\nFirst Name: %s\nLast Name: %s\nEmail: %s\nAuth Provider: %s",
- retrieve["name"],
- retrieve["first_name"],
- retrieve["last_name"],
- retrieve["email"],
- retrieve["auth_provider"]),
- }
-
- slackMessage := slack.New(w.DestinationURL)
- if err := slackMessage.Post(context.Background(), &payload); err != nil {
- return err
- }
-
- }
- return nil
- }
-}
diff --git a/internal/graphapi/ent.resolvers.go b/internal/graphapi/ent.resolvers.go
index cdc5da9d..12191c3a 100644
--- a/internal/graphapi/ent.resolvers.go
+++ b/internal/graphapi/ent.resolvers.go
@@ -242,7 +242,7 @@ func (r *queryResolver) IntegrationHistories(ctx context.Context, after *entgql.
// Invites is the resolver for the invites field.
func (r *queryResolver) Invites(ctx context.Context, after *entgql.Cursor[string], first *int, before *entgql.Cursor[string], last *int, where *generated.InviteWhereInput) (*generated.InviteConnection, error) {
- return r.client.Invite.Query().Paginate(ctx, after, first, before, last, generated.WithInviteFilter(where.Filter))
+ return r.db.Invite.Query().Paginate(ctx, after, first, before, last, generated.WithInviteFilter(where.Filter))
}
// Notes is the resolver for the notes field.
diff --git a/internal/graphapi/helpers.go b/internal/graphapi/helpers.go
index 6697326d..e0c9687f 100644
--- a/internal/graphapi/helpers.go
+++ b/internal/graphapi/helpers.go
@@ -30,9 +30,9 @@ func withTransactionalMutation(ctx context.Context) *ent.Client {
}
// injectClient adds the db client to the context to be used with transactional mutations
-func injectClient(client *ent.Client) graphql.OperationMiddleware {
+func injectClient(db *ent.Client) graphql.OperationMiddleware {
return func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler {
- ctx = ent.NewContext(ctx, client)
+ ctx = ent.NewContext(ctx, db)
return next(ctx)
}
}
diff --git a/internal/graphapi/resolver.go b/internal/graphapi/resolver.go
index 10ab28b8..5893275b 100644
--- a/internal/graphapi/resolver.go
+++ b/internal/graphapi/resolver.go
@@ -45,15 +45,15 @@ var (
// Resolver provides a graph response resolver
type Resolver struct {
- client *ent.Client
+ db *ent.Client
pool *soiree.PondPool
extensionsEnabled bool
}
// NewResolver returns a resolver configured with the given ent client
-func NewResolver(client *ent.Client) *Resolver {
+func NewResolver(db *ent.Client) *Resolver {
return &Resolver{
- client: client,
+ db: db,
}
}
@@ -102,14 +102,11 @@ func (r *Resolver) Handler(withPlayground bool) *Handler {
})
// add transactional db client
- WithTransactions(srv, r.client)
+ WithTransactions(srv, r.db)
// add context level caching
WithContextLevelCache(srv)
- // add analytics
- WithEvents(r.client)
-
// add extensions if enabled
if r.extensionsEnabled {
AddAllExtensions(srv)
@@ -133,29 +130,11 @@ func (r *Resolver) Handler(withPlayground bool) *Handler {
return h
}
-func WithEvents(c *ent.Client) {
- // Add a global hook that runs on all types and all operations.
- c.Use(func(next ent.Mutator) ent.Mutator {
- return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {
- retVal, err := next.Mutate(ctx, m)
- if err != nil {
- return retVal, err
- }
-
- if TrackedEvent(m) {
- CreateEvent(ctx, c, m, retVal)
- }
-
- return retVal, nil
- })
- })
-}
-
// WithTransactions adds the transactioner to the ent db client
-func WithTransactions(h *handler.Server, c *ent.Client) {
+func WithTransactions(h *handler.Server, d *ent.Client) {
// setup transactional db client
- h.AroundOperations(injectClient(c))
- h.Use(entgql.Transactioner{TxOpener: c})
+ h.AroundOperations(injectClient(d))
+ h.Use(entgql.Transactioner{TxOpener: d})
}
// WithContextLevelCache adds a context level cache to the handler
@@ -177,6 +156,7 @@ func WithSkipCache(h *handler.Server) {
})
}
+// WithPool adds a worker pool to the resolver for parallel processing
func (r *Resolver) WithPool(maxWorkers int, maxCapacity int, options ...pond.Option) {
// create the pool
r.pool = soiree.NewNamedPondPool(maxWorkers, maxCapacity, "graph", options...)
diff --git a/internal/graphapi/tools_test.go b/internal/graphapi/tools_test.go
index c90400ee..8fa0e50f 100644
--- a/internal/graphapi/tools_test.go
+++ b/internal/graphapi/tools_test.go
@@ -2,7 +2,6 @@ package graphapi_test
import (
"context"
- "path/filepath"
"testing"
"time"
@@ -11,21 +10,20 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
+ "github.com/theopenlane/emailtemplates"
"github.com/theopenlane/iam/fgax"
mock_fga "github.com/theopenlane/iam/fgax/mockery"
+ "github.com/theopenlane/riverboat/pkg/riverqueue"
"github.com/theopenlane/core/internal/ent/entconfig"
ent "github.com/theopenlane/core/internal/ent/generated"
"github.com/theopenlane/core/internal/entdb"
- "github.com/theopenlane/core/pkg/analytics"
"github.com/theopenlane/core/pkg/openlaneclient"
coreutils "github.com/theopenlane/core/pkg/testutils"
"github.com/theopenlane/echox/middleware/echocontext"
"github.com/theopenlane/iam/auth"
"github.com/theopenlane/iam/sessions"
"github.com/theopenlane/iam/totp"
- "github.com/theopenlane/utils/emails"
- "github.com/theopenlane/utils/marionette"
"github.com/theopenlane/utils/testutils"
"github.com/theopenlane/utils/ulids"
)
@@ -76,25 +74,6 @@ func (suite *GraphTestSuite) SetupTest() {
// create mock FGA client
fc := fgax.NewMockFGAClient(t, c.fga)
- // setup email manager
- emConfig := emails.Config{
- Testing: true,
- Archive: filepath.Join("fixtures", "emails"),
- FromEmail: "mitb@theopenlane.io",
- }
-
- em, err := emails.New(emConfig)
- if err != nil {
- t.Fatal("error creating email manager")
- }
-
- // setup task manager
- tmConfig := marionette.Config{}
-
- taskMan := marionette.New(tmConfig)
-
- taskMan.Start()
-
// setup otp manager
otpOpts := []totp.ConfigOption{
totp.WithCodeLength(6),
@@ -124,9 +103,7 @@ func (suite *GraphTestSuite) SetupTest() {
opts := []ent.Option{
ent.Authz(*fc),
- ent.Emails(em),
- ent.Marionette(taskMan),
- ent.Analytics(&analytics.EventManager{Enabled: false}),
+ ent.Emailer(&emailtemplates.Config{}), // add noop email config
ent.TOTP(&totp.Manager{
TOTPManager: otpMan,
}),
@@ -142,7 +119,9 @@ func (suite *GraphTestSuite) SetupTest() {
}
// create database connection
- db, err := entdb.NewTestClient(ctx, suite.tf, opts)
+ jobOpts := []riverqueue.Option{riverqueue.WithConnectionURI(suite.tf.URI)}
+
+ db, err := entdb.NewTestClient(ctx, suite.tf, jobOpts, opts)
require.NoError(t, err, "failed opening connection to database")
// assign values
@@ -193,11 +172,10 @@ func (suite *GraphTestSuite) TearDownTest() {
// clear all fga mocks
mock_fga.ClearMocks(suite.client.fga)
- if suite.client.db != nil {
- if err := suite.client.db.Close(); err != nil {
- log.Fatal().Err(err).Msg("failed to close database")
- }
+ if err := suite.client.db.Close(); err != nil {
+ log.Fatal().Err(err).Msg("failed to close database")
}
+
}
func (suite *GraphTestSuite) TearDownSuite() {
diff --git a/internal/httpserve/handlers/email.go b/internal/httpserve/handlers/email.go
index 2d2fab13..b17bf1c0 100644
--- a/internal/httpserve/handlers/email.go
+++ b/internal/httpserve/handlers/email.go
@@ -1,142 +1,121 @@
package handlers
import (
- "github.com/theopenlane/utils/emails"
- "github.com/theopenlane/utils/sendgrid"
+ "context"
+ "fmt"
+
+ "github.com/rs/zerolog/log"
+ "github.com/theopenlane/emailtemplates"
+ "github.com/theopenlane/riverboat/pkg/jobs"
)
-// SendVerificationEmail sends an email to a user to verify their email address
-func (h *Handler) SendVerificationEmail(user *User) error {
- contact := &sendgrid.Contact{
+// sendVerificationEmail sends an email to a user to verify their email address
+func (h *Handler) sendVerificationEmail(ctx context.Context, user *User, token string) error {
+ email, err := h.Emailer.NewVerifyEmail(emailtemplates.Recipient{
Email: user.Email,
FirstName: user.FirstName,
LastName: user.LastName,
- }
-
- data := emails.VerifyEmailData{
- EmailData: emails.EmailData{
- Sender: h.EmailManager.MustFromContact(),
- Recipient: sendgrid.Contact{
- Email: user.Email,
- FirstName: user.FirstName,
- LastName: user.LastName,
- },
- },
- FullName: contact.FullName(),
- }
+ }, token)
+ if err != nil {
+ log.Error().Err(err).Msg("error creating email verification")
- var err error
- if data.VerifyURL, err = h.EmailManager.VerifyURL(user.GetVerificationToken()); err != nil {
return err
}
- msg, err := emails.VerifyEmail(data)
+ _, err = h.DBClient.Job.Insert(ctx, jobs.EmailArgs{
+ Message: *email,
+ }, nil)
if err != nil {
+ log.Error().Err(err).Msg("error queueing email verification")
+
return err
}
- // Send the email
- return h.EmailManager.Send(msg)
+ log.Info().Msg("queued email")
+
+ return nil
}
// SendSubscriberEmail sends an email to confirm a user's subscription
-func (h *Handler) SendSubscriberEmail(user *User, orgName string) error {
- data := emails.SubscriberEmailData{
- OrgName: orgName,
- EmailData: emails.EmailData{
- Sender: h.EmailManager.MustFromContact(),
- Recipient: sendgrid.Contact{
- Email: user.Email,
- },
- },
+func (h *Handler) sendSubscriberEmail(ctx context.Context, user *User, orgID string) error {
+ if orgID == "" {
+ return fmt.Errorf("%w, subscriber organization not found", ErrMissingField)
}
- var err error
- if data.VerifySubscriberURL, err = h.EmailManager.SubscriberVerifyURL(user.GetVerificationToken()); err != nil {
- return err
- }
-
- msg, err := emails.SubscribeEmail(data)
+ org, err := h.getOrgByID(ctx, orgID)
if err != nil {
return err
}
- // Send the email
- return h.EmailManager.Send(msg)
-}
-
-// SendPasswordResetRequestEmail Send an email to a user to request them to reset their password
-func (h *Handler) SendPasswordResetRequestEmail(user *User) error {
- data := emails.ResetRequestData{
- EmailData: emails.EmailData{
- Sender: h.EmailManager.MustFromContact(),
- Recipient: sendgrid.Contact{
- Email: user.Email,
- FirstName: user.FirstName,
- LastName: user.LastName,
- },
- },
- }
- data.Recipient.ParseName(user.Name)
+ email, err := h.Emailer.NewSubscriberEmail(emailtemplates.Recipient{
+ Email: user.Email,
+ FirstName: user.FirstName,
+ LastName: user.LastName,
+ }, org.Name, user.GetVerificationToken())
+ if err != nil {
+ log.Error().Err(err).Msg("error creating email verification")
- var err error
- if data.ResetURL, err = h.EmailManager.ResetURL(user.GetPasswordResetToken()); err != nil {
return err
}
- msg, err := emails.PasswordResetRequestEmail(data)
+ _, err = h.DBClient.Job.Insert(ctx, jobs.EmailArgs{
+ Message: *email,
+ }, nil)
if err != nil {
+ log.Error().Err(err).Msg("error queueing email verification")
+
return err
}
- // Send the email
- return h.EmailManager.Send(msg)
+ return nil
}
-// SendPasswordResetSuccessEmail Send an email to a user to inform them that their password has been reset
-func (h *Handler) SendPasswordResetSuccessEmail(user *User) error {
- data := emails.ResetSuccessData{
- EmailData: emails.EmailData{
- Sender: h.EmailManager.MustFromContact(),
- Recipient: sendgrid.Contact{
- Email: user.Email,
- },
- },
- }
+// sendPasswordResetRequestEmail to a user to request them to reset their password
+func (h *Handler) sendPasswordResetRequestEmail(ctx context.Context, user *User) error {
+ email, err := h.Emailer.NewPasswordResetRequestEmail(emailtemplates.Recipient{
+ Email: user.Email,
+ FirstName: user.FirstName,
+ LastName: user.LastName,
+ }, user.GetPasswordResetToken())
+ if err != nil {
+ log.Error().Err(err).Msg("error creating password reset email")
- data.Recipient.ParseName(user.Name)
+ return err
+ }
- msg, err := emails.PasswordResetSuccessEmail(data)
+ _, err = h.DBClient.Job.Insert(ctx, jobs.EmailArgs{
+ Message: *email,
+ }, nil)
if err != nil {
+ log.Error().Err(err).Msg("error queueing password reset email")
+
return err
}
- // Send the email
- return h.EmailManager.Send(msg)
+ return nil
}
-// SendOrgInvitationEmail sends an email inviting a user to join an existing organization
-func (h *Handler) SendOrgInvitationEmail(i *emails.Invite) error {
- data := emails.InviteData{
- InviterName: i.Requestor,
- OrgName: i.OrgName,
- EmailData: emails.EmailData{
- Sender: h.EmailManager.MustFromContact(),
- Recipient: sendgrid.Contact{
- Email: i.Recipient,
- },
- },
- }
+// SendPasswordResetSuccessEmail Send an email to a user to inform them that their password has been reset
+func (h *Handler) sendPasswordResetSuccessEmail(ctx context.Context, user *User) error {
+ email, err := h.Emailer.NewPasswordResetSuccessEmail(emailtemplates.Recipient{
+ Email: user.Email,
+ FirstName: user.FirstName,
+ LastName: user.LastName,
+ })
+ if err != nil {
+ log.Error().Err(err).Msg("error creating password reset success email")
- var err error
- if data.InviteURL, err = h.EmailManager.InviteURL(i.Token); err != nil {
return err
}
- msg, err := emails.InviteEmail(data)
+ _, err = h.DBClient.Job.Insert(ctx, jobs.EmailArgs{
+ Message: *email,
+ }, nil)
if err != nil {
+ log.Error().Err(err).Msg("error queueing password reset success email")
+
return err
}
- return h.EmailManager.Send(msg)
+ return nil
}
diff --git a/internal/httpserve/handlers/eventpublisher.go b/internal/httpserve/handlers/eventpublisher.go
deleted file mode 100644
index 2d91e183..00000000
--- a/internal/httpserve/handlers/eventpublisher.go
+++ /dev/null
@@ -1,54 +0,0 @@
-package handlers
-
-import (
- "net/http"
-
- "github.com/getkin/kin-openapi/openapi3"
- echo "github.com/theopenlane/echox"
-
- "github.com/theopenlane/utils/rout"
-
- "github.com/theopenlane/core/pkg/models"
-)
-
-// EventPublisher publishes an event to the configured topic in the message payload - today this can be anything but there is no event consumer on the other side yet
-func (h *Handler) EventPublisher(ctx echo.Context) error {
- var in models.PublishRequest
- if err := ctx.Bind(&in); err != nil {
- return h.BadRequest(ctx, err)
- }
-
- if err := in.Validate(); err != nil {
- return h.InvalidInput(ctx, err)
- }
-
- if err := h.EventManager.Publish(in.Topic, []byte(in.Message)); err != nil {
- return h.InternalServerError(ctx, err)
- }
-
- out := &models.PublishReply{
- Reply: rout.Reply{Success: true},
- Message: "success!",
- }
-
- return h.Success(ctx, out)
-}
-
-// BindEventPublisher is used to bind the event publisher endpoint to the OpenAPI schema
-func (h *Handler) BindEventPublisher() *openapi3.Operation {
- eventCreate := openapi3.NewOperation()
- eventCreate.Description = "Publish and Correleate Events"
- eventCreate.OperationID = "EventPublisher"
- eventCreate.Security = &openapi3.SecurityRequirements{
- openapi3.SecurityRequirement{
- "apiKey": []string{},
- },
- }
-
- h.AddRequestBody("EventPublishRequest", models.ExamplePublishSuccessRequest, eventCreate)
- h.AddResponse("EventPublishReply", "success", models.ExamplePublishSuccessResponse, eventCreate, http.StatusOK)
- eventCreate.AddResponse(http.StatusInternalServerError, internalServerError())
- eventCreate.AddResponse(http.StatusBadRequest, badRequest())
-
- return eventCreate
-}
diff --git a/internal/httpserve/handlers/forgotpassword.go b/internal/httpserve/handlers/forgotpassword.go
index b355f5fb..bff5a1bd 100644
--- a/internal/httpserve/handlers/forgotpassword.go
+++ b/internal/httpserve/handlers/forgotpassword.go
@@ -4,12 +4,10 @@ import (
"context"
"net/http"
- "github.com/cenkalti/backoff/v4"
"github.com/getkin/kin-openapi/openapi3"
"github.com/rs/zerolog/log"
echo "github.com/theopenlane/echox"
- "github.com/theopenlane/utils/marionette"
"github.com/theopenlane/utils/rout"
"github.com/theopenlane/iam/auth"
@@ -87,13 +85,8 @@ func (h *Handler) storeAndSendPasswordResetToken(ctx context.Context, user *User
return nil, err
}
- // send emails via TaskMan as to not create blocking operations in the server
- if err := h.TaskMan.Queue(marionette.TaskFunc(func(ctx context.Context) error {
- return h.SendPasswordResetRequestEmail(user)
- }), marionette.WithRetries(3), //nolint:mnd
- marionette.WithBackoff(backoff.NewExponentialBackOff()),
- marionette.WithErrorf("could not send password reset email to user %s", user.ID),
- ); err != nil {
+ // add email send to the job queue
+ if err := h.sendPasswordResetRequestEmail(ctx, user); err != nil {
return nil, err
}
diff --git a/internal/httpserve/handlers/forgotpassword_test.go b/internal/httpserve/handlers/forgotpassword_test.go
index dbd8ab97..44a17077 100644
--- a/internal/httpserve/handlers/forgotpassword_test.go
+++ b/internal/httpserve/handlers/forgotpassword_test.go
@@ -1,21 +1,20 @@
package handlers_test
import (
+ "context"
"encoding/json"
"net/http"
"net/http/httptest"
"strings"
"testing"
- "time"
"github.com/brianvoe/gofakeit/v7"
- "github.com/rShetty/asyncwait"
+ "github.com/riverqueue/river/riverdriver/riverpgxv5"
+ "github.com/riverqueue/river/rivertest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
mock_fga "github.com/theopenlane/iam/fgax/mockery"
-
- "github.com/theopenlane/utils/emails"
- "github.com/theopenlane/utils/emails/mock"
+ "github.com/theopenlane/riverboat/pkg/jobs"
"github.com/theopenlane/httpsling"
@@ -87,9 +86,7 @@ func (suite *HandlerTestSuite) TestForgotPasswordHandler() {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
- sent := time.Now()
-
- mock.ResetEmailMock()
+ defer suite.ClearTestData()
resendJSON := models.ForgotPasswordRequest{
Email: tc.email,
@@ -126,30 +123,14 @@ func (suite *HandlerTestSuite) TestForgotPasswordHandler() {
assert.False(t, out.Success)
}
- // Test that one verify email was sent to each user
- messages := []*mock.EmailMetadata{
- {
- To: tc.email,
- From: tc.from,
- Subject: emails.PasswordResetRequestRE,
- Timestamp: sent,
- },
- }
-
- // wait for messages
- predicate := func() bool {
- return suite.h.TaskMan.GetQueueLength() == 0
- }
- successful := asyncwait.NewAsyncWait(maxWaitInMillis, pollIntervalInMillis).Check(predicate)
-
- if successful != true {
- t.Errorf("max wait of email send")
- }
-
+ // ensure email was added to the job queue
if tc.emailExpected {
- mock.CheckEmails(t, messages)
+ job := rivertest.RequireInserted[*riverpgxv5.Driver](context.Background(), t, riverpgxv5.New(suite.db.Job.GetPool()), &jobs.EmailArgs{}, nil)
+ require.NotNil(t, job)
+ assert.Equal(t, []string{tc.email}, job.Args.Message.To)
+ assert.Contains(t, job.Args.Message.Subject, "Password Reset - Action Required")
} else {
- mock.CheckEmails(t, nil)
+ rivertest.RequireNotInserted(ctx, t, riverpgxv5.New(suite.db.Job.GetPool()), &jobs.EmailArgs{}, nil)
}
})
}
diff --git a/internal/httpserve/handlers/handlers.go b/internal/httpserve/handlers/handlers.go
index 3a6587c3..c41c2ba1 100644
--- a/internal/httpserve/handlers/handlers.go
+++ b/internal/httpserve/handlers/handlers.go
@@ -5,25 +5,22 @@ import (
"github.com/lestrrat-go/jwx/v2/jwk"
"github.com/redis/go-redis/v9"
echo "github.com/theopenlane/echox"
+ "github.com/theopenlane/emailtemplates"
"github.com/theopenlane/iam/totp"
- "github.com/theopenlane/utils/emails"
- "github.com/theopenlane/utils/marionette"
"github.com/theopenlane/iam/sessions"
"github.com/theopenlane/iam/tokens"
ent "github.com/theopenlane/core/internal/ent/generated"
"github.com/theopenlane/core/internal/httpserve/authmanager"
- "github.com/theopenlane/core/pkg/analytics"
- "github.com/theopenlane/core/pkg/events/kafka/publisher"
)
// Handler contains configuration options for handlers
type Handler struct {
// IsTest is a flag to determine if the application is running in test mode and will mock external calls
IsTest bool
- // DBClient to interact with the generated ent schema
+ // DBClient to interact with the database
DBClient *ent.Client
// RedisClient to interact with redis
RedisClient *redis.Client
@@ -37,12 +34,6 @@ type Handler struct {
JWTKeys jwk.Set
// SessionConfig to handle sessions
SessionConfig *sessions.SessionConfig
- // EmailManager to handle sending emails
- EmailManager *emails.EmailManager
- // TaskMan manages tasks in a separate goroutine to allow for non blocking operations
- TaskMan *marionette.TaskManager
- // AnalyticsClient is the client used to send analytics events
- AnalyticsClient *analytics.EventManager
// OauthProvider contains the configuration settings for all supported Oauth2 providers
OauthProvider OauthProviderConfig
// AuthMiddleware contains the middleware to be used for authenticated endpoints
@@ -51,6 +42,6 @@ type Handler struct {
WebAuthn *webauthn.WebAuthn
// OTPManager contains the configuration settings for the OTP provider
OTPManager *totp.Manager
- // EventManager contains the configuration settings for the event publisher
- EventManager *publisher.KafkaPublisher
+ // Email contains email sending configuration for the server
+ Emailer emailtemplates.Config
}
diff --git a/internal/httpserve/handlers/invite_test.go b/internal/httpserve/handlers/invite_test.go
index a598c4bd..0084c6dd 100644
--- a/internal/httpserve/handlers/invite_test.go
+++ b/internal/httpserve/handlers/invite_test.go
@@ -7,15 +7,13 @@ import (
"net/http"
"net/http/httptest"
"testing"
- "time"
- "github.com/rShetty/asyncwait"
+ "github.com/riverqueue/river/riverdriver/riverpgxv5"
+ "github.com/riverqueue/river/rivertest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
mock_fga "github.com/theopenlane/iam/fgax/mockery"
-
- "github.com/theopenlane/utils/emails"
- "github.com/theopenlane/utils/emails/mock"
+ "github.com/theopenlane/riverboat/pkg/jobs"
"github.com/theopenlane/iam/auth"
@@ -76,18 +74,16 @@ func (suite *HandlerTestSuite) TestOrgInviteAcceptHandler() {
require.NoError(t, err)
testCases := []struct {
- name string
- email string
- tokenSet bool
- emailExpected bool
- wantErr bool
- errMsg string
+ name string
+ email string
+ tokenSet bool
+ wantErr bool
+ errMsg string
}{
{
- name: "happy path",
- email: groot,
- emailExpected: true,
- tokenSet: true,
+ name: "happy path",
+ email: groot,
+ tokenSet: true,
},
{
name: "missing token",
@@ -107,26 +103,13 @@ func (suite *HandlerTestSuite) TestOrgInviteAcceptHandler() {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
- defer mock_fga.ClearMocks(suite.fga)
-
- sent := time.Now()
-
- mock.ResetEmailMock()
+ defer suite.ClearTestData()
ctx := privacy.DecisionContext(userCtx, privacy.Allow)
invite := suite.db.Invite.Create().
SetRecipient(tc.email).SaveX(ctx)
- // wait for messages so we don't have conflicts with the accept message
- predicate := func() bool {
- return suite.h.TaskMan.GetQueueLength() == 0
- }
-
- asyncwait.NewAsyncWait(maxWaitInMillis, pollIntervalInMillis).Check(predicate)
-
- mock.ResetEmailMock()
-
target := "/invite"
if tc.tokenSet {
target = fmt.Sprintf("/invite?token=%s", invite.Token)
@@ -170,31 +153,20 @@ func (suite *HandlerTestSuite) TestOrgInviteAcceptHandler() {
assert.Equal(t, org.CreateOrganization.Organization.ID, user.User.Setting.DefaultOrg.ID)
- // Test that one email was sent for accepted invite
- messages := []*mock.EmailMetadata{
- {
- To: tc.email,
- From: "mitb@theopenlane.io",
- Subject: emails.InviteBeenAccepted,
- Timestamp: sent,
- },
- }
-
- // wait for messages
- predicate = func() bool {
- return suite.h.TaskMan.GetQueueLength() == 0
- }
- successful := asyncwait.NewAsyncWait(maxWaitInMillis, pollIntervalInMillis).Check(predicate)
-
- if successful != true {
- t.Errorf("max wait of email send")
- }
-
- if tc.emailExpected {
- mock.CheckEmails(t, messages)
- } else {
- mock.CheckEmails(t, nil)
- }
+ // ensure the email jobs are created
+ // there will be two because the first is the invite email and the second is the accepted invite email
+ job := rivertest.RequireManyInserted[*riverpgxv5.Driver](context.Background(), t, riverpgxv5.New(suite.db.Job.GetPool()),
+ []rivertest.ExpectedJob{
+ {
+ Args: jobs.EmailArgs{},
+ },
+ {
+ Args: jobs.EmailArgs{},
+ },
+ })
+ require.NotNil(t, job)
+ assert.Contains(t, string(job[0].EncodedArgs), "Join your team") // first email is the invite email
+ assert.Contains(t, string(job[1].EncodedArgs), "You've been added to an organization") // second email is the accepted invite email
})
}
}
diff --git a/internal/httpserve/handlers/login.go b/internal/httpserve/handlers/login.go
index f4b2dd55..58f62af4 100644
--- a/internal/httpserve/handlers/login.go
+++ b/internal/httpserve/handlers/login.go
@@ -4,7 +4,6 @@ import (
"net/http"
"github.com/getkin/kin-openapi/openapi3"
- ph "github.com/posthog/posthog-go"
"github.com/rs/zerolog/log"
echo "github.com/theopenlane/echox"
@@ -73,14 +72,6 @@ func (h *Handler) LoginHandler(ctx echo.Context) error {
return h.InternalServerError(ctx, err)
}
- props := ph.NewProperties().
- Set("user_id", user.ID).
- Set("email", user.Email).
- Set("organization_id", user.Edges.Setting.Edges.DefaultOrg.ID). // user is logged into their default org
- Set("auth_provider", user.AuthProvider)
-
- h.AnalyticsClient.Event("user_authenticated", props)
-
out := models.LoginReply{
Reply: rout.Reply{Success: true},
Message: "success",
diff --git a/internal/httpserve/handlers/oauth_register.go b/internal/httpserve/handlers/oauth_register.go
index e7f7276e..78cb4644 100644
--- a/internal/httpserve/handlers/oauth_register.go
+++ b/internal/httpserve/handlers/oauth_register.go
@@ -4,7 +4,6 @@ import (
"context"
"strings"
- ph "github.com/posthog/posthog-go"
"github.com/rs/zerolog/log"
echo "github.com/theopenlane/echox"
"golang.org/x/oauth2"
@@ -56,14 +55,6 @@ func (h *Handler) OauthRegister(ctx echo.Context) error {
return h.InternalServerError(ctx, err)
}
- props := ph.NewProperties().
- Set("user_id", user.ID).
- Set("email", user.Email).
- Set("organization_id", user.Edges.Setting.Edges.DefaultOrg.ID). // user is logged into their default org
- Set("auth_provider", in.AuthProvider)
-
- h.AnalyticsClient.Event("user_authenticated", props)
-
out := models.LoginReply{
Reply: rout.Reply{Success: true},
Message: "success",
diff --git a/internal/httpserve/handlers/register.go b/internal/httpserve/handlers/register.go
index 976428c6..42cefd77 100644
--- a/internal/httpserve/handlers/register.go
+++ b/internal/httpserve/handlers/register.go
@@ -4,16 +4,12 @@ import (
"context"
"net/http"
- "github.com/cenkalti/backoff/v4"
"github.com/getkin/kin-openapi/openapi3"
- ph "github.com/posthog/posthog-go"
"github.com/rs/zerolog/log"
echo "github.com/theopenlane/echox"
- "github.com/theopenlane/utils/marionette"
- "github.com/theopenlane/utils/rout"
-
"github.com/theopenlane/iam/auth"
+ "github.com/theopenlane/utils/rout"
"github.com/theopenlane/core/internal/ent/generated"
"github.com/theopenlane/core/internal/ent/privacy/token"
@@ -127,25 +123,7 @@ func (h *Handler) storeAndSendEmailVerificationToken(ctx context.Context, user *
return nil, err
}
- props := ph.NewProperties().
- Set("user_id", user.ID).
- Set("email", user.Email).
- Set("first_name", user.FirstName).
- Set("last_name", user.LastName)
-
- h.AnalyticsClient.Event("email_verification_sent", props)
-
- // send emails via TaskMan as to not create blocking operations in the server
- if err := h.TaskMan.Queue(marionette.TaskFunc(func(ctx context.Context) error {
- return h.SendVerificationEmail(user)
- }), marionette.WithRetries(3), //nolint:mnd
- marionette.WithBackoff(backoff.NewExponentialBackOff()),
- marionette.WithErrorf("could not send verification email to user %s", user.ID),
- ); err != nil {
- return nil, err
- }
-
- return meowtoken, nil
+ return meowtoken, h.sendVerificationEmail(ctx, user, meowtoken.Token)
}
// BindRegisterHandler is used to bind the register endpoint to the OpenAPI schema
diff --git a/internal/httpserve/handlers/register_test.go b/internal/httpserve/handlers/register_test.go
index 37aeafa1..f462ce56 100644
--- a/internal/httpserve/handlers/register_test.go
+++ b/internal/httpserve/handlers/register_test.go
@@ -1,20 +1,21 @@
package handlers_test
import (
+ "context"
"encoding/json"
"net/http"
"net/http/httptest"
"strings"
"testing"
- "time"
- "github.com/rShetty/asyncwait"
+ "github.com/riverqueue/river/riverdriver/riverpgxv5"
+ "github.com/riverqueue/river/rivertest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
mock_fga "github.com/theopenlane/iam/fgax/mockery"
+ "github.com/theopenlane/newman"
+ "github.com/theopenlane/riverboat/pkg/jobs"
- "github.com/theopenlane/utils/emails"
- "github.com/theopenlane/utils/emails/mock"
"github.com/theopenlane/utils/rout"
"github.com/theopenlane/httpsling"
@@ -96,10 +97,6 @@ func (suite *HandlerTestSuite) TestRegisterHandler() {
t.Run(tc.name, func(t *testing.T) {
defer mock_fga.ClearMocks(suite.fga)
- sent := time.Now()
-
- mock.ResetEmailMock()
-
// setup mock authz writes
if tc.expectedErrMessage == "" {
mock_fga.WriteAny(t, suite.fga)
@@ -175,30 +172,15 @@ func (suite *HandlerTestSuite) TestRegisterHandler() {
assert.Contains(t, out.Error, tc.expectedErrMessage)
}
- // Test that one verify email was sent to each user
- messages := []*mock.EmailMetadata{
- {
- To: tc.email,
- From: "mitb@theopenlane.io",
- Subject: emails.VerifyEmailRE,
- Timestamp: sent,
- },
- }
-
// wait for messages
- predicate := func() bool {
- return suite.h.TaskMan.GetQueueLength() == 0
- }
- successful := asyncwait.NewAsyncWait(maxWaitInMillis, pollIntervalInMillis).Check(predicate)
-
- if successful != true {
- t.Errorf("max wait of email send")
- }
-
if tc.emailExpected {
- mock.CheckEmails(t, messages)
- } else {
- mock.CheckEmails(t, nil)
+ job := rivertest.RequireInserted[*riverpgxv5.Driver](context.Background(), t, riverpgxv5.New(suite.db.Job.GetPool()), &jobs.EmailArgs{
+ Message: *newman.NewEmailMessageWithOptions(
+ newman.WithSubject("Please verify your email address to login to Openlane"),
+ ),
+ }, nil)
+ require.NotNil(t, job)
+ require.Equal(t, []string{tc.email}, job.Args.Message.To)
}
})
}
diff --git a/internal/httpserve/handlers/resetpassword.go b/internal/httpserve/handlers/resetpassword.go
index 90ccf562..dd115b56 100644
--- a/internal/httpserve/handlers/resetpassword.go
+++ b/internal/httpserve/handlers/resetpassword.go
@@ -1,20 +1,17 @@
package handlers
import (
- "context"
"database/sql"
"errors"
"fmt"
"net/http"
"time"
- "github.com/cenkalti/backoff/v4"
"github.com/getkin/kin-openapi/openapi3"
"github.com/oklog/ulid/v2"
"github.com/rs/zerolog/log"
echo "github.com/theopenlane/echox"
- "github.com/theopenlane/utils/marionette"
"github.com/theopenlane/utils/rout"
"github.com/theopenlane/iam/auth"
@@ -121,15 +118,8 @@ func (h *Handler) ResetPassword(ctx echo.Context) error {
return h.BadRequest(ctx, err)
}
- if err := h.TaskMan.Queue(marionette.TaskFunc(func(ctx context.Context) error {
- return h.SendPasswordResetSuccessEmail(user)
- }), marionette.WithRetries(3), //nolint:mnd
- marionette.WithBackoff(backoff.NewExponentialBackOff()),
- marionette.WithErrorf("could not send password reset confirmation email to user %s", user.Email),
- ); err != nil {
- log.Error().Err(err).Msg("error sending confirmation email")
-
- return h.InternalServerError(ctx, ErrProcessingRequest)
+ if err := h.sendPasswordResetSuccessEmail(userCtx, user); err != nil {
+ return h.InternalServerError(ctx, err)
}
out := &models.ResetPasswordReply{
diff --git a/internal/httpserve/handlers/resetpassword_test.go b/internal/httpserve/handlers/resetpassword_test.go
index 873bb49f..dce7b345 100644
--- a/internal/httpserve/handlers/resetpassword_test.go
+++ b/internal/httpserve/handlers/resetpassword_test.go
@@ -10,13 +10,13 @@ import (
"time"
"github.com/brianvoe/gofakeit/v7"
- "github.com/rShetty/asyncwait"
+ "github.com/riverqueue/river/riverdriver/riverpgxv5"
+ "github.com/riverqueue/river/rivertest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
mock_fga "github.com/theopenlane/iam/fgax/mockery"
-
- "github.com/theopenlane/utils/emails"
- "github.com/theopenlane/utils/emails/mock"
+ "github.com/theopenlane/newman"
+ "github.com/theopenlane/riverboat/pkg/jobs"
"github.com/theopenlane/echox/middleware/echocontext"
@@ -40,28 +40,24 @@ func (suite *HandlerTestSuite) TestResetPasswordHandler() {
expiredTTL := time.Now().AddDate(0, 0, -1).Format(time.RFC3339Nano)
testCases := []struct {
- name string
- email string
- newPassword string
- tokenSet bool
- tokenProvided string
- ttl string
- emailExpected bool
- expectedEmailSubject string
- expectedResp string
- expectedStatus int
- from string
+ name string
+ email string
+ newPassword string
+ tokenSet bool
+ tokenProvided string
+ ttl string
+ expectedResp string
+ expectedStatus int
+ from string
}{
{
- name: "happy path",
- email: "kelsier@theopenlane.io",
- tokenSet: true,
- newPassword: newPassword,
- from: "mitb@theopenlane.io",
- emailExpected: true,
- expectedEmailSubject: emails.PasswordResetSuccessRE,
- expectedResp: emptyResponse,
- expectedStatus: http.StatusOK,
+ name: "happy path",
+ email: "kelsier@theopenlane.io",
+ tokenSet: true,
+ newPassword: newPassword,
+ from: "mitb@theopenlane.io",
+ expectedResp: emptyResponse,
+ expectedStatus: http.StatusOK,
},
{
name: "bad token (user not found)",
@@ -69,7 +65,6 @@ func (suite *HandlerTestSuite) TestResetPasswordHandler() {
tokenSet: true,
tokenProvided: "thisisnotavalidtoken",
newPassword: newPassword,
- emailExpected: false,
from: "notactuallyanemail",
expectedResp: "password reset token invalid",
expectedStatus: http.StatusBadRequest,
@@ -79,7 +74,6 @@ func (suite *HandlerTestSuite) TestResetPasswordHandler() {
email: "sazed@theopenlane.io",
tokenSet: true,
newPassword: "weak1",
- emailExpected: false,
from: "nottodaysatan",
expectedResp: "password is too weak",
expectedStatus: http.StatusBadRequest,
@@ -89,7 +83,6 @@ func (suite *HandlerTestSuite) TestResetPasswordHandler() {
email: "sventure@theopenlane.io",
tokenSet: true,
newPassword: validPassword,
- emailExpected: false,
from: "mmhmm",
expectedResp: "password was already used",
expectedStatus: http.StatusBadRequest,
@@ -99,7 +92,6 @@ func (suite *HandlerTestSuite) TestResetPasswordHandler() {
email: "dockson@theopenlane.io",
tokenSet: false,
newPassword: newPassword,
- emailExpected: false,
from: "yadayadayada",
expectedResp: "token is required",
expectedStatus: http.StatusBadRequest,
@@ -109,7 +101,6 @@ func (suite *HandlerTestSuite) TestResetPasswordHandler() {
email: "tensoon@theopenlane.io",
newPassword: "6z9Fqc-E-9v32NsJzLNP",
tokenSet: true,
- emailExpected: false,
from: "zonkertons",
ttl: expiredTTL,
expectedResp: "reset token is expired, please request a new token using forgot-password",
@@ -119,10 +110,6 @@ func (suite *HandlerTestSuite) TestResetPasswordHandler() {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
- sent := time.Now()
-
- mock.ResetEmailMock()
-
// create user in the database
rt, _, err := suite.createUserWithResetToken(t, ec, tc.email, tc.ttl)
require.NoError(t, err)
@@ -168,32 +155,14 @@ func (suite *HandlerTestSuite) TestResetPasswordHandler() {
if tc.expectedStatus != http.StatusOK {
assert.Contains(t, out.Error, tc.expectedResp)
- }
-
- // Test that one verify email was sent to each user
- messages := []*mock.EmailMetadata{
- {
- To: tc.email,
- From: tc.from,
- Subject: tc.expectedEmailSubject,
- Timestamp: sent,
- },
- }
-
- // wait for messages
- predicate := func() bool {
- return suite.h.TaskMan.GetQueueLength() == 0
- }
- successful := asyncwait.NewAsyncWait(maxWaitInMillis, pollIntervalInMillis).Check(predicate)
-
- if successful != true {
- t.Errorf("max wait of email send")
- }
-
- if tc.emailExpected {
- mock.CheckEmails(t, messages)
} else {
- mock.CheckEmails(t, nil)
+ job := rivertest.RequireInserted[*riverpgxv5.Driver](context.Background(), t, riverpgxv5.New(suite.db.Job.GetPool()), &jobs.EmailArgs{
+ Message: *newman.NewEmailMessageWithOptions(
+ newman.WithSubject("Openlane Password Reset - Action Required"),
+ ),
+ }, nil)
+ require.NotNil(t, job)
+ require.Equal(t, []string{tc.email}, job.Args.Message.To)
}
})
}
diff --git a/internal/httpserve/handlers/switch.go b/internal/httpserve/handlers/switch.go
index 61876ac7..067acfdf 100644
--- a/internal/httpserve/handlers/switch.go
+++ b/internal/httpserve/handlers/switch.go
@@ -4,7 +4,6 @@ import (
"net/http"
"github.com/getkin/kin-openapi/openapi3"
- ph "github.com/posthog/posthog-go"
"github.com/rs/zerolog/log"
echo "github.com/theopenlane/echox"
"github.com/theopenlane/iam/fgax"
@@ -88,16 +87,6 @@ func (h *Handler) SwitchHandler(ctx echo.Context) error {
return h.InternalServerError(ctx, err)
}
- // track the organization switch event
- props := ph.NewProperties().
- Set("user_id", user.ID).
- Set("email", user.Email).
- Set("target_organization_id", org.ID).
- Set("auth_provider", user.AuthProvider).
- Set("previous_organization_id", orgID)
-
- h.AnalyticsClient.Event("organization_switched", props)
-
// set the out attributes we send back to the client only on success
out := &models.SwitchOrganizationReply{
Reply: rout.Reply{Success: true},
diff --git a/internal/httpserve/handlers/tools_test.go b/internal/httpserve/handlers/tools_test.go
index a3e87325..c36178e6 100644
--- a/internal/httpserve/handlers/tools_test.go
+++ b/internal/httpserve/handlers/tools_test.go
@@ -2,8 +2,6 @@ package handlers_test
import (
"context"
- "log"
- "path/filepath"
"testing"
"time"
@@ -13,12 +11,12 @@ import (
echo "github.com/theopenlane/echox"
"github.com/theopenlane/echox/middleware/echocontext"
+ "github.com/theopenlane/emailtemplates"
"github.com/theopenlane/iam/auth"
"github.com/theopenlane/iam/fgax"
mock_fga "github.com/theopenlane/iam/fgax/mockery"
"github.com/theopenlane/iam/sessions"
- "github.com/theopenlane/utils/emails"
- "github.com/theopenlane/utils/marionette"
+ "github.com/theopenlane/riverboat/pkg/riverqueue"
"github.com/theopenlane/utils/testutils"
"github.com/theopenlane/core/internal/ent/entconfig"
@@ -26,7 +24,6 @@ import (
"github.com/theopenlane/core/internal/entdb"
"github.com/theopenlane/core/internal/httpserve/authmanager"
"github.com/theopenlane/core/internal/httpserve/handlers"
- "github.com/theopenlane/core/pkg/analytics"
"github.com/theopenlane/core/pkg/middleware/transaction"
"github.com/theopenlane/core/pkg/openlaneclient"
coreutils "github.com/theopenlane/core/pkg/testutils"
@@ -36,10 +33,6 @@ var (
// commonly used vars in tests
emptyResponse = "null\n"
validPassword = "sup3rs3cu7e!"
-
- // mock email send settings
- maxWaitInMillis = 2000
- pollIntervalInMillis = 100
)
// HandlerTestSuite handles the setup and teardown between tests
@@ -74,28 +67,8 @@ func (suite *HandlerTestSuite) SetupTest() {
// create mock FGA client
fc := fgax.NewMockFGAClient(t, suite.fga)
- emConfig := emails.Config{
- Testing: true,
- Archive: filepath.Join("fixtures", "emails"),
- FromEmail: "mitb@theopenlane.io",
- }
-
- em, err := emails.New(emConfig)
- if err != nil {
- t.Fatal("error creating email manager")
- }
-
- // Start task manager
- tmConfig := marionette.Config{}
-
- taskMan := marionette.New(tmConfig)
-
- taskMan.Start()
-
tm, err := coreutils.CreateTokenManager(15 * time.Minute) //nolint:mnd
- if err != nil {
- t.Fatal("error creating token manager")
- }
+ require.NoError(t, err)
sm := coreutils.CreateSessionManager()
rc := coreutils.NewRedisClient()
@@ -109,11 +82,9 @@ func (suite *HandlerTestSuite) SetupTest() {
opts := []ent.Option{
ent.Authz(*fc),
- ent.Marionette(taskMan),
- ent.Emails(em),
+ ent.Emailer(&emailtemplates.Config{}),
ent.TokenManager(tm),
ent.SessionConfig(&sessionConfig),
- ent.Analytics(&analytics.EventManager{Enabled: false}),
ent.EntConfig(&entconfig.Config{
Flags: entconfig.Flags{
UseListUserService: false,
@@ -123,9 +94,15 @@ func (suite *HandlerTestSuite) SetupTest() {
}
// create database connection
- db, err := entdb.NewTestClient(ctx, suite.tf, opts)
+ jobOpts := []riverqueue.Option{riverqueue.WithConnectionURI(suite.tf.URI)}
+
+ db, err := entdb.NewTestClient(ctx, suite.tf, jobOpts, opts)
require.NoError(t, err, "failed opening connection to database")
+ // truncate river tables
+ err = db.Job.TruncateRiverTables(ctx)
+ require.NoError(t, err)
+
// add db to test client
suite.db = db
@@ -145,22 +122,28 @@ func (suite *HandlerTestSuite) TearDownTest() {
mock_fga.ClearMocks(suite.fga)
if suite.db != nil {
- if err := suite.db.Close(); err != nil {
- log.Fatalf("failed to close database: %s", err)
- }
+ err := suite.db.CloseAll()
+ require.NoError(suite.T(), err)
}
}
+func (suite *HandlerTestSuite) ClearTestData() {
+ mock_fga.ClearMocks(suite.fga)
+
+ err := suite.db.Job.TruncateRiverTables(context.Background())
+ require.NoError(suite.T(), err)
+}
+
func (suite *HandlerTestSuite) TearDownSuite() {
testutils.TeardownFixture(suite.tf)
}
-func setupEcho(entClient *ent.Client) *echo.Echo {
+func setupEcho(dbClient *ent.Client) *echo.Echo {
// create echo context with middleware
e := echo.New()
transactionConfig := transaction.Client{
- EntDBClient: entClient,
+ EntDBClient: dbClient,
}
e.Use(transactionConfig.Middleware)
@@ -169,23 +152,18 @@ func setupEcho(entClient *ent.Client) *echo.Echo {
}
// handlerSetup to be used for required references in the handler tests
-func handlerSetup(t *testing.T, ent *ent.Client) *handlers.Handler {
+func handlerSetup(t *testing.T, db *ent.Client) *handlers.Handler {
as := authmanager.New()
- as.SetTokenManager(ent.TokenManager)
- as.SetSessionConfig(ent.SessionConfig)
+ as.SetTokenManager(db.TokenManager)
+ as.SetSessionConfig(db.SessionConfig)
h := &handlers.Handler{
IsTest: true,
- TokenManager: ent.TokenManager,
- DBClient: ent,
- RedisClient: ent.SessionConfig.RedisClient,
- SessionConfig: ent.SessionConfig,
+ TokenManager: db.TokenManager,
+ DBClient: db,
+ RedisClient: db.SessionConfig.RedisClient,
+ SessionConfig: db.SessionConfig,
AuthManager: as,
- EmailManager: ent.Emails,
- TaskMan: ent.Marionette,
- AnalyticsClient: &analytics.EventManager{
- Enabled: false,
- },
}
return h
diff --git a/internal/httpserve/handlers/verifyemail.go b/internal/httpserve/handlers/verifyemail.go
index a5be511f..e143d252 100644
--- a/internal/httpserve/handlers/verifyemail.go
+++ b/internal/httpserve/handlers/verifyemail.go
@@ -7,7 +7,6 @@ import (
"entgo.io/ent/dialect/sql"
"github.com/getkin/kin-openapi/openapi3"
- ph "github.com/posthog/posthog-go"
"github.com/rs/zerolog/log"
echo "github.com/theopenlane/echox"
@@ -119,14 +118,6 @@ func (h *Handler) VerifyEmail(ctx echo.Context) error {
return h.InternalServerError(ctx, err)
}
- props := ph.NewProperties().
- Set("user_id", user.ID).
- Set("email", user.Email).
- Set("first_name", user.FirstName).
- Set("last_name", user.LastName)
-
- h.AnalyticsClient.Event("email_verified", props)
-
out := &models.VerifyReply{
ID: entUser.ID,
Email: entUser.Email,
diff --git a/internal/httpserve/handlers/verifysubscribe.go b/internal/httpserve/handlers/verifysubscribe.go
index 6c665442..f099ff39 100644
--- a/internal/httpserve/handlers/verifysubscribe.go
+++ b/internal/httpserve/handlers/verifysubscribe.go
@@ -3,18 +3,14 @@ package handlers
import (
"context"
"errors"
- "fmt"
"net/http"
"time"
"entgo.io/ent/dialect/sql"
- "github.com/cenkalti/backoff/v4"
"github.com/getkin/kin-openapi/openapi3"
- ph "github.com/posthog/posthog-go"
"github.com/rs/zerolog/log"
echo "github.com/theopenlane/echox"
- "github.com/theopenlane/utils/marionette"
"github.com/theopenlane/utils/rout"
"github.com/theopenlane/iam/auth"
@@ -85,11 +81,6 @@ func (h *Handler) VerifySubscriptionHandler(ctx echo.Context) error {
}
}
- props := ph.NewProperties().
- Set("email", entSubscriber.Email)
-
- h.AnalyticsClient.Event("subscriber_verified", props)
-
out := &models.VerifySubscribeReply{
Reply: rout.Reply{Success: true},
Message: "Subscription confirmed, looking forward to sending you updates!",
@@ -157,38 +148,6 @@ func (h *Handler) verifySubscriberToken(ctx context.Context, entSubscriber *gene
return nil
}
-func (h *Handler) sendSubscriberEmail(ctx context.Context, user *User, orgID string) error {
- if orgID == "" {
- return fmt.Errorf("%w, subscriber organization not found", ErrMissingField)
- }
-
- org, err := h.getOrgByID(ctx, orgID)
- if err != nil {
- return err
- }
-
- // send emails via TaskMan as to not create blocking operations in the server
- if err := h.TaskMan.Queue(marionette.TaskFunc(func(ctx context.Context) error {
- return h.SendSubscriberEmail(user, org.Name)
- }), marionette.WithRetries(3), //nolint:mnd
- marionette.WithBackoff(backoff.NewExponentialBackOff()),
- marionette.WithErrorf("could not send subscriber verification email to user %s", user.Email),
- ); err != nil {
- return err
- }
-
- props := ph.NewProperties().
- Set("user_id", user.ID).
- Set("email", user.Email).
- Set("first_name", user.FirstName).
- Set("last_name", user.LastName).
- Set("organization_name", org.Name)
-
- h.AnalyticsClient.Event("email_verification_sent", props)
-
- return nil
-}
-
// BindVerifySubscriberHandler creates the openapi operation for the subscription verification endpoint
func (h *Handler) BindVerifySubscriberHandler() *openapi3.Operation {
verify := openapi3.NewOperation()
diff --git a/internal/httpserve/handlers/verifysubscribe_test.go b/internal/httpserve/handlers/verifysubscribe_test.go
index 9c5cd922..97848a5d 100644
--- a/internal/httpserve/handlers/verifysubscribe_test.go
+++ b/internal/httpserve/handlers/verifysubscribe_test.go
@@ -10,13 +10,13 @@ import (
"time"
"github.com/brianvoe/gofakeit/v7"
- "github.com/rShetty/asyncwait"
+ "github.com/riverqueue/river/riverdriver/riverpgxv5"
+ "github.com/riverqueue/river/rivertest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
mock_fga "github.com/theopenlane/iam/fgax/mockery"
+ "github.com/theopenlane/riverboat/pkg/jobs"
- "github.com/theopenlane/utils/emails"
- "github.com/theopenlane/utils/emails/mock"
"github.com/theopenlane/utils/ulids"
"github.com/theopenlane/iam/auth"
@@ -98,10 +98,6 @@ func (suite *HandlerTestSuite) TestVerifySubscribeHandler() {
t.Run(tc.name, func(t *testing.T) {
defer mock_fga.ClearMocks(suite.fga)
- sent := time.Now()
-
- mock.ResetEmailMock()
-
sub := suite.createTestSubscriber(t, org.CreateOrganization.Organization.ID, tc.email, tc.ttl)
target := "/subscribe/verify"
@@ -133,28 +129,21 @@ func (suite *HandlerTestSuite) TestVerifySubscribeHandler() {
assert.NotEmpty(t, out.Message)
}
- // Test that one verify email was sent to each user
- messages := []*mock.EmailMetadata{
- {
- To: tc.email,
- From: "mitb@theopenlane.io",
- Subject: fmt.Sprintf(emails.Subscribed, "mitb"),
- Timestamp: sent,
- },
- }
-
- // wait for messages
- predicate := func() bool {
- return suite.h.TaskMan.GetQueueLength() == 0
- }
- successful := asyncwait.NewAsyncWait(maxWaitInMillis, pollIntervalInMillis).Check(predicate)
-
- if successful != true {
- t.Errorf("max wait of email send")
- }
-
+ // ensure email job was created
+ // the first job is the subscriber verification email and the following is the subscribed email
if tc.emailExpected {
- mock.CheckEmails(t, messages)
+ job := rivertest.RequireManyInserted[*riverpgxv5.Driver](context.Background(), t, riverpgxv5.New(suite.db.Job.GetPool()),
+ []rivertest.ExpectedJob{
+ {
+ Args: jobs.EmailArgs{},
+ },
+ {
+ Args: jobs.EmailArgs{},
+ },
+ })
+ require.NotNil(t, job)
+ assert.Contains(t, string(job[0].EncodedArgs), "Thank you for subscribing") // first email is the invite email
+ assert.Contains(t, string(job[1].EncodedArgs), "You've been subscribed to") // second email is the accepted invite email
}
})
}
diff --git a/internal/httpserve/route/events.go b/internal/httpserve/route/events.go
deleted file mode 100644
index cc75c4f0..00000000
--- a/internal/httpserve/route/events.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package route
-
-import (
- "net/http"
-
- echo "github.com/theopenlane/echox"
-)
-
-// registerEventPublisher registers the event publisher endpoint
-func registerEventPublisher(router *Router) (err error) {
- path := "/event/publish"
- method := http.MethodPost
- name := "EventPublisher"
-
- route := echo.Route{
- Name: name,
- Method: method,
- Path: path,
- Middlewares: authMW,
- Handler: func(c echo.Context) error {
- return router.Handler.EventPublisher(c)
- },
- }
-
- eventOperation := router.Handler.BindEventPublisher()
-
- if err := router.Addv1Route(path, method, eventOperation, route); err != nil {
- return err
- }
-
- return nil
-}
diff --git a/internal/httpserve/route/router.go b/internal/httpserve/route/router.go
index ff95211a..8d56887b 100644
--- a/internal/httpserve/route/router.go
+++ b/internal/httpserve/route/router.go
@@ -134,7 +134,6 @@ func RegisterRoutes(router *Router) error {
registerUserInfoHandler,
registerOAuthRegisterHandler,
registerSwitchRoute,
- registerEventPublisher,
registerLivenessHandler,
registerMetricsHandler,
registerSecurityTxtHandler,
diff --git a/internal/httpserve/serveropts/option.go b/internal/httpserve/serveropts/option.go
index f89dc71b..e3ee30f3 100644
--- a/internal/httpserve/serveropts/option.go
+++ b/internal/httpserve/serveropts/option.go
@@ -9,6 +9,7 @@ import (
"os"
"github.com/redis/go-redis/v9"
+
"github.com/rs/zerolog/log"
echoprometheus "github.com/theopenlane/echo-prometheus"
echo "github.com/theopenlane/echox"
@@ -21,19 +22,16 @@ import (
"github.com/theopenlane/iam/sessions"
"github.com/theopenlane/iam/tokens"
"github.com/theopenlane/iam/totp"
+ "github.com/theopenlane/riverboat/pkg/riverqueue"
"github.com/theopenlane/utils/cache"
- "github.com/theopenlane/utils/emails"
- "github.com/theopenlane/utils/marionette"
"github.com/theopenlane/utils/ulids"
"github.com/theopenlane/echox/middleware/echocontext"
- "github.com/theopenlane/core/internal/ent/generated"
+ ent "github.com/theopenlane/core/internal/ent/generated"
"github.com/theopenlane/core/internal/graphapi"
"github.com/theopenlane/core/internal/httpserve/config"
"github.com/theopenlane/core/internal/httpserve/server"
- "github.com/theopenlane/core/pkg/analytics"
- "github.com/theopenlane/core/pkg/events/kafka/publisher"
authmw "github.com/theopenlane/core/pkg/middleware/auth"
"github.com/theopenlane/core/pkg/middleware/cachecontrol"
"github.com/theopenlane/core/pkg/middleware/cors"
@@ -178,11 +176,15 @@ func WithAuth() ServerOption {
}
// WithReadyChecks adds readiness checks to the server
-func WithReadyChecks(c *entx.EntClientConfig, f *fgax.Client, r *redis.Client) ServerOption {
+func WithReadyChecks(c *entx.EntClientConfig, f *fgax.Client, r *redis.Client, j riverqueue.JobClient) ServerOption {
return newApplyFunc(func(s *ServerOptions) {
// Always add a check to the primary db connection
s.Config.Handler.AddReadinessCheck("db_primary", entx.Healthcheck(c.GetPrimaryDB()))
+ // Check the connection to the job queue
+ jc := j.(*riverqueue.Client)
+ s.Config.Handler.AddReadinessCheck(("job_queue"), riverqueue.Healthcheck(jc))
+
// Check the secondary db, if enabled
if s.Config.Settings.DB.MultiWrite {
s.Config.Handler.AddReadinessCheck("db_secondary", entx.Healthcheck(c.GetSecondaryDB()))
@@ -201,7 +203,7 @@ func WithReadyChecks(c *entx.EntClientConfig, f *fgax.Client, r *redis.Client) S
}
// WithGraphRoute adds the graph handler to the server
-func WithGraphRoute(srv *server.Server, c *generated.Client) ServerOption {
+func WithGraphRoute(srv *server.Server, c *ent.Client) ServerOption {
return newApplyFunc(func(s *ServerOptions) {
// Setup Graph API Handlers
r := graphapi.NewResolver(c).
@@ -243,55 +245,13 @@ func WithMiddleware() ServerOption {
})
}
-// WithEventPublisher sets up the default Kafka event publisher
-func WithEventPublisher() ServerOption {
- return newApplyFunc(func(s *ServerOptions) {
- ep := publisher.KafkaPublisher{
- Config: s.Config.Settings.Events,
- }
-
- publisher := publisher.NewKafkaPublisher(ep.Config.Addresses)
-
- s.Config.Handler.EventManager = publisher
- })
-}
-
-// WithEmailManager sets up the default SendGrid email manager to be used to send emails to users
+// WithEmailConfig sets up the email config to be used to send emails to users
// on registration, password reset, etc
-func WithEmailManager() ServerOption {
+func WithEmailConfig() ServerOption {
return newApplyFunc(func(s *ServerOptions) {
- em, err := emails.New(s.Config.Settings.Email)
- if err != nil {
- panic(err)
- }
-
- if err := s.Config.Settings.Email.ConsoleURLConfig.Validate(); err != nil {
- panic(err)
- }
-
- em.ConsoleURLConfig = s.Config.Settings.Email.ConsoleURLConfig
-
- if err := s.Config.Settings.Email.MarketingURLConfig.Validate(); err != nil {
- panic(err)
- }
+ log.Debug().Interface("email", s.Config.Settings.Email).Msg("email config")
- em.MarketingURLConfig = s.Config.Settings.Email.MarketingURLConfig
-
- s.Config.Handler.EmailManager = em
- })
-}
-
-// WithTaskManager sets up the default Marionette task manager to be used for delegating background tasks
-func WithTaskManager() ServerOption {
- return newApplyFunc(func(s *ServerOptions) {
- // Start task manager
- tmConfig := marionette.Config{}
-
- tm := marionette.New(tmConfig)
-
- tm.Start()
-
- s.Config.Handler.TaskMan = tm
+ s.Config.Handler.Emailer = s.Config.Settings.Email
})
}
@@ -348,26 +308,6 @@ func WithSessionMiddleware() ServerOption {
})
}
-// WithAnalytics sets up the PostHog analytics manager
-func WithAnalytics() ServerOption {
- return newApplyFunc(func(s *ServerOptions) {
- ph := s.Config.Settings.PostHog.Init()
- if ph == nil {
- s.Config.Handler.AnalyticsClient = &analytics.EventManager{
- Enabled: false,
- Handler: nil,
- }
-
- return
- }
-
- s.Config.Handler.AnalyticsClient = &analytics.EventManager{
- Enabled: true,
- Handler: ph,
- }
- })
-}
-
// WithOTP sets up the OTP provider
func WithOTP() ServerOption {
return newApplyFunc(func(s *ServerOptions) {
diff --git a/jsonschema/api-docs.md b/jsonschema/api-docs.md
index e4c5d07d..446f30b5 100644
--- a/jsonschema/api-docs.md
+++ b/jsonschema/api-docs.md
@@ -13,15 +13,13 @@ Config contains the configuration for the core server
|[**auth**](#auth)|`object`|Auth settings including oauth2 providers and token configuration
|yes|
|[**authz**](#authz)|`object`||yes|
|[**db**](#db)|`object`||yes|
-|[**dbx**](#dbx)|`object`|||
+|[**jobQueue**](#jobqueue)|`object`|||
|[**redis**](#redis)|`object`|||
|[**tracer**](#tracer)|`object`|||
|[**email**](#email)|`object`|||
|[**sessions**](#sessions)|`object`|||
-|[**posthog**](#posthog)|`object`|Config is the configuration for PostHog
||
|[**totp**](#totp)|`object`|||
|[**ratelimit**](#ratelimit)|`object`|Config defines the configuration settings for the default rate limiter
||
-|[**publisherConfig**](#publisherconfig)|`object`|Config is the configuration for the Kafka event source
||
**Additional Properties:** not allowed
@@ -413,17 +411,70 @@ OauthProviderConfig represents the configuration for OAuth providers such as Git
|**enableHistory**|`boolean`|enable history data to be logged to the database
|no|
**Additional Properties:** not allowed
-
-## dbx: object
+
+## jobQueue: object
**Properties**
|Name|Type|Description|Required|
|----|----|-----------|--------|
-|**enabled**|`boolean`|Enable the dbx client
||
-|**baseUrl**|`string`|Base URL for the dbx service
||
-|**endpoint**|`string`|Endpoint for the graphql api
||
-|**debug**|`boolean`|Enable debug mode
||
+|**connectionURI**|`string`|||
+|**runMigrations**|`boolean`|||
+|[**riverConf**](#jobqueueriverconf)|`object`|||
+
+**Additional Properties:** not allowed
+
+### jobQueue\.riverConf: object
+
+**Properties**
+
+|Name|Type|Description|Required|
+|----|----|-----------|--------|
+|**AdvisoryLockPrefix**|`integer`|||
+|**CancelledJobRetentionPeriod**|`integer`|||
+|**CompletedJobRetentionPeriod**|`integer`|||
+|**DiscardedJobRetentionPeriod**|`integer`|||
+|**ErrorHandler**||||
+|**FetchCooldown**|`integer`|||
+|**FetchPollInterval**|`integer`|||
+|**ID**|`string`|||
+|**JobCleanerTimeout**|`integer`|||
+|**JobTimeout**|`integer`|||
+|[**Logger**](#jobqueueriverconflogger)|`object`|||
+|**MaxAttempts**|`integer`|||
+|[**PeriodicJobs**](#jobqueueriverconfperiodicjobs)|`array`|||
+|**PollOnly**|`boolean`|||
+|[**Queues**](#jobqueueriverconfqueues)|`object`|||
+|**ReindexerSchedule**||||
+|**RescueStuckJobsAfter**|`integer`|||
+|**RetryPolicy**||||
+|**TestOnly**|`boolean`|||
+|[**Workers**](#jobqueueriverconfworkers)|`object`|||
+
+**Additional Properties:** not allowed
+
+#### jobQueue\.riverConf\.Logger: object
+
+**No properties.**
+
+**Additional Properties:** not allowed
+
+#### jobQueue\.riverConf\.PeriodicJobs: array
+
+**Items**
+
+
+#### jobQueue\.riverConf\.Queues: object
+
+**Additional Properties**
+
+|Name|Type|Description|Required|
+|----|----|-----------|--------|
+
+
+#### jobQueue\.riverConf\.Workers: object
+
+**No properties.**
**Additional Properties:** not allowed
@@ -501,38 +552,29 @@ OauthProviderConfig represents the configuration for OAuth providers such as Git
|Name|Type|Description|Required|
|----|----|-----------|--------|
-|**sendGridApiKey**|`string`|||
+|**companyName**|`string`|||
+|**companyAddress**|`string`|||
+|**corporation**|`string`|||
|**fromEmail**|`string`|||
-|**testing**|`boolean`|||
-|**archive**|`string`|||
-|**listId**|`string`|||
-|**adminEmail**|`string`|||
-|[**consoleUrl**](#emailconsoleurl)|`object`|||
-|[**marketingUrl**](#emailmarketingurl)|`object`|||
+|**supportEmail**|`string`|||
+|**logoURL**|`string`|||
+|[**urls**](#emailurls)|`object`|||
**Additional Properties:** not allowed
-
-### email\.consoleUrl: object
+
+### email\.urls: object
**Properties**
|Name|Type|Description|Required|
|----|----|-----------|--------|
-|**consoleBase**|`string`|||
+|**root**|`string`|||
+|**product**|`string`|||
+|**docs**|`string`|||
|**verify**|`string`|||
|**invite**|`string`|||
|**reset**|`string`|||
-
-**Additional Properties:** not allowed
-
-### email\.marketingUrl: object
-
-**Properties**
-
-|Name|Type|Description|Required|
-|----|----|-----------|--------|
-|**marketingBase**|`string`|||
-|**subscriberVerify**|`string`|||
+|**verifySubscriber**|`string`|||
**Additional Properties:** not allowed
@@ -546,21 +588,6 @@ OauthProviderConfig represents the configuration for OAuth providers such as Git
|**encryptionKey**|`string`|||
|**domain**|`string`|||
-**Additional Properties:** not allowed
-
-## posthog: object
-
-Config is the configuration for PostHog
-
-
-**Properties**
-
-|Name|Type|Description|Required|
-|----|----|-----------|--------|
-|**enabled**|`boolean`|Enabled is a flag to enable or disable PostHog
||
-|**apiKey**|`string`|APIKey is the PostHog API Key
||
-|**host**|`string`|Host is the PostHog API Host
||
-
**Additional Properties:** not allowed
## totp: object
@@ -594,27 +621,4 @@ Config defines the configuration settings for the default rate limiter
|**expires**|`integer`|||
**Additional Properties:** not allowed
-
-## publisherConfig: object
-
-Config is the configuration for the Kafka event source
-
-
-**Properties**
-
-|Name|Type|Description|Required|
-|----|----|-----------|--------|
-|**enabled**|`boolean`|Enabled is a flag to determine if the Kafka event source is enabled
||
-|**appName**|`string`|AppName is the name of the application that is publishing events
||
-|**address**|`string`|Address is the address of the Kafka broker
||
-|[**addresses**](#publisherconfigaddresses)|`string[]`|||
-|**debug**|`boolean`|Debug is a flag to determine if the Kafka client should run in debug mode
||
-
-**Additional Properties:** not allowed
-
-### publisherConfig\.addresses: array
-
-**Items**
-
-**Item Type:** `string`
diff --git a/jsonschema/core.config.json b/jsonschema/core.config.json
index 6d235e36..c400003b 100644
--- a/jsonschema/core.config.json
+++ b/jsonschema/core.config.json
@@ -2,6 +2,12 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/theopenlane/core/config/config.-config",
"$defs": {
+ "[]*river.PeriodicJob": {
+ "items": {
+ "$ref": "#/$defs/river.PeriodicJob"
+ },
+ "type": "array"
+ },
"[]string": {
"items": {
"type": "string"
@@ -232,61 +238,42 @@
"type": "object",
"description": "Config holds the cors configuration settings"
},
- "dbxclient.Config": {
- "properties": {
- "enabled": {
- "type": "boolean",
- "description": "Enable the dbx client"
- },
- "baseUrl": {
- "type": "string",
- "description": "Base URL for the dbx service"
- },
- "endpoint": {
- "type": "string",
- "description": "Endpoint for the graphql api"
- },
- "debug": {
- "type": "boolean",
- "description": "Enable debug mode"
- }
- },
- "additionalProperties": false,
- "type": "object"
- },
- "emails.Config": {
+ "emailtemplates.Config": {
"properties": {
- "sendGridApiKey": {
+ "companyName": {
"type": "string"
},
- "fromEmail": {
+ "companyAddress": {
"type": "string"
},
- "testing": {
- "type": "boolean"
- },
- "archive": {
+ "corporation": {
"type": "string"
},
- "listId": {
+ "fromEmail": {
"type": "string"
},
- "adminEmail": {
+ "supportEmail": {
"type": "string"
},
- "consoleUrl": {
- "$ref": "#/$defs/emails.ConsoleURLConfig"
+ "logoURL": {
+ "type": "string"
},
- "marketingUrl": {
- "$ref": "#/$defs/emails.MarketingURLConfig"
+ "urls": {
+ "$ref": "#/$defs/emailtemplates.URLConfig"
}
},
"additionalProperties": false,
"type": "object"
},
- "emails.ConsoleURLConfig": {
+ "emailtemplates.URLConfig": {
"properties": {
- "consoleBase": {
+ "root": {
+ "type": "string"
+ },
+ "product": {
+ "type": "string"
+ },
+ "docs": {
"type": "string"
},
"verify": {
@@ -297,17 +284,8 @@
},
"reset": {
"type": "string"
- }
- },
- "additionalProperties": false,
- "type": "object"
- },
- "emails.MarketingURLConfig": {
- "properties": {
- "marketingBase": {
- "type": "string"
},
- "subscriberVerify": {
+ "verifySubscriber": {
"type": "string"
}
},
@@ -541,39 +519,18 @@
"type": "object",
"description": "OauthProviderConfig represents the configuration for OAuth providers such as Github and Google"
},
- "kafkaconfig.Config": {
- "properties": {
- "enabled": {
- "type": "boolean",
- "description": "Enabled is a flag to determine if the Kafka event source is enabled"
- },
- "appName": {
- "type": "string",
- "description": "AppName is the name of the application that is publishing events"
- },
- "address": {
- "type": "string",
- "description": "Address is the address of the Kafka broker"
- },
- "addresses": {
- "$ref": "#/$defs/[]string",
- "description": "Addresses is a list of addresses of the Kafka brokers"
- },
- "debug": {
- "type": "boolean",
- "description": "Debug is a flag to determine if the Kafka client should run in debug mode"
- }
- },
- "additionalProperties": false,
- "type": "object",
- "description": "Config is the configuration for the Kafka event source"
- },
"map[string][]string": {
"additionalProperties": {
"$ref": "#/$defs/[]string"
},
"type": "object"
},
+ "map[string]river.QueueConfig": {
+ "additionalProperties": {
+ "$ref": "#/$defs/river.QueueConfig"
+ },
+ "type": "object"
+ },
"map[string]string": {
"additionalProperties": {
"type": "string"
@@ -656,25 +613,6 @@
"additionalProperties": false,
"type": "object"
},
- "posthog.Config": {
- "properties": {
- "enabled": {
- "type": "boolean",
- "description": "Enabled is a flag to enable or disable PostHog"
- },
- "apiKey": {
- "type": "string",
- "description": "APIKey is the PostHog API Key"
- },
- "host": {
- "type": "string",
- "description": "Host is the PostHog API Host"
- }
- },
- "additionalProperties": false,
- "type": "object",
- "description": "Config is the configuration for PostHog"
- },
"ratelimit.Config": {
"properties": {
"enabled": {
@@ -713,6 +651,100 @@
"type": "object",
"description": "Config contains the types used in executing redirects via the redirect middleware"
},
+ "river.Config": {
+ "properties": {
+ "AdvisoryLockPrefix": {
+ "type": "integer"
+ },
+ "CancelledJobRetentionPeriod": {
+ "type": "integer"
+ },
+ "CompletedJobRetentionPeriod": {
+ "type": "integer"
+ },
+ "DiscardedJobRetentionPeriod": {
+ "type": "integer"
+ },
+ "ErrorHandler": true,
+ "FetchCooldown": {
+ "type": "integer"
+ },
+ "FetchPollInterval": {
+ "type": "integer"
+ },
+ "ID": {
+ "type": "string"
+ },
+ "JobCleanerTimeout": {
+ "type": "integer"
+ },
+ "JobTimeout": {
+ "type": "integer"
+ },
+ "Logger": {
+ "$ref": "#/$defs/slog.Logger"
+ },
+ "MaxAttempts": {
+ "type": "integer"
+ },
+ "PeriodicJobs": {
+ "$ref": "#/$defs/[]*river.PeriodicJob"
+ },
+ "PollOnly": {
+ "type": "boolean"
+ },
+ "Queues": {
+ "$ref": "#/$defs/map[string]river.QueueConfig"
+ },
+ "ReindexerSchedule": true,
+ "RescueStuckJobsAfter": {
+ "type": "integer"
+ },
+ "RetryPolicy": true,
+ "TestOnly": {
+ "type": "boolean"
+ },
+ "Workers": {
+ "$ref": "#/$defs/river.Workers"
+ }
+ },
+ "additionalProperties": false,
+ "type": "object"
+ },
+ "river.PeriodicJob": {
+ "properties": {},
+ "additionalProperties": false,
+ "type": "object"
+ },
+ "river.QueueConfig": {
+ "properties": {
+ "MaxWorkers": {
+ "type": "integer"
+ }
+ },
+ "additionalProperties": false,
+ "type": "object"
+ },
+ "river.Workers": {
+ "properties": {},
+ "additionalProperties": false,
+ "type": "object"
+ },
+ "riverqueue.Config": {
+ "properties": {
+ "connectionURI": {
+ "type": "string"
+ },
+ "runMigrations": {
+ "type": "boolean"
+ },
+ "riverConf": {
+ "$ref": "#/$defs/river.Config"
+ }
+ },
+ "additionalProperties": false,
+ "type": "object"
+ },
"secure.Config": {
"properties": {
"enabled": {
@@ -771,6 +803,11 @@
"additionalProperties": false,
"type": "object"
},
+ "slog.Logger": {
+ "properties": {},
+ "additionalProperties": false,
+ "type": "object"
+ },
"tokens.Config": {
"properties": {
"kid": {
@@ -901,9 +938,9 @@
"$ref": "#/$defs/entx.Config",
"description": "DB contains the database configuration for the ent client"
},
- "dbx": {
- "$ref": "#/$defs/dbxclient.Config",
- "description": "DBx contains the dbx client configuration"
+ "jobQueue": {
+ "$ref": "#/$defs/riverqueue.Config",
+ "description": "JobQueue contains the configuration for the job queue (river) client"
},
"redis": {
"$ref": "#/$defs/cache.Config",
@@ -914,17 +951,13 @@
"description": "Tracer contains the tracing config for opentelemetry"
},
"email": {
- "$ref": "#/$defs/emails.Config",
+ "$ref": "#/$defs/emailtemplates.Config",
"description": "Email contains email sending configuration for the server"
},
"sessions": {
"$ref": "#/$defs/sessions.Config",
"description": "Sessions config for user sessions and cookies"
},
- "posthog": {
- "$ref": "#/$defs/posthog.Config",
- "description": "PostHog contains the configuration for the PostHog analytics"
- },
"totp": {
"$ref": "#/$defs/totp.Config",
"description": "TOTP contains the configuration for the TOTP provider"
@@ -932,10 +965,6 @@
"ratelimit": {
"$ref": "#/$defs/ratelimit.Config",
"description": "Ratelimit contains the configuration for the rate limiter"
- },
- "publisherConfig": {
- "$ref": "#/$defs/kafkaconfig.Config",
- "description": "EventPublisher contains the configuration for the event publisher"
}
},
"additionalProperties": false,
diff --git a/jsonschema/schema_generator.go b/jsonschema/schema_generator.go
index 6b948086..67c8fa62 100644
--- a/jsonschema/schema_generator.go
+++ b/jsonschema/schema_generator.go
@@ -37,9 +37,7 @@ var includedPackages = []string{
"./internal/ent",
"./internal/entdb",
"./internal/httpserve/handlers",
- "./pkg/analytics",
"./pkg/middleware",
- "./pkg/events/kafka/kafkaconfig",
}
// schemaConfig represents the configuration for the schema generator
diff --git a/pkg/analytics/analytics.go b/pkg/analytics/analytics.go
deleted file mode 100644
index 40cc3b5d..00000000
--- a/pkg/analytics/analytics.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package analytics
-
-import (
- ph "github.com/posthog/posthog-go"
-)
-
-// EventManager isn't your normal party planner
-type EventManager struct {
- Enabled bool
- Handler Handler
-}
-
-// Handler is an interface which can be used to call various event / event association parameters provided by the posthog API
-type Handler interface {
- Event(eventName string, properties ph.Properties)
-}
-
-// Event function is used to send an event to the analytics handler
-func (e *EventManager) Event(eventName string, properties ph.Properties) {
- if e.Enabled {
- e.Handler.Event(eventName, properties)
- }
-}
diff --git a/pkg/analytics/doc.go b/pkg/analytics/doc.go
deleted file mode 100644
index 4c597ae7..00000000
--- a/pkg/analytics/doc.go
+++ /dev/null
@@ -1,2 +0,0 @@
-// Package analytics offers system analytics
-package analytics
diff --git a/pkg/analytics/machine/doc.go b/pkg/analytics/machine/doc.go
deleted file mode 100644
index 5ea5babe..00000000
--- a/pkg/analytics/machine/doc.go
+++ /dev/null
@@ -1,2 +0,0 @@
-// Package machine provides a basic wrapper for getting machine ID
-package machine
diff --git a/pkg/analytics/machine/machine.go b/pkg/analytics/machine/machine.go
deleted file mode 100644
index ad720dbc..00000000
--- a/pkg/analytics/machine/machine.go
+++ /dev/null
@@ -1,26 +0,0 @@
-package machine
-
-import (
- "github.com/panta/machineid"
-)
-
-var (
- // ApplicationID is the unique Application ID
- ApplicationID = ""
-)
-
-var (
- id string
-)
-
-func init() {
- id, _ = machineid.ProtectedID(ApplicationID)
-}
-
-func ID() string {
- return id
-}
-
-func Available() bool {
- return id != ""
-}
diff --git a/pkg/analytics/posthog/doc.go b/pkg/analytics/posthog/doc.go
deleted file mode 100644
index 19a7d60f..00000000
--- a/pkg/analytics/posthog/doc.go
+++ /dev/null
@@ -1,2 +0,0 @@
-// Package posthog contains posthog helper functions and utilities
-package posthog
diff --git a/pkg/analytics/posthog/event.go b/pkg/analytics/posthog/event.go
deleted file mode 100644
index 1b8e6de9..00000000
--- a/pkg/analytics/posthog/event.go
+++ /dev/null
@@ -1,65 +0,0 @@
-package posthog
-
-import (
- "time"
-
- "github.com/posthog/posthog-go"
-
- "github.com/theopenlane/core/pkg/analytics/machine"
-)
-
-// Config is the configuration for PostHog
-type Config struct {
- // Enabled is a flag to enable or disable PostHog
- Enabled bool `json:"enabled" koanf:"enabled" default:"false"`
- // APIKey is the PostHog API Key
- APIKey string `json:"apiKey" koanf:"apiKey"`
- // Host is the PostHog API Host
- Host string `json:"host" koanf:"host" default:"https://app.posthog.com"`
-}
-
-type PostHog struct {
- client posthog.Client
- Identifier string
-}
-
-// Init returns a pointer to a PostHog object
-func (c *Config) Init() *PostHog {
- if !c.Enabled || c.APIKey == "" || c.Host == "" || !machine.Available() {
- return nil
- }
-
- client, _ := posthog.NewWithConfig(c.APIKey, posthog.Config{
- Endpoint: c.Host,
- BatchSize: 1,
- })
-
- if client != nil {
- return &PostHog{
- client: client,
- Identifier: machine.ID(),
- }
- }
-
- return nil
-}
-
-// Event is used to send an event to PostHog
-func (p *PostHog) Event(eventName string, properties posthog.Properties) {
- _ = p.client.Enqueue(posthog.Capture{
- DistinctId: p.Identifier,
- Event: eventName,
- Timestamp: time.Now(),
- Properties: properties,
- })
-}
-
-// Properties sets generic properties
-func (p *PostHog) Properties(id, obj string, properties posthog.Properties) {
- _ = p.client.Enqueue(posthog.GroupIdentify{
- Type: obj,
- Key: id,
- Timestamp: time.Now(),
- Properties: properties,
- })
-}
diff --git a/pkg/analytics/posthog/http.go b/pkg/analytics/posthog/http.go
deleted file mode 100644
index ac1bed9b..00000000
--- a/pkg/analytics/posthog/http.go
+++ /dev/null
@@ -1,26 +0,0 @@
-package posthog
-
-import (
- "net/http"
-
- "github.com/posthog/posthog-go"
-)
-
-// GetPackageToPosthogProperties can be used to parse out an http header and map the headers to posthog properties array
-func GetPackageToPosthogProperties(header *http.Header) posthog.Properties {
- properties := posthog.NewProperties().
- Set("browser", header.Get("browser")).
- Set("lang", header.Get("lang")).
- Set("lang_version", header.Get("lang_version")).
- Set("machine", header.Get("machine")).
- Set("os", header.Get("os")).
- Set("package_version", header.Get("package_version")).
- Set("processor", header.Get("processor")).
- Set("publisher", header.Get("publisher")).
- Set("release", header.Get("release")).
- Set("sdk_runtime", header.Get("sdk_runtime")).
- Set("system", header.Get("system")).
- Set("login_method", header.Get("user_agent"))
-
- return properties
-}
diff --git a/pkg/analytics/posthog/logger.go b/pkg/analytics/posthog/logger.go
deleted file mode 100644
index 8c8bb7f3..00000000
--- a/pkg/analytics/posthog/logger.go
+++ /dev/null
@@ -1,14 +0,0 @@
-package posthog
-
-import "github.com/posthog/posthog-go"
-
-var _ posthog.Logger = (*noopLogger)(nil)
-
-type noopLogger struct{}
-
-func (n *noopLogger) Logf(_ string, _ ...interface{}) {
- // noop logger noop's the logs
-}
-func (n noopLogger) Errorf(_ string, _ ...interface{}) {
- // noop logger noop's the logs
-}
diff --git a/pkg/events/doc.go b/pkg/events/doc.go
deleted file mode 100644
index 3865df60..00000000
--- a/pkg/events/doc.go
+++ /dev/null
@@ -1,2 +0,0 @@
-// Package events does event stuff
-package events
diff --git a/pkg/events/events.go b/pkg/events/events.go
deleted file mode 100644
index 5a46e060..00000000
--- a/pkg/events/events.go
+++ /dev/null
@@ -1,35 +0,0 @@
-package events
-
-import (
- "context"
-)
-
-// This file currently contains unused interfaces and types that will be called / integrated in the future
-
-// EventConsumer is the interface for consuming events
-type EventConsumer interface {
- Subscribe(ctx context.Context) error
- Close(context.Context) error
-}
-
-// EventPublisher is the interface for publishing events
-type EventPublisher interface {
- StartPublisher(context.Context) error
- Publish(ctx context.Context, topic string, payload interface{}) error
- Close(context.Context) error
-}
-
-// Properties is a map of properties to set on an event as a wrapper
-type Properties map[string]interface{}
-
-// NewProperties creates a new Properties map
-func NewProperties() Properties {
- return make(Properties, 10) //nolint:mnd
-}
-
-// Set sets a property on the Properties map
-func (p Properties) Set(name string, value interface{}) Properties {
- p[name] = value
-
- return p
-}
diff --git a/pkg/events/kafka/config/config.go b/pkg/events/kafka/config/config.go
deleted file mode 100644
index ef72aeca..00000000
--- a/pkg/events/kafka/config/config.go
+++ /dev/null
@@ -1,31 +0,0 @@
-package config
-
-type ConsumerConfig struct {
- Enabled bool `json:"enabled" koanf:"enabled" default:"false"`
- GroupID string `json:"groupId" koanf:"groupId"`
- Topics []string `json:"topics" koanf:"topics"`
- OffsetFromNewest bool `json:"offsetFromNewest" koanf:"offsetFromNewest" default:"false"`
- ConsumerOutput ConsumerOutput `json:"output" koanf:"output"`
-}
-
-type ConsumerOutput struct {
- Stdout bool `json:"stdout" koanf:"stdout" default:"false"`
- FileLocation string `json:"fileLocation" koanf:"fileLocation" default:"consumer.log"`
-}
-
-type Config struct {
- Address string `json:"address" koanf:"address" default:"localhost:10000"`
- Debug bool `json:"debug" koanf:"debug" default:"false"`
- Kafka struct {
- Addresses []string `json:"addresses" koanf:"addresses"`
- } `json:"kafkaAddresses" koanf:"kafkaAddresses"`
- Consumer struct {
- Enabled bool `json:"enabled" koanf:"enabled" default:"false"`
- GroupID string `json:"groupId" koanf:"groupId" default:"test-group"`
- Topics []string `json:"topics" koanf:"topics" default:"test-topic"`
- Output struct {
- Stdout bool `json:"stdout" koanf:"stdout" default:"false"`
- File string `json:"file" koanf:"file" default:"consumer.log"`
- } `json:"output"`
- }
-}
diff --git a/pkg/events/kafka/config/doc.go b/pkg/events/kafka/config/doc.go
deleted file mode 100644
index 92e173e4..00000000
--- a/pkg/events/kafka/config/doc.go
+++ /dev/null
@@ -1,2 +0,0 @@
-// Package config provides configuration for the Kafka event source
-package config
diff --git a/pkg/events/kafka/consumer/README.md b/pkg/events/kafka/consumer/README.md
deleted file mode 100644
index 60099d33..00000000
--- a/pkg/events/kafka/consumer/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# Example Consumer
-
-You can test your event producer fully works by adding a consumer to read the messages published on the Kafka broker; to see it in action, startup your kafka broker (or in our case run `task run-dev`), and then run:
-
-```go
-go run pkg/events/kafka/consumer/main.go -brokers="localhost:10000" -topics="sarama" -group="example"
-```
diff --git a/pkg/events/kafka/consumer/main.go b/pkg/events/kafka/consumer/main.go
deleted file mode 100644
index 1d206259..00000000
--- a/pkg/events/kafka/consumer/main.go
+++ /dev/null
@@ -1,219 +0,0 @@
-package main
-
-// SIGUSR1 toggle the pause/resume consumption
-import (
- "context"
- "errors"
- "flag"
- "log"
- "os"
- "os/signal"
- "strings"
- "sync"
- "syscall"
-
- "github.com/IBM/sarama"
-
- "github.com/theopenlane/utils/slack"
-)
-
-var (
- brokers = ""
- version = ""
- group = ""
- topics = ""
- assignor = ""
- oldest = true
- verbose = false
-)
-
-func init() {
- flag.StringVar(&brokers, "brokers", "", "Kafka bootstrap brokers to connect to, as a comma separated list")
- flag.StringVar(&group, "group", "", "Kafka consumer group definition")
- flag.StringVar(&version, "version", sarama.DefaultVersion.String(), "Kafka cluster version")
- flag.StringVar(&topics, "topics", "", "Kafka topics to be consumed, as a comma separated list")
- flag.StringVar(&assignor, "assignor", "range", "Consumer group partition assignment strategy (range, roundrobin, sticky)")
- flag.BoolVar(&oldest, "oldest", true, "Kafka consumer consume initial offset from oldest")
- flag.BoolVar(&verbose, "verbose", false, "Sarama logging")
- flag.Parse()
-
- if len(brokers) == 0 {
- panic("no Kafka bootstrap brokers defined, please set the -brokers flag")
- }
-
- if len(topics) == 0 {
- panic("no topics given to be consumed, please set the -topics flag")
- }
-
- if len(group) == 0 {
- panic("no Kafka consumer group defined, please set the -group flag")
- }
-}
-
-func main() {
- keepRunning := true
-
- log.Println("Starting a new Sarama consumer")
-
- if verbose {
- sarama.Logger = log.New(os.Stdout, "[sarama] ", log.LstdFlags)
- }
-
- version, err := sarama.ParseKafkaVersion(version)
- if err != nil {
- log.Panicf("Error parsing Kafka version: %v", err)
- }
-
- config := sarama.NewConfig()
- config.Version = version
-
- switch assignor {
- case "sticky":
- config.Consumer.Group.Rebalance.GroupStrategies = []sarama.BalanceStrategy{sarama.NewBalanceStrategySticky()}
- case "roundrobin":
- config.Consumer.Group.Rebalance.GroupStrategies = []sarama.BalanceStrategy{sarama.NewBalanceStrategyRoundRobin()}
- case "range":
- config.Consumer.Group.Rebalance.GroupStrategies = []sarama.BalanceStrategy{sarama.NewBalanceStrategyRange()}
- default:
- log.Panicf("Unrecognized consumer group partition assignor: %s", assignor)
- }
-
- if oldest {
- config.Consumer.Offsets.Initial = sarama.OffsetOldest
- }
-
- consumer := Consumer{
- ready: make(chan bool),
- }
-
- ctx, cancel := context.WithCancel(context.Background())
-
- client, err := sarama.NewConsumerGroup(strings.Split(brokers, ","), group, config)
- if err != nil {
- log.Panicf("Error creating consumer group client: %v", err)
- }
-
- consumptionIsPaused := false
- wg := &sync.WaitGroup{}
- wg.Add(1)
-
- go func() {
- defer wg.Done()
-
- for {
- // `Consume` should be called inside an infinite loop, when a
- // server-side rebalance happens, the consumer session will need to be
- // recreated to get the new claims
- if err := client.Consume(ctx, strings.Split(topics, ","), &consumer); err != nil {
- if errors.Is(err, sarama.ErrClosedConsumerGroup) {
- return
- }
-
- log.Panicf("Error from consumer: %v", err)
- }
- // check if context was cancelled, signaling that the consumer should stop
- if ctx.Err() != nil {
- return
- }
-
- consumer.ready = make(chan bool)
- }
- }()
-
- <-consumer.ready // Await till the consumer has been set up
- log.Println("Sarama consumer up and running!...")
-
- sigusr1 := make(chan os.Signal, 1)
- signal.Notify(sigusr1, syscall.SIGUSR1)
-
- sigterm := make(chan os.Signal, 1)
- signal.Notify(sigterm, syscall.SIGINT, syscall.SIGTERM)
-
- for keepRunning {
- select {
- case <-ctx.Done():
- log.Println("terminating: context cancelled")
-
- keepRunning = false
- case <-sigterm:
- log.Println("terminating: via signal")
-
- keepRunning = false
- case <-sigusr1:
- toggleConsumptionFlow(client, &consumptionIsPaused)
- }
- }
-
- cancel()
-
- wg.Wait()
-
- if err = client.Close(); err != nil {
- log.Panicf("Error closing client: %v", err)
- }
-}
-
-func toggleConsumptionFlow(client sarama.ConsumerGroup, isPaused *bool) {
- if *isPaused {
- client.ResumeAll()
- log.Println("Resuming consumption")
- } else {
- client.PauseAll()
- log.Println("Pausing consumption")
- }
-
- *isPaused = !*isPaused
-}
-
-// Consumer represents a Sarama consumer group consumer
-type Consumer struct {
- ready chan bool
-}
-
-// Setup is run at the beginning of a new session, before ConsumeClaim
-func (consumer *Consumer) Setup(sarama.ConsumerGroupSession) error {
- // Mark the consumer as ready
- close(consumer.ready)
- return nil
-}
-
-// Cleanup is run at the end of a session, once all ConsumeClaim goroutines have exited
-func (consumer *Consumer) Cleanup(sarama.ConsumerGroupSession) error {
- return nil
-}
-
-// ConsumeClaim must start a consumer loop of ConsumerGroupClaim's Messages().
-// Once the Messages() channel is closed, the Handler must finish its processing
-// loop and exit
-func (consumer *Consumer) ConsumeClaim(session sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error {
- // Do not move the code below to a goroutine.
- // The `ConsumeClaim` itself is called within a goroutine
- for {
- select {
- case message, ok := <-claim.Messages():
- if !ok {
- log.Printf("message channel was closed")
- return nil
- }
-
- log.Printf("Message claimed: value = %s, timestamp = %v, topic = %s", string(message.Value), message.Timestamp, message.Topic)
- // Will move this into an actual configuration parameter later
- webhookURL := ""
-
- payload := slack.Payload{
- Text: "I am a slack message that was sent by a Kafka consumer gobbling up messages produced via the EventManager!",
- }
-
- slackMessage := slack.New(webhookURL)
- if err := slackMessage.Post(context.Background(), &payload); err != nil {
- log.Printf("error: %s\n", err)
- }
-
- session.MarkMessage(message, "")
- // Should return when `session.Context()` is done.
- // If not, will raise `ErrRebalanceInProgress` or `read tcp :: i/o timeout` when kafka rebalanc
- case <-session.Context().Done():
- return nil
- }
- }
-}
diff --git a/pkg/events/kafka/kafkaconfig/config.go b/pkg/events/kafka/kafkaconfig/config.go
deleted file mode 100644
index 2406434f..00000000
--- a/pkg/events/kafka/kafkaconfig/config.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package kafkaconfig
-
-// Config is the configuration for the Kafka event source
-type Config struct {
- // Enabled is a flag to determine if the Kafka event source is enabled
- Enabled bool `json:"enabled" koanf:"enabled" default:"false"`
- // AppName is the name of the application that is publishing events
- AppName string `json:"appName" koanf:"appName" default:"openlane"`
- // Address is the address of the Kafka broker
- Address string `json:"address" koanf:"address" default:"localhost:10000"`
- // Addresses is a list of addresses of the Kafka brokers
- Addresses []string `json:"addresses" koanf:"addresses" default:"[localhost:10000]"`
- // Debug is a flag to determine if the Kafka client should run in debug mode
- Debug bool `json:"debug" koanf:"debug" default:"false"`
-}
diff --git a/pkg/events/kafka/kafkaconfig/doc.go b/pkg/events/kafka/kafkaconfig/doc.go
deleted file mode 100644
index f0635ce5..00000000
--- a/pkg/events/kafka/kafkaconfig/doc.go
+++ /dev/null
@@ -1,2 +0,0 @@
-// Package kafkaconfig provides configuration for the Kafka event source
-package kafkaconfig
diff --git a/pkg/events/kafka/publisher/doc.go b/pkg/events/kafka/publisher/doc.go
deleted file mode 100644
index d7dd0530..00000000
--- a/pkg/events/kafka/publisher/doc.go
+++ /dev/null
@@ -1,2 +0,0 @@
-// Package publisher provides a basic kafka event publisher
-package publisher
diff --git a/pkg/events/kafka/publisher/publisher.go b/pkg/events/kafka/publisher/publisher.go
deleted file mode 100644
index 33e394e7..00000000
--- a/pkg/events/kafka/publisher/publisher.go
+++ /dev/null
@@ -1,48 +0,0 @@
-package publisher
-
-import (
- "github.com/IBM/sarama"
-
- "github.com/theopenlane/core/pkg/events/kafka/kafkaconfig"
-)
-
-// KafkaPublisher is a publisher that sends messages to a Kafka topic
-type KafkaPublisher struct {
- // Broker is a list of Kafka brokers
- Broker []string
- // Config is the configuration for the Kafka event source
- Config kafkaconfig.Config
-}
-
-// NewKafkaPublisher creates a new KafkaPublisher
-func NewKafkaPublisher(broker []string) *KafkaPublisher {
- return &KafkaPublisher{
- Broker: broker,
- }
-}
-
-// Publisher is an interface for publishing messages
-type Publisher interface {
- Publish(topic string, message []byte) error
-}
-
-// Publish satisfies the Publisher interface
-func (kp *KafkaPublisher) Publish(topic string, message []byte) error {
- config := sarama.NewConfig()
- config.Producer.RequiredAcks = sarama.WaitForAll
- config.Producer.Retry.Max = 5
- config.Producer.Return.Successes = true
-
- producer, err := sarama.NewSyncProducer(kp.Broker, config)
- if err != nil {
- return err
- }
- defer producer.Close()
-
- _, _, err = producer.SendMessage(&sarama.ProducerMessage{
- Topic: topic,
- Value: sarama.ByteEncoder(message),
- })
-
- return err
-}
diff --git a/pkg/middleware/auth/auth.go b/pkg/middleware/auth/auth.go
index a20b4dac..dd9d0711 100644
--- a/pkg/middleware/auth/auth.go
+++ b/pkg/middleware/auth/auth.go
@@ -13,7 +13,7 @@ import (
"github.com/theopenlane/iam/auth"
"github.com/theopenlane/iam/tokens"
- "github.com/theopenlane/core/internal/ent/generated"
+ ent "github.com/theopenlane/core/internal/ent/generated"
"github.com/theopenlane/core/internal/ent/generated/apitoken"
"github.com/theopenlane/core/internal/ent/generated/personalaccesstoken"
"github.com/theopenlane/core/internal/ent/generated/privacy"
@@ -73,11 +73,6 @@ func Authenticate(conf *AuthOptions) echo.MiddlewareFunc {
claims, err := validator.Verify(accessToken)
if err != nil {
- // if its not a JWT, check to see if its a PAT or API Token
- if conf.DBClient == nil {
- return rout.HTTPErrorResponse(rout.ErrInvalidCredentials)
- }
-
au, id, err = checkToken(c.Request().Context(), conf, accessToken)
if err != nil {
return rout.HTTPErrorResponse(rout.ErrInvalidCredentials)
@@ -104,7 +99,7 @@ func Authenticate(conf *AuthOptions) echo.MiddlewareFunc {
}
// updateLastUsed updates the last used time for the token depending on the authentication type
-func updateLastUsed(ctx context.Context, dbClient *generated.Client, au *auth.AuthenticatedUser, tokenID string) error {
+func updateLastUsed(ctx context.Context, dbClient *ent.Client, au *auth.AuthenticatedUser, tokenID string) error {
switch au.AuthenticationType {
case auth.PATAuthentication:
// allow the request, we know the user has access to the token, no need to check
@@ -163,7 +158,7 @@ func Reauthenticate(conf *AuthOptions, validator tokens.Validator) func(c echo.C
}
// createAuthenticatedUserFromClaims creates an authenticated user from the claims provided
-func createAuthenticatedUserFromClaims(ctx context.Context, dbClient *generated.Client, claims *tokens.Claims, authType auth.AuthenticationType) (*auth.AuthenticatedUser, error) {
+func createAuthenticatedUserFromClaims(ctx context.Context, dbClient *ent.Client, claims *tokens.Claims, authType auth.AuthenticationType) (*auth.AuthenticatedUser, error) {
// get the user ID from the claims
user, err := dbClient.User.Get(ctx, claims.UserID)
if err != nil {
@@ -196,13 +191,13 @@ func checkToken(ctx context.Context, conf *AuthOptions, token string) (*auth.Aut
ctx = privacy.DecisionContext(ctx, privacy.Allow)
// check if the token is a personal access token
- au, id, err := isValidPersonalAccessToken(ctx, conf.DBClient, token)
+ au, id, err := isValidPersonalAccessToken(ctx, *conf.DBClient, token)
if err == nil {
return au, id, nil
}
// check if the token is an API token
- au, id, err = isValidAPIToken(ctx, conf.DBClient, token)
+ au, id, err = isValidAPIToken(ctx, *conf.DBClient, token)
if err == nil {
return au, id, nil
}
@@ -211,7 +206,7 @@ func checkToken(ctx context.Context, conf *AuthOptions, token string) (*auth.Aut
}
// isValidPersonalAccessToken checks if the provided token is a valid personal access token and returns the authenticated user
-func isValidPersonalAccessToken(ctx context.Context, dbClient *generated.Client, token string) (*auth.AuthenticatedUser, string, error) {
+func isValidPersonalAccessToken(ctx context.Context, dbClient ent.Client, token string) (*auth.AuthenticatedUser, string, error) {
pat, err := dbClient.PersonalAccessToken.Query().Where(personalaccesstoken.Token(token)).
WithOwner().
WithOrganizations().
@@ -247,7 +242,7 @@ func isValidPersonalAccessToken(ctx context.Context, dbClient *generated.Client,
}, pat.ID, nil
}
-func isValidAPIToken(ctx context.Context, dbClient *generated.Client, token string) (*auth.AuthenticatedUser, string, error) {
+func isValidAPIToken(ctx context.Context, dbClient ent.Client, token string) (*auth.AuthenticatedUser, string, error) {
t, err := dbClient.APIToken.Query().Where(apitoken.Token(token)).
Only(ctx)
if err != nil {
@@ -269,7 +264,7 @@ func isValidAPIToken(ctx context.Context, dbClient *generated.Client, token stri
}
// getSubjectName returns the subject name for the user
-func getSubjectName(user *generated.User) string {
+func getSubjectName(user *ent.User) string {
subjectName := user.FirstName + " " + user.LastName
if subjectName == "" {
subjectName = user.DisplayName
diff --git a/pkg/testutils/client.go b/pkg/testutils/client.go
index 6541fbb4..5f82ea35 100644
--- a/pkg/testutils/client.go
+++ b/pkg/testutils/client.go
@@ -8,13 +8,14 @@ import (
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/handler/extension"
"github.com/99designs/gqlgen/graphql/handler/lru"
- "github.com/theopenlane/core/internal/ent/generated"
"github.com/theopenlane/core/internal/graphapi"
"github.com/theopenlane/core/pkg/middleware/auth"
"github.com/theopenlane/core/pkg/openlaneclient"
echo "github.com/theopenlane/echox"
"github.com/theopenlane/echox/middleware/echocontext"
"github.com/vektah/gqlparser/v2/ast"
+
+ ent "github.com/theopenlane/core/internal/ent/generated"
)
// localRoundTripper is an http.RoundTripper that executes HTTP transactions
@@ -31,7 +32,7 @@ func (l localRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)
}
// TestClient creates a new OpenlaneClient for testing
-func TestClient(t *testing.T, c *generated.Client, opts ...openlaneclient.ClientOption) (*openlaneclient.OpenlaneClient, error) {
+func TestClient(t *testing.T, c *ent.Client, opts ...openlaneclient.ClientOption) (*openlaneclient.OpenlaneClient, error) {
e := testEchoServer(t, c, false)
// setup interceptors
@@ -47,7 +48,7 @@ func TestClient(t *testing.T, c *generated.Client, opts ...openlaneclient.Client
}
// TestClientWithAuth creates a new OpenlaneClient for testing that includes the auth middleware
-func TestClientWithAuth(t *testing.T, c *generated.Client, opts ...openlaneclient.ClientOption) (*openlaneclient.OpenlaneClient, error) {
+func TestClientWithAuth(t *testing.T, c *ent.Client, opts ...openlaneclient.ClientOption) (*openlaneclient.OpenlaneClient, error) {
e := testEchoServer(t, c, true)
// setup interceptors
@@ -64,7 +65,7 @@ func TestClientWithAuth(t *testing.T, c *generated.Client, opts ...openlaneclien
// testEchoServer creates a new echo server for testing the graph api
// and optionally includes the middleware for authentication testing
-func testEchoServer(t *testing.T, c *generated.Client, includeMiddleware bool) *echo.Echo {
+func testEchoServer(t *testing.T, c *ent.Client, includeMiddleware bool) *echo.Echo {
srv := testGraphServer(t, c)
e := echo.New()
@@ -88,7 +89,7 @@ func testEchoServer(t *testing.T, c *generated.Client, includeMiddleware bool) *
// createAuthConfig creates a new auth config for testing with the provided client
// and local validator
-func createAuthConfig(c *generated.Client) *auth.AuthOptions {
+func createAuthConfig(c *ent.Client) *auth.AuthOptions {
// setup auth middleware
opts := []auth.AuthOption{
auth.WithDBClient(c),
@@ -102,7 +103,7 @@ func createAuthConfig(c *generated.Client) *auth.AuthOptions {
}
// testGraphServer creates a new graphql server for testing the graph api
-func testGraphServer(t *testing.T, c *generated.Client) *handler.Server {
+func testGraphServer(t *testing.T, c *ent.Client) *handler.Server {
srv := handler.NewDefaultServer(
graphapi.NewExecutableSchema(
graphapi.Config{Resolvers: graphapi.NewResolver(c)},