@shivaedev/identity 0.39.0 → 0.41.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 +17 -0
- package/README.md +37 -28
- package/dist/accountPreferenceHeaders.d.ts +5 -0
- package/dist/accountPreferenceHeaders.d.ts.map +1 -0
- package/dist/accountPreferenceHeaders.js +5 -0
- package/dist/accountPreferenceHeaders.js.map +1 -0
- package/dist/client/preferencesPlugin.d.ts +17 -0
- package/dist/client/preferencesPlugin.d.ts.map +1 -0
- package/dist/{server/better-auth/preferencesClient.js → client/preferencesPlugin.js} +7 -7
- package/dist/client/preferencesPlugin.js.map +1 -0
- package/dist/server/account-data/OwnedModelsUncollected.d.ts +7 -0
- package/dist/server/account-data/OwnedModelsUncollected.d.ts.map +1 -0
- package/dist/server/account-data/OwnedModelsUncollected.js +7 -0
- package/dist/server/account-data/OwnedModelsUncollected.js.map +1 -0
- package/dist/server/account-data/OwnedTableCycle.d.ts +9 -0
- package/dist/server/account-data/OwnedTableCycle.d.ts.map +1 -0
- package/dist/server/account-data/OwnedTableCycle.js +9 -0
- package/dist/server/account-data/OwnedTableCycle.js.map +1 -0
- package/dist/server/account-data/UncoveredUserColumns.d.ts +19 -0
- package/dist/server/account-data/UncoveredUserColumns.d.ts.map +1 -0
- package/dist/server/account-data/UncoveredUserColumns.js +11 -0
- package/dist/server/account-data/UncoveredUserColumns.js.map +1 -0
- package/dist/server/account-data/checkCoverage.d.ts +8 -0
- package/dist/server/account-data/checkCoverage.d.ts.map +1 -0
- package/dist/server/account-data/checkCoverage.js +25 -0
- package/dist/server/account-data/checkCoverage.js.map +1 -0
- package/dist/server/account-data/eraseOrder.d.ts +7 -0
- package/dist/server/account-data/eraseOrder.d.ts.map +1 -0
- package/dist/server/account-data/eraseOrder.js +24 -0
- package/dist/server/account-data/eraseOrder.js.map +1 -0
- package/dist/server/account-data/eraseOwnedRows.d.ts +5 -0
- package/dist/server/account-data/eraseOwnedRows.d.ts.map +1 -0
- package/dist/server/account-data/eraseOwnedRows.js +27 -0
- package/dist/server/account-data/eraseOwnedRows.js.map +1 -0
- package/dist/server/account-data/exportOwnedRows.d.ts +7 -0
- package/dist/server/account-data/exportOwnedRows.d.ts.map +1 -0
- package/dist/server/account-data/exportOwnedRows.js +36 -0
- package/dist/server/account-data/exportOwnedRows.js.map +1 -0
- package/dist/server/account-data/foreignKeys.d.ts +27 -0
- package/dist/server/account-data/foreignKeys.d.ts.map +1 -0
- package/dist/server/account-data/foreignKeys.js +32 -0
- package/dist/server/account-data/foreignKeys.js.map +1 -0
- package/dist/server/account-data/ownedTables.d.ts +11 -0
- package/dist/server/account-data/ownedTables.d.ts.map +1 -0
- package/dist/server/account-data/ownedTables.js +41 -0
- package/dist/server/account-data/ownedTables.js.map +1 -0
- package/dist/server/account-preferences/Rows.d.ts.map +1 -1
- package/dist/server/account-preferences/Rows.js +2 -1
- package/dist/server/account-preferences/Rows.js.map +1 -1
- package/dist/server/better-auth/accountData.d.ts +42 -0
- package/dist/server/better-auth/accountData.d.ts.map +1 -0
- package/dist/server/better-auth/accountData.js +24 -0
- package/dist/server/better-auth/accountData.js.map +1 -0
- package/dist/server/better-auth/adapters/accountPreferenceOptions.d.ts.map +1 -1
- package/dist/server/better-auth/adapters/accountPreferenceOptions.js +3 -2
- package/dist/server/better-auth/adapters/accountPreferenceOptions.js.map +1 -1
- package/dist/server/better-auth/profileExport.d.ts +32 -0
- package/dist/server/better-auth/profileExport.d.ts.map +1 -0
- package/dist/server/better-auth/profileExport.js +53 -0
- package/dist/server/better-auth/profileExport.js.map +1 -0
- package/package.json +10 -10
- package/src/accountPreferenceHeaders.ts +4 -0
- package/src/client/preferencesPlugin.ts +40 -0
- package/src/server/account-data/OwnedModelsUncollected.ts +7 -0
- package/src/server/account-data/OwnedTableCycle.ts +9 -0
- package/src/server/account-data/UncoveredUserColumns.ts +14 -0
- package/src/server/account-data/checkCoverage.ts +28 -0
- package/src/server/account-data/eraseOrder.ts +36 -0
- package/src/server/account-data/eraseOwnedRows.ts +28 -0
- package/src/server/account-data/exportOwnedRows.ts +45 -0
- package/src/server/account-data/foreignKeys.ts +35 -0
- package/src/server/account-data/ownedTables.ts +43 -0
- package/src/server/account-preferences/Rows.ts +2 -1
- package/src/server/better-auth/accountData.ts +26 -0
- package/src/server/better-auth/adapters/accountPreferenceOptions.ts +3 -2
- package/src/server/better-auth/profileExport.ts +55 -0
- package/dist/server/account-export/check.d.ts +0 -15
- package/dist/server/account-export/check.d.ts.map +0 -1
- package/dist/server/account-export/check.js +0 -33
- package/dist/server/account-export/check.js.map +0 -1
- package/dist/server/accountExport.d.ts +0 -14
- package/dist/server/accountExport.d.ts.map +0 -1
- package/dist/server/accountExport.js +0 -15
- package/dist/server/accountExport.js.map +0 -1
- package/dist/server/better-auth/preferencesClient.d.ts +0 -3
- package/dist/server/better-auth/preferencesClient.d.ts.map +0 -1
- package/dist/server/better-auth/preferencesClient.js.map +0 -1
- package/dist/server/better-auth/userDataExport.d.ts +0 -38
- package/dist/server/better-auth/userDataExport.d.ts.map +0 -1
- package/dist/server/better-auth/userDataExport.js +0 -55
- package/dist/server/better-auth/userDataExport.js.map +0 -1
- package/dist/server/userDataExport.d.ts +0 -13
- package/dist/server/userDataExport.d.ts.map +0 -1
- package/dist/server/userDataExport.js +0 -2
- package/dist/server/userDataExport.js.map +0 -1
- package/src/server/account-export/check.ts +0 -38
- package/src/server/accountExport.ts +0 -40
- package/src/server/better-auth/preferencesClient.ts +0 -25
- package/src/server/better-auth/userDataExport.ts +0 -57
- package/src/server/userDataExport.ts +0 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.41.0 - 2026-11-21
|
|
4
|
+
|
|
5
|
+
### Breaking
|
|
6
|
+
|
|
7
|
+
- The account preferences plugin moves to a browser-safe path and a new name. Replace `import { preferencesClient } from "@shivaedev/identity/server/better-auth/preferencesClient.ts"` with `import { preferencesPlugin } from "@shivaedev/identity/client/preferencesPlugin.ts"` and call `preferencesPlugin()` where you called `preferencesClient()`. Its header names come from `accountPreferenceHeaders` in `@shivaedev/identity/accountPreferenceHeaders.ts`.
|
|
8
|
+
|
|
9
|
+
## 0.40.0 - 2026-11-21
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `accountData(declaration, reference?)` from `@shivaedev/identity/server/better-auth/accountData.ts` exports and erases a person's data from the owned models the host reports through sql's owner marks. `exportAccount(userId)` returns the person's auth profile, linked accounts and sessions without credentials, plus each owned model's rows of theirs encoded through its JSON variant, so a server-only field never appears. `eraseOwnedRows(userId)` deletes every owned row of the person inside the caller's transaction, in an order computed from PostgreSQL's foreign keys between the owned tables, and fails with `OwnedTableCycle` naming the tables before it deletes anything when `RESTRICT` or `NO ACTION` keys form a cycle. `check` fails with `UncoveredUserColumns` naming each `{ schema, table, column }` whose foreign key points at the auth user or an owned model's owner column but which is neither an owned model's owner column, `ON DELETE SET NULL`, nor part of Better Auth's tables; export and erase run it first. Without the host's `collectRepositoryModels` all three fail with `OwnedModelsUncollected`, naming the missing Layer, instead of passing with nothing owned.
|
|
14
|
+
- identity's account preferences mark their id as owner, so they are exported and erased with the person's other owned rows.
|
|
15
|
+
|
|
16
|
+
### Breaking
|
|
17
|
+
|
|
18
|
+
- `accountExport(registrations, reference?)` from `server/accountExport.ts`, `UserDataExport`, `UserExportTable` and `UserExportReference` from `server/userDataExport.ts`, `checkUserDataExports` and `UnregisteredUserExportTables` from `server/account-export/check.ts` are removed, and `betterAuthUserDataExport(options, schema)` from `server/better-auth/userDataExport.ts` becomes `profileExport(options, schema)` from `server/better-auth/profileExport.ts`, which returns the export Effect alone and which `accountData` includes as `account`. To migrate, mark each domain model's owner field with `owner` from `@shivaedev/sql/owner.ts`, give a table the application reads only through raw SQL a repository on a model with an owner mark so the host reports it, delete the per-domain registrations, and call `accountData(AppAuth)` in their place: `exportAccount` replaces `exportUser` and returns `{ account, owned }` instead of one entry per domain, and `check` replaces the registration check. Pass a customized user reference as `accountData`'s second argument instead of `accountExport`'s.
|
|
19
|
+
|
|
3
20
|
## 0.39.0 - 2026-11-21
|
|
4
21
|
|
|
5
22
|
### Added
|
package/README.md
CHANGED
|
@@ -145,16 +145,16 @@ export const preferencesModule = {
|
|
|
145
145
|
} satisfies AppModule;
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
-
To capture
|
|
148
|
+
To capture a client's defaults, enable `{ accountPreferences: true }` in `betterAuthMount` and install the Better Auth client plugin from `@shivaedev/identity/client/preferencesPlugin.ts`, which holds no server code:
|
|
149
149
|
|
|
150
150
|
```ts
|
|
151
151
|
import { createAuthClient } from "better-auth/client";
|
|
152
|
-
import {
|
|
152
|
+
import { preferencesPlugin } from "@shivaedev/identity/client/preferencesPlugin.ts";
|
|
153
153
|
|
|
154
|
-
export const auth = createAuthClient({ plugins: [
|
|
154
|
+
export const auth = createAuthClient({ plugins: [preferencesPlugin()] });
|
|
155
155
|
```
|
|
156
156
|
|
|
157
|
-
The
|
|
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
159
|
`AccountClock` from `@shivaedev/identity/server/account-clock/service.ts` is a per-request service. Its Layer requires `Subject`, and its initializer captures that subject's saved timezone. Register that Layer in the host's `requestServices` slot and `accountPreferencesStore` in global `services`. Each new request sees the current saved timezone. 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
|
|
|
@@ -559,16 +559,20 @@ export const secureCredential = Layer.succeed(SessionCredential, {
|
|
|
559
559
|
});
|
|
560
560
|
```
|
|
561
561
|
|
|
562
|
-
Pass that Layer to the Better Auth client as a plugin, and to `makeClient` through `storedCredential
|
|
562
|
+
Pass that Layer to the Better Auth client as a plugin, and to `makeClient` through `storedCredential`. When the mount captures [account preferences](#account-preferences-and-logical-days), install the same `preferencesPlugin()` the browser uses on the native auth client too, so the device's timezone and locale are captured at sign-in:
|
|
563
563
|
|
|
564
564
|
```ts
|
|
565
565
|
import { createAuthClient } from "better-auth/client";
|
|
566
566
|
import { Effect } from "effect";
|
|
567
567
|
import { makeClient } from "@shivaedev/contract/makeClient.ts";
|
|
568
568
|
import { sessionCredentialPlugin } from "@shivaedev/identity/client/adapters/sessionCredentialPlugin.ts";
|
|
569
|
+
import { preferencesPlugin } from "@shivaedev/identity/client/preferencesPlugin.ts";
|
|
569
570
|
import { storedCredential } from "@shivaedev/identity/client/SessionCredential.ts";
|
|
570
571
|
|
|
571
|
-
export const authClient = createAuthClient({
|
|
572
|
+
export const authClient = createAuthClient({
|
|
573
|
+
baseURL: publicOrigin,
|
|
574
|
+
plugins: [sessionCredentialPlugin(secureCredential), preferencesPlugin()],
|
|
575
|
+
});
|
|
572
576
|
const client = makeClient(contracts, { bearerToken: Effect.provide(storedCredential, secureCredential), registry, url: `${publicOrigin}/rpc` });
|
|
573
577
|
```
|
|
574
578
|
|
|
@@ -578,7 +582,7 @@ Native sign-out revokes the stored session. Signing in again while sending the c
|
|
|
578
582
|
|
|
579
583
|
Use `nativeOrigins` for bundled clients so their transport remains credential-free; other declared origins follow the sibling browser policy above.
|
|
580
584
|
|
|
581
|
-
The host answers native preflights with POST for RPC, GET and POST for auth
|
|
585
|
+
The host answers native preflights with POST for RPC, GET and POST for auth. RPC allows only the `Authorization` and `Content-Type` headers; auth also allows the two account preference headers, for native and sibling browser origins alike. Native responses echo the allowed origin exactly with `Vary: Origin`; auth responses expose `set-auth-token`. Native responses never enable CORS credentials. It strips cookies from admitted native requests before auth or RPC session resolution, so only the signed bearer session can authenticate them. This prevents native access from opening a cookie CSRF path, even if a caller sends a cookie. Resource authorization remains app-owned.
|
|
582
586
|
|
|
583
587
|
A WebView's live queries subscribe over the shared WebSocket client. `storedCredential` reads the port each time the socket connects: contract's `makeClient` sends the credential stored then as the socket's first frame, as the [contract guide](https://github.com/ShivaeDev/platform/blob/main/packages/contract/README.md#build-a-shared-websocket-client) describes, and connects without one when none is stored. A new client after each sign-in, sign-out or second sign-in, as React's `SessionBoundary` makes one per session, therefore carries the current credential. The host refuses a query's change stream over HTTP with `WebSocketRequired`. Over HTTP, use the WebView's own fetch with `credentials: "omit"` for commands, one-off reads and explicit NDJSON streams, and abort a stream's request to release server work; a buffering native HTTP bridge cannot deliver a stream incrementally. The host still validates trusted proxy peers and forwarded authority, enforces NDJSON and body limits, uses only transport credentials, redacts diagnostics and authorizes sessions. Native HTTP callers without an Origin can exercise bearer RPC with an origin policy that explicitly permits missing Origins.
|
|
584
588
|
|
|
@@ -1058,37 +1062,38 @@ export default Effect.gen(function* () {
|
|
|
1058
1062
|
});
|
|
1059
1063
|
```
|
|
1060
1064
|
|
|
1061
|
-
Run the auth schema migration before the app migration. Use `ON DELETE CASCADE` to delete owned rows with their user, or a nullable `user_id` and `ON DELETE SET NULL` to retain rows without an owner. `userReference` describes the default PostgreSQL mapping, so an application that customizes Better Auth's user table or id column must use its own mapping. Account reads and writes still go through identity; the foreign key grants no access to auth data. Quality's `boundaries/auth-sql` accepts these references while rejecting other auth SQL outside the configured owners.
|
|
1065
|
+
Run the auth schema migration before the app migration. Use `ON DELETE CASCADE` to delete owned rows with their user, or a nullable `user_id` and `ON DELETE SET NULL` to retain rows without an owner. Mark the column's model field with `owner` as well: the foreign key tells PostgreSQL what to do when the user row goes, and the owner mark tells identity which rows to [export and erase](#export-and-erase-a-persons-data), including in tables whose owner column has no foreign key. `userReference` describes the default PostgreSQL mapping, so an application that customizes Better Auth's user table or id column must use its own mapping. Account reads and writes still go through identity; the foreign key grants no access to auth data. Quality's `boundaries/auth-sql` accepts these references while rejecting other auth SQL outside the configured owners.
|
|
1062
1066
|
|
|
1063
|
-
###
|
|
1067
|
+
### Export and erase a person's data
|
|
1064
1068
|
|
|
1065
|
-
|
|
1069
|
+
Identity learns which rows belong to a person from the owner marks on the application's sql models: each model whose field is marked with `owner` from `@shivaedev/sql/owner.ts` and that has a repository is reported to the host, as the [sql README](https://github.com/ShivaeDev/platform/tree/main/packages/sql#the-field-that-names-a-rows-owner) describes. There is no registration per domain. Build the account data once from the application's auth declaration:
|
|
1066
1070
|
|
|
1067
1071
|
```ts
|
|
1068
|
-
import {
|
|
1069
|
-
import {
|
|
1070
|
-
import { accountExport } from "@shivaedev/identity/server/accountExport.ts";
|
|
1071
|
-
import { betterAuthUserDataExport } from "@shivaedev/identity/server/better-auth/userDataExport.ts";
|
|
1072
|
-
|
|
1073
|
-
const notesExport = {
|
|
1074
|
-
tables: [{ schema: "public", table: "notes" }],
|
|
1075
|
-
export: Effect.fn(function* (userId: string) {
|
|
1076
|
-
const sql = yield* SqlClient.SqlClient;
|
|
1077
|
-
return yield* sql<{ title: string }>`select title from notes where user_id = ${userId} order by title`;
|
|
1078
|
-
}),
|
|
1079
|
-
};
|
|
1072
|
+
import { accountData } from "@shivaedev/identity/server/better-auth/accountData.ts";
|
|
1073
|
+
import { AppAuth } from "#server/AppAuth.ts";
|
|
1080
1074
|
|
|
1081
|
-
const
|
|
1075
|
+
const data = accountData(AppAuth);
|
|
1082
1076
|
|
|
1083
|
-
const
|
|
1084
|
-
const
|
|
1077
|
+
const checkCoverage = data.check;
|
|
1078
|
+
const exportAccount = data.exportAccount;
|
|
1079
|
+
const eraseOwnedRows = data.eraseOwnedRows;
|
|
1085
1080
|
```
|
|
1086
1081
|
|
|
1087
|
-
`
|
|
1082
|
+
`exportAccount(userId)` returns `{ account, owned }`. `account` holds the person's profile fields, linked-account identifiers and session metadata from Better Auth's tables, with timestamps as native Effect UTC values; passwords, access tokens, refresh tokens and session tokens are left out by explicit field selection. `owned` holds one `{ table, rows }` entry per owned model, ordered by table, with every row whose owner field holds the user id, encoded through the model's `json` variant. A field without a JSON variant, such as a `serverOnly` field, is never read, so it cannot reach the export. A table with none of the person's rows keeps its empty entry. Identity's own account preferences are an owned model too.
|
|
1083
|
+
|
|
1084
|
+
`eraseOwnedRows(userId)` deletes every owned row of the person. It reads PostgreSQL's foreign keys between the owned tables and deletes the rows that reference a table before the rows they reference, so `RESTRICT` and `NO ACTION` keys between owned tables need no hand-kept order. It opens no transaction of its own: run it inside the caller's `transact` from `@shivaedev/sql/transact.ts`, and a failure anywhere in that transaction leaves every row in place. When `RESTRICT` or `NO ACTION` keys between owned tables form a cycle, it fails with `OwnedTableCycle` from `server/account-data/OwnedTableCycle.ts`, naming the tables as `schema.table`, before it deletes anything. It erases owned rows only; the auth user and Better Auth's own tables stay for the account deletion that runs after it.
|
|
1085
|
+
|
|
1086
|
+
`check` fails with `UncoveredUserColumns` from `server/account-data/UncoveredUserColumns.ts` when a column refers to the person but nothing covers it. A column refers to the person when its foreign key points at the auth user's id or at an owned model's owner column. It is covered when it is an owned model's owner column, when its foreign key is `ON DELETE SET NULL` (such a row, an authored-by row for example, is not the person's: it stays without them and is not in their export), or when it belongs to one of Better Auth's tables. The error's `columns` names each `{ schema, table, column }` once, from every schema. `exportAccount` and `eraseOwnedRows` run the check first, so a new column whose foreign key points directly at the person, or at an owned model's owner column, fails them until an owner mark or a `SET NULL` key covers it. Run `check` against the migrated database in a startup check or a PostgreSQL story too, after the application's repositories are built under `collectRepositoryModels` from `@shivaedev/sql/RepositoryModels.ts`; `appHost` provides that collector, so an operation it serves sees every owned model.
|
|
1087
|
+
|
|
1088
|
+
Know what the check does not see before you rely on the export:
|
|
1089
|
+
|
|
1090
|
+
- Every table Better Auth's options declare is exempt, plugin tables such as passkeys, two-factor secrets or organization members included, and `account` holds only the profile fields listed above, the user's linked accounts and their sessions. Plugin tables and extra user fields, such as the admin plugin's role and ban fields, are not in the export; an application that wants them adds them to the result in its own export handler.
|
|
1091
|
+
- A table that reaches the person only through another table's key, such as an attachments table whose key cascades from an owned notes table, passes the check and is not exported; erase removes its rows through the cascade when it deletes the notes. Give such a table an owner column and mark it, and it is exported and erased like any owned table.
|
|
1092
|
+
- A row that reaches the person only through an `ON DELETE SET NULL` column stays after the account is deleted, with that column set to null, and is not in the person's export.
|
|
1088
1093
|
|
|
1089
|
-
|
|
1094
|
+
Outside a host, a job or script must provide `collectRepositoryModels` itself and build its repositories under it. Without the collector no owned model is recorded, so `exportAccount`, `eraseOwnedRows` and `check` fail with `OwnedModelsUncollected` from `server/account-data/OwnedModelsUncollected.ts`, whose message names the missing Layer, instead of passing with nothing owned.
|
|
1090
1095
|
|
|
1091
|
-
|
|
1096
|
+
PostgreSQL sees only foreign keys, so a table whose owner column has none is covered by its owner mark alone, and a table the application reaches only through raw SQL needs a repository on a model with an owner mark to be exported and erased. The user reference is the auth declaration's user table, so a customized `user.modelName` needs nothing more, and its `id` column in the `public` schema; when the user's id lives elsewhere, pass that `{ schema, table, column }` as the second argument to `accountData`. The account handler supplies the authorized user's id; these server APIs do not authenticate callers.
|
|
1092
1097
|
|
|
1093
1098
|
### Signed-in story preconditions
|
|
1094
1099
|
|
|
@@ -1229,6 +1234,10 @@ Import the module that defines the name; there is no package-root entry. Paths b
|
|
|
1229
1234
|
| `server/better-auth/adapters/revokeUnadmitted.ts` | `RevokedSessions`: the `{ users, sessions }` counts of a revocation. |
|
|
1230
1235
|
| `server/better-auth/userProfiles.ts` | Public profile lookups for other users. |
|
|
1231
1236
|
| `server/better-auth/sweepExpiredSessions.ts` | `sweepExpiredSessions`: delete expired sessions through the application's SQL client and return the number removed. |
|
|
1237
|
+
| `server/better-auth/accountData.ts` | `accountData(declaration, reference?)`, returning `{ check, exportAccount, eraseOwnedRows }`: a person's account export, owned-row erasure and the coverage check, from the owned models the host reports. |
|
|
1238
|
+
| `server/account-data/UncoveredUserColumns.ts` | `UncoveredUserColumns`: the coverage failure naming each column that refers to a person without an owned model to cover it. |
|
|
1239
|
+
| `server/account-data/OwnedModelsUncollected.ts` | `OwnedModelsUncollected`: the failure of export, erase and check when no collector records the owned models. |
|
|
1240
|
+
| `server/account-data/OwnedTableCycle.ts` | `OwnedTableCycle`: the erase failure naming owned tables whose `RESTRICT` or `NO ACTION` keys form a cycle. |
|
|
1232
1241
|
| `server/better-auth/userReference.ts` | `userReference`: the default auth user table and id column for application foreign keys. |
|
|
1233
1242
|
| `server/better-auth/testDatabase.ts` | `authTestDatabase`: test-only identity/session readouts and faults for the default PostgreSQL auth schema. |
|
|
1234
1243
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountPreferenceHeaders.d.ts","sourceRoot":"","sources":["../src/accountPreferenceHeaders.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB;aACpC,MAAM,EAAE,2BAA2B;aACnC,QAAQ,EAAE,6BAA6B;CAC9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountPreferenceHeaders.js","sourceRoot":"","sources":["../src/accountPreferenceHeaders.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACvC,MAAM,EAAE,2BAA2B;IACnC,QAAQ,EAAE,6BAA6B;CAC9B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface PreferenceRequest {
|
|
2
|
+
readonly headers: Headers;
|
|
3
|
+
}
|
|
4
|
+
interface PreferenceFetchPlugin {
|
|
5
|
+
readonly hooks: {
|
|
6
|
+
readonly onRequest: (context: PreferenceRequest) => void;
|
|
7
|
+
};
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PreferencesPlugin {
|
|
12
|
+
readonly fetchPlugins: PreferenceFetchPlugin[];
|
|
13
|
+
readonly id: "identity-account-preferences";
|
|
14
|
+
}
|
|
15
|
+
export declare function preferencesPlugin(): PreferencesPlugin;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=preferencesPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preferencesPlugin.d.ts","sourceRoot":"","sources":["../../src/client/preferencesPlugin.ts"],"names":[],"mappings":"AAGA,UAAU,iBAAiB;IAC1B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC1B;AAED,UAAU,qBAAqB;IAC9B,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAA;KAAE,CAAC;IAC7E,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,YAAY,EAAE,qBAAqB,EAAE,CAAC;IAC/C,QAAQ,CAAC,EAAE,EAAE,8BAA8B,CAAC;CAC5C;AAED,wBAAgB,iBAAiB,IAAI,iBAAiB,CAqBrD"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import { accountPreferenceHeaders } from "#accountPreferenceHeaders.ts";
|
|
2
|
+
export function preferencesPlugin() {
|
|
2
3
|
return {
|
|
3
4
|
fetchPlugins: [
|
|
4
5
|
{
|
|
5
6
|
hooks: {
|
|
6
7
|
onRequest(context) {
|
|
8
|
+
// A server-rendered auth call would send the server's zone, so only a page or app shell sends one.
|
|
7
9
|
if (!("window" in globalThis)) {
|
|
8
|
-
return
|
|
10
|
+
return;
|
|
9
11
|
}
|
|
10
12
|
const { locale, timeZone } = new Intl.DateTimeFormat().resolvedOptions();
|
|
11
|
-
|
|
12
|
-
headers.set(
|
|
13
|
-
headers.set("x-platform-account-locale", locale);
|
|
14
|
-
return { ...context, headers };
|
|
13
|
+
context.headers.set(accountPreferenceHeaders.timezone, timeZone);
|
|
14
|
+
context.headers.set(accountPreferenceHeaders.locale, locale);
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
17
|
id: "identity-account-preferences",
|
|
@@ -21,4 +21,4 @@ export function preferencesClient() {
|
|
|
21
21
|
id: "identity-account-preferences",
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
//# sourceMappingURL=
|
|
24
|
+
//# sourceMappingURL=preferencesPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preferencesPlugin.js","sourceRoot":"","sources":["../../src/client/preferencesPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAkBxE,MAAM,UAAU,iBAAiB;IAChC,OAAO;QACN,YAAY,EAAE;YACb;gBACC,KAAK,EAAE;oBACN,SAAS,CAAC,OAAO;wBAChB,mGAAmG;wBACnG,IAAI,CAAC,CAAC,QAAQ,IAAI,UAAU,CAAC,EAAE,CAAC;4BAC/B,OAAO;wBACR,CAAC;wBACD,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC,eAAe,EAAE,CAAC;wBACzE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;wBACjE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;oBAC9D,CAAC;iBACD;gBACD,EAAE,EAAE,8BAA8B;gBAClC,IAAI,EAAE,8BAA8B;aACpC;SACD;QACD,EAAE,EAAE,8BAA8B;KAClC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
declare const OwnedModelsUncollected_base: Schema.Class<OwnedModelsUncollected, Schema.TaggedStruct<"OwnedModelsUncollected", {}>, import("effect/Cause").YieldableError>;
|
|
3
|
+
export declare class OwnedModelsUncollected extends OwnedModelsUncollected_base {
|
|
4
|
+
get message(): string;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=OwnedModelsUncollected.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OwnedModelsUncollected.d.ts","sourceRoot":"","sources":["../../../src/server/account-data/OwnedModelsUncollected.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;AAEhC,qBAAa,sBAAuB,SAAQ,2BAA0E;IACrH,IAAa,OAAO,WAEnB;CACD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export class OwnedModelsUncollected extends Schema.TaggedError()("OwnedModelsUncollected", {}) {
|
|
3
|
+
get message() {
|
|
4
|
+
return "No collector receives the owned models that repositories report, so identity cannot see what to export, erase or count as covered: provide collectRepositoryModels from @shivaedev/sql/RepositoryModels.ts before the repositories are built, as appHost does";
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=OwnedModelsUncollected.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OwnedModelsUncollected.js","sourceRoot":"","sources":["../../../src/server/account-data/OwnedModelsUncollected.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,OAAO,sBAAuB,SAAQ,MAAM,CAAC,WAAW,EAA0B,CAAC,wBAAwB,EAAE,EAAE,CAAC;IACrH,IAAa,OAAO;QACnB,OAAO,+PAA+P,CAAC;IACxQ,CAAC;CACD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
declare const OwnedTableCycle_base: Schema.Class<OwnedTableCycle, Schema.TaggedStruct<"OwnedTableCycle", {
|
|
3
|
+
readonly tables: Schema.$Array<Schema.String>;
|
|
4
|
+
}>, import("effect/Cause").YieldableError>;
|
|
5
|
+
export declare class OwnedTableCycle extends OwnedTableCycle_base {
|
|
6
|
+
get message(): string;
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=OwnedTableCycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OwnedTableCycle.d.ts","sourceRoot":"","sources":["../../../src/server/account-data/OwnedTableCycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;AAEhC,qBAAa,eAAgB,SAAQ,oBAEnC;IACD,IAAa,OAAO,WAEnB;CACD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export class OwnedTableCycle extends Schema.TaggedError()("OwnedTableCycle", {
|
|
3
|
+
tables: Schema.Array(Schema.String),
|
|
4
|
+
}) {
|
|
5
|
+
get message() {
|
|
6
|
+
return `Owned tables reference each other through RESTRICT or NO ACTION foreign keys in a cycle, so no order can erase them: ${this.tables.join(", ")}`;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=OwnedTableCycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OwnedTableCycle.js","sourceRoot":"","sources":["../../../src/server/account-data/OwnedTableCycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,OAAO,eAAgB,SAAQ,MAAM,CAAC,WAAW,EAAmB,CAAC,iBAAiB,EAAE;IAC7F,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;CACnC,CAAC;IACD,IAAa,OAAO;QACnB,OAAO,wHAAwH,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IACzJ,CAAC;CACD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
declare const TableColumn: Schema.Struct<{
|
|
3
|
+
readonly column: Schema.String;
|
|
4
|
+
readonly schema: Schema.String;
|
|
5
|
+
readonly table: Schema.String;
|
|
6
|
+
}>;
|
|
7
|
+
export type TableColumn = typeof TableColumn.Type;
|
|
8
|
+
declare const UncoveredUserColumns_base: Schema.Class<UncoveredUserColumns, Schema.TaggedStruct<"UncoveredUserColumns", {
|
|
9
|
+
readonly columns: Schema.$Array<Schema.Struct<{
|
|
10
|
+
readonly column: Schema.String;
|
|
11
|
+
readonly schema: Schema.String;
|
|
12
|
+
readonly table: Schema.String;
|
|
13
|
+
}>>;
|
|
14
|
+
}>, import("effect/Cause").YieldableError>;
|
|
15
|
+
export declare class UncoveredUserColumns extends UncoveredUserColumns_base {
|
|
16
|
+
get message(): string;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=UncoveredUserColumns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UncoveredUserColumns.d.ts","sourceRoot":"","sources":["../../../src/server/account-data/UncoveredUserColumns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,QAAA,MAAM,WAAW;;;;EAAwF,CAAC;AAE1G,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAC;;;;;;;;AAElD,qBAAa,oBAAqB,SAAQ,yBAExC;IACD,IAAa,OAAO,WAGnB;CACD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
const TableColumn = Schema.Struct({ column: Schema.String, schema: Schema.String, table: Schema.String });
|
|
3
|
+
export class UncoveredUserColumns extends Schema.TaggedError()("UncoveredUserColumns", {
|
|
4
|
+
columns: Schema.Array(TableColumn),
|
|
5
|
+
}) {
|
|
6
|
+
get message() {
|
|
7
|
+
const columns = this.columns.map(({ column, schema, table }) => `${schema}.${table}.${column}`).join(", ");
|
|
8
|
+
return `Columns refer to a person, but no owned model covers them: ${columns}. Mark the column's field with owner from @shivaedev/sql/owner.ts on a model that has a repository, or declare its foreign key ON DELETE SET NULL when the row stays without the person`;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=UncoveredUserColumns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UncoveredUserColumns.js","sourceRoot":"","sources":["../../../src/server/account-data/UncoveredUserColumns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AAI1G,MAAM,OAAO,oBAAqB,SAAQ,MAAM,CAAC,WAAW,EAAwB,CAAC,sBAAsB,EAAE;IAC5G,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC;CAClC,CAAC;IACD,IAAa,OAAO;QACnB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,GAAG,MAAM,IAAI,KAAK,IAAI,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3G,OAAO,8DAA8D,OAAO,yLAAyL,CAAC;IACvQ,CAAC;CACD"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { UncoveredUserColumns } from "#server/account-data/UncoveredUserColumns.ts";
|
|
3
|
+
export declare const checkCoverage: (reference: {
|
|
4
|
+
readonly column: string;
|
|
5
|
+
readonly schema: string;
|
|
6
|
+
readonly table: string;
|
|
7
|
+
}, authTables: ReadonlySet<string>) => Effect.Effect<undefined, import("./OwnedModelsUncollected.ts").OwnedModelsUncollected | import("effect/Schema").SchemaError | import("effect/sql/SqlError").SqlError | UncoveredUserColumns, import("effect/sql/SqlClient").SqlClient>;
|
|
8
|
+
//# sourceMappingURL=checkCoverage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkCoverage.d.ts","sourceRoot":"","sources":["../../../src/server/account-data/checkCoverage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAoB,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;AAStG,eAAO,MAAM,aAAa;;;;6QAexB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { foreignKeys } from "#server/account-data/foreignKeys.ts";
|
|
3
|
+
import { ownedTables } from "#server/account-data/ownedTables.ts";
|
|
4
|
+
import { UncoveredUserColumns } from "#server/account-data/UncoveredUserColumns.ts";
|
|
5
|
+
const SET_NULL = "n";
|
|
6
|
+
function key({ column, schema, table }) {
|
|
7
|
+
return `${schema}.${table}.${column}`;
|
|
8
|
+
}
|
|
9
|
+
// Identity's own tables are covered because the person's auth user row goes with the account and they reference it.
|
|
10
|
+
export const checkCoverage = Effect.fn("Identity.checkCoverage")(function* (reference, authTables) {
|
|
11
|
+
const owners = new Set((yield* ownedTables()).map(({ ownerKey }) => ownerKey));
|
|
12
|
+
const user = key(reference);
|
|
13
|
+
const uncovered = new Map();
|
|
14
|
+
for (const foreignKey of yield* foreignKeys()) {
|
|
15
|
+
const refersToPerson = key(foreignKey.target) === user || owners.has(key(foreignKey.target));
|
|
16
|
+
const covered = owners.has(key(foreignKey)) || foreignKey.onDelete === SET_NULL || (foreignKey.schema === reference.schema && authTables.has(foreignKey.table));
|
|
17
|
+
if (refersToPerson && !covered) {
|
|
18
|
+
uncovered.set(key(foreignKey), { column: foreignKey.column, schema: foreignKey.schema, table: foreignKey.table });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (uncovered.size > 0) {
|
|
22
|
+
return yield* new UncoveredUserColumns({ columns: [...uncovered.values()] });
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=checkCoverage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkCoverage.js","sourceRoot":"","sources":["../../../src/server/account-data/checkCoverage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAoB,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;AAEtG,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB,SAAS,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAe;IAClD,OAAO,GAAG,MAAM,IAAI,KAAK,IAAI,MAAM,EAAE,CAAC;AACvC,CAAC;AAED,oHAAoH;AACpH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,EAAE,CAAC,wBAAwB,CAAC,CAAC,QAAQ,CAAC,EAAE,SAAsB,EAAE,UAA+B;IAClI,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC/E,MAAM,IAAI,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC;IAC5B,MAAM,SAAS,GAAG,IAAI,GAAG,EAAuB,CAAC;IACjD,KAAK,MAAM,UAAU,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;QAC/C,MAAM,cAAc,GAAG,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,IAAI,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7F,MAAM,OAAO,GACZ,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,UAAU,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM,IAAI,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;QACjJ,IAAI,cAAc,IAAI,CAAC,OAAO,EAAE,CAAC;YAChC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC;QACnH,CAAC;IACF,CAAC;IACD,IAAI,SAAS,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC,CAAC,IAAI,oBAAoB,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IAC9E,CAAC;AACF,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Result } from "effect";
|
|
2
|
+
export interface Reference {
|
|
3
|
+
readonly source: string;
|
|
4
|
+
readonly target: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function eraseOrder(tables: readonly string[], references: readonly Reference[]): Result.Result<readonly string[], readonly string[]>;
|
|
7
|
+
//# sourceMappingURL=eraseOrder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eraseOrder.d.ts","sourceRoot":"","sources":["../../../src/server/account-data/eraseOrder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AA0BD,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,UAAU,EAAE,SAAS,SAAS,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,MAAM,EAAE,EAAE,SAAS,MAAM,EAAE,CAAC,CAI3I"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Result } from "effect";
|
|
2
|
+
// A table goes once nothing left references it, so the rows referencing a table are deleted before the table's rows.
|
|
3
|
+
function peel({ left, references }, order) {
|
|
4
|
+
const next = left.find((table) => !references.some(({ target }) => target === table));
|
|
5
|
+
if (next === undefined) {
|
|
6
|
+
return { left, order, references };
|
|
7
|
+
}
|
|
8
|
+
const remaining = { left: left.filter((table) => table !== next), references: references.filter(({ source }) => source !== next) };
|
|
9
|
+
return peel(remaining, [...order, next]);
|
|
10
|
+
}
|
|
11
|
+
// Dropping what references nothing left keeps the tables on a cycle and those between its tables.
|
|
12
|
+
function cycle({ left, references }) {
|
|
13
|
+
const sink = left.find((table) => !references.some(({ source }) => source === table));
|
|
14
|
+
if (sink === undefined) {
|
|
15
|
+
return left;
|
|
16
|
+
}
|
|
17
|
+
return cycle({ left: left.filter((table) => table !== sink), references: references.filter(({ target }) => target !== sink) });
|
|
18
|
+
}
|
|
19
|
+
export function eraseOrder(tables, references) {
|
|
20
|
+
const between = references.filter(({ source, target }) => source !== target && tables.includes(source) && tables.includes(target));
|
|
21
|
+
const peeled = peel({ left: tables, references: between }, []);
|
|
22
|
+
return peeled.left.length === 0 ? Result.succeed(peeled.order) : Result.fail(cycle(peeled));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=eraseOrder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eraseOrder.js","sourceRoot":"","sources":["../../../src/server/account-data/eraseOrder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAYhC,qHAAqH;AACrH,SAAS,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAa,EAAE,KAAwB;IACtE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC;IACtF,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;IACpC,CAAC;IACD,MAAM,SAAS,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC,EAAE,CAAC;IACnI,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,GAAG,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED,kGAAkG;AAClG,SAAS,KAAK,CAAC,EAAE,IAAI,EAAE,UAAU,EAAa;IAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC;IACtF,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC;AAChI,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAyB,EAAE,UAAgC;IACrF,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,KAAK,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IACnI,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;IAC/D,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;AAC7F,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { SqlClient } from "effect/sql";
|
|
3
|
+
import { OwnedTableCycle } from "#server/account-data/OwnedTableCycle.ts";
|
|
4
|
+
export declare const eraseOwnedRows: (userId: string) => Effect.Effect<undefined, import("./OwnedModelsUncollected.ts").OwnedModelsUncollected | OwnedTableCycle | import("effect/Schema").SchemaError | import("effect/sql/SqlError").SqlError, SqlClient.SqlClient>;
|
|
5
|
+
//# sourceMappingURL=eraseOwnedRows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eraseOwnedRows.d.ts","sourceRoot":"","sources":["../../../src/server/account-data/eraseOwnedRows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAO1E,eAAO,MAAM,cAAc,kOAgBzB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Effect, Result } from "effect";
|
|
2
|
+
import { SqlClient } from "effect/sql";
|
|
3
|
+
import { eraseOrder } from "#server/account-data/eraseOrder.ts";
|
|
4
|
+
import { foreignKeys } from "#server/account-data/foreignKeys.ts";
|
|
5
|
+
import { OwnedTableCycle } from "#server/account-data/OwnedTableCycle.ts";
|
|
6
|
+
import { ownedTables } from "#server/account-data/ownedTables.ts";
|
|
7
|
+
// A cascading or nulling key orders nothing: PostgreSQL resolves it whichever row goes first.
|
|
8
|
+
const ORDERING_ACTIONS = new Set(["a", "r"]);
|
|
9
|
+
// Runs on the caller's connection, so a surrounding transact erases everything or nothing.
|
|
10
|
+
export const eraseOwnedRows = Effect.fn("Identity.eraseOwnedRows")(function* (userId) {
|
|
11
|
+
const owned = yield* ownedTables();
|
|
12
|
+
const relations = [...new Set(owned.map(({ relation }) => relation))].sort((left, right) => left.localeCompare(right));
|
|
13
|
+
const references = (yield* foreignKeys())
|
|
14
|
+
.filter(({ onDelete }) => ORDERING_ACTIONS.has(onDelete))
|
|
15
|
+
.map(({ schema, table, target }) => ({ source: `${schema}.${table}`, target: `${target.schema}.${target.table}` }));
|
|
16
|
+
const order = eraseOrder(relations, references);
|
|
17
|
+
if (Result.isFailure(order)) {
|
|
18
|
+
return yield* new OwnedTableCycle({ tables: order.failure });
|
|
19
|
+
}
|
|
20
|
+
const sql = yield* SqlClient.SqlClient;
|
|
21
|
+
for (const relation of order.success) {
|
|
22
|
+
for (const { owner, table } of owned.filter((model) => model.relation === relation)) {
|
|
23
|
+
yield* sql `delete from ${sql(table)} where ${sql(owner.field)} = ${userId}`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=eraseOwnedRows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eraseOwnedRows.js","sourceRoot":"","sources":["../../../src/server/account-data/eraseOwnedRows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAElE,8FAA8F;AAC9F,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAE7C,2FAA2F;AAC3F,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,EAAE,CAAC,yBAAyB,CAAC,CAAC,QAAQ,CAAC,EAAE,MAAc;IAC3F,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IACnC,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;IACvH,MAAM,UAAU,GAAG,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;SACvC,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;SACxD,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;IACrH,MAAM,KAAK,GAAG,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAChD,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC,CAAC,IAAI,eAAe,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;IACD,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC;IACvC,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QACtC,KAAK,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,EAAE,CAAC;YACrF,KAAK,CAAC,CAAC,GAAG,CAAA,eAAe,GAAG,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,MAAM,EAAE,CAAC;QAC7E,CAAC;IACF,CAAC;AACF,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { SqlClient } from "effect/sql";
|
|
3
|
+
export declare const exportOwnedRows: (userId: string) => Effect.Effect<{
|
|
4
|
+
rows: readonly unknown[];
|
|
5
|
+
table: string;
|
|
6
|
+
}[], import("./OwnedModelsUncollected.ts").OwnedModelsUncollected | Schema.SchemaError | import("effect/sql/SqlError").SqlError, SqlClient.SqlClient>;
|
|
7
|
+
//# sourceMappingURL=exportOwnedRows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exportOwnedRows.d.ts","sourceRoot":"","sources":["../../../src/server/account-data/exportOwnedRows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAa,MAAM,QAAQ,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA8BvC,eAAO,MAAM,eAAe;;;qJAa1B,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Effect, Schema, SchemaAST } from "effect";
|
|
2
|
+
import { SqlClient } from "effect/sql";
|
|
3
|
+
import { groupColumns } from "@shivaedev/sql/adapters/groupColumns.ts";
|
|
4
|
+
import { sqlNameTransforms } from "@shivaedev/sql/sqlNameTransforms.ts";
|
|
5
|
+
import { storageSchema } from "@shivaedev/sql/storageSchema.ts";
|
|
6
|
+
import { ownedTables } from "#server/account-data/ownedTables.ts";
|
|
7
|
+
function exportedSchemas({ model }, names) {
|
|
8
|
+
const json = model.json.ast;
|
|
9
|
+
const properties = [];
|
|
10
|
+
const fields = {};
|
|
11
|
+
for (const property of SchemaAST.isObjects(json) ? json.propertySignatures : []) {
|
|
12
|
+
const field = typeof property.name === "string" ? model.fields[property.name] : undefined;
|
|
13
|
+
if (typeof property.name === "string" && field !== undefined) {
|
|
14
|
+
properties.push(property);
|
|
15
|
+
fields[property.name] = field;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
columns: groupColumns(fields),
|
|
20
|
+
json: Schema.make(new SchemaAST.Objects(properties, [])),
|
|
21
|
+
stored: Schema.make(storageSchema(Schema.Struct(fields), fields, names).ast),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export const exportOwnedRows = Effect.fn("Identity.exportOwnedRows")(function* (userId) {
|
|
25
|
+
const sql = yield* SqlClient.SqlClient;
|
|
26
|
+
const names = yield* sqlNameTransforms;
|
|
27
|
+
const owned = [...(yield* ownedTables())].sort((left, right) => left.table.localeCompare(right.table));
|
|
28
|
+
return yield* Effect.forEach(owned, (model) => Effect.gen(function* () {
|
|
29
|
+
const { columns, json, stored } = exportedSchemas(model, names);
|
|
30
|
+
const selected = sql.csv(columns.map(({ column }) => sql `${sql(column)}`));
|
|
31
|
+
const rows = yield* sql `select ${selected} from ${sql(model.table)} where ${sql(model.owner.field)} = ${userId}`;
|
|
32
|
+
const decoded = yield* Schema.decodeUnknownEffect(Schema.Array(stored))(rows);
|
|
33
|
+
return { rows: yield* Schema.encodeUnknownEffect(Schema.Array(json))(decoded), table: model.table };
|
|
34
|
+
}));
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=exportOwnedRows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exportOwnedRows.js","sourceRoot":"","sources":["../../../src/server/account-data/exportOwnedRows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAEvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAOlE,SAAS,eAAe,CAAC,EAAE,KAAK,EAAc,EAAE,KAA+C;IAC9F,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;IAC5B,MAAM,UAAU,GAAkC,EAAE,CAAC;IACrD,MAAM,MAAM,GAAsC,EAAE,CAAC;IACrD,KAAK,MAAM,QAAQ,IAAI,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACjF,MAAM,KAAK,GAAG,OAAO,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1F,IAAI,OAAO,QAAQ,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YAC9D,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC1B,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QAC/B,CAAC;IACF,CAAC;IACD,OAAO;QACN,OAAO,EAAE,YAAY,CAAC,MAAM,CAAC;QAC7B,IAAI,EAAE,MAAM,CAAC,IAAI,CAAW,IAAI,SAAS,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAClE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAW,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC;KACtF,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,EAAE,CAAC,0BAA0B,CAAC,CAAC,QAAQ,CAAC,EAAE,MAAc;IAC7F,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC;IACvC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,iBAAiB,CAAC;IACvC,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IACvG,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAC7C,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACnB,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAChE,MAAM,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3E,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,GAAG,CAAA,UAAU,QAAQ,SAAS,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,MAAM,EAAE,CAAC;QACjH,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC9E,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IACrG,CAAC,CAAC,CACF,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { SqlClient } from "effect/sql";
|
|
3
|
+
declare const ForeignKeyColumn: Schema.Struct<{
|
|
4
|
+
readonly column: Schema.String;
|
|
5
|
+
readonly onDelete: Schema.String;
|
|
6
|
+
readonly schema: Schema.String;
|
|
7
|
+
readonly table: Schema.String;
|
|
8
|
+
readonly target: Schema.Struct<{
|
|
9
|
+
readonly column: Schema.String;
|
|
10
|
+
readonly schema: Schema.String;
|
|
11
|
+
readonly table: Schema.String;
|
|
12
|
+
}>;
|
|
13
|
+
}>;
|
|
14
|
+
export type ForeignKeyColumn = typeof ForeignKeyColumn.Type;
|
|
15
|
+
export declare const foreignKeys: () => Effect.Effect<{
|
|
16
|
+
readonly column: string;
|
|
17
|
+
readonly onDelete: string;
|
|
18
|
+
readonly schema: string;
|
|
19
|
+
readonly table: string;
|
|
20
|
+
readonly target: {
|
|
21
|
+
readonly column: string;
|
|
22
|
+
readonly schema: string;
|
|
23
|
+
readonly table: string;
|
|
24
|
+
};
|
|
25
|
+
}[], Schema.SchemaError | import("effect/sql/SqlError").SqlError, SqlClient.SqlClient>;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=foreignKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"foreignKeys.d.ts","sourceRoot":"","sources":["../../../src/server/account-data/foreignKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,SAAS,EAAa,MAAM,YAAY,CAAC;AAElD,QAAA,MAAM,gBAAgB;;;;;;;;;;EAMpB,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAC;AAG5D,eAAO,MAAM,WAAW;;;;;;;;;;sFAoBtB,CAAC"}
|