@stll/auth-model 0.2.1 → 0.2.2
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 +30 -31
- package/dist/contract.js +5 -2
- package/package.json +4 -4
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.1";
|
|
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.1";
|
|
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,7 +151,7 @@ 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 ["
|
|
154
|
+
readonly fields: readonly ["providerId", "accountId"];
|
|
155
155
|
readonly predicate: null;
|
|
156
156
|
readonly unique: true;
|
|
157
157
|
}, {
|
|
@@ -213,7 +213,7 @@ declare const BETTER_AUTH_CORE_SCHEMA: {
|
|
|
213
213
|
}];
|
|
214
214
|
};
|
|
215
215
|
};
|
|
216
|
-
type BetterAuthAdapterContract = {
|
|
216
|
+
export type BetterAuthAdapterContract = {
|
|
217
217
|
camelCase: boolean;
|
|
218
218
|
dateStorage: "timestamp-with-time-zone";
|
|
219
219
|
idGeneration: "application-string";
|
|
@@ -224,7 +224,7 @@ type BetterAuthAdapterContract = {
|
|
|
224
224
|
usePlural: boolean;
|
|
225
225
|
verificationStorage: "database";
|
|
226
226
|
};
|
|
227
|
-
declare const BETTER_AUTH_ADAPTER_INVARIANTS: {
|
|
227
|
+
export declare const BETTER_AUTH_ADAPTER_INVARIANTS: {
|
|
228
228
|
readonly dateStorage: "timestamp-with-time-zone";
|
|
229
229
|
readonly idGeneration: "application-string";
|
|
230
230
|
readonly sessionStorage: "database";
|
|
@@ -243,21 +243,21 @@ declare const BETTER_AUTH_ADAPTER_INVARIANTS: {
|
|
|
243
243
|
readonly transaction: true;
|
|
244
244
|
readonly usePlural: false;
|
|
245
245
|
};
|
|
246
|
-
type BetterAuthSchemaCandidate = {
|
|
246
|
+
export type BetterAuthSchemaCandidate = {
|
|
247
247
|
adapter: BetterAuthAdapterContract;
|
|
248
248
|
models: Record<string, BetterAuthModelContract>;
|
|
249
249
|
};
|
|
250
|
-
type BetterAuthSchemaExtensions = {
|
|
250
|
+
export type BetterAuthSchemaExtensions = {
|
|
251
251
|
fields?: Partial<Record<BetterAuthCoreModelName, Record<string, BetterAuthFieldContract>>>;
|
|
252
252
|
indexes?: Partial<Record<BetterAuthCoreModelName, readonly BetterAuthIndexContract[]>>;
|
|
253
253
|
models?: readonly string[];
|
|
254
254
|
};
|
|
255
|
-
type BetterAuthSchemaParityIssue = {
|
|
255
|
+
export type BetterAuthSchemaParityIssue = {
|
|
256
256
|
actual: unknown;
|
|
257
257
|
expected: unknown;
|
|
258
258
|
path: string;
|
|
259
259
|
};
|
|
260
|
-
type BetterAuthSchemaParityResult = {
|
|
260
|
+
export type BetterAuthSchemaParityResult = {
|
|
261
261
|
status: "compatible";
|
|
262
262
|
} | {
|
|
263
263
|
issues: BetterAuthSchemaParityIssue[];
|
|
@@ -267,8 +267,8 @@ type BetterAuthSchemaParityResult = {
|
|
|
267
267
|
* Compares a normalized host schema with the complete shared core. Extensions
|
|
268
268
|
* are exact allowlists: missing, stale, and undeclared additions all fail.
|
|
269
269
|
*/
|
|
270
|
-
declare const compareBetterAuthSchema: (candidate: BetterAuthSchemaCandidate, extensions?: BetterAuthSchemaExtensions) => BetterAuthSchemaParityResult;
|
|
271
|
-
declare const BETTER_AUTH_PARITY_MANIFEST: {
|
|
270
|
+
export declare const compareBetterAuthSchema: (candidate: BetterAuthSchemaCandidate, extensions?: BetterAuthSchemaExtensions) => BetterAuthSchemaParityResult;
|
|
271
|
+
export declare const BETTER_AUTH_PARITY_MANIFEST: {
|
|
272
272
|
readonly adapterInvariants: {
|
|
273
273
|
readonly dateStorage: "timestamp-with-time-zone";
|
|
274
274
|
readonly idGeneration: "application-string";
|
|
@@ -357,7 +357,7 @@ declare const BETTER_AUTH_PARITY_MANIFEST: {
|
|
|
357
357
|
readonly primaryKey: readonly ["id"];
|
|
358
358
|
readonly fields: Record<string, BetterAuthFieldContract>;
|
|
359
359
|
readonly indexes: readonly [{
|
|
360
|
-
readonly fields: readonly ["
|
|
360
|
+
readonly fields: readonly ["providerId", "accountId"];
|
|
361
361
|
readonly predicate: null;
|
|
362
362
|
readonly unique: true;
|
|
363
363
|
}, {
|
|
@@ -420,5 +420,4 @@ declare const BETTER_AUTH_PARITY_MANIFEST: {
|
|
|
420
420
|
};
|
|
421
421
|
};
|
|
422
422
|
};
|
|
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 };
|
|
423
|
+
//#endregion
|
package/dist/contract.js
CHANGED
|
@@ -278,7 +278,10 @@ const BETTER_AUTH_CORE_SCHEMA = {
|
|
|
278
278
|
primaryKey: ["id"],
|
|
279
279
|
fields: withPhysicalNames({
|
|
280
280
|
id: idField,
|
|
281
|
-
issuer: field("string", {
|
|
281
|
+
issuer: field("string", {
|
|
282
|
+
database: { notNull: false },
|
|
283
|
+
required: true
|
|
284
|
+
}),
|
|
282
285
|
accountId: field("string", { required: true }),
|
|
283
286
|
providerId: field("string", { required: true }),
|
|
284
287
|
userId: field("string", {
|
|
@@ -297,7 +300,7 @@ const BETTER_AUTH_CORE_SCHEMA = {
|
|
|
297
300
|
updatedAt: updatedDate
|
|
298
301
|
}),
|
|
299
302
|
indexes: [{
|
|
300
|
-
fields: ["
|
|
303
|
+
fields: ["providerId", "accountId"],
|
|
301
304
|
predicate: null,
|
|
302
305
|
unique: true
|
|
303
306
|
}, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/auth-model",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
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
50
|
"better-auth": "1.7.1",
|
|
51
|
-
"bun-types": "1.4.
|
|
52
|
-
"tsdown": "0.
|
|
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"
|