@midsummer-ai/sdk 0.1.0-staging.3608 → 0.1.0-staging.3620
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/auth/client.d.mts +23 -0
- package/auth/client.mjs +45 -0
- package/auth/contract.d.mts +24 -0
- package/auth/contract.mjs +498 -0
- package/auth/files.d.mts +28 -0
- package/auth/files.mjs +231 -0
- package/auth/index.d.mts +199 -0
- package/auth/index.mjs +3 -0
- package/auth/key.d.mts +19 -0
- package/auth/key.mjs +28 -0
- package/auth/mail.d.mts +31 -0
- package/auth/mail.mjs +138 -0
- package/auth/password.d.mts +2 -0
- package/auth/password.mjs +2 -0
- package/auth/stand-in.d.mts +15 -0
- package/auth/stand-in.mjs +41 -0
- package/auth-BM6vB3XD.mjs +754 -0
- package/billing/index.d.mts +6 -3
- package/billing/index.mjs +2 -1
- package/client-BshDU1b2.d.mts +155 -0
- package/{connection-C_JSWUrt.mjs → client-C7QtAX5u.mjs} +668 -3
- package/database/client.d.mts +1 -153
- package/database/client.mjs +1 -665
- package/database/react.d.mts +1 -1
- package/database/stand-in.d.mts +1 -1
- package/package.json +62 -1
- package/{store-CsBhnabU.mjs → store-dsVD9VnM.mjs} +1 -1
- package/store-gCz6XVaG.d.mts +15 -0
- package/{tabs-gHJHkhm2.mjs → tabs-C85sXTwS.mjs} +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { t as AuthStore } from "../store-gCz6XVaG.mjs";
|
|
2
|
+
import { SignInMail } from "./mail.mjs";
|
|
3
|
+
//#region src/auth/stand-in.d.ts
|
|
4
|
+
interface StandIn {
|
|
5
|
+
readonly store: AuthStore;
|
|
6
|
+
readonly mail: (mail: SignInMail) => Promise<void>;
|
|
7
|
+
readonly outbox: ReadonlyArray<SignInMail>;
|
|
8
|
+
/** How many calls reached the rows, of any kind. */
|
|
9
|
+
calls(): number;
|
|
10
|
+
/** The rows of a table, as kept. */
|
|
11
|
+
rows(table: string): ReadonlyArray<Record<string, unknown>>;
|
|
12
|
+
}
|
|
13
|
+
declare function standIn(): StandIn;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { StandIn, standIn };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { memoryAdapter } from "better-auth/adapters/memory";
|
|
2
|
+
import { getAuthTables } from "better-auth/db";
|
|
3
|
+
//#region src/auth/stand-in.ts
|
|
4
|
+
/**
|
|
5
|
+
* Sign-in's Stand-in: its rows in memory and its mail kept, for `midsummer dev` without a database and for
|
|
6
|
+
* tests. It is better-auth's own memory store, so sign-in behaves as it does over the Project's Database,
|
|
7
|
+
* and passes the contract (`@midsummer-ai/sdk/auth/contract`) except durability.
|
|
8
|
+
*
|
|
9
|
+
* const stand = standIn()
|
|
10
|
+
* const auth = createAuth({ store: stand.store, mail: stand.mail })
|
|
11
|
+
* stand.outbox // every sign-in mail, newest last
|
|
12
|
+
* stand.reads() // how many reads and writes reached the rows
|
|
13
|
+
*/
|
|
14
|
+
function standIn() {
|
|
15
|
+
const tables = {};
|
|
16
|
+
const outbox = [];
|
|
17
|
+
let count = 0;
|
|
18
|
+
const counted = (store) => new Proxy(store, { get(target, key, receiver) {
|
|
19
|
+
const value = Reflect.get(target, key, receiver);
|
|
20
|
+
if (typeof value !== "function" || key === "transaction" || key === "createSchema") return value;
|
|
21
|
+
return (...args) => {
|
|
22
|
+
count++;
|
|
23
|
+
return value.apply(target, args);
|
|
24
|
+
};
|
|
25
|
+
} });
|
|
26
|
+
const memory = memoryAdapter(tables);
|
|
27
|
+
return {
|
|
28
|
+
store: ((options) => {
|
|
29
|
+
for (const table of Object.values(getAuthTables(options))) tables[table.modelName] ??= [];
|
|
30
|
+
return counted(memory(options));
|
|
31
|
+
}),
|
|
32
|
+
mail: async (mail) => {
|
|
33
|
+
outbox.push(mail);
|
|
34
|
+
},
|
|
35
|
+
outbox,
|
|
36
|
+
calls: () => count,
|
|
37
|
+
rows: (table) => tables[table] ?? []
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { standIn };
|