@guren/core 1.7.0 → 1.8.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.
package/dist/bin.d.ts CHANGED
@@ -1,5 +1 @@
1
- #!/usr/bin/env bun
2
- import '@guren/server/lambda';
3
- import '@guren/server/redis';
4
- import '@guren/server/runtime';
5
- import '@guren/server/vite';
1
+ import "@guren/cli/bin";
package/dist/bin.js CHANGED
@@ -1,4 +1,3 @@
1
1
  #!/usr/bin/env bun
2
-
3
- // src/bin.ts
4
2
  import "@guren/cli/bin";
3
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,22 +1,22 @@
1
- import { ApiTokenStore, ApiToken, SessionStore, SessionData, OAuthStateStore, OAuthStatePayload } from '@guren/server';
2
- export * from '@guren/server';
3
- export { AccessorDefinitions, AccessorFn, AwsDataApiDatabase, AwsDataApiDatabaseOptions, AwsDataApiSeederContext, BelongsToManyRecord, BelongsToManyRelationResult, BelongsToRecord, BelongsToRelationResult, BelongsToRequiredRecord, CastType, D1DatabaseHandle, D1DatabaseOptions, DrizzleAdapter, EagerLoadConstraint, FindManyOptions, GroupCondition, HasManyRecord, HasManyRelationResult, HasManyThroughRecord, HasManyThroughRelationResult, HasOneRecord, HasOneRelationResult, HookCallback, HookName, InferModelInsert, InferModelRecord, MassAssignmentException, Model, ModelHooks, ModelNotFoundException, ModelObserver, ModelObserverConstructor, ModelPaginationMeta, ModelQueryOptions, MorphManyRecord, MorphManyRelationResult, MorphToRecord, MorphToRelationResult, MutatorDefinitions, MutatorFn, MySqlDatabase, MySqlDatabaseOptions, MySqlSeederContext, ORMAdapter, ORMAdapterAdvanced, OrderByClause, OrderByInput, OrderDefinition, OrderDirection, PaginateOptions, PaginatedResult, PlainObject, PostgresDatabase, PostgresDatabaseOptions, PostgresSeederContext, QueryBuilder, QueryBuilderOptions, ScopeFunction, SeederContext, SeederHandler, SimpleCondition, SoftDeletes, SoftDeletesStatic, SqliteDatabase, SqliteDatabaseOptions, SqliteSeederContext, TransactionHandle, TransactionModelScope, WhereClause, WhereCondition, WhereGroupCallback, WhereOperator, WithRelations, createAwsDataApiDatabase, createD1Database, createMySqlDatabase, createPostgresDatabase, createSqliteDatabase, defineModel, defineSeeder, runSeeders } from '@guren/orm';
4
-
1
+ import { ApiToken, ApiTokenStore, OAuthStatePayload, OAuthStateStore, SessionData, SessionStore } from "@guren/server";
2
+ import { AccessorDefinitions, AccessorFn, AwsDataApiDatabase, AwsDataApiDatabaseOptions, AwsDataApiSeederContext, BelongsToManyRecord, BelongsToManyRelationResult, BelongsToRecord, BelongsToRelationResult, BelongsToRequiredRecord, CastType, D1DatabaseHandle, D1DatabaseOptions, DrizzleAdapter, EagerLoadConstraint, FindManyOptions, GroupCondition, HasManyRecord, HasManyRelationResult, HasManyThroughRecord, HasManyThroughRelationResult, HasOneRecord, HasOneRelationResult, HookCallback, HookName, InferModelInsert, InferModelRecord, MassAssignmentException, MigrationRunSummary, MigrationStatusEntry, Model, ModelHooks, ModelNotFoundException, ModelObserver, ModelObserverConstructor, ModelPaginationMeta, ModelQueryOptions, MorphManyRecord, MorphManyRelationResult, MorphToRecord, MorphToRelationResult, MutatorDefinitions, MutatorFn, MySqlDatabase, MySqlDatabaseOptions, MySqlSeederContext, ORMAdapter, ORMAdapterAdvanced, OrderByClause, OrderByInput, OrderDefinition, OrderDirection, PaginateOptions, PaginatedResult, PlainObject, PostgresDatabase, PostgresDatabaseOptions, PostgresSeederContext, QueryBuilder, QueryBuilderOptions, ScopeFunction, SeederContext, SeederHandler, SeederRunSummary, SimpleCondition, SoftDeletes, SoftDeletesStatic, SqliteDatabase, SqliteDatabaseOptions, SqliteSeederContext, TransactionHandle, TransactionModelScope, WhereClause, WhereCondition, WhereGroupCallback, WhereOperator, WithRelations, createAwsDataApiDatabase, createD1Database, createMySqlDatabase, createPostgresDatabase, createSqliteDatabase, defineModel, defineSeeder, runSeeders } from "@guren/orm";
3
+ export * from "@guren/server";
4
+ //#region src/api-token-store.d.ts
5
5
  /**
6
6
  * Options for DatabaseApiTokenStore.
7
7
  */
8
8
  interface DatabaseApiTokenStoreOptions {
9
- /**
10
- * How the `abilities` column stores the ability list.
11
- *
12
- * - `'json'` (default) passes the array straight through — use with a
13
- * JSON-capable column (pg `jsonb`/`json`, sqlite `text(..., { mode: 'json' })`).
14
- * - `'text'` serializes to a JSON string for plain text columns.
15
- *
16
- * Reads always accept both representations.
17
- * @default 'json'
18
- */
19
- abilitiesMode?: 'json' | 'text';
9
+ /**
10
+ * How the `abilities` column stores the ability list.
11
+ *
12
+ * - `'json'` (default) passes the array straight through — use with a
13
+ * JSON-capable column (pg `jsonb`/`json`, sqlite `text(..., { mode: 'json' })`).
14
+ * - `'text'` serializes to a JSON string for plain text columns.
15
+ *
16
+ * Reads always accept both representations.
17
+ * @default 'json'
18
+ */
19
+ abilitiesMode?: 'json' | 'text';
20
20
  }
21
21
  /**
22
22
  * Database-backed API token store built on the Guren ORM.
@@ -41,39 +41,40 @@ interface DatabaseApiTokenStoreOptions {
41
41
  * ```
42
42
  */
43
43
  declare class DatabaseApiTokenStore implements ApiTokenStore {
44
- private readonly model;
45
- private readonly abilitiesMode;
46
- constructor(table: unknown, options?: DatabaseApiTokenStoreOptions);
47
- store(token: ApiToken): Promise<void>;
48
- findByHashedToken(hashedToken: string): Promise<ApiToken | null>;
49
- findByUserId(userId: string | number): Promise<ApiToken[]>;
50
- delete(id: string): Promise<void>;
51
- deleteForUser(userId: string | number): Promise<void>;
52
- updateLastUsed(id: string, timestamp: Date): Promise<void>;
53
- /**
54
- * Delete tokens whose expiration time has passed. Expired tokens are
55
- * already rejected by `verifyApiToken`; call this from a scheduled
56
- * job to keep the table small.
57
- */
58
- deleteExpired(now?: Date): Promise<void>;
59
- private deserialize;
44
+ private readonly model;
45
+ private readonly abilitiesMode;
46
+ constructor(table: unknown, options?: DatabaseApiTokenStoreOptions);
47
+ store(token: ApiToken): Promise<void>;
48
+ findByHashedToken(hashedToken: string): Promise<ApiToken | null>;
49
+ findByUserId(userId: string | number): Promise<ApiToken[]>;
50
+ delete(id: string): Promise<void>;
51
+ deleteForUser(userId: string | number): Promise<void>;
52
+ updateLastUsed(id: string, timestamp: Date): Promise<void>;
53
+ /**
54
+ * Delete tokens whose expiration time has passed. Expired tokens are
55
+ * already rejected by `verifyApiToken`; call this from a scheduled
56
+ * job to keep the table small.
57
+ */
58
+ deleteExpired(now?: Date): Promise<void>;
59
+ private deserialize;
60
60
  }
61
-
61
+ //#endregion
62
+ //#region src/session-store.d.ts
62
63
  /**
63
64
  * Options for DatabaseSessionStore.
64
65
  */
65
66
  interface DatabaseSessionStoreOptions {
66
- /**
67
- * How the `data` column stores the serialized session.
68
- *
69
- * - `'json'` (default) passes the object straight through — use with a
70
- * JSON-capable column (pg `jsonb`/`json`, sqlite `text(..., { mode: 'json' })`).
71
- * - `'text'` serializes to a JSON string for plain text columns.
72
- *
73
- * Reads always accept both representations.
74
- * @default 'json'
75
- */
76
- dataMode?: 'json' | 'text';
67
+ /**
68
+ * How the `data` column stores the serialized session.
69
+ *
70
+ * - `'json'` (default) passes the object straight through — use with a
71
+ * JSON-capable column (pg `jsonb`/`json`, sqlite `text(..., { mode: 'json' })`).
72
+ * - `'text'` serializes to a JSON string for plain text columns.
73
+ *
74
+ * Reads always accept both representations.
75
+ * @default 'json'
76
+ */
77
+ dataMode?: 'json' | 'text';
77
78
  }
78
79
  /**
79
80
  * Database-backed session store built on the Guren ORM — works on any
@@ -106,30 +107,31 @@ interface DatabaseSessionStoreOptions {
106
107
  * ```
107
108
  */
108
109
  declare class DatabaseSessionStore implements SessionStore {
109
- private readonly model;
110
- private readonly dataMode;
111
- constructor(table: unknown, options?: DatabaseSessionStoreOptions);
112
- read(id: string): Promise<SessionData | undefined>;
113
- write(id: string, data: SessionData, ttlSeconds: number): Promise<void>;
114
- destroy(id: string): Promise<void>;
115
- /**
116
- * Refresh an existing session's TTL with a single conditional UPDATE — no
117
- * data rewrite, no existence check. Missing rows and rows that have
118
- * already expired (but not yet been swept) are left untouched, never
119
- * resurrected — matching the `SessionStore.touch` contract and the memory
120
- * store's behavior.
121
- */
122
- touch(id: string, ttlSeconds: number): Promise<void>;
123
- /**
124
- * Delete sessions whose expiration time has passed. Expired rows are
125
- * already treated as missing (and removed) by `read`; call this from a
126
- * scheduled job to keep the table small.
127
- */
128
- deleteExpired(now?: Date): Promise<void>;
129
- private deserialize;
130
- private expiryDate;
110
+ private readonly model;
111
+ private readonly dataMode;
112
+ constructor(table: unknown, options?: DatabaseSessionStoreOptions);
113
+ read(id: string): Promise<SessionData | undefined>;
114
+ write(id: string, data: SessionData, ttlSeconds: number): Promise<void>;
115
+ destroy(id: string): Promise<void>;
116
+ /**
117
+ * Refresh an existing session's TTL with a single conditional UPDATE — no
118
+ * data rewrite, no existence check. Missing rows and rows that have
119
+ * already expired (but not yet been swept) are left untouched, never
120
+ * resurrected — matching the `SessionStore.touch` contract and the memory
121
+ * store's behavior.
122
+ */
123
+ touch(id: string, ttlSeconds: number): Promise<void>;
124
+ /**
125
+ * Delete sessions whose expiration time has passed. Expired rows are
126
+ * already treated as missing (and removed) by `read`; call this from a
127
+ * scheduled job to keep the table small.
128
+ */
129
+ deleteExpired(now?: Date): Promise<void>;
130
+ private deserialize;
131
+ private expiryDate;
131
132
  }
132
-
133
+ //#endregion
134
+ //#region src/oauth-state-store.d.ts
133
135
  /**
134
136
  * Database-backed OAuth state store built on the Guren ORM.
135
137
  *
@@ -168,49 +170,49 @@ declare class DatabaseSessionStore implements SessionStore {
168
170
  * ```
169
171
  */
170
172
  declare class DatabaseOAuthStateStore implements OAuthStateStore {
171
- private readonly model;
172
- constructor(table: unknown);
173
- store(stateHash: string, payload: OAuthStatePayload): Promise<void>;
174
- find(stateHash: string): Promise<OAuthStatePayload | null>;
175
- /**
176
- * Fetch the row for `stateHash`, clearing it out and returning null if
177
- * expired. Shared by `find` and `consume`, which otherwise diverge only
178
- * in what they do with a live row.
179
- */
180
- private fetchLive;
181
- delete(stateHash: string): Promise<void>;
182
- /**
183
- * Atomically fetch and delete a state, guaranteeing exactly one concurrent
184
- * caller for the same hash receives the payload.
185
- *
186
- * This guarantee depends on the configured ORM adapter's `delete()`
187
- * reporting whether a row actually matched — either the deleted row
188
- * (RETURNING) or an affected-row count. `DrizzleAdapter`, the framework's
189
- * default and only shipped adapter, always does this: RETURNING drivers
190
- * (Postgres, SQLite, D1) resolve to the deleted row or `undefined` only
191
- * when zero rows matched; MySQL resolves to a result carrying
192
- * `affectedRows` (verified by inspection, not a dedicated test).
193
- *
194
- * The `ORMAdapter.delete` contract also permits a bare `void` return.
195
- * A custom adapter (via `Model.useAdapter()`) that returns `void`
196
- * unconditionally — on both a successful delete and a no-op — gives
197
- * `consume()` no way to tell which caller won: the value is identical for
198
- * both, so no post-hoc check can attribute the deletion. Rather than
199
- * silently rejecting every real login for such adapters,
200
- * `deleteRemovedRow` treats an unrecognized non-null result as removed —
201
- * this reopens the pre-consume find-then-delete race window (multiple
202
- * concurrent callers can pass) for adapters that can't report a match,
203
- * but does not break login. It is fail-closed (returns null / rejects)
204
- * only for `null`/`undefined`, DrizzleAdapter's definitive "no rows
205
- * matched" signal.
206
- */
207
- consume(stateHash: string): Promise<OAuthStatePayload | null>;
208
- /**
209
- * Delete OAuth states whose expiration time has passed. Expired states
210
- * are already rejected by `find`; call this from a scheduled job to keep
211
- * the table small.
212
- */
213
- deleteExpired(now?: Date): Promise<void>;
173
+ private readonly model;
174
+ constructor(table: unknown);
175
+ store(stateHash: string, payload: OAuthStatePayload): Promise<void>;
176
+ find(stateHash: string): Promise<OAuthStatePayload | null>;
177
+ /**
178
+ * Fetch the row for `stateHash`, clearing it out and returning null if
179
+ * expired. Shared by `find` and `consume`, which otherwise diverge only
180
+ * in what they do with a live row.
181
+ */
182
+ private fetchLive;
183
+ delete(stateHash: string): Promise<void>;
184
+ /**
185
+ * Atomically fetch and delete a state, guaranteeing exactly one concurrent
186
+ * caller for the same hash receives the payload.
187
+ *
188
+ * This guarantee depends on the configured ORM adapter's `delete()`
189
+ * reporting whether a row actually matched — either the deleted row
190
+ * (RETURNING) or an affected-row count. `DrizzleAdapter`, the framework's
191
+ * default and only shipped adapter, always does this: RETURNING drivers
192
+ * (Postgres, SQLite, D1) resolve to the deleted row or `undefined` only
193
+ * when zero rows matched; MySQL resolves to a result carrying
194
+ * `affectedRows` (verified by inspection, not a dedicated test).
195
+ *
196
+ * The `ORMAdapter.delete` contract also permits a bare `void` return.
197
+ * A custom adapter (via `Model.useAdapter()`) that returns `void`
198
+ * unconditionally — on both a successful delete and a no-op — gives
199
+ * `consume()` no way to tell which caller won: the value is identical for
200
+ * both, so no post-hoc check can attribute the deletion. Rather than
201
+ * silently rejecting every real login for such adapters,
202
+ * `deleteRemovedRow` treats an unrecognized non-null result as removed —
203
+ * this reopens the pre-consume find-then-delete race window (multiple
204
+ * concurrent callers can pass) for adapters that can't report a match,
205
+ * but does not break login. It is fail-closed (returns null / rejects)
206
+ * only for `null`/`undefined`, DrizzleAdapter's definitive "no rows
207
+ * matched" signal.
208
+ */
209
+ consume(stateHash: string): Promise<OAuthStatePayload | null>;
210
+ /**
211
+ * Delete OAuth states whose expiration time has passed. Expired states
212
+ * are already rejected by `find`; call this from a scheduled job to keep
213
+ * the table small.
214
+ */
215
+ deleteExpired(now?: Date): Promise<void>;
214
216
  }
215
-
216
- export { DatabaseApiTokenStore, type DatabaseApiTokenStoreOptions, DatabaseOAuthStateStore, DatabaseSessionStore, type DatabaseSessionStoreOptions };
217
+ //#endregion
218
+ export { type AccessorDefinitions, type AccessorFn, type AwsDataApiDatabase, type AwsDataApiDatabaseOptions, type AwsDataApiSeederContext, type BelongsToManyRecord, type BelongsToManyRelationResult, type BelongsToRecord, type BelongsToRelationResult, type BelongsToRequiredRecord, type CastType, type D1DatabaseHandle, type D1DatabaseOptions, DatabaseApiTokenStore, type DatabaseApiTokenStoreOptions, DatabaseOAuthStateStore, DatabaseSessionStore, type DatabaseSessionStoreOptions, DrizzleAdapter, type EagerLoadConstraint, type FindManyOptions, type GroupCondition, type HasManyRecord, type HasManyRelationResult, type HasManyThroughRecord, type HasManyThroughRelationResult, type HasOneRecord, type HasOneRelationResult, type HookCallback, type HookName, type InferModelInsert, type InferModelRecord, MassAssignmentException, type MigrationRunSummary, type MigrationStatusEntry, Model, type ModelHooks, ModelNotFoundException, type ModelObserver, type ModelObserverConstructor, type ModelPaginationMeta, type ModelQueryOptions, type MorphManyRecord, type MorphManyRelationResult, type MorphToRecord, type MorphToRelationResult, type MutatorDefinitions, type MutatorFn, type MySqlDatabase, type MySqlDatabaseOptions, type MySqlSeederContext, type ORMAdapter, type ORMAdapterAdvanced, type OrderByClause, type OrderByInput, type OrderDefinition, type OrderDirection, type PaginateOptions, type PaginatedResult, type PlainObject, type PostgresDatabase, type PostgresDatabaseOptions, type PostgresSeederContext, QueryBuilder, type QueryBuilderOptions, type ScopeFunction, type SeederContext, type SeederHandler, type SeederRunSummary, type SimpleCondition, SoftDeletes, type SoftDeletesStatic, type SqliteDatabase, type SqliteDatabaseOptions, type SqliteSeederContext, type TransactionHandle, type TransactionModelScope, type WhereClause, type WhereCondition, type WhereGroupCallback, type WhereOperator, type WithRelations, createAwsDataApiDatabase, createD1Database, createMySqlDatabase, createPostgresDatabase, createSqliteDatabase, defineModel, defineSeeder, runSeeders };