@shivaedev/identity 0.42.0 → 0.44.0
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/CHANGELOG.md +22 -0
- package/README.md +26 -14
- package/dist/Account.d.ts +4 -3
- package/dist/Account.d.ts.map +1 -1
- package/dist/generated/Account.d.ts +3 -1
- package/dist/generated/Account.d.ts.map +1 -1
- package/dist/generated/Account.js +2 -2
- package/dist/generated/Account.js.map +1 -1
- package/dist/identity.d.ts +2 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +1 -0
- package/dist/identity.js.map +1 -1
- package/dist/server/AccountDeletion.d.ts +3 -2
- package/dist/server/AccountDeletion.d.ts.map +1 -1
- package/dist/server/AccountDeletion.js.map +1 -1
- package/dist/server/account-clock/boundary.d.ts +1 -1
- package/dist/server/account-clock/boundary.d.ts.map +1 -1
- package/dist/server/account-clock/boundary.js +2 -2
- package/dist/server/account-clock/boundary.js.map +1 -1
- package/dist/server/account-clock/dayRange.d.ts +2 -3
- package/dist/server/account-clock/dayRange.d.ts.map +1 -1
- package/dist/server/account-clock/dayRange.js +6 -4
- package/dist/server/account-clock/dayRange.js.map +1 -1
- package/dist/server/account-clock/initialize.d.ts +1 -6
- package/dist/server/account-clock/initialize.d.ts.map +1 -1
- package/dist/server/account-clock/initialize.js +1 -9
- package/dist/server/account-clock/initialize.js.map +1 -1
- package/dist/server/account-clock/logicalDay.d.ts +1 -2
- package/dist/server/account-clock/logicalDay.d.ts.map +1 -1
- package/dist/server/account-clock/logicalDay.js +6 -4
- package/dist/server/account-clock/logicalDay.js.map +1 -1
- package/dist/server/account-clock/service.d.ts +4 -5
- package/dist/server/account-clock/service.d.ts.map +1 -1
- package/dist/server/account-clock/service.js +2 -3
- package/dist/server/account-clock/service.js.map +1 -1
- package/dist/server/account-clock/zone.d.ts +3 -0
- package/dist/server/account-clock/zone.d.ts.map +1 -0
- package/dist/server/account-clock/zone.js +8 -0
- package/dist/server/account-clock/zone.js.map +1 -0
- package/dist/server/better-auth/accountDeletion.d.ts +2 -1
- package/dist/server/better-auth/accountDeletion.d.ts.map +1 -1
- package/dist/server/better-auth/accountDeletion.js +3 -1
- package/dist/server/better-auth/accountDeletion.js.map +1 -1
- package/dist/server/better-auth/adapters/evictCachedAccount.d.ts +7 -0
- package/dist/server/better-auth/adapters/evictCachedAccount.d.ts.map +1 -0
- package/dist/server/better-auth/adapters/evictCachedAccount.js +36 -0
- package/dist/server/better-auth/adapters/evictCachedAccount.js.map +1 -0
- package/dist/server/better-auth/adapters/oauthGrants.d.ts.map +1 -1
- package/dist/server/better-auth/adapters/oauthGrants.js +7 -1
- package/dist/server/better-auth/adapters/oauthGrants.js.map +1 -1
- package/dist/server/better-auth/deleteAccount.d.ts +1 -1
- package/dist/server/better-auth/deleteAccount.d.ts.map +1 -1
- package/dist/server/better-auth/deleteAccount.js +6 -0
- package/dist/server/better-auth/deleteAccount.js.map +1 -1
- package/dist/server/better-auth/deleteUserRows.d.ts.map +1 -1
- package/dist/server/better-auth/deleteUserRows.js +6 -3
- package/dist/server/better-auth/deleteUserRows.js.map +1 -1
- package/dist/server/better-auth/seedUsers.js +1 -1
- package/dist/server/better-auth/seedUsers.js.map +1 -1
- package/dist/server/localOwner.d.ts +2 -0
- package/dist/server/localOwner.d.ts.map +1 -1
- package/dist/server/localOwner.js +3 -1
- package/dist/server/localOwner.js.map +1 -1
- package/dist/server/machineTokens.d.ts +2 -0
- package/dist/server/machineTokens.d.ts.map +1 -1
- package/dist/server/machineTokens.js +1 -1
- package/dist/server/machineTokens.js.map +1 -1
- package/dist/server/providerAccountsUser.d.ts +1 -0
- package/dist/server/providerAccountsUser.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/generated/Account.ts +2 -2
- package/src/identity.ts +1 -0
- package/src/server/AccountDeletion.ts +7 -2
- package/src/server/account-clock/boundary.ts +2 -2
- package/src/server/account-clock/dayRange.ts +7 -5
- package/src/server/account-clock/initialize.ts +1 -9
- package/src/server/account-clock/logicalDay.ts +6 -5
- package/src/server/account-clock/service.ts +2 -3
- package/src/server/account-clock/zone.ts +8 -0
- package/src/server/better-auth/accountDeletion.ts +3 -0
- package/src/server/better-auth/adapters/evictCachedAccount.ts +41 -0
- package/src/server/better-auth/adapters/oauthGrants.ts +7 -1
- package/src/server/better-auth/deleteAccount.ts +6 -0
- package/src/server/better-auth/deleteUserRows.ts +6 -3
- package/src/server/better-auth/seedUsers.ts +1 -1
- package/src/server/localOwner.ts +3 -1
- package/src/server/machineTokens.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.44.0 - 2026-11-21
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- The account `delete` command works when the auth declaration configures `secondaryStorage`. It previously failed on the `verification` table, which Better Auth does not create there. Inside its transaction it now revokes the person's sessions in `secondaryStorage` as Better Auth does, so none of them resolves a user afterwards, with or without `storeSessionInDatabase`. It records Better Auth's revoked-before time, which alone ends a session created before the deletion, and deletes the listed sessions whether the store's client returns JSON text or parsed values. It also deletes the email codes of their exact address kept there.
|
|
8
|
+
|
|
9
|
+
### Breaking
|
|
10
|
+
|
|
11
|
+
- `AccountClock` is a global service that answers for any account: `logicalDay(account, instant?)` and `dayRange(account, day)` take the account id first and read that account's saved timezone on each call, and the Layer requires `AccountPreferencesStore` and `AccountDayStart` instead of `Subject`. Replace `clock.logicalDay()` with `clock.logicalDay((yield* Subject).id)` and `clock.dayRange(day)` with `clock.dayRange((yield* Subject).id, day)`, and move the clock's Layer from `requestServices` to `services`, for example `AccountClock.layer.pipe(Layer.provide(Layer.succeed(AccountDayStart, 240)), Layer.provideMerge(accountPreferencesStore))`. Both methods now fail with `AuthUnavailable` when the account's preferences cannot be read, where the old clock failed its request Layer's construction, and `dayRange` keeps its `SchemaError` for a `day` that is not an ISO calendar date. A defined module's operation, a job, and a native handler whose contract declares a subject or identity middleware carry `AuthUnavailable` with nothing to add; a native contract without either adds `rejections: { AuthUnavailable }` to the query.
|
|
12
|
+
|
|
13
|
+
## 0.43.0 - 2026-11-21
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- The account `delete` command admits three attempts per person in ten seconds, the budget Better Auth gives `/change-email`, through `@shivaedev/rate-limit`, and refuses a further attempt with `TooManyRequests`, which a form hook shows as a notice.
|
|
18
|
+
- `SessionUser` carries `emailVerified`, whether the signed-in person has confirmed their email address. An operation reads it from the session lookup Platform already makes, so it learns the flag with no second session read, and a `defineSeed` run reads the seeded persona's stored flag. An account that has not confirmed reads `false`; the first lookup after the person follows the confirmation link reads `true`.
|
|
19
|
+
|
|
20
|
+
### Breaking
|
|
21
|
+
|
|
22
|
+
- `accountDeletion` requires a rate-limit `Store` from `@shivaedev/rate-limit/Store.ts`. An application whose registrations provide none adds one to one registration's `ports`, such as `ports: memoryStore` with `memoryStore` from `@shivaedev/rate-limit/memoryStore.ts`.
|
|
23
|
+
- `SessionUserSchema`, `SessionUserValue` and `UserSessionShape` require `emailVerified: boolean`. A custom session provider adds `emailVerified` to the `user` it returns, and a test fixture that builds a `SessionUser` value or a provider's session user adds the field too, such as `Effect.provideService(SessionUser, { email, emailVerified: true, id, name })`. A provider without it still compiles, because `SessionPolicy.provider` requires only `user.id`: every operation behind `AuthenticatedUser`, `AuthenticatedUserWithProviderAccounts`, permission middleware, a subject resolver or `mcpRoutes` then fails as a defect when it reads the session user, while the person stays signed in. Operations behind `Authenticated` alone keep working. An application on Better Auth changes nothing, because Better Auth always supplies the field.
|
|
24
|
+
|
|
3
25
|
## 0.42.0 - 2026-11-21
|
|
4
26
|
|
|
5
27
|
### Added
|
package/README.md
CHANGED
|
@@ -156,24 +156,35 @@ export const auth = createAuthClient({ plugins: [preferencesPlugin()] });
|
|
|
156
156
|
|
|
157
157
|
The client sends its `Intl.DateTimeFormat` timezone and locale to the auth mount in the `x-platform-account-timezone` and `x-platform-account-locale` headers, whose names `accountPreferenceHeaders` from `@shivaedev/identity/accountPreferenceHeaders.ts` exports. It sends them only where a global `window` exists, as in a browser, a WebView or React Native, so a server-side auth call does not report the server's zone. A successful first sign-in captures those values with metric units. After redirect-based sign-in, the client's first `getSession` captures them. Missing or invalid timezone data leaves preferences uncaptured; a later session can capture them. A bundled native shell installs the same plugin (see [Bundled native clients](#bundled-native-clients)). Clients without a Better Auth client can call the `capture` contract with their own defaults.
|
|
158
158
|
|
|
159
|
-
`AccountClock` from `@shivaedev/identity/server/account-clock/service.ts` is a
|
|
159
|
+
`AccountClock` from `@shivaedev/identity/server/account-clock/service.ts` answers which logical day it is for any account. It is a global service: its Layer requires `AccountPreferencesStore` and `AccountDayStart`, not `Subject`, and each call reads the named account's saved timezone, so a request, a roster of many accounts, an RPC without a subject and a worker job use the same clock. Register its Layer once in global `services`, beside the store it reads. Configure `AccountDayStart` from `@shivaedev/identity/server/account-clock/settings.ts` in minutes after local midnight; it defaults to zero and accepts integers from 0 through 1439. The same module exports `LogicalDay`.
|
|
160
160
|
|
|
161
161
|
```ts
|
|
162
|
-
import {
|
|
162
|
+
import { Effect, Layer } from "effect";
|
|
163
|
+
import { Migrator } from "effect/sql";
|
|
164
|
+
import { AccountPreferences } from "@shivaedev/identity/AccountPreferences.ts";
|
|
163
165
|
import { AccountClock } from "@shivaedev/identity/server/account-clock/service.ts";
|
|
164
166
|
import { AccountDayStart } from "@shivaedev/identity/server/account-clock/settings.ts";
|
|
167
|
+
import { accountPreferencesStore } from "@shivaedev/identity/server/account-preferences/store.ts";
|
|
168
|
+
import { accountPreferencesMigration } from "@shivaedev/identity/server/accountPreferencesMigration.ts";
|
|
169
|
+
import { Subject } from "@shivaedev/identity/subject.ts";
|
|
170
|
+
import type { AppModule } from "@shivaedev/server/AppModule.ts";
|
|
171
|
+
|
|
172
|
+
export const preferencesModule = {
|
|
173
|
+
migrations: { loader: Migrator.fromRecord({ "0005_account_preferences": accountPreferencesMigration }) },
|
|
174
|
+
module: AccountPreferences,
|
|
175
|
+
services: AccountClock.layer.pipe(Layer.provide(Layer.succeed(AccountDayStart, 240)), Layer.provideMerge(accountPreferencesStore)),
|
|
176
|
+
} satisfies AppModule;
|
|
165
177
|
|
|
166
|
-
export const requestServices = AccountClock.layer.pipe(Layer.provide(Layer.succeed(AccountDayStart, 240)), Layer.orDie);
|
|
167
178
|
const today = Effect.gen(function* () {
|
|
168
179
|
const clock = yield* AccountClock;
|
|
169
|
-
const
|
|
170
|
-
return yield* clock.dayRange(
|
|
180
|
+
const account = (yield* Subject).id;
|
|
181
|
+
return yield* clock.dayRange(account, yield* clock.logicalDay(account));
|
|
171
182
|
});
|
|
172
183
|
```
|
|
173
184
|
|
|
174
|
-
|
|
185
|
+
The registration provides the store to the clock and to the module's operations at once. A self read passes `(yield* Subject).id`, a read that already takes its owner passes that id, and a roster asks once per account. Each call that cannot read the account's preferences fails with `AuthUnavailable`, in the call's own error channel, and `dayRange` also fails with `SchemaError` when `day` is not an ISO calendar date. A contract's subject or identity middleware already declares `AuthUnavailable`; a native query without either declares `rejections: { AuthUnavailable }`.
|
|
175
186
|
|
|
176
|
-
`logicalDay(instant)` returns
|
|
187
|
+
`logicalDay(account, instant)` returns the account's ISO calendar date; omitting the instant uses Effect's current clock. An account without saved preferences reads `UTC`. `dayRange(account, day)` returns UTC `DateTime` values `{ start, end }`, with an inclusive start and exclusive end. Endpoints are constructed separately in local calendar time: a 04:00 New York day spanning spring DST lasts 23 hours, and one spanning autumn DST lasts 25 hours. The exact boundary belongs to the new logical day. Applications use `timestamp >= start && timestamp < end` when grouping records. Day starts within a DST gap use Effect's compatible disambiguation (later in a gap, earlier in an overlap).
|
|
177
188
|
|
|
178
189
|
### Once per application: contracts and session policy
|
|
179
190
|
|
|
@@ -676,7 +687,7 @@ Declare expected refusals with the shared tagged error schemas from [`@shivaedev
|
|
|
676
687
|
|
|
677
688
|
### Reading the signed-in user
|
|
678
689
|
|
|
679
|
-
When a handler needs the current user's name and email, declare `AuthenticatedUser` and read `SessionUser`. `Identity` keeps its `{ id }` shape; `AuthenticatedUser` supplies both services for that invocation. Its provider must return `user: { id, name, email }`, described by `UserSessionShape`.
|
|
690
|
+
When a handler needs the current user's name and email, declare `AuthenticatedUser` and read `SessionUser`. `Identity` keeps its `{ id }` shape; `AuthenticatedUser` supplies both services for that invocation. Its provider must return `user: { id, name, email, emailVerified }`, described by `UserSessionShape`. `SessionUser.emailVerified` says whether the person has confirmed their address. Better Auth's provider reads it from the session lookup the request already makes, so a screen or operation that shows "confirm your email" or gates a feature on a confirmed address needs no second session read: an account that has not confirmed reads `false`, and the first lookup after the person follows the confirmation link reads `true`. The browser's remembered session keeps only the session, user id and grants, so an application serves the flag from its own profile query.
|
|
680
691
|
|
|
681
692
|
```ts
|
|
682
693
|
import { Effect, Layer, Schema } from "effect";
|
|
@@ -698,7 +709,7 @@ export const AccountHandlers = Account.toLayer({
|
|
|
698
709
|
export const AccountServer = Layer.merge(AccountHandlers, authenticatedUserLayer());
|
|
699
710
|
```
|
|
700
711
|
|
|
701
|
-
Here `sessions` is the application's policy Layer from the previous example, with a Better Auth lookup that returns all
|
|
712
|
+
Here `sessions` is the application's policy Layer from the previous example, with a Better Auth lookup that returns all four user fields. The host provides it once to middleware and routes; custom hosts provide it with `Layer.provide(sessions)`. Merge `authenticatedUserLayer()` alongside the handler Layer when using `appHost`; the host continues to supply its id-only and optional middleware. A missing session fails with typed `Unauthorized`; rejected origins fail with `Forbidden`, and provider failures remain `AuthUnavailable`. The profile contains id, name, email and `emailVerified`, plus an optional role and permissions when the provider supplies them, without exposing the rest of the provider's user record. Handlers do not query the provider's user table.
|
|
702
713
|
|
|
703
714
|
#### Reading provider account IDs
|
|
704
715
|
|
|
@@ -1097,13 +1108,14 @@ PostgreSQL sees only foreign keys, so a table whose owner column has none is cov
|
|
|
1097
1108
|
|
|
1098
1109
|
### Delete an account
|
|
1099
1110
|
|
|
1100
|
-
`Account` from `@shivaedev/identity/Account.ts` is a defined module, which is server code: register it as `module: Account` with `services: accountDeletion(AppAuth)`, using `accountDeletion` from `@shivaedev/identity/server/better-auth/accountDeletion.ts`. Its `identity.account.delete({ password })` command deletes the signed-in person's account; it needs the `AuthenticatedUser` middleware, the application's `SqlClient` and `Reactivity`, which `appHost` provides, and the owned models the host collects. Browser code imports the client contract under the same name from `@shivaedev/identity/generated/Account.ts`; give the command to a form hook such as React's `useCreate`, so a refused password shows on the password field.
|
|
1111
|
+
`Account` from `@shivaedev/identity/Account.ts` is a defined module, which is server code: register it as `module: Account` with `services: accountDeletion(AppAuth)`, using `accountDeletion` from `@shivaedev/identity/server/better-auth/accountDeletion.ts`. Its `identity.account.delete({ password })` command deletes the signed-in person's account; it needs the `AuthenticatedUser` middleware, the application's `SqlClient` and `Reactivity`, which `appHost` provides, the rate-limit `Store` the application declares once in one registration's `ports`, and the owned models the host collects. Browser code imports the client contract under the same name from `@shivaedev/identity/generated/Account.ts`; give the command to a form hook such as React's `useCreate`, so a refused password shows on the password field.
|
|
1101
1112
|
|
|
1102
1113
|
The command runs these steps in order:
|
|
1103
1114
|
|
|
1104
|
-
1. It
|
|
1105
|
-
2.
|
|
1106
|
-
3.
|
|
1115
|
+
1. It admits three attempts per person in ten seconds through [`@shivaedev/rate-limit`](https://github.com/ShivaeDev/platform/tree/main/packages/rate-limit#readme), in that one store, the budget Better Auth gives `/change-email` and its other password-checked routes. A further attempt is refused with `TooManyRequests` before the password is checked, and a form hook shows its message, `Too many attempts. Wait a moment and try again.`, as a notice. The window starts at the first attempt and every attempt counts, so a correct password within the budget still deletes.
|
|
1116
|
+
2. It checks the person's current password with the verifier the declaration's options configure, Better Auth's own unless `emailAndPassword.password.verify` replaces it. A missing, overlong or wrong password is refused with `BadRequest` on the `password` field, and an account without a credential password with `PreconditionFailed`; nothing is deleted.
|
|
1117
|
+
3. One `transact` runs the application's hand-over, then [`eraseOwnedRows`](#export-and-erase-a-persons-data), then deletes the person's auth rows: the user row, whose `ON DELETE CASCADE` keys remove their sessions and sign-in accounts, and the verification rows Better Auth writes for them. Those are the rows whose value is their id, such as a password-reset token, the `email-verification`, `sign-in` and `forget-password` codes of their exact address, and the change-email and two-factor codes that start with their id.
|
|
1118
|
+
4. On commit it announces `userKeys` and `sessionKeys`, so live readers refresh. The person's next session check answers signed out, which makes a remembered session forget itself, and their next protected request is refused with `Unauthorized`.
|
|
1107
1119
|
|
|
1108
1120
|
The hand-over is the application's policy for rows that other people keep, such as a shared household that passes to another member. It is an application service written with `defineService` whose `handOver(userId)` operation yields its own dependencies; pass its tag to `accountDeletion` and provide its Layer, and leave both out when nothing is handed over. The deletion calls it inside its transaction, so its writes commit or roll back with the rest:
|
|
1109
1121
|
|
|
@@ -1125,7 +1137,7 @@ A failing hand-over, a failing erase or a failing auth delete rolls everything b
|
|
|
1125
1137
|
|
|
1126
1138
|
The mount closes Better Auth's `/delete-user` and `/delete-user/callback`, even when the options enable `user.deleteUser`, and the admin plugin's `/admin/remove-user`, so this command is the one HTTP route that deletes an account. Better Auth deletes outside any transaction and erases no owned rows, and its `user.delete.before` hooks do not run here: move such a hook's body into the hand-over. Server code that calls Better Auth's `auth.api` directly is not covered by the closed routes.
|
|
1127
1139
|
|
|
1128
|
-
The deletion reads and writes Better Auth's tables through the application's SQL client.
|
|
1140
|
+
The deletion reads and writes Better Auth's tables through the application's SQL client. Once it commits, none of the person's sessions resolves a `SessionUser`, with sessions in the database, in Better Auth's cookie cache or in `secondaryStorage`, with or without `storeSessionInDatabase`. Their database sessions go with the user row, and identity resolves every request past the cookie cache. With `secondaryStorage`, the last step inside the transaction makes the same writes Better Auth makes when it revokes a user's sessions there: it records the revocation time Better Auth's session lookup checks, which alone ends every session created before the deletion, and deletes the sessions the store lists for the person, whether its client returns that list as JSON text or already parsed. It also deletes the `email-verification`, `sign-in` and `forget-password` codes of their exact address there; a password-reset token, change-email or two-factor code kept in `secondaryStorage` is keyed by what only the email holds, so it stays until it expires and names an id that no longer exists. Better Auth's own `/get-session` route still answers from the cookie cache until it expires when the declaration states no roles, so a browser session check can report the person signed in while every request is refused. Accounts that sign in only through a provider have no password to confirm with and are refused.
|
|
1129
1141
|
|
|
1130
1142
|
### Signed-in story preconditions
|
|
1131
1143
|
|
package/dist/Account.d.ts
CHANGED
|
@@ -9,9 +9,10 @@ export declare const Account: import("@shivaedev/contract/defineModule.ts").Modu
|
|
|
9
9
|
readonly AuthUnavailable: typeof import("@shivaedev/errors/taxonomy.ts").AuthUnavailable;
|
|
10
10
|
readonly BadRequest: typeof import("@shivaedev/errors/taxonomy.ts").BadRequest;
|
|
11
11
|
readonly PreconditionFailed: typeof import("@shivaedev/errors/taxonomy.ts").PreconditionFailed;
|
|
12
|
-
|
|
12
|
+
readonly TooManyRequests: typeof import("@shivaedev/errors/taxonomy.ts").TooManyRequests;
|
|
13
|
+
}, import("effect/Effect").Effect<void, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable | import("@shivaedev/errors/taxonomy.ts").BadRequest | import("@shivaedev/errors/taxonomy.ts").PreconditionFailed | Schema.SchemaError | import("effect/sql/SqlError").SqlError | import("@shivaedev/rate-limit/Store.ts").StoreError | import("@shivaedev/errors/taxonomy.ts").TooManyRequests, AccountDeletion | import("./identity.ts").SessionUser>>] & readonly import("@shivaedev/contract/defineModule.ts").ModuleOperation[], import("@shivaedev/contract/moduleProof.ts").ModuleRequirements<readonly [import("@shivaedev/contract/servedOperation.ts").ServedCommandOf<"delete", {
|
|
13
14
|
password: Schema.String;
|
|
14
|
-
}, import("effect/Effect").Effect<void, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable | import("@shivaedev/errors/taxonomy.ts").BadRequest | import("@shivaedev/errors/taxonomy.ts").PreconditionFailed | Schema.SchemaError | import("effect/sql/SqlError").SqlError, import("./identity.ts").SessionUser> | import("effect/Effect").Effect<{
|
|
15
|
-
readonly delete: (password: string) => import("effect/Effect").Effect<void, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable | import("@shivaedev/errors/taxonomy.ts").BadRequest | import("@shivaedev/errors/taxonomy.ts").PreconditionFailed | Schema.SchemaError | import("effect/sql/SqlError").SqlError, import("./identity.ts").SessionUser>;
|
|
15
|
+
}, import("effect/Effect").Effect<void, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable | import("@shivaedev/errors/taxonomy.ts").BadRequest | import("@shivaedev/errors/taxonomy.ts").PreconditionFailed | Schema.SchemaError | import("effect/sql/SqlError").SqlError | import("@shivaedev/rate-limit/Store.ts").StoreError | import("@shivaedev/errors/taxonomy.ts").TooManyRequests, import("./identity.ts").SessionUser> | import("effect/Effect").Effect<{
|
|
16
|
+
readonly delete: (password: string) => import("effect/Effect").Effect<void, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable | import("@shivaedev/errors/taxonomy.ts").BadRequest | import("@shivaedev/errors/taxonomy.ts").PreconditionFailed | Schema.SchemaError | import("effect/sql/SqlError").SqlError | import("@shivaedev/rate-limit/Store.ts").StoreError | import("@shivaedev/errors/taxonomy.ts").TooManyRequests, import("./identity.ts").SessionUser>;
|
|
16
17
|
}, never, AccountDeletion>, void>], typeof AuthenticatedUser, undefined>, typeof AuthenticatedUser, undefined, undefined>;
|
|
17
18
|
//# sourceMappingURL=Account.d.ts.map
|
package/dist/Account.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../src/Account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAS7D,eAAO,MAAM,OAAO
|
|
1
|
+
{"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../src/Account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAS7D,eAAO,MAAM,OAAO;;;;;;;;;;;;;yHAKlB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Account as AccountModule } from "#Account.ts";
|
|
2
2
|
import { AuthenticatedUser } from "#middleware.ts";
|
|
3
3
|
import type { ClientMatchesModule } from "@shivaedev/contract/clientMatchesModule.ts";
|
|
4
|
-
import { AuthUnavailable, BadRequest, PreconditionFailed } from "@shivaedev/errors/taxonomy.ts";
|
|
4
|
+
import { AuthUnavailable, BadRequest, PreconditionFailed, TooManyRequests } from "@shivaedev/errors/taxonomy.ts";
|
|
5
5
|
import { Schema } from "effect";
|
|
6
6
|
export declare const identityAccountWire: {
|
|
7
7
|
readonly delete: {
|
|
@@ -9,6 +9,7 @@ export declare const identityAccountWire: {
|
|
|
9
9
|
readonly AuthUnavailable: typeof AuthUnavailable;
|
|
10
10
|
readonly BadRequest: typeof BadRequest;
|
|
11
11
|
readonly PreconditionFailed: typeof PreconditionFailed;
|
|
12
|
+
readonly TooManyRequests: typeof TooManyRequests;
|
|
12
13
|
};
|
|
13
14
|
readonly success: Schema.Void;
|
|
14
15
|
};
|
|
@@ -21,6 +22,7 @@ export declare const Account: import("@shivaedev/contract/defineModule.ts").Modu
|
|
|
21
22
|
readonly AuthUnavailable: typeof AuthUnavailable;
|
|
22
23
|
readonly BadRequest: typeof BadRequest;
|
|
23
24
|
readonly PreconditionFailed: typeof PreconditionFailed;
|
|
25
|
+
readonly TooManyRequests: typeof TooManyRequests;
|
|
24
26
|
}>[], typeof AuthenticatedUser, undefined, undefined>;
|
|
25
27
|
export declare const identityAccountMatchModule: ClientMatchesModule<typeof Account, typeof AccountModule>;
|
|
26
28
|
//# sourceMappingURL=Account.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../../src/generated/Account.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../../src/generated/Account.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACjH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,eAAO,MAAM,mBAAmB;;;;;;;;;;CAEtB,CAAC;AAEX,eAAO,MAAM,OAAO;;;;;;;;;qDAQlB,CAAC;AAEH,eAAO,MAAM,0BAA0B,EAAE,mBAAmB,CAAC,OAAO,OAAO,EAAE,OAAO,aAAa,CAAQ,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AuthenticatedUser } from "#middleware.ts";
|
|
2
2
|
import { clientContract } from "@shivaedev/contract/clientContract.ts";
|
|
3
|
-
import { AuthUnavailable, BadRequest, PreconditionFailed } from "@shivaedev/errors/taxonomy.ts";
|
|
3
|
+
import { AuthUnavailable, BadRequest, PreconditionFailed, TooManyRequests } from "@shivaedev/errors/taxonomy.ts";
|
|
4
4
|
import { Schema } from "effect";
|
|
5
5
|
export const identityAccountWire = {
|
|
6
|
-
delete: { rejections: { AuthUnavailable, BadRequest, PreconditionFailed }, success: Schema.Void },
|
|
6
|
+
delete: { rejections: { AuthUnavailable, BadRequest, PreconditionFailed, TooManyRequests }, success: Schema.Void },
|
|
7
7
|
};
|
|
8
8
|
export const Account = clientContract({
|
|
9
9
|
commands: ["delete"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Account.js","sourceRoot":"","sources":["../../src/generated/Account.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"Account.js","sourceRoot":"","sources":["../../src/generated/Account.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACjH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAClC,MAAM,EAAE,EAAE,UAAU,EAAE,EAAE,eAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE;CACzG,CAAC;AAEX,MAAM,CAAC,MAAM,OAAO,GAAG,cAAc,CAAC;IACrC,QAAQ,EAAE,CAAC,QAAQ,CAAC;IACpB,UAAU,EAAE,iBAAiB;IAC7B,IAAI,EAAE,kBAAkB;IACxB,QAAQ,EAAE;QACT,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;KACnC;IACD,IAAI,EAAE,mBAAmB;CACzB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAA8D,IAAI,CAAC"}
|
package/dist/identity.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export interface ProviderAccountValue {
|
|
|
18
18
|
}
|
|
19
19
|
export declare const SessionUserSchema: Schema.Struct<{
|
|
20
20
|
readonly email: Schema.String;
|
|
21
|
+
readonly emailVerified: Schema.Boolean;
|
|
21
22
|
readonly id: Schema.String;
|
|
22
23
|
readonly name: Schema.String;
|
|
23
24
|
readonly permissions: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
@@ -29,6 +30,7 @@ export declare const SessionUserSchema: Schema.Struct<{
|
|
|
29
30
|
export type SessionUserValue = typeof SessionUserSchema.Type;
|
|
30
31
|
declare const SessionUser_base: Context.ServiceClass<SessionUser, "@shivaedev/identity/SessionUser", {
|
|
31
32
|
readonly email: string;
|
|
33
|
+
readonly emailVerified: boolean;
|
|
32
34
|
readonly id: string;
|
|
33
35
|
readonly name: string;
|
|
34
36
|
readonly permissions?: readonly {
|
package/dist/identity.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEnE,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;;AACnF,qBAAa,SAAU,SAAQ,cAAqE;CAAG;AACvG,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACpB;;AACD,qBAAa,QAAS,SAAQ,aAA0E;CAAG;;AAC3G,qBAAa,gBAAiB,SAAQ,qBAAyG;CAAG;AAClJ,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AACD,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEnE,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;;AACnF,qBAAa,SAAU,SAAQ,cAAqE;CAAG;AACvG,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACpB;;AACD,qBAAa,QAAS,SAAQ,aAA0E;CAAG;;AAC3G,qBAAa,gBAAiB,SAAQ,qBAAyG;CAAG;AAClJ,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AACD,eAAO,MAAM,iBAAiB;;;;;;;;;;EAO5B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,iBAAiB,CAAC,IAAI,CAAC;;;;;;;;;;;;AAC7D,qBAAa,WAAY,SAAQ,gBAAmF;CAAG;AACvH,MAAM,WAAW,oCAAqC,SAAQ,gBAAgB;IAC7E,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,oBAAoB,EAAE,EAAE,eAAe,GAAG,YAAY,CAAC,CAAC;CAC1G;;AACD,qBAAa,+BAAgC,SAAQ,oCAEpD;CAAG"}
|
package/dist/identity.js
CHANGED
|
@@ -8,6 +8,7 @@ export class OptionalIdentity extends Context.Service()("@shivaedev/identity/Opt
|
|
|
8
8
|
}
|
|
9
9
|
export const SessionUserSchema = Schema.Struct({
|
|
10
10
|
email: Schema.String,
|
|
11
|
+
emailVerified: Schema.Boolean,
|
|
11
12
|
id: Schema.String,
|
|
12
13
|
name: Schema.String,
|
|
13
14
|
permissions: Schema.optionalKey(Schema.Array(Permission)),
|
package/dist/identity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA4B,MAAM,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D,MAAM,OAAO,SAAU,SAAQ,OAAO,CAAC,OAAO,EAAqB,CAAC,+BAA+B,CAAC;CAAG;AAIvG,MAAM,OAAO,QAAS,SAAQ,OAAO,CAAC,OAAO,EAA2B,CAAC,8BAA8B,CAAC;CAAG;AAC3G,MAAM,OAAO,gBAAiB,SAAQ,OAAO,CAAC,OAAO,EAAkD,CAAC,sCAAsC,CAAC;CAAG;AAKlJ,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9C,KAAK,EAAE,MAAM,CAAC,MAAM;IACpB,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACzD,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;CACnD,CAAC,CAAC;AAEH,MAAM,OAAO,WAAY,SAAQ,OAAO,CAAC,OAAO,EAAiC,CAAC,iCAAiC,CAAC;CAAG;AAIvH,MAAM,OAAO,+BAAgC,SAAQ,OAAO,CAAC,OAAO,EAAyE,CAC5I,qDAAqD,CACrD;CAAG"}
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA4B,MAAM,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D,MAAM,OAAO,SAAU,SAAQ,OAAO,CAAC,OAAO,EAAqB,CAAC,+BAA+B,CAAC;CAAG;AAIvG,MAAM,OAAO,QAAS,SAAQ,OAAO,CAAC,OAAO,EAA2B,CAAC,8BAA8B,CAAC;CAAG;AAC3G,MAAM,OAAO,gBAAiB,SAAQ,OAAO,CAAC,OAAO,EAAkD,CAAC,sCAAsC,CAAC;CAAG;AAKlJ,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9C,KAAK,EAAE,MAAM,CAAC,MAAM;IACpB,aAAa,EAAE,MAAM,CAAC,OAAO;IAC7B,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACzD,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;CACnD,CAAC,CAAC;AAEH,MAAM,OAAO,WAAY,SAAQ,OAAO,CAAC,OAAO,EAAiC,CAAC,iCAAiC,CAAC;CAAG;AAIvH,MAAM,OAAO,+BAAgC,SAAQ,OAAO,CAAC,OAAO,EAAyE,CAC5I,qDAAqD,CACrD;CAAG"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Context, type Effect, type Schema } from "effect";
|
|
2
2
|
import type { SqlError } from "effect/sql/SqlError";
|
|
3
|
-
import type { AuthUnavailable, BadRequest, PreconditionFailed } from "@shivaedev/errors/taxonomy.ts";
|
|
3
|
+
import type { AuthUnavailable, BadRequest, PreconditionFailed, TooManyRequests } from "@shivaedev/errors/taxonomy.ts";
|
|
4
|
+
import type { StoreError } from "@shivaedev/rate-limit/Store.ts";
|
|
4
5
|
import type { SessionUser } from "#identity.ts";
|
|
5
6
|
declare const AccountDeletion_base: Context.ServiceClass<AccountDeletion, "@shivaedev/identity/AccountDeletion", {
|
|
6
|
-
readonly delete: (password: string) => Effect.Effect<void, AuthUnavailable | BadRequest | PreconditionFailed | Schema.SchemaError | SqlError, SessionUser>;
|
|
7
|
+
readonly delete: (password: string) => Effect.Effect<void, AuthUnavailable | BadRequest | PreconditionFailed | Schema.SchemaError | SqlError | StoreError | TooManyRequests, SessionUser>;
|
|
7
8
|
}>;
|
|
8
9
|
export declare class AccountDeletion extends AccountDeletion_base {
|
|
9
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountDeletion.d.ts","sourceRoot":"","sources":["../../src/server/AccountDeletion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"AccountDeletion.d.ts","sourceRoot":"","sources":["../../src/server/AccountDeletion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACtH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;;qBAM7B,CAChB,QAAQ,EAAE,MAAM,KACZ,MAAM,CAAC,MAAM,CACjB,IAAI,EACJ,eAAe,GAAG,UAAU,GAAG,kBAAkB,GAAG,MAAM,CAAC,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,eAAe,EAChH,WAAW,CACX;;AATH,qBAAa,eAAgB,SAAQ,oBAWK;CAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountDeletion.js","sourceRoot":"","sources":["../../src/server/AccountDeletion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA4B,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"AccountDeletion.js","sourceRoot":"","sources":["../../src/server/AccountDeletion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA4B,MAAM,QAAQ,CAAC;AAM3D,oGAAoG;AACpG,MAAM,OAAO,eAAgB,SAAQ,OAAO,CAAC,OAAO,EAWjD,CAAC,qCAAqC,CAAC;CAAG"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DateTime, Effect } from "effect";
|
|
2
|
-
export declare const boundary: (day: string,
|
|
2
|
+
export declare const boundary: (day: string, timeZone: DateTime.TimeZone, minutes: number) => Effect.Effect<DateTime.Utc, never, never>;
|
|
3
3
|
//# sourceMappingURL=boundary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boundary.d.ts","sourceRoot":"","sources":["../../../src/server/account-clock/boundary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE1C,eAAO,MAAM,QAAQ
|
|
1
|
+
{"version":3,"file":"boundary.d.ts","sourceRoot":"","sources":["../../../src/server/account-clock/boundary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE1C,eAAO,MAAM,QAAQ,0GAUpB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DateTime, Effect } from "effect";
|
|
2
|
-
export const boundary = Effect.fn("AccountClock.boundary")((day,
|
|
2
|
+
export const boundary = Effect.fn("AccountClock.boundary")((day, timeZone, minutes) => Effect.sync(() => DateTime.toUtc(DateTime.makeZonedUnsafe(`${day}T00:00:00.000Z`, {
|
|
3
3
|
adjustForTimeZone: true,
|
|
4
4
|
disambiguation: "compatible",
|
|
5
|
-
timeZone
|
|
5
|
+
timeZone,
|
|
6
6
|
}).pipe(DateTime.setParts({ hour: Math.floor(minutes / 60), minute: minutes % 60 })))));
|
|
7
7
|
//# sourceMappingURL=boundary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boundary.js","sourceRoot":"","sources":["../../../src/server/account-clock/boundary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE1C,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC,uBAAuB,CAAC,CAAC,CAAC,GAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"boundary.js","sourceRoot":"","sources":["../../../src/server/account-clock/boundary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE1C,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC,uBAAuB,CAAC,CAAC,CAAC,GAAW,EAAE,QAA2B,EAAE,OAAe,EAAE,EAAE,CACxH,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAChB,QAAQ,CAAC,KAAK,CACb,QAAQ,CAAC,eAAe,CAAC,GAAG,GAAG,gBAAgB,EAAE;IAChD,iBAAiB,EAAE,IAAI;IACvB,cAAc,EAAE,YAAY;IAC5B,QAAQ;CACR,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,CAAC,CAAC,CACpF,CACD,CACD,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DateTime, Effect, Schema } from "effect";
|
|
2
|
-
|
|
3
|
-
export declare function dayRange({ minutes, timezone }: Effect.Success<typeof initialize>): (day: string) => Effect.Effect<{
|
|
2
|
+
export declare function dayRange(minutes: number): (account: string, day: string) => Effect.Effect<{
|
|
4
3
|
end: DateTime.Utc;
|
|
5
4
|
start: DateTime.Utc;
|
|
6
|
-
}, Schema.SchemaError,
|
|
5
|
+
}, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable | Schema.SchemaError, "@shivaedev/identity/AccountPreferencesStore">;
|
|
7
6
|
//# sourceMappingURL=dayRange.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dayRange.d.ts","sourceRoot":"","sources":["../../../src/server/account-clock/dayRange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"dayRange.d.ts","sourceRoot":"","sources":["../../../src/server/account-clock/dayRange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAOlD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM;;;gIAMvC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { DateTime, Effect, Schema } from "effect";
|
|
2
2
|
import { boundary } from "#server/account-clock/boundary.ts";
|
|
3
3
|
import { LogicalDay } from "#server/account-clock/settings.ts";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { zone } from "#server/account-clock/zone.ts";
|
|
5
|
+
const decodeDay = Schema.decodeUnknownEffect(LogicalDay.pipe(Schema.decodeTo(Schema.DateTimeUtcFromString)));
|
|
6
|
+
export function dayRange(minutes) {
|
|
7
|
+
return Effect.fn("AccountClock.dayRange")(function* (account, day) {
|
|
7
8
|
const next = DateTime.formatIsoDateUtc(DateTime.add(yield* decodeDay(day), { days: 1 }));
|
|
8
|
-
|
|
9
|
+
const timeZone = yield* zone(account);
|
|
10
|
+
return { end: yield* boundary(next, timeZone, minutes), start: yield* boundary(day, timeZone, minutes) };
|
|
9
11
|
});
|
|
10
12
|
}
|
|
11
13
|
//# sourceMappingURL=dayRange.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dayRange.js","sourceRoot":"","sources":["../../../src/server/account-clock/dayRange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"dayRange.js","sourceRoot":"","sources":["../../../src/server/account-clock/dayRange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAErD,MAAM,SAAS,GAAG,MAAM,CAAC,mBAAmB,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;AAE7G,MAAM,UAAU,QAAQ,CAAC,OAAe;IACvC,OAAO,MAAM,CAAC,EAAE,CAAC,uBAAuB,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAe,EAAE,GAAW;QAChF,MAAM,IAAI,GAAG,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACzF,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC;IAC1G,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
|
-
|
|
3
|
-
export declare const initialize: Effect.Effect<{
|
|
4
|
-
minutes: number;
|
|
5
|
-
timezone: string;
|
|
6
|
-
zone: import("effect/DateTime").TimeZone.Named;
|
|
7
|
-
}, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable | Schema.SchemaError, "@shivaedev/identity/AccountPreferencesStore" | Subject>;
|
|
2
|
+
export declare const initialize: Effect.Effect<number, Schema.SchemaError, never>;
|
|
8
3
|
//# sourceMappingURL=initialize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../../src/server/account-clock/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGxC,
|
|
1
|
+
{"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../../src/server/account-clock/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGxC,eAAO,MAAM,UAAU,kDAAwE,CAAC"}
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
2
|
import { AccountDayStart, DayStart } from "#server/account-clock/settings.ts";
|
|
3
|
-
|
|
4
|
-
import { Subject } from "#subject.ts";
|
|
5
|
-
export const initialize = Effect.gen(function* () {
|
|
6
|
-
const { id } = yield* Subject;
|
|
7
|
-
const { timezone } = yield* (yield* AccountPreferencesStore).get(id);
|
|
8
|
-
const minutes = yield* Schema.decodeUnknownEffect(DayStart)(yield* AccountDayStart);
|
|
9
|
-
const zone = yield* Schema.decodeUnknownEffect(Schema.TimeZoneNamedFromString)(timezone);
|
|
10
|
-
return { minutes, timezone, zone };
|
|
11
|
-
});
|
|
3
|
+
export const initialize = Effect.flatMap(AccountDayStart, Schema.decodeUnknownEffect(DayStart));
|
|
12
4
|
//# sourceMappingURL=initialize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/server/account-clock/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/server/account-clock/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE9E,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { DateTime, Effect } from "effect";
|
|
2
|
-
|
|
3
|
-
export declare function logicalDay({ minutes, timezone, zone }: Effect.Success<typeof initialize>): (instant?: DateTime.Utc | undefined) => Effect.Effect<string, never, never>;
|
|
2
|
+
export declare function logicalDay(minutes: number): (account: string, instant?: DateTime.Utc | undefined) => Effect.Effect<string, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable, "@shivaedev/identity/AccountPreferencesStore">;
|
|
4
3
|
//# sourceMappingURL=logicalDay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logicalDay.d.ts","sourceRoot":"","sources":["../../../src/server/account-clock/logicalDay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"logicalDay.d.ts","sourceRoot":"","sources":["../../../src/server/account-clock/logicalDay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAI1C,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,0LAQzC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { DateTime, Effect } from "effect";
|
|
2
2
|
import { boundary } from "#server/account-clock/boundary.ts";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { zone } from "#server/account-clock/zone.ts";
|
|
4
|
+
export function logicalDay(minutes) {
|
|
5
|
+
return Effect.fn("AccountClock.logicalDay")(function* (account, instant) {
|
|
5
6
|
const now = instant ?? (yield* DateTime.now);
|
|
6
|
-
const
|
|
7
|
+
const timeZone = yield* zone(account);
|
|
8
|
+
const local = DateTime.setZone(now, timeZone);
|
|
7
9
|
const day = DateTime.formatIsoDate(local);
|
|
8
|
-
return DateTime.isLessThan(now, yield* boundary(day,
|
|
10
|
+
return DateTime.isLessThan(now, yield* boundary(day, timeZone, minutes)) ? DateTime.formatIsoDate(DateTime.subtract(local, { days: 1 })) : day;
|
|
9
11
|
});
|
|
10
12
|
}
|
|
11
13
|
//# sourceMappingURL=logicalDay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logicalDay.js","sourceRoot":"","sources":["../../../src/server/account-clock/logicalDay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"logicalDay.js","sourceRoot":"","sources":["../../../src/server/account-clock/logicalDay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAErD,MAAM,UAAU,UAAU,CAAC,OAAe;IACzC,OAAO,MAAM,CAAC,EAAE,CAAC,yBAAyB,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAe,EAAE,OAAsB;QAC7F,MAAM,GAAG,GAAG,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC7C,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtC,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAC9C,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC1C,OAAO,QAAQ,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAChJ,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { Subject } from "#subject.ts";
|
|
2
1
|
export declare const AccountClock: import("effect/Context").Service<"@shivaedev/identity/AccountClock", Readonly<{
|
|
3
|
-
readonly dayRange: (day: string) => import("effect/Effect").Effect<{
|
|
2
|
+
readonly dayRange: (account: string, day: string) => import("effect/Effect").Effect<{
|
|
4
3
|
end: import("effect/DateTime").Utc;
|
|
5
4
|
start: import("effect/DateTime").Utc;
|
|
6
|
-
}, import("effect/Schema").SchemaError, never>;
|
|
7
|
-
readonly logicalDay: (instant?: import("effect/DateTime").Utc | undefined) => import("effect/Effect").Effect<string,
|
|
5
|
+
}, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable | import("effect/Schema").SchemaError, never>;
|
|
6
|
+
readonly logicalDay: (account: string, instant?: import("effect/DateTime").Utc | undefined) => import("effect/Effect").Effect<string, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable, never>;
|
|
8
7
|
}>> & {
|
|
9
|
-
readonly layer: import("effect/Layer").Layer<"@shivaedev/identity/AccountClock", import("
|
|
8
|
+
readonly layer: import("effect/Layer").Layer<"@shivaedev/identity/AccountClock", import("effect/Schema").SchemaError, "@shivaedev/identity/AccountPreferencesStore">;
|
|
10
9
|
};
|
|
11
10
|
//# sourceMappingURL=service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/server/account-clock/service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/server/account-clock/service.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,YAAY;;;;;;;;CAKvB,CAAC"}
|
|
@@ -4,11 +4,10 @@ import { initialize } from "#server/account-clock/initialize.ts";
|
|
|
4
4
|
import { logicalDay } from "#server/account-clock/logicalDay.ts";
|
|
5
5
|
import { AccountDayStart } from "#server/account-clock/settings.ts";
|
|
6
6
|
import { AccountPreferencesStore } from "#server/account-preferences/service.ts";
|
|
7
|
-
import { Subject } from "#subject.ts";
|
|
8
7
|
export const AccountClock = defineService({
|
|
9
8
|
id: "@shivaedev/identity/AccountClock",
|
|
10
9
|
initialize,
|
|
11
|
-
methods: (
|
|
12
|
-
requires: [AccountPreferencesStore,
|
|
10
|
+
methods: (minutes) => ({ dayRange: dayRange(minutes), logicalDay: logicalDay(minutes) }),
|
|
11
|
+
requires: [AccountPreferencesStore, AccountDayStart],
|
|
13
12
|
});
|
|
14
13
|
//# sourceMappingURL=service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/server/account-clock/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/server/account-clock/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC;IACzC,EAAE,EAAE,kCAAkC;IACtC,UAAU;IACV,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;IACxF,QAAQ,EAAE,CAAC,uBAAuB,EAAE,eAAe,CAAC;CACpD,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
export declare const zone: (account: string) => Effect.Effect<import("effect/DateTime").TimeZone.Named, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable, "@shivaedev/identity/AccountPreferencesStore">;
|
|
3
|
+
//# sourceMappingURL=zone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zone.d.ts","sourceRoot":"","sources":["../../../src/server/account-clock/zone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAGxC,eAAO,MAAM,IAAI,sLAIf,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { AccountPreferencesStore } from "#server/account-preferences/service.ts";
|
|
3
|
+
export const zone = Effect.fn("AccountClock.zone")(function* (account) {
|
|
4
|
+
const { timezone } = yield* (yield* AccountPreferencesStore).get(account);
|
|
5
|
+
// The store returns only timezones its row schema has checked, so a timezone that does not decode here is a broken invariant.
|
|
6
|
+
return yield* Schema.decodeUnknownEffect(Schema.TimeZoneNamedFromString)(timezone).pipe(Effect.orDie);
|
|
7
|
+
});
|
|
8
|
+
//# sourceMappingURL=zone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zone.js","sourceRoot":"","sources":["../../../src/server/account-clock/zone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,mBAAmB,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAe;IAC5E,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,uBAAuB,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC1E,8HAA8H;IAC9H,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACvG,CAAC,CAAC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Context, Effect, Layer } from "effect";
|
|
2
2
|
import * as Reactivity from "effect/reactivity/Reactivity";
|
|
3
3
|
import { SqlClient } from "effect/sql";
|
|
4
|
+
import { Store } from "@shivaedev/rate-limit/Store.ts";
|
|
4
5
|
import { AccountDeletion } from "#server/AccountDeletion.ts";
|
|
5
6
|
import type { AuthSchemaDeclaration } from "#server/better-auth/define.ts";
|
|
6
7
|
export interface AccountHandOver<E> {
|
|
@@ -9,5 +10,5 @@ export interface AccountHandOver<E> {
|
|
|
9
10
|
export interface AccountDeletionOptions<TIdentifier, E> {
|
|
10
11
|
readonly handOver?: Context.Service<TIdentifier, AccountHandOver<E>> | undefined;
|
|
11
12
|
}
|
|
12
|
-
export declare function accountDeletion<TIdentifier = never, E = never>(auth: Pick<AuthSchemaDeclaration, "options">, options?: AccountDeletionOptions<TIdentifier, E>): Layer.Layer<AccountDeletion, never, Reactivity.Reactivity | SqlClient.SqlClient | Exclude<TIdentifier, import("effect/Scope").Scope>>;
|
|
13
|
+
export declare function accountDeletion<TIdentifier = never, E = never>(auth: Pick<AuthSchemaDeclaration, "options">, options?: AccountDeletionOptions<TIdentifier, E>): Layer.Layer<AccountDeletion, never, Reactivity.Reactivity | SqlClient.SqlClient | Store | Exclude<TIdentifier, import("effect/Scope").Scope>>;
|
|
13
14
|
//# sourceMappingURL=accountDeletion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountDeletion.d.ts","sourceRoot":"","sources":["../../../src/server/better-auth/accountDeletion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAG3E,MAAM,WAAW,eAAe,CAAC,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;CAC9D;AAED,MAAM,WAAW,sBAAsB,CAAC,WAAW,EAAE,CAAC;IACrD,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;CACjF;AAGD,wBAAgB,eAAe,CAAC,WAAW,GAAG,KAAK,EAAE,CAAC,GAAG,KAAK,EAC7D,IAAI,EAAE,IAAI,CAAC,qBAAqB,EAAE,SAAS,CAAC,EAC5C,OAAO,GAAE,sBAAsB,CAAC,WAAW,EAAE,CAAC,CAAM,
|
|
1
|
+
{"version":3,"file":"accountDeletion.d.ts","sourceRoot":"","sources":["../../../src/server/better-auth/accountDeletion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAG3E,MAAM,WAAW,eAAe,CAAC,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;CAC9D;AAED,MAAM,WAAW,sBAAsB,CAAC,WAAW,EAAE,CAAC;IACrD,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;CACjF;AAGD,wBAAgB,eAAe,CAAC,WAAW,GAAG,KAAK,EAAE,CAAC,GAAG,KAAK,EAC7D,IAAI,EAAE,IAAI,CAAC,qBAAqB,EAAE,SAAS,CAAC,EAC5C,OAAO,GAAE,sBAAsB,CAAC,WAAW,EAAE,CAAC,CAAM,iJAuBpD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Effect, Layer } from "effect";
|
|
2
2
|
import * as Reactivity from "effect/reactivity/Reactivity";
|
|
3
3
|
import { SqlClient } from "effect/sql";
|
|
4
|
+
import { Store } from "@shivaedev/rate-limit/Store.ts";
|
|
4
5
|
import { AccountDeletion } from "#server/AccountDeletion.ts";
|
|
5
6
|
import { AccountDeletionPolicy } from "#server/better-auth/AccountDeletionPolicy.ts";
|
|
6
7
|
import { deleteAccount } from "#server/better-auth/deleteAccount.ts";
|
|
@@ -9,13 +10,14 @@ export function accountDeletion(auth, options = {}) {
|
|
|
9
10
|
return Layer.effect(AccountDeletion)(Effect.gen(function* () {
|
|
10
11
|
const sql = yield* SqlClient.SqlClient;
|
|
11
12
|
const reactivity = yield* Reactivity.Reactivity;
|
|
13
|
+
const store = yield* Store;
|
|
12
14
|
const service = options.handOver === undefined ? undefined : yield* options.handOver;
|
|
13
15
|
const policy = {
|
|
14
16
|
auth,
|
|
15
17
|
handOver: (userId) => (service === undefined ? Effect.void : Effect.orDie(service.handOver(userId))),
|
|
16
18
|
};
|
|
17
19
|
return AccountDeletion.of({
|
|
18
|
-
delete: (password) => deleteAccount(password).pipe(Effect.provideService(AccountDeletionPolicy, policy), Effect.provideService(SqlClient.SqlClient, sql), Effect.provideService(Reactivity.Reactivity, reactivity)),
|
|
20
|
+
delete: (password) => deleteAccount(password).pipe(Effect.provideService(AccountDeletionPolicy, policy), Effect.provideService(SqlClient.SqlClient, sql), Effect.provideService(Reactivity.Reactivity, reactivity), Effect.provideService(Store, store)),
|
|
19
21
|
});
|
|
20
22
|
}));
|
|
21
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountDeletion.js","sourceRoot":"","sources":["../../../src/server/better-auth/accountDeletion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAErF,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAUrE,2GAA2G;AAC3G,MAAM,UAAU,eAAe,CAC9B,IAA4C,EAC5C,OAAO,GAA2C,EAAE;IAEpD,OAAO,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,CACnC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACnB,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC;QACvC,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC;QAChD,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;QACrF,MAAM,MAAM,GAAG;YACd,IAAI;YACJ,QAAQ,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;SAC5G,CAAC;QACF,OAAO,eAAe,CAAC,EAAE,CAAC;YACzB,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CACpB,aAAa,CAAC,QAAQ,CAAC,CAAC,IAAI,CAC3B,MAAM,CAAC,cAAc,CAAC,qBAAqB,EAAE,MAAM,CAAC,EACpD,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC,EAC/C,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"accountDeletion.js","sourceRoot":"","sources":["../../../src/server/better-auth/accountDeletion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAErF,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAUrE,2GAA2G;AAC3G,MAAM,UAAU,eAAe,CAC9B,IAA4C,EAC5C,OAAO,GAA2C,EAAE;IAEpD,OAAO,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,CACnC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACnB,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC;QACvC,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC;QAChD,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC;QAC3B,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;QACrF,MAAM,MAAM,GAAG;YACd,IAAI;YACJ,QAAQ,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;SAC5G,CAAC;QACF,OAAO,eAAe,CAAC,EAAE,CAAC;YACzB,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CACpB,aAAa,CAAC,QAAQ,CAAC,CAAC,IAAI,CAC3B,MAAM,CAAC,cAAc,CAAC,qBAAqB,EAAE,MAAM,CAAC,EACpD,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC,EAC/C,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,EACxD,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CACnC;SACF,CAAC,CAAC;IACJ,CAAC,CAAC,CACF,CAAC;AACH,CAAC"}
|