shred-api-client 2.0.6 → 2.0.8
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/Project.api.d.ts +4 -0
- package/dist/api/Project.api.js +13 -0
- package/dist/model/project/Project.api.d.ts +12 -0
- package/dist/model/project/Project.api.js +5 -0
- package/dist/model/project/Project.schema.d.ts +3 -0
- package/dist/model/project/Project.schema.js +1 -0
- package/package.json +3 -3
|
@@ -6,6 +6,10 @@ declare class ProjectAPI implements Project.IAPI {
|
|
|
6
6
|
private env;
|
|
7
7
|
private clientHTTP;
|
|
8
8
|
constructor(env: Environment);
|
|
9
|
+
permissions: {
|
|
10
|
+
isEligibleForFreeProject: (ctx: Context) => Promise<boolean>;
|
|
11
|
+
};
|
|
12
|
+
getNext(ctx: Context, userId: string): Promise<Project.Entity | null>;
|
|
9
13
|
getUserHistory(context: Context, userId: string): Promise<Core.APIResponse<Project.Entity>>;
|
|
10
14
|
find(context: Context, projectId: string): Promise<Project.Entity>;
|
|
11
15
|
create(context: Context, createData: Project.ProjectCreation): Promise<Project.Entity>;
|
package/dist/api/Project.api.js
CHANGED
|
@@ -31,9 +31,22 @@ const Project = __importStar(require("../model/project"));
|
|
|
31
31
|
const parseQuery_1 = require("../util/parseQuery");
|
|
32
32
|
class ProjectAPI {
|
|
33
33
|
constructor(env) {
|
|
34
|
+
this.permissions = {
|
|
35
|
+
isEligibleForFreeProject: async (ctx) => {
|
|
36
|
+
const endpointData = Project.Endpoints.IsEligibleForFreeProject;
|
|
37
|
+
const data = await this.clientHTTP.makeRequest(this.env, endpointData.uri, endpointData.method, null, ctx);
|
|
38
|
+
return data.canCreate;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
34
41
|
this.env = env;
|
|
35
42
|
this.clientHTTP = new HTTPClient_1.default();
|
|
36
43
|
}
|
|
44
|
+
async getNext(ctx, userId) {
|
|
45
|
+
const endpointData = Project.Endpoints.GetNext;
|
|
46
|
+
const endpoint = endpointData.uri.replace(":userId", userId);
|
|
47
|
+
const data = await this.clientHTTP.makeRequest(this.env, endpoint, endpointData.method, null, ctx);
|
|
48
|
+
return data;
|
|
49
|
+
}
|
|
37
50
|
async getUserHistory(context, userId) {
|
|
38
51
|
const endpointData = Project.Endpoints.GetUserHistory;
|
|
39
52
|
const endpoint = endpointData.uri.replace(":userId", userId);
|
|
@@ -13,13 +13,21 @@ export interface IAPI {
|
|
|
13
13
|
deny: (context: Context, projectId: string, denyFeedback: string, categories?: string[]) => Promise<boolean>;
|
|
14
14
|
unschedule: (context: Context, projectId: string) => Promise<boolean>;
|
|
15
15
|
rollback: (context: Context, projectId: string) => Promise<boolean>;
|
|
16
|
+
getNext: (context: Context, userId: string) => Promise<Project | null>;
|
|
16
17
|
getUserHistory: (context: Context, userId: string) => Promise<Core.APIResponse<Project>>;
|
|
18
|
+
permissions: {
|
|
19
|
+
isEligibleForFreeProject(context: Context): Promise<boolean>;
|
|
20
|
+
};
|
|
17
21
|
}
|
|
18
22
|
export declare const Endpoints: {
|
|
19
23
|
List: {
|
|
20
24
|
uri: string;
|
|
21
25
|
method: string;
|
|
22
26
|
};
|
|
27
|
+
GetNext: {
|
|
28
|
+
uri: string;
|
|
29
|
+
method: string;
|
|
30
|
+
};
|
|
23
31
|
CreateProject: {
|
|
24
32
|
uri: string;
|
|
25
33
|
method: string;
|
|
@@ -48,6 +56,10 @@ export declare const Endpoints: {
|
|
|
48
56
|
uri: string;
|
|
49
57
|
method: string;
|
|
50
58
|
};
|
|
59
|
+
IsEligibleForFreeProject: {
|
|
60
|
+
uri: string;
|
|
61
|
+
method: string;
|
|
62
|
+
};
|
|
51
63
|
Approve: {
|
|
52
64
|
uri: string;
|
|
53
65
|
method: string;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Endpoints = void 0;
|
|
4
4
|
exports.Endpoints = {
|
|
5
5
|
List: { uri: "/projects/list", method: "GET" },
|
|
6
|
+
GetNext: { uri: "/projects/:userId/next", method: "GET" },
|
|
6
7
|
CreateProject: { uri: "/projects/create", method: "POST" },
|
|
7
8
|
FindOne: { uri: `/projects/:projectId/`, method: "GET" },
|
|
8
9
|
GetGoals: { uri: `/projects/goals/list/`, method: "GET" },
|
|
@@ -13,6 +14,10 @@ exports.Endpoints = {
|
|
|
13
14
|
uri: "/projects/:projectId/sendToApproval/",
|
|
14
15
|
method: "PUT",
|
|
15
16
|
},
|
|
17
|
+
IsEligibleForFreeProject: {
|
|
18
|
+
uri: "/projects/free/allowed/",
|
|
19
|
+
method: "GET",
|
|
20
|
+
},
|
|
16
21
|
Approve: { uri: "/projects/:projectId/approve/", method: "POST" },
|
|
17
22
|
Unschedule: { uri: "/projects/:projectId/unschedule/", method: "POST" },
|
|
18
23
|
Rollback: { uri: "/projects/:projectId/rollback/", method: "POST" },
|
|
@@ -95,6 +95,7 @@ export declare const ProjectSchema: z.ZodObject<{
|
|
|
95
95
|
progress?: number | undefined;
|
|
96
96
|
}>, "many">>;
|
|
97
97
|
expirationTimestamp: z.ZodNumber;
|
|
98
|
+
isFree: z.ZodOptional<z.ZodBoolean>;
|
|
98
99
|
timeline: z.ZodArray<z.ZodObject<{
|
|
99
100
|
status: z.ZodNativeEnum<typeof Status>;
|
|
100
101
|
title: z.ZodString;
|
|
@@ -154,6 +155,7 @@ export declare const ProjectSchema: z.ZodObject<{
|
|
|
154
155
|
duration?: number | undefined;
|
|
155
156
|
progress?: number | undefined;
|
|
156
157
|
}[] | undefined;
|
|
158
|
+
isFree?: boolean | undefined;
|
|
157
159
|
}, {
|
|
158
160
|
id: string;
|
|
159
161
|
userId: string;
|
|
@@ -191,6 +193,7 @@ export declare const ProjectSchema: z.ZodObject<{
|
|
|
191
193
|
duration?: number | undefined;
|
|
192
194
|
progress?: number | undefined;
|
|
193
195
|
}[] | undefined;
|
|
196
|
+
isFree?: boolean | undefined;
|
|
194
197
|
}>;
|
|
195
198
|
export type ProjectCreation = Pick<Project, "title" | "instructions" | "captionStyle" | "assets">;
|
|
196
199
|
export type SendToApproval = {
|
|
@@ -52,6 +52,7 @@ exports.ProjectSchema = zod_1.z.object({
|
|
|
52
52
|
userId: zod_1.z.string(),
|
|
53
53
|
assets: zod_1.z.array(asset_1.AssetSchema).optional(),
|
|
54
54
|
expirationTimestamp: zod_1.z.number(),
|
|
55
|
+
isFree: zod_1.z.boolean().optional(),
|
|
55
56
|
timeline: zod_1.z.array(exports.TimelineItemSchema),
|
|
56
57
|
submitTimestamp: zod_1.z.number(),
|
|
57
58
|
tenantId: zod_1.z.string().optional(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shred-api-client",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "API Client for Shred",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"author": "Marcus Cartágenes",
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"axios": "1.
|
|
19
|
-
"uuid": "^
|
|
18
|
+
"axios": "1.9.0",
|
|
19
|
+
"uuid": "^11.1.0",
|
|
20
20
|
"winston": "^3.13.0",
|
|
21
21
|
"zod": "^3.24.3"
|
|
22
22
|
},
|