@guren/core 1.8.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 +1 -5
- package/dist/bin.js +1 -2
- package/dist/index.d.ts +113 -111
- package/dist/index.js +342 -287
- package/dist/internal/deploy-build.d.ts +71 -70
- package/dist/internal/deploy-build.js +467 -209
- package/dist/internal/zod-compat.d.ts +12 -11
- package/dist/internal/zod-compat.js +112 -60
- package/dist/lambda.d.ts +2 -1
- package/dist/lambda.js +2 -17
- package/dist/redis.d.ts +2 -1
- package/dist/redis.js +2 -23
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +1 -1
- package/dist/vite.d.ts +3 -2
- package/dist/vite.js +2 -5
- package/package.json +11 -7
package/dist/bin.d.ts
CHANGED
package/dist/bin.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { ApiTokenStore,
|
|
2
|
-
|
|
3
|
-
export
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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 };
|