shred-api-client 1.3.4 → 1.3.6
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/dist/api/Subscription.api.d.ts +1 -0
- package/dist/api/Subscription.api.js +5 -0
- package/dist/api/User.api.d.ts +2 -1
- package/dist/api/User.api.js +5 -0
- package/dist/model/Subscription.schema.d.ts +5 -0
- package/dist/model/Subscription.schema.js +4 -0
- package/dist/model/User.schema.d.ts +11 -1
- package/dist/model/User.schema.js +11 -1
- package/dist/model/exceptions/ForbiddenException.d.ts +4 -0
- package/dist/model/exceptions/ForbiddenException.js +13 -0
- package/dist/model/exceptions/UnauthorizedException.d.ts +4 -0
- package/dist/model/exceptions/UnauthorizedException.js +13 -0
- package/dist/model/exceptions/index.d.ts +4 -0
- package/dist/model/exceptions/index.js +4 -0
- package/dist/namespace.d.ts +2 -1
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ declare class SubscriptionAPI implements SubscriptionAPISchema {
|
|
|
5
5
|
private env;
|
|
6
6
|
private clientHTTP;
|
|
7
7
|
constructor(env: Environment);
|
|
8
|
+
getProduct(id: string): Promise<Product>;
|
|
8
9
|
getProducts(): Promise<Product[]>;
|
|
9
10
|
createCheckout(planId: string | null, ctx: Context): Promise<string>;
|
|
10
11
|
}
|
|
@@ -10,6 +10,11 @@ class SubscriptionAPI {
|
|
|
10
10
|
this.env = env;
|
|
11
11
|
this.clientHTTP = new HTTPClient_1.default();
|
|
12
12
|
}
|
|
13
|
+
async getProduct(id) {
|
|
14
|
+
const endpointInfo = Subscription_schema_1.SubscriptionEndpoints.GetProduct;
|
|
15
|
+
const data = await this.clientHTTP.makeRequest(this.env, `${endpointInfo.uri}/${id}`, endpointInfo.method, null);
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
13
18
|
async getProducts() {
|
|
14
19
|
const endpointInfo = Subscription_schema_1.SubscriptionEndpoints.GetProducts;
|
|
15
20
|
const data = await this.clientHTTP.makeRequest(this.env, endpointInfo.uri, endpointInfo.method, null);
|
package/dist/api/User.api.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import Context from "../model/Context";
|
|
2
|
-
import { User, UserAPISchema } from "../model/User.schema";
|
|
2
|
+
import { System, User, UserAPISchema } from "../model/User.schema";
|
|
3
3
|
import Environment from "../model/Env";
|
|
4
4
|
declare class UserAPI implements UserAPISchema {
|
|
5
5
|
private env;
|
|
6
6
|
private clientHTTP;
|
|
7
7
|
constructor(env: Environment);
|
|
8
8
|
isEmailAvaliable(email: string): Promise<boolean>;
|
|
9
|
+
authenticate(context: Context, system: System): Promise<string>;
|
|
9
10
|
createUser(email: string, name: string, newPassword: string, newPasswordConfirmation: string, profession: string | null, invitationCode: string | null): Promise<any>;
|
|
10
11
|
getUserInfo(context: Context): Promise<User>;
|
|
11
12
|
}
|
package/dist/api/User.api.js
CHANGED
|
@@ -15,6 +15,11 @@ class UserAPI {
|
|
|
15
15
|
const data = await this.clientHTTP.makeRequest(this.env, `${endpointData.uri}?email=${email}`, endpointData.method);
|
|
16
16
|
return data.isValid;
|
|
17
17
|
}
|
|
18
|
+
async authenticate(context, system) {
|
|
19
|
+
const endpointData = User_schema_1.UserEndpoints.Authenticate;
|
|
20
|
+
const data = await this.clientHTTP.makeRequest(this.env, `${endpointData.uri}`, endpointData.method, { system }, context);
|
|
21
|
+
return data.isValid;
|
|
22
|
+
}
|
|
18
23
|
async createUser(email, name, newPassword, newPasswordConfirmation, profession, invitationCode) {
|
|
19
24
|
const endpointData = User_schema_1.UserEndpoints.CreateUser;
|
|
20
25
|
const data = await this.clientHTTP.makeRequest(this.env, endpointData.uri, endpointData.method, {
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import Context from "./Context";
|
|
2
2
|
interface SubscriptionAPISchema {
|
|
3
|
+
getProduct: (id: string) => Promise<Product>;
|
|
3
4
|
getProducts: () => Promise<Product[]>;
|
|
4
5
|
createCheckout: (planId: string | null, ctx: Context) => Promise<string>;
|
|
5
6
|
}
|
|
6
7
|
declare const SubscriptionEndpoints: {
|
|
8
|
+
GetProduct: {
|
|
9
|
+
uri: string;
|
|
10
|
+
method: string;
|
|
11
|
+
};
|
|
7
12
|
GetProducts: {
|
|
8
13
|
uri: string;
|
|
9
14
|
method: string;
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SubscriptionEndpoints = exports.SubscriptionType = void 0;
|
|
4
4
|
const SubscriptionEndpoints = {
|
|
5
|
+
GetProduct: {
|
|
6
|
+
uri: "/subscriptions/products",
|
|
7
|
+
method: "GET",
|
|
8
|
+
},
|
|
5
9
|
GetProducts: {
|
|
6
10
|
uri: "/subscriptions/products/public/list",
|
|
7
11
|
method: "GET",
|
|
@@ -4,6 +4,7 @@ import { Tenant } from "./Tenant.schema";
|
|
|
4
4
|
interface UserAPISchema {
|
|
5
5
|
getUserInfo: (context: Context) => Promise<User>;
|
|
6
6
|
isEmailAvaliable: (email: string) => Promise<boolean>;
|
|
7
|
+
authenticate: (context: Context, system: System) => Promise<string>;
|
|
7
8
|
createUser: (email: string, name: string, newPassword: string, newPasswordConfirmation: string, profession: string | null, invitationCode: string | null) => Promise<User>;
|
|
8
9
|
}
|
|
9
10
|
declare const UserEndpoints: {
|
|
@@ -19,6 +20,10 @@ declare const UserEndpoints: {
|
|
|
19
20
|
uri: string;
|
|
20
21
|
method: string;
|
|
21
22
|
};
|
|
23
|
+
Authenticate: {
|
|
24
|
+
uri: string;
|
|
25
|
+
method: string;
|
|
26
|
+
};
|
|
22
27
|
CreateUser: {
|
|
23
28
|
uri: string;
|
|
24
29
|
method: string;
|
|
@@ -29,6 +34,11 @@ declare enum Role {
|
|
|
29
34
|
EDITOR = "Editor",
|
|
30
35
|
QA = "QA"
|
|
31
36
|
}
|
|
37
|
+
declare enum System {
|
|
38
|
+
APP = "APP",
|
|
39
|
+
EDITOR = "EDITOR",
|
|
40
|
+
QA = "QA"
|
|
41
|
+
}
|
|
32
42
|
type Preferences = {
|
|
33
43
|
primaryColor?: string;
|
|
34
44
|
secondaryColor?: string;
|
|
@@ -57,4 +67,4 @@ type User = {
|
|
|
57
67
|
bindedAccounts?: string[];
|
|
58
68
|
isEnabled?: boolean;
|
|
59
69
|
};
|
|
60
|
-
export { User, UserAPISchema, UserEndpoints, Role };
|
|
70
|
+
export { User, UserAPISchema, UserEndpoints, Role, System };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Role = exports.UserEndpoints = void 0;
|
|
3
|
+
exports.System = exports.Role = exports.UserEndpoints = void 0;
|
|
4
4
|
const UserEndpoints = {
|
|
5
5
|
GetUserInfo: {
|
|
6
6
|
uri: "/api/user/info",
|
|
@@ -14,6 +14,10 @@ const UserEndpoints = {
|
|
|
14
14
|
uri: "/accounts/public/email/avaliable",
|
|
15
15
|
method: "GET",
|
|
16
16
|
},
|
|
17
|
+
Authenticate: {
|
|
18
|
+
uri: "/accounts/authenticate",
|
|
19
|
+
method: "POST",
|
|
20
|
+
},
|
|
17
21
|
CreateUser: {
|
|
18
22
|
uri: "/api/user/public/createAccount",
|
|
19
23
|
method: "POST",
|
|
@@ -26,3 +30,9 @@ var Role;
|
|
|
26
30
|
Role["EDITOR"] = "Editor";
|
|
27
31
|
Role["QA"] = "QA";
|
|
28
32
|
})(Role || (exports.Role = Role = {}));
|
|
33
|
+
var System;
|
|
34
|
+
(function (System) {
|
|
35
|
+
System["APP"] = "APP";
|
|
36
|
+
System["EDITOR"] = "EDITOR";
|
|
37
|
+
System["QA"] = "QA";
|
|
38
|
+
})(System || (exports.System = System = {}));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ShredException_1 = __importDefault(require("./ShredException"));
|
|
7
|
+
class ForbiddenException extends ShredException_1.default {
|
|
8
|
+
constructor(message) {
|
|
9
|
+
super(message, 403);
|
|
10
|
+
this.name = "ForbiddenException";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.default = ForbiddenException;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ShredException_1 = __importDefault(require("./ShredException"));
|
|
7
|
+
class UnauthorizedException extends ShredException_1.default {
|
|
8
|
+
constructor(message) {
|
|
9
|
+
super(message, 400);
|
|
10
|
+
this.name = "UnauthorizedException";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.default = UnauthorizedException;
|
|
@@ -2,10 +2,14 @@ import ConflictException from "./ConflictException";
|
|
|
2
2
|
import InvalidArgumentException from "./InvalidArgumentException";
|
|
3
3
|
import ResourceNotFoundException from "./ResourceNotFoundException";
|
|
4
4
|
import ShredException from "./ShredException";
|
|
5
|
+
import UnauthorizedException from "./UnauthorizedException";
|
|
6
|
+
import ForbiddenException from "./ForbiddenException";
|
|
5
7
|
declare const _default: {
|
|
6
8
|
ConflictException: typeof ConflictException;
|
|
7
9
|
InvalidArgumentException: typeof InvalidArgumentException;
|
|
8
10
|
ResourceNotFoundException: typeof ResourceNotFoundException;
|
|
9
11
|
ShredException: typeof ShredException;
|
|
12
|
+
UnauthorizedException: typeof UnauthorizedException;
|
|
13
|
+
ForbiddenException: typeof ForbiddenException;
|
|
10
14
|
};
|
|
11
15
|
export default _default;
|
|
@@ -7,9 +7,13 @@ const ConflictException_1 = __importDefault(require("./ConflictException"));
|
|
|
7
7
|
const InvalidArgumentException_1 = __importDefault(require("./InvalidArgumentException"));
|
|
8
8
|
const ResourceNotFoundException_1 = __importDefault(require("./ResourceNotFoundException"));
|
|
9
9
|
const ShredException_1 = __importDefault(require("./ShredException"));
|
|
10
|
+
const UnauthorizedException_1 = __importDefault(require("./UnauthorizedException"));
|
|
11
|
+
const ForbiddenException_1 = __importDefault(require("./ForbiddenException"));
|
|
10
12
|
exports.default = {
|
|
11
13
|
ConflictException: ConflictException_1.default,
|
|
12
14
|
InvalidArgumentException: InvalidArgumentException_1.default,
|
|
13
15
|
ResourceNotFoundException: ResourceNotFoundException_1.default,
|
|
14
16
|
ShredException: ShredException_1.default,
|
|
17
|
+
UnauthorizedException: UnauthorizedException_1.default,
|
|
18
|
+
ForbiddenException: ForbiddenException_1.default,
|
|
15
19
|
};
|
package/dist/namespace.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Product as TProduct, Subscription as TSubscription } from "./model/Subscription.schema";
|
|
2
|
-
import { User as TUser, Role as TRole } from "./model/User.schema";
|
|
2
|
+
import { System as TSystem, User as TUser, Role as TRole } from "./model/User.schema";
|
|
3
3
|
import { Email as TEmail } from "./model/Email.schema";
|
|
4
4
|
import { Tenant as TTenant } from "./model/Tenant.schema";
|
|
5
5
|
import { Prompt as TPrompt, Script as TScript, Category as TCategory } from "./model/Prompt.schema";
|
|
@@ -12,6 +12,7 @@ export declare namespace Shred {
|
|
|
12
12
|
type Subscription = TSubscription;
|
|
13
13
|
type User = TUser;
|
|
14
14
|
type Email = TEmail;
|
|
15
|
+
type System = TSystem;
|
|
15
16
|
namespace PromptTypes {
|
|
16
17
|
type Prompt = TPrompt;
|
|
17
18
|
type Script = TScript;
|