taximeter 0.1.2 → 0.2.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/CHANGELOG.md +8 -0
- package/README.md +22 -6
- package/SECURITY.md +4 -1
- package/dist/{chunk-DWBUWM3G.js → chunk-NXK2MCRO.js} +380 -43
- package/dist/cli/index.js +1 -1
- package/dist/index.d.ts +27 -9
- package/dist/index.js +1 -1
- package/dist/ui/assets/{index-Bts-0doc.js → index-BFxfiuVt.js} +9 -9
- package/dist/ui/index.html +1 -1
- package/docs/SDK.md +18 -2
- package/package.json +1 -1
- package/taximeter.config.example.json +2 -1
package/dist/cli/index.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -43,6 +43,10 @@ declare const configSchema: z.ZodObject<{
|
|
|
43
43
|
allowPayTo: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
44
44
|
maxSinglePayment: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
45
45
|
maxSingleAsset: z.ZodDefault<z.ZodString>;
|
|
46
|
+
unknownAsset: z.ZodDefault<z.ZodEnum<{
|
|
47
|
+
allow: "allow";
|
|
48
|
+
deny: "deny";
|
|
49
|
+
}>>;
|
|
46
50
|
}, z.core.$strict>>;
|
|
47
51
|
ports: z.ZodPrefault<z.ZodObject<{
|
|
48
52
|
proxy: z.ZodDefault<z.ZodNumber>;
|
|
@@ -88,6 +92,7 @@ declare function loadConfig(flags?: unknown, options?: {
|
|
|
88
92
|
allowPayTo: string[];
|
|
89
93
|
maxSinglePayment: string | null;
|
|
90
94
|
maxSingleAsset: string;
|
|
95
|
+
unknownAsset: "allow" | "deny";
|
|
91
96
|
};
|
|
92
97
|
ports: {
|
|
93
98
|
proxy: number;
|
|
@@ -176,13 +181,31 @@ declare const blockedBodySchema: z.ZodObject<{
|
|
|
176
181
|
}, z.core.$strip>;
|
|
177
182
|
type BlockedBody = z.infer<typeof blockedBodySchema>;
|
|
178
183
|
|
|
184
|
+
type Decision = {
|
|
185
|
+
allowed: true;
|
|
186
|
+
} | {
|
|
187
|
+
allowed: false;
|
|
188
|
+
body: BlockedBody;
|
|
189
|
+
};
|
|
190
|
+
type Scope = "perTask" | "perAgent" | "global";
|
|
191
|
+
type PolicyState = {
|
|
192
|
+
reserved: PaymentEvent | undefined;
|
|
193
|
+
spent: Record<Scope, string>;
|
|
194
|
+
};
|
|
195
|
+
/** Pure, synchronous budget decision. The caller must reserve in the same transaction. */
|
|
196
|
+
declare function evaluate(proposed: PaymentEvent, events: PaymentEvent[], config: TaximeterConfig, now: number): Decision;
|
|
197
|
+
|
|
179
198
|
/** Synchronous storage edge; money derivations remain pure in derive.ts. */
|
|
180
199
|
declare class Ledger {
|
|
181
200
|
private readonly database;
|
|
201
|
+
private readonly cache;
|
|
182
202
|
constructor(input: string);
|
|
183
203
|
transaction<T>(operation: () => T): T;
|
|
184
204
|
append(input: unknown): boolean;
|
|
185
205
|
appendOutcome(input: unknown): boolean;
|
|
206
|
+
policyState(proposed: PaymentEvent, budgets: TaximeterConfig["budgets"], now: number): PolicyState;
|
|
207
|
+
/** Rebuild disposable projections without modifying the append-only audit log. */
|
|
208
|
+
rebuildCache(): void;
|
|
186
209
|
events(): {
|
|
187
210
|
id: string;
|
|
188
211
|
ts: string;
|
|
@@ -320,15 +343,6 @@ declare function deriveEvents(events: PaymentEvent[], outcomes?: Outcome[]): Pay
|
|
|
320
343
|
declare function totals(events: PaymentEvent[]): Total[];
|
|
321
344
|
declare function formatAmount(amount: string, decimals: number): string;
|
|
322
345
|
|
|
323
|
-
type Decision = {
|
|
324
|
-
allowed: true;
|
|
325
|
-
} | {
|
|
326
|
-
allowed: false;
|
|
327
|
-
body: BlockedBody;
|
|
328
|
-
};
|
|
329
|
-
/** Pure, synchronous budget decision. The caller must reserve in the same transaction. */
|
|
330
|
-
declare function evaluate(proposed: PaymentEvent, events: PaymentEvent[], config: TaximeterConfig, now: number): Decision;
|
|
331
|
-
|
|
332
346
|
declare function createProxy(options: {
|
|
333
347
|
ledger: Ledger;
|
|
334
348
|
config: TaximeterConfig;
|
|
@@ -379,6 +393,10 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
379
393
|
allowPayTo: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
380
394
|
maxSinglePayment: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
381
395
|
maxSingleAsset: z.ZodOptional<z.ZodString>;
|
|
396
|
+
unknownAsset: z.ZodOptional<z.ZodEnum<{
|
|
397
|
+
allow: "allow";
|
|
398
|
+
deny: "deny";
|
|
399
|
+
}>>;
|
|
382
400
|
}, z.core.$strict>>;
|
|
383
401
|
ports: z.ZodOptional<z.ZodObject<{
|
|
384
402
|
proxy: z.ZodOptional<z.ZodNumber>;
|