@stll/auth-model 0.2.1 → 0.2.3
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/contract.d.ts +29 -38
- package/dist/contract.js +1 -6
- package/package.json +5 -5
package/dist/contract.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
//#region src/contract.d.ts
|
|
2
2
|
/** Better Auth version whose logical schema this contract describes. */
|
|
3
|
-
declare const BETTER_AUTH_CONTRACT_VERSION = "1.7.
|
|
4
|
-
declare const ORGANIZATION_ROLE_NAMES: readonly ["owner", "admin", "member", "intern", "external"];
|
|
5
|
-
type OrganizationRoleName = (typeof ORGANIZATION_ROLE_NAMES)[number];
|
|
3
|
+
export declare const BETTER_AUTH_CONTRACT_VERSION = "1.7.4";
|
|
4
|
+
export declare const ORGANIZATION_ROLE_NAMES: readonly ["owner", "admin", "member", "intern", "external"];
|
|
5
|
+
export type OrganizationRoleName = (typeof ORGANIZATION_ROLE_NAMES)[number];
|
|
6
6
|
/** Better Auth organization resources. Hosts extend this with product grants. */
|
|
7
|
-
declare const BETTER_AUTH_ORGANIZATION_STATEMENTS: {
|
|
7
|
+
export declare const BETTER_AUTH_ORGANIZATION_STATEMENTS: {
|
|
8
8
|
readonly organization: readonly ["update", "delete"];
|
|
9
9
|
readonly member: readonly ["create", "update", "delete"];
|
|
10
10
|
readonly invitation: readonly ["create", "cancel"];
|
|
@@ -12,9 +12,9 @@ declare const BETTER_AUTH_ORGANIZATION_STATEMENTS: {
|
|
|
12
12
|
readonly ac: readonly ["create", "read", "update", "delete"];
|
|
13
13
|
};
|
|
14
14
|
type OrganizationPermissionMap = { [Resource in keyof typeof BETTER_AUTH_ORGANIZATION_STATEMENTS]: (typeof BETTER_AUTH_ORGANIZATION_STATEMENTS)[Resource][number][]; };
|
|
15
|
-
type BetterAuthOrganizationRoleGrants = Record<OrganizationRoleName, OrganizationPermissionMap>;
|
|
15
|
+
export type BetterAuthOrganizationRoleGrants = Record<OrganizationRoleName, OrganizationPermissionMap>;
|
|
16
16
|
/** Core grants shared by every application; product grants remain host-owned. */
|
|
17
|
-
declare const BETTER_AUTH_ORGANIZATION_ROLE_GRANTS: {
|
|
17
|
+
export declare const BETTER_AUTH_ORGANIZATION_ROLE_GRANTS: {
|
|
18
18
|
owner: {
|
|
19
19
|
organization: ("update" | "delete")[];
|
|
20
20
|
member: ("update" | "delete" | "create")[];
|
|
@@ -55,7 +55,7 @@ declare const BETTER_AUTH_ORGANIZATION_ROLE_GRANTS: {
|
|
|
55
55
|
* Values that change Better Auth's organization authorization semantics.
|
|
56
56
|
* Hooks, adapters, email delivery, and product-specific options stay local.
|
|
57
57
|
*/
|
|
58
|
-
declare const BETTER_AUTH_ORGANIZATION_OPTIONS: {
|
|
58
|
+
export declare const BETTER_AUTH_ORGANIZATION_OPTIONS: {
|
|
59
59
|
readonly allowUserToCreateOrganization: true;
|
|
60
60
|
readonly cancelPendingInvitationsOnReInvite: false;
|
|
61
61
|
readonly creatorRole: "owner";
|
|
@@ -64,16 +64,16 @@ declare const BETTER_AUTH_ORGANIZATION_OPTIONS: {
|
|
|
64
64
|
readonly requireEmailVerificationOnInvitation: true;
|
|
65
65
|
};
|
|
66
66
|
/** Adapter switches which must match in every host. */
|
|
67
|
-
declare const BETTER_AUTH_ADAPTER_OPTIONS: {
|
|
67
|
+
export declare const BETTER_AUTH_ADAPTER_OPTIONS: {
|
|
68
68
|
readonly camelCase: false;
|
|
69
69
|
readonly provider: "pg";
|
|
70
70
|
readonly transaction: true;
|
|
71
71
|
readonly usePlural: false;
|
|
72
72
|
};
|
|
73
|
-
declare const BETTER_AUTH_CORE_MODEL_NAMES: readonly ["user", "session", "account", "verification", "organization", "member", "invitation"];
|
|
74
|
-
type BetterAuthCoreModelName = (typeof BETTER_AUTH_CORE_MODEL_NAMES)[number];
|
|
75
|
-
type BetterAuthFieldType = "boolean" | "date" | "string";
|
|
76
|
-
type BetterAuthFieldDefault = {
|
|
73
|
+
export declare const BETTER_AUTH_CORE_MODEL_NAMES: readonly ["user", "session", "account", "verification", "organization", "member", "invitation"];
|
|
74
|
+
export type BetterAuthCoreModelName = (typeof BETTER_AUTH_CORE_MODEL_NAMES)[number];
|
|
75
|
+
export type BetterAuthFieldType = "boolean" | "date" | "string";
|
|
76
|
+
export type BetterAuthFieldDefault = {
|
|
77
77
|
kind: "none";
|
|
78
78
|
} | {
|
|
79
79
|
kind: "runtime";
|
|
@@ -81,12 +81,12 @@ type BetterAuthFieldDefault = {
|
|
|
81
81
|
kind: "literal";
|
|
82
82
|
value: boolean | number | string;
|
|
83
83
|
};
|
|
84
|
-
type BetterAuthFieldReference = {
|
|
84
|
+
export type BetterAuthFieldReference = {
|
|
85
85
|
field: "id";
|
|
86
86
|
model: "organization" | "user";
|
|
87
87
|
onDelete: "cascade" | null;
|
|
88
88
|
};
|
|
89
|
-
type BetterAuthLogicalFieldContract = {
|
|
89
|
+
export type BetterAuthLogicalFieldContract = {
|
|
90
90
|
default: BetterAuthFieldDefault;
|
|
91
91
|
indexed: boolean;
|
|
92
92
|
input: "allowed" | "server-managed";
|
|
@@ -98,7 +98,7 @@ type BetterAuthLogicalFieldContract = {
|
|
|
98
98
|
type: BetterAuthFieldType;
|
|
99
99
|
unique: boolean;
|
|
100
100
|
};
|
|
101
|
-
type BetterAuthDatabaseFieldContract = {
|
|
101
|
+
export type BetterAuthDatabaseFieldContract = {
|
|
102
102
|
columnName: string;
|
|
103
103
|
columnType: "boolean" | "text" | "timestamptz";
|
|
104
104
|
default: BetterAuthFieldDefault;
|
|
@@ -110,16 +110,16 @@ type BetterAuthDatabaseFieldContract = {
|
|
|
110
110
|
unique: boolean;
|
|
111
111
|
};
|
|
112
112
|
/** Better Auth behavior and physical database guarantees, kept separate. */
|
|
113
|
-
type BetterAuthFieldContract = {
|
|
113
|
+
export type BetterAuthFieldContract = {
|
|
114
114
|
database: BetterAuthDatabaseFieldContract;
|
|
115
115
|
logical: BetterAuthLogicalFieldContract;
|
|
116
116
|
};
|
|
117
|
-
type BetterAuthIndexContract = {
|
|
117
|
+
export type BetterAuthIndexContract = {
|
|
118
118
|
fields: readonly string[];
|
|
119
119
|
predicate: string | null;
|
|
120
120
|
unique: boolean;
|
|
121
121
|
};
|
|
122
|
-
type BetterAuthModelContract = {
|
|
122
|
+
export type BetterAuthModelContract = {
|
|
123
123
|
fields: Record<string, BetterAuthFieldContract>;
|
|
124
124
|
indexes: readonly BetterAuthIndexContract[];
|
|
125
125
|
primaryKey: readonly string[];
|
|
@@ -129,7 +129,7 @@ type BetterAuthModelContract = {
|
|
|
129
129
|
* Normalized Better Auth core plus the organization plugin's shared models and
|
|
130
130
|
* `activeOrganizationId` session extension.
|
|
131
131
|
*/
|
|
132
|
-
declare const BETTER_AUTH_CORE_SCHEMA: {
|
|
132
|
+
export declare const BETTER_AUTH_CORE_SCHEMA: {
|
|
133
133
|
readonly user: {
|
|
134
134
|
readonly tableName: "user";
|
|
135
135
|
readonly primaryKey: readonly ["id"];
|
|
@@ -151,10 +151,6 @@ declare const BETTER_AUTH_CORE_SCHEMA: {
|
|
|
151
151
|
readonly primaryKey: readonly ["id"];
|
|
152
152
|
readonly fields: Record<string, BetterAuthFieldContract>;
|
|
153
153
|
readonly indexes: readonly [{
|
|
154
|
-
readonly fields: readonly ["issuer", "accountId"];
|
|
155
|
-
readonly predicate: null;
|
|
156
|
-
readonly unique: true;
|
|
157
|
-
}, {
|
|
158
154
|
readonly fields: readonly ["userId"];
|
|
159
155
|
readonly predicate: null;
|
|
160
156
|
readonly unique: false;
|
|
@@ -213,7 +209,7 @@ declare const BETTER_AUTH_CORE_SCHEMA: {
|
|
|
213
209
|
}];
|
|
214
210
|
};
|
|
215
211
|
};
|
|
216
|
-
type BetterAuthAdapterContract = {
|
|
212
|
+
export type BetterAuthAdapterContract = {
|
|
217
213
|
camelCase: boolean;
|
|
218
214
|
dateStorage: "timestamp-with-time-zone";
|
|
219
215
|
idGeneration: "application-string";
|
|
@@ -224,7 +220,7 @@ type BetterAuthAdapterContract = {
|
|
|
224
220
|
usePlural: boolean;
|
|
225
221
|
verificationStorage: "database";
|
|
226
222
|
};
|
|
227
|
-
declare const BETTER_AUTH_ADAPTER_INVARIANTS: {
|
|
223
|
+
export declare const BETTER_AUTH_ADAPTER_INVARIANTS: {
|
|
228
224
|
readonly dateStorage: "timestamp-with-time-zone";
|
|
229
225
|
readonly idGeneration: "application-string";
|
|
230
226
|
readonly sessionStorage: "database";
|
|
@@ -243,21 +239,21 @@ declare const BETTER_AUTH_ADAPTER_INVARIANTS: {
|
|
|
243
239
|
readonly transaction: true;
|
|
244
240
|
readonly usePlural: false;
|
|
245
241
|
};
|
|
246
|
-
type BetterAuthSchemaCandidate = {
|
|
242
|
+
export type BetterAuthSchemaCandidate = {
|
|
247
243
|
adapter: BetterAuthAdapterContract;
|
|
248
244
|
models: Record<string, BetterAuthModelContract>;
|
|
249
245
|
};
|
|
250
|
-
type BetterAuthSchemaExtensions = {
|
|
246
|
+
export type BetterAuthSchemaExtensions = {
|
|
251
247
|
fields?: Partial<Record<BetterAuthCoreModelName, Record<string, BetterAuthFieldContract>>>;
|
|
252
248
|
indexes?: Partial<Record<BetterAuthCoreModelName, readonly BetterAuthIndexContract[]>>;
|
|
253
249
|
models?: readonly string[];
|
|
254
250
|
};
|
|
255
|
-
type BetterAuthSchemaParityIssue = {
|
|
251
|
+
export type BetterAuthSchemaParityIssue = {
|
|
256
252
|
actual: unknown;
|
|
257
253
|
expected: unknown;
|
|
258
254
|
path: string;
|
|
259
255
|
};
|
|
260
|
-
type BetterAuthSchemaParityResult = {
|
|
256
|
+
export type BetterAuthSchemaParityResult = {
|
|
261
257
|
status: "compatible";
|
|
262
258
|
} | {
|
|
263
259
|
issues: BetterAuthSchemaParityIssue[];
|
|
@@ -267,8 +263,8 @@ type BetterAuthSchemaParityResult = {
|
|
|
267
263
|
* Compares a normalized host schema with the complete shared core. Extensions
|
|
268
264
|
* are exact allowlists: missing, stale, and undeclared additions all fail.
|
|
269
265
|
*/
|
|
270
|
-
declare const compareBetterAuthSchema: (candidate: BetterAuthSchemaCandidate, extensions?: BetterAuthSchemaExtensions) => BetterAuthSchemaParityResult;
|
|
271
|
-
declare const BETTER_AUTH_PARITY_MANIFEST: {
|
|
266
|
+
export declare const compareBetterAuthSchema: (candidate: BetterAuthSchemaCandidate, extensions?: BetterAuthSchemaExtensions) => BetterAuthSchemaParityResult;
|
|
267
|
+
export declare const BETTER_AUTH_PARITY_MANIFEST: {
|
|
272
268
|
readonly adapterInvariants: {
|
|
273
269
|
readonly dateStorage: "timestamp-with-time-zone";
|
|
274
270
|
readonly idGeneration: "application-string";
|
|
@@ -288,7 +284,7 @@ declare const BETTER_AUTH_PARITY_MANIFEST: {
|
|
|
288
284
|
readonly transaction: true;
|
|
289
285
|
readonly usePlural: false;
|
|
290
286
|
};
|
|
291
|
-
readonly betterAuthVersion: "1.7.
|
|
287
|
+
readonly betterAuthVersion: "1.7.4";
|
|
292
288
|
readonly options: {
|
|
293
289
|
readonly allowUserToCreateOrganization: true;
|
|
294
290
|
readonly cancelPendingInvitationsOnReInvite: false;
|
|
@@ -357,10 +353,6 @@ declare const BETTER_AUTH_PARITY_MANIFEST: {
|
|
|
357
353
|
readonly primaryKey: readonly ["id"];
|
|
358
354
|
readonly fields: Record<string, BetterAuthFieldContract>;
|
|
359
355
|
readonly indexes: readonly [{
|
|
360
|
-
readonly fields: readonly ["issuer", "accountId"];
|
|
361
|
-
readonly predicate: null;
|
|
362
|
-
readonly unique: true;
|
|
363
|
-
}, {
|
|
364
356
|
readonly fields: readonly ["userId"];
|
|
365
357
|
readonly predicate: null;
|
|
366
358
|
readonly unique: false;
|
|
@@ -420,5 +412,4 @@ declare const BETTER_AUTH_PARITY_MANIFEST: {
|
|
|
420
412
|
};
|
|
421
413
|
};
|
|
422
414
|
};
|
|
423
|
-
//#endregion
|
|
424
|
-
export { BETTER_AUTH_ADAPTER_INVARIANTS, BETTER_AUTH_ADAPTER_OPTIONS, BETTER_AUTH_CONTRACT_VERSION, BETTER_AUTH_CORE_MODEL_NAMES, BETTER_AUTH_CORE_SCHEMA, BETTER_AUTH_ORGANIZATION_OPTIONS, BETTER_AUTH_ORGANIZATION_ROLE_GRANTS, BETTER_AUTH_ORGANIZATION_STATEMENTS, BETTER_AUTH_PARITY_MANIFEST, BetterAuthAdapterContract, BetterAuthCoreModelName, BetterAuthDatabaseFieldContract, BetterAuthFieldContract, BetterAuthFieldDefault, BetterAuthFieldReference, BetterAuthFieldType, BetterAuthIndexContract, BetterAuthLogicalFieldContract, BetterAuthModelContract, BetterAuthOrganizationRoleGrants, BetterAuthSchemaCandidate, BetterAuthSchemaExtensions, BetterAuthSchemaParityIssue, BetterAuthSchemaParityResult, ORGANIZATION_ROLE_NAMES, OrganizationRoleName, compareBetterAuthSchema };
|
|
415
|
+
//#endregion
|
package/dist/contract.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/contract.ts
|
|
2
2
|
/** Better Auth version whose logical schema this contract describes. */
|
|
3
|
-
const BETTER_AUTH_CONTRACT_VERSION = "1.7.
|
|
3
|
+
const BETTER_AUTH_CONTRACT_VERSION = "1.7.4";
|
|
4
4
|
const ORGANIZATION_ROLE_NAMES = [
|
|
5
5
|
"owner",
|
|
6
6
|
"admin",
|
|
@@ -278,7 +278,6 @@ const BETTER_AUTH_CORE_SCHEMA = {
|
|
|
278
278
|
primaryKey: ["id"],
|
|
279
279
|
fields: withPhysicalNames({
|
|
280
280
|
id: idField,
|
|
281
|
-
issuer: field("string", { required: true }),
|
|
282
281
|
accountId: field("string", { required: true }),
|
|
283
282
|
providerId: field("string", { required: true }),
|
|
284
283
|
userId: field("string", {
|
|
@@ -297,10 +296,6 @@ const BETTER_AUTH_CORE_SCHEMA = {
|
|
|
297
296
|
updatedAt: updatedDate
|
|
298
297
|
}),
|
|
299
298
|
indexes: [{
|
|
300
|
-
fields: ["issuer", "accountId"],
|
|
301
|
-
predicate: null,
|
|
302
|
-
unique: true
|
|
303
|
-
}, {
|
|
304
299
|
fields: ["userId"],
|
|
305
300
|
predicate: null,
|
|
306
301
|
unique: false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/auth-model",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Portable Better Auth core contract and parity checks.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"authentication",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"typecheck": "bun ../../packages/scripts/src/tsc-native.ts --noEmit",
|
|
43
43
|
"lint": "cd ../.. && bun --bun oxlint -c oxlint.config.ts --report-unused-disable-directives-severity=error --deny-warnings --type-aware packages/auth-model",
|
|
44
44
|
"lint:fix": "cd ../.. && bun --bun oxlint -c oxlint.config.ts --type-aware --fix packages/auth-model",
|
|
45
|
-
"format": "oxfmt .",
|
|
45
|
+
"format": "bun ../../scripts/run-oxfmt.ts .",
|
|
46
46
|
"prepack": "bun run build"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@stll/typescript-config": "0.0.0",
|
|
50
|
-
"better-auth": "1.7.
|
|
51
|
-
"bun-types": "1.4.
|
|
52
|
-
"tsdown": "0.
|
|
50
|
+
"better-auth": "1.7.4",
|
|
51
|
+
"bun-types": "1.4.2",
|
|
52
|
+
"tsdown": "0.23.0"
|
|
53
53
|
},
|
|
54
54
|
"main": "./dist/contract.js",
|
|
55
55
|
"types": "./dist/contract.d.ts"
|