@sealkeeper/schema 0.4.3 → 0.4.5
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/dist/agent-name.d.ts +1 -1
- package/dist/agent-name.js +4 -4
- package/dist/api.d.ts +744 -27
- package/dist/api.js +232 -43
- package/dist/badge.d.ts +1 -0
- package/dist/badge.js +7 -0
- package/dist/credential.d.ts +186 -1
- package/dist/credential.js +55 -8
- package/dist/db/agents.d.ts +70 -0
- package/dist/db/agents.js +18 -0
- package/dist/db/client.d.ts +398 -0
- package/dist/db/client.js +2 -0
- package/dist/db/events.js +7 -0
- package/dist/db/index.d.ts +17 -1
- package/dist/db/index.js +5 -1
- package/dist/db/migrate.js +5 -1
- package/dist/db/migrator.d.ts +3 -1
- package/dist/db/migrator.js +8 -2
- package/dist/db/operator-identities.d.ts +211 -0
- package/dist/db/operator-identities.js +49 -0
- package/dist/db/operator-level-grants.d.ts +109 -0
- package/dist/db/operator-level-grants.js +30 -0
- package/dist/db/operator-slugs.d.ts +92 -0
- package/dist/db/operator-slugs.js +25 -0
- package/dist/db/operators.d.ts +119 -0
- package/dist/db/operators.js +30 -2
- package/dist/db/standing.d.ts +36 -0
- package/dist/db/standing.js +5 -0
- package/dist/db/task-claim-failures.d.ts +143 -0
- package/dist/db/task-claim-failures.js +37 -0
- package/dist/db/task-outcomes.d.ts +19 -0
- package/dist/db/task-outcomes.js +8 -1
- package/dist/db/tasks.d.ts +79 -0
- package/dist/db/tasks.js +19 -1
- package/dist/envelope.d.ts +3 -0
- package/dist/envelope.js +16 -11
- package/dist/goal.d.ts +149 -0
- package/dist/goal.js +171 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/moderation.d.ts +28 -0
- package/dist/moderation.js +450 -0
- package/dist/operator-domains.d.ts +104 -0
- package/dist/operator-domains.js +85 -0
- package/dist/policy.d.ts +4 -0
- package/dist/policy.js +10 -0
- package/dist/runtime.d.ts +17 -0
- package/dist/runtime.js +61 -0
- package/dist/seal-conformance.js +32 -1
- package/dist/standing.d.ts +68 -0
- package/dist/standing.js +132 -6
- package/dist/tasks.d.ts +23 -1
- package/dist/tasks.js +29 -5
- package/package.json +1 -1
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
export declare const operatorIdentities: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
2
|
+
name: "operator_identities";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
6
|
+
name: "created_at";
|
|
7
|
+
tableName: "operator_identities";
|
|
8
|
+
dataType: "date";
|
|
9
|
+
columnType: "PgTimestamp";
|
|
10
|
+
data: Date;
|
|
11
|
+
driverParam: string;
|
|
12
|
+
notNull: true;
|
|
13
|
+
hasDefault: true;
|
|
14
|
+
isPrimaryKey: false;
|
|
15
|
+
isAutoincrement: false;
|
|
16
|
+
hasRuntimeDefault: false;
|
|
17
|
+
enumValues: undefined;
|
|
18
|
+
baseColumn: never;
|
|
19
|
+
identity: undefined;
|
|
20
|
+
generated: undefined;
|
|
21
|
+
}, {}, {}>;
|
|
22
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
23
|
+
name: "updated_at";
|
|
24
|
+
tableName: "operator_identities";
|
|
25
|
+
dataType: "date";
|
|
26
|
+
columnType: "PgTimestamp";
|
|
27
|
+
data: Date;
|
|
28
|
+
driverParam: string;
|
|
29
|
+
notNull: true;
|
|
30
|
+
hasDefault: true;
|
|
31
|
+
isPrimaryKey: false;
|
|
32
|
+
isAutoincrement: false;
|
|
33
|
+
hasRuntimeDefault: false;
|
|
34
|
+
enumValues: undefined;
|
|
35
|
+
baseColumn: never;
|
|
36
|
+
identity: undefined;
|
|
37
|
+
generated: undefined;
|
|
38
|
+
}, {}, {}>;
|
|
39
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
40
|
+
name: "id";
|
|
41
|
+
tableName: "operator_identities";
|
|
42
|
+
dataType: "string";
|
|
43
|
+
columnType: "PgUUID";
|
|
44
|
+
data: string;
|
|
45
|
+
driverParam: string;
|
|
46
|
+
notNull: true;
|
|
47
|
+
hasDefault: true;
|
|
48
|
+
isPrimaryKey: true;
|
|
49
|
+
isAutoincrement: false;
|
|
50
|
+
hasRuntimeDefault: false;
|
|
51
|
+
enumValues: undefined;
|
|
52
|
+
baseColumn: never;
|
|
53
|
+
identity: undefined;
|
|
54
|
+
generated: undefined;
|
|
55
|
+
}, {}, {}>;
|
|
56
|
+
operatorId: import("drizzle-orm/pg-core").PgColumn<{
|
|
57
|
+
name: "operator_id";
|
|
58
|
+
tableName: "operator_identities";
|
|
59
|
+
dataType: "string";
|
|
60
|
+
columnType: "PgUUID";
|
|
61
|
+
data: string;
|
|
62
|
+
driverParam: string;
|
|
63
|
+
notNull: true;
|
|
64
|
+
hasDefault: false;
|
|
65
|
+
isPrimaryKey: false;
|
|
66
|
+
isAutoincrement: false;
|
|
67
|
+
hasRuntimeDefault: false;
|
|
68
|
+
enumValues: undefined;
|
|
69
|
+
baseColumn: never;
|
|
70
|
+
identity: undefined;
|
|
71
|
+
generated: undefined;
|
|
72
|
+
}, {}, {}>;
|
|
73
|
+
kind: import("drizzle-orm/pg-core").PgColumn<{
|
|
74
|
+
name: "kind";
|
|
75
|
+
tableName: "operator_identities";
|
|
76
|
+
dataType: "string";
|
|
77
|
+
columnType: "PgText";
|
|
78
|
+
data: string;
|
|
79
|
+
driverParam: string;
|
|
80
|
+
notNull: true;
|
|
81
|
+
hasDefault: false;
|
|
82
|
+
isPrimaryKey: false;
|
|
83
|
+
isAutoincrement: false;
|
|
84
|
+
hasRuntimeDefault: false;
|
|
85
|
+
enumValues: [string, ...string[]];
|
|
86
|
+
baseColumn: never;
|
|
87
|
+
identity: undefined;
|
|
88
|
+
generated: undefined;
|
|
89
|
+
}, {}, {}>;
|
|
90
|
+
provider: import("drizzle-orm/pg-core").PgColumn<{
|
|
91
|
+
name: "provider";
|
|
92
|
+
tableName: "operator_identities";
|
|
93
|
+
dataType: "string";
|
|
94
|
+
columnType: "PgText";
|
|
95
|
+
data: string;
|
|
96
|
+
driverParam: string;
|
|
97
|
+
notNull: true;
|
|
98
|
+
hasDefault: false;
|
|
99
|
+
isPrimaryKey: false;
|
|
100
|
+
isAutoincrement: false;
|
|
101
|
+
hasRuntimeDefault: false;
|
|
102
|
+
enumValues: [string, ...string[]];
|
|
103
|
+
baseColumn: never;
|
|
104
|
+
identity: undefined;
|
|
105
|
+
generated: undefined;
|
|
106
|
+
}, {}, {}>;
|
|
107
|
+
subject: import("drizzle-orm/pg-core").PgColumn<{
|
|
108
|
+
name: "subject";
|
|
109
|
+
tableName: "operator_identities";
|
|
110
|
+
dataType: "string";
|
|
111
|
+
columnType: "PgText";
|
|
112
|
+
data: string;
|
|
113
|
+
driverParam: string;
|
|
114
|
+
notNull: true;
|
|
115
|
+
hasDefault: false;
|
|
116
|
+
isPrimaryKey: false;
|
|
117
|
+
isAutoincrement: false;
|
|
118
|
+
hasRuntimeDefault: false;
|
|
119
|
+
enumValues: [string, ...string[]];
|
|
120
|
+
baseColumn: never;
|
|
121
|
+
identity: undefined;
|
|
122
|
+
generated: undefined;
|
|
123
|
+
}, {}, {}>;
|
|
124
|
+
subjectHash: import("drizzle-orm/pg-core").PgColumn<{
|
|
125
|
+
name: "subject_hash";
|
|
126
|
+
tableName: "operator_identities";
|
|
127
|
+
dataType: "string";
|
|
128
|
+
columnType: "PgText";
|
|
129
|
+
data: string;
|
|
130
|
+
driverParam: string;
|
|
131
|
+
notNull: true;
|
|
132
|
+
hasDefault: false;
|
|
133
|
+
isPrimaryKey: false;
|
|
134
|
+
isAutoincrement: false;
|
|
135
|
+
hasRuntimeDefault: false;
|
|
136
|
+
enumValues: [string, ...string[]];
|
|
137
|
+
baseColumn: never;
|
|
138
|
+
identity: undefined;
|
|
139
|
+
generated: undefined;
|
|
140
|
+
}, {}, {}>;
|
|
141
|
+
token: import("drizzle-orm/pg-core").PgColumn<{
|
|
142
|
+
name: "token";
|
|
143
|
+
tableName: "operator_identities";
|
|
144
|
+
dataType: "string";
|
|
145
|
+
columnType: "PgText";
|
|
146
|
+
data: string;
|
|
147
|
+
driverParam: string;
|
|
148
|
+
notNull: false;
|
|
149
|
+
hasDefault: false;
|
|
150
|
+
isPrimaryKey: false;
|
|
151
|
+
isAutoincrement: false;
|
|
152
|
+
hasRuntimeDefault: false;
|
|
153
|
+
enumValues: [string, ...string[]];
|
|
154
|
+
baseColumn: never;
|
|
155
|
+
identity: undefined;
|
|
156
|
+
generated: undefined;
|
|
157
|
+
}, {}, {}>;
|
|
158
|
+
verifiedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
159
|
+
name: "verified_at";
|
|
160
|
+
tableName: "operator_identities";
|
|
161
|
+
dataType: "date";
|
|
162
|
+
columnType: "PgTimestamp";
|
|
163
|
+
data: Date;
|
|
164
|
+
driverParam: string;
|
|
165
|
+
notNull: false;
|
|
166
|
+
hasDefault: false;
|
|
167
|
+
isPrimaryKey: false;
|
|
168
|
+
isAutoincrement: false;
|
|
169
|
+
hasRuntimeDefault: false;
|
|
170
|
+
enumValues: undefined;
|
|
171
|
+
baseColumn: never;
|
|
172
|
+
identity: undefined;
|
|
173
|
+
generated: undefined;
|
|
174
|
+
}, {}, {}>;
|
|
175
|
+
lastCheckedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
176
|
+
name: "last_checked_at";
|
|
177
|
+
tableName: "operator_identities";
|
|
178
|
+
dataType: "date";
|
|
179
|
+
columnType: "PgTimestamp";
|
|
180
|
+
data: Date;
|
|
181
|
+
driverParam: string;
|
|
182
|
+
notNull: false;
|
|
183
|
+
hasDefault: false;
|
|
184
|
+
isPrimaryKey: false;
|
|
185
|
+
isAutoincrement: false;
|
|
186
|
+
hasRuntimeDefault: false;
|
|
187
|
+
enumValues: undefined;
|
|
188
|
+
baseColumn: never;
|
|
189
|
+
identity: undefined;
|
|
190
|
+
generated: undefined;
|
|
191
|
+
}, {}, {}>;
|
|
192
|
+
lapsedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
193
|
+
name: "lapsed_at";
|
|
194
|
+
tableName: "operator_identities";
|
|
195
|
+
dataType: "date";
|
|
196
|
+
columnType: "PgTimestamp";
|
|
197
|
+
data: Date;
|
|
198
|
+
driverParam: string;
|
|
199
|
+
notNull: false;
|
|
200
|
+
hasDefault: false;
|
|
201
|
+
isPrimaryKey: false;
|
|
202
|
+
isAutoincrement: false;
|
|
203
|
+
hasRuntimeDefault: false;
|
|
204
|
+
enumValues: undefined;
|
|
205
|
+
baseColumn: never;
|
|
206
|
+
identity: undefined;
|
|
207
|
+
generated: undefined;
|
|
208
|
+
}, {}, {}>;
|
|
209
|
+
};
|
|
210
|
+
dialect: 'pg';
|
|
211
|
+
}>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { sql } from 'drizzle-orm';
|
|
2
|
+
import { check, index, pgTable, text, timestamp, unique, uniqueIndex, uuid, } from 'drizzle-orm/pg-core';
|
|
3
|
+
import { operators } from './operators.js';
|
|
4
|
+
import { timestamps } from './timestamps.js';
|
|
5
|
+
/*
|
|
6
|
+
* Operator identities (VOU-185). One row per identity an operator links,
|
|
7
|
+
* today only kind 'dns', a domain proven by a TXT record at
|
|
8
|
+
* _sealkeeper.<domain> (apps/api/src/operator-domains.ts). VOU-149 adds
|
|
9
|
+
* kind 'oidc' rows to the same table.
|
|
10
|
+
*
|
|
11
|
+
* subject is the domain, lower case, and subject_hash its SHA-256,
|
|
12
|
+
* base64url, the hash a SEAL carries. token is the value the TXT record
|
|
13
|
+
* must hold. It proves control of the domain and nothing else, but it is
|
|
14
|
+
* never logged. provider is the attester's URL, SealKeeper itself for dns.
|
|
15
|
+
*
|
|
16
|
+
* verified_at is the last check that found the record, null until the
|
|
17
|
+
* first. last_checked_at is the last check of any result. lapsed_at is the
|
|
18
|
+
* first check that missed the record after it was verified, cleared when a
|
|
19
|
+
* check finds it again. The identity counts as verified from verified_at
|
|
20
|
+
* until lapsed_at plus the grace period (OPERATOR_VERIFICATION). An operator
|
|
21
|
+
* adds a domain once, and one domain is verified for one operator at a
|
|
22
|
+
* time.
|
|
23
|
+
*/
|
|
24
|
+
export const operatorIdentities = pgTable('operator_identities', {
|
|
25
|
+
id: uuid('id').primaryKey().defaultRandom(),
|
|
26
|
+
operatorId: uuid('operator_id')
|
|
27
|
+
.notNull()
|
|
28
|
+
.references(() => operators.id),
|
|
29
|
+
kind: text('kind').notNull(),
|
|
30
|
+
provider: text('provider').notNull(),
|
|
31
|
+
subject: text('subject').notNull(),
|
|
32
|
+
subjectHash: text('subject_hash').notNull(),
|
|
33
|
+
token: text('token'),
|
|
34
|
+
verifiedAt: timestamp('verified_at', { withTimezone: true }),
|
|
35
|
+
lastCheckedAt: timestamp('last_checked_at', { withTimezone: true }),
|
|
36
|
+
lapsedAt: timestamp('lapsed_at', { withTimezone: true }),
|
|
37
|
+
...timestamps,
|
|
38
|
+
}, (t) => [
|
|
39
|
+
unique('operator_identities_operator_kind_subject_unique').on(t.operatorId, t.kind, t.subject),
|
|
40
|
+
// One operator at a time holds a verified subject.
|
|
41
|
+
uniqueIndex('operator_identities_verified_subject_idx')
|
|
42
|
+
.on(t.kind, t.subject)
|
|
43
|
+
.where(sql `${t.verifiedAt} is not null`),
|
|
44
|
+
// The daily recheck's pick, verified rows by their last check.
|
|
45
|
+
index('operator_identities_recheck_idx')
|
|
46
|
+
.on(t.lastCheckedAt)
|
|
47
|
+
.where(sql `${t.verifiedAt} is not null`),
|
|
48
|
+
check('operator_identities_kind', sql `${t.kind} in ('dns')`),
|
|
49
|
+
]);
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export declare const operatorLevelGrants: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
2
|
+
name: "operator_level_grants";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
6
|
+
name: "created_at";
|
|
7
|
+
tableName: "operator_level_grants";
|
|
8
|
+
dataType: "date";
|
|
9
|
+
columnType: "PgTimestamp";
|
|
10
|
+
data: Date;
|
|
11
|
+
driverParam: string;
|
|
12
|
+
notNull: true;
|
|
13
|
+
hasDefault: true;
|
|
14
|
+
isPrimaryKey: false;
|
|
15
|
+
isAutoincrement: false;
|
|
16
|
+
hasRuntimeDefault: false;
|
|
17
|
+
enumValues: undefined;
|
|
18
|
+
baseColumn: never;
|
|
19
|
+
identity: undefined;
|
|
20
|
+
generated: undefined;
|
|
21
|
+
}, {}, {}>;
|
|
22
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
23
|
+
name: "updated_at";
|
|
24
|
+
tableName: "operator_level_grants";
|
|
25
|
+
dataType: "date";
|
|
26
|
+
columnType: "PgTimestamp";
|
|
27
|
+
data: Date;
|
|
28
|
+
driverParam: string;
|
|
29
|
+
notNull: true;
|
|
30
|
+
hasDefault: true;
|
|
31
|
+
isPrimaryKey: false;
|
|
32
|
+
isAutoincrement: false;
|
|
33
|
+
hasRuntimeDefault: false;
|
|
34
|
+
enumValues: undefined;
|
|
35
|
+
baseColumn: never;
|
|
36
|
+
identity: undefined;
|
|
37
|
+
generated: undefined;
|
|
38
|
+
}, {}, {}>;
|
|
39
|
+
operatorId: import("drizzle-orm/pg-core").PgColumn<{
|
|
40
|
+
name: "operator_id";
|
|
41
|
+
tableName: "operator_level_grants";
|
|
42
|
+
dataType: "string";
|
|
43
|
+
columnType: "PgUUID";
|
|
44
|
+
data: string;
|
|
45
|
+
driverParam: string;
|
|
46
|
+
notNull: true;
|
|
47
|
+
hasDefault: false;
|
|
48
|
+
isPrimaryKey: false;
|
|
49
|
+
isAutoincrement: false;
|
|
50
|
+
hasRuntimeDefault: false;
|
|
51
|
+
enumValues: undefined;
|
|
52
|
+
baseColumn: never;
|
|
53
|
+
identity: undefined;
|
|
54
|
+
generated: undefined;
|
|
55
|
+
}, {}, {}>;
|
|
56
|
+
agentId: import("drizzle-orm/pg-core").PgColumn<{
|
|
57
|
+
name: "agent_id";
|
|
58
|
+
tableName: "operator_level_grants";
|
|
59
|
+
dataType: "string";
|
|
60
|
+
columnType: "PgText";
|
|
61
|
+
data: string;
|
|
62
|
+
driverParam: string;
|
|
63
|
+
notNull: true;
|
|
64
|
+
hasDefault: false;
|
|
65
|
+
isPrimaryKey: false;
|
|
66
|
+
isAutoincrement: false;
|
|
67
|
+
hasRuntimeDefault: false;
|
|
68
|
+
enumValues: [string, ...string[]];
|
|
69
|
+
baseColumn: never;
|
|
70
|
+
identity: undefined;
|
|
71
|
+
generated: undefined;
|
|
72
|
+
}, {}, {}>;
|
|
73
|
+
level: import("drizzle-orm/pg-core").PgColumn<{
|
|
74
|
+
name: "level";
|
|
75
|
+
tableName: "operator_level_grants";
|
|
76
|
+
dataType: "string";
|
|
77
|
+
columnType: "PgText";
|
|
78
|
+
data: string;
|
|
79
|
+
driverParam: string;
|
|
80
|
+
notNull: true;
|
|
81
|
+
hasDefault: false;
|
|
82
|
+
isPrimaryKey: false;
|
|
83
|
+
isAutoincrement: false;
|
|
84
|
+
hasRuntimeDefault: false;
|
|
85
|
+
enumValues: [string, ...string[]];
|
|
86
|
+
baseColumn: never;
|
|
87
|
+
identity: undefined;
|
|
88
|
+
generated: undefined;
|
|
89
|
+
}, {}, {}>;
|
|
90
|
+
grantedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
91
|
+
name: "granted_at";
|
|
92
|
+
tableName: "operator_level_grants";
|
|
93
|
+
dataType: "date";
|
|
94
|
+
columnType: "PgTimestamp";
|
|
95
|
+
data: Date;
|
|
96
|
+
driverParam: string;
|
|
97
|
+
notNull: true;
|
|
98
|
+
hasDefault: false;
|
|
99
|
+
isPrimaryKey: false;
|
|
100
|
+
isAutoincrement: false;
|
|
101
|
+
hasRuntimeDefault: false;
|
|
102
|
+
enumValues: undefined;
|
|
103
|
+
baseColumn: never;
|
|
104
|
+
identity: undefined;
|
|
105
|
+
generated: undefined;
|
|
106
|
+
}, {}, {}>;
|
|
107
|
+
};
|
|
108
|
+
dialect: 'pg';
|
|
109
|
+
}>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { sql } from 'drizzle-orm';
|
|
2
|
+
import { check, index, pgTable, primaryKey, text, timestamp, uuid, } from 'drizzle-orm/pg-core';
|
|
3
|
+
import { timestamps } from './timestamps.js';
|
|
4
|
+
/*
|
|
5
|
+
* The operator silver cap (VOU-182). One row per agent that took one of its
|
|
6
|
+
* operator's slots at a level, today only silver. The scoring run writes a
|
|
7
|
+
* row the first time an agent earns the level, when the operator has fewer
|
|
8
|
+
* than OPERATOR_SILVER_CAP.agents rows with granted_at in the last
|
|
9
|
+
* OPERATOR_SILVER_CAP.days days, and holds the agent at bronze otherwise
|
|
10
|
+
* (apps/api/src/silver-cap.ts). An agent keeps its row through dormancy and
|
|
11
|
+
* version changes.
|
|
12
|
+
*
|
|
13
|
+
* No foreign key to agents or operators. The row outlives the agent, so
|
|
14
|
+
* deleting an agent and registering it again does not free a slot. After
|
|
15
|
+
* the operator deletes its account the rows stay until the scoring run
|
|
16
|
+
* purges them with the deleted_operators hold. granted_at is the run's
|
|
17
|
+
* clock, the one the cap counts on.
|
|
18
|
+
*/
|
|
19
|
+
export const operatorLevelGrants = pgTable('operator_level_grants', {
|
|
20
|
+
operatorId: uuid('operator_id').notNull(),
|
|
21
|
+
agentId: text('agent_id').notNull(),
|
|
22
|
+
level: text('level').notNull(),
|
|
23
|
+
grantedAt: timestamp('granted_at', { withTimezone: true }).notNull(),
|
|
24
|
+
...timestamps,
|
|
25
|
+
}, (t) => [
|
|
26
|
+
primaryKey({ columns: [t.operatorId, t.agentId, t.level] }),
|
|
27
|
+
// The cap's count, an operator's grants of one level by date.
|
|
28
|
+
index('operator_level_grants_operator_level_granted_at_idx').on(t.operatorId, t.level, t.grantedAt),
|
|
29
|
+
check('operator_level_grants_level', sql `${t.level} in ('silver')`),
|
|
30
|
+
]);
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export declare const operatorSlugs: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
2
|
+
name: "operator_slugs";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
6
|
+
name: "created_at";
|
|
7
|
+
tableName: "operator_slugs";
|
|
8
|
+
dataType: "date";
|
|
9
|
+
columnType: "PgTimestamp";
|
|
10
|
+
data: Date;
|
|
11
|
+
driverParam: string;
|
|
12
|
+
notNull: true;
|
|
13
|
+
hasDefault: true;
|
|
14
|
+
isPrimaryKey: false;
|
|
15
|
+
isAutoincrement: false;
|
|
16
|
+
hasRuntimeDefault: false;
|
|
17
|
+
enumValues: undefined;
|
|
18
|
+
baseColumn: never;
|
|
19
|
+
identity: undefined;
|
|
20
|
+
generated: undefined;
|
|
21
|
+
}, {}, {}>;
|
|
22
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
23
|
+
name: "updated_at";
|
|
24
|
+
tableName: "operator_slugs";
|
|
25
|
+
dataType: "date";
|
|
26
|
+
columnType: "PgTimestamp";
|
|
27
|
+
data: Date;
|
|
28
|
+
driverParam: string;
|
|
29
|
+
notNull: true;
|
|
30
|
+
hasDefault: true;
|
|
31
|
+
isPrimaryKey: false;
|
|
32
|
+
isAutoincrement: false;
|
|
33
|
+
hasRuntimeDefault: false;
|
|
34
|
+
enumValues: undefined;
|
|
35
|
+
baseColumn: never;
|
|
36
|
+
identity: undefined;
|
|
37
|
+
generated: undefined;
|
|
38
|
+
}, {}, {}>;
|
|
39
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
40
|
+
name: "id";
|
|
41
|
+
tableName: "operator_slugs";
|
|
42
|
+
dataType: "number";
|
|
43
|
+
columnType: "PgBigSerial53";
|
|
44
|
+
data: number;
|
|
45
|
+
driverParam: number;
|
|
46
|
+
notNull: true;
|
|
47
|
+
hasDefault: true;
|
|
48
|
+
isPrimaryKey: true;
|
|
49
|
+
isAutoincrement: false;
|
|
50
|
+
hasRuntimeDefault: false;
|
|
51
|
+
enumValues: undefined;
|
|
52
|
+
baseColumn: never;
|
|
53
|
+
identity: undefined;
|
|
54
|
+
generated: undefined;
|
|
55
|
+
}, {}, {}>;
|
|
56
|
+
operatorId: import("drizzle-orm/pg-core").PgColumn<{
|
|
57
|
+
name: "operator_id";
|
|
58
|
+
tableName: "operator_slugs";
|
|
59
|
+
dataType: "string";
|
|
60
|
+
columnType: "PgUUID";
|
|
61
|
+
data: string;
|
|
62
|
+
driverParam: string;
|
|
63
|
+
notNull: false;
|
|
64
|
+
hasDefault: false;
|
|
65
|
+
isPrimaryKey: false;
|
|
66
|
+
isAutoincrement: false;
|
|
67
|
+
hasRuntimeDefault: false;
|
|
68
|
+
enumValues: undefined;
|
|
69
|
+
baseColumn: never;
|
|
70
|
+
identity: undefined;
|
|
71
|
+
generated: undefined;
|
|
72
|
+
}, {}, {}>;
|
|
73
|
+
oldSlug: import("drizzle-orm/pg-core").PgColumn<{
|
|
74
|
+
name: "old_slug";
|
|
75
|
+
tableName: "operator_slugs";
|
|
76
|
+
dataType: "string";
|
|
77
|
+
columnType: "PgText";
|
|
78
|
+
data: string;
|
|
79
|
+
driverParam: string;
|
|
80
|
+
notNull: true;
|
|
81
|
+
hasDefault: false;
|
|
82
|
+
isPrimaryKey: false;
|
|
83
|
+
isAutoincrement: false;
|
|
84
|
+
hasRuntimeDefault: false;
|
|
85
|
+
enumValues: [string, ...string[]];
|
|
86
|
+
baseColumn: never;
|
|
87
|
+
identity: undefined;
|
|
88
|
+
generated: undefined;
|
|
89
|
+
}, {}, {}>;
|
|
90
|
+
};
|
|
91
|
+
dialect: 'pg';
|
|
92
|
+
}>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { bigserial, index, pgTable, text, uuid } from 'drizzle-orm/pg-core';
|
|
2
|
+
import { operators } from './operators.js';
|
|
3
|
+
import { timestamps } from './timestamps.js';
|
|
4
|
+
// One row per operator slug change, holding the slug given up. For
|
|
5
|
+
// SLUG_REDIRECT_DAYS after created_at a handle with the old slug answers
|
|
6
|
+
// 404 renamed with the new handle, and no other operator can take the old
|
|
7
|
+
// slug. The operator itself can take it back.
|
|
8
|
+
//
|
|
9
|
+
// operator_id is null once the operator is deleted. deleteOperator adds a
|
|
10
|
+
// row for its current slug then and clears operator_id on the rows still
|
|
11
|
+
// inside their hold, so those slugs stay held for everyone for the rest of
|
|
12
|
+
// SLUG_REDIRECT_DAYS. With no operator to follow, a handle with one of them
|
|
13
|
+
// answers 404 not_found. The row keeps only the slug string and its dates.
|
|
14
|
+
//
|
|
15
|
+
// The scoring run deletes every row once SLUG_REDIRECT_DAYS are up, with
|
|
16
|
+
// an operator or without, since past that it redirects and holds nothing.
|
|
17
|
+
export const operatorSlugs = pgTable('operator_slugs', {
|
|
18
|
+
id: bigserial('id', { mode: 'number' }).primaryKey(),
|
|
19
|
+
operatorId: uuid('operator_id').references(() => operators.id),
|
|
20
|
+
oldSlug: text('old_slug').notNull(),
|
|
21
|
+
...timestamps,
|
|
22
|
+
}, (t) => [
|
|
23
|
+
index('operator_slugs_old_slug_created_idx').on(t.oldSlug, t.createdAt),
|
|
24
|
+
index('operator_slugs_operator_idx').on(t.operatorId),
|
|
25
|
+
]);
|
package/dist/db/operators.d.ts
CHANGED
|
@@ -87,6 +87,91 @@ export declare const operators: import("drizzle-orm/pg-core").PgTableWithColumns
|
|
|
87
87
|
identity: undefined;
|
|
88
88
|
generated: undefined;
|
|
89
89
|
}, {}, {}>;
|
|
90
|
+
slug: import("drizzle-orm/pg-core").PgColumn<{
|
|
91
|
+
name: "slug";
|
|
92
|
+
tableName: "operators";
|
|
93
|
+
dataType: "string";
|
|
94
|
+
columnType: "PgText";
|
|
95
|
+
data: string;
|
|
96
|
+
driverParam: string;
|
|
97
|
+
notNull: true;
|
|
98
|
+
hasDefault: false;
|
|
99
|
+
isPrimaryKey: false;
|
|
100
|
+
isAutoincrement: false;
|
|
101
|
+
hasRuntimeDefault: false;
|
|
102
|
+
enumValues: [string, ...string[]];
|
|
103
|
+
baseColumn: never;
|
|
104
|
+
identity: undefined;
|
|
105
|
+
generated: undefined;
|
|
106
|
+
}, {}, {}>;
|
|
107
|
+
displayName: import("drizzle-orm/pg-core").PgColumn<{
|
|
108
|
+
name: "display_name";
|
|
109
|
+
tableName: "operators";
|
|
110
|
+
dataType: "string";
|
|
111
|
+
columnType: "PgText";
|
|
112
|
+
data: string;
|
|
113
|
+
driverParam: string;
|
|
114
|
+
notNull: true;
|
|
115
|
+
hasDefault: false;
|
|
116
|
+
isPrimaryKey: false;
|
|
117
|
+
isAutoincrement: false;
|
|
118
|
+
hasRuntimeDefault: false;
|
|
119
|
+
enumValues: [string, ...string[]];
|
|
120
|
+
baseColumn: never;
|
|
121
|
+
identity: undefined;
|
|
122
|
+
generated: undefined;
|
|
123
|
+
}, {}, {}>;
|
|
124
|
+
displayNameKey: import("drizzle-orm/pg-core").PgColumn<{
|
|
125
|
+
name: "display_name_key";
|
|
126
|
+
tableName: "operators";
|
|
127
|
+
dataType: "string";
|
|
128
|
+
columnType: "PgText";
|
|
129
|
+
data: string;
|
|
130
|
+
driverParam: string;
|
|
131
|
+
notNull: true;
|
|
132
|
+
hasDefault: false;
|
|
133
|
+
isPrimaryKey: false;
|
|
134
|
+
isAutoincrement: false;
|
|
135
|
+
hasRuntimeDefault: false;
|
|
136
|
+
enumValues: [string, ...string[]];
|
|
137
|
+
baseColumn: never;
|
|
138
|
+
identity: undefined;
|
|
139
|
+
generated: undefined;
|
|
140
|
+
}, {}, {}>;
|
|
141
|
+
slugChangedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
142
|
+
name: "slug_changed_at";
|
|
143
|
+
tableName: "operators";
|
|
144
|
+
dataType: "date";
|
|
145
|
+
columnType: "PgTimestamp";
|
|
146
|
+
data: Date;
|
|
147
|
+
driverParam: string;
|
|
148
|
+
notNull: false;
|
|
149
|
+
hasDefault: false;
|
|
150
|
+
isPrimaryKey: false;
|
|
151
|
+
isAutoincrement: false;
|
|
152
|
+
hasRuntimeDefault: false;
|
|
153
|
+
enumValues: undefined;
|
|
154
|
+
baseColumn: never;
|
|
155
|
+
identity: undefined;
|
|
156
|
+
generated: undefined;
|
|
157
|
+
}, {}, {}>;
|
|
158
|
+
slugNoticeDismissedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
159
|
+
name: "slug_notice_dismissed_at";
|
|
160
|
+
tableName: "operators";
|
|
161
|
+
dataType: "date";
|
|
162
|
+
columnType: "PgTimestamp";
|
|
163
|
+
data: Date;
|
|
164
|
+
driverParam: string;
|
|
165
|
+
notNull: false;
|
|
166
|
+
hasDefault: false;
|
|
167
|
+
isPrimaryKey: false;
|
|
168
|
+
isAutoincrement: false;
|
|
169
|
+
hasRuntimeDefault: false;
|
|
170
|
+
enumValues: undefined;
|
|
171
|
+
baseColumn: never;
|
|
172
|
+
identity: undefined;
|
|
173
|
+
generated: undefined;
|
|
174
|
+
}, {}, {}>;
|
|
90
175
|
accountCreatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
91
176
|
name: "account_created_at";
|
|
92
177
|
tableName: "operators";
|
|
@@ -104,6 +189,40 @@ export declare const operators: import("drizzle-orm/pg-core").PgTableWithColumns
|
|
|
104
189
|
identity: undefined;
|
|
105
190
|
generated: undefined;
|
|
106
191
|
}, {}, {}>;
|
|
192
|
+
termsVersion: import("drizzle-orm/pg-core").PgColumn<{
|
|
193
|
+
name: "terms_version";
|
|
194
|
+
tableName: "operators";
|
|
195
|
+
dataType: "string";
|
|
196
|
+
columnType: "PgText";
|
|
197
|
+
data: string;
|
|
198
|
+
driverParam: string;
|
|
199
|
+
notNull: false;
|
|
200
|
+
hasDefault: false;
|
|
201
|
+
isPrimaryKey: false;
|
|
202
|
+
isAutoincrement: false;
|
|
203
|
+
hasRuntimeDefault: false;
|
|
204
|
+
enumValues: [string, ...string[]];
|
|
205
|
+
baseColumn: never;
|
|
206
|
+
identity: undefined;
|
|
207
|
+
generated: undefined;
|
|
208
|
+
}, {}, {}>;
|
|
209
|
+
privacyVersion: import("drizzle-orm/pg-core").PgColumn<{
|
|
210
|
+
name: "privacy_version";
|
|
211
|
+
tableName: "operators";
|
|
212
|
+
dataType: "string";
|
|
213
|
+
columnType: "PgText";
|
|
214
|
+
data: string;
|
|
215
|
+
driverParam: string;
|
|
216
|
+
notNull: false;
|
|
217
|
+
hasDefault: false;
|
|
218
|
+
isPrimaryKey: false;
|
|
219
|
+
isAutoincrement: false;
|
|
220
|
+
hasRuntimeDefault: false;
|
|
221
|
+
enumValues: [string, ...string[]];
|
|
222
|
+
baseColumn: never;
|
|
223
|
+
identity: undefined;
|
|
224
|
+
generated: undefined;
|
|
225
|
+
}, {}, {}>;
|
|
107
226
|
};
|
|
108
227
|
dialect: 'pg';
|
|
109
228
|
}>;
|