@sealkeeper/schema 0.0.1 → 0.4.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/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +14 -1
- package/dist/agent-id.d.ts +13 -0
- package/dist/agent-id.js +29 -0
- package/dist/agent-name.d.ts +9 -0
- package/dist/agent-name.js +58 -0
- package/dist/api.d.ts +1207 -0
- package/dist/api.js +624 -0
- package/dist/base64url.d.ts +4 -0
- package/dist/base64url.js +43 -0
- package/dist/credential.d.ts +392 -0
- package/dist/credential.js +287 -0
- package/dist/db/agent-renames.d.ts +126 -0
- package/dist/db/agent-renames.js +20 -0
- package/dist/db/agents.d.ts +145 -0
- package/dist/db/agents.js +40 -0
- package/dist/db/client.d.ts +1893 -0
- package/dist/db/client.js +34 -0
- package/dist/db/credentials.d.ts +143 -0
- package/dist/db/credentials.js +16 -0
- package/dist/db/deleted-operators.d.ts +75 -0
- package/dist/db/deleted-operators.js +13 -0
- package/dist/db/events.d.ts +160 -0
- package/dist/db/events.js +34 -0
- package/dist/db/feed-items.d.ts +109 -0
- package/dist/db/feed-items.js +16 -0
- package/dist/db/index.d.ts +56 -0
- package/dist/db/index.js +23 -0
- package/dist/db/migrate.d.ts +1 -0
- package/dist/db/migrate.js +30 -0
- package/dist/db/migrator.d.ts +2 -0
- package/dist/db/migrator.js +20 -0
- package/dist/db/operators.d.ts +109 -0
- package/dist/db/operators.js +11 -0
- package/dist/db/quota-counters.d.ts +109 -0
- package/dist/db/quota-counters.js +17 -0
- package/dist/db/ratings.d.ts +160 -0
- package/dist/db/ratings.js +27 -0
- package/dist/db/scores.d.ts +160 -0
- package/dist/db/scores.js +15 -0
- package/dist/db/standing.d.ts +228 -0
- package/dist/db/standing.js +29 -0
- package/dist/db/task-outcomes.d.ts +126 -0
- package/dist/db/task-outcomes.js +18 -0
- package/dist/db/tasks.d.ts +251 -0
- package/dist/db/tasks.js +49 -0
- package/dist/db/timestamps.d.ts +4 -0
- package/dist/db/timestamps.js +24 -0
- package/dist/db/url.d.ts +12 -0
- package/dist/db/url.js +25 -0
- package/dist/dimensions.d.ts +21 -0
- package/dist/dimensions.js +15 -0
- package/dist/envelope.d.ts +16 -0
- package/dist/envelope.js +70 -0
- package/dist/events.d.ts +153 -0
- package/dist/events.js +98 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/dist/seal-conformance.d.ts +14 -0
- package/dist/seal-conformance.js +176 -0
- package/dist/standing.d.ts +46 -0
- package/dist/standing.js +79 -0
- package/dist/tasks.d.ts +49 -0
- package/dist/tasks.js +102 -0
- package/dist/top-dimensions.d.ts +9 -0
- package/dist/top-dimensions.js +13 -0
- package/package.json +69 -5
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
export declare const agentRenames: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
2
|
+
name: "agent_renames";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
6
|
+
name: "created_at";
|
|
7
|
+
tableName: "agent_renames";
|
|
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: "agent_renames";
|
|
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: "agent_renames";
|
|
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
|
+
agentId: import("drizzle-orm/pg-core").PgColumn<{
|
|
57
|
+
name: "agent_id";
|
|
58
|
+
tableName: "agent_renames";
|
|
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
|
+
oldName: import("drizzle-orm/pg-core").PgColumn<{
|
|
74
|
+
name: "old_name";
|
|
75
|
+
tableName: "agent_renames";
|
|
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
|
+
newName: import("drizzle-orm/pg-core").PgColumn<{
|
|
91
|
+
name: "new_name";
|
|
92
|
+
tableName: "agent_renames";
|
|
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
|
+
issuedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
108
|
+
name: "issued_at";
|
|
109
|
+
tableName: "agent_renames";
|
|
110
|
+
dataType: "date";
|
|
111
|
+
columnType: "PgTimestamp";
|
|
112
|
+
data: Date;
|
|
113
|
+
driverParam: string;
|
|
114
|
+
notNull: true;
|
|
115
|
+
hasDefault: false;
|
|
116
|
+
isPrimaryKey: false;
|
|
117
|
+
isAutoincrement: false;
|
|
118
|
+
hasRuntimeDefault: false;
|
|
119
|
+
enumValues: undefined;
|
|
120
|
+
baseColumn: never;
|
|
121
|
+
identity: undefined;
|
|
122
|
+
generated: undefined;
|
|
123
|
+
}, {}, {}>;
|
|
124
|
+
};
|
|
125
|
+
dialect: 'pg';
|
|
126
|
+
}>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { bigserial, index, pgTable, text, timestamp, } from 'drizzle-orm/pg-core';
|
|
2
|
+
import { agents } from './agents.js';
|
|
3
|
+
import { timestamps } from './timestamps.js';
|
|
4
|
+
// One row per rename. An old handle keeps resolving, as a redirect, for
|
|
5
|
+
// RENAME_REDIRECT_DAYS after the rename, and the profile shows the old name
|
|
6
|
+
// for as long. issued_at is the signed issuedAt of the rename, so an older
|
|
7
|
+
// envelope sent again is refused.
|
|
8
|
+
//
|
|
9
|
+
// bigserial is a bigint filled from its own sequence. mode 'number' reads it
|
|
10
|
+
// as a JS number, which is safe well past any count of renames.
|
|
11
|
+
export const agentRenames = pgTable('agent_renames', {
|
|
12
|
+
id: bigserial('id', { mode: 'number' }).primaryKey(),
|
|
13
|
+
agentId: text('agent_id')
|
|
14
|
+
.notNull()
|
|
15
|
+
.references(() => agents.id),
|
|
16
|
+
oldName: text('old_name').notNull(),
|
|
17
|
+
newName: text('new_name').notNull(),
|
|
18
|
+
issuedAt: timestamp('issued_at', { withTimezone: true }).notNull(),
|
|
19
|
+
...timestamps,
|
|
20
|
+
}, (t) => [index('agent_renames_agent_created_idx').on(t.agentId, t.createdAt)]);
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
export declare const agents: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
2
|
+
name: "agents";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
6
|
+
name: "created_at";
|
|
7
|
+
tableName: "agents";
|
|
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: "agents";
|
|
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: "agents";
|
|
42
|
+
dataType: "string";
|
|
43
|
+
columnType: "PgText";
|
|
44
|
+
data: string;
|
|
45
|
+
driverParam: string;
|
|
46
|
+
notNull: true;
|
|
47
|
+
hasDefault: false;
|
|
48
|
+
isPrimaryKey: true;
|
|
49
|
+
isAutoincrement: false;
|
|
50
|
+
hasRuntimeDefault: false;
|
|
51
|
+
enumValues: [string, ...string[]];
|
|
52
|
+
baseColumn: never;
|
|
53
|
+
identity: undefined;
|
|
54
|
+
generated: undefined;
|
|
55
|
+
}, {}, {}>;
|
|
56
|
+
operatorId: import("drizzle-orm/pg-core").PgColumn<{
|
|
57
|
+
name: "operator_id";
|
|
58
|
+
tableName: "agents";
|
|
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
|
+
name: import("drizzle-orm/pg-core").PgColumn<{
|
|
74
|
+
name: "name";
|
|
75
|
+
tableName: "agents";
|
|
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
|
+
version: import("drizzle-orm/pg-core").PgColumn<{
|
|
91
|
+
name: "version";
|
|
92
|
+
tableName: "agents";
|
|
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
|
+
versionIssuedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
108
|
+
name: "version_issued_at";
|
|
109
|
+
tableName: "agents";
|
|
110
|
+
dataType: "date";
|
|
111
|
+
columnType: "PgTimestamp";
|
|
112
|
+
data: Date;
|
|
113
|
+
driverParam: string;
|
|
114
|
+
notNull: false;
|
|
115
|
+
hasDefault: false;
|
|
116
|
+
isPrimaryKey: false;
|
|
117
|
+
isAutoincrement: false;
|
|
118
|
+
hasRuntimeDefault: false;
|
|
119
|
+
enumValues: undefined;
|
|
120
|
+
baseColumn: never;
|
|
121
|
+
identity: undefined;
|
|
122
|
+
generated: undefined;
|
|
123
|
+
}, {}, {}>;
|
|
124
|
+
card: import("drizzle-orm/pg-core").PgColumn<{
|
|
125
|
+
name: "card";
|
|
126
|
+
tableName: "agents";
|
|
127
|
+
dataType: "json";
|
|
128
|
+
columnType: "PgJsonb";
|
|
129
|
+
data: unknown;
|
|
130
|
+
driverParam: unknown;
|
|
131
|
+
notNull: false;
|
|
132
|
+
hasDefault: false;
|
|
133
|
+
isPrimaryKey: false;
|
|
134
|
+
isAutoincrement: false;
|
|
135
|
+
hasRuntimeDefault: false;
|
|
136
|
+
enumValues: undefined;
|
|
137
|
+
baseColumn: never;
|
|
138
|
+
identity: undefined;
|
|
139
|
+
generated: undefined;
|
|
140
|
+
}, {}, {}>;
|
|
141
|
+
};
|
|
142
|
+
dialect: 'pg';
|
|
143
|
+
}>;
|
|
144
|
+
export type Agent = typeof agents.$inferSelect;
|
|
145
|
+
export type NewAgent = typeof agents.$inferInsert;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { sql } from 'drizzle-orm';
|
|
2
|
+
import { check, jsonb, pgTable, text, timestamp, uniqueIndex, uuid, } from 'drizzle-orm/pg-core';
|
|
3
|
+
import { operators } from './operators.js';
|
|
4
|
+
import { timestamps } from './timestamps.js';
|
|
5
|
+
// How a Drizzle table is declared.
|
|
6
|
+
//
|
|
7
|
+
// pgTable(sqlName, columns, extras) returns a table object. Queries use it,
|
|
8
|
+
// as in db.select().from(agents), and drizzle-kit diffs it to write
|
|
9
|
+
// migrations.
|
|
10
|
+
//
|
|
11
|
+
// columns maps a TypeScript property to a column builder. The first argument
|
|
12
|
+
// of each builder is the SQL column name, so the property is camelCase in
|
|
13
|
+
// code and snake_case in the database. Builders chain constraints such as
|
|
14
|
+
// .notNull(), .primaryKey() and .references(() => operators.id). The arrow in
|
|
15
|
+
// references() lets tables point at each other regardless of file order.
|
|
16
|
+
//
|
|
17
|
+
// ...timestamps spreads the shared created_at and updated_at columns in.
|
|
18
|
+
//
|
|
19
|
+
// extras receives the built columns and returns table level constraints and
|
|
20
|
+
// indexes. Here it is a check constraint written as raw SQL. The agent id is
|
|
21
|
+
// the ed25519 public key, 32 bytes, base64url without padding, so 43 chars.
|
|
22
|
+
export const agents = pgTable('agents', {
|
|
23
|
+
id: text('id').primaryKey(),
|
|
24
|
+
operatorId: uuid('operator_id')
|
|
25
|
+
.notNull()
|
|
26
|
+
.references(() => operators.id),
|
|
27
|
+
name: text('name').notNull(),
|
|
28
|
+
version: text('version').notNull(),
|
|
29
|
+
// The signed issuedAt of the last version change, null until the first.
|
|
30
|
+
// A change issued no later than this one is refused, so an old envelope
|
|
31
|
+
// sent again cannot move the version back.
|
|
32
|
+
versionIssuedAt: timestamp('version_issued_at', { withTimezone: true }),
|
|
33
|
+
card: jsonb('card'),
|
|
34
|
+
...timestamps,
|
|
35
|
+
}, (t) => [
|
|
36
|
+
check('agents_id_length', sql `length(${t.id}) = 43`),
|
|
37
|
+
// The handle login/name points at one agent. Names are lowercase, so a
|
|
38
|
+
// plain unique index is enough.
|
|
39
|
+
uniqueIndex('agents_operator_name_unique').on(t.operatorId, t.name),
|
|
40
|
+
]);
|