@proteinjs/user 1.15.0 → 1.17.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/dist/generated/index.js +1 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/src/MachineAccount.d.ts.map +1 -1
- package/dist/src/MachineAccount.js +5 -0
- package/dist/src/MachineAccount.js.map +1 -1
- package/dist/src/tables/InviteTable.d.ts +7 -0
- package/dist/src/tables/InviteTable.d.ts.map +1 -1
- package/dist/src/tables/InviteTable.js +11 -0
- package/dist/src/tables/InviteTable.js.map +1 -1
- package/dist/src/tables/SessionTable.d.ts +7 -0
- package/dist/src/tables/SessionTable.d.ts.map +1 -1
- package/dist/src/tables/SessionTable.js +11 -0
- package/dist/src/tables/SessionTable.js.map +1 -1
- package/dist/src/tables/UserTable.d.ts +18 -2
- package/dist/src/tables/UserTable.d.ts.map +1 -1
- package/dist/src/tables/UserTable.js +1 -0
- package/dist/src/tables/UserTable.js.map +1 -1
- package/dist/test/recordTableDeclarations.test.d.ts +2 -0
- package/dist/test/recordTableDeclarations.test.d.ts.map +1 -0
- package/dist/test/recordTableDeclarations.test.js +39 -0
- package/dist/test/recordTableDeclarations.test.js.map +1 -0
- package/generated/index.ts +1 -1
- package/package.json +3 -3
- package/src/MachineAccount.ts +5 -0
- package/src/tables/InviteTable.ts +11 -0
- package/src/tables/SessionTable.ts +11 -0
- package/src/tables/UserTable.ts +18 -2
- package/test/recordTableDeclarations.test.ts +34 -0
package/src/tables/UserTable.ts
CHANGED
|
@@ -22,7 +22,9 @@ export type UserStatus = (typeof USER_STATUSES)[number];
|
|
|
22
22
|
* MACHINE ACCOUNTS (see `MachineAccount`) whose declared fields are reverted to source on every
|
|
23
23
|
* boot; human rows (flag null/false) are structurally untouchable by the boot sync. A machine
|
|
24
24
|
* account removed from source is deactivated — never deleted — so rows it is referenced from
|
|
25
|
-
* stay intact, and re-declaring it reactivates it.
|
|
25
|
+
* stay intact, and re-declaring it reactivates it. Whether a row IS a machine account is the
|
|
26
|
+
* explicit `machine` column (founder ruling 2026-09-02) — `isLoadedFromSource` is the sync's
|
|
27
|
+
* ownership flag and an input to the machine STAMP, never the question consumers ask.
|
|
26
28
|
*/
|
|
27
29
|
export type User = SourceRecord & {
|
|
28
30
|
name: string;
|
|
@@ -49,11 +51,24 @@ export type User = SourceRecord & {
|
|
|
49
51
|
* @proteinjs/db-file depends on @proteinjs/user, so a user→file reference would be circular.
|
|
50
52
|
*/
|
|
51
53
|
avatarFileId?: string | null;
|
|
54
|
+
/**
|
|
55
|
+
* The EXPLICIT machine-account marker (founder ruling 2026-09-02): true = this row is a
|
|
56
|
+
* MACHINE identity (CI signals, ops bridges — never a person); null/false = human, so
|
|
57
|
+
* pre-existing human rows need no backfill (the `status`/opt-out null-default convention).
|
|
58
|
+
* ONE owner for the question "is this a machine": every consumer (audience derivations,
|
|
59
|
+
* people lists, purge walkers) reads THIS column — never `isLoadedFromSource`, which merely
|
|
60
|
+
* says who SYNCS the row. Stamped true by the `MachineAccount` declaration on every boot
|
|
61
|
+
* (insert and adopt alike), by provisioning migrations for hand-made machine rows, and by
|
|
62
|
+
* the source-loaded backfill (user-server BackfillMachineFlagForSourceLoadedAccounts).
|
|
63
|
+
*/
|
|
64
|
+
machine?: boolean | null;
|
|
52
65
|
/**
|
|
53
66
|
* Account standing. Written ONLY by the SetUserStatus service (audited per change). New rows
|
|
54
67
|
* default to 'active'; rows predating the column read null, which every gate treats as active —
|
|
55
68
|
* only an explicit 'deactivated' is refused (authentication and session resolution both gate on
|
|
56
|
-
* it in @proteinjs/user-server).
|
|
69
|
+
* it in @proteinjs/user-server). The legacy null state is retired by the
|
|
70
|
+
* BackfillUserStatusActive migration (@proteinjs/user-server), so deployed rows read a real
|
|
71
|
+
* value; the gates' null-tolerant reading stays as the contract for any not-yet-migrated env.
|
|
57
72
|
*/
|
|
58
73
|
status?: UserStatus | null;
|
|
59
74
|
/** When the user asked for their account to be deleted. Written by the account-deletion flow only. */
|
|
@@ -137,6 +152,7 @@ export class UserTable extends Table<User> {
|
|
|
137
152
|
invitedBy: new ReferenceColumn<User>('invited_by', 'user', false, { maxLength: 255 }),
|
|
138
153
|
avatarEmoji: new StringColumn('avatar_emoji'),
|
|
139
154
|
avatarFileId: new StringColumn('avatar_file_id'),
|
|
155
|
+
machine: new BooleanColumn('machine'),
|
|
140
156
|
status: new StringColumn<UserStatus>('status', { defaultValue: async () => 'active' }, 16),
|
|
141
157
|
deleteRequestedAt: new DateTimeColumn('delete_requested_at'),
|
|
142
158
|
purgeAfter: new DateTimeColumn('purge_after'),
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { InviteTable } from '../src/tables/InviteTable';
|
|
2
|
+
import { SessionTable } from '../src/tables/SessionTable';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The admin row-scan declarations (founder admin review, v1.22): what the generic record table
|
|
6
|
+
* renders for invites and sessions is DECLARED here (Table.ui.recordTable.columns — db-ui
|
|
7
|
+
* renders what tables declare). Two pins with teeth:
|
|
8
|
+
* - the invite row scan never carries the redeemable `token` (auth material; hygiene) — it
|
|
9
|
+
* stays on the record form;
|
|
10
|
+
* - the session row scan never carries the serialized session blob (cookie material).
|
|
11
|
+
* Every declared name must be a real column property, so a schema rename cannot silently
|
|
12
|
+
* strand the declaration.
|
|
13
|
+
*/
|
|
14
|
+
describe('admin row-scan declarations', () => {
|
|
15
|
+
it('invite rows: who, by whom, until when — never the token', () => {
|
|
16
|
+
const table = new InviteTable();
|
|
17
|
+
const declared = table.ui?.recordTable?.columns;
|
|
18
|
+
expect(declared).toEqual(['email', 'invitedBy', 'tokenExpiresAt']);
|
|
19
|
+
expect(declared).not.toContain('token');
|
|
20
|
+
for (const column of declared!) {
|
|
21
|
+
expect((table.columns as any)[column]).toBeDefined();
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('session rows: whose, when it dies, which one — never the serialized session', () => {
|
|
26
|
+
const table = new SessionTable();
|
|
27
|
+
const declared = table.ui?.recordTable?.columns;
|
|
28
|
+
expect(declared).toEqual(['userEmail', 'expires', 'sessionId']);
|
|
29
|
+
expect(declared).not.toContain('session');
|
|
30
|
+
for (const column of declared!) {
|
|
31
|
+
expect((table.columns as any)[column]).toBeDefined();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
});
|