@stigmer/sdk 3.16.1-dev.20260917224426 → 3.17.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/gen/client.d.ts +12 -0
- package/gen/client.d.ts.map +1 -1
- package/gen/client.js +12 -0
- package/gen/client.js.map +1 -1
- package/gen/license.d.ts +58 -0
- package/gen/license.d.ts.map +1 -0
- package/gen/license.js +97 -0
- package/gen/license.js.map +1 -0
- package/gen/plan.d.ts +56 -0
- package/gen/plan.d.ts.map +1 -0
- package/gen/plan.js +99 -0
- package/gen/plan.js.map +1 -0
- package/gen/resource-availability.d.ts.map +1 -1
- package/gen/resource-availability.js +3 -0
- package/gen/resource-availability.js.map +1 -1
- package/gen/subscription.d.ts +33 -0
- package/gen/subscription.d.ts.map +1 -0
- package/gen/subscription.js +69 -0
- package/gen/subscription.js.map +1 -0
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -1
- package/index.js +8 -0
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/platform.d.ts +15 -3
- package/platform.d.ts.map +1 -1
- package/platform.js +22 -3
- package/platform.js.map +1 -1
- package/src/gen/client.ts +15 -0
- package/src/gen/license.ts +141 -0
- package/src/gen/plan.ts +138 -0
- package/src/gen/resource-availability.ts +3 -0
- package/src/gen/subscription.ts +84 -0
- package/src/index.ts +18 -0
- package/src/platform.ts +25 -2
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Code generated by stigmer-codegen. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
import { wrapError } from "./errors.js";
|
|
4
|
+
import { stripUndefined } from "./proto-utils.js";
|
|
5
|
+
import { create } from "@bufbuild/protobuf";
|
|
6
|
+
import { createClient, type Client, type Transport } from "@connectrpc/connect";
|
|
7
|
+
import { SubscriptionSchema, type Subscription } from "@stigmer/protos/ai/stigmer/billing/subscription/v1/api_pb";
|
|
8
|
+
import { SubscriptionCommandController } from "@stigmer/protos/ai/stigmer/billing/subscription/v1/command_pb";
|
|
9
|
+
import { ChangePlanInputSchema, CancelSubscriptionInputSchema, GetSubscriptionForOrganizationInputSchema, GetEntitlementsInputSchema, GetEntitlementsOutputSchema, type ChangePlanInput, type CancelSubscriptionInput, type GetSubscriptionForOrganizationInput, type GetEntitlementsInput, type GetEntitlementsOutput } from "@stigmer/protos/ai/stigmer/billing/subscription/v1/io_pb";
|
|
10
|
+
import { SubscriptionQueryController } from "@stigmer/protos/ai/stigmer/billing/subscription/v1/query_pb";
|
|
11
|
+
import { SubscriptionSpecSchema } from "@stigmer/protos/ai/stigmer/billing/subscription/v1/spec_pb";
|
|
12
|
+
import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
|
|
13
|
+
import { ApiResourceMetadataSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/metadata_pb";
|
|
14
|
+
|
|
15
|
+
/** Provides operations on subscription resources. */
|
|
16
|
+
export class SubscriptionClient {
|
|
17
|
+
private readonly command: Client<typeof SubscriptionCommandController>;
|
|
18
|
+
private readonly query: Client<typeof SubscriptionQueryController>;
|
|
19
|
+
|
|
20
|
+
constructor(transport: Transport) {
|
|
21
|
+
this.command = createClient(SubscriptionCommandController, transport);
|
|
22
|
+
this.query = createClient(SubscriptionQueryController, transport);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async changePlan(input: ChangePlanInput): Promise<Subscription> {
|
|
26
|
+
try {
|
|
27
|
+
return await this.command.changePlan(input);
|
|
28
|
+
} catch (e) { throw wrapError(e); }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async cancel(input: CancelSubscriptionInput): Promise<Subscription> {
|
|
32
|
+
try {
|
|
33
|
+
return await this.command.cancel(input);
|
|
34
|
+
} catch (e) { throw wrapError(e); }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async getForOrganization(input: GetSubscriptionForOrganizationInput): Promise<Subscription> {
|
|
38
|
+
try {
|
|
39
|
+
return await this.query.getForOrganization(input);
|
|
40
|
+
} catch (e) { throw wrapError(e); }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async getEntitlements(input: GetEntitlementsInput): Promise<GetEntitlementsOutput> {
|
|
44
|
+
try {
|
|
45
|
+
return await this.query.getEntitlements(input);
|
|
46
|
+
} catch (e) { throw wrapError(e); }
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Input for creating/updating a Subscription. */
|
|
51
|
+
export interface SubscriptionInput {
|
|
52
|
+
/**
|
|
53
|
+
* The resource's `metadata.id`, for exact update addressing when set
|
|
54
|
+
* from a loaded resource. Required for updates to platform-scoped
|
|
55
|
+
* (org-less) kinds, where the org+slug fallback cannot match. On
|
|
56
|
+
* create, the cloud server stamps its own id regardless; the OSS
|
|
57
|
+
* server honors a caller-supplied id (existing apply semantics).
|
|
58
|
+
*/
|
|
59
|
+
id?: string;
|
|
60
|
+
name: string;
|
|
61
|
+
slug?: string;
|
|
62
|
+
org: string;
|
|
63
|
+
labels?: Record<string, string>;
|
|
64
|
+
visibility?: ApiResourceVisibility;
|
|
65
|
+
planId: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function buildSubscriptionProto(input: SubscriptionInput): Subscription {
|
|
69
|
+
return Object.assign(create(SubscriptionSchema), {
|
|
70
|
+
apiVersion: "billing.stigmer.ai/v1",
|
|
71
|
+
kind: "Subscription",
|
|
72
|
+
metadata: Object.assign(create(ApiResourceMetadataSchema), {
|
|
73
|
+
...(input.id && { id: input.id }),
|
|
74
|
+
name: input.name,
|
|
75
|
+
org: input.org,
|
|
76
|
+
...(input.slug && { slug: input.slug }),
|
|
77
|
+
...(input.labels && { labels: input.labels }),
|
|
78
|
+
...(input.visibility && { visibility: input.visibility }),
|
|
79
|
+
}),
|
|
80
|
+
spec: Object.assign(create(SubscriptionSpecSchema), stripUndefined({
|
|
81
|
+
planId: input.planId,
|
|
82
|
+
})),
|
|
83
|
+
}) as Subscription;
|
|
84
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -283,6 +283,24 @@ export {
|
|
|
283
283
|
toPlatformClientUpdateInput,
|
|
284
284
|
type PlatformClientInput,
|
|
285
285
|
} from "./gen/platformclient.js";
|
|
286
|
+
// The billing kinds (cloud_only): the plan catalog, an organization's
|
|
287
|
+
// subscription, and issued licenses. The entitlement input types are
|
|
288
|
+
// emitted once per module that uses them, identical in shape; this barrel
|
|
289
|
+
// exports the plan's copy. A subscription is created by the payment system,
|
|
290
|
+
// never by a client, so no input type is exported for it.
|
|
291
|
+
export {
|
|
292
|
+
PlanClient,
|
|
293
|
+
type PlanInput,
|
|
294
|
+
type PlanTermsInput,
|
|
295
|
+
type EntitlementsInput,
|
|
296
|
+
type EntitlementLimitsInput,
|
|
297
|
+
} from "./gen/plan.js";
|
|
298
|
+
export { SubscriptionClient } from "./gen/subscription.js";
|
|
299
|
+
export {
|
|
300
|
+
LicenseClient,
|
|
301
|
+
type LicenseInput,
|
|
302
|
+
type LicenseCustomerInput,
|
|
303
|
+
} from "./gen/license.js";
|
|
286
304
|
export {
|
|
287
305
|
ProjectClient,
|
|
288
306
|
toProjectUpdateInput,
|
package/src/platform.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { createClient, type Client, type Transport } from "@connectrpc/connect";
|
|
2
2
|
import { create } from "@bufbuild/protobuf";
|
|
3
3
|
import {
|
|
4
|
+
GetLicenseStatusInputSchema,
|
|
4
5
|
GetServerInfoInputSchema,
|
|
5
6
|
PlatformQueryController,
|
|
6
7
|
} from "@stigmer/protos/ai/stigmer/platform/v1/server_info_pb";
|
|
7
8
|
import type {
|
|
9
|
+
GetLicenseStatusOutput,
|
|
8
10
|
GetServerInfoOutput,
|
|
9
11
|
ServerEdition,
|
|
10
12
|
} from "@stigmer/protos/ai/stigmer/platform/v1/server_info_pb";
|
|
@@ -25,11 +27,12 @@ export interface ServerInfo {
|
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
|
-
* Client for platform-level queries (server info, capabilities).
|
|
30
|
+
* Client for platform-level queries (server info, capabilities, license).
|
|
29
31
|
*
|
|
30
32
|
* The {@link getServerInfo} method is the authoritative source for
|
|
31
33
|
* deployment mode detection. It replaces URL-based hostname guessing
|
|
32
|
-
* with a server-reported value.
|
|
34
|
+
* with a server-reported value. {@link getLicenseStatus} is its sibling
|
|
35
|
+
* for the license the server holds; every edition answers it.
|
|
33
36
|
*/
|
|
34
37
|
export class PlatformClient {
|
|
35
38
|
private readonly platform: Client<typeof PlatformQueryController>;
|
|
@@ -62,4 +65,24 @@ export class PlatformClient {
|
|
|
62
65
|
throw wrapError(e);
|
|
63
66
|
}
|
|
64
67
|
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Retrieve the state of the license the connected server holds.
|
|
71
|
+
*
|
|
72
|
+
* Every edition answers: open source and Stigmer Cloud report `absent`
|
|
73
|
+
* (neither holds a key); a Stigmer Enterprise deployment reports the
|
|
74
|
+
* state of its configured ticket with the verified claims. Requires a
|
|
75
|
+
* signed-in caller. The generated output is returned as it is, so the
|
|
76
|
+
* presence contract it documents (claims exactly when a ticket verified,
|
|
77
|
+
* key id whenever one was presented) reaches the caller unchanged.
|
|
78
|
+
*/
|
|
79
|
+
async getLicenseStatus(): Promise<GetLicenseStatusOutput> {
|
|
80
|
+
try {
|
|
81
|
+
return await this.platform.getLicenseStatus(
|
|
82
|
+
create(GetLicenseStatusInputSchema, {}),
|
|
83
|
+
);
|
|
84
|
+
} catch (e) {
|
|
85
|
+
throw wrapError(e);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
65
88
|
}
|