@downcity/services 0.1.59 → 0.1.62

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 (66) hide show
  1. package/LICENSE +183 -0
  2. package/bin/balance/amount.d.ts +51 -0
  3. package/bin/balance/amount.d.ts.map +1 -0
  4. package/bin/balance/amount.js +101 -0
  5. package/bin/balance/amount.js.map +1 -0
  6. package/bin/balance/index.d.ts +2 -0
  7. package/bin/balance/index.d.ts.map +1 -1
  8. package/bin/balance/index.js +1 -0
  9. package/bin/balance/index.js.map +1 -1
  10. package/bin/balance/routes.d.ts.map +1 -1
  11. package/bin/balance/routes.js +1 -0
  12. package/bin/balance/routes.js.map +1 -1
  13. package/bin/balance/service.d.ts +13 -1
  14. package/bin/balance/service.d.ts.map +1 -1
  15. package/bin/balance/service.js +54 -25
  16. package/bin/balance/service.js.map +1 -1
  17. package/bin/balance/types.d.ts +44 -9
  18. package/bin/balance/types.d.ts.map +1 -1
  19. package/bin/balance/types.js +2 -1
  20. package/bin/balance/types.js.map +1 -1
  21. package/bin/balance/utils.d.ts.map +1 -1
  22. package/bin/balance/utils.js +17 -5
  23. package/bin/balance/utils.js.map +1 -1
  24. package/bin/billing/index.d.ts +7 -0
  25. package/bin/billing/index.d.ts.map +1 -0
  26. package/bin/billing/index.js +6 -0
  27. package/bin/billing/index.js.map +1 -0
  28. package/bin/billing/routes.d.ts +14 -0
  29. package/bin/billing/routes.d.ts.map +1 -0
  30. package/bin/billing/routes.js +61 -0
  31. package/bin/billing/routes.js.map +1 -0
  32. package/bin/billing/schema.d.ts +582 -0
  33. package/bin/billing/schema.d.ts.map +1 -0
  34. package/bin/billing/schema.js +81 -0
  35. package/bin/billing/schema.js.map +1 -0
  36. package/bin/billing/service.d.ts +619 -0
  37. package/bin/billing/service.d.ts.map +1 -0
  38. package/bin/billing/service.js +457 -0
  39. package/bin/billing/service.js.map +1 -0
  40. package/bin/billing/types.d.ts +205 -0
  41. package/bin/billing/types.d.ts.map +1 -0
  42. package/bin/billing/types.js +10 -0
  43. package/bin/billing/types.js.map +1 -0
  44. package/bin/index.d.ts +5 -1
  45. package/bin/index.d.ts.map +1 -1
  46. package/bin/index.js +3 -1
  47. package/bin/index.js.map +1 -1
  48. package/bin/payment/types.d.ts +5 -1
  49. package/bin/payment/types.d.ts.map +1 -1
  50. package/bin/payment-creem/creem.d.ts.map +1 -1
  51. package/bin/payment-creem/creem.js +15 -0
  52. package/bin/payment-creem/creem.js.map +1 -1
  53. package/bin/payment-dodo/dodo.d.ts.map +1 -1
  54. package/bin/payment-dodo/dodo.js +16 -1
  55. package/bin/payment-dodo/dodo.js.map +1 -1
  56. package/bin/payment-stripe/stripe.d.ts.map +1 -1
  57. package/bin/payment-stripe/stripe.js +14 -1
  58. package/bin/payment-stripe/stripe.js.map +1 -1
  59. package/bin/payment-waffo/waffo.d.ts.map +1 -1
  60. package/bin/payment-waffo/waffo.js +15 -0
  61. package/bin/payment-waffo/waffo.js.map +1 -1
  62. package/bin/types/Amount.d.ts +25 -0
  63. package/bin/types/Amount.d.ts.map +1 -0
  64. package/bin/types/Amount.js +17 -0
  65. package/bin/types/Amount.js.map +1 -0
  66. package/package.json +2 -2
@@ -0,0 +1,619 @@
1
+ /**
2
+ * Downcity 官方 Billing 服务实现。
3
+ *
4
+ * 设计边界:
5
+ * - usage 负责记录事实,billing 负责把事实换算成 charge
6
+ * - balance 负责真正的钱包扣减与流水
7
+ * - pricing rule 使用 microcredits,1 credit = 1 USD = 1_000_000 microcredits
8
+ */
9
+ import { InstallableService, type Context, type ServiceInstallContext } from "@downcity/city";
10
+ import type { BillingCharge, BillingChargeQuery, BillingPricingRule, BillingPricingRuleInput, BillingPricingRuleQuery, BillingServiceOptions } from "./types.js";
11
+ /**
12
+ * Billing 服务实例。
13
+ */
14
+ export declare class BillingService extends InstallableService {
15
+ readonly id = "billing";
16
+ readonly name = "Billing";
17
+ readonly version = "0.1.0";
18
+ readonly schema: {
19
+ pricing_rules: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
20
+ name: "service_billing_pricing_rules";
21
+ schema: undefined;
22
+ columns: {
23
+ rule_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
24
+ name: "rule_id";
25
+ tableName: "service_billing_pricing_rules";
26
+ dataType: "string";
27
+ columnType: "SQLiteText";
28
+ data: string;
29
+ driverParam: string;
30
+ notNull: true;
31
+ hasDefault: false;
32
+ isPrimaryKey: true;
33
+ isAutoincrement: false;
34
+ hasRuntimeDefault: false;
35
+ enumValues: [string, ...string[]];
36
+ baseColumn: never;
37
+ identity: undefined;
38
+ generated: undefined;
39
+ }, {}, {
40
+ length: number | undefined;
41
+ }>;
42
+ service_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
43
+ name: "service_id";
44
+ tableName: "service_billing_pricing_rules";
45
+ dataType: "string";
46
+ columnType: "SQLiteText";
47
+ data: string;
48
+ driverParam: string;
49
+ notNull: true;
50
+ hasDefault: false;
51
+ isPrimaryKey: false;
52
+ isAutoincrement: false;
53
+ hasRuntimeDefault: false;
54
+ enumValues: [string, ...string[]];
55
+ baseColumn: never;
56
+ identity: undefined;
57
+ generated: undefined;
58
+ }, {}, {
59
+ length: number | undefined;
60
+ }>;
61
+ action_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
62
+ name: "action_id";
63
+ tableName: "service_billing_pricing_rules";
64
+ dataType: "string";
65
+ columnType: "SQLiteText";
66
+ data: string;
67
+ driverParam: string;
68
+ notNull: true;
69
+ hasDefault: false;
70
+ isPrimaryKey: false;
71
+ isAutoincrement: false;
72
+ hasRuntimeDefault: false;
73
+ enumValues: [string, ...string[]];
74
+ baseColumn: never;
75
+ identity: undefined;
76
+ generated: undefined;
77
+ }, {}, {
78
+ length: number | undefined;
79
+ }>;
80
+ model_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
81
+ name: "model_id";
82
+ tableName: "service_billing_pricing_rules";
83
+ dataType: "string";
84
+ columnType: "SQLiteText";
85
+ data: string;
86
+ driverParam: string;
87
+ notNull: true;
88
+ hasDefault: false;
89
+ isPrimaryKey: false;
90
+ isAutoincrement: false;
91
+ hasRuntimeDefault: false;
92
+ enumValues: [string, ...string[]];
93
+ baseColumn: never;
94
+ identity: undefined;
95
+ generated: undefined;
96
+ }, {}, {
97
+ length: number | undefined;
98
+ }>;
99
+ provider_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
100
+ name: "provider_id";
101
+ tableName: "service_billing_pricing_rules";
102
+ dataType: "string";
103
+ columnType: "SQLiteText";
104
+ data: string;
105
+ driverParam: string;
106
+ notNull: true;
107
+ hasDefault: false;
108
+ isPrimaryKey: false;
109
+ isAutoincrement: false;
110
+ hasRuntimeDefault: false;
111
+ enumValues: [string, ...string[]];
112
+ baseColumn: never;
113
+ identity: undefined;
114
+ generated: undefined;
115
+ }, {}, {
116
+ length: number | undefined;
117
+ }>;
118
+ request_microcredits: import("drizzle-orm/sqlite-core").SQLiteColumn<{
119
+ name: "request_microcredits";
120
+ tableName: "service_billing_pricing_rules";
121
+ dataType: "number";
122
+ columnType: "SQLiteInteger";
123
+ data: number;
124
+ driverParam: number;
125
+ notNull: true;
126
+ hasDefault: false;
127
+ isPrimaryKey: false;
128
+ isAutoincrement: false;
129
+ hasRuntimeDefault: false;
130
+ enumValues: undefined;
131
+ baseColumn: never;
132
+ identity: undefined;
133
+ generated: undefined;
134
+ }, {}, {}>;
135
+ input_token_microcredits: import("drizzle-orm/sqlite-core").SQLiteColumn<{
136
+ name: "input_token_microcredits";
137
+ tableName: "service_billing_pricing_rules";
138
+ dataType: "number";
139
+ columnType: "SQLiteInteger";
140
+ data: number;
141
+ driverParam: number;
142
+ notNull: true;
143
+ hasDefault: false;
144
+ isPrimaryKey: false;
145
+ isAutoincrement: false;
146
+ hasRuntimeDefault: false;
147
+ enumValues: undefined;
148
+ baseColumn: never;
149
+ identity: undefined;
150
+ generated: undefined;
151
+ }, {}, {}>;
152
+ input_mtoken_microcredits: import("drizzle-orm/sqlite-core").SQLiteColumn<{
153
+ name: "input_mtoken_microcredits";
154
+ tableName: "service_billing_pricing_rules";
155
+ dataType: "number";
156
+ columnType: "SQLiteInteger";
157
+ data: number;
158
+ driverParam: number;
159
+ notNull: true;
160
+ hasDefault: false;
161
+ isPrimaryKey: false;
162
+ isAutoincrement: false;
163
+ hasRuntimeDefault: false;
164
+ enumValues: undefined;
165
+ baseColumn: never;
166
+ identity: undefined;
167
+ generated: undefined;
168
+ }, {}, {}>;
169
+ output_token_microcredits: import("drizzle-orm/sqlite-core").SQLiteColumn<{
170
+ name: "output_token_microcredits";
171
+ tableName: "service_billing_pricing_rules";
172
+ dataType: "number";
173
+ columnType: "SQLiteInteger";
174
+ data: number;
175
+ driverParam: number;
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
+ output_mtoken_microcredits: import("drizzle-orm/sqlite-core").SQLiteColumn<{
187
+ name: "output_mtoken_microcredits";
188
+ tableName: "service_billing_pricing_rules";
189
+ dataType: "number";
190
+ columnType: "SQLiteInteger";
191
+ data: number;
192
+ driverParam: number;
193
+ notNull: true;
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
+ cached_token_microcredits: import("drizzle-orm/sqlite-core").SQLiteColumn<{
204
+ name: "cached_token_microcredits";
205
+ tableName: "service_billing_pricing_rules";
206
+ dataType: "number";
207
+ columnType: "SQLiteInteger";
208
+ data: number;
209
+ driverParam: number;
210
+ notNull: true;
211
+ hasDefault: false;
212
+ isPrimaryKey: false;
213
+ isAutoincrement: false;
214
+ hasRuntimeDefault: false;
215
+ enumValues: undefined;
216
+ baseColumn: never;
217
+ identity: undefined;
218
+ generated: undefined;
219
+ }, {}, {}>;
220
+ cached_mtoken_microcredits: import("drizzle-orm/sqlite-core").SQLiteColumn<{
221
+ name: "cached_mtoken_microcredits";
222
+ tableName: "service_billing_pricing_rules";
223
+ dataType: "number";
224
+ columnType: "SQLiteInteger";
225
+ data: number;
226
+ driverParam: 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
+ image_microcredits: import("drizzle-orm/sqlite-core").SQLiteColumn<{
238
+ name: "image_microcredits";
239
+ tableName: "service_billing_pricing_rules";
240
+ dataType: "number";
241
+ columnType: "SQLiteInteger";
242
+ data: number;
243
+ driverParam: number;
244
+ notNull: true;
245
+ hasDefault: false;
246
+ isPrimaryKey: false;
247
+ isAutoincrement: false;
248
+ hasRuntimeDefault: false;
249
+ enumValues: undefined;
250
+ baseColumn: never;
251
+ identity: undefined;
252
+ generated: undefined;
253
+ }, {}, {}>;
254
+ status: import("drizzle-orm/sqlite-core").SQLiteColumn<{
255
+ name: "status";
256
+ tableName: "service_billing_pricing_rules";
257
+ dataType: "string";
258
+ columnType: "SQLiteText";
259
+ data: string;
260
+ driverParam: string;
261
+ notNull: true;
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
+ length: number | undefined;
272
+ }>;
273
+ note: import("drizzle-orm/sqlite-core").SQLiteColumn<{
274
+ name: "note";
275
+ tableName: "service_billing_pricing_rules";
276
+ dataType: "string";
277
+ columnType: "SQLiteText";
278
+ data: string;
279
+ driverParam: string;
280
+ notNull: true;
281
+ hasDefault: false;
282
+ isPrimaryKey: false;
283
+ isAutoincrement: false;
284
+ hasRuntimeDefault: false;
285
+ enumValues: [string, ...string[]];
286
+ baseColumn: never;
287
+ identity: undefined;
288
+ generated: undefined;
289
+ }, {}, {
290
+ length: number | undefined;
291
+ }>;
292
+ created_at: import("drizzle-orm/sqlite-core").SQLiteColumn<{
293
+ name: "created_at";
294
+ tableName: "service_billing_pricing_rules";
295
+ dataType: "string";
296
+ columnType: "SQLiteText";
297
+ data: string;
298
+ driverParam: string;
299
+ notNull: true;
300
+ hasDefault: false;
301
+ isPrimaryKey: false;
302
+ isAutoincrement: false;
303
+ hasRuntimeDefault: false;
304
+ enumValues: [string, ...string[]];
305
+ baseColumn: never;
306
+ identity: undefined;
307
+ generated: undefined;
308
+ }, {}, {
309
+ length: number | undefined;
310
+ }>;
311
+ updated_at: import("drizzle-orm/sqlite-core").SQLiteColumn<{
312
+ name: "updated_at";
313
+ tableName: "service_billing_pricing_rules";
314
+ dataType: "string";
315
+ columnType: "SQLiteText";
316
+ data: string;
317
+ driverParam: string;
318
+ notNull: true;
319
+ hasDefault: false;
320
+ isPrimaryKey: false;
321
+ isAutoincrement: false;
322
+ hasRuntimeDefault: false;
323
+ enumValues: [string, ...string[]];
324
+ baseColumn: never;
325
+ identity: undefined;
326
+ generated: undefined;
327
+ }, {}, {
328
+ length: number | undefined;
329
+ }>;
330
+ };
331
+ dialect: "sqlite";
332
+ }>;
333
+ charges: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
334
+ name: "service_billing_charges";
335
+ schema: undefined;
336
+ columns: {
337
+ charge_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
338
+ name: "charge_id";
339
+ tableName: "service_billing_charges";
340
+ dataType: "string";
341
+ columnType: "SQLiteText";
342
+ data: string;
343
+ driverParam: string;
344
+ notNull: true;
345
+ hasDefault: false;
346
+ isPrimaryKey: true;
347
+ isAutoincrement: false;
348
+ hasRuntimeDefault: false;
349
+ enumValues: [string, ...string[]];
350
+ baseColumn: never;
351
+ identity: undefined;
352
+ generated: undefined;
353
+ }, {}, {
354
+ length: number | undefined;
355
+ }>;
356
+ user_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
357
+ name: "user_id";
358
+ tableName: "service_billing_charges";
359
+ dataType: "string";
360
+ columnType: "SQLiteText";
361
+ data: string;
362
+ driverParam: string;
363
+ notNull: true;
364
+ hasDefault: false;
365
+ isPrimaryKey: false;
366
+ isAutoincrement: false;
367
+ hasRuntimeDefault: false;
368
+ enumValues: [string, ...string[]];
369
+ baseColumn: never;
370
+ identity: undefined;
371
+ generated: undefined;
372
+ }, {}, {
373
+ length: number | undefined;
374
+ }>;
375
+ town_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
376
+ name: "town_id";
377
+ tableName: "service_billing_charges";
378
+ dataType: "string";
379
+ columnType: "SQLiteText";
380
+ data: string;
381
+ driverParam: string;
382
+ notNull: true;
383
+ hasDefault: false;
384
+ isPrimaryKey: false;
385
+ isAutoincrement: false;
386
+ hasRuntimeDefault: false;
387
+ enumValues: [string, ...string[]];
388
+ baseColumn: never;
389
+ identity: undefined;
390
+ generated: undefined;
391
+ }, {}, {
392
+ length: number | undefined;
393
+ }>;
394
+ service_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
395
+ name: "service_id";
396
+ tableName: "service_billing_charges";
397
+ dataType: "string";
398
+ columnType: "SQLiteText";
399
+ data: string;
400
+ driverParam: string;
401
+ notNull: true;
402
+ hasDefault: false;
403
+ isPrimaryKey: false;
404
+ isAutoincrement: false;
405
+ hasRuntimeDefault: false;
406
+ enumValues: [string, ...string[]];
407
+ baseColumn: never;
408
+ identity: undefined;
409
+ generated: undefined;
410
+ }, {}, {
411
+ length: number | undefined;
412
+ }>;
413
+ action_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
414
+ name: "action_id";
415
+ tableName: "service_billing_charges";
416
+ dataType: "string";
417
+ columnType: "SQLiteText";
418
+ data: string;
419
+ driverParam: string;
420
+ notNull: true;
421
+ hasDefault: false;
422
+ isPrimaryKey: false;
423
+ isAutoincrement: false;
424
+ hasRuntimeDefault: false;
425
+ enumValues: [string, ...string[]];
426
+ baseColumn: never;
427
+ identity: undefined;
428
+ generated: undefined;
429
+ }, {}, {
430
+ length: number | undefined;
431
+ }>;
432
+ model_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
433
+ name: "model_id";
434
+ tableName: "service_billing_charges";
435
+ dataType: "string";
436
+ columnType: "SQLiteText";
437
+ data: string;
438
+ driverParam: string;
439
+ notNull: true;
440
+ hasDefault: false;
441
+ isPrimaryKey: false;
442
+ isAutoincrement: false;
443
+ hasRuntimeDefault: false;
444
+ enumValues: [string, ...string[]];
445
+ baseColumn: never;
446
+ identity: undefined;
447
+ generated: undefined;
448
+ }, {}, {
449
+ length: number | undefined;
450
+ }>;
451
+ provider_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
452
+ name: "provider_id";
453
+ tableName: "service_billing_charges";
454
+ dataType: "string";
455
+ columnType: "SQLiteText";
456
+ data: string;
457
+ driverParam: string;
458
+ notNull: true;
459
+ hasDefault: false;
460
+ isPrimaryKey: false;
461
+ isAutoincrement: false;
462
+ hasRuntimeDefault: false;
463
+ enumValues: [string, ...string[]];
464
+ baseColumn: never;
465
+ identity: undefined;
466
+ generated: undefined;
467
+ }, {}, {
468
+ length: number | undefined;
469
+ }>;
470
+ rule_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
471
+ name: "rule_id";
472
+ tableName: "service_billing_charges";
473
+ dataType: "string";
474
+ columnType: "SQLiteText";
475
+ data: string;
476
+ driverParam: string;
477
+ notNull: true;
478
+ hasDefault: false;
479
+ isPrimaryKey: false;
480
+ isAutoincrement: false;
481
+ hasRuntimeDefault: false;
482
+ enumValues: [string, ...string[]];
483
+ baseColumn: never;
484
+ identity: undefined;
485
+ generated: undefined;
486
+ }, {}, {
487
+ length: number | undefined;
488
+ }>;
489
+ amount_microcredits: import("drizzle-orm/sqlite-core").SQLiteColumn<{
490
+ name: "amount_microcredits";
491
+ tableName: "service_billing_charges";
492
+ dataType: "number";
493
+ columnType: "SQLiteInteger";
494
+ data: number;
495
+ driverParam: number;
496
+ notNull: true;
497
+ hasDefault: false;
498
+ isPrimaryKey: false;
499
+ isAutoincrement: false;
500
+ hasRuntimeDefault: false;
501
+ enumValues: undefined;
502
+ baseColumn: never;
503
+ identity: undefined;
504
+ generated: undefined;
505
+ }, {}, {}>;
506
+ status: import("drizzle-orm/sqlite-core").SQLiteColumn<{
507
+ name: "status";
508
+ tableName: "service_billing_charges";
509
+ dataType: "string";
510
+ columnType: "SQLiteText";
511
+ data: string;
512
+ driverParam: string;
513
+ notNull: true;
514
+ hasDefault: false;
515
+ isPrimaryKey: false;
516
+ isAutoincrement: false;
517
+ hasRuntimeDefault: false;
518
+ enumValues: [string, ...string[]];
519
+ baseColumn: never;
520
+ identity: undefined;
521
+ generated: undefined;
522
+ }, {}, {
523
+ length: number | undefined;
524
+ }>;
525
+ note: import("drizzle-orm/sqlite-core").SQLiteColumn<{
526
+ name: "note";
527
+ tableName: "service_billing_charges";
528
+ dataType: "string";
529
+ columnType: "SQLiteText";
530
+ data: string;
531
+ driverParam: string;
532
+ notNull: true;
533
+ hasDefault: false;
534
+ isPrimaryKey: false;
535
+ isAutoincrement: false;
536
+ hasRuntimeDefault: false;
537
+ enumValues: [string, ...string[]];
538
+ baseColumn: never;
539
+ identity: undefined;
540
+ generated: undefined;
541
+ }, {}, {
542
+ length: number | undefined;
543
+ }>;
544
+ metadata_json: import("drizzle-orm/sqlite-core").SQLiteColumn<{
545
+ name: "metadata_json";
546
+ tableName: "service_billing_charges";
547
+ dataType: "string";
548
+ columnType: "SQLiteText";
549
+ data: string;
550
+ driverParam: string;
551
+ notNull: true;
552
+ hasDefault: false;
553
+ isPrimaryKey: false;
554
+ isAutoincrement: false;
555
+ hasRuntimeDefault: false;
556
+ enumValues: [string, ...string[]];
557
+ baseColumn: never;
558
+ identity: undefined;
559
+ generated: undefined;
560
+ }, {}, {
561
+ length: number | undefined;
562
+ }>;
563
+ created_at: import("drizzle-orm/sqlite-core").SQLiteColumn<{
564
+ name: "created_at";
565
+ tableName: "service_billing_charges";
566
+ dataType: "string";
567
+ columnType: "SQLiteText";
568
+ data: string;
569
+ driverParam: string;
570
+ notNull: true;
571
+ hasDefault: false;
572
+ isPrimaryKey: false;
573
+ isAutoincrement: false;
574
+ hasRuntimeDefault: false;
575
+ enumValues: [string, ...string[]];
576
+ baseColumn: never;
577
+ identity: undefined;
578
+ generated: undefined;
579
+ }, {}, {
580
+ length: number | undefined;
581
+ }>;
582
+ };
583
+ dialect: "sqlite";
584
+ }>;
585
+ };
586
+ private readonly balance;
587
+ private readonly initialRules;
588
+ private readonly requireBeforeCall;
589
+ constructor(options: BillingServiceOptions);
590
+ _onInit(): Promise<void>;
591
+ install(ctx: ServiceInstallContext): void;
592
+ /**
593
+ * 新增或更新 pricing rule。
594
+ */
595
+ upsertPricingRule(input: BillingPricingRuleInput): Promise<BillingPricingRule>;
596
+ /**
597
+ * 列出 pricing rules。
598
+ */
599
+ listPricingRules(query?: BillingPricingRuleQuery): Promise<BillingPricingRule[]>;
600
+ /**
601
+ * 列出 charge。
602
+ */
603
+ listCharges(query?: BillingChargeQuery): Promise<BillingCharge[]>;
604
+ /**
605
+ * 对当前 service 调用执行结算。
606
+ */
607
+ settle(ctx: Context): Promise<BillingCharge | undefined>;
608
+ private createCharge;
609
+ private resolvePricingRule;
610
+ private readPricingRule;
611
+ private readPricingRuleRequired;
612
+ private ensurePricingRuleColumns;
613
+ private resolveRaw;
614
+ }
615
+ /**
616
+ * 创建 Billing 服务实例。
617
+ */
618
+ export declare function billingService(options: BillingServiceOptions): BillingService;
619
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/billing/service.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,kBAAkB,EAClB,KAAK,OAAO,EACZ,KAAK,qBAAqB,EAC3B,MAAM,gB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