@alethialabs/platform 0.1.1 → 0.3.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/dist/console-refs.d.ts +633 -0
- package/dist/console-refs.js +82 -0
- package/dist/paddle.d.ts +4 -0
- package/dist/paddle.js +9 -0
- package/dist/types.d.ts +4 -0
- package/package.json +9 -1
|
@@ -0,0 +1,633 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The console's `billing_plan` enum. Declared with the same name and values so the staff app reads a
|
|
3
|
+
* typed value; the contract test holds the values equal to the console's, so a plan added or renamed
|
|
4
|
+
* there fails CI before the staff app meets a value it does not know.
|
|
5
|
+
*/
|
|
6
|
+
export declare const billingPlan: import("drizzle-orm/pg-core").PgEnum<["community", "team", "enterprise"]>;
|
|
7
|
+
/** The console's `billing_status` enum, held to the console's values the same way. */
|
|
8
|
+
export declare const billingStatus: import("drizzle-orm/pg-core").PgEnum<["none", "trialing", "active", "past_due", "canceled"]>;
|
|
9
|
+
/** Owning organization of a support case: name and slug for the staff list and detail. */
|
|
10
|
+
export declare const organization: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
11
|
+
name: "organization";
|
|
12
|
+
schema: undefined;
|
|
13
|
+
columns: {
|
|
14
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
15
|
+
name: "id";
|
|
16
|
+
tableName: "organization";
|
|
17
|
+
dataType: "string";
|
|
18
|
+
columnType: "PgUUID";
|
|
19
|
+
data: string;
|
|
20
|
+
driverParam: string;
|
|
21
|
+
notNull: true;
|
|
22
|
+
hasDefault: true;
|
|
23
|
+
isPrimaryKey: true;
|
|
24
|
+
isAutoincrement: false;
|
|
25
|
+
hasRuntimeDefault: false;
|
|
26
|
+
enumValues: undefined;
|
|
27
|
+
baseColumn: never;
|
|
28
|
+
identity: undefined;
|
|
29
|
+
generated: undefined;
|
|
30
|
+
}, {}, {}>;
|
|
31
|
+
name: import("drizzle-orm/pg-core").PgColumn<{
|
|
32
|
+
name: "name";
|
|
33
|
+
tableName: "organization";
|
|
34
|
+
dataType: "string";
|
|
35
|
+
columnType: "PgText";
|
|
36
|
+
data: string;
|
|
37
|
+
driverParam: string;
|
|
38
|
+
notNull: true;
|
|
39
|
+
hasDefault: false;
|
|
40
|
+
isPrimaryKey: false;
|
|
41
|
+
isAutoincrement: false;
|
|
42
|
+
hasRuntimeDefault: false;
|
|
43
|
+
enumValues: [string, ...string[]];
|
|
44
|
+
baseColumn: never;
|
|
45
|
+
identity: undefined;
|
|
46
|
+
generated: undefined;
|
|
47
|
+
}, {}, {}>;
|
|
48
|
+
slug: import("drizzle-orm/pg-core").PgColumn<{
|
|
49
|
+
name: "slug";
|
|
50
|
+
tableName: "organization";
|
|
51
|
+
dataType: "string";
|
|
52
|
+
columnType: "PgText";
|
|
53
|
+
data: string;
|
|
54
|
+
driverParam: string;
|
|
55
|
+
notNull: false;
|
|
56
|
+
hasDefault: false;
|
|
57
|
+
isPrimaryKey: false;
|
|
58
|
+
isAutoincrement: false;
|
|
59
|
+
hasRuntimeDefault: false;
|
|
60
|
+
enumValues: [string, ...string[]];
|
|
61
|
+
baseColumn: never;
|
|
62
|
+
identity: undefined;
|
|
63
|
+
generated: undefined;
|
|
64
|
+
}, {}, {}>;
|
|
65
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
66
|
+
name: "createdAt";
|
|
67
|
+
tableName: "organization";
|
|
68
|
+
dataType: "date";
|
|
69
|
+
columnType: "PgTimestamp";
|
|
70
|
+
data: Date;
|
|
71
|
+
driverParam: string;
|
|
72
|
+
notNull: false;
|
|
73
|
+
hasDefault: false;
|
|
74
|
+
isPrimaryKey: false;
|
|
75
|
+
isAutoincrement: false;
|
|
76
|
+
hasRuntimeDefault: false;
|
|
77
|
+
enumValues: undefined;
|
|
78
|
+
baseColumn: never;
|
|
79
|
+
identity: undefined;
|
|
80
|
+
generated: undefined;
|
|
81
|
+
}, {}, {}>;
|
|
82
|
+
};
|
|
83
|
+
dialect: "pg";
|
|
84
|
+
}>;
|
|
85
|
+
/** A platform user: the case customer and, for `assigned_staff_id`, the staff assignee. */
|
|
86
|
+
export declare const user: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
87
|
+
name: "user";
|
|
88
|
+
schema: undefined;
|
|
89
|
+
columns: {
|
|
90
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
91
|
+
name: "id";
|
|
92
|
+
tableName: "user";
|
|
93
|
+
dataType: "string";
|
|
94
|
+
columnType: "PgUUID";
|
|
95
|
+
data: string;
|
|
96
|
+
driverParam: string;
|
|
97
|
+
notNull: true;
|
|
98
|
+
hasDefault: true;
|
|
99
|
+
isPrimaryKey: true;
|
|
100
|
+
isAutoincrement: false;
|
|
101
|
+
hasRuntimeDefault: false;
|
|
102
|
+
enumValues: undefined;
|
|
103
|
+
baseColumn: never;
|
|
104
|
+
identity: undefined;
|
|
105
|
+
generated: undefined;
|
|
106
|
+
}, {}, {}>;
|
|
107
|
+
name: import("drizzle-orm/pg-core").PgColumn<{
|
|
108
|
+
name: "name";
|
|
109
|
+
tableName: "user";
|
|
110
|
+
dataType: "string";
|
|
111
|
+
columnType: "PgText";
|
|
112
|
+
data: string;
|
|
113
|
+
driverParam: string;
|
|
114
|
+
notNull: false;
|
|
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
|
+
email: import("drizzle-orm/pg-core").PgColumn<{
|
|
125
|
+
name: "email";
|
|
126
|
+
tableName: "user";
|
|
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
|
+
};
|
|
142
|
+
dialect: "pg";
|
|
143
|
+
}>;
|
|
144
|
+
/**
|
|
145
|
+
* The AI usage ledger: one row per metered AI action, snapshotting the real USD cost of serving it in
|
|
146
|
+
* `cost_micros` (1e-6 USD). Read for the staff AI-spend rollup.
|
|
147
|
+
*/
|
|
148
|
+
export declare const aiUsageLedger: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
149
|
+
name: "ai_usage_ledger";
|
|
150
|
+
schema: undefined;
|
|
151
|
+
columns: {
|
|
152
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
153
|
+
name: "id";
|
|
154
|
+
tableName: "ai_usage_ledger";
|
|
155
|
+
dataType: "string";
|
|
156
|
+
columnType: "PgUUID";
|
|
157
|
+
data: string;
|
|
158
|
+
driverParam: string;
|
|
159
|
+
notNull: true;
|
|
160
|
+
hasDefault: true;
|
|
161
|
+
isPrimaryKey: true;
|
|
162
|
+
isAutoincrement: false;
|
|
163
|
+
hasRuntimeDefault: false;
|
|
164
|
+
enumValues: undefined;
|
|
165
|
+
baseColumn: never;
|
|
166
|
+
identity: undefined;
|
|
167
|
+
generated: undefined;
|
|
168
|
+
}, {}, {}>;
|
|
169
|
+
user_id: import("drizzle-orm/pg-core").PgColumn<{
|
|
170
|
+
name: "user_id";
|
|
171
|
+
tableName: "ai_usage_ledger";
|
|
172
|
+
dataType: "string";
|
|
173
|
+
columnType: "PgUUID";
|
|
174
|
+
data: string;
|
|
175
|
+
driverParam: string;
|
|
176
|
+
notNull: true;
|
|
177
|
+
hasDefault: false;
|
|
178
|
+
isPrimaryKey: false;
|
|
179
|
+
isAutoincrement: false;
|
|
180
|
+
hasRuntimeDefault: false;
|
|
181
|
+
enumValues: undefined;
|
|
182
|
+
baseColumn: never;
|
|
183
|
+
identity: undefined;
|
|
184
|
+
generated: undefined;
|
|
185
|
+
}, {}, {}>;
|
|
186
|
+
org_id: import("drizzle-orm/pg-core").PgColumn<{
|
|
187
|
+
name: "org_id";
|
|
188
|
+
tableName: "ai_usage_ledger";
|
|
189
|
+
dataType: "string";
|
|
190
|
+
columnType: "PgUUID";
|
|
191
|
+
data: string;
|
|
192
|
+
driverParam: string;
|
|
193
|
+
notNull: false;
|
|
194
|
+
hasDefault: false;
|
|
195
|
+
isPrimaryKey: false;
|
|
196
|
+
isAutoincrement: false;
|
|
197
|
+
hasRuntimeDefault: false;
|
|
198
|
+
enumValues: undefined;
|
|
199
|
+
baseColumn: never;
|
|
200
|
+
identity: undefined;
|
|
201
|
+
generated: undefined;
|
|
202
|
+
}, {}, {}>;
|
|
203
|
+
kind: import("drizzle-orm/pg-core").PgColumn<{
|
|
204
|
+
name: "kind";
|
|
205
|
+
tableName: "ai_usage_ledger";
|
|
206
|
+
dataType: "string";
|
|
207
|
+
columnType: "PgText";
|
|
208
|
+
data: string;
|
|
209
|
+
driverParam: string;
|
|
210
|
+
notNull: true;
|
|
211
|
+
hasDefault: false;
|
|
212
|
+
isPrimaryKey: false;
|
|
213
|
+
isAutoincrement: false;
|
|
214
|
+
hasRuntimeDefault: false;
|
|
215
|
+
enumValues: [string, ...string[]];
|
|
216
|
+
baseColumn: never;
|
|
217
|
+
identity: undefined;
|
|
218
|
+
generated: undefined;
|
|
219
|
+
}, {}, {}>;
|
|
220
|
+
credits: import("drizzle-orm/pg-core").PgColumn<{
|
|
221
|
+
name: "credits";
|
|
222
|
+
tableName: "ai_usage_ledger";
|
|
223
|
+
dataType: "number";
|
|
224
|
+
columnType: "PgInteger";
|
|
225
|
+
data: number;
|
|
226
|
+
driverParam: string | number;
|
|
227
|
+
notNull: true;
|
|
228
|
+
hasDefault: false;
|
|
229
|
+
isPrimaryKey: false;
|
|
230
|
+
isAutoincrement: false;
|
|
231
|
+
hasRuntimeDefault: false;
|
|
232
|
+
enumValues: undefined;
|
|
233
|
+
baseColumn: never;
|
|
234
|
+
identity: undefined;
|
|
235
|
+
generated: undefined;
|
|
236
|
+
}, {}, {}>;
|
|
237
|
+
source: import("drizzle-orm/pg-core").PgColumn<{
|
|
238
|
+
name: "source";
|
|
239
|
+
tableName: "ai_usage_ledger";
|
|
240
|
+
dataType: "string";
|
|
241
|
+
columnType: "PgText";
|
|
242
|
+
data: string;
|
|
243
|
+
driverParam: string;
|
|
244
|
+
notNull: true;
|
|
245
|
+
hasDefault: false;
|
|
246
|
+
isPrimaryKey: false;
|
|
247
|
+
isAutoincrement: false;
|
|
248
|
+
hasRuntimeDefault: false;
|
|
249
|
+
enumValues: [string, ...string[]];
|
|
250
|
+
baseColumn: never;
|
|
251
|
+
identity: undefined;
|
|
252
|
+
generated: undefined;
|
|
253
|
+
}, {}, {}>;
|
|
254
|
+
model: import("drizzle-orm/pg-core").PgColumn<{
|
|
255
|
+
name: "model";
|
|
256
|
+
tableName: "ai_usage_ledger";
|
|
257
|
+
dataType: "string";
|
|
258
|
+
columnType: "PgText";
|
|
259
|
+
data: string;
|
|
260
|
+
driverParam: string;
|
|
261
|
+
notNull: false;
|
|
262
|
+
hasDefault: false;
|
|
263
|
+
isPrimaryKey: false;
|
|
264
|
+
isAutoincrement: false;
|
|
265
|
+
hasRuntimeDefault: false;
|
|
266
|
+
enumValues: [string, ...string[]];
|
|
267
|
+
baseColumn: never;
|
|
268
|
+
identity: undefined;
|
|
269
|
+
generated: undefined;
|
|
270
|
+
}, {}, {}>;
|
|
271
|
+
cost_micros: import("drizzle-orm/pg-core").PgColumn<{
|
|
272
|
+
name: "cost_micros";
|
|
273
|
+
tableName: "ai_usage_ledger";
|
|
274
|
+
dataType: "number";
|
|
275
|
+
columnType: "PgBigInt53";
|
|
276
|
+
data: number;
|
|
277
|
+
driverParam: string | number;
|
|
278
|
+
notNull: false;
|
|
279
|
+
hasDefault: false;
|
|
280
|
+
isPrimaryKey: false;
|
|
281
|
+
isAutoincrement: false;
|
|
282
|
+
hasRuntimeDefault: false;
|
|
283
|
+
enumValues: undefined;
|
|
284
|
+
baseColumn: never;
|
|
285
|
+
identity: undefined;
|
|
286
|
+
generated: undefined;
|
|
287
|
+
}, {}, {}>;
|
|
288
|
+
created_at: import("drizzle-orm/pg-core").PgColumn<{
|
|
289
|
+
name: "created_at";
|
|
290
|
+
tableName: "ai_usage_ledger";
|
|
291
|
+
dataType: "date";
|
|
292
|
+
columnType: "PgTimestamp";
|
|
293
|
+
data: Date;
|
|
294
|
+
driverParam: string;
|
|
295
|
+
notNull: true;
|
|
296
|
+
hasDefault: false;
|
|
297
|
+
isPrimaryKey: false;
|
|
298
|
+
isAutoincrement: false;
|
|
299
|
+
hasRuntimeDefault: false;
|
|
300
|
+
enumValues: undefined;
|
|
301
|
+
baseColumn: never;
|
|
302
|
+
identity: undefined;
|
|
303
|
+
generated: undefined;
|
|
304
|
+
}, {}, {}>;
|
|
305
|
+
};
|
|
306
|
+
dialect: "pg";
|
|
307
|
+
}>;
|
|
308
|
+
/**
|
|
309
|
+
* The org billing record, the sole source of an org's plan. The staff app reads it for the org
|
|
310
|
+
* detail and changes a plan only through the console's `set-plan` route, never by writing here, so
|
|
311
|
+
* the console stays the single writer.
|
|
312
|
+
*/
|
|
313
|
+
export declare const organizationBilling: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
314
|
+
name: "organization_billing";
|
|
315
|
+
schema: undefined;
|
|
316
|
+
columns: {
|
|
317
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
318
|
+
name: "id";
|
|
319
|
+
tableName: "organization_billing";
|
|
320
|
+
dataType: "string";
|
|
321
|
+
columnType: "PgUUID";
|
|
322
|
+
data: string;
|
|
323
|
+
driverParam: string;
|
|
324
|
+
notNull: true;
|
|
325
|
+
hasDefault: true;
|
|
326
|
+
isPrimaryKey: true;
|
|
327
|
+
isAutoincrement: false;
|
|
328
|
+
hasRuntimeDefault: false;
|
|
329
|
+
enumValues: undefined;
|
|
330
|
+
baseColumn: never;
|
|
331
|
+
identity: undefined;
|
|
332
|
+
generated: undefined;
|
|
333
|
+
}, {}, {}>;
|
|
334
|
+
organizationId: import("drizzle-orm/pg-core").PgColumn<{
|
|
335
|
+
name: "organizationId";
|
|
336
|
+
tableName: "organization_billing";
|
|
337
|
+
dataType: "string";
|
|
338
|
+
columnType: "PgUUID";
|
|
339
|
+
data: string;
|
|
340
|
+
driverParam: string;
|
|
341
|
+
notNull: true;
|
|
342
|
+
hasDefault: false;
|
|
343
|
+
isPrimaryKey: false;
|
|
344
|
+
isAutoincrement: false;
|
|
345
|
+
hasRuntimeDefault: false;
|
|
346
|
+
enumValues: undefined;
|
|
347
|
+
baseColumn: never;
|
|
348
|
+
identity: undefined;
|
|
349
|
+
generated: undefined;
|
|
350
|
+
}, {}, {}>;
|
|
351
|
+
plan: import("drizzle-orm/pg-core").PgColumn<{
|
|
352
|
+
name: "plan";
|
|
353
|
+
tableName: "organization_billing";
|
|
354
|
+
dataType: "string";
|
|
355
|
+
columnType: "PgEnumColumn";
|
|
356
|
+
data: "community" | "team" | "enterprise";
|
|
357
|
+
driverParam: string;
|
|
358
|
+
notNull: true;
|
|
359
|
+
hasDefault: false;
|
|
360
|
+
isPrimaryKey: false;
|
|
361
|
+
isAutoincrement: false;
|
|
362
|
+
hasRuntimeDefault: false;
|
|
363
|
+
enumValues: ["community", "team", "enterprise"];
|
|
364
|
+
baseColumn: never;
|
|
365
|
+
identity: undefined;
|
|
366
|
+
generated: undefined;
|
|
367
|
+
}, {}, {}>;
|
|
368
|
+
status: import("drizzle-orm/pg-core").PgColumn<{
|
|
369
|
+
name: "status";
|
|
370
|
+
tableName: "organization_billing";
|
|
371
|
+
dataType: "string";
|
|
372
|
+
columnType: "PgEnumColumn";
|
|
373
|
+
data: "none" | "trialing" | "active" | "past_due" | "canceled";
|
|
374
|
+
driverParam: string;
|
|
375
|
+
notNull: true;
|
|
376
|
+
hasDefault: false;
|
|
377
|
+
isPrimaryKey: false;
|
|
378
|
+
isAutoincrement: false;
|
|
379
|
+
hasRuntimeDefault: false;
|
|
380
|
+
enumValues: ["none", "trialing", "active", "past_due", "canceled"];
|
|
381
|
+
baseColumn: never;
|
|
382
|
+
identity: undefined;
|
|
383
|
+
generated: undefined;
|
|
384
|
+
}, {}, {}>;
|
|
385
|
+
stripeCustomerId: import("drizzle-orm/pg-core").PgColumn<{
|
|
386
|
+
name: "stripeCustomerId";
|
|
387
|
+
tableName: "organization_billing";
|
|
388
|
+
dataType: "string";
|
|
389
|
+
columnType: "PgText";
|
|
390
|
+
data: string;
|
|
391
|
+
driverParam: string;
|
|
392
|
+
notNull: false;
|
|
393
|
+
hasDefault: false;
|
|
394
|
+
isPrimaryKey: false;
|
|
395
|
+
isAutoincrement: false;
|
|
396
|
+
hasRuntimeDefault: false;
|
|
397
|
+
enumValues: [string, ...string[]];
|
|
398
|
+
baseColumn: never;
|
|
399
|
+
identity: undefined;
|
|
400
|
+
generated: undefined;
|
|
401
|
+
}, {}, {}>;
|
|
402
|
+
stripeSubscriptionId: import("drizzle-orm/pg-core").PgColumn<{
|
|
403
|
+
name: "stripeSubscriptionId";
|
|
404
|
+
tableName: "organization_billing";
|
|
405
|
+
dataType: "string";
|
|
406
|
+
columnType: "PgText";
|
|
407
|
+
data: string;
|
|
408
|
+
driverParam: string;
|
|
409
|
+
notNull: false;
|
|
410
|
+
hasDefault: false;
|
|
411
|
+
isPrimaryKey: false;
|
|
412
|
+
isAutoincrement: false;
|
|
413
|
+
hasRuntimeDefault: false;
|
|
414
|
+
enumValues: [string, ...string[]];
|
|
415
|
+
baseColumn: never;
|
|
416
|
+
identity: undefined;
|
|
417
|
+
generated: undefined;
|
|
418
|
+
}, {}, {}>;
|
|
419
|
+
paddleCustomerId: import("drizzle-orm/pg-core").PgColumn<{
|
|
420
|
+
name: "paddleCustomerId";
|
|
421
|
+
tableName: "organization_billing";
|
|
422
|
+
dataType: "string";
|
|
423
|
+
columnType: "PgText";
|
|
424
|
+
data: string;
|
|
425
|
+
driverParam: string;
|
|
426
|
+
notNull: false;
|
|
427
|
+
hasDefault: false;
|
|
428
|
+
isPrimaryKey: false;
|
|
429
|
+
isAutoincrement: false;
|
|
430
|
+
hasRuntimeDefault: false;
|
|
431
|
+
enumValues: [string, ...string[]];
|
|
432
|
+
baseColumn: never;
|
|
433
|
+
identity: undefined;
|
|
434
|
+
generated: undefined;
|
|
435
|
+
}, {}, {}>;
|
|
436
|
+
paddleSubscriptionId: import("drizzle-orm/pg-core").PgColumn<{
|
|
437
|
+
name: "paddleSubscriptionId";
|
|
438
|
+
tableName: "organization_billing";
|
|
439
|
+
dataType: "string";
|
|
440
|
+
columnType: "PgText";
|
|
441
|
+
data: string;
|
|
442
|
+
driverParam: string;
|
|
443
|
+
notNull: false;
|
|
444
|
+
hasDefault: false;
|
|
445
|
+
isPrimaryKey: false;
|
|
446
|
+
isAutoincrement: false;
|
|
447
|
+
hasRuntimeDefault: false;
|
|
448
|
+
enumValues: [string, ...string[]];
|
|
449
|
+
baseColumn: never;
|
|
450
|
+
identity: undefined;
|
|
451
|
+
generated: undefined;
|
|
452
|
+
}, {}, {}>;
|
|
453
|
+
seats: import("drizzle-orm/pg-core").PgColumn<{
|
|
454
|
+
name: "seats";
|
|
455
|
+
tableName: "organization_billing";
|
|
456
|
+
dataType: "number";
|
|
457
|
+
columnType: "PgInteger";
|
|
458
|
+
data: number;
|
|
459
|
+
driverParam: string | number;
|
|
460
|
+
notNull: false;
|
|
461
|
+
hasDefault: false;
|
|
462
|
+
isPrimaryKey: false;
|
|
463
|
+
isAutoincrement: false;
|
|
464
|
+
hasRuntimeDefault: false;
|
|
465
|
+
enumValues: undefined;
|
|
466
|
+
baseColumn: never;
|
|
467
|
+
identity: undefined;
|
|
468
|
+
generated: undefined;
|
|
469
|
+
}, {}, {}>;
|
|
470
|
+
currentPeriodStart: import("drizzle-orm/pg-core").PgColumn<{
|
|
471
|
+
name: "currentPeriodStart";
|
|
472
|
+
tableName: "organization_billing";
|
|
473
|
+
dataType: "date";
|
|
474
|
+
columnType: "PgTimestamp";
|
|
475
|
+
data: Date;
|
|
476
|
+
driverParam: string;
|
|
477
|
+
notNull: false;
|
|
478
|
+
hasDefault: false;
|
|
479
|
+
isPrimaryKey: false;
|
|
480
|
+
isAutoincrement: false;
|
|
481
|
+
hasRuntimeDefault: false;
|
|
482
|
+
enumValues: undefined;
|
|
483
|
+
baseColumn: never;
|
|
484
|
+
identity: undefined;
|
|
485
|
+
generated: undefined;
|
|
486
|
+
}, {}, {}>;
|
|
487
|
+
currentPeriodEnd: import("drizzle-orm/pg-core").PgColumn<{
|
|
488
|
+
name: "currentPeriodEnd";
|
|
489
|
+
tableName: "organization_billing";
|
|
490
|
+
dataType: "date";
|
|
491
|
+
columnType: "PgTimestamp";
|
|
492
|
+
data: Date;
|
|
493
|
+
driverParam: string;
|
|
494
|
+
notNull: false;
|
|
495
|
+
hasDefault: false;
|
|
496
|
+
isPrimaryKey: false;
|
|
497
|
+
isAutoincrement: false;
|
|
498
|
+
hasRuntimeDefault: false;
|
|
499
|
+
enumValues: undefined;
|
|
500
|
+
baseColumn: never;
|
|
501
|
+
identity: undefined;
|
|
502
|
+
generated: undefined;
|
|
503
|
+
}, {}, {}>;
|
|
504
|
+
welcomedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
505
|
+
name: "welcomedAt";
|
|
506
|
+
tableName: "organization_billing";
|
|
507
|
+
dataType: "date";
|
|
508
|
+
columnType: "PgTimestamp";
|
|
509
|
+
data: Date;
|
|
510
|
+
driverParam: string;
|
|
511
|
+
notNull: false;
|
|
512
|
+
hasDefault: false;
|
|
513
|
+
isPrimaryKey: false;
|
|
514
|
+
isAutoincrement: false;
|
|
515
|
+
hasRuntimeDefault: false;
|
|
516
|
+
enumValues: undefined;
|
|
517
|
+
baseColumn: never;
|
|
518
|
+
identity: undefined;
|
|
519
|
+
generated: undefined;
|
|
520
|
+
}, {}, {}>;
|
|
521
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
522
|
+
name: "updatedAt";
|
|
523
|
+
tableName: "organization_billing";
|
|
524
|
+
dataType: "date";
|
|
525
|
+
columnType: "PgTimestamp";
|
|
526
|
+
data: Date;
|
|
527
|
+
driverParam: string;
|
|
528
|
+
notNull: false;
|
|
529
|
+
hasDefault: false;
|
|
530
|
+
isPrimaryKey: false;
|
|
531
|
+
isAutoincrement: false;
|
|
532
|
+
hasRuntimeDefault: false;
|
|
533
|
+
enumValues: undefined;
|
|
534
|
+
baseColumn: never;
|
|
535
|
+
identity: undefined;
|
|
536
|
+
generated: undefined;
|
|
537
|
+
}, {}, {}>;
|
|
538
|
+
};
|
|
539
|
+
dialect: "pg";
|
|
540
|
+
}>;
|
|
541
|
+
/** Org membership: the staff app reads the member list and resolves the owner. */
|
|
542
|
+
export declare const member: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
543
|
+
name: "member";
|
|
544
|
+
schema: undefined;
|
|
545
|
+
columns: {
|
|
546
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
547
|
+
name: "id";
|
|
548
|
+
tableName: "member";
|
|
549
|
+
dataType: "string";
|
|
550
|
+
columnType: "PgUUID";
|
|
551
|
+
data: string;
|
|
552
|
+
driverParam: string;
|
|
553
|
+
notNull: true;
|
|
554
|
+
hasDefault: true;
|
|
555
|
+
isPrimaryKey: true;
|
|
556
|
+
isAutoincrement: false;
|
|
557
|
+
hasRuntimeDefault: false;
|
|
558
|
+
enumValues: undefined;
|
|
559
|
+
baseColumn: never;
|
|
560
|
+
identity: undefined;
|
|
561
|
+
generated: undefined;
|
|
562
|
+
}, {}, {}>;
|
|
563
|
+
organizationId: import("drizzle-orm/pg-core").PgColumn<{
|
|
564
|
+
name: "organizationId";
|
|
565
|
+
tableName: "member";
|
|
566
|
+
dataType: "string";
|
|
567
|
+
columnType: "PgUUID";
|
|
568
|
+
data: string;
|
|
569
|
+
driverParam: string;
|
|
570
|
+
notNull: true;
|
|
571
|
+
hasDefault: false;
|
|
572
|
+
isPrimaryKey: false;
|
|
573
|
+
isAutoincrement: false;
|
|
574
|
+
hasRuntimeDefault: false;
|
|
575
|
+
enumValues: undefined;
|
|
576
|
+
baseColumn: never;
|
|
577
|
+
identity: undefined;
|
|
578
|
+
generated: undefined;
|
|
579
|
+
}, {}, {}>;
|
|
580
|
+
userId: import("drizzle-orm/pg-core").PgColumn<{
|
|
581
|
+
name: "userId";
|
|
582
|
+
tableName: "member";
|
|
583
|
+
dataType: "string";
|
|
584
|
+
columnType: "PgUUID";
|
|
585
|
+
data: string;
|
|
586
|
+
driverParam: string;
|
|
587
|
+
notNull: true;
|
|
588
|
+
hasDefault: false;
|
|
589
|
+
isPrimaryKey: false;
|
|
590
|
+
isAutoincrement: false;
|
|
591
|
+
hasRuntimeDefault: false;
|
|
592
|
+
enumValues: undefined;
|
|
593
|
+
baseColumn: never;
|
|
594
|
+
identity: undefined;
|
|
595
|
+
generated: undefined;
|
|
596
|
+
}, {}, {}>;
|
|
597
|
+
role: import("drizzle-orm/pg-core").PgColumn<{
|
|
598
|
+
name: "role";
|
|
599
|
+
tableName: "member";
|
|
600
|
+
dataType: "string";
|
|
601
|
+
columnType: "PgText";
|
|
602
|
+
data: string;
|
|
603
|
+
driverParam: string;
|
|
604
|
+
notNull: true;
|
|
605
|
+
hasDefault: false;
|
|
606
|
+
isPrimaryKey: false;
|
|
607
|
+
isAutoincrement: false;
|
|
608
|
+
hasRuntimeDefault: false;
|
|
609
|
+
enumValues: [string, ...string[]];
|
|
610
|
+
baseColumn: never;
|
|
611
|
+
identity: undefined;
|
|
612
|
+
generated: undefined;
|
|
613
|
+
}, {}, {}>;
|
|
614
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
615
|
+
name: "createdAt";
|
|
616
|
+
tableName: "member";
|
|
617
|
+
dataType: "date";
|
|
618
|
+
columnType: "PgTimestamp";
|
|
619
|
+
data: Date;
|
|
620
|
+
driverParam: string;
|
|
621
|
+
notNull: false;
|
|
622
|
+
hasDefault: false;
|
|
623
|
+
isPrimaryKey: false;
|
|
624
|
+
isAutoincrement: false;
|
|
625
|
+
hasRuntimeDefault: false;
|
|
626
|
+
enumValues: undefined;
|
|
627
|
+
baseColumn: never;
|
|
628
|
+
identity: undefined;
|
|
629
|
+
generated: undefined;
|
|
630
|
+
}, {}, {}>;
|
|
631
|
+
};
|
|
632
|
+
dialect: "pg";
|
|
633
|
+
}>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Alethia Labs <legal@alethialabs.io>
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
3
|
+
// Read-only Drizzle references to the console-owned tables the staff app (apps/admin) reads.
|
|
4
|
+
//
|
|
5
|
+
// The console OWNS these tables and their migrations; nothing here generates or changes a migration.
|
|
6
|
+
// Each reference declares only the columns the staff app touches, named as the physical schema names
|
|
7
|
+
// them under the `snake_case` casing both apps configure.
|
|
8
|
+
//
|
|
9
|
+
// They live in this published package, not inside the staff app, for one reason: the staff app is
|
|
10
|
+
// moving to its own repository, and a console migration that renamed or dropped one of these columns
|
|
11
|
+
// would then break it in production with nothing in this repository noticing. The console's test
|
|
12
|
+
// `tests/db/console-refs-contract.test.ts` checks every column below against the console's real
|
|
13
|
+
// schema (it exists, has the same SQL type and, for an enum, the same values, and is NOT NULL wherever
|
|
14
|
+
// it is declared NOT NULL here), so that change fails CI here instead.
|
|
15
|
+
//
|
|
16
|
+
// Adding a column the staff app reads means adding it here; the contract test then holds the console
|
|
17
|
+
// to it.
|
|
18
|
+
import { bigint, integer, pgEnum, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core";
|
|
19
|
+
/**
|
|
20
|
+
* The console's `billing_plan` enum. Declared with the same name and values so the staff app reads a
|
|
21
|
+
* typed value; the contract test holds the values equal to the console's, so a plan added or renamed
|
|
22
|
+
* there fails CI before the staff app meets a value it does not know.
|
|
23
|
+
*/
|
|
24
|
+
export const billingPlan = pgEnum("billing_plan", ["community", "team", "enterprise"]);
|
|
25
|
+
/** The console's `billing_status` enum, held to the console's values the same way. */
|
|
26
|
+
export const billingStatus = pgEnum("billing_status", ["none", "trialing", "active", "past_due", "canceled"]);
|
|
27
|
+
/** Owning organization of a support case: name and slug for the staff list and detail. */
|
|
28
|
+
export const organization = pgTable("organization", {
|
|
29
|
+
id: uuid().primaryKey().defaultRandom(),
|
|
30
|
+
name: text().notNull(),
|
|
31
|
+
slug: text().unique(),
|
|
32
|
+
createdAt: timestamp({ withTimezone: true }),
|
|
33
|
+
});
|
|
34
|
+
/** A platform user: the case customer and, for `assigned_staff_id`, the staff assignee. */
|
|
35
|
+
export const user = pgTable("user", {
|
|
36
|
+
id: uuid().primaryKey().defaultRandom(),
|
|
37
|
+
name: text(),
|
|
38
|
+
email: text().notNull().unique(),
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* The AI usage ledger: one row per metered AI action, snapshotting the real USD cost of serving it in
|
|
42
|
+
* `cost_micros` (1e-6 USD). Read for the staff AI-spend rollup.
|
|
43
|
+
*/
|
|
44
|
+
export const aiUsageLedger = pgTable("ai_usage_ledger", {
|
|
45
|
+
id: uuid().primaryKey().defaultRandom(),
|
|
46
|
+
user_id: uuid().notNull(),
|
|
47
|
+
org_id: uuid(),
|
|
48
|
+
kind: text().notNull(),
|
|
49
|
+
credits: integer().notNull(),
|
|
50
|
+
source: text().notNull(),
|
|
51
|
+
model: text(),
|
|
52
|
+
cost_micros: bigint({ mode: "number" }),
|
|
53
|
+
created_at: timestamp({ withTimezone: true }).notNull(),
|
|
54
|
+
});
|
|
55
|
+
/**
|
|
56
|
+
* The org billing record, the sole source of an org's plan. The staff app reads it for the org
|
|
57
|
+
* detail and changes a plan only through the console's `set-plan` route, never by writing here, so
|
|
58
|
+
* the console stays the single writer.
|
|
59
|
+
*/
|
|
60
|
+
export const organizationBilling = pgTable("organization_billing", {
|
|
61
|
+
id: uuid().primaryKey().defaultRandom(),
|
|
62
|
+
organizationId: uuid().notNull().unique(),
|
|
63
|
+
plan: billingPlan().notNull(),
|
|
64
|
+
status: billingStatus().notNull(),
|
|
65
|
+
stripeCustomerId: text(),
|
|
66
|
+
stripeSubscriptionId: text(),
|
|
67
|
+
paddleCustomerId: text(),
|
|
68
|
+
paddleSubscriptionId: text(),
|
|
69
|
+
seats: integer(),
|
|
70
|
+
currentPeriodStart: timestamp({ withTimezone: true }),
|
|
71
|
+
currentPeriodEnd: timestamp({ withTimezone: true }),
|
|
72
|
+
welcomedAt: timestamp({ withTimezone: true }),
|
|
73
|
+
updatedAt: timestamp({ withTimezone: true }),
|
|
74
|
+
});
|
|
75
|
+
/** Org membership: the staff app reads the member list and resolves the owner. */
|
|
76
|
+
export const member = pgTable("member", {
|
|
77
|
+
id: uuid().primaryKey().defaultRandom(),
|
|
78
|
+
organizationId: uuid().notNull(),
|
|
79
|
+
userId: uuid().notNull(),
|
|
80
|
+
role: text().notNull(),
|
|
81
|
+
createdAt: timestamp({ withTimezone: true }),
|
|
82
|
+
});
|
package/dist/paddle.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** A Paddle customer id: `ctm_` + 26 lowercase alphanumerics. */
|
|
2
|
+
export declare const PADDLE_CUSTOMER_ID_PATTERN: RegExp;
|
|
3
|
+
/** The message shown when a value does not match {@link PADDLE_CUSTOMER_ID_PATTERN}. */
|
|
4
|
+
export declare const PADDLE_CUSTOMER_ID_HINT = "A Paddle customer id is ctm_ followed by 26 lowercase letters and digits.";
|
package/dist/paddle.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Alethia Labs <legal@alethialabs.io>
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
3
|
+
// The shape of a Paddle customer id, shared by the staff app (which checks what the operator typed)
|
|
4
|
+
// and the console (which re-checks it at its own boundary before writing the billing row). Paddle's
|
|
5
|
+
// API reference documents customer ids as `ctm_` followed by 26 lowercase letters and digits.
|
|
6
|
+
/** A Paddle customer id: `ctm_` + 26 lowercase alphanumerics. */
|
|
7
|
+
export const PADDLE_CUSTOMER_ID_PATTERN = /^ctm_[a-z0-9]{26}$/;
|
|
8
|
+
/** The message shown when a value does not match {@link PADDLE_CUSTOMER_ID_PATTERN}. */
|
|
9
|
+
export const PADDLE_CUSTOMER_ID_HINT = "A Paddle customer id is ctm_ followed by 26 lowercase letters and digits.";
|
package/dist/types.d.ts
CHANGED
|
@@ -14,4 +14,8 @@ export interface PlatformAuditInput {
|
|
|
14
14
|
slug?: string | null;
|
|
15
15
|
stripeCustomerId?: string | null;
|
|
16
16
|
stripeSubscriptionId?: string | null;
|
|
17
|
+
/** The Paddle customer id an operator linked to the org (link_paddle_customer). */
|
|
18
|
+
paddleCustomerId?: string | null;
|
|
19
|
+
/** The value it replaced, when the operator confirmed replacing one. */
|
|
20
|
+
replacedPaddleCustomerId?: string | null;
|
|
17
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alethialabs/platform",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Alethia platform records: enterprise contracts and the platform audit log, as Drizzle schema, enums and types.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"author": "Alethia Labs <legal@alethialabs.io>",
|
|
@@ -29,6 +29,14 @@
|
|
|
29
29
|
"./types": {
|
|
30
30
|
"types": "./dist/types.d.ts",
|
|
31
31
|
"default": "./dist/types.js"
|
|
32
|
+
},
|
|
33
|
+
"./console-refs": {
|
|
34
|
+
"types": "./dist/console-refs.d.ts",
|
|
35
|
+
"default": "./dist/console-refs.js"
|
|
36
|
+
},
|
|
37
|
+
"./paddle": {
|
|
38
|
+
"types": "./dist/paddle.d.ts",
|
|
39
|
+
"default": "./dist/paddle.js"
|
|
32
40
|
}
|
|
33
41
|
},
|
|
34
42
|
"files": [
|