lh-api-client 0.0.1

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 (49) hide show
  1. package/dist/api-keys/index.d.ts +37 -0
  2. package/dist/api-keys/index.js +23 -0
  3. package/dist/api-keys/index.js.map +1 -0
  4. package/dist/audit/index.d.ts +47 -0
  5. package/dist/audit/index.js +27 -0
  6. package/dist/audit/index.js.map +1 -0
  7. package/dist/cache-coverage/index.d.ts +24 -0
  8. package/dist/cache-coverage/index.js +9 -0
  9. package/dist/cache-coverage/index.js.map +1 -0
  10. package/dist/client.d.ts +25 -0
  11. package/dist/client.js +68 -0
  12. package/dist/client.js.map +1 -0
  13. package/dist/index.d.ts +29 -0
  14. package/dist/index.js +53 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/member/index.d.ts +49 -0
  17. package/dist/member/index.js +38 -0
  18. package/dist/member/index.js.map +1 -0
  19. package/dist/models/index.d.ts +7 -0
  20. package/dist/models/index.js +15 -0
  21. package/dist/models/index.js.map +1 -0
  22. package/dist/org-usage/index.d.ts +47 -0
  23. package/dist/org-usage/index.js +7 -0
  24. package/dist/org-usage/index.js.map +1 -0
  25. package/dist/orgs/index.d.ts +113 -0
  26. package/dist/orgs/index.js +65 -0
  27. package/dist/orgs/index.js.map +1 -0
  28. package/dist/phase2/index.d.ts +46 -0
  29. package/dist/phase2/index.js +120 -0
  30. package/dist/phase2/index.js.map +1 -0
  31. package/dist/plan/index.d.ts +52 -0
  32. package/dist/plan/index.js +41 -0
  33. package/dist/plan/index.js.map +1 -0
  34. package/dist/platform-token/index.d.ts +37 -0
  35. package/dist/platform-token/index.js +22 -0
  36. package/dist/platform-token/index.js.map +1 -0
  37. package/dist/price-book/index.d.ts +17 -0
  38. package/dist/price-book/index.js +10 -0
  39. package/dist/price-book/index.js.map +1 -0
  40. package/dist/statement/index.d.ts +38 -0
  41. package/dist/statement/index.js +10 -0
  42. package/dist/statement/index.js.map +1 -0
  43. package/dist/subscription/index.d.ts +45 -0
  44. package/dist/subscription/index.js +30 -0
  45. package/dist/subscription/index.js.map +1 -0
  46. package/dist/topup/index.d.ts +37 -0
  47. package/dist/topup/index.js +19 -0
  48. package/dist/topup/index.js.map +1 -0
  49. package/package.json +27 -0
@@ -0,0 +1,113 @@
1
+ import { Client } from '../client';
2
+ /**
3
+ * One row from `GET /platform/orgs`. Mirrors `OrganizationService.listForOperator`
4
+ * return shape; additive backend fields don't require client changes here unless
5
+ * consumers want to surface them.
6
+ */
7
+ export interface OrgListRow {
8
+ id: string;
9
+ name: string;
10
+ status: 'ACTIVE' | 'SUSPENDED' | 'CLOSED';
11
+ balance: string;
12
+ currency: string;
13
+ }
14
+ export interface ListOrgsArgs {
15
+ status?: 'ACTIVE' | 'SUSPENDED' | 'CLOSED';
16
+ nearLimit?: boolean;
17
+ overBudget?: boolean;
18
+ quietSinceDays?: number;
19
+ /**
20
+ * US-OP-13 / #359 — filter orgs that have any ACTIVE non-base sub whose
21
+ * `commitmentEnd` falls within the next N days. Used by
22
+ * `lh-ops org list --expiring-within Xd` for renewal-window discovery.
23
+ */
24
+ expiringWithinDays?: number;
25
+ sortBy?: 'balance-asc';
26
+ }
27
+ /**
28
+ * US-OP-9 (T2 of v0.1.7). Cross-org overview for platform operators.
29
+ * Filter flags pass through to the backend's `listForOperator` filter set.
30
+ * Query param names are kebab-case to mirror the CLI flag names.
31
+ */
32
+ export declare function listOrgs(client: Client, args: ListOrgsArgs): Promise<OrgListRow[]>;
33
+ /**
34
+ * One token's state on new-api as surfaced for operator triage (US-7).
35
+ * `maskedKey` is new-api-masked (never the full secret); `remainQuota === -1`
36
+ * means UnlimitedQuota (V2 tokens, where LH is the sole gatekeeper).
37
+ */
38
+ export interface OrgTokenInfo {
39
+ tokenId: number;
40
+ tokenName: string;
41
+ maskedKey: string;
42
+ status: number;
43
+ statusText: string;
44
+ remainQuota: number;
45
+ usedQuota: number;
46
+ isExpired: boolean;
47
+ accessedTime: number;
48
+ }
49
+ export interface RenamedOrg {
50
+ id: string;
51
+ name: string;
52
+ status: string;
53
+ }
54
+ /** Rename a customer org's display name (operator action). */
55
+ export declare function renameOrg(client: Client, orgId: string, name: string): Promise<RenamedOrg>;
56
+ /**
57
+ * Body for `POST /platform/orgs` (ProvisionOrgDto). `planId` is an OPTIONAL
58
+ * paid plan id — when supplied a paid sub is seeded on top of the always-seeded
59
+ * base sub (ADR-017 §6). Requires the `write:orgs` scope on the token.
60
+ */
61
+ export interface ProvisionOrgArgs {
62
+ orgName: string;
63
+ adminEmail: string;
64
+ adminName: string;
65
+ planId?: string;
66
+ }
67
+ /**
68
+ * Result of provisioning. The backend returns the created org plus the admin's
69
+ * one-time temp password and (optionally) the seeded paid subscription. Shape
70
+ * mirrors `OrganizationService.createOrgWithAdmin`; additive fields are
71
+ * pass-through.
72
+ */
73
+ export interface ProvisionedOrg {
74
+ organization: {
75
+ id: string;
76
+ name: string;
77
+ status: string;
78
+ [k: string]: unknown;
79
+ };
80
+ [k: string]: unknown;
81
+ }
82
+ /**
83
+ * Provision a brand-new customer org + its admin user (operator action,
84
+ * sales-driven). Mirrors `POST /platform/orgs`. Token must carry `write:orgs`.
85
+ */
86
+ export declare function provisionOrg(client: Client, args: ProvisionOrgArgs): Promise<ProvisionedOrg>;
87
+ /**
88
+ * Body for `PATCH /platform/orgs/:orgId/currency` (SetOrgCurrencyDto, ADR-026).
89
+ * Binary: CNY requires a positive `contractRate`; USD must omit it. The rate is
90
+ * display/top-up only, never a billing input. Requires `write:billing`.
91
+ */
92
+ export interface SetOrgCurrencyArgs {
93
+ currency: 'CNY' | 'USD';
94
+ /** Required + positive for CNY; omit for USD. Cross-field rule enforced server-side. */
95
+ contractRate?: number;
96
+ }
97
+ export interface OrgCurrency {
98
+ id: string;
99
+ currency: 'CNY' | 'USD';
100
+ contractRate: string | null;
101
+ [k: string]: unknown;
102
+ }
103
+ /**
104
+ * Set a customer org's settlement currency + fixed contract rate (ADR-026).
105
+ * Mirrors `PATCH /platform/orgs/:orgId/currency`. Token must carry
106
+ * `write:billing`.
107
+ */
108
+ export declare function setOrgCurrency(client: Client, orgId: string, args: SetOrgCurrencyArgs): Promise<OrgCurrency>;
109
+ /**
110
+ * US-7 read slice (#435). Pass through the org's new-api token state for
111
+ * "is it LH or new-api?" triage. Read-only.
112
+ */
113
+ export declare function getOrgTokens(client: Client, orgId: string): Promise<OrgTokenInfo[]>;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listOrgs = listOrgs;
4
+ exports.renameOrg = renameOrg;
5
+ exports.provisionOrg = provisionOrg;
6
+ exports.setOrgCurrency = setOrgCurrency;
7
+ exports.getOrgTokens = getOrgTokens;
8
+ /**
9
+ * US-OP-9 (T2 of v0.1.7). Cross-org overview for platform operators.
10
+ * Filter flags pass through to the backend's `listForOperator` filter set.
11
+ * Query param names are kebab-case to mirror the CLI flag names.
12
+ */
13
+ async function listOrgs(client, args) {
14
+ return client.request('/platform/orgs', {
15
+ method: 'GET',
16
+ query: {
17
+ status: args.status,
18
+ 'near-limit': args.nearLimit ? '1' : undefined,
19
+ 'over-budget': args.overBudget ? '1' : undefined,
20
+ 'quiet-since-days': args.quietSinceDays !== undefined ? String(args.quietSinceDays) : undefined,
21
+ 'expiring-within-days': args.expiringWithinDays !== undefined
22
+ ? String(args.expiringWithinDays)
23
+ : undefined,
24
+ 'sort-by': args.sortBy,
25
+ },
26
+ });
27
+ }
28
+ /** Rename a customer org's display name (operator action). */
29
+ async function renameOrg(client, orgId, name) {
30
+ return client.request(`/platform/orgs/${encodeURIComponent(orgId)}/name`, { method: 'PATCH', body: { name } });
31
+ }
32
+ /**
33
+ * Provision a brand-new customer org + its admin user (operator action,
34
+ * sales-driven). Mirrors `POST /platform/orgs`. Token must carry `write:orgs`.
35
+ */
36
+ async function provisionOrg(client, args) {
37
+ return client.request('/platform/orgs', {
38
+ method: 'POST',
39
+ body: {
40
+ orgName: args.orgName,
41
+ adminEmail: args.adminEmail,
42
+ adminName: args.adminName,
43
+ planId: args.planId,
44
+ },
45
+ });
46
+ }
47
+ /**
48
+ * Set a customer org's settlement currency + fixed contract rate (ADR-026).
49
+ * Mirrors `PATCH /platform/orgs/:orgId/currency`. Token must carry
50
+ * `write:billing`.
51
+ */
52
+ async function setOrgCurrency(client, orgId, args) {
53
+ return client.request(`/platform/orgs/${encodeURIComponent(orgId)}/currency`, {
54
+ method: 'PATCH',
55
+ body: { currency: args.currency, contractRate: args.contractRate },
56
+ });
57
+ }
58
+ /**
59
+ * US-7 read slice (#435). Pass through the org's new-api token state for
60
+ * "is it LH or new-api?" triage. Read-only.
61
+ */
62
+ async function getOrgTokens(client, orgId) {
63
+ return client.request(`/platform/orgs/${encodeURIComponent(orgId)}/tokens`, { method: 'GET' });
64
+ }
65
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/orgs/index.ts"],"names":[],"mappings":";;AAkCA,4BAmBC;AA0BD,8BASC;AAkCD,oCAaC;AAyBD,wCAYC;AAMD,oCAQC;AA7JD;;;;GAIG;AACI,KAAK,UAAU,QAAQ,CAC5B,MAAc,EACd,IAAkB;IAElB,OAAO,MAAM,CAAC,OAAO,CAAe,gBAAgB,EAAE;QACpD,MAAM,EAAE,KAAK;QACb,KAAK,EAAE;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;YAC9C,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;YAChD,kBAAkB,EAChB,IAAI,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS;YAC7E,sBAAsB,EACpB,IAAI,CAAC,kBAAkB,KAAK,SAAS;gBAC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AC"}
@@ -0,0 +1,46 @@
1
+ import { Client } from '../client';
2
+ export interface Phase2Flags {
3
+ opsTeamSize: number;
4
+ hasNontech: boolean;
5
+ complianceAsk: boolean;
6
+ salesDemoRequested: boolean;
7
+ }
8
+ export interface Phase2Trigger {
9
+ id: 1 | 2 | 3;
10
+ name: string;
11
+ satisfied: boolean;
12
+ detail: string;
13
+ }
14
+ export interface Phase2State {
15
+ triggers: Phase2Trigger[];
16
+ satisfied: number;
17
+ activeOrgCount: number;
18
+ flags: Phase2Flags;
19
+ }
20
+ export declare const DEFAULT_STATE_PATH: string;
21
+ export declare const PHASE2_BANNER = ">>> ADR-012 Phase 2 trigger met \u2014 schedule new ADR <<<";
22
+ /**
23
+ * Pure-logic evaluator (no IO). Same function used by lh-ops `phase2-status`
24
+ * subcommand and lh-ops-skill `phase2_status` MCP tool.
25
+ */
26
+ export declare function evaluatePhase2State(flags: Phase2Flags, activeOrgCount: number): Phase2State;
27
+ /**
28
+ * Load manual flags from disk. Returns DEFAULT_FLAGS (all-false-ish) when
29
+ * the state file doesn't exist — common for fresh installs.
30
+ */
31
+ export declare function loadPhase2Flags(filePath?: string): Promise<Phase2Flags>;
32
+ /**
33
+ * Persist manual flags. CLI subcommand `lh-ops phase2-status set-*` uses this.
34
+ */
35
+ export declare function savePhase2Flags(flags: Phase2Flags, filePath?: string): Promise<void>;
36
+ export interface Phase2StatusResult extends Phase2State {
37
+ banner: string | null;
38
+ }
39
+ /**
40
+ * End-to-end: fetch live activeOrgCount + load flags + evaluate + decorate
41
+ * with banner. Both CLI and MCP call this; the differences are presentation
42
+ * (CLI renders ASCII checklist; MCP returns structured JSON).
43
+ */
44
+ export declare function phase2Status(client: Client, opts?: {
45
+ statePath?: string;
46
+ }): Promise<Phase2StatusResult>;
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.PHASE2_BANNER = exports.DEFAULT_STATE_PATH = void 0;
37
+ exports.evaluatePhase2State = evaluatePhase2State;
38
+ exports.loadPhase2Flags = loadPhase2Flags;
39
+ exports.savePhase2Flags = savePhase2Flags;
40
+ exports.phase2Status = phase2Status;
41
+ const fs_1 = require("fs");
42
+ const os_1 = require("os");
43
+ const path = __importStar(require("path"));
44
+ exports.DEFAULT_STATE_PATH = path.join((0, os_1.homedir)(), '.lh-ops', 'phase2-state.json');
45
+ exports.PHASE2_BANNER = '>>> ADR-012 Phase 2 trigger met — schedule new ADR <<<';
46
+ /**
47
+ * Pure-logic evaluator (no IO). Same function used by lh-ops `phase2-status`
48
+ * subcommand and lh-ops-skill `phase2_status` MCP tool.
49
+ */
50
+ function evaluatePhase2State(flags, activeOrgCount) {
51
+ const triggers = [
52
+ {
53
+ id: 1,
54
+ name: 'Ops team ≥ 3 with non-technical member',
55
+ satisfied: flags.opsTeamSize >= 3 && flags.hasNontech,
56
+ detail: `opsTeamSize=${flags.opsTeamSize}, hasNontech=${flags.hasNontech}`,
57
+ },
58
+ {
59
+ id: 2,
60
+ name: 'Paid customers ≥ 5 + at least 1 compliance ask',
61
+ satisfied: activeOrgCount >= 5 && flags.complianceAsk,
62
+ detail: `activeOrgs=${activeOrgCount}, complianceAsk=${flags.complianceAsk}`,
63
+ },
64
+ {
65
+ id: 3,
66
+ name: 'Sales requested customer-facing audit-trail demo',
67
+ satisfied: flags.salesDemoRequested,
68
+ detail: `salesDemoRequested=${flags.salesDemoRequested}`,
69
+ },
70
+ ];
71
+ const satisfied = triggers.filter((t) => t.satisfied).length;
72
+ return { triggers, satisfied, activeOrgCount, flags };
73
+ }
74
+ const DEFAULT_FLAGS = {
75
+ opsTeamSize: 1,
76
+ hasNontech: false,
77
+ complianceAsk: false,
78
+ salesDemoRequested: false,
79
+ };
80
+ /**
81
+ * Load manual flags from disk. Returns DEFAULT_FLAGS (all-false-ish) when
82
+ * the state file doesn't exist — common for fresh installs.
83
+ */
84
+ async function loadPhase2Flags(filePath = exports.DEFAULT_STATE_PATH) {
85
+ try {
86
+ const raw = await fs_1.promises.readFile(filePath, 'utf8');
87
+ return JSON.parse(raw);
88
+ }
89
+ catch (err) {
90
+ if (err.code === 'ENOENT') {
91
+ return { ...DEFAULT_FLAGS };
92
+ }
93
+ throw err;
94
+ }
95
+ }
96
+ /**
97
+ * Persist manual flags. CLI subcommand `lh-ops phase2-status set-*` uses this.
98
+ */
99
+ async function savePhase2Flags(flags, filePath = exports.DEFAULT_STATE_PATH) {
100
+ await fs_1.promises.mkdir(path.dirname(filePath), { recursive: true, mode: 0o700 });
101
+ await fs_1.promises.writeFile(filePath, JSON.stringify(flags, null, 2), { mode: 0o600 });
102
+ }
103
+ /**
104
+ * End-to-end: fetch live activeOrgCount + load flags + evaluate + decorate
105
+ * with banner. Both CLI and MCP call this; the differences are presentation
106
+ * (CLI renders ASCII checklist; MCP returns structured JSON).
107
+ */
108
+ async function phase2Status(client, opts = {}) {
109
+ const orgs = await client.request('/platform/orgs', {
110
+ method: 'GET',
111
+ query: { status: 'ACTIVE' },
112
+ });
113
+ const flags = await loadPhase2Flags(opts.statePath);
114
+ const state = evaluatePhase2State(flags, orgs.length);
115
+ return {
116
+ ...state,
117
+ banner: state.satisfied >= 2 ? exports.PHASE2_BANNER : null,
118
+ };
119
+ }
120
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/phase2/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,kDA0BC;AAaD,0CAYC;AAKD,0CAMC;AAWD,oCAcC;AAvID,2BAAoC;AACpC,2BAA6B;AAC7B,2CAA6B;AAiChB,QAAA,kBAAkB,GAAG,IAAI,CAAC,IAAI,CACzC,IAAA,YAAO,GAAE,EACT,SAAS,EACT,mBAAmB,CACpB,CAAC;AAEW,QAAA,aAAa,GACxB,wDAAwD,CAAC;AAE3D;;;GAGG;AACH,SAAgB,mBAAmB,CACjC,KAAkB,EAClB,cAAsB;IAEtB,MAAM,QAAQ,GAAoB;QAChC;YACE,EAAE,EAAE,CAAC;YACL,IAAI,EAAE,wCAAwC;YAC9C,SAAS,EAAE,KAAK,CAAC,WAAW,IAAI,CAAC,IAAI,KAAK,CAAC,UAAU;YACrD,MAAM,EAAE,eAAe,KAAK,CAAC,WAAW,gBAAgB,KAAK,CAAC,UAAU,EAAE;SAC3E;QACD;YACE,EAAE,EAAE,CAAC;YACL,IAAI,EAAE,gDAAgD;YACtD,SAAS,EAAE,cAAc,IAAI,CAAC,IAAI,KAAK,CAAC,aAAa;YACrD,MAAM,EAAE,cAAc,cAAc,mBAAmB,KAAK,CAAC,aAAa,EAAE;SAC7E;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CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AAChF,CAAC;AAMD;;;;GAIG;AACI,KAAK,UAAU,YAAY,CAChC,MAAc,EACd,OAA+B,EAAE;IAEjC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAwB,gBAAgB,EAAE;QACzE,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;KAC5B,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACpD,MAAM,KAAK,GAAG,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACtD,OAAO;QACL,GAAG,KAAK;QACR,MAAM,EAAE,KAAK,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,qBAAa,CAAC,CAAC,CAAC,IAAI;KACpD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { Client } from '../client';
2
+ /**
3
+ * Plan SKU as returned by `/platform/plans` (mirrors the Prisma `Plan` model).
4
+ * `family` / `tier` are backend enums kept as `string` here so adding an enum
5
+ * value doesn't force a client release. Additive backend fields don't require
6
+ * changes here unless a consumer wants to surface them.
7
+ */
8
+ export interface PlanQuota {
9
+ dimension: string;
10
+ limit: number;
11
+ window: string;
12
+ }
13
+ export type PlanStatus = 'ACTIVE' | 'ARCHIVED';
14
+ export interface Plan {
15
+ id: string;
16
+ family: string;
17
+ tier: string;
18
+ displayName: string;
19
+ quotas: PlanQuota[];
20
+ status: PlanStatus;
21
+ isBaseTier: boolean;
22
+ createdAt: string;
23
+ /** ISO timestamp — also the optimistic-lock token for update/archive. */
24
+ updatedAt: string;
25
+ }
26
+ export interface ListPlansArgs {
27
+ family?: string;
28
+ status?: string;
29
+ }
30
+ /** US-1. List plan SKUs, optionally filtered by family / status. */
31
+ export declare function listPlans(client: Client, args?: ListPlansArgs): Promise<Plan[]>;
32
+ /** US-1. Fetch a single plan (also the source of the `updatedAt` lock token). */
33
+ export declare function getPlan(client: Client, planId: string): Promise<Plan>;
34
+ /** Mutable fields on PATCH /platform/plans/:id (mirrors backend UpdatePlanDto). */
35
+ export interface UpdatePlanInput {
36
+ displayName?: string;
37
+ quotas?: PlanQuota[];
38
+ status?: PlanStatus;
39
+ isBaseTier?: boolean;
40
+ }
41
+ /**
42
+ * US-1. Update a plan. The backend enforces an optimistic lock: `ifMatch` must
43
+ * equal the plan's current `updatedAt` (get it from `getPlan`). Omitting it
44
+ * yields HTTP 412; a stale value yields 409.
45
+ */
46
+ export declare function updatePlan(client: Client, planId: string, dto: UpdatePlanInput, ifMatch?: string): Promise<Plan>;
47
+ /**
48
+ * US-1. Archive a plan (status → ARCHIVED). Same optimistic-lock contract as
49
+ * `updatePlan`. Archived plans stop appearing in the enterprise selection list
50
+ * but existing subscriptions keep running to commitmentEnd.
51
+ */
52
+ export declare function archivePlan(client: Client, planId: string, ifMatch?: string): Promise<Plan>;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listPlans = listPlans;
4
+ exports.getPlan = getPlan;
5
+ exports.updatePlan = updatePlan;
6
+ exports.archivePlan = archivePlan;
7
+ /** US-1. List plan SKUs, optionally filtered by family / status. */
8
+ async function listPlans(client, args = {}) {
9
+ return client.request('/platform/plans', {
10
+ method: 'GET',
11
+ query: { family: args.family, status: args.status },
12
+ });
13
+ }
14
+ /** US-1. Fetch a single plan (also the source of the `updatedAt` lock token). */
15
+ async function getPlan(client, planId) {
16
+ return client.request(`/platform/plans/${encodeURIComponent(planId)}`, { method: 'GET' });
17
+ }
18
+ /**
19
+ * US-1. Update a plan. The backend enforces an optimistic lock: `ifMatch` must
20
+ * equal the plan's current `updatedAt` (get it from `getPlan`). Omitting it
21
+ * yields HTTP 412; a stale value yields 409.
22
+ */
23
+ async function updatePlan(client, planId, dto, ifMatch) {
24
+ return client.request(`/platform/plans/${encodeURIComponent(planId)}`, {
25
+ method: 'PATCH',
26
+ body: dto,
27
+ headers: ifMatch ? { 'if-match': ifMatch } : undefined,
28
+ });
29
+ }
30
+ /**
31
+ * US-1. Archive a plan (status → ARCHIVED). Same optimistic-lock contract as
32
+ * `updatePlan`. Archived plans stop appearing in the enterprise selection list
33
+ * but existing subscriptions keep running to commitmentEnd.
34
+ */
35
+ async function archivePlan(client, planId, ifMatch) {
36
+ return client.request(`/platform/plans/${encodeURIComponent(planId)}/archive`, {
37
+ method: 'POST',
38
+ headers: ifMatch ? { 'if-match': ifMatch } : undefined,
39
+ });
40
+ }
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plan/index.ts"],"names":[],"mappings":";;AAmCA,8BAQC;AAGD,0BAKC;AAeD,gCAcC;AAOD,kCAYC;AAjED,oEAAoE;AAC7D,KAAK,UAAU,SAAS,CAC7B,MAAc,EACd,OAAsB,EAAE;IAExB,OAAO,MAAM,CAAC,OAAO,CAAS,iBAAiB,EAAE;QAC/C,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;KACpD,CAAC,CAAC;AACL,CAAC;AAED,iFAAiF;AAC1E,KAAK,UAAU,OAAO,CAAC,MAAc,EAAE,MAAc;IAC1D,OAAO,MAAM,CAAC,OAAO,CACnB,mBAAmB,kBAAkB,CAAC,MAAM,CAAC,EAAE,EAC/C,EAAE,MAAM,EAAE,KAAK,EAAE,CAClB,CAAC;AACJ,CAAC;AAUD;;;;GAIG;AACI,KAAK,UAAU,UAAU,CAC9B,MAAc,EACd,MAAc,EACd,GAAoB,EACpB,OAAgB;IAEhB,OAAO,MAAM,CAAC,OAAO,CACnB,mBAAmB,kBAAkB,CAAC,MAAM,CAAC,EAAE,EAC/C;QACE,MAAM,EAAE,OAAO;QACf,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS;KACvD,CACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,WAAW,CAC/B,MAAc,EACd,MAAc,EACd,OAAgB;IAEhB,OAAO,MAAM,CAAC,OAAO,CACnB,mBAAmB,kBAAkB,CAAC,MAAM,CAAC,UAAU,EACvD;QACE,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS;KACvD,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { Client } from '../client';
2
+ export interface IssueTokenArgs {
3
+ /** One or more scopes from the KNOWN_SCOPES taxonomy (e.g. read:keys). */
4
+ scopes: string[];
5
+ /** Human label shown in `token list`. */
6
+ label?: string;
7
+ /** Token lifetime in days; omit for a non-expiring token. */
8
+ expiresInDays?: number;
9
+ }
10
+ /** Response of `POST /platform/tokens` — `token` plaintext is shown ONCE. */
11
+ export interface IssuedToken {
12
+ id: string;
13
+ tokenPrefix: string;
14
+ scopes: string[];
15
+ label: string | null;
16
+ expiresAt: string | null;
17
+ /** The `lh_pat_…` plaintext — only present on issue, never stored/returned again. */
18
+ token: string;
19
+ }
20
+ /** Row from `GET /platform/tokens` — never includes the hash or plaintext. */
21
+ export interface TokenSummary {
22
+ id: string;
23
+ tokenPrefix: string;
24
+ scopes: string[];
25
+ label: string | null;
26
+ status: string;
27
+ lastUsedAt: string | null;
28
+ expiresAt: string | null;
29
+ createdAt: string;
30
+ revokedAt: string | null;
31
+ }
32
+ export declare function issuePlatformToken(client: Client, args: IssueTokenArgs): Promise<IssuedToken>;
33
+ export declare function listPlatformTokens(client: Client): Promise<TokenSummary[]>;
34
+ export declare function revokePlatformToken(client: Client, id: string): Promise<{
35
+ id: string;
36
+ status: string;
37
+ }>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.issuePlatformToken = issuePlatformToken;
4
+ exports.listPlatformTokens = listPlatformTokens;
5
+ exports.revokePlatformToken = revokePlatformToken;
6
+ async function issuePlatformToken(client, args) {
7
+ return client.request('/platform/tokens', {
8
+ method: 'POST',
9
+ body: {
10
+ scopes: args.scopes,
11
+ label: args.label,
12
+ expiresInDays: args.expiresInDays,
13
+ },
14
+ });
15
+ }
16
+ async function listPlatformTokens(client) {
17
+ return client.request('/platform/tokens', { method: 'GET' });
18
+ }
19
+ async function revokePlatformToken(client, id) {
20
+ return client.request(`/platform/tokens/${encodeURIComponent(id)}/revoke`, { method: 'POST' });
21
+ }
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/platform-token/index.ts"],"names":[],"mappings":";;AAuCA,gDAYC;AAED,gDAIC;AAED,kDAQC;AA5BM,KAAK,UAAU,kBAAkB,CACtC,MAAc,EACd,IAAoB;IAEpB,OAAO,MAAM,CAAC,OAAO,CAAc,kBAAkB,EAAE;QACrD,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,aAAa,EAAE,IAAI,CAAC,aAAa;SAClC;KACF,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,kBAAkB,CACtC,MAAc;IAEd,OAAO,MAAM,CAAC,OAAO,CAAiB,kBAAkB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;AAC/E,CAAC;AAEM,KAAK,UAAU,mBAAmB,CACvC,MAAc,EACd,EAAU;IAEV,OAAO,MAAM,CAAC,OAAO,CACnB,oBAAoB,kBAAkB,CAAC,EAAE,CAAC,SAAS,EACnD,EAAE,MAAM,EAAE,MAAM,EAAE,CACnB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Client } from '../client';
2
+ /**
3
+ * A price book version as returned by `GET /platform/pricebook` (mirrors the
4
+ * Prisma `PriceBook` model). There is no `status` enum — `isActive` marks the
5
+ * single live version; all others are historical.
6
+ */
7
+ export interface PriceBookSummary {
8
+ id: string;
9
+ version: string;
10
+ effectiveFrom: string;
11
+ isActive: boolean;
12
+ createdAt: string;
13
+ /** Map of model → price; omitted by some list projections. */
14
+ modelPrices?: Record<string, unknown>;
15
+ }
16
+ /** US-2. List every price book version (active + historical). */
17
+ export declare function listPriceBooks(client: Client): Promise<PriceBookSummary[]>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listPriceBooks = listPriceBooks;
4
+ /** US-2. List every price book version (active + historical). */
5
+ async function listPriceBooks(client) {
6
+ return client.request('/platform/pricebook', {
7
+ method: 'GET',
8
+ });
9
+ }
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/price-book/index.ts"],"names":[],"mappings":";;AAkBA,wCAMC;AAPD,iEAAiE;AAC1D,KAAK,UAAU,cAAc,CAClC,MAAc;IAEd,OAAO,MAAM,CAAC,OAAO,CAAqB,qBAAqB,EAAE;QAC/D,MAAM,EAAE,KAAK;KACd,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { Client } from '../client';
2
+ /**
3
+ * Response payload from `GET /platform/orgs/:orgId/statement?month=YYYY-MM`.
4
+ * US-OP-10 (T3 of v0.1.7) monthly checkpoint.
5
+ */
6
+ export interface StatementPayload {
7
+ orgId: string;
8
+ month: string;
9
+ periodStart: string;
10
+ periodEnd: string;
11
+ consumption: Array<{
12
+ subscriptionId: string;
13
+ model: string;
14
+ requestCount: number;
15
+ promptTokens: number;
16
+ completionTokens: number;
17
+ cost: string;
18
+ }>;
19
+ balance: {
20
+ starting: string;
21
+ topups: string;
22
+ charges: string;
23
+ ending: string;
24
+ };
25
+ keys: {
26
+ activeStart: number;
27
+ activeEnd: number;
28
+ newInPeriod: number;
29
+ revokedInPeriod: number;
30
+ dormancyInPeriod: number;
31
+ };
32
+ reconciliationHash: string;
33
+ }
34
+ export interface GetStatementArgs {
35
+ orgId: string;
36
+ month: string;
37
+ }
38
+ export declare function getStatement(client: Client, args: GetStatementArgs): Promise<StatementPayload>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getStatement = getStatement;
4
+ async function getStatement(client, args) {
5
+ return client.request(`/platform/orgs/${encodeURIComponent(args.orgId)}/statement`, {
6
+ method: 'GET',
7
+ query: { month: args.month },
8
+ });
9
+ }
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/statement/index.ts"],"names":[],"mappings":";;AAwCA,oCAWC;AAXM,KAAK,UAAU,YAAY,CAChC,MAAc,EACd,IAAsB;IAEtB,OAAO,MAAM,CAAC,OAAO,CACnB,kBAAkB,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,EAC5D;QACE,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE;KAC7B,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { Client } from '../client';
2
+ /** A subscription row (mirrors the Prisma `Subscription` model's public fields). */
3
+ export interface Subscription {
4
+ id: string;
5
+ orgId: string;
6
+ planId: string;
7
+ maxKeys: number;
8
+ contractStart: string;
9
+ commitmentEnd: string;
10
+ priceBookVersion: string;
11
+ status: 'ACTIVE' | 'EXPIRED' | 'CANCELLED';
12
+ isBaseTier: boolean;
13
+ }
14
+ export interface ExtendContractArgs {
15
+ /** New ISO8601 commitmentEnd — must be in the future and later than current. */
16
+ commitmentEnd: string;
17
+ memo?: string;
18
+ }
19
+ /**
20
+ * US-8 (#29): extend a subscription's contract commitment (renewal). Per
21
+ * subscription (an org holds many — ADR-014). Only `commitmentEnd` moves;
22
+ * tier/quota changes go through re-subscribe (cancel + add).
23
+ */
24
+ export declare function extendContract(client: Client, orgId: string, subId: string, args: ExtendContractArgs): Promise<Subscription>;
25
+ /**
26
+ * Body for `POST /platform/orgs/:orgId/subscriptions` (AddSubscriptionDto, #83).
27
+ * `priceBookVersion` is optional — the service captures the active version when
28
+ * omitted (sales-driven motion). Date-relationship checks live server-side.
29
+ */
30
+ export interface AddSubscriptionArgs {
31
+ planId: string;
32
+ /** Max keys for this subscription (integer ≥ 1). */
33
+ maxKeys: number;
34
+ /** ISO8601 contract start. */
35
+ contractStart: string;
36
+ /** ISO8601 commitment end — must be in the future and later than contractStart. */
37
+ commitmentEnd: string;
38
+ priceBookVersion?: string;
39
+ }
40
+ /**
41
+ * Add an additional (paid) subscription to an already-existing org — operator
42
+ * change-order motion (#83, ADR-014: an org holds many subs). Mirrors
43
+ * `POST /platform/orgs/:orgId/subscriptions`. Token must carry `write:orgs`.
44
+ */
45
+ export declare function addSubscription(client: Client, orgId: string, args: AddSubscriptionArgs): Promise<Subscription>;