@betterinternship/schema 1.25.1 → 1.26.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/README.md CHANGED
@@ -1,33 +1,36 @@
1
- # @betterinternship/schema
2
-
3
- Consolidated database schema package for BetterInternship. Replaces the previous `@betterinternship/schema.base` and `@betterinternship/schema.moa` packages.
4
-
5
- ## Exports
6
-
7
- - `db` — Kysely client over the `career.*` schema
8
- - `internshipDb` — Kysely client over the `forms.*` schema
9
- - `documentDb` — Kysely client over the `documents.*` schema
10
- - `internalDb` — Kysely client over the `internal.*` schema
11
- - `handleDBError` — shared Postgres error translator
12
- - Types: `DB` (career), `InternshipDB`, `DocumentDB`, all `Career*` table interfaces, `Json`, `Generated`, `Timestamp`, etc.
13
- - Namespaces: `Internship`, `Document`, `Internal` (full re-exports of their respective generated type files)
14
-
15
- ## Environment
16
-
17
- Requires a single `DATABASE_URL` pointing at the unified Postgres database.
18
-
19
- ## Codegen
20
-
21
- ```
22
- npm run generate # career.* -> lib/db.types.ts
23
- npm run generate:internship # forms.* -> lib/db.internship.types.ts
24
- npm run generate:documents # documents.* -> lib/db.doc.types.ts
25
- npm run generate:internal # internal.* -> lib/db.internal.types.ts
26
- npm run generate:iom # iom.* -> lib/db.iom.types.ts
27
- ```
28
-
29
- Each script reads `DATABASE_URL` from `dev.env`. Create `dev.env` with your dev database URL:
30
-
31
- ```
32
- DATABASE_URL="postgres://..."
33
- ```
1
+ # @betterinternship/schema
2
+
3
+ Consolidated database schema package for BetterInternship. Replaces the previous `@betterinternship/schema.base` and `@betterinternship/schema.moa` packages.
4
+
5
+ ## Exports
6
+
7
+ - `db` — Kysely client over the `career.*` schema
8
+ - `internshipDb` — Kysely client over the `forms.*` schema
9
+ - `documentDb` — Kysely client over the `documents.*` schema
10
+ - `internalDb` — Kysely client over the `internal.*` schema
11
+ - `handleDBError` — shared Postgres error translator
12
+ - Types: `DB` (career), `InternshipDB`, `DocumentDB`, all `Career*` table interfaces, `Json`, `Generated`, `Timestamp`, etc.
13
+ - Namespaces: `Internship`, `Document`, `Internal` (full re-exports of their respective generated type files)
14
+
15
+ ## Environment
16
+
17
+ Each script reads `DATABASE_URL` from `dev.env`. Create `dev.env` with your dev database URL:
18
+
19
+ ```
20
+ DATABASE_URL="postgres://..."
21
+ ```
22
+
23
+ ## Codegen
24
+
25
+ ```
26
+ npm run generate # career.* -> lib/db.types.ts
27
+ npm run generate:internship # forms.* -> lib/db.internship.types.ts
28
+ npm run generate:documents # documents.* -> lib/db.doc.types.ts
29
+ npm run generate:internal # internal.* -> lib/db.internal.types.ts
30
+ npm run generate:iom # iom.* -> lib/db.iom.types.ts
31
+ ```
32
+
33
+ After that, dont forget to run:
34
+ ```
35
+ npm run build
36
+ ```
@@ -1,183 +1,185 @@
1
- import type { ColumnType } from "kysely";
2
- export type Generated<T> = T extends ColumnType<infer S, infer I, infer U> ? ColumnType<S, I | undefined, U> : ColumnType<T, T | undefined, T>;
3
- export type InternalAuthEventType = "expired" | "impersonation_ended" | "impersonation_started" | "login" | "logout" | "revoked";
4
- export type InternalAuthRealm = "company" | "employer" | "god" | "signatory" | "student" | "university";
5
- export type InternalLinkClickOutcome = "expired" | "invalid" | "revoked" | "valid";
6
- export type InternalLinkDomain = "admin" | "career_api" | "docs" | "employer" | "moa" | "student" | "uni";
7
- export type InternalMqJobStatus = "done" | "failed" | "processing" | "queued";
8
- export type InternalProcessStatus = "canceled" | "failed" | "handled" | "pending";
9
- export type InternalSocialChannel = "facebook" | "telegram";
10
- export type InternalSocialPostStatus = "cancelled" | "failed" | "posted" | "queued" | "released" | "sending" | "skipped";
11
- export type InternalTaskStatus = "failed" | "handled" | "pending" | "retrying";
12
- export type Json = JsonValue;
13
- export type JsonArray = JsonValue[];
14
- export type JsonObject = {
15
- [x: string]: JsonValue | undefined;
16
- };
17
- export type JsonPrimitive = boolean | number | string | null;
18
- export type JsonValue = JsonArray | JsonObject | JsonPrimitive;
19
- export type Timestamp = ColumnType<Date, Date | string, Date | string>;
20
- export interface InternalAppConfig {
21
- key: string;
22
- updated_at: Generated<Timestamp>;
23
- updated_by: string | null;
24
- value: string;
25
- }
26
- export interface InternalAuthEventLog {
27
- at: Generated<Timestamp>;
28
- email: string | null;
29
- event: InternalAuthEventType;
30
- god_id: string | null;
31
- id: Generated<string>;
32
- realm: InternalAuthRealm;
33
- reason: string | null;
34
- session_id: string | null;
35
- subject_id: string;
36
- }
37
- export interface InternalAuthSessions {
38
- created_at: Generated<Timestamp>;
39
- email: string | null;
40
- expires_at: Timestamp;
41
- id: Generated<string>;
42
- impersonated_by_session_id: string | null;
43
- last_seen_at: Generated<Timestamp>;
44
- realm: InternalAuthRealm;
45
- subject_id: string;
46
- token_hash: string;
47
- }
48
- export interface InternalEmailDeliveryEvents {
49
- attempts: number | null;
50
- correlation_detail: string | null;
51
- correlation_id: string | null;
52
- correlation_type: string | null;
53
- created_at: Generated<Timestamp>;
54
- error_message: string | null;
55
- event_type: string;
56
- feedback_id: string;
57
- handled_at: Timestamp | null;
58
- id: Generated<string>;
59
- message_id: string | null;
60
- recipient_email: string;
61
- resolved_at: Timestamp | null;
62
- subject: string | null;
63
- }
64
- export interface InternalGodAuditLog {
65
- action: string;
66
- at: Generated<Timestamp>;
67
- god_id: string;
68
- id: Generated<string>;
69
- outcome: string;
70
- params: Json | null;
71
- session_id: string | null;
72
- target_id: string | null;
73
- target_type: string | null;
74
- }
75
- export interface InternalGods {
76
- created_at: Generated<Timestamp>;
77
- display_name: string;
78
- email: string;
79
- id: Generated<string>;
80
- is_deactivated: Generated<boolean>;
81
- preferences: Generated<Json>;
82
- }
83
- export interface InternalMqJobs {
84
- created_at: Generated<Timestamp>;
85
- error: string | null;
86
- id: Generated<string>;
87
- owner_id: string | null;
88
- progress_done: number | null;
89
- progress_failed: number | null;
90
- progress_total: number | null;
91
- result: Json | null;
92
- status: Generated<InternalMqJobStatus>;
93
- type: string;
94
- updated_at: Generated<Timestamp>;
95
- }
96
- export interface InternalProcesses {
97
- base_inputs: Generated<Json | null>;
98
- error: Json | null;
99
- id: Generated<string>;
100
- name: string;
101
- result: Json | null;
102
- status: Generated<InternalProcessStatus>;
103
- timestamp: Generated<Timestamp>;
104
- }
105
- export interface InternalRecipientLinkClicks {
106
- context: Json | null;
107
- created_at: Generated<Timestamp>;
108
- id: Generated<string>;
109
- ip: string | null;
110
- link_id: string | null;
111
- link_type: string;
112
- outcome: InternalLinkClickOutcome;
113
- recipient_id: string;
114
- user_agent: string | null;
115
- }
116
- export interface InternalSlugs {
117
- created_at: Generated<Timestamp>;
118
- destination_host: InternalLinkDomain | null;
119
- domain: InternalLinkDomain;
120
- slug: string;
121
- url: string;
122
- }
123
- export interface InternalSocialPosts {
124
- cancelled_by: string | null;
125
- channel: InternalSocialChannel;
126
- error: string | null;
127
- external_post_id: string | null;
128
- finished_at: Timestamp | null;
129
- id: Generated<string>;
130
- job_id: string;
131
- queued_at: Generated<Timestamp>;
132
- released_at: Timestamp | null;
133
- sending_at: Timestamp | null;
134
- skip_reason: string | null;
135
- status: Generated<InternalSocialPostStatus>;
136
- }
137
- export interface InternalTasks {
138
- error: string | null;
139
- handler_id: string;
140
- id: Generated<string>;
141
- inputs: Json | null;
142
- internal_id: string;
143
- parent_ids: string[] | null;
144
- process_id: string;
145
- process_name: string;
146
- result: Json | null;
147
- status: Generated<InternalTaskStatus>;
148
- timestamp: Generated<Timestamp>;
149
- }
150
- export interface InternalTestInboxes {
151
- added_by: string;
152
- created_at: Generated<Timestamp>;
153
- email: string;
154
- id: Generated<string>;
155
- kind: string;
156
- note: string | null;
157
- verified_at: Timestamp | null;
158
- }
159
- export interface InternalTestPresets {
160
- created_by: string;
161
- id: Generated<string>;
162
- name: string;
163
- panel: string;
164
- updated_at: Generated<Timestamp>;
165
- updated_by: string;
166
- values: Json;
167
- }
168
- export interface DB {
169
- "internal.app_config": InternalAppConfig;
170
- "internal.auth_event_log": InternalAuthEventLog;
171
- "internal.auth_sessions": InternalAuthSessions;
172
- "internal.email_delivery_events": InternalEmailDeliveryEvents;
173
- "internal.god_audit_log": InternalGodAuditLog;
174
- "internal.gods": InternalGods;
175
- "internal.mq_jobs": InternalMqJobs;
176
- "internal.processes": InternalProcesses;
177
- "internal.recipient_link_clicks": InternalRecipientLinkClicks;
178
- "internal.slugs": InternalSlugs;
179
- "internal.social_posts": InternalSocialPosts;
180
- "internal.tasks": InternalTasks;
181
- "internal.test_inboxes": InternalTestInboxes;
182
- "internal.test_presets": InternalTestPresets;
183
- }
1
+ import type { ColumnType } from "kysely";
2
+ export type Generated<T> = T extends ColumnType<infer S, infer I, infer U> ? ColumnType<S, I | undefined, U> : ColumnType<T, T | undefined, T>;
3
+ export type InternalAuthEventType = "expired" | "impersonation_ended" | "impersonation_started" | "login" | "logout" | "revoked";
4
+ export type InternalAuthRealm = "company" | "employer" | "god" | "signatory" | "student" | "university";
5
+ export type InternalLinkClickOutcome = "expired" | "invalid" | "revoked" | "valid";
6
+ export type InternalLinkDomain = "admin" | "career_api" | "docs" | "employer" | "moa" | "student" | "uni";
7
+ export type InternalMqJobStatus = "done" | "failed" | "processing" | "queued";
8
+ export type InternalProcessStatus = "canceled" | "failed" | "handled" | "pending";
9
+ export type InternalSocialChannel = "facebook" | "telegram";
10
+ export type InternalSocialPostStatus = "cancelled" | "failed" | "posted" | "queued" | "released" | "sending" | "skipped";
11
+ export type InternalTaskStatus = "failed" | "handled" | "pending" | "retrying";
12
+ export type Json = JsonValue;
13
+ export type JsonArray = JsonValue[];
14
+ export type JsonObject = {
15
+ [x: string]: JsonValue | undefined;
16
+ };
17
+ export type JsonPrimitive = boolean | number | string | null;
18
+ export type JsonValue = JsonArray | JsonObject | JsonPrimitive;
19
+ export type Timestamp = ColumnType<Date, Date | string, Date | string>;
20
+ export interface InternalAppConfig {
21
+ key: string;
22
+ updated_at: Generated<Timestamp>;
23
+ updated_by: string | null;
24
+ value: string;
25
+ }
26
+ export interface InternalAuthEventLog {
27
+ at: Generated<Timestamp>;
28
+ email: string | null;
29
+ event: InternalAuthEventType;
30
+ god_id: string | null;
31
+ id: Generated<string>;
32
+ realm: InternalAuthRealm;
33
+ reason: string | null;
34
+ session_id: string | null;
35
+ subject_id: string;
36
+ }
37
+ export interface InternalAuthSessions {
38
+ created_at: Generated<Timestamp>;
39
+ email: string | null;
40
+ expires_at: Timestamp;
41
+ id: Generated<string>;
42
+ impersonated_by_session_id: string | null;
43
+ last_seen_at: Generated<Timestamp>;
44
+ realm: InternalAuthRealm;
45
+ subject_id: string;
46
+ token_hash: string;
47
+ }
48
+ export interface InternalEmailDeliveryEvents {
49
+ attempts: number | null;
50
+ correlation_detail: string | null;
51
+ correlation_id: string | null;
52
+ correlation_type: string | null;
53
+ created_at: Generated<Timestamp>;
54
+ error_message: string | null;
55
+ event_type: string;
56
+ feedback_id: string;
57
+ first_opened_at: Timestamp | null;
58
+ handled_at: Timestamp | null;
59
+ id: Generated<string>;
60
+ message_id: string | null;
61
+ open_count: Generated<number>;
62
+ recipient_email: string;
63
+ resolved_at: Timestamp | null;
64
+ subject: string | null;
65
+ }
66
+ export interface InternalGodAuditLog {
67
+ action: string;
68
+ at: Generated<Timestamp>;
69
+ god_id: string;
70
+ id: Generated<string>;
71
+ outcome: string;
72
+ params: Json | null;
73
+ session_id: string | null;
74
+ target_id: string | null;
75
+ target_type: string | null;
76
+ }
77
+ export interface InternalGods {
78
+ created_at: Generated<Timestamp>;
79
+ display_name: string;
80
+ email: string;
81
+ id: Generated<string>;
82
+ is_deactivated: Generated<boolean>;
83
+ preferences: Generated<Json>;
84
+ }
85
+ export interface InternalMqJobs {
86
+ created_at: Generated<Timestamp>;
87
+ error: string | null;
88
+ id: Generated<string>;
89
+ owner_id: string | null;
90
+ progress_done: number | null;
91
+ progress_failed: number | null;
92
+ progress_total: number | null;
93
+ result: Json | null;
94
+ status: Generated<InternalMqJobStatus>;
95
+ type: string;
96
+ updated_at: Generated<Timestamp>;
97
+ }
98
+ export interface InternalProcesses {
99
+ base_inputs: Generated<Json | null>;
100
+ error: Json | null;
101
+ id: Generated<string>;
102
+ name: string;
103
+ result: Json | null;
104
+ status: Generated<InternalProcessStatus>;
105
+ timestamp: Generated<Timestamp>;
106
+ }
107
+ export interface InternalRecipientLinkClicks {
108
+ context: Json | null;
109
+ created_at: Generated<Timestamp>;
110
+ id: Generated<string>;
111
+ ip: string | null;
112
+ link_id: string | null;
113
+ link_type: string;
114
+ outcome: InternalLinkClickOutcome;
115
+ recipient_id: string;
116
+ user_agent: string | null;
117
+ }
118
+ export interface InternalSlugs {
119
+ created_at: Generated<Timestamp>;
120
+ destination_host: InternalLinkDomain | null;
121
+ domain: InternalLinkDomain;
122
+ slug: string;
123
+ url: string;
124
+ }
125
+ export interface InternalSocialPosts {
126
+ cancelled_by: string | null;
127
+ channel: InternalSocialChannel;
128
+ error: string | null;
129
+ external_post_id: string | null;
130
+ finished_at: Timestamp | null;
131
+ id: Generated<string>;
132
+ job_id: string;
133
+ queued_at: Generated<Timestamp>;
134
+ released_at: Timestamp | null;
135
+ sending_at: Timestamp | null;
136
+ skip_reason: string | null;
137
+ status: Generated<InternalSocialPostStatus>;
138
+ }
139
+ export interface InternalTasks {
140
+ error: string | null;
141
+ handler_id: string;
142
+ id: Generated<string>;
143
+ inputs: Json | null;
144
+ internal_id: string;
145
+ parent_ids: string[] | null;
146
+ process_id: string;
147
+ process_name: string;
148
+ result: Json | null;
149
+ status: Generated<InternalTaskStatus>;
150
+ timestamp: Generated<Timestamp>;
151
+ }
152
+ export interface InternalTestInboxes {
153
+ added_by: string;
154
+ created_at: Generated<Timestamp>;
155
+ email: string;
156
+ id: Generated<string>;
157
+ kind: string;
158
+ note: string | null;
159
+ verified_at: Timestamp | null;
160
+ }
161
+ export interface InternalTestPresets {
162
+ created_by: string;
163
+ id: Generated<string>;
164
+ name: string;
165
+ panel: string;
166
+ updated_at: Generated<Timestamp>;
167
+ updated_by: string;
168
+ values: Json;
169
+ }
170
+ export interface DB {
171
+ "internal.app_config": InternalAppConfig;
172
+ "internal.auth_event_log": InternalAuthEventLog;
173
+ "internal.auth_sessions": InternalAuthSessions;
174
+ "internal.email_delivery_events": InternalEmailDeliveryEvents;
175
+ "internal.god_audit_log": InternalGodAuditLog;
176
+ "internal.gods": InternalGods;
177
+ "internal.mq_jobs": InternalMqJobs;
178
+ "internal.processes": InternalProcesses;
179
+ "internal.recipient_link_clicks": InternalRecipientLinkClicks;
180
+ "internal.slugs": InternalSlugs;
181
+ "internal.social_posts": InternalSocialPosts;
182
+ "internal.tasks": InternalTasks;
183
+ "internal.test_inboxes": InternalTestInboxes;
184
+ "internal.test_presets": InternalTestPresets;
185
+ }