lh-api-client 0.0.1 → 0.0.3
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/audit/index.d.ts +26 -3
- package/dist/audit/index.js +57 -0
- package/dist/audit/index.js.map +1 -1
- package/dist/client.d.ts +1 -0
- package/dist/client.js +76 -6
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/topup/index.d.ts +6 -4
- package/dist/topup/index.js.map +1 -1
- package/package.json +1 -1
package/dist/audit/index.d.ts
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { Client } from '../client';
|
|
2
2
|
/**
|
|
3
|
-
* One audit entry from `GET /platform/audit`. Mirrors the
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* One audit entry from `GET /platform/audit`. Mirrors the backend
|
|
4
|
+
* `AuditLogRow` (backend/src/modules/audit/audit.service.ts) verbatim —
|
|
5
|
+
* resynced 2026-09-02 (#896) after #886 added label enrichment on the
|
|
6
|
+
* read path.
|
|
6
7
|
*
|
|
7
8
|
* `occurredAt` is the timestamp; `before` + `after` are diffable JSON
|
|
8
9
|
* snapshots (used for state-change audits); `payload` is free-form
|
|
9
10
|
* context (request params, response codes, etc.). All three Json fields
|
|
10
11
|
* are nullable — many actions only set one or two.
|
|
12
|
+
*
|
|
13
|
+
* Label fields (#886): `platformTokenId` is the raw anchor the backend
|
|
14
|
+
* enriches from; `actorEmail`/`actorName`/`orgName`/`tokenLabel`/
|
|
15
|
+
* `tokenPrefix` are ABSENT when the referenced id doesn't resolve
|
|
16
|
+
* (actor 'system', purged org/token) — the raw id remains the display
|
|
17
|
+
* fallback. Never assume they are present.
|
|
11
18
|
*/
|
|
12
19
|
export interface AuditEntry {
|
|
13
20
|
id: string;
|
|
@@ -18,7 +25,23 @@ export interface AuditEntry {
|
|
|
18
25
|
before: unknown;
|
|
19
26
|
after: unknown;
|
|
20
27
|
payload: unknown;
|
|
28
|
+
platformTokenId: string | null;
|
|
29
|
+
actorEmail?: string;
|
|
30
|
+
actorName?: string;
|
|
31
|
+
orgName?: string;
|
|
32
|
+
tokenLabel?: string | null;
|
|
33
|
+
tokenPrefix?: string;
|
|
21
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Every `action` literal the backend currently writes via
|
|
37
|
+
* `auditService.record()` (grep-audited 2026-09-02, #896 — includes the
|
|
38
|
+
* #881 `plan.archive.force` and ADR-015 `api_key.auto_inactivate`/`park`
|
|
39
|
+
* family). `AuditEntry.action` stays `string` on purpose: new backend
|
|
40
|
+
* actions must not break typed consumers. Keep this list in sync when a
|
|
41
|
+
* new `record()` call site lands; `activity/enterprise-visible-actions`
|
|
42
|
+
* on the backend is the enforcement point for the tenant-visible subset.
|
|
43
|
+
*/
|
|
44
|
+
export declare const AUDIT_ACTIONS: readonly ["api_key.acknowledge", "api_key.auto_inactivate", "api_key.create", "api_key.park", "api_key.reactivate", "api_key.revoke", "api_key.revoke_token_orphaned", "api_key.switch_subscription", "auth.password.change", "auth.password.reset", "drift.settle_failed", "member.create", "member.deactivate", "member.delete", "member.enable_login", "member.freeze", "member.import", "member.reactivate", "member.reset_login_password", "member.set_budget_cap", "member.unfreeze", "member.update", "notification.broadcast", "org.activate", "org.create", "org.rename", "org.set_currency", "org.suspend", "plan.archive", "plan.archive.force", "plan.create", "plan.publish", "plan.update", "platform_token.create", "platform_token.revoke", "pricebook.activate", "pricebook.create", "provision.base_sub_anchor_fallback", "subscription.cancel", "subscription.contract.extend", "subscription.create", "subscription.rebook", "subscription.status_change", "topup.execute", "user.create"];
|
|
22
45
|
export interface QueryAuditArgs {
|
|
23
46
|
/** ISO-8601 inclusive start, e.g. 2026-04-19T00:00:00Z */
|
|
24
47
|
from: string;
|
package/dist/audit/index.js
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AUDIT_ACTIONS = void 0;
|
|
3
4
|
exports.queryAudit = queryAudit;
|
|
5
|
+
/**
|
|
6
|
+
* Every `action` literal the backend currently writes via
|
|
7
|
+
* `auditService.record()` (grep-audited 2026-09-02, #896 — includes the
|
|
8
|
+
* #881 `plan.archive.force` and ADR-015 `api_key.auto_inactivate`/`park`
|
|
9
|
+
* family). `AuditEntry.action` stays `string` on purpose: new backend
|
|
10
|
+
* actions must not break typed consumers. Keep this list in sync when a
|
|
11
|
+
* new `record()` call site lands; `activity/enterprise-visible-actions`
|
|
12
|
+
* on the backend is the enforcement point for the tenant-visible subset.
|
|
13
|
+
*/
|
|
14
|
+
exports.AUDIT_ACTIONS = [
|
|
15
|
+
'api_key.acknowledge',
|
|
16
|
+
'api_key.auto_inactivate',
|
|
17
|
+
'api_key.create',
|
|
18
|
+
'api_key.park',
|
|
19
|
+
'api_key.reactivate',
|
|
20
|
+
'api_key.revoke',
|
|
21
|
+
'api_key.revoke_token_orphaned',
|
|
22
|
+
'api_key.switch_subscription',
|
|
23
|
+
'auth.password.change',
|
|
24
|
+
'auth.password.reset',
|
|
25
|
+
'drift.settle_failed',
|
|
26
|
+
'member.create',
|
|
27
|
+
'member.deactivate',
|
|
28
|
+
'member.delete',
|
|
29
|
+
'member.enable_login',
|
|
30
|
+
'member.freeze',
|
|
31
|
+
'member.import',
|
|
32
|
+
'member.reactivate',
|
|
33
|
+
'member.reset_login_password',
|
|
34
|
+
'member.set_budget_cap',
|
|
35
|
+
'member.unfreeze',
|
|
36
|
+
'member.update',
|
|
37
|
+
'notification.broadcast',
|
|
38
|
+
'org.activate',
|
|
39
|
+
'org.create',
|
|
40
|
+
'org.rename',
|
|
41
|
+
'org.set_currency',
|
|
42
|
+
'org.suspend',
|
|
43
|
+
'plan.archive',
|
|
44
|
+
'plan.archive.force',
|
|
45
|
+
'plan.create',
|
|
46
|
+
'plan.publish',
|
|
47
|
+
'plan.update',
|
|
48
|
+
'platform_token.create',
|
|
49
|
+
'platform_token.revoke',
|
|
50
|
+
'pricebook.activate',
|
|
51
|
+
'pricebook.create',
|
|
52
|
+
'provision.base_sub_anchor_fallback',
|
|
53
|
+
'subscription.cancel',
|
|
54
|
+
'subscription.contract.extend',
|
|
55
|
+
'subscription.create',
|
|
56
|
+
'subscription.rebook',
|
|
57
|
+
'subscription.status_change',
|
|
58
|
+
'topup.execute',
|
|
59
|
+
'user.create',
|
|
60
|
+
];
|
|
4
61
|
/**
|
|
5
62
|
* v0.2.0 agent read tool. Mirrors `GET /platform/audit` (lh-ops CLI has
|
|
6
63
|
* the same endpoint via `audit query`). All filters are AND-composed
|
package/dist/audit/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/audit/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/audit/index.ts"],"names":[],"mappings":";;;AAwHA,gCAgBC;AApGD;;;;;;;;GAQG;AACU,QAAA,aAAa,GAAG;IAC3B,qBAAqB;IACrB,yBAAyB;IACzB,gBAAgB;IAChB,cAAc;IACd,oBAAoB;IACpB,gBAAgB;IAChB,+BAA+B;IAC/B,6BAA6B;IAC7B,sBAAsB;IACtB,qBAAqB;IACrB,qBAAqB;IACrB,eAAe;IACf,mBAAmB;IACnB,eAAe;IACf,qBAAqB;IACrB,eAAe;IACf,eAAe;IACf,mBAAmB;IACnB,6BAA6B;IAC7B,uBAAuB;IACvB,iBAAiB;IACjB,eAAe;IACf,wBAAwB;IACxB,cAAc;IACd,YAAY;IACZ,YAAY;IACZ,kBAAkB;IAClB,aAAa;IACb,cAAc;IACd,oBAAoB;IACpB,aAAa;IACb,cAAc;IACd,aAAa;IACb,uBAAuB;IACvB,uBAAuB;IACvB,oBAAoB;IACpB,kBAAkB;IAClB,oCAAoC;IACpC,qBAAqB;IACrB,8BAA8B;IAC9B,qBAAqB;IACrB,qBAAqB;IACrB,4BAA4B;IAC5B,eAAe;IACf,aAAa;CACL,CAAC;AAoBX;;;;;;;;GAQG;AACI,KAAK,UAAU,UAAU,CAC9B,MAAc,EACd,IAAoB;IAEpB,OAAO,MAAM,CAAC,OAAO,CAAe,iBAAiB,EAAE;QACrD,MAAM,EAAE,KAAK;QACb,KAAK,EAAE;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/dist/client.d.ts
CHANGED
package/dist/client.js
CHANGED
|
@@ -35,11 +35,43 @@ class Client {
|
|
|
35
35
|
headers.authorization = `Bearer ${this.opts.token}`;
|
|
36
36
|
if (options.headers)
|
|
37
37
|
Object.assign(headers, options.headers);
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
const method = options.method ?? 'GET';
|
|
39
|
+
const isIdempotentGet = method === 'GET';
|
|
40
|
+
// #616 — undici (Node fetch) 偶发 DNS/keep-alive 断 against launchhill.com
|
|
41
|
+
// (curl 同网络稳定 → client 侧缺 timeout/retry)。GET 幂等 → 网络层错误重试
|
|
42
|
+
// 2 次(指数退避 200ms/600ms)。POST/PUT/PATCH/DELETE 不自动重试:
|
|
43
|
+
// pricebook publish version-unique 重试会 409;非幂等写不能自动重放。HTTP
|
|
44
|
+
// 4xx/5xx 不重试(那是服务端逻辑,重试无意义,由 caller 处理 ApiError)。
|
|
45
|
+
const MAX_RETRIES = isIdempotentGet ? 2 : 0;
|
|
46
|
+
let attempt = 0;
|
|
47
|
+
// eslint-disable-next-line no-constant-condition
|
|
48
|
+
while (true) {
|
|
49
|
+
try {
|
|
50
|
+
const res = await fetch(url, {
|
|
51
|
+
method,
|
|
52
|
+
headers,
|
|
53
|
+
body: options.body !== undefined ? JSON.stringify(options.body) : undefined,
|
|
54
|
+
});
|
|
55
|
+
return await this.handleResponse(res, method, url);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
if (attempt < MAX_RETRIES && isTransientNetworkError(err)) {
|
|
59
|
+
const backoff = 200 * (attempt === 0 ? 1 : 3);
|
|
60
|
+
await sleep(backoff);
|
|
61
|
+
attempt++;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
// #542 — HTTP errors (ApiError) carry their own context; network-layer
|
|
65
|
+
// errors get enriched with method/URL + a write-side hint so operators
|
|
66
|
+
// can decide whether a non-idempotent write (issue/topup/provision) may
|
|
67
|
+
// have landed before retrying — instead of a bare "fetch failed".
|
|
68
|
+
if (err instanceof ApiError)
|
|
69
|
+
throw err;
|
|
70
|
+
throw enrichNetworkError(method, url, err);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async handleResponse(res, method, url) {
|
|
43
75
|
const text = await res.text();
|
|
44
76
|
let parsed = text;
|
|
45
77
|
if (text.length > 0) {
|
|
@@ -51,7 +83,7 @@ class Client {
|
|
|
51
83
|
}
|
|
52
84
|
}
|
|
53
85
|
if (!res.ok) {
|
|
54
|
-
throw new ApiError(res.status, parsed, `HTTP ${res.status} ${res.statusText} from ${
|
|
86
|
+
throw new ApiError(res.status, parsed, `HTTP ${res.status} ${res.statusText} from ${method} ${url.pathname}`);
|
|
55
87
|
}
|
|
56
88
|
// LH backend wraps successful responses in a TransformInterceptor envelope:
|
|
57
89
|
// `{ data: <actual payload>, timestamp, ... }`. Unwrap for caller convenience.
|
|
@@ -65,4 +97,42 @@ class Client {
|
|
|
65
97
|
}
|
|
66
98
|
}
|
|
67
99
|
exports.Client = Client;
|
|
100
|
+
// #616 — transient = network-layer (fetch rejected before a response), NOT
|
|
101
|
+
// HTTP errors. undici throws these as Error with .code like ECONNRESET,
|
|
102
|
+
// ENOTFOUND, EAI_AGAIN, UND_ERR_SOCKET, or a bare "fetch failed" wrapping
|
|
103
|
+
// a cause. Non-transient (a real HTTP 5xx) reaches handleResponse → ApiError.
|
|
104
|
+
function isTransientNetworkError(err) {
|
|
105
|
+
if (!(err instanceof Error))
|
|
106
|
+
return false;
|
|
107
|
+
const code = err.code;
|
|
108
|
+
if (code === 'ECONNRESET' ||
|
|
109
|
+
code === 'ENOTFOUND' ||
|
|
110
|
+
code === 'EAI_AGAIN' ||
|
|
111
|
+
code === 'ETIMEDOUT' ||
|
|
112
|
+
code === 'UND_ERR_SOCKET' ||
|
|
113
|
+
code === 'ECONNREFUSED') {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
// undici often throws a generic "fetch failed" wrapping a cause; treat a
|
|
117
|
+
// fetch-rejected error (no HTTP response) with a network-y cause as transient.
|
|
118
|
+
const cause = err.cause;
|
|
119
|
+
if (cause instanceof Error)
|
|
120
|
+
return isTransientNetworkError(cause);
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
function sleep(ms) {
|
|
124
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
125
|
+
}
|
|
126
|
+
// #542 — wrap a network-layer error with method/URL + a write-side hint. GET
|
|
127
|
+
// (idempotent) gets no hint; non-idempotent writes get "可能已生效" so operators
|
|
128
|
+
// verify with a read command before retrying (avoids duplicate issue/topup).
|
|
129
|
+
function enrichNetworkError(method, url, err) {
|
|
130
|
+
const cause = err instanceof Error ? err.message : String(err);
|
|
131
|
+
const hint = method === 'GET'
|
|
132
|
+
? ''
|
|
133
|
+
: ' — 该操作可能已生效,重试前先用读命令核对(如 lh-ops token list / get_statement),避免重复签发/充值/开通';
|
|
134
|
+
const e = new Error(`${method} ${url.pathname} 网络失败: ${cause}${hint}`);
|
|
135
|
+
e.cause = err;
|
|
136
|
+
return e;
|
|
137
|
+
}
|
|
68
138
|
//# sourceMappingURL=client.js.map
|
package/d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,WAAW;QACpB,IAAI,KAAK,WAAW;QACpB,IAAI,KAAK,gBAAgB;QACzB,IAAI,KAAK,cAAc,EACvB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,yEAAyE;IACzE,+EAA+E;IAC/E,MAAM,KAAK,GAAI,GAA2B,CAAC,KAAK,CAAC;IACjD,IAAI,KAAK,YAAY,KAAK;QAAE,OAAO,uBAAuB,CAAC,KAAK,CAAC,CAAC;IAClE,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,6EAA6E;AAC7E,4EAA4E;AAC5E,6EAA6E;AAC7E,SAAS,kBAAkB,CAAC,MAAc,EAAE,GAAQ,EAAE,GAAY;IAChE,MAAM,KAAK,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC/D,MAAM,IAAI,GACR,MAAM,KAAK,KAAK;QACd,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,0EAA0E,CAAC;IACjF,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,MAAM,IAAI,GAAG,CAAC,QAAQ,UAAU,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC;IACtE,CAAiC,CAAC,KAAK,GAAG,GAAG,CAAC;IAC/C,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export type { ApiKeyExportRow, ListApiKeysArgs } from './api-keys';
|
|
|
15
15
|
export { listMembers, unfreezeMember, setMemberBudgetCap, } from './member';
|
|
16
16
|
export type { MemberRow, ListMembersArgs } from './member';
|
|
17
17
|
export { queryAudit } from './audit';
|
|
18
|
+
export { AUDIT_ACTIONS } from './audit';
|
|
18
19
|
export type { AuditEntry, QueryAuditArgs } from './audit';
|
|
19
20
|
export { listPlans, getPlan, updatePlan, archivePlan } from './plan';
|
|
20
21
|
export type { Plan, PlanQuota, PlanStatus, ListPlansArgs, UpdatePlanInput, } from './plan';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.revokePlatformToken = exports.listPlatformTokens = exports.issuePlatformToken = exports.listUpstreamModels = exports.executeTopup = exports.addSubscription = exports.extendContract = exports.listPriceBooks = exports.archivePlan = exports.updatePlan = exports.getPlan = exports.listPlans = exports.queryAudit = exports.setMemberBudgetCap = exports.unfreezeMember = exports.listMembers = exports.listApiKeys = exports.PHASE2_BANNER = exports.DEFAULT_STATE_PATH = exports.phase2Status = exports.savePhase2Flags = exports.loadPhase2Flags = exports.evaluatePhase2State = exports.getCacheCoverage = exports.getOrgUsage = exports.getStatement = exports.setOrgCurrency = exports.provisionOrg = exports.renameOrg = exports.getOrgTokens = exports.listOrgs = exports.ApiError = exports.Client = void 0;
|
|
3
|
+
exports.revokePlatformToken = exports.listPlatformTokens = exports.issuePlatformToken = exports.listUpstreamModels = exports.executeTopup = exports.addSubscription = exports.extendContract = exports.listPriceBooks = exports.archivePlan = exports.updatePlan = exports.getPlan = exports.listPlans = exports.AUDIT_ACTIONS = exports.queryAudit = exports.setMemberBudgetCap = exports.unfreezeMember = exports.listMembers = exports.listApiKeys = exports.PHASE2_BANNER = exports.DEFAULT_STATE_PATH = exports.phase2Status = exports.savePhase2Flags = exports.loadPhase2Flags = exports.evaluatePhase2State = exports.getCacheCoverage = exports.getOrgUsage = exports.getStatement = exports.setOrgCurrency = exports.provisionOrg = exports.renameOrg = exports.getOrgTokens = exports.listOrgs = exports.ApiError = exports.Client = void 0;
|
|
4
4
|
// Public surface — both lh-ops and lh-ops-skill import from here.
|
|
5
5
|
var client_1 = require("./client");
|
|
6
6
|
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
|
|
@@ -32,6 +32,8 @@ Object.defineProperty(exports, "unfreezeMember", { enumerable: true, get: functi
|
|
|
32
32
|
Object.defineProperty(exports, "setMemberBudgetCap", { enumerable: true, get: function () { return member_1.setMemberBudgetCap; } });
|
|
33
33
|
var audit_1 = require("./audit");
|
|
34
34
|
Object.defineProperty(exports, "queryAudit", { enumerable: true, get: function () { return audit_1.queryAudit; } });
|
|
35
|
+
var audit_2 = require("./audit");
|
|
36
|
+
Object.defineProperty(exports, "AUDIT_ACTIONS", { enumerable: true, get: function () { return audit_2.AUDIT_ACTIONS; } });
|
|
35
37
|
var plan_1 = require("./plan");
|
|
36
38
|
Object.defineProperty(exports, "listPlans", { enumerable: true, get: function () { return plan_1.listPlans; } });
|
|
37
39
|
Object.defineProperty(exports, "getPlan", { enumerable: true, get: function () { return plan_1.getPlan; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,kEAAkE;AAClE,mCAA4C;AAAnC,gGAAA,MAAM,OAAA;AAAE,kGAAA,QAAQ,OAAA;AAGzB,+BAMgB;AALd,gGAAA,QAAQ,OAAA;AACR,oGAAA,YAAY,OAAA;AACZ,iGAAA,SAAS,OAAA;AACT,oGAAA,YAAY,OAAA;AACZ,sGAAA,cAAc,OAAA;AAahB,yCAA2C;AAAlC,yGAAA,YAAY,OAAA;AAGrB,yCAA0C;AAAjC,wGAAA,WAAW,OAAA;AAEpB,mDAAoD;AAA3C,kHAAA,gBAAgB,OAAA;AAGzB,mCAOkB;AANhB,6GAAA,mBAAmB,OAAA;AACnB,yGAAA,eAAe,OAAA;AACf,yGAAA,eAAe,OAAA;AACf,sGAAA,YAAY,OAAA;AACZ,4GAAA,kBAAkB,OAAA;AAClB,uGAAA,aAAa,OAAA;AASf,uCAAyC;AAAhC,u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,mCAA8C;AAArC,4GAAA,kBAAkB,OAAA;AAE3B,mDAI0B;AAHxB,oHAAA,kBAAkB,OAAA;AAClB,oHAAA,kBAAkB,OAAA;AAClB,qHAAA,mBAAmB,OAAA"}
|
package/dist/topup/index.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Client } from '../client';
|
|
2
2
|
/**
|
|
3
3
|
* Body for `POST /platform/topups/execute` (ExecuteTopupDto, #28 Smoke-A
|
|
4
|
-
* subset). Single-shot
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* subset). Single-shot balance movement: credits (positive) or deducts
|
|
5
|
+
* (negative) an org's balance and writes the audit + DEPOSIT log atomically.
|
|
6
|
+
* #734 (Option A): negative amounts are allowed (operator deduction /
|
|
7
|
+
* correction). Zero is rejected at the service layer. Requires the
|
|
8
|
+
* `write:billing` scope on the token.
|
|
7
9
|
*/
|
|
8
10
|
export interface ExecuteTopupArgs {
|
|
9
11
|
orgId: string;
|
|
10
|
-
/**
|
|
12
|
+
/** USD-canonical amount. Positive = credit, negative = deduction (#734). */
|
|
11
13
|
amountUsd: number;
|
|
12
14
|
memo?: string;
|
|
13
15
|
}
|
package/dist/topup/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/topup/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/topup/index.ts"],"names":[],"mappings":";;AAyCA,oCAYC;AAjBD;;;;GAIG;AACI,KAAK,UAAU,YAAY,CAChC,MAAc,EACd,IAAsB;IAEtB,OAAO,MAAM,CAAC,OAAO,CAAc,0BAA0B,EAAE;QAC7D,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lh-api-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Shared HTTP client + types + pure-logic helpers for talking to LH Enterprise backend. Consumed by lh-ops (CLI) and lh-ops-skill (MCP).",
|
|
6
6
|
"main": "./dist/index.js",
|