@getstrata/bootstrap 0.2.22 → 0.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bootstrap/applicationRegistry.d.ts +1 -1
- package/dist/bootstrap/buildModuleRoutes.d.ts +10 -0
- package/dist/bootstrap/config.d.ts +1 -1
- package/dist/bootstrap/contracts.d.ts +4 -4
- package/dist/bootstrap/public-api.d.ts +2 -0
- package/dist/entries/applicationRegistry.js +12 -115
- package/dist/entries/buildModuleRoutes.js +626 -0
- package/dist/entries/config.js +9 -9
- package/dist/entries/context.js +114 -178
- package/dist/entries/contracts.js +10 -85
- package/dist/entries/createWebRoutes.js +9 -9
- package/dist/entries/dependencies.js +114 -178
- package/dist/entries/http/securedRouteModelBinding.js +4 -34
- package/dist/entries/httpKernel.js +9 -9
- package/dist/entries/membershipService.js +0 -34
- package/dist/entries/providers/view.js +9 -9
- package/dist/entries/providers.js +104 -115
- package/dist/entries/queue/defaultJobs.js +0 -34
- package/dist/entries/web/routing.js +20 -41
- package/dist/index.js +1670 -1659
- package/package.json +9 -4
- package/dist/cli/commands/scheduleRun.d.ts +0 -3
- package/dist/config/app.d.ts +0 -10
- package/dist/config/auth.d.ts +0 -7
- package/dist/config/contentSecurityPolicy.d.ts +0 -5
- package/dist/config/cors.d.ts +0 -9
- package/dist/config/database.d.ts +0 -10
- package/dist/config/features.d.ts +0 -18
- package/dist/config/frontend.d.ts +0 -6
- package/dist/config/queue.d.ts +0 -8
- package/dist/config/rateLimit.d.ts +0 -10
- package/dist/config/uploads.d.ts +0 -5
- package/dist/core/admin/formatValue.d.ts +0 -3
- package/dist/core/admin/index.d.ts +0 -3
- package/dist/core/admin/registry.d.ts +0 -11
- package/dist/core/admin/types.d.ts +0 -24
- package/dist/core/audit/exportAuditLogs.d.ts +0 -8
- package/dist/core/audit/siemFormatter.d.ts +0 -30
- package/dist/core/auth/abilityChecker.d.ts +0 -6
- package/dist/core/auth/accessControl.d.ts +0 -8
- package/dist/core/auth/authContext.d.ts +0 -11
- package/dist/core/auth/guard.d.ts +0 -36
- package/dist/core/auth/membershipContext.d.ts +0 -15
- package/dist/core/auth/membershipContextMiddleware.d.ts +0 -3
- package/dist/core/auth/membershipMiddleware.d.ts +0 -2
- package/dist/core/auth/membershipScope.d.ts +0 -16
- package/dist/core/auth/membershipService.d.ts +0 -23
- package/dist/core/auth/oauth/oidcProvider.d.ts +0 -18
- package/dist/core/auth/oauth/providers.d.ts +0 -22
- package/dist/core/auth/oauth/samlProvider.d.ts +0 -9
- package/dist/core/auth/oauth/types.d.ts +0 -11
- package/dist/core/auth/password.d.ts +0 -3
- package/dist/core/auth/policy.d.ts +0 -15
- package/dist/core/auth/resolveMembershipService.d.ts +0 -3
- package/dist/core/auth/scimAuthMiddleware.d.ts +0 -3
- package/dist/core/auth/sessionCookie.d.ts +0 -6
- package/dist/core/auth/sessionGuard.d.ts +0 -9
- package/dist/core/auth/tokenHash.d.ts +0 -3
- package/dist/core/cache/createCacheStore.d.ts +0 -11
- package/dist/core/cache/redisCacheStore.d.ts +0 -23
- package/dist/core/cache/repository.d.ts +0 -17
- package/dist/core/cache/simpleCache.d.ts +0 -23
- package/dist/core/cache/simpleCacheStore.d.ts +0 -16
- package/dist/core/cache/store.d.ts +0 -12
- package/dist/core/cache/taggedCache.d.ts +0 -9
- package/dist/core/cache/tags.d.ts +0 -11
- package/dist/core/config/envSchema.d.ts +0 -12
- package/dist/core/contracts/container.d.ts +0 -30
- package/dist/core/contracts/di.d.ts +0 -31
- package/dist/core/contracts/serviceContainer.d.ts +0 -1
- package/dist/core/contracts/serviceTokens.d.ts +0 -8
- package/dist/core/crypto/fieldEncryption.d.ts +0 -13
- package/dist/core/crypto/mfaSecret.d.ts +0 -3
- package/dist/core/crypto/nonCryptographicHash.d.ts +0 -2
- package/dist/core/database/baseRepository.d.ts +0 -67
- package/dist/core/database/bindConnection.d.ts +0 -3
- package/dist/core/database/boundConnection.d.ts +0 -5
- package/dist/core/database/connection.d.ts +0 -7
- package/dist/core/database/connectionContext.d.ts +0 -8
- package/dist/core/database/defaultConnection.d.ts +0 -6
- package/dist/core/database/errors.d.ts +0 -12
- package/dist/core/database/index.d.ts +0 -18
- package/dist/core/database/migrations/advisoryLock.d.ts +0 -6
- package/dist/core/database/migrations/runner.d.ts +0 -25
- package/dist/core/database/migrations/types.d.ts +0 -15
- package/dist/core/database/model.d.ts +0 -57
- package/dist/core/database/query.d.ts +0 -63
- package/dist/core/database/queryProxy.d.ts +0 -3
- package/dist/core/database/relationships.d.ts +0 -100
- package/dist/core/database/repositoryConnection.d.ts +0 -4
- package/dist/core/database/repositoryQuery.d.ts +0 -38
- package/dist/core/database/schema/blueprint.d.ts +0 -47
- package/dist/core/database/schema/columnDefinition.d.ts +0 -36
- package/dist/core/database/schema/driver.d.ts +0 -8
- package/dist/core/database/schema/errors.d.ts +0 -4
- package/dist/core/database/schema/grammars/compileStatements.d.ts +0 -8
- package/dist/core/database/schema/grammars/createGrammar.d.ts +0 -4
- package/dist/core/database/schema/grammars/grammar.d.ts +0 -10
- package/dist/core/database/schema/grammars/index.d.ts +0 -7
- package/dist/core/database/schema/grammars/mysqlGrammar.d.ts +0 -2
- package/dist/core/database/schema/grammars/postgresGrammar.d.ts +0 -2
- package/dist/core/database/schema/grammars/sqliteGrammar.d.ts +0 -2
- package/dist/core/database/schema/index.d.ts +0 -12
- package/dist/core/database/schema/schema.d.ts +0 -21
- package/dist/core/database/seeders/runner.d.ts +0 -6
- package/dist/core/database/seeders/types.d.ts +0 -8
- package/dist/core/database/table.d.ts +0 -13
- package/dist/core/database/transaction.d.ts +0 -3
- package/dist/core/database/types.d.ts +0 -66
- package/dist/core/database/whereBuilder.d.ts +0 -17
- package/dist/core/errors/http.d.ts +0 -33
- package/dist/core/events/eventBus.d.ts +0 -10
- package/dist/core/events/index.d.ts +0 -4
- package/dist/core/facades/index.d.ts +0 -10
- package/dist/core/http/authMiddleware.d.ts +0 -5
- package/dist/core/http/authorizeMiddleware.d.ts +0 -5
- package/dist/core/http/bodySizeLimitMiddleware.d.ts +0 -4
- package/dist/core/http/conditionalResponse.d.ts +0 -2
- package/dist/core/http/contentNegotiation.d.ts +0 -2
- package/dist/core/http/cookies.d.ts +0 -4
- package/dist/core/http/corsMiddleware.d.ts +0 -3
- package/dist/core/http/csrfMiddleware.d.ts +0 -3
- package/dist/core/http/csrfProtection.d.ts +0 -12
- package/dist/core/http/csrfToken.d.ts +0 -14
- package/dist/core/http/etag.d.ts +0 -18
- package/dist/core/http/flashMiddleware.d.ts +0 -3
- package/dist/core/http/flashSession.d.ts +0 -12
- package/dist/core/http/formRequest.d.ts +0 -10
- package/dist/core/http/index.d.ts +0 -27
- package/dist/core/http/loginThrottleMiddleware.d.ts +0 -11
- package/dist/core/http/memoryThrottleMiddleware.d.ts +0 -9
- package/dist/core/http/metricsMiddleware.d.ts +0 -4
- package/dist/core/http/middleware.d.ts +0 -8
- package/dist/core/http/pagination.d.ts +0 -11
- package/dist/core/http/parseFormBody.d.ts +0 -6
- package/dist/core/http/parseMultipartUpload.d.ts +0 -10
- package/dist/core/http/requestMetaContext.d.ts +0 -15
- package/dist/core/http/requireAbilityMiddleware.d.ts +0 -4
- package/dist/core/http/requireAuthMiddleware.d.ts +0 -4
- package/dist/core/http/requireGlobalAdminMiddleware.d.ts +0 -3
- package/dist/core/http/requireWebAuthMiddleware.d.ts +0 -4
- package/dist/core/http/resources.d.ts +0 -7
- package/dist/core/http/route.d.ts +0 -6
- package/dist/core/http/routeMiddleware.d.ts +0 -3
- package/dist/core/http/routeModelBinding.d.ts +0 -3
- package/dist/core/http/scimThrottleMiddleware.d.ts +0 -9
- package/dist/core/http/securedRouteModelBinding.d.ts +0 -11
- package/dist/core/http/securityHeadersMiddleware.d.ts +0 -3
- package/dist/core/http/throttleMiddleware.d.ts +0 -11
- package/dist/core/http/validation.d.ts +0 -23
- package/dist/core/http/webErrorResponse.d.ts +0 -5
- package/dist/core/http/webFormRequest.d.ts +0 -7
- package/dist/core/jobs/dispatchWebhookJob.d.ts +0 -13
- package/dist/core/jobs/invalidateCacheTagsJob.d.ts +0 -12
- package/dist/core/lifecycle/gracefulShutdown.d.ts +0 -6
- package/dist/core/logging/logger.d.ts +0 -17
- package/dist/core/logging/requestLoggingMiddleware.d.ts +0 -3
- package/dist/core/mail/mailer.d.ts +0 -38
- package/dist/core/mail/markdownMail.d.ts +0 -15
- package/dist/core/mail/markdownMailable.d.ts +0 -12
- package/dist/core/metrics/prometheus.d.ts +0 -26
- package/dist/core/notifications/dispatcher.d.ts +0 -13
- package/dist/core/notifications/index.d.ts +0 -3
- package/dist/core/notifications/notification.d.ts +0 -7
- package/dist/core/notifications/types.d.ts +0 -25
- package/dist/core/openapi/registeredRoute.d.ts +0 -6
- package/dist/core/pagination/index.d.ts +0 -27
- package/dist/core/queue/createAppQueue.d.ts +0 -5
- package/dist/core/queue/failedJobRepository.d.ts +0 -6
- package/dist/core/queue/failedJobService.d.ts +0 -16
- package/dist/core/queue/failedJobTable.d.ts +0 -3
- package/dist/core/queue/index.d.ts +0 -19
- package/dist/core/queue/jobRegistry.d.ts +0 -13
- package/dist/core/queue/jobRunner.d.ts +0 -9
- package/dist/core/queue/publicQueue.d.ts +0 -16
- package/dist/core/queue/queueMetrics.d.ts +0 -15
- package/dist/core/queue/redisQueue.d.ts +0 -29
- package/dist/core/queue/resilientQueue.d.ts +0 -9
- package/dist/core/queue/types.d.ts +0 -8
- package/dist/core/runtime/applicationRegistry.d.ts +0 -17
- package/dist/core/runtime/asyncContextStore.d.ts +0 -3
- package/dist/core/scheduler/schedule.d.ts +0 -15
- package/dist/core/security/publicReads.d.ts +0 -3
- package/dist/core/security/safeFetch.d.ts +0 -10
- package/dist/core/security/safeUrl.d.ts +0 -20
- package/dist/core/security/scimTenantTokens.d.ts +0 -3
- package/dist/core/security/securityEvents.d.ts +0 -6
- package/dist/core/security/timingSafeCompare.d.ts +0 -2
- package/dist/core/security/tokenExpiry.d.ts +0 -2
- package/dist/core/security/totp.d.ts +0 -3
- package/dist/core/storage/storage.d.ts +0 -44
- package/dist/core/tenant/databaseTenantContext.d.ts +0 -2
- package/dist/core/tenant/resolveTenant.d.ts +0 -3
- package/dist/core/tenant/tenantContext.d.ts +0 -13
- package/dist/core/tenant/tenantDatabaseScope.d.ts +0 -8
- package/dist/core/tenant/tenantMiddleware.d.ts +0 -6
- package/dist/core/tracing/otel.d.ts +0 -26
- package/dist/core/tracing/traceContext.d.ts +0 -9
- package/dist/core/tracing/tracingMiddleware.d.ts +0 -3
- package/dist/core/validation/rules.d.ts +0 -17
- package/dist/core/view/etaViewEngine.d.ts +0 -15
- package/dist/core/view/htmlResponse.d.ts +0 -6
- package/dist/core/view/index.d.ts +0 -5
- package/dist/core/view/viewEngine.d.ts +0 -6
- package/dist/core/view/webLayoutData.d.ts +0 -17
- package/dist/db/connection/createConnection.d.ts +0 -6
- package/dist/db/connection/index.d.ts +0 -11
- package/dist/domain/abilities.d.ts +0 -5
- package/dist/domain/auth.d.ts +0 -4
- package/dist/domain/scim.d.ts +0 -9
- package/dist/domain/workhub.d.ts +0 -35
- package/dist/framework/public-api.d.ts +0 -116
- package/dist/modules/organization/memberRepository.d.ts +0 -14
- package/dist/modules/organization/memberTypes.d.ts +0 -9
- package/dist/modules/organization/repository.d.ts +0 -14
- package/dist/modules/organization/table.d.ts +0 -3
- package/dist/modules/organization/types.d.ts +0 -10
- package/dist/modules/scim/controller.d.ts +0 -16
- package/dist/modules/scim/scimResponse.d.ts +0 -10
- package/dist/modules/scim/service.d.ts +0 -214
- package/dist/modules/user/apiTokenRepository.d.ts +0 -8
- package/dist/modules/user/apiTokenTable.d.ts +0 -3
- package/dist/modules/user/authService.d.ts +0 -23
- package/dist/modules/user/notificationRepository.d.ts +0 -6
- package/dist/modules/user/notificationService.d.ts +0 -25
- package/dist/modules/user/notificationTable.d.ts +0 -3
- package/dist/modules/user/notificationTypes.d.ts +0 -12
- package/dist/modules/user/oauthIdentityRepository.d.ts +0 -9
- package/dist/modules/user/provider.d.ts +0 -11
- package/dist/modules/user/repository.d.ts +0 -13
- package/dist/modules/user/table.d.ts +0 -3
- package/dist/modules/user/tokenService.d.ts +0 -29
- package/dist/modules/user/types.d.ts +0 -46
- package/dist/types/services.d.ts +0 -16
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
interface EnvRule {
|
|
2
|
-
required?: boolean;
|
|
3
|
-
integer?: boolean;
|
|
4
|
-
minimum?: number;
|
|
5
|
-
default?: string;
|
|
6
|
-
pattern?: RegExp;
|
|
7
|
-
}
|
|
8
|
-
type EnvSchema = Record<string, EnvRule>;
|
|
9
|
-
declare function defineEnvSchema(schema: EnvSchema): EnvSchema;
|
|
10
|
-
declare function validateEnv(schema: EnvSchema, env?: Record<string, string | undefined>): Record<string, string>;
|
|
11
|
-
export type { EnvRule, EnvSchema };
|
|
12
|
-
export { defineEnvSchema, validateEnv };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
type ServiceFactory<T> = (container: ServiceContainer) => T;
|
|
2
|
-
interface ServiceContainerLike {
|
|
3
|
-
has(key: string): boolean;
|
|
4
|
-
resolve<T>(key: string): T;
|
|
5
|
-
}
|
|
6
|
-
declare class ServiceContainer implements ServiceContainerLike {
|
|
7
|
-
private readonly services;
|
|
8
|
-
private readonly singletonFactories;
|
|
9
|
-
private readonly bindings;
|
|
10
|
-
set<T>(key: string, value: T): T;
|
|
11
|
-
singleton<T>(key: string, factory: ServiceFactory<T>): void;
|
|
12
|
-
bind<T>(key: string, factory: ServiceFactory<T>): void;
|
|
13
|
-
get<T>(key: string): T;
|
|
14
|
-
resolve<T>(key: string): T;
|
|
15
|
-
has(key: string): boolean;
|
|
16
|
-
}
|
|
17
|
-
interface ConfigStoreLike {
|
|
18
|
-
get<T>(key: string): T | undefined;
|
|
19
|
-
require<T>(key: string): T;
|
|
20
|
-
has(key: string): boolean;
|
|
21
|
-
}
|
|
22
|
-
declare class ConfigStore implements ConfigStoreLike {
|
|
23
|
-
private readonly values;
|
|
24
|
-
set<T>(key: string, value: T): T;
|
|
25
|
-
get<T>(key: string): T | undefined;
|
|
26
|
-
require<T>(key: string): T;
|
|
27
|
-
has(key: string): boolean;
|
|
28
|
-
}
|
|
29
|
-
export type { ConfigStoreLike, ServiceContainerLike, ServiceFactory };
|
|
30
|
-
export { ConfigStore, ServiceContainer };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { CacheLike } from "../../types/services";
|
|
2
|
-
import type { StorageManager } from "../storage/storage";
|
|
3
|
-
import type { ConfigStore, ConfigStoreLike, ServiceContainer, ServiceFactory } from "./container";
|
|
4
|
-
type AppRouteMap = Record<string, any>;
|
|
5
|
-
type CachedJson = <T>(cacheKey: string, loader: () => Promise<T>, tags?: string[], request?: Request) => Promise<Response>;
|
|
6
|
-
interface AppDependencies {
|
|
7
|
-
container: ServiceContainer;
|
|
8
|
-
cache: CacheLike;
|
|
9
|
-
storage: StorageManager;
|
|
10
|
-
}
|
|
11
|
-
type MutableAppDependencies = Partial<Omit<AppDependencies, "container">> & Pick<AppDependencies, "container">;
|
|
12
|
-
interface ProviderContext {
|
|
13
|
-
container: ServiceContainer;
|
|
14
|
-
config: ConfigStore;
|
|
15
|
-
dependencies: MutableAppDependencies;
|
|
16
|
-
}
|
|
17
|
-
interface ServiceProvider {
|
|
18
|
-
name: string;
|
|
19
|
-
register?(context: ProviderContext): void;
|
|
20
|
-
boot?(context: ProviderContext): void;
|
|
21
|
-
}
|
|
22
|
-
interface AppContext {
|
|
23
|
-
container: ServiceContainer;
|
|
24
|
-
config: ConfigStoreLike;
|
|
25
|
-
dependencies: AppDependencies;
|
|
26
|
-
}
|
|
27
|
-
declare function getRequiredDependency<K extends keyof AppDependencies>(dependencies: Partial<AppDependencies>, key: K): AppDependencies[K];
|
|
28
|
-
declare function assertAppDependenciesComplete(dependencies: MutableAppDependencies): asserts dependencies is AppDependencies;
|
|
29
|
-
declare function resolveService<T>(dependencies: AppDependencies, token: string): T;
|
|
30
|
-
export type { AppContext, AppDependencies, AppRouteMap, CachedJson, MutableAppDependencies, ProviderContext, ServiceFactory, ServiceProvider, };
|
|
31
|
-
export { assertAppDependenciesComplete, getRequiredDependency, resolveService };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type { ServiceContainerLike } from "./container.ts";
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
declare const CORE_CONFIG_TOKEN = "core.config";
|
|
2
|
-
declare const CORE_CACHE_TOKEN = "core.cache";
|
|
3
|
-
declare const CORE_QUEUE_TOKEN = "core.queue";
|
|
4
|
-
declare const CORE_EVENT_BUS_TOKEN = "core.eventBus";
|
|
5
|
-
declare const CORE_POLICY_GATE_TOKEN = "core.policyGate";
|
|
6
|
-
declare const CORE_AUTH_TOKEN = "core.auth";
|
|
7
|
-
declare const CORE_TOKEN_SERVICE_TOKEN = "core.tokenService";
|
|
8
|
-
export { CORE_AUTH_TOKEN, CORE_CACHE_TOKEN, CORE_CONFIG_TOKEN, CORE_EVENT_BUS_TOKEN, CORE_POLICY_GATE_TOKEN, CORE_QUEUE_TOKEN, CORE_TOKEN_SERVICE_TOKEN, };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
declare function resolveEncryptionKey(): Buffer | null;
|
|
2
|
-
declare function isFieldEncryptionEnabled(): boolean;
|
|
3
|
-
declare function encryptField(plaintext: string, key: Buffer): string;
|
|
4
|
-
declare function decryptField(value: string, key: Buffer): string;
|
|
5
|
-
declare function hashLookupValue(normalizedValue: string, key: Buffer): string;
|
|
6
|
-
declare function normalizeEmail(email: string): string;
|
|
7
|
-
declare function protectEmail(email: string): {
|
|
8
|
-
storedEmail: string;
|
|
9
|
-
emailLookup: string;
|
|
10
|
-
};
|
|
11
|
-
declare function revealEmail(storedEmail: string): string;
|
|
12
|
-
declare function emailLookupForQuery(email: string): string;
|
|
13
|
-
export { decryptField, emailLookupForQuery, encryptField, hashLookupValue, isFieldEncryptionEnabled, normalizeEmail, protectEmail, resolveEncryptionKey, revealEmail, };
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { type CursorPaginatedResult, type PaginatedResult } from "../pagination/index.ts";
|
|
2
|
-
import { type BelongsToRelation, type HasManyRelation, type MorphManyRelation, type MorphOneRelation, type MorphToRelation } from "./relationships.ts";
|
|
3
|
-
import { RepositoryQuery } from "./repositoryQuery.ts";
|
|
4
|
-
import type { TableDefinition } from "./table.ts";
|
|
5
|
-
import type { MutationValues, QueryOptions, QueryWhere, UpdateValues } from "./types.ts";
|
|
6
|
-
import type { WhereNode } from "./whereBuilder.ts";
|
|
7
|
-
type ExtendedQueryOptions<TEntity extends object> = QueryOptions<TEntity> & {
|
|
8
|
-
whereNodes?: WhereNode<TEntity>[];
|
|
9
|
-
};
|
|
10
|
-
interface DatabaseConnection {
|
|
11
|
-
unsafe<T>(query: string, params?: readonly unknown[]): Promise<T[]>;
|
|
12
|
-
begin?<T>(callback: (transaction: DatabaseConnection) => Promise<T>): Promise<T>;
|
|
13
|
-
close?(): Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
interface SqlDatabaseConnection extends DatabaseConnection {
|
|
16
|
-
(strings: TemplateStringsArray, ...values: unknown[]): Promise<unknown[]>;
|
|
17
|
-
}
|
|
18
|
-
type ErrorFactory<TValue> = (value: TValue) => Error;
|
|
19
|
-
declare class BaseRepository<TEntity extends object, PrimaryKey extends keyof TEntity & string> {
|
|
20
|
-
protected readonly table: TableDefinition<TEntity, PrimaryKey>;
|
|
21
|
-
protected readonly connection: DatabaseConnection;
|
|
22
|
-
constructor(table: TableDefinition<TEntity, PrimaryKey>, connection?: DatabaseConnection);
|
|
23
|
-
findAll(options?: ExtendedQueryOptions<TEntity>): Promise<TEntity[]>;
|
|
24
|
-
paginate(options: {
|
|
25
|
-
page: number;
|
|
26
|
-
perPage: number;
|
|
27
|
-
} & Omit<ExtendedQueryOptions<TEntity>, "limit" | "offset">): Promise<PaginatedResult<TEntity>>;
|
|
28
|
-
chunk(count: number, callback: (rows: TEntity[]) => Promise<boolean | void>, options?: Omit<ExtendedQueryOptions<TEntity>, "limit" | "offset">): Promise<void>;
|
|
29
|
-
cursorPaginate(options: {
|
|
30
|
-
perPage: number;
|
|
31
|
-
cursor?: TEntity[PrimaryKey];
|
|
32
|
-
cursorColumn?: PrimaryKey;
|
|
33
|
-
direction?: "asc" | "desc";
|
|
34
|
-
} & Omit<ExtendedQueryOptions<TEntity>, "limit" | "offset">): Promise<CursorPaginatedResult<TEntity, TEntity[PrimaryKey]>>;
|
|
35
|
-
findById(id: TEntity[PrimaryKey]): Promise<TEntity | null>;
|
|
36
|
-
findByIdOrThrow(id: TEntity[PrimaryKey], errorFactory?: ErrorFactory<TEntity[PrimaryKey]>): Promise<TEntity>;
|
|
37
|
-
findByIds(ids: readonly TEntity[PrimaryKey][]): Promise<TEntity[]>;
|
|
38
|
-
firstOrNull(where: QueryWhere<TEntity>, options?: Omit<QueryOptions<TEntity>, "where" | "limit">): Promise<TEntity | null>;
|
|
39
|
-
create(values: MutationValues<TEntity>): Promise<TEntity>;
|
|
40
|
-
updateById(id: TEntity[PrimaryKey], changes: UpdateValues<TEntity, PrimaryKey>): Promise<TEntity | null>;
|
|
41
|
-
updateByIdOrThrow(id: TEntity[PrimaryKey], changes: UpdateValues<TEntity, PrimaryKey>, errorFactory?: ErrorFactory<TEntity[PrimaryKey]>): Promise<TEntity>;
|
|
42
|
-
deleteById(id: TEntity[PrimaryKey]): Promise<boolean>;
|
|
43
|
-
softDeleteById(id: TEntity[PrimaryKey]): Promise<boolean>;
|
|
44
|
-
forceDeleteById(id: TEntity[PrimaryKey]): Promise<boolean>;
|
|
45
|
-
restoreById(id: TEntity[PrimaryKey]): Promise<TEntity | null>;
|
|
46
|
-
withConnection(connection: DatabaseConnection): this;
|
|
47
|
-
getConnection(): DatabaseConnection;
|
|
48
|
-
getTable(): TableDefinition<TEntity, PrimaryKey>;
|
|
49
|
-
query(where?: QueryWhere<TEntity>): RepositoryQuery<TEntity, PrimaryKey>;
|
|
50
|
-
protected findWhere(where: QueryWhere<TEntity>, options?: Omit<QueryOptions<TEntity>, "where">): Promise<TEntity[]>;
|
|
51
|
-
protected countWhere(where?: QueryWhere<TEntity>, options?: Pick<QueryOptions<TEntity>, "withTrashed" | "onlyTrashed" | "joins" | "groupBy">, whereNodes?: readonly WhereNode<TEntity>[]): Promise<number>;
|
|
52
|
-
protected averageColumn(column: keyof TEntity & string, where?: QueryWhere<TEntity>): Promise<number>;
|
|
53
|
-
protected averageExpression(expression: string, alias: string, where?: QueryWhere<TEntity>): Promise<number>;
|
|
54
|
-
protected pluckNumberValues(expression: string, alias: string, options?: QueryOptions<TEntity>): Promise<number[]>;
|
|
55
|
-
protected countGroupedBy<K extends keyof TEntity & string>(column: K, where?: QueryWhere<TEntity>): Promise<Array<{
|
|
56
|
-
value: TEntity[K] | null;
|
|
57
|
-
count: number;
|
|
58
|
-
}>>;
|
|
59
|
-
findByHasManyRelation<TParent extends object, LocalKey extends keyof TParent & string, ForeignKey extends keyof TEntity & string>(relation: HasManyRelation<TParent, TEntity, LocalKey, ForeignKey>, parentId: TParent[LocalKey], options?: Omit<QueryOptions<TEntity>, "where">): Promise<TEntity[]>;
|
|
60
|
-
loadHasManyForParents<TParent extends object, LocalKey extends keyof TParent & string, ForeignKey extends keyof TEntity & string>(parents: readonly TParent[], relation: HasManyRelation<TParent, TEntity, LocalKey, ForeignKey>, options?: Omit<QueryOptions<TEntity>, "where">): Promise<Map<TParent[LocalKey], TEntity[]>>;
|
|
61
|
-
loadBelongsToForParents<TChild extends object, TParent extends object, ForeignKey extends keyof TChild & string, OwnerKey extends keyof TParent & string>(children: readonly TChild[], relation: BelongsToRelation<TChild, TParent, ForeignKey, OwnerKey>, parentRepository: BaseRepository<TParent, OwnerKey>, options?: Omit<QueryOptions<TParent>, "where">): Promise<Map<TChild[ForeignKey], TParent>>;
|
|
62
|
-
loadMorphManyForParents<TParent extends object, LocalKey extends keyof TParent & string, MorphTypeKey extends keyof TEntity & string, MorphIdKey extends keyof TEntity & string>(parents: readonly TParent[], relation: MorphManyRelation<TParent, TEntity, LocalKey, MorphTypeKey, MorphIdKey>, options?: Omit<QueryOptions<TEntity>, "where">): Promise<Map<TParent[LocalKey], TEntity[]>>;
|
|
63
|
-
loadMorphOneForParents<TParent extends object, LocalKey extends keyof TParent & string, MorphTypeKey extends keyof TEntity & string, MorphIdKey extends keyof TEntity & string>(parents: readonly TParent[], relation: MorphOneRelation<TParent, TEntity, LocalKey, MorphTypeKey, MorphIdKey>, options?: Omit<QueryOptions<TEntity>, "where">): Promise<Map<TParent[LocalKey], TEntity | undefined>>;
|
|
64
|
-
loadMorphToForChildren<TChild extends object, TParent extends object, MorphTypeKey extends keyof TChild & string, MorphIdKey extends keyof TChild & string, OwnerKey extends keyof TParent & string>(children: readonly TChild[], relation: MorphToRelation<TChild, MorphTypeKey, MorphIdKey>, repositoriesByType: ReadonlyMap<string, BaseRepository<TParent, OwnerKey>>, options?: Omit<QueryOptions<TParent>, "where">): Promise<Map<TChild[MorphIdKey], TParent>>;
|
|
65
|
-
}
|
|
66
|
-
export default BaseRepository;
|
|
67
|
-
export type { DatabaseConnection, SqlDatabaseConnection };
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { DatabaseConnection } from "./baseRepository";
|
|
2
|
-
declare function bindDatabaseConnection(connection: DatabaseConnection): void;
|
|
3
|
-
declare function getBoundDatabaseConnection(): DatabaseConnection | null;
|
|
4
|
-
declare function resetBoundDatabaseConnection(): void;
|
|
5
|
-
export { bindDatabaseConnection, getBoundDatabaseConnection, resetBoundDatabaseConnection };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { DatabaseConnection } from "./baseRepository.ts";
|
|
2
|
-
type UnsafeQueryable = {
|
|
3
|
-
unsafe<T>(query: string, params?: readonly unknown[]): Promise<T[]>;
|
|
4
|
-
};
|
|
5
|
-
declare function createDatabaseConnection(source: UnsafeQueryable): DatabaseConnection;
|
|
6
|
-
export type { UnsafeQueryable };
|
|
7
|
-
export { createDatabaseConnection };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
type ActiveDatabaseHandle = {
|
|
2
|
-
unsafe<T>(query: string, params?: readonly unknown[]): Promise<T[]>;
|
|
3
|
-
};
|
|
4
|
-
declare function runWithDatabaseConnection<T>(connection: ActiveDatabaseHandle, callback: () => T | Promise<T>): T | Promise<T>;
|
|
5
|
-
declare function getActiveDatabaseConnection<T extends ActiveDatabaseHandle>(fallback: T): T;
|
|
6
|
-
declare function hasActiveDatabaseConnection(): boolean;
|
|
7
|
-
export type { ActiveDatabaseHandle };
|
|
8
|
-
export { getActiveDatabaseConnection, hasActiveDatabaseConnection, runWithDatabaseConnection };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { SqlDatabaseConnection } from "./baseRepository";
|
|
2
|
-
declare function registerDefaultDatabasePool(connection: SqlDatabaseConnection): void;
|
|
3
|
-
declare function getDefaultDatabasePool(): SqlDatabaseConnection;
|
|
4
|
-
declare function getDefaultDatabaseQuery(): SqlDatabaseConnection;
|
|
5
|
-
declare function resetDefaultDatabasePoolForTests(): void;
|
|
6
|
-
export { getDefaultDatabasePool, getDefaultDatabaseQuery, registerDefaultDatabasePool, resetDefaultDatabasePoolForTests, };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { HttpError } from "../errors/http";
|
|
2
|
-
interface PostgresErrorLike {
|
|
3
|
-
code?: string;
|
|
4
|
-
errno?: string | number;
|
|
5
|
-
constraint?: string;
|
|
6
|
-
detail?: string;
|
|
7
|
-
message?: string;
|
|
8
|
-
}
|
|
9
|
-
declare function isPostgresError(error: unknown): error is PostgresErrorLike;
|
|
10
|
-
declare function mapDatabaseError(error: unknown): HttpError;
|
|
11
|
-
declare function withDatabaseErrorHandling<TValue>(operation: () => Promise<TValue>): Promise<TValue>;
|
|
12
|
-
export { isPostgresError, mapDatabaseError, withDatabaseErrorHandling };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export type { DatabaseConnection } from "./baseRepository.ts";
|
|
2
|
-
export { default as BaseRepository } from "./baseRepository.ts";
|
|
3
|
-
export { createDatabaseConnection } from "./connection.ts";
|
|
4
|
-
export { mapDatabaseError, withDatabaseErrorHandling } from "./errors.ts";
|
|
5
|
-
export type { CastType, GlobalScopeFn, ModelConstructor } from "./model.ts";
|
|
6
|
-
export { applyCasts, dehydrateValue, filterMassAssignable, hydrateValue, Model, registerModelRepository, } from "./model.ts";
|
|
7
|
-
export { buildAdvancedWhereClause, buildCountQuery, buildDeleteByIdQuery, buildGroupedCountQuery, buildInsertQuery, buildJoinClause, buildOrderByClause, buildProjectionQuery, buildQueryWhereClause, buildRestoreByIdQuery, buildSelectQuery, buildSoftDeleteByIdQuery, buildUpdateQuery, buildWhereClause, parseQualifiedColumn, qualifyColumn, quoteIdentifier, resolveQualifiedColumn, resolveSoftDeleteColumn, } from "./query.ts";
|
|
8
|
-
export type { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasOneRelation, MorphManyRelation, MorphOneRelation, MorphToRelation, } from "./relationships.ts";
|
|
9
|
-
export { belongsTo, belongsToMany, hasMany, hasOne, indexBelongsToManyRelation, indexBelongsToRelation, indexHasManyRelation, indexHasOneRelation, indexMorphManyRelation, indexMorphOneRelation, indexMorphToRelation, morphMany, morphOne, morphTo, } from "./relationships.ts";
|
|
10
|
-
export { RepositoryQuery } from "./repositoryQuery.ts";
|
|
11
|
-
export type { BlueprintAction, BlueprintCallback, ColumnKind, DatabaseDriver, ForeignKeyOptions, Grammar, IndexDefinition, IndexKind, ResolveDatabaseDriverOptions, SchemaBuilder, } from "./schema/index.ts";
|
|
12
|
-
export { Blueprint, ColumnDefinition, compileBlueprint, createSchemaBuilder, ForeignIdColumnDefinition, grammarForDriver, inferReferencedTable, MySqlGrammar, PostgresGrammar, resolveDatabaseDriver, Schema, SqliteGrammar, UnsupportedSchemaFeatureError, } from "./schema/index.ts";
|
|
13
|
-
export type { TableDefinition } from "./table.ts";
|
|
14
|
-
export { defineTable } from "./table.ts";
|
|
15
|
-
export { runInTransaction } from "./transaction.ts";
|
|
16
|
-
export type { DatabaseComparable, DatabaseScalar, MutationValues, QueryFilterValue, QueryJoin, QueryJoinOn, QueryOperator, QueryOptions, QueryOrder, QuerySelectItem, QueryWhere, UpdateValues, } from "./types.ts";
|
|
17
|
-
export type { WhereNode } from "./whereBuilder.ts";
|
|
18
|
-
export { WhereBuilder } from "./whereBuilder.ts";
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
declare const MIGRATION_LOCK_KEY = 42424242;
|
|
2
|
-
type LockableDatabase = {
|
|
3
|
-
unsafe<T>(query: string, params?: readonly unknown[]): Promise<T[]>;
|
|
4
|
-
};
|
|
5
|
-
declare function withMigrationLock<T>(db: LockableDatabase, callback: () => Promise<T>, lockKey?: number): Promise<T>;
|
|
6
|
-
export { MIGRATION_LOCK_KEY, withMigrationLock };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { Migration, MigrationDatabase, MigrationStatus } from "./types.ts";
|
|
2
|
-
type AppliedMigrationRow = {
|
|
3
|
-
name: string;
|
|
4
|
-
batch: number | string;
|
|
5
|
-
};
|
|
6
|
-
declare function ensureMigrationsTable(db: MigrationDatabase): Promise<void>;
|
|
7
|
-
declare function getAppliedMigrations(db: MigrationDatabase): Promise<AppliedMigrationRow[]>;
|
|
8
|
-
declare function loadMigrationsFromDirectory(directory: string): Promise<Migration[]>;
|
|
9
|
-
declare function getMigrationStatus(db: MigrationDatabase, migrations: Migration[]): Promise<MigrationStatus[]>;
|
|
10
|
-
declare function runPendingMigrations(db: MigrationDatabase, migrations: Migration[], options?: {
|
|
11
|
-
onMigration?: (name: string) => void;
|
|
12
|
-
}): Promise<number>;
|
|
13
|
-
declare function migrateDatabase(db: MigrationDatabase, migrations: Migration[], options?: {
|
|
14
|
-
advisoryLock?: boolean;
|
|
15
|
-
onMigration?: (name: string) => void;
|
|
16
|
-
}): Promise<number>;
|
|
17
|
-
declare function rollbackDatabase(db: MigrationDatabase, migrations: Migration[], options?: {
|
|
18
|
-
onMigration?: (name: string) => void;
|
|
19
|
-
}): Promise<number>;
|
|
20
|
-
declare function freshDatabase(db: MigrationDatabase, migrations: Migration[], options?: {
|
|
21
|
-
advisoryLock?: boolean;
|
|
22
|
-
onMigration?: (name: string) => void;
|
|
23
|
-
}): Promise<void>;
|
|
24
|
-
export { withMigrationLock } from "./advisoryLock.ts";
|
|
25
|
-
export { ensureMigrationsTable, freshDatabase, getAppliedMigrations, getMigrationStatus, loadMigrationsFromDirectory, migrateDatabase, rollbackDatabase, runPendingMigrations, };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
interface MigrationDatabase {
|
|
2
|
-
unsafe<T = unknown>(query: string, params?: readonly unknown[]): Promise<T[]>;
|
|
3
|
-
schema?: import("../schema/schema.ts").SchemaBuilder;
|
|
4
|
-
}
|
|
5
|
-
interface Migration {
|
|
6
|
-
name: string;
|
|
7
|
-
up(db: MigrationDatabase): Promise<void>;
|
|
8
|
-
down(db: MigrationDatabase): Promise<void>;
|
|
9
|
-
}
|
|
10
|
-
type MigrationStatus = {
|
|
11
|
-
name: string;
|
|
12
|
-
status: "up" | "pending";
|
|
13
|
-
batch: number | null;
|
|
14
|
-
};
|
|
15
|
-
export type { Migration, MigrationDatabase, MigrationStatus };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type BaseRepository from "./baseRepository.ts";
|
|
2
|
-
import type { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasOneRelation } from "./relationships.ts";
|
|
3
|
-
import type { RepositoryQuery } from "./repositoryQuery.ts";
|
|
4
|
-
import type { QueryOptions, QueryWhere } from "./types.ts";
|
|
5
|
-
type CastType = "date" | "datetime" | "json" | "bool" | "boolean";
|
|
6
|
-
type LoadedAttributes = Record<string, unknown>;
|
|
7
|
-
type ModelCasts = Partial<Record<string, CastType>>;
|
|
8
|
-
type GlobalScopeFn<TEntity extends object, PrimaryKey extends keyof TEntity & string> = (query: RepositoryQuery<TEntity, PrimaryKey>) => RepositoryQuery<TEntity, PrimaryKey>;
|
|
9
|
-
type ModelClassType<TEntity extends object, PrimaryKey extends keyof TEntity & string> = typeof Model & (new (attributes: TEntity, repository: BaseRepository<TEntity, PrimaryKey>, exists?: boolean) => Model<TEntity, PrimaryKey>);
|
|
10
|
-
interface ModelConstructor<TEntity extends object, PrimaryKey extends keyof TEntity & string, TModel extends Model<TEntity, PrimaryKey>> extends ModelClassType<TEntity, PrimaryKey> {
|
|
11
|
-
new (attributes: TEntity, repository: BaseRepository<TEntity, PrimaryKey>, exists?: boolean): TModel;
|
|
12
|
-
}
|
|
13
|
-
declare function hydrateValue(value: unknown, cast: CastType): unknown;
|
|
14
|
-
declare function dehydrateValue(value: unknown, cast: CastType): unknown;
|
|
15
|
-
declare function filterMassAssignable(fillable: readonly string[] | undefined, guarded: readonly string[] | true | undefined, input: LoadedAttributes): LoadedAttributes;
|
|
16
|
-
declare function applyCasts(values: LoadedAttributes, casts: ModelCasts, direction: "hydrate" | "dehydrate"): LoadedAttributes;
|
|
17
|
-
declare class Model<TEntity extends object, PrimaryKey extends keyof TEntity & string> {
|
|
18
|
-
protected attributes: TEntity;
|
|
19
|
-
protected readonly repository: BaseRepository<TEntity, PrimaryKey>;
|
|
20
|
-
static $fillable?: readonly string[];
|
|
21
|
-
static $guarded?: readonly string[] | true;
|
|
22
|
-
static $casts: ModelCasts;
|
|
23
|
-
static $timestamps: boolean;
|
|
24
|
-
private _exists;
|
|
25
|
-
constructor(attributes: TEntity, repository: BaseRepository<TEntity, PrimaryKey>, exists?: boolean);
|
|
26
|
-
get $exists(): boolean;
|
|
27
|
-
get<K extends keyof TEntity>(key: K): TEntity[K];
|
|
28
|
-
get id(): TEntity[PrimaryKey];
|
|
29
|
-
toObject(): TEntity;
|
|
30
|
-
protected primaryKey(): PrimaryKey;
|
|
31
|
-
protected static primaryKeyField(this: object): string;
|
|
32
|
-
protected static hydrateAttributes<TEntity extends object>(this: object, attributes: TEntity): TEntity;
|
|
33
|
-
protected static dehydrateAttributes(this: object, attributes: LoadedAttributes): LoadedAttributes;
|
|
34
|
-
protected static fromRecord<TEntity extends object, PrimaryKey extends keyof TEntity & string>(this: object, record: TEntity, repository: BaseRepository<TEntity, PrimaryKey>, exists?: boolean): Model<TEntity, PrimaryKey>;
|
|
35
|
-
static boot(): void;
|
|
36
|
-
static addGlobalScope<TEntity extends object, PrimaryKey extends keyof TEntity & string>(this: object, _name: string, scope: GlobalScopeFn<TEntity, PrimaryKey>): void;
|
|
37
|
-
static repository<TEntity extends object, PrimaryKey extends keyof TEntity & string>(this: object): BaseRepository<TEntity, PrimaryKey>;
|
|
38
|
-
static query<TEntity extends object, PrimaryKey extends keyof TEntity & string>(this: object): RepositoryQuery<TEntity, PrimaryKey>;
|
|
39
|
-
static create(this: object, attributes: Record<string, unknown>): Promise<Model<Record<string, unknown>, "id">>;
|
|
40
|
-
static find(this: object, id: unknown): Promise<Model<Record<string, unknown>, "id"> | null>;
|
|
41
|
-
static findOrFail(this: object, id: unknown, errorFactory?: (id: unknown) => Error): Promise<Model<Record<string, unknown>, "id">>;
|
|
42
|
-
static all(this: object, options?: Omit<QueryOptions<object>, "where">): Promise<Array<Model<Record<string, unknown>, "id">>>;
|
|
43
|
-
static firstWhere(this: object, where: QueryWhere<object>, options?: Omit<QueryOptions<object>, "where">): Promise<Model<Record<string, unknown>, "id"> | null>;
|
|
44
|
-
save(): Promise<this>;
|
|
45
|
-
update(changes: Partial<TEntity>): Promise<this>;
|
|
46
|
-
delete(): Promise<boolean>;
|
|
47
|
-
forceDelete(): Promise<boolean>;
|
|
48
|
-
restore(): Promise<this | null>;
|
|
49
|
-
loadHasMany<TChild extends object, LocalKey extends keyof TEntity & string, ForeignKey extends keyof TChild & string, Alias extends string>(as: Alias, relation: HasManyRelation<TEntity, TChild, LocalKey, ForeignKey>, childRepository: BaseRepository<TChild, keyof TChild & string>, options?: Omit<QueryOptions<TChild>, "where">): Promise<this & Record<Alias, TChild[]>>;
|
|
50
|
-
loadHasOne<TChild extends object, LocalKey extends keyof TEntity & string, ForeignKey extends keyof TChild & string, Alias extends string>(as: Alias, relation: HasOneRelation<TEntity, TChild, LocalKey, ForeignKey>, childRepository: BaseRepository<TChild, keyof TChild & string>, options?: Omit<QueryOptions<TChild>, "where">): Promise<this & Record<Alias, TChild | undefined>>;
|
|
51
|
-
loadBelongsTo<TParent extends object, ForeignKey extends keyof TEntity & string, OwnerKey extends keyof TParent & string, Alias extends string>(as: Alias, relation: BelongsToRelation<TEntity, TParent, ForeignKey, OwnerKey>, parentRepository: BaseRepository<TParent, OwnerKey>, options?: Omit<QueryOptions<TParent>, "where">): Promise<this & Record<Alias, TParent | undefined>>;
|
|
52
|
-
loadBelongsToMany<TRelated extends object, Pivot extends object, ParentKey extends keyof TEntity & string, RelatedKey extends keyof TRelated & string, ForeignPivotKey extends keyof Pivot & string, RelatedPivotKey extends keyof Pivot & string, Alias extends string>(as: Alias, relation: BelongsToManyRelation<TEntity, TRelated, Pivot, ParentKey, RelatedKey, ForeignPivotKey, RelatedPivotKey>, relatedRepository: BaseRepository<TRelated, RelatedKey>, options?: Omit<QueryOptions<TRelated>, "where">): Promise<this & Record<Alias, TRelated[]>>;
|
|
53
|
-
mergeAttributes(patch: Partial<TEntity>): this;
|
|
54
|
-
}
|
|
55
|
-
declare function registerModelRepository<TModelClass>(model: TModelClass, repository: object): TModelClass;
|
|
56
|
-
export type { CastType, GlobalScopeFn, ModelClassType, ModelConstructor };
|
|
57
|
-
export { applyCasts, dehydrateValue, filterMassAssignable, hydrateValue, Model, registerModelRepository, };
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { TableDefinition } from "./table.ts";
|
|
2
|
-
import type { MutationValues, QueryJoin, QueryOptions, QueryWhere, UpdateValues } from "./types.ts";
|
|
3
|
-
import type { WhereNode } from "./whereBuilder.ts";
|
|
4
|
-
declare function quoteIdentifier(identifier: string): string;
|
|
5
|
-
declare function qualifyColumn(tableName: string, column: string): string;
|
|
6
|
-
declare function resolveQualifiedColumn(defaultTable: string, columnName: string): string;
|
|
7
|
-
declare function parseQualifiedColumn(reference: string): {
|
|
8
|
-
table: string;
|
|
9
|
-
column: string;
|
|
10
|
-
};
|
|
11
|
-
declare function buildWhereClause<TEntity extends object>(tableName: string, where?: QueryWhere<TEntity>): {
|
|
12
|
-
clause: string;
|
|
13
|
-
params: unknown[];
|
|
14
|
-
};
|
|
15
|
-
declare function buildAdvancedWhereClause<TEntity extends object>(tableName: string, where?: QueryWhere<TEntity>, whereNodes?: readonly WhereNode<TEntity>[], params?: unknown[]): {
|
|
16
|
-
clause: string;
|
|
17
|
-
params: unknown[];
|
|
18
|
-
};
|
|
19
|
-
declare function resolveSoftDeleteColumn<TEntity>(table: TableDefinition<TEntity>): string | null;
|
|
20
|
-
declare function buildQueryWhereClause<TEntity extends object>(table: TableDefinition<TEntity>, options?: Pick<QueryOptions<TEntity>, "where" | "withTrashed" | "onlyTrashed">, whereNodes?: readonly WhereNode<TEntity>[], params?: unknown[]): {
|
|
21
|
-
clause: string;
|
|
22
|
-
params: unknown[];
|
|
23
|
-
};
|
|
24
|
-
declare function buildOrderByClause<TEntity extends object>(tableName: string, orderBy?: QueryOptions<TEntity>["orderBy"]): string;
|
|
25
|
-
declare function buildJoinClause(joins?: readonly QueryJoin[]): string;
|
|
26
|
-
declare function buildSelectQuery<TEntity extends object>(table: TableDefinition<TEntity>, options?: QueryOptions<TEntity>, whereNodes?: readonly WhereNode<TEntity>[]): {
|
|
27
|
-
text: string;
|
|
28
|
-
params: unknown[];
|
|
29
|
-
};
|
|
30
|
-
declare function buildCountQuery<TEntity extends object>(table: TableDefinition<TEntity>, where?: QueryWhere<TEntity>, options?: Pick<QueryOptions<TEntity>, "withTrashed" | "onlyTrashed" | "joins" | "groupBy">, whereNodes?: readonly WhereNode<TEntity>[]): {
|
|
31
|
-
text: string;
|
|
32
|
-
params: unknown[];
|
|
33
|
-
};
|
|
34
|
-
declare function buildProjectionQuery<TEntity extends object>(table: TableDefinition<TEntity>, expression: string, alias: string, options?: QueryOptions<TEntity>, whereNodes?: readonly WhereNode<TEntity>[]): {
|
|
35
|
-
text: string;
|
|
36
|
-
params: unknown[];
|
|
37
|
-
};
|
|
38
|
-
declare function assertSafeProjectionExpression(expression: string): void;
|
|
39
|
-
declare function buildGroupedCountQuery<TEntity extends object, K extends keyof TEntity & string>(table: TableDefinition<TEntity>, column: K, where?: QueryWhere<TEntity>, options?: Pick<QueryOptions<TEntity>, "withTrashed" | "onlyTrashed">): {
|
|
40
|
-
text: string;
|
|
41
|
-
params: unknown[];
|
|
42
|
-
};
|
|
43
|
-
declare function buildInsertQuery<TEntity extends object, PrimaryKey extends keyof TEntity & string>(table: TableDefinition<TEntity, PrimaryKey>, values: MutationValues<TEntity>): {
|
|
44
|
-
text: string;
|
|
45
|
-
params: unknown[];
|
|
46
|
-
};
|
|
47
|
-
declare function buildUpdateQuery<TEntity extends object, PrimaryKey extends keyof TEntity & string>(table: TableDefinition<TEntity, PrimaryKey>, id: TEntity[PrimaryKey], changes: UpdateValues<TEntity, PrimaryKey>): {
|
|
48
|
-
text: string;
|
|
49
|
-
params: unknown[];
|
|
50
|
-
};
|
|
51
|
-
declare function buildSoftDeleteByIdQuery<TEntity extends object, PrimaryKey extends keyof TEntity & string>(table: TableDefinition<TEntity, PrimaryKey>, id: TEntity[PrimaryKey], deletedAt: Date): {
|
|
52
|
-
text: string;
|
|
53
|
-
params: unknown[];
|
|
54
|
-
};
|
|
55
|
-
declare function buildRestoreByIdQuery<TEntity extends object, PrimaryKey extends keyof TEntity & string>(table: TableDefinition<TEntity, PrimaryKey>, id: TEntity[PrimaryKey]): {
|
|
56
|
-
text: string;
|
|
57
|
-
params: unknown[];
|
|
58
|
-
};
|
|
59
|
-
declare function buildDeleteByIdQuery<TEntity extends object, PrimaryKey extends keyof TEntity & string>(table: TableDefinition<TEntity, PrimaryKey>, id: TEntity[PrimaryKey]): {
|
|
60
|
-
text: string;
|
|
61
|
-
params: unknown[];
|
|
62
|
-
};
|
|
63
|
-
export { assertSafeProjectionExpression, buildAdvancedWhereClause, buildCountQuery, buildDeleteByIdQuery, buildGroupedCountQuery, buildInsertQuery, buildJoinClause, buildOrderByClause, buildProjectionQuery, buildQueryWhereClause, buildRestoreByIdQuery, buildSelectQuery, buildSoftDeleteByIdQuery, buildUpdateQuery, buildWhereClause, parseQualifiedColumn, qualifyColumn, quoteIdentifier, resolveQualifiedColumn, resolveSoftDeleteColumn, };
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
interface HasManyRelation<TParent, TChild, LocalKey extends keyof TParent & string = keyof TParent & string, ForeignKey extends keyof TChild & string = keyof TChild & string> {
|
|
2
|
-
type: "hasMany";
|
|
3
|
-
name: string;
|
|
4
|
-
localKey: LocalKey;
|
|
5
|
-
foreignKey: ForeignKey;
|
|
6
|
-
}
|
|
7
|
-
interface HasOneRelation<TParent, TChild, LocalKey extends keyof TParent & string = keyof TParent & string, ForeignKey extends keyof TChild & string = keyof TChild & string> {
|
|
8
|
-
type: "hasOne";
|
|
9
|
-
name: string;
|
|
10
|
-
localKey: LocalKey;
|
|
11
|
-
foreignKey: ForeignKey;
|
|
12
|
-
}
|
|
13
|
-
interface BelongsToRelation<TChild, TParent, ForeignKey extends keyof TChild & string = keyof TChild & string, OwnerKey extends keyof TParent & string = keyof TParent & string> {
|
|
14
|
-
type: "belongsTo";
|
|
15
|
-
name: string;
|
|
16
|
-
foreignKey: ForeignKey;
|
|
17
|
-
ownerKey: OwnerKey;
|
|
18
|
-
}
|
|
19
|
-
interface BelongsToManyRelation<TParent, TRelated, Pivot extends object, ParentKey extends keyof TParent & string = keyof TParent & string, RelatedKey extends keyof TRelated & string = keyof TRelated & string, ForeignPivotKey extends keyof Pivot & string = keyof Pivot & string, RelatedPivotKey extends keyof Pivot & string = keyof Pivot & string> {
|
|
20
|
-
type: "belongsToMany";
|
|
21
|
-
name: string;
|
|
22
|
-
pivotTable: string;
|
|
23
|
-
parentKey: ParentKey;
|
|
24
|
-
relatedKey: RelatedKey;
|
|
25
|
-
foreignPivotKey: ForeignPivotKey;
|
|
26
|
-
relatedPivotKey: RelatedPivotKey;
|
|
27
|
-
}
|
|
28
|
-
declare function hasMany<TParent, TChild, LocalKey extends keyof TParent & string = keyof TParent & string, ForeignKey extends keyof TChild & string = keyof TChild & string>(definition: {
|
|
29
|
-
name: string;
|
|
30
|
-
localKey: LocalKey;
|
|
31
|
-
foreignKey: ForeignKey;
|
|
32
|
-
}): HasManyRelation<TParent, TChild, LocalKey, ForeignKey>;
|
|
33
|
-
declare function hasOne<TParent, TChild, LocalKey extends keyof TParent & string = keyof TParent & string, ForeignKey extends keyof TChild & string = keyof TChild & string>(definition: {
|
|
34
|
-
name: string;
|
|
35
|
-
localKey: LocalKey;
|
|
36
|
-
foreignKey: ForeignKey;
|
|
37
|
-
}): HasOneRelation<TParent, TChild, LocalKey, ForeignKey>;
|
|
38
|
-
declare function belongsTo<TChild, TParent, ForeignKey extends keyof TChild & string = keyof TChild & string, OwnerKey extends keyof TParent & string = keyof TParent & string>(definition: {
|
|
39
|
-
name: string;
|
|
40
|
-
foreignKey: ForeignKey;
|
|
41
|
-
ownerKey: OwnerKey;
|
|
42
|
-
}): BelongsToRelation<TChild, TParent, ForeignKey, OwnerKey>;
|
|
43
|
-
declare function belongsToMany<TParent, TRelated, Pivot extends object, ParentKey extends keyof TParent & string = keyof TParent & string, RelatedKey extends keyof TRelated & string = keyof TRelated & string, ForeignPivotKey extends keyof Pivot & string = keyof Pivot & string, RelatedPivotKey extends keyof Pivot & string = keyof Pivot & string>(definition: {
|
|
44
|
-
name: string;
|
|
45
|
-
pivotTable: string;
|
|
46
|
-
parentKey: ParentKey;
|
|
47
|
-
relatedKey: RelatedKey;
|
|
48
|
-
foreignPivotKey: ForeignPivotKey;
|
|
49
|
-
relatedPivotKey: RelatedPivotKey;
|
|
50
|
-
}): BelongsToManyRelation<TParent, TRelated, Pivot, ParentKey, RelatedKey, ForeignPivotKey, RelatedPivotKey>;
|
|
51
|
-
declare function indexHasManyRelation<TParent, TChild, LocalKey extends keyof TParent & string, ForeignKey extends keyof TChild & string>(parents: readonly TParent[], children: readonly TChild[], relation: HasManyRelation<TParent, TChild, LocalKey, ForeignKey>): Map<TParent[LocalKey], TChild[]>;
|
|
52
|
-
declare function indexHasOneRelation<TParent, TChild, LocalKey extends keyof TParent & string, ForeignKey extends keyof TChild & string>(parents: readonly TParent[], children: readonly TChild[], relation: HasOneRelation<TParent, TChild, LocalKey, ForeignKey>): Map<TParent[LocalKey], TChild | undefined>;
|
|
53
|
-
declare function indexBelongsToRelation<TChild, TParent, ForeignKey extends keyof TChild & string, OwnerKey extends keyof TParent & string>(children: readonly TChild[], parents: readonly TParent[], relation: BelongsToRelation<TChild, TParent, ForeignKey, OwnerKey>): Map<TChild[ForeignKey], TParent>;
|
|
54
|
-
declare function indexBelongsToManyRelation<TParent, TRelated, Pivot extends object, ParentKey extends keyof TParent & string, RelatedKey extends keyof TRelated & string, ForeignPivotKey extends keyof Pivot & string, RelatedPivotKey extends keyof Pivot & string>(parents: readonly TParent[], pivotRows: readonly Pivot[], relatedRows: readonly TRelated[], relation: BelongsToManyRelation<TParent, TRelated, Pivot, ParentKey, RelatedKey, ForeignPivotKey, RelatedPivotKey>): Map<TParent[ParentKey], TRelated[]>;
|
|
55
|
-
interface MorphManyRelation<TParent, TChild, LocalKey extends keyof TParent & string = keyof TParent & string, MorphTypeKey extends keyof TChild & string = keyof TChild & string, MorphIdKey extends keyof TChild & string = keyof TChild & string> {
|
|
56
|
-
type: "morphMany";
|
|
57
|
-
name: string;
|
|
58
|
-
localKey: LocalKey;
|
|
59
|
-
morphTypeKey: MorphTypeKey;
|
|
60
|
-
morphIdKey: MorphIdKey;
|
|
61
|
-
morphType: string;
|
|
62
|
-
}
|
|
63
|
-
interface MorphOneRelation<TParent, TChild, LocalKey extends keyof TParent & string = keyof TParent & string, MorphTypeKey extends keyof TChild & string = keyof TChild & string, MorphIdKey extends keyof TChild & string = keyof TChild & string> {
|
|
64
|
-
type: "morphOne";
|
|
65
|
-
name: string;
|
|
66
|
-
localKey: LocalKey;
|
|
67
|
-
morphTypeKey: MorphTypeKey;
|
|
68
|
-
morphIdKey: MorphIdKey;
|
|
69
|
-
morphType: string;
|
|
70
|
-
}
|
|
71
|
-
interface MorphToRelation<TChild, MorphTypeKey extends keyof TChild & string = keyof TChild & string, MorphIdKey extends keyof TChild & string = keyof TChild & string> {
|
|
72
|
-
type: "morphTo";
|
|
73
|
-
name: string;
|
|
74
|
-
morphTypeKey: MorphTypeKey;
|
|
75
|
-
morphIdKey: MorphIdKey;
|
|
76
|
-
}
|
|
77
|
-
declare function morphMany<TParent, TChild, LocalKey extends keyof TParent & string = keyof TParent & string, MorphTypeKey extends keyof TChild & string = keyof TChild & string, MorphIdKey extends keyof TChild & string = keyof TChild & string>(definition: {
|
|
78
|
-
name: string;
|
|
79
|
-
localKey: LocalKey;
|
|
80
|
-
morphTypeKey: MorphTypeKey;
|
|
81
|
-
morphIdKey: MorphIdKey;
|
|
82
|
-
morphType: string;
|
|
83
|
-
}): MorphManyRelation<TParent, TChild, LocalKey, MorphTypeKey, MorphIdKey>;
|
|
84
|
-
declare function morphOne<TParent, TChild, LocalKey extends keyof TParent & string = keyof TParent & string, MorphTypeKey extends keyof TChild & string = keyof TChild & string, MorphIdKey extends keyof TChild & string = keyof TChild & string>(definition: {
|
|
85
|
-
name: string;
|
|
86
|
-
localKey: LocalKey;
|
|
87
|
-
morphTypeKey: MorphTypeKey;
|
|
88
|
-
morphIdKey: MorphIdKey;
|
|
89
|
-
morphType: string;
|
|
90
|
-
}): MorphOneRelation<TParent, TChild, LocalKey, MorphTypeKey, MorphIdKey>;
|
|
91
|
-
declare function morphTo<TChild, MorphTypeKey extends keyof TChild & string = keyof TChild & string, MorphIdKey extends keyof TChild & string = keyof TChild & string>(definition: {
|
|
92
|
-
name: string;
|
|
93
|
-
morphTypeKey: MorphTypeKey;
|
|
94
|
-
morphIdKey: MorphIdKey;
|
|
95
|
-
}): MorphToRelation<TChild, MorphTypeKey, MorphIdKey>;
|
|
96
|
-
declare function indexMorphManyRelation<TParent, TChild, LocalKey extends keyof TParent & string, MorphTypeKey extends keyof TChild & string, MorphIdKey extends keyof TChild & string>(parents: readonly TParent[], children: readonly TChild[], relation: MorphManyRelation<TParent, TChild, LocalKey, MorphTypeKey, MorphIdKey>): Map<TParent[LocalKey], TChild[]>;
|
|
97
|
-
declare function indexMorphOneRelation<TParent, TChild, LocalKey extends keyof TParent & string, MorphTypeKey extends keyof TChild & string, MorphIdKey extends keyof TChild & string>(parents: readonly TParent[], children: readonly TChild[], relation: MorphOneRelation<TParent, TChild, LocalKey, MorphTypeKey, MorphIdKey>): Map<TParent[LocalKey], TChild | undefined>;
|
|
98
|
-
declare function indexMorphToRelation<TChild, TParent extends object, MorphTypeKey extends keyof TChild & string, MorphIdKey extends keyof TChild & string, OwnerKey extends keyof TParent & string>(children: readonly TChild[], parentsByType: ReadonlyMap<string, ReadonlyMap<TParent[OwnerKey], TParent>>, relation: MorphToRelation<TChild, MorphTypeKey, MorphIdKey>): Map<TChild[MorphIdKey], TParent>;
|
|
99
|
-
export type { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasOneRelation, MorphManyRelation, MorphOneRelation, MorphToRelation, };
|
|
100
|
-
export { belongsTo, belongsToMany, hasMany, hasOne, indexBelongsToManyRelation, indexBelongsToRelation, indexHasManyRelation, indexHasOneRelation, indexMorphManyRelation, indexMorphOneRelation, indexMorphToRelation, morphMany, morphOne, morphTo, };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { PaginatedResult } from "../pagination/index.ts";
|
|
2
|
-
import type BaseRepository from "./baseRepository.ts";
|
|
3
|
-
import type { BelongsToRelation, HasManyRelation, MorphManyRelation, MorphOneRelation, MorphToRelation } from "./relationships.ts";
|
|
4
|
-
import type { QueryOptions, QueryWhere } from "./types.ts";
|
|
5
|
-
import { WhereBuilder } from "./whereBuilder.ts";
|
|
6
|
-
type LoadedRow = Record<string, unknown>;
|
|
7
|
-
declare class RepositoryQuery<TEntity extends object, PrimaryKey extends keyof TEntity & string> {
|
|
8
|
-
private readonly repository;
|
|
9
|
-
private whereClause;
|
|
10
|
-
private queryOptions;
|
|
11
|
-
private readonly eagerLoads;
|
|
12
|
-
private readonly whereNodes;
|
|
13
|
-
constructor(repository: BaseRepository<TEntity, PrimaryKey>, whereClause?: QueryWhere<TEntity>, queryOptions?: Omit<QueryOptions<TEntity>, "where">);
|
|
14
|
-
where(input: QueryWhere<TEntity> | ((builder: WhereBuilder<TEntity>) => void)): this;
|
|
15
|
-
orWhere(input: QueryWhere<TEntity> | ((builder: WhereBuilder<TEntity>) => void)): this;
|
|
16
|
-
orderBy(orderBy: QueryOptions<TEntity>["orderBy"]): this;
|
|
17
|
-
limit(limit: number): this;
|
|
18
|
-
offset(offset: number): this;
|
|
19
|
-
join(left: `${string}.${string}`, right: `${string}.${string}`): this;
|
|
20
|
-
leftJoin(left: `${string}.${string}`, right: `${string}.${string}`): this;
|
|
21
|
-
groupBy(groupBy: QueryOptions<TEntity>["groupBy"]): this;
|
|
22
|
-
having(having: QueryWhere<TEntity>): this;
|
|
23
|
-
withHasMany<TChild extends object, LocalKey extends keyof TEntity & string, ForeignKey extends keyof TChild & string, Alias extends string>(as: Alias, relation: HasManyRelation<TEntity, TChild, LocalKey, ForeignKey>, childRepository: BaseRepository<TChild, keyof TChild & string>, options?: Omit<QueryOptions<TChild>, "where">): this;
|
|
24
|
-
withBelongsTo<TParent extends object, ForeignKey extends keyof TEntity & string, OwnerKey extends keyof TParent & string, Alias extends string>(as: Alias, relation: BelongsToRelation<TEntity, TParent, ForeignKey, OwnerKey>, parentRepository: BaseRepository<TParent, OwnerKey>, options?: Omit<QueryOptions<TParent>, "where">): this;
|
|
25
|
-
withMorphMany<TChild extends object, LocalKey extends keyof TEntity & string, MorphTypeKey extends keyof TChild & string, MorphIdKey extends keyof TChild & string, Alias extends string>(as: Alias, relation: MorphManyRelation<TEntity, TChild, LocalKey, MorphTypeKey, MorphIdKey>, childRepository: BaseRepository<TChild, keyof TChild & string>, options?: Omit<QueryOptions<TChild>, "where">): this;
|
|
26
|
-
withMorphOne<TChild extends object, LocalKey extends keyof TEntity & string, MorphTypeKey extends keyof TChild & string, MorphIdKey extends keyof TChild & string, Alias extends string>(as: Alias, relation: MorphOneRelation<TEntity, TChild, LocalKey, MorphTypeKey, MorphIdKey>, childRepository: BaseRepository<TChild, keyof TChild & string>, options?: Omit<QueryOptions<TChild>, "where">): this;
|
|
27
|
-
withMorphTo<TParent extends object, MorphTypeKey extends keyof TEntity & string, MorphIdKey extends keyof TEntity & string, Alias extends string>(as: Alias, relation: MorphToRelation<TEntity, MorphTypeKey, MorphIdKey>, repositoriesByType: ReadonlyMap<string, BaseRepository<TParent, keyof TParent & string>>, options?: Omit<QueryOptions<TParent>, "where">): this;
|
|
28
|
-
get(): Promise<Array<TEntity & LoadedRow>>;
|
|
29
|
-
first(): Promise<(TEntity & LoadedRow) | null>;
|
|
30
|
-
paginate(options: {
|
|
31
|
-
page: number;
|
|
32
|
-
perPage: number;
|
|
33
|
-
}): Promise<PaginatedResult<TEntity>>;
|
|
34
|
-
private buildOptions;
|
|
35
|
-
private addJoin;
|
|
36
|
-
private attach;
|
|
37
|
-
}
|
|
38
|
-
export { RepositoryQuery };
|