@parra/parra-js-sdk 0.2.38 → 0.2.42

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.
@@ -1,10 +1,22 @@
1
1
  import { HTTPClient } from "@parra/http-client";
2
+ export interface AuthorizationCheckRequestBody {
3
+ namespace: string;
4
+ subject: string;
5
+ scope: string;
6
+ context?: Map<string, any>;
7
+ }
8
+ export interface AuthorizationCheck {
9
+ allowed: boolean;
10
+ }
2
11
  export interface CreateCheckoutSessionRequestBody {
3
12
  plan_id: string;
4
13
  }
5
14
  export interface CheckoutSession {
6
15
  url: string;
7
16
  }
17
+ export interface BillingPortalSession {
18
+ url: string;
19
+ }
8
20
  export interface CreateCustomerRequestBody {
9
21
  name: string;
10
22
  tenant_id: string;
@@ -32,18 +44,18 @@ export interface Price {
32
44
  export interface UnitPrice {
33
45
  currency: Currency;
34
46
  amount: number;
35
- interval?: Interval;
47
+ interval?: Interval | null;
36
48
  }
37
49
  export interface Plan {
38
50
  id: string;
39
51
  created_at: string;
40
52
  updated_at: string;
41
53
  deleted_at?: string | null;
42
- tier: string;
43
- interval: string;
44
- price: UnitPrice;
45
- discounted_price?: Price;
46
- unit_price: UnitPrice;
54
+ tier: string | null;
55
+ interval: string | null;
56
+ price: UnitPrice | null;
57
+ discounted_price?: Price | null;
58
+ unit_price: UnitPrice | null;
47
59
  context?: string | null;
48
60
  }
49
61
  export declare enum SubscriptionStatus {
@@ -69,7 +81,7 @@ export interface Subscription {
69
81
  updated_at: string;
70
82
  deleted_at?: string | null;
71
83
  customer_id: string;
72
- status: SubscriptionStatus;
84
+ status: SubscriptionStatus | null;
73
85
  cancel_at?: string | null;
74
86
  cancel_at_period_end?: boolean | null;
75
87
  canceled_at?: string | null;
@@ -79,18 +91,32 @@ export interface Subscription {
79
91
  ended_at?: string | null;
80
92
  trial_start?: string | null;
81
93
  trial_end?: string | null;
82
- items: Array<SubscriptionItem>;
94
+ items: Array<SubscriptionItem> | null;
83
95
  }
84
96
  export interface TenantPlansResponse {
85
- plans?: Array<Plan>;
86
- subscriptions?: Array<Subscription>;
97
+ plans?: Array<Plan> | null;
98
+ subscriptions?: Array<Subscription> | null;
87
99
  }
88
100
  export interface StripeEvent {
89
101
  }
102
+ export interface Entitlement {
103
+ }
104
+ export declare type Entitlements = Array<Entitlement>;
105
+ export declare type UpdateEntitlementsRequestBody = Array<Entitlement>;
90
106
  export interface CreateTenantRequestBody {
91
107
  name: string;
92
108
  is_test: boolean;
93
109
  }
110
+ export interface TenantUser {
111
+ id: string;
112
+ created_at: string;
113
+ updated_at: string;
114
+ deleted_at?: string | null;
115
+ name: string;
116
+ is_test: boolean;
117
+ entitlements?: Array<Entitlement> | null;
118
+ scopes: Array<string>;
119
+ }
94
120
  export interface Tenant {
95
121
  id: string;
96
122
  created_at: string;
@@ -98,6 +124,7 @@ export interface Tenant {
98
124
  deleted_at?: string | null;
99
125
  name: string;
100
126
  is_test: boolean;
127
+ entitlements?: Array<Entitlement> | null;
101
128
  }
102
129
  export declare type TenantListResponse = Array<Tenant>;
103
130
  export interface TenantCollectionResponse {
@@ -139,6 +166,9 @@ export interface ApiKeyCollectionResponse {
139
166
  }
140
167
  export interface AnswerData {
141
168
  }
169
+ export interface FeedbackMetrics {
170
+ questions_asked_this_month: number;
171
+ }
142
172
  export interface Answer {
143
173
  id: string;
144
174
  created_at: string;
@@ -162,12 +192,12 @@ export declare enum CardItemType {
162
192
  question = "question"
163
193
  }
164
194
  export interface CardItem {
165
- type: CardItemType;
166
- version: string;
167
- data: CardItemData;
195
+ type: CardItemType | null;
196
+ version: string | null;
197
+ data: CardItemData | null;
168
198
  }
169
199
  export interface CardsResponse {
170
- items: Array<CardItem>;
200
+ items: Array<CardItem> | null;
171
201
  }
172
202
  export declare enum QuestionType {
173
203
  choice = "choice",
@@ -179,28 +209,28 @@ export declare enum QuestionKind {
179
209
  star = "star"
180
210
  }
181
211
  export interface MutableChoiceQuestionOption {
182
- title: string;
183
- value: string;
212
+ title: string | null;
213
+ value: string | null;
184
214
  is_other?: boolean | null;
185
215
  }
186
216
  export interface ChoiceQuestionOption {
187
- title: string;
188
- value: string;
217
+ title: string | null;
218
+ value: string | null;
189
219
  is_other?: boolean | null;
190
- id: string;
220
+ id: string | null;
191
221
  }
192
222
  export interface ChoiceQuestionBody {
193
- options: Array<ChoiceQuestionOption>;
223
+ options: Array<ChoiceQuestionOption> | null;
194
224
  }
195
225
  export interface MutableChoiceQuestionBody {
196
- options: Array<MutableChoiceQuestionOption>;
226
+ options: Array<MutableChoiceQuestionOption> | null;
197
227
  }
198
228
  export declare type MutableQuestionData = MutableChoiceQuestionBody;
199
229
  export declare type QuestionData = ChoiceQuestionBody;
200
230
  export interface UpdateQuestionRequestBody {
201
231
  title: string;
202
232
  subtitle?: string | null;
203
- data: MutableQuestionData;
233
+ data: MutableQuestionData | null;
204
234
  active?: boolean;
205
235
  expires_at?: string | null;
206
236
  answer_quota?: number | null;
@@ -208,12 +238,12 @@ export interface UpdateQuestionRequestBody {
208
238
  export interface CreateQuestionRequestBody {
209
239
  title: string;
210
240
  subtitle?: string | null;
211
- data: MutableQuestionData;
241
+ data: MutableQuestionData | null;
212
242
  active?: boolean;
213
243
  expires_at?: string | null;
214
244
  answer_quota?: number | null;
215
- type: QuestionType;
216
- kind: QuestionKind;
245
+ type: QuestionType | null;
246
+ kind: QuestionKind | null;
217
247
  }
218
248
  export declare enum QuestionStatus {
219
249
  open = "open",
@@ -224,20 +254,20 @@ export interface Question {
224
254
  created_at: string;
225
255
  updated_at: string;
226
256
  deleted_at?: string | null;
227
- status: QuestionStatus;
257
+ status: QuestionStatus | null;
228
258
  tenant_id: string;
229
259
  title: string;
230
260
  subtitle?: string | null;
231
- type: QuestionType;
232
- kind: QuestionKind;
233
- data: QuestionData;
261
+ type: QuestionType | null;
262
+ kind: QuestionKind | null;
263
+ data: QuestionData | null;
234
264
  active?: boolean;
235
265
  answer_quota?: number | null;
236
266
  answer_count?: number;
237
267
  expires_at?: string | null;
238
268
  closed_at?: string | null;
239
- answer?: Answer;
240
- metrics?: QuestionMetrics;
269
+ answer?: Answer | null;
270
+ metrics?: QuestionMetrics | null;
241
271
  }
242
272
  export interface QuestionCollectionResponse {
243
273
  page: number;
@@ -253,18 +283,18 @@ export interface QuestionMetrics {
253
283
  deleted_at?: string | null;
254
284
  question_id: string;
255
285
  answer_count: number;
256
- type: QuestionType;
257
- data: QuestionMetricsData;
286
+ type: QuestionType | null;
287
+ data: QuestionMetricsData | null;
258
288
  }
259
289
  export declare type QuestionMetricsData = ChoiceQuestionMetricsBody;
260
290
  export interface ChoiceQuestionMetricsBody {
261
- options: Array<ChoiceQuestionMetricsOption>;
291
+ options: Array<ChoiceQuestionMetricsOption> | null;
262
292
  }
263
293
  export interface ChoiceQuestionMetricsOption {
264
- title: string;
265
- value: string;
294
+ title: string | null;
295
+ value: string | null;
266
296
  is_other?: boolean | null;
267
- id: string;
297
+ id: string | null;
268
298
  answer_count: number;
269
299
  }
270
300
  export interface NotificationRecipient {
@@ -284,7 +314,7 @@ export interface CreateNotificationRequestBody {
284
314
  silent?: boolean;
285
315
  content_available?: boolean;
286
316
  expires_at?: string | null;
287
- recipients: Array<NotificationRecipient>;
317
+ recipients: Array<NotificationRecipient> | null;
288
318
  }
289
319
  export interface NotificationResponse {
290
320
  type?: string;
@@ -357,7 +387,7 @@ export interface CreateUserRequestBody {
357
387
  avatar_url?: string | null;
358
388
  locale?: string | null;
359
389
  type: string;
360
- identities?: Array<CreateIdentityRequestBody>;
390
+ identities?: Array<CreateIdentityRequestBody> | null;
361
391
  }
362
392
  export interface UpdateUserRequestBody {
363
393
  first_name: string;
@@ -371,6 +401,12 @@ export interface UserCollectionResponse {
371
401
  total_count: number;
372
402
  data: Array<UserResponse>;
373
403
  }
404
+ export interface CheckAuthorizationRequestBody {
405
+ scope: string;
406
+ }
407
+ export interface CheckAuthorization {
408
+ allowed: boolean;
409
+ }
374
410
  export interface UserInfoResponse {
375
411
  user?: UserResponse | null;
376
412
  }
@@ -381,12 +417,13 @@ declare class ParraAPI {
381
417
  baseUrl: string;
382
418
  });
383
419
  createCustomer: (body?: CreateCustomerRequestBody | undefined) => Promise<Customer>;
420
+ updateEntitlementsForCustomerById: (customer_id: string) => Promise<Response>;
421
+ createBillingPortalSession: (tenant_id: string) => Promise<BillingPortalSession>;
384
422
  createCheckoutSession: (body?: CreateCheckoutSessionRequestBody | undefined) => Promise<CheckoutSession>;
385
423
  getPlansForTenantById: (tenant_id: string) => Promise<TenantPlansResponse>;
386
424
  getTenantById: (tenant_id: string) => Promise<Tenant>;
387
425
  createTenantForUserById: (user_id: string, body?: CreateTenantRequestBody | undefined) => Promise<Tenant>;
388
426
  getTenantsForUserById: (user_id: string) => Promise<TenantListResponse>;
389
- getTenantByUserIdAndTenantId: (user_id: string, tenant_id: string) => Promise<Tenant>;
390
427
  createApiKeyForTenantById: (tenant_id: string, body?: CreateApiKeyRequestBody | undefined) => Promise<ApiKeyWithSecretResponse>;
391
428
  getApiKeysForTenantById: (tenant_id: string) => Promise<ApiKeyCollectionResponse>;
392
429
  deleteApiKeyForTenantById: (tenant_id: string, api_key_id: string) => Promise<Response>;
@@ -425,6 +462,7 @@ declare class ParraAPI {
425
462
  createIdentityForUserById: (user_id: string, body: CreateIdentityRequestBody) => Promise<IdentityResponse>;
426
463
  listIdentitiesForUserById: (user_id: string) => Promise<Array<IdentityResponse>>;
427
464
  getUserByProviderAndProviderUserId: (provider: string, provider_user_id: string) => Promise<UserResponse>;
465
+ checkAuthorization: (body?: CheckAuthorizationRequestBody | undefined) => Promise<CheckAuthorization>;
428
466
  getUserInfo: () => Promise<UserInfoResponse>;
429
467
  }
430
468
  export default ParraAPI;
package/dist/ParraAPI.js CHANGED
@@ -54,6 +54,16 @@ var ParraAPI = /** @class */ (function () {
54
54
  },
55
55
  });
56
56
  };
57
+ this.updateEntitlementsForCustomerById = function (customer_id) {
58
+ return _this.http.execute(_this.options.baseUrl + "/v1/customers/" + customer_id + "/entitlements", {
59
+ method: "post",
60
+ });
61
+ };
62
+ this.createBillingPortalSession = function (tenant_id) {
63
+ return _this.http.execute(_this.options.baseUrl + "/v1/tenants/" + tenant_id + "/billing-portal/sessions", {
64
+ method: "post",
65
+ });
66
+ };
57
67
  this.createCheckoutSession = function (body) {
58
68
  return _this.http.execute(_this.options.baseUrl + "/v1/checkout/sessions", {
59
69
  method: "post",
@@ -87,11 +97,6 @@ var ParraAPI = /** @class */ (function () {
87
97
  method: "get",
88
98
  });
89
99
  };
90
- this.getTenantByUserIdAndTenantId = function (user_id, tenant_id) {
91
- return _this.http.execute(_this.options.baseUrl + "/v1/users/" + user_id + "/tenants/" + tenant_id, {
92
- method: "get",
93
- });
94
- };
95
100
  this.createApiKeyForTenantById = function (tenant_id, body) {
96
101
  return _this.http.execute(_this.options.baseUrl + "/v1/tenants/" + tenant_id + "/api-keys", {
97
102
  method: "post",
@@ -236,6 +241,15 @@ var ParraAPI = /** @class */ (function () {
236
241
  method: "get",
237
242
  });
238
243
  };
244
+ this.checkAuthorization = function (body) {
245
+ return _this.http.execute(_this.options.baseUrl + "/v1/tenants/authorization/check", {
246
+ method: "post",
247
+ body: JSON.stringify(body),
248
+ headers: {
249
+ "content-type": "application/json",
250
+ },
251
+ });
252
+ };
239
253
  this.getUserInfo = function () {
240
254
  return _this.http.execute(_this.options.baseUrl + "/v1/user-info", {
241
255
  method: "get",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parra/parra-js-sdk",
3
- "version": "0.2.38",
3
+ "version": "0.2.42",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",