@downcity/services 0.1.69 → 0.1.73

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.
Files changed (46) hide show
  1. package/bin/balance/index.d.ts +2 -2
  2. package/bin/balance/index.d.ts.map +1 -1
  3. package/bin/balance/index.js +1 -1
  4. package/bin/balance/index.js.map +1 -1
  5. package/bin/balance/routes.d.ts.map +1 -1
  6. package/bin/balance/routes.js +36 -0
  7. package/bin/balance/routes.js.map +1 -1
  8. package/bin/balance/schema.d.ts +161 -0
  9. package/bin/balance/schema.d.ts.map +1 -1
  10. package/bin/balance/schema.js +38 -0
  11. package/bin/balance/schema.js.map +1 -1
  12. package/bin/balance/service.d.ts +171 -1
  13. package/bin/balance/service.d.ts.map +1 -1
  14. package/bin/balance/service.js +77 -5
  15. package/bin/balance/service.js.map +1 -1
  16. package/bin/balance/types.d.ts +81 -1
  17. package/bin/balance/types.d.ts.map +1 -1
  18. package/bin/balance/utils.d.ts +5 -1
  19. package/bin/balance/utils.d.ts.map +1 -1
  20. package/bin/balance/utils.js +17 -0
  21. package/bin/balance/utils.js.map +1 -1
  22. package/bin/index.d.ts +3 -5
  23. package/bin/index.d.ts.map +1 -1
  24. package/bin/index.js +2 -3
  25. package/bin/index.js.map +1 -1
  26. package/package.json +2 -2
  27. package/bin/billing/index.d.ts +0 -7
  28. package/bin/billing/index.d.ts.map +0 -1
  29. package/bin/billing/index.js +0 -6
  30. package/bin/billing/index.js.map +0 -1
  31. package/bin/billing/routes.d.ts +0 -14
  32. package/bin/billing/routes.d.ts.map +0 -1
  33. package/bin/billing/routes.js +0 -61
  34. package/bin/billing/routes.js.map +0 -1
  35. package/bin/billing/schema.d.ts +0 -582
  36. package/bin/billing/schema.d.ts.map +0 -1
  37. package/bin/billing/schema.js +0 -81
  38. package/bin/billing/schema.js.map +0 -1
  39. package/bin/billing/service.d.ts +0 -623
  40. package/bin/billing/service.d.ts.map +0 -1
  41. package/bin/billing/service.js +0 -486
  42. package/bin/billing/service.js.map +0 -1
  43. package/bin/billing/types.d.ts +0 -226
  44. package/bin/billing/types.d.ts.map +0 -1
  45. package/bin/billing/types.js +0 -10
  46. package/bin/billing/types.js.map +0 -1
@@ -1,582 +0,0 @@
1
- /**
2
- * Billing 服务表结构定义。
3
- *
4
- * 关键说明(中文)
5
- * - pricing_rules 负责把 usage 事实转换成 microcredits
6
- * - charges 记录每次已经结算的扣费结果
7
- */
8
- export declare const PRICING_RULE_TABLE = "service_billing_pricing_rules";
9
- export declare const CHARGE_TABLE = "service_billing_charges";
10
- /**
11
- * SQLite pricing rule 表。
12
- */
13
- export declare const billingPricingRules: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
14
- name: "service_billing_pricing_rules";
15
- schema: undefined;
16
- columns: {
17
- rule_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
18
- name: "rule_id";
19
- tableName: "service_billing_pricing_rules";
20
- dataType: "string";
21
- columnType: "SQLiteText";
22
- data: string;
23
- driverParam: string;
24
- notNull: true;
25
- hasDefault: false;
26
- isPrimaryKey: true;
27
- isAutoincrement: false;
28
- hasRuntimeDefault: false;
29
- enumValues: [string, ...string[]];
30
- baseColumn: never;
31
- identity: undefined;
32
- generated: undefined;
33
- }, {}, {
34
- length: number | undefined;
35
- }>;
36
- service_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
37
- name: "service_id";
38
- tableName: "service_billing_pricing_rules";
39
- dataType: "string";
40
- columnType: "SQLiteText";
41
- data: string;
42
- driverParam: string;
43
- notNull: true;
44
- hasDefault: false;
45
- isPrimaryKey: false;
46
- isAutoincrement: false;
47
- hasRuntimeDefault: false;
48
- enumValues: [string, ...string[]];
49
- baseColumn: never;
50
- identity: undefined;
51
- generated: undefined;
52
- }, {}, {
53
- length: number | undefined;
54
- }>;
55
- action_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
56
- name: "action_id";
57
- tableName: "service_billing_pricing_rules";
58
- dataType: "string";
59
- columnType: "SQLiteText";
60
- data: string;
61
- driverParam: string;
62
- notNull: true;
63
- hasDefault: false;
64
- isPrimaryKey: false;
65
- isAutoincrement: false;
66
- hasRuntimeDefault: false;
67
- enumValues: [string, ...string[]];
68
- baseColumn: never;
69
- identity: undefined;
70
- generated: undefined;
71
- }, {}, {
72
- length: number | undefined;
73
- }>;
74
- model_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
75
- name: "model_id";
76
- tableName: "service_billing_pricing_rules";
77
- dataType: "string";
78
- columnType: "SQLiteText";
79
- data: string;
80
- driverParam: string;
81
- notNull: true;
82
- hasDefault: false;
83
- isPrimaryKey: false;
84
- isAutoincrement: false;
85
- hasRuntimeDefault: false;
86
- enumValues: [string, ...string[]];
87
- baseColumn: never;
88
- identity: undefined;
89
- generated: undefined;
90
- }, {}, {
91
- length: number | undefined;
92
- }>;
93
- provider_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
94
- name: "provider_id";
95
- tableName: "service_billing_pricing_rules";
96
- dataType: "string";
97
- columnType: "SQLiteText";
98
- data: string;
99
- driverParam: string;
100
- notNull: true;
101
- hasDefault: false;
102
- isPrimaryKey: false;
103
- isAutoincrement: false;
104
- hasRuntimeDefault: false;
105
- enumValues: [string, ...string[]];
106
- baseColumn: never;
107
- identity: undefined;
108
- generated: undefined;
109
- }, {}, {
110
- length: number | undefined;
111
- }>;
112
- request_microcredits: import("drizzle-orm/sqlite-core").SQLiteColumn<{
113
- name: "request_microcredits";
114
- tableName: "service_billing_pricing_rules";
115
- dataType: "number";
116
- columnType: "SQLiteInteger";
117
- data: number;
118
- driverParam: number;
119
- notNull: true;
120
- hasDefault: false;
121
- isPrimaryKey: false;
122
- isAutoincrement: false;
123
- hasRuntimeDefault: false;
124
- enumValues: undefined;
125
- baseColumn: never;
126
- identity: undefined;
127
- generated: undefined;
128
- }, {}, {}>;
129
- input_token_microcredits: import("drizzle-orm/sqlite-core").SQLiteColumn<{
130
- name: "input_token_microcredits";
131
- tableName: "service_billing_pricing_rules";
132
- dataType: "number";
133
- columnType: "SQLiteInteger";
134
- data: number;
135
- driverParam: number;
136
- notNull: true;
137
- hasDefault: false;
138
- isPrimaryKey: false;
139
- isAutoincrement: false;
140
- hasRuntimeDefault: false;
141
- enumValues: undefined;
142
- baseColumn: never;
143
- identity: undefined;
144
- generated: undefined;
145
- }, {}, {}>;
146
- input_mtoken_microcredits: import("drizzle-orm/sqlite-core").SQLiteColumn<{
147
- name: "input_mtoken_microcredits";
148
- tableName: "service_billing_pricing_rules";
149
- dataType: "number";
150
- columnType: "SQLiteInteger";
151
- data: number;
152
- driverParam: number;
153
- notNull: true;
154
- hasDefault: false;
155
- isPrimaryKey: false;
156
- isAutoincrement: false;
157
- hasRuntimeDefault: false;
158
- enumValues: undefined;
159
- baseColumn: never;
160
- identity: undefined;
161
- generated: undefined;
162
- }, {}, {}>;
163
- output_token_microcredits: import("drizzle-orm/sqlite-core").SQLiteColumn<{
164
- name: "output_token_microcredits";
165
- tableName: "service_billing_pricing_rules";
166
- dataType: "number";
167
- columnType: "SQLiteInteger";
168
- data: number;
169
- driverParam: number;
170
- notNull: true;
171
- hasDefault: false;
172
- isPrimaryKey: false;
173
- isAutoincrement: false;
174
- hasRuntimeDefault: false;
175
- enumValues: undefined;
176
- baseColumn: never;
177
- identity: undefined;
178
- generated: undefined;
179
- }, {}, {}>;
180
- output_mtoken_microcredits: import("drizzle-orm/sqlite-core").SQLiteColumn<{
181
- name: "output_mtoken_microcredits";
182
- tableName: "service_billing_pricing_rules";
183
- dataType: "number";
184
- columnType: "SQLiteInteger";
185
- data: number;
186
- driverParam: number;
187
- notNull: true;
188
- hasDefault: false;
189
- isPrimaryKey: false;
190
- isAutoincrement: false;
191
- hasRuntimeDefault: false;
192
- enumValues: undefined;
193
- baseColumn: never;
194
- identity: undefined;
195
- generated: undefined;
196
- }, {}, {}>;
197
- cached_token_microcredits: import("drizzle-orm/sqlite-core").SQLiteColumn<{
198
- name: "cached_token_microcredits";
199
- tableName: "service_billing_pricing_rules";
200
- dataType: "number";
201
- columnType: "SQLiteInteger";
202
- data: number;
203
- driverParam: number;
204
- notNull: true;
205
- hasDefault: false;
206
- isPrimaryKey: false;
207
- isAutoincrement: false;
208
- hasRuntimeDefault: false;
209
- enumValues: undefined;
210
- baseColumn: never;
211
- identity: undefined;
212
- generated: undefined;
213
- }, {}, {}>;
214
- cached_mtoken_microcredits: import("drizzle-orm/sqlite-core").SQLiteColumn<{
215
- name: "cached_mtoken_microcredits";
216
- tableName: "service_billing_pricing_rules";
217
- dataType: "number";
218
- columnType: "SQLiteInteger";
219
- data: number;
220
- driverParam: number;
221
- notNull: true;
222
- hasDefault: false;
223
- isPrimaryKey: false;
224
- isAutoincrement: false;
225
- hasRuntimeDefault: false;
226
- enumValues: undefined;
227
- baseColumn: never;
228
- identity: undefined;
229
- generated: undefined;
230
- }, {}, {}>;
231
- image_microcredits: import("drizzle-orm/sqlite-core").SQLiteColumn<{
232
- name: "image_microcredits";
233
- tableName: "service_billing_pricing_rules";
234
- dataType: "number";
235
- columnType: "SQLiteInteger";
236
- data: number;
237
- driverParam: number;
238
- notNull: true;
239
- hasDefault: false;
240
- isPrimaryKey: false;
241
- isAutoincrement: false;
242
- hasRuntimeDefault: false;
243
- enumValues: undefined;
244
- baseColumn: never;
245
- identity: undefined;
246
- generated: undefined;
247
- }, {}, {}>;
248
- status: import("drizzle-orm/sqlite-core").SQLiteColumn<{
249
- name: "status";
250
- tableName: "service_billing_pricing_rules";
251
- dataType: "string";
252
- columnType: "SQLiteText";
253
- data: string;
254
- driverParam: string;
255
- notNull: true;
256
- hasDefault: false;
257
- isPrimaryKey: false;
258
- isAutoincrement: false;
259
- hasRuntimeDefault: false;
260
- enumValues: [string, ...string[]];
261
- baseColumn: never;
262
- identity: undefined;
263
- generated: undefined;
264
- }, {}, {
265
- length: number | undefined;
266
- }>;
267
- note: import("drizzle-orm/sqlite-core").SQLiteColumn<{
268
- name: "note";
269
- tableName: "service_billing_pricing_rules";
270
- dataType: "string";
271
- columnType: "SQLiteText";
272
- data: string;
273
- driverParam: string;
274
- notNull: true;
275
- hasDefault: false;
276
- isPrimaryKey: false;
277
- isAutoincrement: false;
278
- hasRuntimeDefault: false;
279
- enumValues: [string, ...string[]];
280
- baseColumn: never;
281
- identity: undefined;
282
- generated: undefined;
283
- }, {}, {
284
- length: number | undefined;
285
- }>;
286
- created_at: import("drizzle-orm/sqlite-core").SQLiteColumn<{
287
- name: "created_at";
288
- tableName: "service_billing_pricing_rules";
289
- dataType: "string";
290
- columnType: "SQLiteText";
291
- data: string;
292
- driverParam: string;
293
- notNull: true;
294
- hasDefault: false;
295
- isPrimaryKey: false;
296
- isAutoincrement: false;
297
- hasRuntimeDefault: false;
298
- enumValues: [string, ...string[]];
299
- baseColumn: never;
300
- identity: undefined;
301
- generated: undefined;
302
- }, {}, {
303
- length: number | undefined;
304
- }>;
305
- updated_at: import("drizzle-orm/sqlite-core").SQLiteColumn<{
306
- name: "updated_at";
307
- tableName: "service_billing_pricing_rules";
308
- dataType: "string";
309
- columnType: "SQLiteText";
310
- data: string;
311
- driverParam: string;
312
- notNull: true;
313
- hasDefault: false;
314
- isPrimaryKey: false;
315
- isAutoincrement: false;
316
- hasRuntimeDefault: false;
317
- enumValues: [string, ...string[]];
318
- baseColumn: never;
319
- identity: undefined;
320
- generated: undefined;
321
- }, {}, {
322
- length: number | undefined;
323
- }>;
324
- };
325
- dialect: "sqlite";
326
- }>;
327
- /**
328
- * SQLite charge 表。
329
- */
330
- export declare const billingCharges: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
331
- name: "service_billing_charges";
332
- schema: undefined;
333
- columns: {
334
- charge_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
335
- name: "charge_id";
336
- tableName: "service_billing_charges";
337
- dataType: "string";
338
- columnType: "SQLiteText";
339
- data: string;
340
- driverParam: string;
341
- notNull: true;
342
- hasDefault: false;
343
- isPrimaryKey: true;
344
- isAutoincrement: false;
345
- hasRuntimeDefault: false;
346
- enumValues: [string, ...string[]];
347
- baseColumn: never;
348
- identity: undefined;
349
- generated: undefined;
350
- }, {}, {
351
- length: number | undefined;
352
- }>;
353
- user_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
354
- name: "user_id";
355
- tableName: "service_billing_charges";
356
- dataType: "string";
357
- columnType: "SQLiteText";
358
- data: string;
359
- driverParam: string;
360
- notNull: true;
361
- hasDefault: false;
362
- isPrimaryKey: false;
363
- isAutoincrement: false;
364
- hasRuntimeDefault: false;
365
- enumValues: [string, ...string[]];
366
- baseColumn: never;
367
- identity: undefined;
368
- generated: undefined;
369
- }, {}, {
370
- length: number | undefined;
371
- }>;
372
- town_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
373
- name: "town_id";
374
- tableName: "service_billing_charges";
375
- dataType: "string";
376
- columnType: "SQLiteText";
377
- data: string;
378
- driverParam: string;
379
- notNull: true;
380
- hasDefault: false;
381
- isPrimaryKey: false;
382
- isAutoincrement: false;
383
- hasRuntimeDefault: false;
384
- enumValues: [string, ...string[]];
385
- baseColumn: never;
386
- identity: undefined;
387
- generated: undefined;
388
- }, {}, {
389
- length: number | undefined;
390
- }>;
391
- service_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
392
- name: "service_id";
393
- tableName: "service_billing_charges";
394
- dataType: "string";
395
- columnType: "SQLiteText";
396
- data: string;
397
- driverParam: string;
398
- notNull: true;
399
- hasDefault: false;
400
- isPrimaryKey: false;
401
- isAutoincrement: false;
402
- hasRuntimeDefault: false;
403
- enumValues: [string, ...string[]];
404
- baseColumn: never;
405
- identity: undefined;
406
- generated: undefined;
407
- }, {}, {
408
- length: number | undefined;
409
- }>;
410
- action_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
411
- name: "action_id";
412
- tableName: "service_billing_charges";
413
- dataType: "string";
414
- columnType: "SQLiteText";
415
- data: string;
416
- driverParam: string;
417
- notNull: true;
418
- hasDefault: false;
419
- isPrimaryKey: false;
420
- isAutoincrement: false;
421
- hasRuntimeDefault: false;
422
- enumValues: [string, ...string[]];
423
- baseColumn: never;
424
- identity: undefined;
425
- generated: undefined;
426
- }, {}, {
427
- length: number | undefined;
428
- }>;
429
- model_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
430
- name: "model_id";
431
- tableName: "service_billing_charges";
432
- dataType: "string";
433
- columnType: "SQLiteText";
434
- data: string;
435
- driverParam: string;
436
- notNull: true;
437
- hasDefault: false;
438
- isPrimaryKey: false;
439
- isAutoincrement: false;
440
- hasRuntimeDefault: false;
441
- enumValues: [string, ...string[]];
442
- baseColumn: never;
443
- identity: undefined;
444
- generated: undefined;
445
- }, {}, {
446
- length: number | undefined;
447
- }>;
448
- provider_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
449
- name: "provider_id";
450
- tableName: "service_billing_charges";
451
- dataType: "string";
452
- columnType: "SQLiteText";
453
- data: string;
454
- driverParam: string;
455
- notNull: true;
456
- hasDefault: false;
457
- isPrimaryKey: false;
458
- isAutoincrement: false;
459
- hasRuntimeDefault: false;
460
- enumValues: [string, ...string[]];
461
- baseColumn: never;
462
- identity: undefined;
463
- generated: undefined;
464
- }, {}, {
465
- length: number | undefined;
466
- }>;
467
- rule_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
468
- name: "rule_id";
469
- tableName: "service_billing_charges";
470
- dataType: "string";
471
- columnType: "SQLiteText";
472
- data: string;
473
- driverParam: string;
474
- notNull: true;
475
- hasDefault: false;
476
- isPrimaryKey: false;
477
- isAutoincrement: false;
478
- hasRuntimeDefault: false;
479
- enumValues: [string, ...string[]];
480
- baseColumn: never;
481
- identity: undefined;
482
- generated: undefined;
483
- }, {}, {
484
- length: number | undefined;
485
- }>;
486
- amount_microcredits: import("drizzle-orm/sqlite-core").SQLiteColumn<{
487
- name: "amount_microcredits";
488
- tableName: "service_billing_charges";
489
- dataType: "number";
490
- columnType: "SQLiteInteger";
491
- data: number;
492
- driverParam: number;
493
- notNull: true;
494
- hasDefault: false;
495
- isPrimaryKey: false;
496
- isAutoincrement: false;
497
- hasRuntimeDefault: false;
498
- enumValues: undefined;
499
- baseColumn: never;
500
- identity: undefined;
501
- generated: undefined;
502
- }, {}, {}>;
503
- status: import("drizzle-orm/sqlite-core").SQLiteColumn<{
504
- name: "status";
505
- tableName: "service_billing_charges";
506
- dataType: "string";
507
- columnType: "SQLiteText";
508
- data: string;
509
- driverParam: string;
510
- notNull: true;
511
- hasDefault: false;
512
- isPrimaryKey: false;
513
- isAutoincrement: false;
514
- hasRuntimeDefault: false;
515
- enumValues: [string, ...string[]];
516
- baseColumn: never;
517
- identity: undefined;
518
- generated: undefined;
519
- }, {}, {
520
- length: number | undefined;
521
- }>;
522
- note: import("drizzle-orm/sqlite-core").SQLiteColumn<{
523
- name: "note";
524
- tableName: "service_billing_charges";
525
- dataType: "string";
526
- columnType: "SQLiteText";
527
- data: string;
528
- driverParam: string;
529
- notNull: true;
530
- hasDefault: false;
531
- isPrimaryKey: false;
532
- isAutoincrement: false;
533
- hasRuntimeDefault: false;
534
- enumValues: [string, ...string[]];
535
- baseColumn: never;
536
- identity: undefined;
537
- generated: undefined;
538
- }, {}, {
539
- length: number | undefined;
540
- }>;
541
- metadata_json: import("drizzle-orm/sqlite-core").SQLiteColumn<{
542
- name: "metadata_json";
543
- tableName: "service_billing_charges";
544
- dataType: "string";
545
- columnType: "SQLiteText";
546
- data: string;
547
- driverParam: string;
548
- notNull: true;
549
- hasDefault: false;
550
- isPrimaryKey: false;
551
- isAutoincrement: false;
552
- hasRuntimeDefault: false;
553
- enumValues: [string, ...string[]];
554
- baseColumn: never;
555
- identity: undefined;
556
- generated: undefined;
557
- }, {}, {
558
- length: number | undefined;
559
- }>;
560
- created_at: import("drizzle-orm/sqlite-core").SQLiteColumn<{
561
- name: "created_at";
562
- tableName: "service_billing_charges";
563
- dataType: "string";
564
- columnType: "SQLiteText";
565
- data: string;
566
- driverParam: string;
567
- notNull: true;
568
- hasDefault: false;
569
- isPrimaryKey: false;
570
- isAutoincrement: false;
571
- hasRuntimeDefault: false;
572
- enumValues: [string, ...string[]];
573
- baseColumn: never;
574
- identity: undefined;
575
- generated: undefined;
576
- }, {}, {
577
- length: number | undefined;
578
- }>;
579
- };
580
- dialect: "sqlite";
581
- }>;
582
- //# sourceMappingURL=schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/billing/schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,eAAO,MAAM,kBAAkB,kCAAkC,CAAC;AAClE,eAAO,MAAM,YAAY,4BAA4B,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmC9B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BzB,CAAC"}
@@ -1,81 +0,0 @@
1
- /**
2
- * Billing 服务表结构定义。
3
- *
4
- * 关键说明(中文)
5
- * - pricing_rules 负责把 usage 事实转换成 microcredits
6
- * - charges 记录每次已经结算的扣费结果
7
- */
8
- import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
9
- export const PRICING_RULE_TABLE = "service_billing_pricing_rules";
10
- export const CHARGE_TABLE = "service_billing_charges";
11
- /**
12
- * SQLite pricing rule 表。
13
- */
14
- export const billingPricingRules = sqliteTable(PRICING_RULE_TABLE, {
15
- /** 规则 ID。 */
16
- rule_id: text("rule_id").primaryKey(),
17
- /** 服务 ID,例如 ai。 */
18
- service_id: text("service_id").notNull(),
19
- /** action ID,例如 chat/completions。 */
20
- action_id: text("action_id").notNull(),
21
- /** 模型 ID,空字符串表示 fallback。 */
22
- model_id: text("model_id").notNull(),
23
- /** provider ID,空字符串表示 fallback。 */
24
- provider_id: text("provider_id").notNull(),
25
- /** 每次请求固定扣费。 */
26
- request_microcredits: integer("request_microcredits").notNull(),
27
- /** 每个 input token 扣费。 */
28
- input_token_microcredits: integer("input_token_microcredits").notNull(),
29
- /** 每 1,000,000 个 input token 扣费。 */
30
- input_mtoken_microcredits: integer("input_mtoken_microcredits").notNull(),
31
- /** 每个 output token 扣费。 */
32
- output_token_microcredits: integer("output_token_microcredits").notNull(),
33
- /** 每 1,000,000 个 output token 扣费。 */
34
- output_mtoken_microcredits: integer("output_mtoken_microcredits").notNull(),
35
- /** 每个 cached input token 扣费。 */
36
- cached_token_microcredits: integer("cached_token_microcredits").notNull(),
37
- /** 每 1,000,000 个 cached input token 扣费。 */
38
- cached_mtoken_microcredits: integer("cached_mtoken_microcredits").notNull(),
39
- /** 每张图片扣费。 */
40
- image_microcredits: integer("image_microcredits").notNull(),
41
- /** 规则状态。 */
42
- status: text("status").notNull(),
43
- /** 说明文本。 */
44
- note: text("note").notNull(),
45
- /** 创建时间。 */
46
- created_at: text("created_at").notNull(),
47
- /** 更新时间。 */
48
- updated_at: text("updated_at").notNull(),
49
- });
50
- /**
51
- * SQLite charge 表。
52
- */
53
- export const billingCharges = sqliteTable(CHARGE_TABLE, {
54
- /** 扣费记录 ID。 */
55
- charge_id: text("charge_id").primaryKey(),
56
- /** 用户 ID。 */
57
- user_id: text("user_id").notNull(),
58
- /** Town ID。 */
59
- town_id: text("town_id").notNull(),
60
- /** 服务 ID。 */
61
- service_id: text("service_id").notNull(),
62
- /** action ID。 */
63
- action_id: text("action_id").notNull(),
64
- /** 模型 ID。 */
65
- model_id: text("model_id").notNull(),
66
- /** provider ID。 */
67
- provider_id: text("provider_id").notNull(),
68
- /** 命中的 pricing rule ID。 */
69
- rule_id: text("rule_id").notNull(),
70
- /** 扣费金额,单位为 microcredits。 */
71
- amount_microcredits: integer("amount_microcredits").notNull(),
72
- /** 状态。 */
73
- status: text("status").notNull(),
74
- /** 说明文本。 */
75
- note: text("note").notNull(),
76
- /** 扩展字段 JSON。 */
77
- metadata_json: text("metadata_json").notNull(),
78
- /** 创建时间。 */
79
- created_at: text("created_at").notNull(),
80
- });
81
- //# sourceMappingURL=schema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/billing/schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAErE,MAAM,CAAC,MAAM,kBAAkB,GAAG,+BAA+B,CAAC;AAClE,MAAM,CAAC,MAAM,YAAY,GAAG,yBAAyB,CAAC;AAEtD;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,WAAW,CAAC,kBAAkB,EAAE;IACjE,aAAa;IACb,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE;IACrC,mBAAmB;IACnB,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IACxC,qCAAqC;IACrC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE;IACtC,6BAA6B;IAC7B,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE;I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