shred-api-client 2.0.5 → 2.0.7

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.
@@ -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
+ getUserHistory(context: Context, userId: string): Promise<Core.APIResponse<Project.Entity>>;
9
13
  find(context: Context, projectId: string): Promise<Project.Entity>;
10
14
  create(context: Context, createData: Project.ProjectCreation): Promise<Project.Entity>;
11
15
  review(ctx: Context, pId: string, revision: string): Promise<boolean>;
@@ -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 getUserHistory(context, userId) {
45
+ const endpointData = Project.Endpoints.GetUserHistory;
46
+ const endpoint = endpointData.uri.replace(":userId", userId);
47
+ const data = await this.clientHTTP.makeRequest(this.env, endpoint, endpointData.method, null, context);
48
+ return data;
49
+ }
37
50
  async find(context, projectId) {
38
51
  const endpointData = Project.Endpoints.FindOne;
39
52
  const endpoint = endpointData.uri.replace(":projectId", projectId);
@@ -13,6 +13,10 @@ 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
+ getUserHistory: (context: Context, userId: string) => Promise<Core.APIResponse<Project>>;
17
+ permissions: {
18
+ isEligibleForFreeProject(context: Context): Promise<boolean>;
19
+ };
16
20
  }
17
21
  export declare const Endpoints: {
18
22
  List: {
@@ -47,6 +51,10 @@ export declare const Endpoints: {
47
51
  uri: string;
48
52
  method: string;
49
53
  };
54
+ IsEligibleForFreeProject: {
55
+ uri: string;
56
+ method: string;
57
+ };
50
58
  Approve: {
51
59
  uri: string;
52
60
  method: string;
@@ -63,4 +71,8 @@ export declare const Endpoints: {
63
71
  uri: string;
64
72
  method: string;
65
73
  };
74
+ GetUserHistory: {
75
+ uri: string;
76
+ method: string;
77
+ };
66
78
  };
@@ -13,8 +13,13 @@ exports.Endpoints = {
13
13
  uri: "/projects/:projectId/sendToApproval/",
14
14
  method: "PUT",
15
15
  },
16
+ IsEligibleForFreeProject: {
17
+ uri: "/projects/free/allowed/",
18
+ method: "GET",
19
+ },
16
20
  Approve: { uri: "/projects/:projectId/approve/", method: "POST" },
17
21
  Unschedule: { uri: "/projects/:projectId/unschedule/", method: "POST" },
18
22
  Rollback: { uri: "/projects/:projectId/rollback/", method: "POST" },
19
23
  Deny: { uri: "/projects/:projectId/deny/", method: "POST" },
24
+ GetUserHistory: { uri: "/projects/user/:userId/history/", method: "GET" },
20
25
  };
@@ -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.5",
3
+ "version": "2.0.7",
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.7.2",
19
- "uuid": "^10.0.0",
18
+ "axios": "1.9.0",
19
+ "uuid": "^11.1.0",
20
20
  "winston": "^3.13.0",
21
21
  "zod": "^3.24.3"
22
22
  },