@getstrata/bootstrap 0.1.1 → 0.2.1

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.
Files changed (95) hide show
  1. package/dist/bootstrap/context.d.ts +6 -0
  2. package/dist/bootstrap/createWebRoutes.d.ts +4 -0
  3. package/dist/bootstrap/discoverListeners.d.ts +5 -0
  4. package/dist/bootstrap/discoverModules.d.ts +4 -0
  5. package/dist/bootstrap/env.d.ts +9 -0
  6. package/dist/bootstrap/httpKernel.d.ts +2 -0
  7. package/dist/bootstrap/listeners/invalidateCacheOnModelWrite.d.ts +3 -0
  8. package/dist/bootstrap/modules.d.ts +1 -0
  9. package/dist/bootstrap/providers/auth.d.ts +3 -0
  10. package/dist/bootstrap/providers/cache.d.ts +3 -0
  11. package/dist/bootstrap/providers/config.d.ts +5 -0
  12. package/dist/bootstrap/providers/events.d.ts +5 -0
  13. package/dist/bootstrap/providers/index.d.ts +3 -0
  14. package/dist/bootstrap/providers/listeners.d.ts +3 -0
  15. package/dist/bootstrap/providers/policy.d.ts +3 -0
  16. package/dist/bootstrap/providers/queue.d.ts +3 -0
  17. package/dist/bootstrap/providers/view.d.ts +5 -0
  18. package/dist/bootstrap/public-api.d.ts +7 -1
  19. package/dist/bootstrap/routeRegistry.d.ts +14 -0
  20. package/dist/bootstrap/schedule.d.ts +1 -0
  21. package/dist/bootstrap/secretsGuard.d.ts +2 -0
  22. package/dist/cli/commands/scheduleRun.d.ts +3 -0
  23. package/dist/config/auth.d.ts +7 -0
  24. package/dist/config/queue.d.ts +8 -0
  25. package/dist/config/rateLimit.d.ts +2 -1
  26. package/dist/core/audit/exportAuditLogs.d.ts +8 -0
  27. package/dist/core/audit/siemFormatter.d.ts +30 -0
  28. package/dist/core/auth/sessionCookie.d.ts +6 -0
  29. package/dist/core/auth/sessionGuard.d.ts +9 -0
  30. package/dist/core/cache/createCacheStore.d.ts +11 -0
  31. package/dist/core/cache/modelCacheTags.d.ts +3 -0
  32. package/dist/core/cache/redisCacheStore.d.ts +23 -0
  33. package/dist/core/cache/repository.d.ts +17 -0
  34. package/dist/core/cache/simpleCache.d.ts +23 -0
  35. package/dist/core/cache/simpleCacheStore.d.ts +16 -0
  36. package/dist/core/cache/store.d.ts +12 -0
  37. package/dist/core/cache/taggedCache.d.ts +9 -0
  38. package/dist/core/config/envSchema.d.ts +12 -0
  39. package/dist/core/database/baseRepository.d.ts +16 -4
  40. package/dist/core/database/index.d.ts +10 -4
  41. package/dist/core/database/migrations/types.d.ts +15 -0
  42. package/dist/core/database/model.d.ts +57 -0
  43. package/dist/core/database/query.d.ts +25 -14
  44. package/dist/core/database/relationships.d.ts +32 -2
  45. package/dist/core/database/repositoryQuery.d.ts +16 -1
  46. package/dist/core/database/schema/blueprint.d.ts +47 -0
  47. package/dist/core/database/schema/columnDefinition.d.ts +36 -0
  48. package/dist/core/database/schema/driver.d.ts +8 -0
  49. package/dist/core/database/schema/errors.d.ts +4 -0
  50. package/dist/core/database/schema/grammars/compileStatements.d.ts +8 -0
  51. package/dist/core/database/schema/grammars/createGrammar.d.ts +4 -0
  52. package/dist/core/database/schema/grammars/grammar.d.ts +10 -0
  53. package/dist/core/database/schema/grammars/index.d.ts +7 -0
  54. package/dist/core/database/schema/grammars/mysqlGrammar.d.ts +2 -0
  55. package/dist/core/database/schema/grammars/postgresGrammar.d.ts +2 -0
  56. package/dist/core/database/schema/grammars/sqliteGrammar.d.ts +2 -0
  57. package/dist/core/database/schema/index.d.ts +12 -0
  58. package/dist/core/database/schema/schema.d.ts +21 -0
  59. package/dist/core/database/types.d.ts +39 -2
  60. package/dist/core/database/whereBuilder.d.ts +17 -0
  61. package/dist/core/jobs/dispatchWebhookJob.d.ts +14 -0
  62. package/dist/core/jobs/invalidateCacheTagsJob.d.ts +12 -0
  63. package/dist/core/pagination/index.d.ts +11 -1
  64. package/dist/core/queue/createAppQueue.d.ts +6 -0
  65. package/dist/core/queue/failedJobRepository.d.ts +6 -0
  66. package/dist/core/queue/failedJobService.d.ts +15 -0
  67. package/dist/core/queue/failedJobTable.d.ts +3 -0
  68. package/dist/core/queue/jobRegistry.d.ts +14 -0
  69. package/dist/core/queue/jobRunner.d.ts +9 -0
  70. package/dist/core/queue/publicQueue.d.ts +15 -0
  71. package/dist/core/queue/redisQueue.d.ts +29 -0
  72. package/dist/core/queue/resilientQueue.d.ts +9 -0
  73. package/dist/core/queue/types.d.ts +8 -0
  74. package/dist/core/scheduler/schedule.d.ts +15 -0
  75. package/dist/core/security/safeFetch.d.ts +8 -0
  76. package/dist/core/security/safeUrl.d.ts +5 -0
  77. package/dist/core/view/etaViewEngine.d.ts +15 -0
  78. package/dist/core/view/htmlResponse.d.ts +6 -0
  79. package/dist/core/view/index.d.ts +5 -0
  80. package/dist/core/view/viewEngine.d.ts +6 -0
  81. package/dist/core/view/webLayoutData.d.ts +17 -0
  82. package/dist/domain/scim.d.ts +9 -0
  83. package/dist/index.js +4180 -458
  84. package/dist/modules/user/apiTokenRepository.d.ts +1 -1
  85. package/dist/modules/user/apiTokenTable.d.ts +1 -1
  86. package/dist/modules/user/authService.d.ts +1 -1
  87. package/dist/modules/user/notificationRepository.d.ts +1 -1
  88. package/dist/modules/user/notificationService.d.ts +1 -1
  89. package/dist/modules/user/notificationTable.d.ts +1 -1
  90. package/dist/modules/user/oauthIdentityRepository.d.ts +2 -2
  91. package/dist/modules/user/provider.d.ts +1 -1
  92. package/dist/modules/user/repository.d.ts +1 -1
  93. package/dist/modules/user/table.d.ts +1 -1
  94. package/dist/modules/user/tokenService.d.ts +1 -1
  95. package/package.json +44 -3
@@ -4,23 +4,53 @@ interface HasManyRelation<TParent, TChild, LocalKey extends keyof TParent & stri
4
4
  localKey: LocalKey;
5
5
  foreignKey: ForeignKey;
6
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
+ }
7
13
  interface BelongsToRelation<TChild, TParent, ForeignKey extends keyof TChild & string = keyof TChild & string, OwnerKey extends keyof TParent & string = keyof TParent & string> {
8
14
  type: "belongsTo";
9
15
  name: string;
10
16
  foreignKey: ForeignKey;
11
17
  ownerKey: OwnerKey;
12
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
+ }
13
28
  declare function hasMany<TParent, TChild, LocalKey extends keyof TParent & string = keyof TParent & string, ForeignKey extends keyof TChild & string = keyof TChild & string>(definition: {
14
29
  name: string;
15
30
  localKey: LocalKey;
16
31
  foreignKey: ForeignKey;
17
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>;
18
38
  declare function belongsTo<TChild, TParent, ForeignKey extends keyof TChild & string = keyof TChild & string, OwnerKey extends keyof TParent & string = keyof TParent & string>(definition: {
19
39
  name: string;
20
40
  foreignKey: ForeignKey;
21
41
  ownerKey: OwnerKey;
22
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>;
23
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>;
24
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>;
25
- export type { BelongsToRelation, HasManyRelation };
26
- export { belongsTo, hasMany, indexBelongsToRelation, indexHasManyRelation };
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
+ export type { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasOneRelation };
56
+ export { belongsTo, belongsToMany, hasMany, hasOne, indexBelongsToManyRelation, indexBelongsToRelation, indexHasManyRelation, indexHasOneRelation, };
@@ -1,20 +1,35 @@
1
+ import type { PaginatedResult } from "../pagination/index.ts";
1
2
  import type BaseRepository from "./baseRepository.ts";
2
3
  import type { BelongsToRelation, HasManyRelation } from "./relationships.ts";
3
4
  import type { QueryOptions, QueryWhere } from "./types.ts";
5
+ import { WhereBuilder } from "./whereBuilder.ts";
4
6
  type LoadedRow = Record<string, unknown>;
5
7
  declare class RepositoryQuery<TEntity extends object, PrimaryKey extends keyof TEntity & string> {
6
8
  private readonly repository;
7
9
  private whereClause;
8
10
  private queryOptions;
9
11
  private readonly eagerLoads;
12
+ private readonly whereNodes;
10
13
  constructor(repository: BaseRepository<TEntity, PrimaryKey>, whereClause?: QueryWhere<TEntity>, queryOptions?: Omit<QueryOptions<TEntity>, "where">);
11
- where(where: QueryWhere<TEntity>): this;
14
+ where(input: QueryWhere<TEntity> | ((builder: WhereBuilder<TEntity>) => void)): this;
15
+ orWhere(input: QueryWhere<TEntity> | ((builder: WhereBuilder<TEntity>) => void)): this;
12
16
  orderBy(orderBy: QueryOptions<TEntity>["orderBy"]): this;
13
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;
14
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;
15
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;
16
25
  get(): Promise<Array<TEntity & LoadedRow>>;
17
26
  first(): Promise<(TEntity & LoadedRow) | null>;
27
+ paginate(options: {
28
+ page: number;
29
+ perPage: number;
30
+ }): Promise<PaginatedResult<TEntity>>;
31
+ private buildOptions;
32
+ private addJoin;
18
33
  private attach;
19
34
  }
20
35
  export { RepositoryQuery };
@@ -0,0 +1,47 @@
1
+ import { ColumnDefinition, ForeignIdColumnDefinition } from "./columnDefinition.ts";
2
+ type IndexKind = "index" | "unique" | "partial" | "uniquePartial" | "fullText" | "gin";
3
+ interface IndexDefinition {
4
+ name?: string;
5
+ columns: string[];
6
+ kind: IndexKind;
7
+ where?: string;
8
+ order?: "asc" | "desc";
9
+ }
10
+ type BlueprintAction = "create" | "alter" | "drop";
11
+ declare class Blueprint {
12
+ readonly table: string;
13
+ readonly action: BlueprintAction;
14
+ readonly columns: ColumnDefinition[];
15
+ readonly indexes: IndexDefinition[];
16
+ readonly droppedColumns: string[];
17
+ readonly droppedIndexes: string[];
18
+ constructor(table: string, action: BlueprintAction);
19
+ id(name?: string): ColumnDefinition;
20
+ string(name: string, length?: number): ColumnDefinition;
21
+ text(name: string): ColumnDefinition;
22
+ boolean(name: string): ColumnDefinition;
23
+ integer(name: string): ColumnDefinition;
24
+ bigInteger(name: string): ColumnDefinition;
25
+ timestamp(name: string): ColumnDefinition;
26
+ json(name: string): ColumnDefinition;
27
+ jsonb(name: string): ColumnDefinition;
28
+ foreignId(name: string): ForeignIdColumnDefinition;
29
+ timestamps(): void;
30
+ softDeletes(): void;
31
+ dropColumn(name: string): void;
32
+ dropSoftDeletes(): void;
33
+ dropIndex(name: string): void;
34
+ unique(columns: string | string[], name?: string): void;
35
+ index(columns: string | string[], options?: {
36
+ name?: string;
37
+ order?: "asc" | "desc";
38
+ }): void;
39
+ partialIndex(columns: string | string[], where: string, nameOrOptions?: string | {
40
+ name?: string;
41
+ unique?: boolean;
42
+ }): void;
43
+ fullText(columns: string | string[], name?: string): void;
44
+ ginIndex(column: string, name?: string): void;
45
+ }
46
+ export type { BlueprintAction, IndexDefinition, IndexKind };
47
+ export { Blueprint };
@@ -0,0 +1,36 @@
1
+ type ColumnKind = "id" | "string" | "text" | "boolean" | "integer" | "bigInteger" | "timestamp" | "json" | "jsonb" | "foreignId";
2
+ interface ForeignKeyOptions {
3
+ referencesTable: string;
4
+ referencesColumn: string;
5
+ onDelete?: "cascade" | "set null" | "restrict";
6
+ }
7
+ declare class ColumnDefinition {
8
+ readonly name: string;
9
+ kind: ColumnKind;
10
+ length?: number;
11
+ isNullable: boolean;
12
+ isPrimary: boolean;
13
+ isUnique: boolean;
14
+ autoIncrement: boolean;
15
+ defaultValue?: string;
16
+ checkExpression?: string;
17
+ foreignKey?: ForeignKeyOptions;
18
+ constructor(name: string, kind: ColumnKind);
19
+ nullable(): this;
20
+ notNullable(): this;
21
+ default(value: string | number | boolean): this;
22
+ defaultRaw(expression: string): this;
23
+ unique(): this;
24
+ primary(): this;
25
+ check(expression: string): this;
26
+ }
27
+ declare class ForeignIdColumnDefinition extends ColumnDefinition {
28
+ constructor(name: string);
29
+ references(table: string, column?: string): this;
30
+ constrained(table?: string): this;
31
+ cascadeOnDelete(): this;
32
+ nullOnDelete(): this;
33
+ }
34
+ declare function inferReferencedTable(columnName: string): string;
35
+ export type { ColumnKind, ForeignKeyOptions };
36
+ export { ColumnDefinition, ForeignIdColumnDefinition, inferReferencedTable };
@@ -0,0 +1,8 @@
1
+ type DatabaseDriver = "pgsql" | "mysql" | "sqlite";
2
+ interface ResolveDatabaseDriverOptions {
3
+ url?: string;
4
+ connection?: string;
5
+ }
6
+ declare function resolveDatabaseDriver(options?: ResolveDatabaseDriverOptions): DatabaseDriver;
7
+ export type { DatabaseDriver, ResolveDatabaseDriverOptions };
8
+ export { resolveDatabaseDriver };
@@ -0,0 +1,4 @@
1
+ declare class UnsupportedSchemaFeatureError extends Error {
2
+ constructor(feature: string, driver: string);
3
+ }
4
+ export { UnsupportedSchemaFeatureError };
@@ -0,0 +1,8 @@
1
+ import type { Blueprint, IndexDefinition } from "../blueprint.ts";
2
+ import type { ColumnDefinition } from "../columnDefinition.ts";
3
+ import type { DatabaseDriver } from "../driver.ts";
4
+ declare function compileDropTable(driver: DatabaseDriver, tableName: string): string[];
5
+ declare function compileColumn(driver: DatabaseDriver, column: ColumnDefinition, mode: "create" | "alter"): string;
6
+ declare function compileIndex(_driver: DatabaseDriver, tableName: string, index: IndexDefinition): string;
7
+ declare function compileBlueprint(driver: DatabaseDriver, blueprint: Blueprint): string[];
8
+ export { compileBlueprint, compileColumn, compileDropTable, compileIndex };
@@ -0,0 +1,4 @@
1
+ import type { DatabaseDriver } from "../driver.ts";
2
+ import type { Grammar } from "./grammar.ts";
3
+ declare function createGrammar(driver: DatabaseDriver): Grammar;
4
+ export { createGrammar };
@@ -0,0 +1,10 @@
1
+ import type { Blueprint } from "../blueprint.ts";
2
+ import type { ColumnDefinition } from "../columnDefinition.ts";
3
+ import type { DatabaseDriver } from "../driver.ts";
4
+ interface Grammar {
5
+ readonly driver: DatabaseDriver;
6
+ compile(blueprint: Blueprint): string[];
7
+ }
8
+ declare function compileColumnType(driver: DatabaseDriver, column: ColumnDefinition): string;
9
+ export type { Grammar };
10
+ export { compileColumnType };
@@ -0,0 +1,7 @@
1
+ import type { DatabaseDriver } from "../driver.ts";
2
+ import type { Grammar } from "./grammar.ts";
3
+ import { MySqlGrammar } from "./mysqlGrammar.ts";
4
+ import { PostgresGrammar } from "./postgresGrammar.ts";
5
+ import { SqliteGrammar } from "./sqliteGrammar.ts";
6
+ declare function grammarForDriver(driver: DatabaseDriver): Grammar;
7
+ export { grammarForDriver, MySqlGrammar, PostgresGrammar, SqliteGrammar };
@@ -0,0 +1,2 @@
1
+ declare const MySqlGrammar: import("./grammar.ts").Grammar;
2
+ export { MySqlGrammar };
@@ -0,0 +1,2 @@
1
+ declare const PostgresGrammar: import("./grammar.ts").Grammar;
2
+ export { PostgresGrammar };
@@ -0,0 +1,2 @@
1
+ declare const SqliteGrammar: import("./grammar.ts").Grammar;
2
+ export { SqliteGrammar };
@@ -0,0 +1,12 @@
1
+ export type { BlueprintAction, IndexDefinition, IndexKind } from "./blueprint.ts";
2
+ export { Blueprint } from "./blueprint.ts";
3
+ export type { ColumnKind, ForeignKeyOptions } from "./columnDefinition.ts";
4
+ export { ColumnDefinition, ForeignIdColumnDefinition, inferReferencedTable, } from "./columnDefinition.ts";
5
+ export type { DatabaseDriver, ResolveDatabaseDriverOptions } from "./driver.ts";
6
+ export { resolveDatabaseDriver } from "./driver.ts";
7
+ export { UnsupportedSchemaFeatureError } from "./errors.ts";
8
+ export { compileBlueprint } from "./grammars/compileStatements.ts";
9
+ export type { Grammar } from "./grammars/grammar.ts";
10
+ export { grammarForDriver, MySqlGrammar, PostgresGrammar, SqliteGrammar, } from "./grammars/index.ts";
11
+ export type { BlueprintCallback } from "./schema.ts";
12
+ export { createSchemaBuilder, Schema, SchemaBuilder } from "./schema.ts";
@@ -0,0 +1,21 @@
1
+ import type { MigrationDatabase } from "../migrations/types.ts";
2
+ import { Blueprint } from "./blueprint.ts";
3
+ import type { DatabaseDriver } from "./driver.ts";
4
+ import { resolveDatabaseDriver } from "./driver.ts";
5
+ type BlueprintCallback = (table: Blueprint) => void;
6
+ declare class SchemaBuilder {
7
+ #private;
8
+ constructor(driver: DatabaseDriver);
9
+ create(table: string, callback: BlueprintCallback): this;
10
+ table(table: string, callback: BlueprintCallback): this;
11
+ drop(table: string): this;
12
+ toSql(): string[];
13
+ execute(db: MigrationDatabase): Promise<void>;
14
+ }
15
+ declare class Schema {
16
+ static builder(driver?: DatabaseDriver): SchemaBuilder;
17
+ static run(db: MigrationDatabase, driver: DatabaseDriver, callback: (schema: SchemaBuilder) => void | Promise<void>): Promise<void>;
18
+ }
19
+ declare function createSchemaBuilder(db: MigrationDatabase, driver?: DatabaseDriver): SchemaBuilder;
20
+ export type { BlueprintCallback };
21
+ export { createSchemaBuilder, resolveDatabaseDriver, Schema, SchemaBuilder };
@@ -8,14 +8,47 @@ type QueryOperator = {
8
8
  lt?: DatabaseComparable;
9
9
  lte?: DatabaseComparable;
10
10
  isNull?: boolean;
11
+ ilike?: string;
12
+ tsMatch?: string;
11
13
  };
12
14
  type QueryFilterValue = DatabaseScalar | readonly DatabaseScalar[] | QueryOperator;
13
- type QueryWhere<TEntity> = Partial<Record<keyof TEntity & string, QueryFilterValue>>;
15
+ type QueryWhere<TEntity> = Partial<Record<keyof TEntity & string, QueryFilterValue>> & Partial<Record<string, QueryFilterValue>>;
14
16
  type QueryOrder<TEntity> = {
15
17
  column: keyof TEntity & string;
16
18
  direction?: "ASC" | "DESC" | "asc" | "desc";
17
19
  };
18
20
  type QueryOrderShorthand<TEntity> = Partial<Record<keyof TEntity & string, "ASC" | "DESC" | "asc" | "desc">>;
21
+ type QueryJoinOn = {
22
+ left: {
23
+ table: string;
24
+ column: string;
25
+ };
26
+ right: {
27
+ table: string;
28
+ column: string;
29
+ };
30
+ };
31
+ type QueryJoin = {
32
+ type: "inner" | "left";
33
+ table: string;
34
+ on: QueryJoinOn[];
35
+ };
36
+ type QuerySelectItem = {
37
+ kind: "column";
38
+ table: string;
39
+ column: string;
40
+ as?: string;
41
+ } | {
42
+ kind: "literalText";
43
+ value: string;
44
+ as: string;
45
+ } | {
46
+ kind: "tsRank";
47
+ table: string;
48
+ column: string;
49
+ query: string;
50
+ as: string;
51
+ };
19
52
  interface QueryOptions<TEntity> {
20
53
  where?: QueryWhere<TEntity>;
21
54
  orderBy?: QueryOrder<TEntity> | QueryOrder<TEntity>[] | QueryOrderShorthand<TEntity>;
@@ -23,7 +56,11 @@ interface QueryOptions<TEntity> {
23
56
  offset?: number;
24
57
  withTrashed?: boolean;
25
58
  onlyTrashed?: boolean;
59
+ joins?: QueryJoin[];
60
+ groupBy?: string | string[];
61
+ having?: QueryWhere<TEntity>;
62
+ select?: QuerySelectItem[];
26
63
  }
27
64
  type MutationValues<TEntity> = Partial<TEntity>;
28
65
  type UpdateValues<TEntity, PrimaryKey extends keyof TEntity & string = keyof TEntity & string> = Partial<Omit<TEntity, PrimaryKey>>;
29
- export type { DatabaseComparable, DatabaseScalar, MutationValues, QueryFilterValue, QueryOperator, QueryOptions, QueryOrder, QueryWhere, UpdateValues, };
66
+ export type { DatabaseComparable, DatabaseScalar, MutationValues, QueryFilterValue, QueryJoin, QueryJoinOn, QueryOperator, QueryOptions, QueryOrder, QuerySelectItem, QueryWhere, UpdateValues, };
@@ -0,0 +1,17 @@
1
+ import type { QueryWhere } from "./types.ts";
2
+ type WhereNode<TEntity extends object> = {
3
+ kind: "and" | "or";
4
+ where: QueryWhere<TEntity>;
5
+ } | {
6
+ kind: "and" | "or";
7
+ group: WhereNode<TEntity>[];
8
+ };
9
+ declare class WhereBuilder<TEntity extends object> {
10
+ readonly nodes: WhereNode<TEntity>[];
11
+ where(where: QueryWhere<TEntity>): this;
12
+ orWhere(where: QueryWhere<TEntity>): this;
13
+ whereGroup(fn: (builder: WhereBuilder<TEntity>) => void): this;
14
+ orWhereGroup(fn: (builder: WhereBuilder<TEntity>) => void): this;
15
+ }
16
+ export type { WhereNode };
17
+ export { WhereBuilder };
@@ -0,0 +1,14 @@
1
+ import { Job } from "../queue";
2
+ interface DispatchWebhookPayload {
3
+ webhookId: number;
4
+ event: string;
5
+ payload: Record<string, unknown>;
6
+ }
7
+ declare class DispatchWebhookJob extends Job<DispatchWebhookPayload> {
8
+ constructor();
9
+ readonly maxAttempts = 3;
10
+ readonly backoffMs = 2000;
11
+ handle(payload: DispatchWebhookPayload): Promise<void>;
12
+ }
13
+ export default DispatchWebhookJob;
14
+ export type { DispatchWebhookPayload };
@@ -0,0 +1,12 @@
1
+ import type { CacheLike } from "../../types/services";
2
+ import { Job } from "../queue";
3
+ interface InvalidateCacheTagsPayload {
4
+ tags: string[];
5
+ }
6
+ declare class InvalidateCacheTagsJob extends Job<InvalidateCacheTagsPayload> {
7
+ private readonly cache;
8
+ constructor(cache: CacheLike);
9
+ handle(payload: InvalidateCacheTagsPayload): Promise<void>;
10
+ }
11
+ export default InvalidateCacheTagsJob;
12
+ export type { InvalidateCacheTagsPayload };
@@ -8,10 +8,20 @@ interface PaginatedResult<T> {
8
8
  data: T[];
9
9
  meta: PaginationMeta;
10
10
  }
11
+ interface CursorPaginationMeta<Cursor = unknown> {
12
+ per_page: number;
13
+ next_cursor: Cursor | null;
14
+ prev_cursor: Cursor | null;
15
+ has_more: boolean;
16
+ }
17
+ interface CursorPaginatedResult<T, Cursor = unknown> {
18
+ data: T[];
19
+ meta: CursorPaginationMeta<Cursor>;
20
+ }
11
21
  declare function buildPaginationMeta(input: {
12
22
  page: number;
13
23
  perPage: number;
14
24
  total: number;
15
25
  }): PaginationMeta;
16
- export type { PaginatedResult, PaginationMeta };
26
+ export type { CursorPaginatedResult, CursorPaginationMeta, PaginatedResult, PaginationMeta };
17
27
  export { buildPaginationMeta };
@@ -0,0 +1,6 @@
1
+ import type { Queue } from "./index";
2
+ import { createFailedJobService, createQueueWorker, createTrackedJob, type FailedJobService } from "./publicQueue";
3
+ declare const FAILED_JOB_SERVICE_TOKEN = "core.failedJobs";
4
+ declare function registerDefaultJobs(): void;
5
+ declare function createAppQueue(driver: "sync" | "async" | "redis", redisUrl?: string, failedJobs?: FailedJobService): Queue;
6
+ export { createAppQueue, createFailedJobService, createQueueWorker, createTrackedJob, FAILED_JOB_SERVICE_TOKEN, registerDefaultJobs, };
@@ -0,0 +1,6 @@
1
+ import { BaseRepository } from "../database";
2
+ import type { FailedJobRecord } from "./types";
3
+ declare class FailedJobRepository extends BaseRepository<FailedJobRecord, "id"> {
4
+ constructor();
5
+ }
6
+ export default FailedJobRepository;
@@ -0,0 +1,15 @@
1
+ import type FailedJobRepository from "./failedJobRepository";
2
+ import type { FailedJobRecord } from "./types";
3
+ declare class FailedJobService {
4
+ private readonly repository;
5
+ constructor(repository: FailedJobRepository);
6
+ recordFailure(input: {
7
+ jobName: string;
8
+ payload: Record<string, unknown>;
9
+ exception: string;
10
+ }): Promise<FailedJobRecord>;
11
+ listRecent(limit?: number): Promise<FailedJobRecord[]>;
12
+ retry(id: number): Promise<FailedJobRecord>;
13
+ flush(): Promise<number>;
14
+ }
15
+ export default FailedJobService;
@@ -0,0 +1,3 @@
1
+ import type { FailedJobRecord } from "./types";
2
+ declare const failedJobTable: import("../database").TableDefinition<FailedJobRecord, "id">;
3
+ export { failedJobTable };
@@ -0,0 +1,14 @@
1
+ import type { Job } from "./index";
2
+ type JobFactory = () => Job;
3
+ declare class JobRegistry {
4
+ constructor();
5
+ private readonly factories;
6
+ private readonly instances;
7
+ register(name: string, factory: JobFactory): void;
8
+ resolveName(job: Job): string | undefined;
9
+ track(name: string, job: Job): Job;
10
+ create(name: string): Job | undefined;
11
+ names(): string[];
12
+ }
13
+ declare const jobRegistry: JobRegistry;
14
+ export { JobRegistry, jobRegistry };
@@ -0,0 +1,9 @@
1
+ import type FailedJobService from "./failedJobService";
2
+ interface QueueJobEnvelope {
3
+ name: string;
4
+ payload: Record<string, unknown>;
5
+ attempts?: number;
6
+ }
7
+ declare function runQueueJob(envelope: QueueJobEnvelope, failedJobs: FailedJobService): Promise<void>;
8
+ export type { QueueJobEnvelope };
9
+ export { runQueueJob };
@@ -0,0 +1,15 @@
1
+ import FailedJobRepository from "./failedJobRepository.ts";
2
+ import FailedJobService from "./failedJobService.ts";
3
+ import type { Job, Queue } from "./index.ts";
4
+ import { jobRegistry } from "./jobRegistry.ts";
5
+ import { QueueWorker, RedisQueue } from "./redisQueue.ts";
6
+ import { ResilientQueue } from "./resilientQueue.ts";
7
+ declare function createFailedJobService(): FailedJobService;
8
+ declare function createTrackedJob<TPayload extends object>(name: string, job: Job<TPayload>): Job<TPayload>;
9
+ declare function createProductionQueue(driver: "sync" | "async" | "redis", options?: {
10
+ redisUrl?: string;
11
+ failedJobs?: FailedJobService;
12
+ registerJobs?: () => void;
13
+ }): Queue;
14
+ declare function createQueueWorker(redisUrl: string, failedJobs?: FailedJobService): QueueWorker;
15
+ export { createFailedJobService, createProductionQueue, createQueueWorker, createTrackedJob, FailedJobRepository, FailedJobService, jobRegistry, QueueWorker, RedisQueue, ResilientQueue, };
@@ -0,0 +1,29 @@
1
+ import type FailedJobService from "./failedJobService";
2
+ import type { Job, Queue, QueuePriority } from "./index";
3
+ import { type QueueJobEnvelope } from "./jobRunner";
4
+ declare const QUEUE_LIST_KEY = "workhub:queue:default";
5
+ declare const QUEUE_HIGH_KEY = "workhub:queue:high";
6
+ declare const QUEUE_LOW_KEY = "workhub:queue:low";
7
+ declare function queueKeyForPriority(priority?: QueuePriority): string;
8
+ declare function parseQueueJobEnvelope(rawPayload: string): QueueJobEnvelope | null;
9
+ declare class RedisQueue implements Queue {
10
+ private readonly client;
11
+ constructor(redisUrl: string);
12
+ dispatch<TPayload extends object>(job: Job<TPayload>, payload: TPayload): Promise<void>;
13
+ }
14
+ declare class QueueWorker {
15
+ private readonly failedJobs;
16
+ private readonly timeoutSeconds;
17
+ private running;
18
+ private stopping;
19
+ private readonly client;
20
+ constructor(redisUrl: string, failedJobs: FailedJobService, timeoutSeconds?: number);
21
+ requestStop(): void;
22
+ isRunning(): boolean;
23
+ processNext(): Promise<boolean>;
24
+ run(): Promise<void>;
25
+ close(): void;
26
+ }
27
+ declare function countPendingQueueJobs(redisUrl: string): Promise<number>;
28
+ export type { QueueJobEnvelope };
29
+ export { countPendingQueueJobs, parseQueueJobEnvelope, QUEUE_HIGH_KEY, QUEUE_LIST_KEY, QUEUE_LOW_KEY, QueueWorker, queueKeyForPriority, RedisQueue, };
@@ -0,0 +1,9 @@
1
+ import type FailedJobService from "./failedJobService";
2
+ import type { Job, Queue } from "./index";
3
+ declare class ResilientQueue implements Queue {
4
+ private readonly failedJobs;
5
+ private readonly asyncDispatch;
6
+ constructor(failedJobs: FailedJobService, asyncDispatch?: boolean);
7
+ dispatch<TPayload extends object>(job: Job<TPayload>, payload: TPayload): Promise<void>;
8
+ }
9
+ export { ResilientQueue };
@@ -0,0 +1,8 @@
1
+ interface FailedJobRecord {
2
+ id: number;
3
+ job_name: string;
4
+ payload: Record<string, unknown>;
5
+ exception: string;
6
+ failed_at: Date;
7
+ }
8
+ export type { FailedJobRecord };
@@ -0,0 +1,15 @@
1
+ type ScheduledTask = {
2
+ expression: string;
3
+ name: string;
4
+ run: () => void | Promise<void>;
5
+ };
6
+ declare class Schedule {
7
+ private readonly tasks;
8
+ command(expression: string, name: string, run: () => void | Promise<void>): this;
9
+ dueTasks(now?: Date): ScheduledTask[];
10
+ tasksList(): ScheduledTask[];
11
+ }
12
+ declare const appSchedule: Schedule;
13
+ declare function runDueScheduledTasks(schedule?: Schedule, now?: Date): Promise<number>;
14
+ export type { ScheduledTask };
15
+ export { appSchedule, runDueScheduledTasks, Schedule };
@@ -0,0 +1,8 @@
1
+ declare const DEFAULT_FETCH_TIMEOUT_MS = 10000;
2
+ interface SafeFetchOptions {
3
+ timeoutMs?: number;
4
+ maxRedirects?: number;
5
+ }
6
+ declare function safeFetch(input: string, init?: RequestInit, options?: SafeFetchOptions): Promise<Response>;
7
+ export type { SafeFetchOptions };
8
+ export { DEFAULT_FETCH_TIMEOUT_MS, safeFetch };
@@ -0,0 +1,5 @@
1
+ declare function isBlockedHostname(hostname: string): boolean;
2
+ declare function assertSafeOutboundUrl(rawUrl: string, options?: {
3
+ allowHttp?: boolean;
4
+ }): URL;
5
+ export { assertSafeOutboundUrl, isBlockedHostname };
@@ -0,0 +1,15 @@
1
+ import type { ViewEngine } from "./viewEngine";
2
+ declare const DEFAULT_VIEWS_DIRECTORY: string;
3
+ declare const DEFAULT_LAYOUT = "layouts/app.eta";
4
+ interface RenderOptions {
5
+ layout?: string | false;
6
+ }
7
+ type LayoutDataResolver = () => Promise<Record<string, unknown>>;
8
+ declare class EtaViewEngine implements ViewEngine {
9
+ private readonly eta;
10
+ private readonly resolveLayoutData?;
11
+ constructor(viewsDirectory?: string, resolveLayoutData?: LayoutDataResolver);
12
+ render(name: string, data?: Record<string, unknown>, options?: RenderOptions): Promise<string>;
13
+ }
14
+ export type { RenderOptions };
15
+ export { DEFAULT_LAYOUT, DEFAULT_VIEWS_DIRECTORY, EtaViewEngine };
@@ -0,0 +1,6 @@
1
+ declare function htmlResponse(html: string, init?: {
2
+ status?: number;
3
+ statusText?: string;
4
+ }): Response;
5
+ declare function isHtmxRequest(request: Request): boolean;
6
+ export { htmlResponse, isHtmxRequest };
@@ -0,0 +1,5 @@
1
+ export { DEFAULT_VIEWS_DIRECTORY, EtaViewEngine } from "./etaViewEngine";
2
+ export { htmlResponse, isHtmxRequest } from "./htmlResponse";
3
+ export type { ViewEngine } from "./viewEngine";
4
+ export type { WebLayoutAuthUser, WebLayoutData } from "./webLayoutData";
5
+ export { resolveWebLayoutData } from "./webLayoutData";
@@ -0,0 +1,6 @@
1
+ interface ViewEngine {
2
+ render(name: string, data?: Record<string, unknown>, options?: {
3
+ layout?: string | false;
4
+ }): Promise<string>;
5
+ }
6
+ export type { ViewEngine };
@@ -0,0 +1,17 @@
1
+ import type { ServiceContainer } from "../../bootstrap/contracts";
2
+ interface WebLayoutAuthUser {
3
+ id: number;
4
+ email: string;
5
+ role: string;
6
+ }
7
+ interface WebLayoutData {
8
+ authUser: WebLayoutAuthUser | null;
9
+ csrfToken: string;
10
+ flash: {
11
+ level: string;
12
+ message: string;
13
+ } | null;
14
+ }
15
+ declare function resolveWebLayoutData(container: ServiceContainer, request?: Request): Promise<Record<string, unknown>>;
16
+ export type { WebLayoutAuthUser, WebLayoutData };
17
+ export { resolveWebLayoutData };