@gettersethya/mira-client 0.1.0-alpha.3 → 0.1.0-alpha.31
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/README.md +20 -9
- package/dist/src/client/auth.d.ts +46 -14
- package/dist/src/client/auth.d.ts.map +1 -1
- package/dist/src/client/auth.js +47 -7
- package/dist/src/client/auth.js.map +1 -1
- package/dist/src/client/collection.d.ts +196 -21
- package/dist/src/client/collection.d.ts.map +1 -1
- package/dist/src/client/collection.js +45 -9
- package/dist/src/client/collection.js.map +1 -1
- package/dist/src/client/factory.d.ts +37 -15
- package/dist/src/client/factory.d.ts.map +1 -1
- package/dist/src/client/factory.js +42 -17
- package/dist/src/client/factory.js.map +1 -1
- package/dist/src/client/file.d.ts +2 -2
- package/dist/src/client/file.d.ts.map +1 -1
- package/dist/src/client/file.js +1 -1
- package/dist/src/client/file.js.map +1 -1
- package/dist/src/client/handler.d.ts +1 -1
- package/dist/src/client/handler.d.ts.map +1 -1
- package/dist/src/client/handler.js +3 -3
- package/dist/src/client/handler.js.map +1 -1
- package/dist/src/client/index.d.ts +10 -8
- package/dist/src/client/index.d.ts.map +1 -1
- package/dist/src/client/index.js +4 -3
- package/dist/src/client/index.js.map +1 -1
- package/dist/src/client/telemetry.d.ts +81 -0
- package/dist/src/client/telemetry.d.ts.map +1 -0
- package/dist/src/client/telemetry.js +34 -0
- package/dist/src/client/telemetry.js.map +1 -0
- package/dist/src/client/types.d.ts +2 -118
- package/dist/src/client/types.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/tests/client/auth.test.js +66 -3
- package/dist/tests/client/auth.test.js.map +1 -1
- package/dist/tests/client/collection.test.js +160 -14
- package/dist/tests/client/collection.test.js.map +1 -1
- package/dist/tests/client/factory.test.d.ts +2 -0
- package/dist/tests/client/factory.test.d.ts.map +1 -0
- package/dist/tests/client/factory.test.js +48 -0
- package/dist/tests/client/factory.test.js.map +1 -0
- package/dist/tests/client/handler.test.js +3 -3
- package/dist/tests/client/handler.test.js.map +1 -1
- package/dist/tests/client/select.test.d.ts +2 -0
- package/dist/tests/client/select.test.d.ts.map +1 -0
- package/dist/tests/client/select.test.js +165 -0
- package/dist/tests/client/select.test.js.map +1 -0
- package/dist/tests/client/session-restore.test.d.ts +2 -0
- package/dist/tests/client/session-restore.test.d.ts.map +1 -0
- package/dist/tests/client/session-restore.test.js +96 -0
- package/dist/tests/client/session-restore.test.js.map +1 -0
- package/dist/tests/client/telemetry.test.d.ts +2 -0
- package/dist/tests/client/telemetry.test.d.ts.map +1 -0
- package/dist/tests/client/telemetry.test.js +30 -0
- package/dist/tests/client/telemetry.test.js.map +1 -0
- package/dist/tests/client/types.test.js +26 -3
- package/dist/tests/client/types.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @gettersethya/mira-client
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@gettersethya/mira-client)
|
|
4
|
+
|
|
3
5
|
> **Early pre-alpha.** Breaking changes may occur without notice.
|
|
4
6
|
|
|
5
7
|
Type-safe client SDK for [Mira](https://github.com/gettersethya/mira). Works in the browser and Node.js (SSR). Every operation returns a handler with both a Promise interface (`.raw()`) and an Effect interface (`.toEffect()`).
|
|
@@ -67,7 +69,7 @@ const post = await mira.posts.create().raw({
|
|
|
67
69
|
})
|
|
68
70
|
|
|
69
71
|
// Update
|
|
70
|
-
const updated = await mira.posts.update().raw(
|
|
72
|
+
const updated = await mira.posts.update().raw({ id: "post-id", data: { title: "Updated" } })
|
|
71
73
|
|
|
72
74
|
// Delete
|
|
73
75
|
await mira.posts.delete().raw("post-id")
|
|
@@ -76,20 +78,26 @@ await mira.posts.delete().raw("post-id")
|
|
|
76
78
|
## Authentication
|
|
77
79
|
|
|
78
80
|
```typescript
|
|
79
|
-
// Login —
|
|
81
|
+
// Login — the server sets an HttpOnly cookie (browser) or returns a token (server)
|
|
80
82
|
const { token, record } = await mira.users.authWithPassword().raw({
|
|
81
83
|
email: "user@example.com",
|
|
82
84
|
password: "password123",
|
|
83
85
|
})
|
|
84
86
|
|
|
85
|
-
//
|
|
86
|
-
mira.auth.
|
|
87
|
+
// Browser: restore session state from the persisted cookie on app startup
|
|
88
|
+
await mira.auth.refresh() // hits GET /api/auth/me
|
|
89
|
+
mira.auth.isLoggedIn() // boolean — synchronous, reflects last known state
|
|
90
|
+
mira.auth.clear() // POST /api/auth/logout, then resets the flag
|
|
87
91
|
|
|
88
|
-
//
|
|
89
|
-
mira.
|
|
92
|
+
// Fetch the current user for a specific auth collection (unwraps the envelope)
|
|
93
|
+
const me = await mira.users.me().raw()
|
|
94
|
+
// → InferRecord<typeof Users.fields>; rejects with 401 if the token is for another collection
|
|
90
95
|
|
|
91
|
-
//
|
|
92
|
-
mira.auth.
|
|
96
|
+
// Server: manage the token manually
|
|
97
|
+
mira.auth.setToken(token)
|
|
98
|
+
mira.auth.token // string | null
|
|
99
|
+
mira.auth.isValid() // boolean — checks the JWT exp claim
|
|
100
|
+
mira.auth.clear()
|
|
93
101
|
```
|
|
94
102
|
|
|
95
103
|
## Effect-based usage
|
|
@@ -128,8 +136,11 @@ const url = `${buildFileUrl("posts", postId, "thumb.png")}?token=${fileToken}`
|
|
|
128
136
|
|
|
129
137
|
## Type inference
|
|
130
138
|
|
|
139
|
+
These types now live in `@gettersethya/mira-collection` and are re-exported here for convenience.
|
|
140
|
+
|
|
131
141
|
```typescript
|
|
132
|
-
import type { InferRecord, InferCreateInput } from "@gettersethya/mira-
|
|
142
|
+
import type { InferRecord, InferCreateInput } from "@gettersethya/mira-collection"
|
|
143
|
+
// ...or import them from "@gettersethya/mira-client"
|
|
133
144
|
|
|
134
145
|
type Post = InferRecord<typeof Posts> // full record with system fields
|
|
135
146
|
type NewPost = InferCreateInput<typeof Posts> // creation input, no system fields
|
|
@@ -1,28 +1,53 @@
|
|
|
1
|
-
import type { HttpClient } from "@effect/platform";
|
|
2
1
|
import { Effect, MutableRef } from "effect";
|
|
2
|
+
import type { HttpClient } from "effect/http";
|
|
3
3
|
import type { MiraError } from "./errors.js";
|
|
4
4
|
import type { ClientHandler, ExecuteFn } from "./handler.js";
|
|
5
5
|
/**
|
|
6
|
-
* Browser-side authentication helper.
|
|
7
|
-
* the client has authenticated.
|
|
6
|
+
* Browser-side authentication helper.
|
|
8
7
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* The server sets an HttpOnly cookie (`mira_token`) on successful login. The
|
|
9
|
+
* browser sends it automatically on every same-origin request — the client
|
|
10
|
+
* never reads or writes it directly.
|
|
12
11
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* Because the cookie is HttpOnly, the client cannot tell on page load whether
|
|
13
|
+
* a session exists. Use `ensureSession()` (or `refresh()`) to re-validate the
|
|
14
|
+
* cookie against the server and restore `isLoggedIn()` state.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* // user is authenticated
|
|
19
|
-
* }
|
|
20
|
-
* mira.auth.clear() // sends POST /api/auth/logout
|
|
16
|
+
* `clear()` calls `POST /api/auth/logout` to clear the cookie server-side,
|
|
17
|
+
* then resets the in-memory login flag.
|
|
21
18
|
*
|
|
22
19
|
* @see ServerAuth — server-side alternative for SSR environments
|
|
23
20
|
*/
|
|
24
21
|
export type BrowserAuth = {
|
|
22
|
+
/** True if the user logged in during this page session or a session check confirmed a valid cookie. */
|
|
25
23
|
isLoggedIn(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Calls `GET /api/auth/me` to check whether a valid `mira_token` cookie exists.
|
|
26
|
+
* Sets the in-memory login flag to match the server's answer.
|
|
27
|
+
* Call this once on app startup to restore login state after a page reload.
|
|
28
|
+
*
|
|
29
|
+
* Always performs a fresh request (does not dedupe). Prefer `ensureSession()`
|
|
30
|
+
* in route guards so multiple guards share a single request per page load.
|
|
31
|
+
*
|
|
32
|
+
* @returns true if a valid session exists, false otherwise
|
|
33
|
+
*/
|
|
34
|
+
refresh(): Promise<boolean>;
|
|
35
|
+
/**
|
|
36
|
+
* Like `refresh()`, but memoized per page load: the first call issues a
|
|
37
|
+
* single `GET /api/auth/me` and every subsequent call returns the same
|
|
38
|
+
* in-flight/recently-resolved promise. Safe to call from many async route
|
|
39
|
+
* guards without triggering duplicate requests.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // TanStack Router guard
|
|
43
|
+
* beforeLoad: async () => {
|
|
44
|
+
* if (!(await client.auth.ensureSession())) throw redirect({ to: "/login" })
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* @returns true if a valid session exists, false otherwise
|
|
48
|
+
*/
|
|
49
|
+
ensureSession(): Promise<boolean>;
|
|
50
|
+
/** Calls `POST /api/auth/logout` to clear the server cookie, then resets the login flag. */
|
|
26
51
|
clear(): void;
|
|
27
52
|
};
|
|
28
53
|
/**
|
|
@@ -54,7 +79,14 @@ export type ServerAuth = {
|
|
|
54
79
|
* Factory function for `BrowserAuth`. Called internally by `createMiraClient` in browser mode.
|
|
55
80
|
* @internal Use `createMiraClient()` instead of calling this directly
|
|
56
81
|
*/
|
|
57
|
-
export declare function makeBrowserAuth(execute: ExecuteFn, makeClientHandler: <T>(effect: Effect.Effect<T, MiraError, HttpClient.HttpClient>) => ClientHandler<T>, loggedInRef: MutableRef.MutableRef<boolean
|
|
82
|
+
export declare function makeBrowserAuth(execute: ExecuteFn, makeClientHandler: <T>(effect: Effect.Effect<T, MiraError, HttpClient.HttpClient>) => ClientHandler<T>, loggedInRef: MutableRef.MutableRef<boolean>,
|
|
83
|
+
/**
|
|
84
|
+
* Shared per-page-load memo for the session check. Shared with the collection
|
|
85
|
+
* clients so a successful login / logout can invalidate a stale result (e.g. a
|
|
86
|
+
* `false` memoized before login) — otherwise a post-login navigation would
|
|
87
|
+
* re-read the stale `false` and bounce between `/login` and the protected route.
|
|
88
|
+
*/
|
|
89
|
+
sessionMemoRef?: MutableRef.MutableRef<Promise<boolean> | null>): BrowserAuth;
|
|
58
90
|
/**
|
|
59
91
|
* Factory function for `ServerAuth`. Called internally by `createMiraClient` in server mode.
|
|
60
92
|
* @internal Use `createMiraClient("/", { type: "server" })` instead of calling this directly
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/client/auth.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/client/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAG7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE5D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,uGAAuG;IACvG,UAAU,IAAI,OAAO,CAAA;IACrB;;;;;;;;;OASG;IACH,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;IAC3B;;;;;;;;;;;;;OAaG;IACH,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;IACjC,4FAA4F;IAC5F,KAAK,IAAI,IAAI,CAAA;CACd,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,KAAK,IAAI,IAAI,CAAA;IACb,OAAO,IAAI,OAAO,CAAA;CACnB,CAAA;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,SAAS,EAClB,iBAAiB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,aAAa,CAAC,CAAC,CAAC,EACtG,WAAW,EAAE,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC;AAC3C;;;;;GAKG;AACH,cAAc,GAAE,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAyB,GACrF,WAAW,CAgDb;AAcD;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,YAAY,EAAE,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,EAClD,iBAAiB,EAAE,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,GAC1F,UAAU,CAoBZ"}
|
package/dist/src/client/auth.js
CHANGED
|
@@ -1,17 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { MutableRef } from "effect";
|
|
2
|
+
import { HttpClientRequest as HCR } from "effect/http";
|
|
3
3
|
/**
|
|
4
4
|
* Factory function for `BrowserAuth`. Called internally by `createMiraClient` in browser mode.
|
|
5
5
|
* @internal Use `createMiraClient()` instead of calling this directly
|
|
6
6
|
*/
|
|
7
|
-
export function makeBrowserAuth(execute, makeClientHandler, loggedInRef
|
|
7
|
+
export function makeBrowserAuth(execute, makeClientHandler, loggedInRef,
|
|
8
|
+
/**
|
|
9
|
+
* Shared per-page-load memo for the session check. Shared with the collection
|
|
10
|
+
* clients so a successful login / logout can invalidate a stale result (e.g. a
|
|
11
|
+
* `false` memoized before login) — otherwise a post-login navigation would
|
|
12
|
+
* re-read the stale `false` and bounce between `/login` and the protected route.
|
|
13
|
+
*/
|
|
14
|
+
sessionMemoRef = MutableRef.make(null)) {
|
|
15
|
+
const checkSession = async () => {
|
|
16
|
+
try {
|
|
17
|
+
const effect = execute(HCR.get("/api/auth/me"));
|
|
18
|
+
await makeClientHandler(effect).raw();
|
|
19
|
+
MutableRef.set(loggedInRef, true);
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
MutableRef.set(loggedInRef, false);
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
8
27
|
return {
|
|
9
28
|
isLoggedIn: () => MutableRef.get(loggedInRef),
|
|
29
|
+
refresh: () => {
|
|
30
|
+
const promise = checkSession();
|
|
31
|
+
MutableRef.set(sessionMemoRef, promise);
|
|
32
|
+
return promise;
|
|
33
|
+
},
|
|
34
|
+
ensureSession: () => {
|
|
35
|
+
const memo = MutableRef.get(sessionMemoRef);
|
|
36
|
+
if (memo !== null)
|
|
37
|
+
return memo;
|
|
38
|
+
const promise = checkSession();
|
|
39
|
+
MutableRef.set(sessionMemoRef, promise);
|
|
40
|
+
return promise;
|
|
41
|
+
},
|
|
10
42
|
clear: () => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
43
|
+
// Flip the flag synchronously so a route guard that runs immediately after
|
|
44
|
+
// `clear()` (e.g. `navigate({ to: "/login" })`) does not still see the user
|
|
45
|
+
// as logged in and bounce back to the protected route.
|
|
46
|
+
MutableRef.set(loggedInRef, false);
|
|
47
|
+
// Pin the session memo to a resolved `false` rather than `null`. The logout
|
|
48
|
+
// POST is fire-and-forget, so the cookie may still be valid for a moment;
|
|
49
|
+
// if a guard re-ran `ensureSession()` in that window it would get a `200`
|
|
50
|
+
// and re-authenticate, bouncing the user back to the protected route.
|
|
51
|
+
// A pinned `false` short-circuits every check until the next login, which
|
|
52
|
+
// resets the memo (see `authWithPassword`).
|
|
53
|
+
MutableRef.set(sessionMemoRef, Promise.resolve(false));
|
|
54
|
+
const effect = execute(HCR.post("/api/auth/logout"));
|
|
15
55
|
void makeClientHandler(effect).raw();
|
|
16
56
|
},
|
|
17
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/client/auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/client/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,UAAU,EAAE,MAAM,QAAQ,CAAA;AAE3C,OAAO,EAAE,iBAAiB,IAAI,GAAG,EAAE,MAAM,aAAa,CAAA;AAgFtD;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAkB,EAClB,iBAAsG,EACtG,WAA2C;AAC3C;;;;;GAKG;AACH,iBAAiE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;IAEtF,MAAM,YAAY,GAAG,KAAK,IAAsB,EAAE;QAChD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,OAAO,CACpB,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CACxB,CAAA;YACD,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAA;YACrC,UAAU,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;YACjC,OAAO,IAAI,CAAA;QACb,CAAC;QAAC,MAAM,CAAC;YACP,UAAU,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;YAClC,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC,CAAA;IAED,OAAO;QACL,UAAU,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC;QAE7C,OAAO,EAAE,GAAG,EAAE;YACZ,MAAM,OAAO,GAAG,YAAY,EAAE,CAAA;YAC9B,UAAU,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;YACvC,OAAO,OAAO,CAAA;QAChB,CAAC;QAED,aAAa,EAAE,GAAG,EAAE;YAClB,MAAM,IAAI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AA;IACb,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,YAAkD,EAClD,iBAA2F;IAE3F,OAAO;QACL,IAAI,KAAK;YACP,OAAO,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;QACrC,CAAC;QACD,QAAQ,CAAC,KAAa;YACpB,UAAU,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,CAAC,CAAA;QACrC,CAAC;QACD,KAAK,EAAE,GAAS,EAAE;YAChB,UAAU,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;YAClC,UAAU,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,GAAG,EAAE,CAAC,CAAA;QAC9C,CAAC;QACD,OAAO,EAAE,GAAY,EAAE;YACrB,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;YAC1C,IAAI,KAAK,KAAK,IAAI;gBAAE,OAAO,KAAK,CAAA;YAChC,MAAM,GAAG,GAAG,YAAY,CAAC,KAAK,CAAC,CAAA;YAC/B,IAAI,GAAG,KAAK,IAAI;gBAAE,OAAO,KAAK,CAAA;YAC9B,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,CAAA;QAChC,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import type { AnyCollectionDef, FieldFilterOperand, FieldsMap, FilterNode, InferFieldValue } from "@gettersethya/mira-collection";
|
|
2
|
+
import type { Schedule } from "effect";
|
|
3
|
+
import { MutableRef, Option } from "effect";
|
|
3
4
|
import { MiraError } from "./errors.js";
|
|
4
5
|
import type { ClientHandler, ExecuteFn } from "./handler.js";
|
|
5
|
-
import type { CollectionFileFields,
|
|
6
|
+
import type { CollectionFileFields, CollectionKind, CreateInput, InferRecord, RegisterInput, RelationKeys, SelectableKeys, UpdateInput, WithSelect } from "./types.js";
|
|
6
7
|
/**
|
|
7
8
|
* Optional retry configuration for collection operations.
|
|
8
9
|
* Wraps an Effect `Schedule` that determines retry behavior when a `MiraError` occurs.
|
|
@@ -23,18 +24,18 @@ import type { CollectionFileFields, InferMutationInput, InferRecord, RelationKey
|
|
|
23
24
|
export type RetryOptions = {
|
|
24
25
|
schedule?: Schedule.Schedule<unknown, MiraError, never>;
|
|
25
26
|
};
|
|
26
|
-
type GetListOptions<F extends FieldsMap, E extends ReadonlyArray<string
|
|
27
|
+
export type GetListOptions<F extends FieldsMap, E extends ReadonlyArray<string>, S extends ReadonlyArray<string> | undefined = undefined> = {
|
|
27
28
|
filter?: (f: FilterBuilder<F>) => FilterNode;
|
|
28
29
|
sort?: keyof F & string;
|
|
29
30
|
order?: "asc" | "desc";
|
|
30
31
|
cursor?: number | null;
|
|
31
32
|
limit?: number;
|
|
32
|
-
select?:
|
|
33
|
+
select?: S;
|
|
33
34
|
expand?: E;
|
|
34
35
|
retryOptions?: RetryOptions;
|
|
35
36
|
};
|
|
36
|
-
type GetOneOptions<F extends FieldsMap, E extends ReadonlyArray<string
|
|
37
|
-
select?:
|
|
37
|
+
export type GetOneOptions<F extends FieldsMap, E extends ReadonlyArray<string>, S extends ReadonlyArray<string> | undefined = undefined> = {
|
|
38
|
+
select?: S;
|
|
38
39
|
expand?: E;
|
|
39
40
|
retryOptions?: RetryOptions;
|
|
40
41
|
};
|
|
@@ -80,7 +81,7 @@ export type FilterBuilder<F extends FieldsMap> = {
|
|
|
80
81
|
* @see makeCollectionClient — constructs CollectionClient instances
|
|
81
82
|
* @see ClientHandler — return type of all methods
|
|
82
83
|
*/
|
|
83
|
-
export type
|
|
84
|
+
export type RawCollectionClient<F extends FieldsMap, K extends CollectionKind = "base"> = {
|
|
84
85
|
/**
|
|
85
86
|
* List records with optional filtering, sorting, cursor pagination, and field selection.
|
|
86
87
|
*
|
|
@@ -105,8 +106,8 @@ export type CollectionClient<F extends FieldsMap> = {
|
|
|
105
106
|
* @param options.retryOptions - Optional retry schedule
|
|
106
107
|
* @returns ClientHandler for the paginated result
|
|
107
108
|
*/
|
|
108
|
-
getList<E extends ReadonlyArray<RelationKeys<F>> = []>(options?: GetListOptions<F, E>): ClientHandler<{
|
|
109
|
-
items:
|
|
109
|
+
getList<E extends ReadonlyArray<RelationKeys<F>> = [], S extends ReadonlyArray<SelectableKeys<F>> | undefined = undefined>(options?: GetListOptions<F, E, S>): ClientHandler<{
|
|
110
|
+
items: Array<WithSelect<F, S, E>>;
|
|
110
111
|
nextCursor: number | null;
|
|
111
112
|
}>;
|
|
112
113
|
/**
|
|
@@ -123,7 +124,7 @@ export type CollectionClient<F extends FieldsMap> = {
|
|
|
123
124
|
* @param options.retryOptions - Optional retry schedule
|
|
124
125
|
* @returns ClientHandler resolving to Option of the record (None if no match)
|
|
125
126
|
*/
|
|
126
|
-
getFirstOrNone<E extends ReadonlyArray<RelationKeys<F>> = []>(filter: (f: FilterBuilder<F>) => FilterNode, options?: Omit<GetListOptions<F, E>, "filter" | "limit" | "cursor">): ClientHandler<Option.Option<
|
|
127
|
+
getFirstOrNone<E extends ReadonlyArray<RelationKeys<F>> = [], S extends ReadonlyArray<SelectableKeys<F>> | undefined = undefined>(filter: (f: FilterBuilder<F>) => FilterNode, options?: Omit<GetListOptions<F, E, S>, "filter" | "limit" | "cursor">): ClientHandler<Option.Option<WithSelect<F, S, E>>>;
|
|
127
128
|
/**
|
|
128
129
|
* Fetch all records matching the filter, automatically following pagination.
|
|
129
130
|
* Defaults to `limit: 1000` — override via options if you need a different page size.
|
|
@@ -140,9 +141,9 @@ export type CollectionClient<F extends FieldsMap> = {
|
|
|
140
141
|
* @param options.retryOptions - Optional retry schedule
|
|
141
142
|
* @returns ClientHandler resolving to a flat array of records
|
|
142
143
|
*/
|
|
143
|
-
getFullList<E extends ReadonlyArray<RelationKeys<F>> = []>(options?: Omit<GetListOptions<F, E>, "limit" | "cursor"> & {
|
|
144
|
+
getFullList<E extends ReadonlyArray<RelationKeys<F>> = [], S extends ReadonlyArray<SelectableKeys<F>> | undefined = undefined>(options?: Omit<GetListOptions<F, E, S>, "limit" | "cursor"> & {
|
|
144
145
|
limit?: number;
|
|
145
|
-
}): ClientHandler<
|
|
146
|
+
}): ClientHandler<Array<WithSelect<F, S, E>>>;
|
|
146
147
|
/**
|
|
147
148
|
* Get a single record by its `id`.
|
|
148
149
|
* Returns a 404 `MiraError` if the record does not exist.
|
|
@@ -153,7 +154,7 @@ export type CollectionClient<F extends FieldsMap> = {
|
|
|
153
154
|
* @param options.retryOptions - Optional retry schedule
|
|
154
155
|
* @returns ClientHandler resolving to the record
|
|
155
156
|
*/
|
|
156
|
-
getOne<E extends ReadonlyArray<RelationKeys<F>> = []>(id: string, options?: GetOneOptions<F, E>): ClientHandler<
|
|
157
|
+
getOne<E extends ReadonlyArray<RelationKeys<F>> = [], S extends ReadonlyArray<SelectableKeys<F>> | undefined = undefined>(id: string, options?: GetOneOptions<F, E, S>): ClientHandler<WithSelect<F, S, E>>;
|
|
157
158
|
/**
|
|
158
159
|
* Create a new record.
|
|
159
160
|
*
|
|
@@ -162,7 +163,7 @@ export type CollectionClient<F extends FieldsMap> = {
|
|
|
162
163
|
*
|
|
163
164
|
* @returns A mutation ClientHandler — call `.raw(input)` with the record data
|
|
164
165
|
*/
|
|
165
|
-
create(): ClientHandler<InferRecord<F>,
|
|
166
|
+
create(): ClientHandler<InferRecord<F>, CreateInput<F, K>>;
|
|
166
167
|
/**
|
|
167
168
|
* Update an existing record by ID.
|
|
168
169
|
* Only the fields present in `data` are updated (partial/patch semantics).
|
|
@@ -172,10 +173,7 @@ export type CollectionClient<F extends FieldsMap> = {
|
|
|
172
173
|
*
|
|
173
174
|
* @returns A mutation ClientHandler — call `.raw({ id, data })`
|
|
174
175
|
*/
|
|
175
|
-
update(): ClientHandler<InferRecord<F>,
|
|
176
|
-
id: string;
|
|
177
|
-
data: Partial<InferMutationInput<F>>;
|
|
178
|
-
}>;
|
|
176
|
+
update(): ClientHandler<InferRecord<F>, UpdateInput<F, K>>;
|
|
179
177
|
/**
|
|
180
178
|
* Delete a record by ID.
|
|
181
179
|
* Returns `void` on success. Throws `MiraError` (404) if the record does not exist.
|
|
@@ -203,6 +201,39 @@ export type CollectionClient<F extends FieldsMap> = {
|
|
|
203
201
|
email: string;
|
|
204
202
|
password: string;
|
|
205
203
|
}>;
|
|
204
|
+
/**
|
|
205
|
+
* Register (self-signup) a new user on an auth collection.
|
|
206
|
+
* Only available on collections defined with `AuthCollection.define()`.
|
|
207
|
+
*
|
|
208
|
+
* Wraps the create endpoint (`POST /api/collections/:name`) — open registration
|
|
209
|
+
* therefore requires the collection's create rule to permit it (e.g. `create: R.public()`).
|
|
210
|
+
* Does **not** auto-login; call `authWithPassword()` after if needed.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* const user = await mira.users.register().raw({
|
|
214
|
+
* email: "user@example.com",
|
|
215
|
+
* password: "secret123",
|
|
216
|
+
* passwordConfirm: "secret123"
|
|
217
|
+
* })
|
|
218
|
+
*
|
|
219
|
+
* @returns A mutation ClientHandler — call `.raw({ email, password, passwordConfirm, ... })`
|
|
220
|
+
*/
|
|
221
|
+
register?(): ClientHandler<InferRecord<F>, RegisterInput<F>>;
|
|
222
|
+
/**
|
|
223
|
+
* Fetch the currently authenticated user for this auth collection from
|
|
224
|
+
* `GET /api/auth/me`. Only available on collections defined with
|
|
225
|
+
* `AuthCollection.define()`.
|
|
226
|
+
*
|
|
227
|
+
* The response envelope is `{ collection, record }`; the client unwraps it and
|
|
228
|
+
* resolves to the record directly. If the session token belongs to a different
|
|
229
|
+
* collection, the call rejects with a 401 `MiraError`.
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* const me = await mira.users.me().raw()
|
|
233
|
+
*
|
|
234
|
+
* @returns A query ClientHandler — call `.raw()`
|
|
235
|
+
*/
|
|
236
|
+
me?(): ClientHandler<InferRecord<F>>;
|
|
206
237
|
/**
|
|
207
238
|
* File field client interfaces for the collection.
|
|
208
239
|
* Provides `.url()` and `.asyncUrl()` methods for constructing file download URLs.
|
|
@@ -212,7 +243,144 @@ export type CollectionClient<F extends FieldsMap> = {
|
|
|
212
243
|
*/
|
|
213
244
|
fields: CollectionFileFields<F>;
|
|
214
245
|
};
|
|
215
|
-
|
|
246
|
+
/**
|
|
247
|
+
* Client interface for a single collection, providing typed CRUD operations.
|
|
248
|
+
* Created via `makeCollectionClient()` or automatically via `createMiraClient()`.
|
|
249
|
+
*
|
|
250
|
+
* For auth collections (`K = "auth"`) the `authWithPassword`/`register` methods
|
|
251
|
+
* are guaranteed present; for other kinds they are absent.
|
|
252
|
+
*
|
|
253
|
+
* @typeParam F - The FieldsMap type of the collection
|
|
254
|
+
* @typeParam K - The collection kind (`"base" | "auth" | "view"`)
|
|
255
|
+
*/
|
|
256
|
+
export type CollectionClient<F extends FieldsMap, K extends CollectionKind = "base"> = RawCollectionClient<F, K> & AuthByKind<F>[K];
|
|
257
|
+
/**
|
|
258
|
+
* The auth methods guaranteed for each collection kind. For `"base"` collections
|
|
259
|
+
* there are none; for `"auth"` collections `authWithPassword`/`register` are
|
|
260
|
+
* required (they are always built at runtime for auth collections).
|
|
261
|
+
*
|
|
262
|
+
* Expressed as a lookup map indexed by `K` rather than a `K extends "auth" ? … : {}`
|
|
263
|
+
* conditional so that adapters can branch on a generic `K` without assertions.
|
|
264
|
+
*/
|
|
265
|
+
export type AuthByKind<F extends FieldsMap> = {
|
|
266
|
+
[P in CollectionKind]: P extends "auth" ? {
|
|
267
|
+
authWithPassword(): ClientHandler<{
|
|
268
|
+
token: string;
|
|
269
|
+
record: InferRecord<F>;
|
|
270
|
+
}, {
|
|
271
|
+
email: string;
|
|
272
|
+
password: string;
|
|
273
|
+
}>;
|
|
274
|
+
register(): ClientHandler<InferRecord<F>, RegisterInput<F>>;
|
|
275
|
+
me(): ClientHandler<InferRecord<F>>;
|
|
276
|
+
} : {};
|
|
277
|
+
};
|
|
278
|
+
export type AdaptedAuthByKind<F extends FieldsMap> = {
|
|
279
|
+
[P in CollectionKind]: P extends "auth" ? {
|
|
280
|
+
authWithPassword(): EnrichedMutationHandler<ClientHandler<{
|
|
281
|
+
token: string;
|
|
282
|
+
record: InferRecord<F>;
|
|
283
|
+
}, {
|
|
284
|
+
email: string;
|
|
285
|
+
password: string;
|
|
286
|
+
}>>;
|
|
287
|
+
register(): EnrichedMutationHandler<ClientHandler<InferRecord<F>, RegisterInput<F>>>;
|
|
288
|
+
me(): EnrichedQueryHandler<ClientHandler<InferRecord<F>>>;
|
|
289
|
+
} : {};
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* A readonly array of values used as a TanStack Query key.
|
|
293
|
+
*
|
|
294
|
+
* @see AdaptedCollectionClient — carries `queryKey` on every query handler
|
|
295
|
+
*/
|
|
296
|
+
export type QueryKey = ReadonlyArray<unknown>;
|
|
297
|
+
/**
|
|
298
|
+
* The structural shape of a TanStack Query `queryOptions` object, as produced
|
|
299
|
+
* by any framework adapter. The client package cannot depend on TanStack, so
|
|
300
|
+
* the option objects are typed structurally; TanStack's `useQuery` accepts this
|
|
301
|
+
* shape and infers `data` from `queryFn`'s return type.
|
|
302
|
+
*/
|
|
303
|
+
export type AdaptedQueryOptions<T> = {
|
|
304
|
+
queryKey: QueryKey;
|
|
305
|
+
queryFn: () => Promise<T>;
|
|
306
|
+
};
|
|
307
|
+
/**
|
|
308
|
+
* The structural shape of a TanStack Query `mutationOptions` object.
|
|
309
|
+
*
|
|
310
|
+
* @see AdaptedCollectionClient — carries `mutationOptions` on every mutation handler
|
|
311
|
+
*/
|
|
312
|
+
export type AdaptedMutationOptions<TData, TInput> = {
|
|
313
|
+
mutationFn: (input: TInput) => Promise<TData>;
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* A query handler (`getList` / `getOne` / `getFirstOrNone` / `getFullList`)
|
|
317
|
+
* augmented with the query key and `queryOptions`. `queryFn` is the handler's
|
|
318
|
+
* own `raw` function, so the option type is derived from the handler directly
|
|
319
|
+
* (no re-instantiation of the result type).
|
|
320
|
+
*/
|
|
321
|
+
type EnrichedQueryHandler<H extends {
|
|
322
|
+
raw(): Promise<unknown>;
|
|
323
|
+
}> = H & {
|
|
324
|
+
queryKey: QueryKey;
|
|
325
|
+
queryOptions: {
|
|
326
|
+
queryKey: QueryKey;
|
|
327
|
+
queryFn: H["raw"];
|
|
328
|
+
};
|
|
329
|
+
};
|
|
330
|
+
/**
|
|
331
|
+
* A mutation handler (`create` / `update` / `delete` / `register`) augmented
|
|
332
|
+
* with `mutationOptions`. `mutationFn` is the handler's own `raw` function.
|
|
333
|
+
*/
|
|
334
|
+
type EnrichedMutationHandler<H extends {
|
|
335
|
+
raw(input: never): Promise<unknown>;
|
|
336
|
+
}> = H & {
|
|
337
|
+
mutationOptions: {
|
|
338
|
+
mutationFn: H["raw"];
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
/**
|
|
342
|
+
* A {@link CollectionClient} whose query handlers also expose `queryKey` /
|
|
343
|
+
* `queryOptions` and whose mutation handlers also expose `mutationOptions`,
|
|
344
|
+
* plus `invalidateAll` / `invalidateOne` query-cache helpers.
|
|
345
|
+
*
|
|
346
|
+
* Produced at runtime by an adapter (e.g. `collectionAdapter` from
|
|
347
|
+
* `@gettersethya/mira-tanstack-adapter`) and surfaced through
|
|
348
|
+
* `withCollections(map, { adapter })`.
|
|
349
|
+
*
|
|
350
|
+
* @typeParam F - The collection's `FieldsMap`
|
|
351
|
+
* @typeParam K - The collection kind (`"base" | "auth" | "view"`)
|
|
352
|
+
*/
|
|
353
|
+
export type AdaptedCollectionClient<F extends FieldsMap, K extends CollectionKind = "base"> = AdaptedCommon<F, K> & AdaptedAuthByKind<F>[K];
|
|
354
|
+
/**
|
|
355
|
+
* The kind-independent members of {@link AdaptedCollectionClient}. Split out so
|
|
356
|
+
* the adapter body can annotate the object it builds and spread the per-kind
|
|
357
|
+
* extras on top (yielding exactly this type).
|
|
358
|
+
*/
|
|
359
|
+
export type AdaptedCommon<F extends FieldsMap, K extends CollectionKind = "base"> = Omit<RawCollectionClient<F, K>, "getList" | "getOne" | "getFirstOrNone" | "getFullList" | "create" | "update" | "delete" | "register" | "authWithPassword" | "me"> & {
|
|
360
|
+
getList<E extends ReadonlyArray<RelationKeys<F>> = [], S extends ReadonlyArray<SelectableKeys<F>> | undefined = undefined>(options?: GetListOptions<F, E, S>): EnrichedQueryHandler<ClientHandler<{
|
|
361
|
+
items: Array<WithSelect<F, S, E>>;
|
|
362
|
+
nextCursor: number | null;
|
|
363
|
+
}>>;
|
|
364
|
+
getOne<E extends ReadonlyArray<RelationKeys<F>> = [], S extends ReadonlyArray<SelectableKeys<F>> | undefined = undefined>(id: string, options?: GetOneOptions<F, E, S>): EnrichedQueryHandler<ClientHandler<WithSelect<F, S, E>>>;
|
|
365
|
+
getFirstOrNone<E extends ReadonlyArray<RelationKeys<F>> = [], S extends ReadonlyArray<SelectableKeys<F>> | undefined = undefined>(filter: (f: FilterBuilder<F>) => FilterNode, options?: Omit<GetListOptions<F, E, S>, "filter" | "limit" | "cursor">): EnrichedQueryHandler<ClientHandler<Option.Option<WithSelect<F, S, E>>>>;
|
|
366
|
+
getFullList<E extends ReadonlyArray<RelationKeys<F>> = [], S extends ReadonlyArray<SelectableKeys<F>> | undefined = undefined>(options?: Omit<GetListOptions<F, E, S>, "limit" | "cursor"> & {
|
|
367
|
+
limit?: number;
|
|
368
|
+
}): EnrichedQueryHandler<ClientHandler<Array<WithSelect<F, S, E>>>>;
|
|
369
|
+
create(): EnrichedMutationHandler<ClientHandler<InferRecord<F>, CreateInput<F, K>>>;
|
|
370
|
+
update(): EnrichedMutationHandler<ClientHandler<InferRecord<F>, UpdateInput<F, K>>>;
|
|
371
|
+
delete(): EnrichedMutationHandler<ClientHandler<void, string>>;
|
|
372
|
+
invalidateAll(queryClient: {
|
|
373
|
+
invalidateQueries(opts: {
|
|
374
|
+
queryKey: QueryKey;
|
|
375
|
+
}): unknown;
|
|
376
|
+
}): unknown;
|
|
377
|
+
invalidateOne(queryClient: {
|
|
378
|
+
invalidateQueries(opts: {
|
|
379
|
+
queryKey: QueryKey;
|
|
380
|
+
}): unknown;
|
|
381
|
+
}, id: string): unknown;
|
|
382
|
+
};
|
|
383
|
+
type MakeCollectionClientParams<F extends FieldsMap, K extends CollectionKind = "base"> = {
|
|
216
384
|
collectionName: string;
|
|
217
385
|
schema: AnyCollectionDef["schema"];
|
|
218
386
|
fields: F;
|
|
@@ -225,7 +393,14 @@ type MakeCollectionClientParams<F extends FieldsMap> = {
|
|
|
225
393
|
expiresAt: number;
|
|
226
394
|
}>>;
|
|
227
395
|
isAuth: boolean;
|
|
396
|
+
kind?: K;
|
|
228
397
|
defaultRetryOptions?: RetryOptions;
|
|
398
|
+
/**
|
|
399
|
+
* Shared browser-session memo (see `makeBrowserAuth`). Cleared after a
|
|
400
|
+
* successful login so a stale `false` result from before login cannot bounce
|
|
401
|
+
* a freshly-authenticated navigation back to `/login`.
|
|
402
|
+
*/
|
|
403
|
+
sessionMemoRef?: MutableRef.MutableRef<Promise<boolean> | null> | null;
|
|
229
404
|
};
|
|
230
405
|
/**
|
|
231
406
|
* Construct a `CollectionClient<F>` for a given collection definition.
|
|
@@ -234,6 +409,6 @@ type MakeCollectionClientParams<F extends FieldsMap> = {
|
|
|
234
409
|
*
|
|
235
410
|
* @internal Use `createMiraClient().collection(def)` or `withCollections()` instead.
|
|
236
411
|
*/
|
|
237
|
-
export declare function makeCollectionClient<F extends FieldsMap>(params: MakeCollectionClientParams<F>):
|
|
412
|
+
export declare function makeCollectionClient<F extends FieldsMap, K extends CollectionKind = "base">(params: MakeCollectionClientParams<F, K>): RawCollectionClient<F, K>;
|
|
238
413
|
export {};
|
|
239
414
|
//# sourceMappingURL=collection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../../src/client/collection.ts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