@devsym/subscription-portal-s2s-client 1.1.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.
@@ -0,0 +1,255 @@
1
+ interface components {
2
+ schemas: {
3
+ ApiError: {
4
+ error: {
5
+ code: string;
6
+ message: string;
7
+ correlationId: string;
8
+ details?: {
9
+ [key: string]: unknown;
10
+ };
11
+ };
12
+ };
13
+ RedeemLicenseKeyRequest: {
14
+ licenseKey: string;
15
+ /** Format: uuid */
16
+ microsoftTenantId: string;
17
+ requestedBy?: {
18
+ externalUserId?: string;
19
+ displayName?: string;
20
+ };
21
+ correlationId?: string;
22
+ };
23
+ RedeemLicenseKeyResponse: {
24
+ /** @enum {string} */
25
+ result: "linked" | "alreadyLinked";
26
+ subscriptionId: string;
27
+ customerOrganizationId: string;
28
+ effectiveEntitledAppId: string;
29
+ status: string;
30
+ quantity: number;
31
+ ownershipAcquisitionMode: string;
32
+ correlationId: string;
33
+ };
34
+ ReleaseClaimRequest: {
35
+ /** Format: uuid */
36
+ subscriptionId: string;
37
+ /** Format: uuid */
38
+ microsoftTenantId: string;
39
+ };
40
+ ReleaseClaimResponse: {
41
+ /** @enum {string} */
42
+ result: "released";
43
+ subscriptionId?: string;
44
+ correlationId: string;
45
+ };
46
+ SubscriptionStatusResponse: {
47
+ appId: string;
48
+ microsoftTenantId: string;
49
+ customerOrganizationId?: string;
50
+ hasActiveEntitlement: boolean;
51
+ aggregateEffectiveQuantity: number;
52
+ subscriptions: {
53
+ subscriptionId: string;
54
+ /** @enum {string} */
55
+ status: "pending" | "active" | "suspended" | "canceled" | "expired" | "incomplete" | "unassigned";
56
+ /** @enum {string} */
57
+ entitlementType: "paid" | "trial" | "manual";
58
+ /** @enum {string} */
59
+ provider: "microsoft" | "paddle" | "trial" | "manual";
60
+ effectiveQuantity?: number;
61
+ lastSynchronizedOn?: string;
62
+ /** @description Present and true on a trial that an active paid or manual entitlement supersedes. The trial is still listed but does not contribute to aggregateEffectiveQuantity. */
63
+ supersededByPaid?: boolean;
64
+ }[];
65
+ };
66
+ CapabilitiesResponse: {
67
+ /**
68
+ * @description The S2S contract major this instance serves.
69
+ * @enum {string}
70
+ */
71
+ apiVersion: "v1";
72
+ /** @description The portal build serving the request. Present for support and diagnostics; never branch integration behaviour on it, branch on operations instead. */
73
+ portalVersion?: string;
74
+ appId: string;
75
+ /** @description The operationIds this instance serves. A client calling an operation absent from this list receives 404. */
76
+ operations: string[];
77
+ /** @description Roles effectively granted to the caller for this app: present both in the caller's access token and in its trusted-application record. A role missing here fails with insufficient_role when used. */
78
+ grantedRoles: string[];
79
+ };
80
+ EntitlementsResponse: {
81
+ appId: string;
82
+ microsoftTenantId: string;
83
+ customerOrganizationId?: string;
84
+ hasActiveEntitlement: boolean;
85
+ aggregateEffectiveQuantity: number;
86
+ items: {
87
+ subscriptionId: string;
88
+ /** @enum {string} */
89
+ provider: "microsoft" | "paddle" | "trial" | "manual";
90
+ /** @enum {string} */
91
+ entitlementType: "paid" | "trial" | "manual";
92
+ status: string;
93
+ effectiveQuantity?: number;
94
+ lastSynchronizedOn?: string;
95
+ }[];
96
+ };
97
+ LinkageResponse: {
98
+ appId: string;
99
+ microsoftTenantId: string;
100
+ customerOrganizationId?: string;
101
+ tenantLink?: {
102
+ /** @enum {string} */
103
+ linkSource: "activation" | "claim" | "manualAssignment" | "trial";
104
+ linkedOn: string;
105
+ isActive: boolean;
106
+ };
107
+ claims: {
108
+ subscriptionId: string;
109
+ /** @enum {string} */
110
+ claimState: "assigned" | "unassigned" | "released";
111
+ }[];
112
+ };
113
+ SubscriptionSyncRequest: {
114
+ reason: string;
115
+ };
116
+ TenantSyncRequest: {
117
+ /** @enum {string} */
118
+ provider: "microsoft" | "paddle";
119
+ reason: string;
120
+ };
121
+ StartTrialRequest: {
122
+ requestedBy?: {
123
+ externalUserId?: string;
124
+ displayName?: string;
125
+ };
126
+ /** Format: email */
127
+ beneficiaryEmail?: string;
128
+ displayName?: string;
129
+ };
130
+ StartTrialResponse: {
131
+ /** @enum {string} */
132
+ result: "started" | "alreadyActive";
133
+ subscriptionId: string;
134
+ customerOrganizationId: string;
135
+ /** @enum {string} */
136
+ trialMode: "timeBased" | "seatLimited";
137
+ /** @enum {string} */
138
+ trialStatus: "active";
139
+ trialStartOn: string;
140
+ trialEndOn?: string;
141
+ trialSeatLimit?: number;
142
+ trialUsage?: number;
143
+ correlationId: string;
144
+ };
145
+ SyncRequestResponse: {
146
+ accepted: boolean;
147
+ syncRequestId: string;
148
+ /** @enum {string} */
149
+ status: "queued";
150
+ correlationId: string;
151
+ };
152
+ };
153
+ responses: {
154
+ /** @description A normalized error response. */
155
+ ApiError: {
156
+ headers: {
157
+ [name: string]: unknown;
158
+ };
159
+ content: {
160
+ "application/json": components["schemas"]["ApiError"];
161
+ };
162
+ };
163
+ };
164
+ parameters: {
165
+ AppId: string;
166
+ SubscriptionId: string;
167
+ MicrosoftTenantId: string;
168
+ CorrelationId: string;
169
+ IdempotencyKey: string;
170
+ };
171
+ requestBodies: never;
172
+ headers: never;
173
+ pathItems: never;
174
+ }
175
+
176
+ type TokenProvider = {
177
+ getToken(scope: string): Promise<{
178
+ token: string;
179
+ } | null>;
180
+ };
181
+ declare function defaultTokenProvider(): TokenProvider;
182
+
183
+ type PortalS2sClientOptions = {
184
+ baseUrl: string;
185
+ audience: string;
186
+ credential?: TokenProvider;
187
+ fetch?: typeof globalThis.fetch;
188
+ randomUuid?: () => string;
189
+ sleep?: (milliseconds: number) => Promise<void>;
190
+ };
191
+ /**
192
+ * The S2S contract major this client speaks. Every route it calls lives under
193
+ * `/api/s2s/{S2S_API_VERSION}/`. The package major is locked to this value: a
194
+ * new contract major ships as a new client major, never as a minor.
195
+ */
196
+ declare const S2S_API_VERSION = "v1";
197
+ type RedeemLicenseKeyRequest = components["schemas"]["RedeemLicenseKeyRequest"];
198
+ type RedeemLicenseKeyResponse = components["schemas"]["RedeemLicenseKeyResponse"];
199
+ type ReleaseClaimRequest = components["schemas"]["ReleaseClaimRequest"];
200
+ type ReleaseClaimResponse = components["schemas"]["ReleaseClaimResponse"];
201
+ type SubscriptionStatusResponse = components["schemas"]["SubscriptionStatusResponse"];
202
+ type EntitlementsResponse = components["schemas"]["EntitlementsResponse"];
203
+ type CapabilitiesResponse = components["schemas"]["CapabilitiesResponse"];
204
+ type LinkageResponse = components["schemas"]["LinkageResponse"];
205
+ type SubscriptionSyncRequest = components["schemas"]["SubscriptionSyncRequest"];
206
+ type TenantSyncRequest = components["schemas"]["TenantSyncRequest"];
207
+ type SyncRequestResponse = components["schemas"]["SyncRequestResponse"];
208
+ type StartTrialRequest = components["schemas"]["StartTrialRequest"];
209
+ type StartTrialResponse = components["schemas"]["StartTrialResponse"];
210
+ declare class PortalS2sClient {
211
+ private readonly baseUrl;
212
+ private readonly audience;
213
+ private readonly credential;
214
+ private readonly fetch;
215
+ private readonly randomUuid;
216
+ private readonly sleep;
217
+ constructor(options: PortalS2sClientOptions);
218
+ /**
219
+ * Reports what this portal instance serves and what this caller may do.
220
+ *
221
+ * Instances are self-hosted and may run an older build than this client, so
222
+ * call this at startup: check `operations` for the routes you rely on and
223
+ * `grantedRoles` for the roles you need, and fail configuration loudly rather
224
+ * than discovering the gap on a customer's first redeem or trial start.
225
+ * Requires no application role.
226
+ */
227
+ getCapabilities(appId: string): Promise<CapabilitiesResponse>;
228
+ getSubscriptionStatus(appId: string, microsoftTenantId: string): Promise<SubscriptionStatusResponse>;
229
+ getEntitlements(appId: string, microsoftTenantId: string): Promise<EntitlementsResponse>;
230
+ getLinkage(appId: string, microsoftTenantId: string): Promise<LinkageResponse>;
231
+ redeemLicenseKey(appId: string, request: RedeemLicenseKeyRequest): Promise<RedeemLicenseKeyResponse>;
232
+ releaseClaim(appId: string, request: ReleaseClaimRequest): Promise<ReleaseClaimResponse>;
233
+ requestSubscriptionSync(appId: string, subscriptionId: string, request: SubscriptionSyncRequest): Promise<SyncRequestResponse>;
234
+ startTrial(appId: string, microsoftTenantId: string, request?: StartTrialRequest): Promise<StartTrialResponse>;
235
+ requestTenantSync(appId: string, microsoftTenantId: string, request: TenantSyncRequest): Promise<SyncRequestResponse>;
236
+ private request;
237
+ private unexpectedResponse;
238
+ }
239
+
240
+ type PortalS2sErrorOptions = {
241
+ status?: number;
242
+ code: string;
243
+ correlationId?: string;
244
+ details?: Record<string, unknown>;
245
+ message: string;
246
+ };
247
+ declare class PortalS2sError extends Error {
248
+ readonly status: number | undefined;
249
+ readonly code: string;
250
+ readonly correlationId: string | undefined;
251
+ readonly details: Record<string, unknown> | undefined;
252
+ constructor(options: PortalS2sErrorOptions);
253
+ }
254
+
255
+ export { type CapabilitiesResponse, type EntitlementsResponse, type LinkageResponse, PortalS2sClient, type PortalS2sClientOptions, PortalS2sError, type RedeemLicenseKeyRequest, type RedeemLicenseKeyResponse, type ReleaseClaimRequest, type ReleaseClaimResponse, S2S_API_VERSION, type StartTrialRequest, type StartTrialResponse, type SubscriptionStatusResponse, type SubscriptionSyncRequest, type SyncRequestResponse, type TenantSyncRequest, type TokenProvider, defaultTokenProvider };
@@ -0,0 +1,255 @@
1
+ interface components {
2
+ schemas: {
3
+ ApiError: {
4
+ error: {
5
+ code: string;
6
+ message: string;
7
+ correlationId: string;
8
+ details?: {
9
+ [key: string]: unknown;
10
+ };
11
+ };
12
+ };
13
+ RedeemLicenseKeyRequest: {
14
+ licenseKey: string;
15
+ /** Format: uuid */
16
+ microsoftTenantId: string;
17
+ requestedBy?: {
18
+ externalUserId?: string;
19
+ displayName?: string;
20
+ };
21
+ correlationId?: string;
22
+ };
23
+ RedeemLicenseKeyResponse: {
24
+ /** @enum {string} */
25
+ result: "linked" | "alreadyLinked";
26
+ subscriptionId: string;
27
+ customerOrganizationId: string;
28
+ effectiveEntitledAppId: string;
29
+ status: string;
30
+ quantity: number;
31
+ ownershipAcquisitionMode: string;
32
+ correlationId: string;
33
+ };
34
+ ReleaseClaimRequest: {
35
+ /** Format: uuid */
36
+ subscriptionId: string;
37
+ /** Format: uuid */
38
+ microsoftTenantId: string;
39
+ };
40
+ ReleaseClaimResponse: {
41
+ /** @enum {string} */
42
+ result: "released";
43
+ subscriptionId?: string;
44
+ correlationId: string;
45
+ };
46
+ SubscriptionStatusResponse: {
47
+ appId: string;
48
+ microsoftTenantId: string;
49
+ customerOrganizationId?: string;
50
+ hasActiveEntitlement: boolean;
51
+ aggregateEffectiveQuantity: number;
52
+ subscriptions: {
53
+ subscriptionId: string;
54
+ /** @enum {string} */
55
+ status: "pending" | "active" | "suspended" | "canceled" | "expired" | "incomplete" | "unassigned";
56
+ /** @enum {string} */
57
+ entitlementType: "paid" | "trial" | "manual";
58
+ /** @enum {string} */
59
+ provider: "microsoft" | "paddle" | "trial" | "manual";
60
+ effectiveQuantity?: number;
61
+ lastSynchronizedOn?: string;
62
+ /** @description Present and true on a trial that an active paid or manual entitlement supersedes. The trial is still listed but does not contribute to aggregateEffectiveQuantity. */
63
+ supersededByPaid?: boolean;
64
+ }[];
65
+ };
66
+ CapabilitiesResponse: {
67
+ /**
68
+ * @description The S2S contract major this instance serves.
69
+ * @enum {string}
70
+ */
71
+ apiVersion: "v1";
72
+ /** @description The portal build serving the request. Present for support and diagnostics; never branch integration behaviour on it, branch on operations instead. */
73
+ portalVersion?: string;
74
+ appId: string;
75
+ /** @description The operationIds this instance serves. A client calling an operation absent from this list receives 404. */
76
+ operations: string[];
77
+ /** @description Roles effectively granted to the caller for this app: present both in the caller's access token and in its trusted-application record. A role missing here fails with insufficient_role when used. */
78
+ grantedRoles: string[];
79
+ };
80
+ EntitlementsResponse: {
81
+ appId: string;
82
+ microsoftTenantId: string;
83
+ customerOrganizationId?: string;
84
+ hasActiveEntitlement: boolean;
85
+ aggregateEffectiveQuantity: number;
86
+ items: {
87
+ subscriptionId: string;
88
+ /** @enum {string} */
89
+ provider: "microsoft" | "paddle" | "trial" | "manual";
90
+ /** @enum {string} */
91
+ entitlementType: "paid" | "trial" | "manual";
92
+ status: string;
93
+ effectiveQuantity?: number;
94
+ lastSynchronizedOn?: string;
95
+ }[];
96
+ };
97
+ LinkageResponse: {
98
+ appId: string;
99
+ microsoftTenantId: string;
100
+ customerOrganizationId?: string;
101
+ tenantLink?: {
102
+ /** @enum {string} */
103
+ linkSource: "activation" | "claim" | "manualAssignment" | "trial";
104
+ linkedOn: string;
105
+ isActive: boolean;
106
+ };
107
+ claims: {
108
+ subscriptionId: string;
109
+ /** @enum {string} */
110
+ claimState: "assigned" | "unassigned" | "released";
111
+ }[];
112
+ };
113
+ SubscriptionSyncRequest: {
114
+ reason: string;
115
+ };
116
+ TenantSyncRequest: {
117
+ /** @enum {string} */
118
+ provider: "microsoft" | "paddle";
119
+ reason: string;
120
+ };
121
+ StartTrialRequest: {
122
+ requestedBy?: {
123
+ externalUserId?: string;
124
+ displayName?: string;
125
+ };
126
+ /** Format: email */
127
+ beneficiaryEmail?: string;
128
+ displayName?: string;
129
+ };
130
+ StartTrialResponse: {
131
+ /** @enum {string} */
132
+ result: "started" | "alreadyActive";
133
+ subscriptionId: string;
134
+ customerOrganizationId: string;
135
+ /** @enum {string} */
136
+ trialMode: "timeBased" | "seatLimited";
137
+ /** @enum {string} */
138
+ trialStatus: "active";
139
+ trialStartOn: string;
140
+ trialEndOn?: string;
141
+ trialSeatLimit?: number;
142
+ trialUsage?: number;
143
+ correlationId: string;
144
+ };
145
+ SyncRequestResponse: {
146
+ accepted: boolean;
147
+ syncRequestId: string;
148
+ /** @enum {string} */
149
+ status: "queued";
150
+ correlationId: string;
151
+ };
152
+ };
153
+ responses: {
154
+ /** @description A normalized error response. */
155
+ ApiError: {
156
+ headers: {
157
+ [name: string]: unknown;
158
+ };
159
+ content: {
160
+ "application/json": components["schemas"]["ApiError"];
161
+ };
162
+ };
163
+ };
164
+ parameters: {
165
+ AppId: string;
166
+ SubscriptionId: string;
167
+ MicrosoftTenantId: string;
168
+ CorrelationId: string;
169
+ IdempotencyKey: string;
170
+ };
171
+ requestBodies: never;
172
+ headers: never;
173
+ pathItems: never;
174
+ }
175
+
176
+ type TokenProvider = {
177
+ getToken(scope: string): Promise<{
178
+ token: string;
179
+ } | null>;
180
+ };
181
+ declare function defaultTokenProvider(): TokenProvider;
182
+
183
+ type PortalS2sClientOptions = {
184
+ baseUrl: string;
185
+ audience: string;
186
+ credential?: TokenProvider;
187
+ fetch?: typeof globalThis.fetch;
188
+ randomUuid?: () => string;
189
+ sleep?: (milliseconds: number) => Promise<void>;
190
+ };
191
+ /**
192
+ * The S2S contract major this client speaks. Every route it calls lives under
193
+ * `/api/s2s/{S2S_API_VERSION}/`. The package major is locked to this value: a
194
+ * new contract major ships as a new client major, never as a minor.
195
+ */
196
+ declare const S2S_API_VERSION = "v1";
197
+ type RedeemLicenseKeyRequest = components["schemas"]["RedeemLicenseKeyRequest"];
198
+ type RedeemLicenseKeyResponse = components["schemas"]["RedeemLicenseKeyResponse"];
199
+ type ReleaseClaimRequest = components["schemas"]["ReleaseClaimRequest"];
200
+ type ReleaseClaimResponse = components["schemas"]["ReleaseClaimResponse"];
201
+ type SubscriptionStatusResponse = components["schemas"]["SubscriptionStatusResponse"];
202
+ type EntitlementsResponse = components["schemas"]["EntitlementsResponse"];
203
+ type CapabilitiesResponse = components["schemas"]["CapabilitiesResponse"];
204
+ type LinkageResponse = components["schemas"]["LinkageResponse"];
205
+ type SubscriptionSyncRequest = components["schemas"]["SubscriptionSyncRequest"];
206
+ type TenantSyncRequest = components["schemas"]["TenantSyncRequest"];
207
+ type SyncRequestResponse = components["schemas"]["SyncRequestResponse"];
208
+ type StartTrialRequest = components["schemas"]["StartTrialRequest"];
209
+ type StartTrialResponse = components["schemas"]["StartTrialResponse"];
210
+ declare class PortalS2sClient {
211
+ private readonly baseUrl;
212
+ private readonly audience;
213
+ private readonly credential;
214
+ private readonly fetch;
215
+ private readonly randomUuid;
216
+ private readonly sleep;
217
+ constructor(options: PortalS2sClientOptions);
218
+ /**
219
+ * Reports what this portal instance serves and what this caller may do.
220
+ *
221
+ * Instances are self-hosted and may run an older build than this client, so
222
+ * call this at startup: check `operations` for the routes you rely on and
223
+ * `grantedRoles` for the roles you need, and fail configuration loudly rather
224
+ * than discovering the gap on a customer's first redeem or trial start.
225
+ * Requires no application role.
226
+ */
227
+ getCapabilities(appId: string): Promise<CapabilitiesResponse>;
228
+ getSubscriptionStatus(appId: string, microsoftTenantId: string): Promise<SubscriptionStatusResponse>;
229
+ getEntitlements(appId: string, microsoftTenantId: string): Promise<EntitlementsResponse>;
230
+ getLinkage(appId: string, microsoftTenantId: string): Promise<LinkageResponse>;
231
+ redeemLicenseKey(appId: string, request: RedeemLicenseKeyRequest): Promise<RedeemLicenseKeyResponse>;
232
+ releaseClaim(appId: string, request: ReleaseClaimRequest): Promise<ReleaseClaimResponse>;
233
+ requestSubscriptionSync(appId: string, subscriptionId: string, request: SubscriptionSyncRequest): Promise<SyncRequestResponse>;
234
+ startTrial(appId: string, microsoftTenantId: string, request?: StartTrialRequest): Promise<StartTrialResponse>;
235
+ requestTenantSync(appId: string, microsoftTenantId: string, request: TenantSyncRequest): Promise<SyncRequestResponse>;
236
+ private request;
237
+ private unexpectedResponse;
238
+ }
239
+
240
+ type PortalS2sErrorOptions = {
241
+ status?: number;
242
+ code: string;
243
+ correlationId?: string;
244
+ details?: Record<string, unknown>;
245
+ message: string;
246
+ };
247
+ declare class PortalS2sError extends Error {
248
+ readonly status: number | undefined;
249
+ readonly code: string;
250
+ readonly correlationId: string | undefined;
251
+ readonly details: Record<string, unknown> | undefined;
252
+ constructor(options: PortalS2sErrorOptions);
253
+ }
254
+
255
+ export { type CapabilitiesResponse, type EntitlementsResponse, type LinkageResponse, PortalS2sClient, type PortalS2sClientOptions, PortalS2sError, type RedeemLicenseKeyRequest, type RedeemLicenseKeyResponse, type ReleaseClaimRequest, type ReleaseClaimResponse, S2S_API_VERSION, type StartTrialRequest, type StartTrialResponse, type SubscriptionStatusResponse, type SubscriptionSyncRequest, type SyncRequestResponse, type TenantSyncRequest, type TokenProvider, defaultTokenProvider };