shred-api-client 1.5.4 → 1.7.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.
@@ -1,11 +1,12 @@
1
1
  import Context from "../model/Context";
2
- import { Product, SubscriptionAPISchema } from "../model/Subscription.schema";
2
+ import { Product, Subscription, SubscriptionAPISchema } from "../model/Subscription.schema";
3
3
  import Environment from "../model/Env";
4
4
  declare class SubscriptionAPI implements SubscriptionAPISchema {
5
5
  private env;
6
6
  private clientHTTP;
7
7
  constructor(env: Environment);
8
8
  getProduct(id: string, context?: Context): Promise<Product>;
9
+ getSubscription(context: Context): Promise<Subscription | null>;
9
10
  getProducts(ctx?: Context): Promise<Product[]>;
10
11
  createCheckout(planId: string | null, ctx: Context): Promise<string>;
11
12
  }
@@ -15,6 +15,11 @@ class SubscriptionAPI {
15
15
  const data = await this.clientHTTP.makeRequest(this.env, `${endpointInfo.uri}/${id}`, endpointInfo.method, null, context);
16
16
  return data;
17
17
  }
18
+ async getSubscription(context) {
19
+ const endpointInfo = Subscription_schema_1.SubscriptionEndpoints.GetActiveSubscription;
20
+ const data = await this.clientHTTP.makeRequest(this.env, endpointInfo.uri, endpointInfo.method, null, context);
21
+ return data;
22
+ }
18
23
  async getProducts(ctx) {
19
24
  const endpointInfo = Subscription_schema_1.SubscriptionEndpoints.GetProducts;
20
25
  const data = await this.clientHTTP.makeRequest(this.env, endpointInfo.uri, endpointInfo.method, null, ctx);
@@ -45,8 +45,7 @@ class UserAPI {
45
45
  }
46
46
  async getUserInfo(context) {
47
47
  const endpointData = User_schema_1.UserEndpoints.GetUserInfo;
48
- const data = await this.clientHTTP.makeRequest(this.env, endpointData.uri, endpointData.method, null, context, true //Use legacy api (old endpoints)
49
- );
48
+ const data = await this.clientHTTP.makeRequest(this.env, endpointData.uri, endpointData.method, null, context);
50
49
  if (!data.registered) {
51
50
  //Login by 3rd party and don't have register yet
52
51
  const enableEndpointData = User_schema_1.UserEndpoints.EnableUser;
@@ -1,5 +1,6 @@
1
1
  import Context from "./Context";
2
2
  interface SubscriptionAPISchema {
3
+ getSubscription: (context: Context) => Promise<Subscription | null>;
3
4
  getProduct: (id: string, context?: Context) => Promise<Product>;
4
5
  getProducts: (ctx?: Context) => Promise<Product[]>;
5
6
  createCheckout: (planId: string | null, ctx: Context) => Promise<string>;
@@ -9,6 +10,10 @@ declare const SubscriptionEndpoints: {
9
10
  uri: string;
10
11
  method: string;
11
12
  };
13
+ GetActiveSubscription: {
14
+ uri: string;
15
+ method: string;
16
+ };
12
17
  GetProducts: {
13
18
  uri: string;
14
19
  method: string;
@@ -6,6 +6,10 @@ const SubscriptionEndpoints = {
6
6
  uri: "/subscriptions/products/public/retrieve",
7
7
  method: "GET",
8
8
  },
9
+ GetActiveSubscription: {
10
+ uri: "/subscriptions/active",
11
+ method: "GET",
12
+ },
9
13
  GetProducts: {
10
14
  uri: "/subscriptions/products/public/list",
11
15
  method: "GET",
@@ -1,6 +1,4 @@
1
1
  import Context from "./Context";
2
- import { Subscription } from "./Subscription.schema";
3
- import { Tenant } from "./Tenant.schema";
4
2
  interface UserAPISchema {
5
3
  getUserInfo: (context: Context) => Promise<User>;
6
4
  isEmailAvaliable: (email: string) => Promise<boolean>;
@@ -64,19 +62,14 @@ type User = {
64
62
  name: string;
65
63
  email: string;
66
64
  fcmToken?: string;
67
- registeredAt: number;
68
65
  profession?: string;
69
66
  photoUrl?: string;
70
67
  preferences?: Preferences;
71
- tenant?: Tenant;
68
+ tenantId?: string;
69
+ editorId?: string;
72
70
  customerId: string;
73
- registered: boolean;
74
- subscription?: Subscription;
75
71
  invitationCode?: string;
76
- canCreateFreeProject: boolean;
77
- phone?: string;
78
- role?: Role;
79
- bindedAccounts?: string[];
80
- isEnabled?: boolean;
72
+ canCreateFreeProject?: boolean;
73
+ role: Role;
81
74
  };
82
75
  export { User, UserAPISchema, UserEndpoints, Role, System };
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.System = exports.Role = exports.UserEndpoints = void 0;
4
4
  const UserEndpoints = {
5
5
  GetUserInfo: {
6
- uri: "/api/user/info",
6
+ uri: "/accounts/user/info",
7
7
  method: "GET",
8
8
  },
9
9
  EnableUser: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shred-api-client",
3
- "version": "1.5.4",
3
+ "version": "1.7.0",
4
4
  "description": "API Client for Shred",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -15,12 +15,12 @@
15
15
  "author": "Marcus Cartágenes",
16
16
  "license": "ISC",
17
17
  "dependencies": {
18
- "@types/uuid": "^10.0.0",
19
18
  "axios": "1.7.2",
20
19
  "uuid": "^10.0.0",
21
20
  "winston": "^3.13.0"
22
21
  },
23
22
  "devDependencies": {
23
+ "@types/uuid": "^10.0.0",
24
24
  "@types/node": "^20.12.7",
25
25
  "tscpaths": "^0.0.9",
26
26
  "tsup": "^8.0.2",