@sealkeeper/schema 0.4.6 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/api.d.ts +787 -35
- package/dist/api.js +357 -44
- package/dist/conformance.d.ts +4 -0
- package/dist/conformance.js +7 -0
- package/dist/credential.d.ts +196 -27
- package/dist/credential.js +128 -80
- package/dist/dimensions.d.ts +16 -3
- package/dist/dimensions.js +48 -2
- package/dist/events.d.ts +1 -0
- package/dist/events.js +13 -1
- package/dist/fingerprint-conformance.d.ts +17 -0
- package/dist/fingerprint-conformance.js +83 -0
- package/dist/fingerprint.d.ts +132 -0
- package/dist/fingerprint.js +166 -0
- package/dist/goal.d.ts +16 -1
- package/dist/goal.js +29 -6
- package/dist/handshake-conformance.d.ts +18 -0
- package/dist/handshake-conformance.js +276 -0
- package/dist/handshake.d.ts +66 -0
- package/dist/handshake.js +187 -0
- package/dist/hidden.d.ts +1 -0
- package/dist/hidden.js +5 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/moderation.js +1 -4
- package/dist/policy.d.ts +1 -1
- package/dist/policy.js +1 -1
- package/dist/seal-conformance.js +148 -4
- package/dist/seal-verify.d.ts +21 -0
- package/dist/seal-verify.js +63 -0
- package/dist/standing.d.ts +61 -0
- package/dist/standing.js +132 -4
- package/dist/task-templates.d.ts +46 -0
- package/dist/task-templates.js +501 -0
- package/dist/tasks.d.ts +43 -0
- package/dist/tasks.js +103 -0
- package/dist/template-conformance.d.ts +10 -0
- package/dist/template-conformance.js +298 -0
- package/dist/top-dimensions.d.ts +3 -3
- package/dist/top-dimensions.js +12 -6
- package/package.json +4 -8
- package/dist/db/agent-milestones.d.ts +0 -75
- package/dist/db/agent-milestones.js +0 -16
- package/dist/db/agent-renames.d.ts +0 -126
- package/dist/db/agent-renames.js +0 -20
- package/dist/db/agents.d.ts +0 -351
- package/dist/db/agents.js +0 -99
- package/dist/db/client.d.ts +0 -2561
- package/dist/db/client.js +0 -61
- package/dist/db/credentials.d.ts +0 -143
- package/dist/db/credentials.js +0 -16
- package/dist/db/deleted-operators.d.ts +0 -75
- package/dist/db/deleted-operators.js +0 -13
- package/dist/db/events.d.ts +0 -160
- package/dist/db/events.js +0 -41
- package/dist/db/feed-items.d.ts +0 -109
- package/dist/db/feed-items.js +0 -21
- package/dist/db/index.d.ts +0 -76
- package/dist/db/index.js +0 -28
- package/dist/db/migrate.d.ts +0 -1
- package/dist/db/migrate.js +0 -34
- package/dist/db/migrator.d.ts +0 -6
- package/dist/db/migrator.js +0 -36
- package/dist/db/operator-identities.d.ts +0 -211
- package/dist/db/operator-identities.js +0 -49
- package/dist/db/operator-level-grants.d.ts +0 -109
- package/dist/db/operator-level-grants.js +0 -30
- package/dist/db/operator-slugs.d.ts +0 -92
- package/dist/db/operator-slugs.js +0 -25
- package/dist/db/operators.d.ts +0 -228
- package/dist/db/operators.js +0 -39
- package/dist/db/quota-counters.d.ts +0 -109
- package/dist/db/quota-counters.js +0 -17
- package/dist/db/ratings.d.ts +0 -160
- package/dist/db/ratings.js +0 -27
- package/dist/db/scores.d.ts +0 -160
- package/dist/db/scores.js +0 -15
- package/dist/db/standing.d.ts +0 -264
- package/dist/db/standing.js +0 -34
- package/dist/db/task-claim-failures.d.ts +0 -143
- package/dist/db/task-claim-failures.js +0 -37
- package/dist/db/task-outcomes.d.ts +0 -145
- package/dist/db/task-outcomes.js +0 -25
- package/dist/db/tasks.d.ts +0 -381
- package/dist/db/tasks.js +0 -106
- package/dist/db/timestamps.d.ts +0 -4
- package/dist/db/timestamps.js +0 -24
- package/dist/db/url.d.ts +0 -12
- package/dist/db/url.js +0 -25
package/dist/db/index.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { agentMilestones } from './agent-milestones.js';
|
|
2
|
-
import type { agentRenames } from './agent-renames.js';
|
|
3
|
-
import type { credentials } from './credentials.js';
|
|
4
|
-
import type { deletedOperators } from './deleted-operators.js';
|
|
5
|
-
import type { events } from './events.js';
|
|
6
|
-
import type { feedItems } from './feed-items.js';
|
|
7
|
-
import type { operatorIdentities } from './operator-identities.js';
|
|
8
|
-
import type { operatorLevelGrants } from './operator-level-grants.js';
|
|
9
|
-
import type { operatorSlugs } from './operator-slugs.js';
|
|
10
|
-
import type { operators } from './operators.js';
|
|
11
|
-
import type { quotaCounters } from './quota-counters.js';
|
|
12
|
-
import type { ratings } from './ratings.js';
|
|
13
|
-
import type { scores } from './scores.js';
|
|
14
|
-
import type { standing } from './standing.js';
|
|
15
|
-
import type { taskClaimFailures } from './task-claim-failures.js';
|
|
16
|
-
import type { taskOutcomes } from './task-outcomes.js';
|
|
17
|
-
import type { tasks } from './tasks.js';
|
|
18
|
-
export { and, asc, desc, eq, gt, inArray, isNotNull, isNull, lt, lte, max, ne, notInArray, or, type SQL, sql, } from 'drizzle-orm';
|
|
19
|
-
export { DrizzleQueryError } from 'drizzle-orm/errors';
|
|
20
|
-
export { agentMilestones } from './agent-milestones.js';
|
|
21
|
-
export { agentRenames } from './agent-renames.js';
|
|
22
|
-
export type { Agent, NewAgent } from './agents.js';
|
|
23
|
-
export { agents } from './agents.js';
|
|
24
|
-
export { createDb, type Db, type DbOptions, type Tx } from './client.js';
|
|
25
|
-
export { credentials } from './credentials.js';
|
|
26
|
-
export { deletedOperators } from './deleted-operators.js';
|
|
27
|
-
export { events } from './events.js';
|
|
28
|
-
export { feedItems } from './feed-items.js';
|
|
29
|
-
export { migrationsFolder, runMigrations } from './migrator.js';
|
|
30
|
-
export { operatorIdentities } from './operator-identities.js';
|
|
31
|
-
export { operatorLevelGrants } from './operator-level-grants.js';
|
|
32
|
-
export { operatorSlugs } from './operator-slugs.js';
|
|
33
|
-
export { operators } from './operators.js';
|
|
34
|
-
export { quotaCounters } from './quota-counters.js';
|
|
35
|
-
export { ratings } from './ratings.js';
|
|
36
|
-
export { scores } from './scores.js';
|
|
37
|
-
export { type StoredCounts, type StoredLevelInputs, standing, } from './standing.js';
|
|
38
|
-
export { taskClaimFailures } from './task-claim-failures.js';
|
|
39
|
-
export { taskOutcomes } from './task-outcomes.js';
|
|
40
|
-
export { tasks } from './tasks.js';
|
|
41
|
-
export { timestamps } from './timestamps.js';
|
|
42
|
-
export { pgArgs } from './url.js';
|
|
43
|
-
export type Operator = typeof operators.$inferSelect;
|
|
44
|
-
export type NewOperator = typeof operators.$inferInsert;
|
|
45
|
-
export type Event = typeof events.$inferSelect;
|
|
46
|
-
export type NewEvent = typeof events.$inferInsert;
|
|
47
|
-
export type Task = typeof tasks.$inferSelect;
|
|
48
|
-
export type NewTask = typeof tasks.$inferInsert;
|
|
49
|
-
export type TaskOutcome = typeof taskOutcomes.$inferSelect;
|
|
50
|
-
export type NewTaskOutcome = typeof taskOutcomes.$inferInsert;
|
|
51
|
-
export type TaskClaimFailure = typeof taskClaimFailures.$inferSelect;
|
|
52
|
-
export type NewTaskClaimFailure = typeof taskClaimFailures.$inferInsert;
|
|
53
|
-
export type Rating = typeof ratings.$inferSelect;
|
|
54
|
-
export type NewRating = typeof ratings.$inferInsert;
|
|
55
|
-
export type Credential = typeof credentials.$inferSelect;
|
|
56
|
-
export type NewCredential = typeof credentials.$inferInsert;
|
|
57
|
-
export type Score = typeof scores.$inferSelect;
|
|
58
|
-
export type NewScore = typeof scores.$inferInsert;
|
|
59
|
-
export type StandingRow = typeof standing.$inferSelect;
|
|
60
|
-
export type NewStandingRow = typeof standing.$inferInsert;
|
|
61
|
-
export type QuotaCounter = typeof quotaCounters.$inferSelect;
|
|
62
|
-
export type NewQuotaCounter = typeof quotaCounters.$inferInsert;
|
|
63
|
-
export type AgentRename = typeof agentRenames.$inferSelect;
|
|
64
|
-
export type NewAgentRename = typeof agentRenames.$inferInsert;
|
|
65
|
-
export type FeedItem = typeof feedItems.$inferSelect;
|
|
66
|
-
export type NewFeedItem = typeof feedItems.$inferInsert;
|
|
67
|
-
export type AgentMilestone = typeof agentMilestones.$inferSelect;
|
|
68
|
-
export type NewAgentMilestone = typeof agentMilestones.$inferInsert;
|
|
69
|
-
export type OperatorSlugRow = typeof operatorSlugs.$inferSelect;
|
|
70
|
-
export type NewOperatorSlugRow = typeof operatorSlugs.$inferInsert;
|
|
71
|
-
export type DeletedOperator = typeof deletedOperators.$inferSelect;
|
|
72
|
-
export type NewDeletedOperator = typeof deletedOperators.$inferInsert;
|
|
73
|
-
export type OperatorLevelGrant = typeof operatorLevelGrants.$inferSelect;
|
|
74
|
-
export type NewOperatorLevelGrant = typeof operatorLevelGrants.$inferInsert;
|
|
75
|
-
export type OperatorIdentity = typeof operatorIdentities.$inferSelect;
|
|
76
|
-
export type NewOperatorIdentity = typeof operatorIdentities.$inferInsert;
|
package/dist/db/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// The query helpers the API needs beyond the relational query API. The API
|
|
2
|
-
// takes them from here so drizzle-orm stays a dependency of this package only.
|
|
3
|
-
export { and, asc, desc, eq, gt, inArray, isNotNull, isNull, lt, lte, max, ne, notInArray, or, sql, } from 'drizzle-orm';
|
|
4
|
-
// What every failed query throws. Its message holds the SQL and every bound
|
|
5
|
-
// param, so the API error log must never print it.
|
|
6
|
-
export { DrizzleQueryError } from 'drizzle-orm/errors';
|
|
7
|
-
export { agentMilestones } from './agent-milestones.js';
|
|
8
|
-
export { agentRenames } from './agent-renames.js';
|
|
9
|
-
export { agents } from './agents.js';
|
|
10
|
-
export { createDb } from './client.js';
|
|
11
|
-
export { credentials } from './credentials.js';
|
|
12
|
-
export { deletedOperators } from './deleted-operators.js';
|
|
13
|
-
export { events } from './events.js';
|
|
14
|
-
export { feedItems } from './feed-items.js';
|
|
15
|
-
export { migrationsFolder, runMigrations } from './migrator.js';
|
|
16
|
-
export { operatorIdentities } from './operator-identities.js';
|
|
17
|
-
export { operatorLevelGrants } from './operator-level-grants.js';
|
|
18
|
-
export { operatorSlugs } from './operator-slugs.js';
|
|
19
|
-
export { operators } from './operators.js';
|
|
20
|
-
export { quotaCounters } from './quota-counters.js';
|
|
21
|
-
export { ratings } from './ratings.js';
|
|
22
|
-
export { scores } from './scores.js';
|
|
23
|
-
export { standing, } from './standing.js';
|
|
24
|
-
export { taskClaimFailures } from './task-claim-failures.js';
|
|
25
|
-
export { taskOutcomes } from './task-outcomes.js';
|
|
26
|
-
export { tasks } from './tasks.js';
|
|
27
|
-
export { timestamps } from './timestamps.js';
|
|
28
|
-
export { pgArgs } from './url.js';
|
package/dist/db/migrate.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/db/migrate.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// Applies the SQL migrations in packages/schema/drizzle to DATABASE_URL.
|
|
2
|
-
// This is what the vouched-migrate Cloud Run Job runs, so the image needs
|
|
3
|
-
// drizzle-orm only and not drizzle-kit. Local dev keeps `pnpm db:migrate`.
|
|
4
|
-
// @types/node is a devDependency only for this script, migrator.ts and url.ts.
|
|
5
|
-
/// <reference types="node" />
|
|
6
|
-
import { runMigrations } from './migrator.js';
|
|
7
|
-
const url = process.env.DATABASE_URL;
|
|
8
|
-
if (!url) {
|
|
9
|
-
console.error('DATABASE_URL is not set');
|
|
10
|
-
process.exit(1);
|
|
11
|
-
}
|
|
12
|
-
try {
|
|
13
|
-
// A notice is a migration telling the operator of the database something,
|
|
14
|
-
// such as 0025 listing the operators whose slug got a suffix.
|
|
15
|
-
await runMigrations(url, {
|
|
16
|
-
onNotice: (notice) => console.log(JSON.stringify({ msg: 'migration notice', notice })),
|
|
17
|
-
});
|
|
18
|
-
console.log(JSON.stringify({ msg: 'migrations applied' }));
|
|
19
|
-
}
|
|
20
|
-
catch (err) {
|
|
21
|
-
// Log messages and the error code only, never the error object or the URL,
|
|
22
|
-
// which carry the password. Drizzle wraps connection and auth failures as
|
|
23
|
-
// a failed query, so the real reason is in err.cause.
|
|
24
|
-
const msg = err instanceof Error ? err.message : 'unknown error';
|
|
25
|
-
const cause = err instanceof Error && err.cause instanceof Error ? err.cause : undefined;
|
|
26
|
-
const code = cause?.code;
|
|
27
|
-
console.error(JSON.stringify({
|
|
28
|
-
msg: 'migration failed',
|
|
29
|
-
error: msg,
|
|
30
|
-
cause: cause?.message,
|
|
31
|
-
code,
|
|
32
|
-
}));
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
package/dist/db/migrator.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const migrationsFolder: string;
|
|
2
|
-
export declare const MIGRATION_LOCK_TIMEOUT_MS = 5000;
|
|
3
|
-
export declare const MIGRATION_STATEMENT_TIMEOUT_MS = 120000;
|
|
4
|
-
export declare function runMigrations(databaseUrl: string, { onNotice }?: {
|
|
5
|
-
onNotice?: (message: string) => void;
|
|
6
|
-
}): Promise<void>;
|
package/dist/db/migrator.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// The one drizzle migrator. migrate.ts (the vouched-migrate job) and the API
|
|
2
|
-
// test helper both call runMigrations, so there is a single code path.
|
|
3
|
-
/// <reference types="node" />
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { drizzle } from 'drizzle-orm/postgres-js';
|
|
6
|
-
import { migrate } from 'drizzle-orm/postgres-js/migrator';
|
|
7
|
-
import postgres from 'postgres';
|
|
8
|
-
import { pgArgs } from './url.js';
|
|
9
|
-
// Resolves to packages/schema/drizzle from both src/db and dist/db.
|
|
10
|
-
export const migrationsFolder = fileURLToPath(new URL('../../drizzle', import.meta.url));
|
|
11
|
-
// A migration that waits on a lock, such as an ALTER TABLE queued behind the
|
|
12
|
-
// scoring run's transaction, fails after MIGRATION_LOCK_TIMEOUT_MS instead of
|
|
13
|
-
// waiting with no bound and blocking every query queued behind it. One
|
|
14
|
-
// statement may run for MIGRATION_STATEMENT_TIMEOUT_MS (VOU-205).
|
|
15
|
-
export const MIGRATION_LOCK_TIMEOUT_MS = 5_000;
|
|
16
|
-
export const MIGRATION_STATEMENT_TIMEOUT_MS = 120_000;
|
|
17
|
-
// onNotice receives the text of each notice a migration raises, such as
|
|
18
|
-
// the operators 0025 gave a suffixed slug. Silent when left out.
|
|
19
|
-
export async function runMigrations(databaseUrl, { onNotice } = {}) {
|
|
20
|
-
const [connUrl, options] = pgArgs(databaseUrl);
|
|
21
|
-
const sql = postgres(connUrl, {
|
|
22
|
-
...options,
|
|
23
|
-
max: 1,
|
|
24
|
-
connection: {
|
|
25
|
-
lock_timeout: MIGRATION_LOCK_TIMEOUT_MS,
|
|
26
|
-
statement_timeout: MIGRATION_STATEMENT_TIMEOUT_MS,
|
|
27
|
-
},
|
|
28
|
-
onnotice: (notice) => onNotice?.(notice.message),
|
|
29
|
-
});
|
|
30
|
-
try {
|
|
31
|
-
await migrate(drizzle(sql), { migrationsFolder });
|
|
32
|
-
}
|
|
33
|
-
finally {
|
|
34
|
-
await sql.end();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,211 +0,0 @@
|
|
|
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
|
-
}>;
|
|
@@ -1,49 +0,0 @@
|
|
|
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
|
-
]);
|
|
@@ -1,109 +0,0 @@
|
|
|
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
|
-
}>;
|
|
@@ -1,30 +0,0 @@
|
|
|
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
|
-
]);
|