shred-api-client 2.0.8 → 2.0.10-rc.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.
Files changed (127) hide show
  1. package/dist/index.d.mts +2596 -0
  2. package/dist/index.d.ts +2596 -15
  3. package/dist/index.js +1773 -40
  4. package/dist/index.js.map +1 -0
  5. package/dist/index.mjs +1732 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +9 -6
  8. package/dist/api/AppConfig.api.d.ts +0 -9
  9. package/dist/api/AppConfig.api.js +0 -42
  10. package/dist/api/Email.api.d.ts +0 -10
  11. package/dist/api/Email.api.js +0 -42
  12. package/dist/api/Goal.api.d.ts +0 -10
  13. package/dist/api/Goal.api.js +0 -42
  14. package/dist/api/Note.api.d.ts +0 -13
  15. package/dist/api/Note.api.js +0 -60
  16. package/dist/api/Notification.api.d.ts +0 -18
  17. package/dist/api/Notification.api.js +0 -80
  18. package/dist/api/Project.api.d.ts +0 -26
  19. package/dist/api/Project.api.js +0 -122
  20. package/dist/api/Prompt.api.d.ts +0 -14
  21. package/dist/api/Prompt.api.js +0 -41
  22. package/dist/api/Subscription.api.d.ts +0 -18
  23. package/dist/api/Subscription.api.js +0 -69
  24. package/dist/api/Tenant.api.d.ts +0 -14
  25. package/dist/api/Tenant.api.js +0 -47
  26. package/dist/api/Track.api.d.ts +0 -9
  27. package/dist/api/Track.api.js +0 -19
  28. package/dist/api/User.api.d.ts +0 -25
  29. package/dist/api/User.api.js +0 -98
  30. package/dist/model/Api.d.ts +0 -26
  31. package/dist/model/Api.js +0 -33
  32. package/dist/model/Context.d.ts +0 -5
  33. package/dist/model/Context.js +0 -2
  34. package/dist/model/Env.d.ts +0 -2
  35. package/dist/model/Env.js +0 -2
  36. package/dist/model/app-config/AppConfig.api.d.ts +0 -9
  37. package/dist/model/app-config/AppConfig.api.js +0 -9
  38. package/dist/model/app-config/index.d.ts +0 -1
  39. package/dist/model/app-config/index.js +0 -17
  40. package/dist/model/asset/Asset.schema.d.ts +0 -43
  41. package/dist/model/asset/Asset.schema.js +0 -19
  42. package/dist/model/asset/index.d.ts +0 -2
  43. package/dist/model/asset/index.js +0 -5
  44. package/dist/model/core/APIResponse.d.ts +0 -6
  45. package/dist/model/core/APIResponse.js +0 -2
  46. package/dist/model/core/Query.d.ts +0 -15
  47. package/dist/model/core/Query.js +0 -2
  48. package/dist/model/core/index.d.ts +0 -2
  49. package/dist/model/core/index.js +0 -18
  50. package/dist/model/email/Email.api.d.ts +0 -11
  51. package/dist/model/email/Email.api.js +0 -9
  52. package/dist/model/email/Email.schema.d.ts +0 -15
  53. package/dist/model/email/Email.schema.js +0 -9
  54. package/dist/model/email/index.d.ts +0 -3
  55. package/dist/model/email/index.js +0 -20
  56. package/dist/model/exceptions/ConflictException.d.ts +0 -4
  57. package/dist/model/exceptions/ConflictException.js +0 -13
  58. package/dist/model/exceptions/ForbiddenException.d.ts +0 -4
  59. package/dist/model/exceptions/ForbiddenException.js +0 -13
  60. package/dist/model/exceptions/InvalidArgumentException.d.ts +0 -4
  61. package/dist/model/exceptions/InvalidArgumentException.js +0 -13
  62. package/dist/model/exceptions/ResourceNotFoundException.d.ts +0 -4
  63. package/dist/model/exceptions/ResourceNotFoundException.js +0 -13
  64. package/dist/model/exceptions/ShredException.d.ts +0 -4
  65. package/dist/model/exceptions/ShredException.js +0 -10
  66. package/dist/model/exceptions/UnauthorizedException.d.ts +0 -4
  67. package/dist/model/exceptions/UnauthorizedException.js +0 -13
  68. package/dist/model/exceptions/index.d.ts +0 -16
  69. package/dist/model/exceptions/index.js +0 -20
  70. package/dist/model/goal/Goal.api.d.ts +0 -11
  71. package/dist/model/goal/Goal.api.js +0 -6
  72. package/dist/model/goal/Goal.schema.d.ts +0 -154
  73. package/dist/model/goal/Goal.schema.js +0 -26
  74. package/dist/model/goal/index.d.ts +0 -3
  75. package/dist/model/goal/index.js +0 -22
  76. package/dist/model/note/Note.api.d.ts +0 -26
  77. package/dist/model/note/Note.api.js +0 -21
  78. package/dist/model/note/Note.schema.d.ts +0 -141
  79. package/dist/model/note/Note.schema.js +0 -30
  80. package/dist/model/note/index.d.ts +0 -3
  81. package/dist/model/note/index.js +0 -21
  82. package/dist/model/notification/Notification.api.d.ts +0 -47
  83. package/dist/model/notification/Notification.api.js +0 -13
  84. package/dist/model/notification/Notification.schema.d.ts +0 -454
  85. package/dist/model/notification/Notification.schema.js +0 -111
  86. package/dist/model/notification/index.d.ts +0 -3
  87. package/dist/model/notification/index.js +0 -30
  88. package/dist/model/project/Project.api.d.ts +0 -83
  89. package/dist/model/project/Project.api.js +0 -26
  90. package/dist/model/project/Project.schema.d.ts +0 -209
  91. package/dist/model/project/Project.schema.js +0 -60
  92. package/dist/model/project/index.d.ts +0 -3
  93. package/dist/model/project/index.js +0 -24
  94. package/dist/model/prompt/Prompt.api.d.ts +0 -31
  95. package/dist/model/prompt/Prompt.api.js +0 -25
  96. package/dist/model/prompt/Prompt.schema.d.ts +0 -165
  97. package/dist/model/prompt/Prompt.schema.js +0 -24
  98. package/dist/model/prompt/index.d.ts +0 -3
  99. package/dist/model/prompt/index.js +0 -22
  100. package/dist/model/subscription/Subscription.api.d.ts +0 -59
  101. package/dist/model/subscription/Subscription.api.js +0 -49
  102. package/dist/model/subscription/Subscription.schema.d.ts +0 -314
  103. package/dist/model/subscription/Subscription.schema.js +0 -53
  104. package/dist/model/subscription/index.d.ts +0 -3
  105. package/dist/model/subscription/index.js +0 -25
  106. package/dist/model/tenant/Tenant.api.d.ts +0 -35
  107. package/dist/model/tenant/Tenant.api.js +0 -29
  108. package/dist/model/tenant/Tenant.schema.d.ts +0 -342
  109. package/dist/model/tenant/Tenant.schema.js +0 -29
  110. package/dist/model/tenant/index.d.ts +0 -3
  111. package/dist/model/tenant/index.js +0 -21
  112. package/dist/model/track/Track.api.d.ts +0 -10
  113. package/dist/model/track/Track.api.js +0 -9
  114. package/dist/model/track/Track.schema.d.ts +0 -44
  115. package/dist/model/track/Track.schema.js +0 -14
  116. package/dist/model/track/index.d.ts +0 -3
  117. package/dist/model/track/index.js +0 -21
  118. package/dist/model/user/User.api.d.ts +0 -86
  119. package/dist/model/user/User.api.js +0 -21
  120. package/dist/model/user/User.schema.d.ts +0 -117
  121. package/dist/model/user/User.schema.js +0 -42
  122. package/dist/model/user/index.d.ts +0 -3
  123. package/dist/model/user/index.js +0 -23
  124. package/dist/util/HTTPClient.d.ts +0 -5
  125. package/dist/util/HTTPClient.js +0 -51
  126. package/dist/util/parseQuery.d.ts +0 -2
  127. package/dist/util/parseQuery.js +0 -25
package/dist/index.mjs ADDED
@@ -0,0 +1,1732 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/util/HTTPClient.ts
8
+ import axios, { isAxiosError } from "axios";
9
+ var HOSTS = {
10
+ prod: "https://api.shreditapp.com",
11
+ staging: "https://api.staging.shreditapp.com",
12
+ local: "https://api.staging.shreditapp.com"
13
+ };
14
+ var OLD_HOSTS = {
15
+ prod: "https://api.shredmedia.co",
16
+ staging: "https://api-staging.shredmedia.co",
17
+ local: "https://api-staging.shredmedia.co"
18
+ };
19
+ var HTTPClient = class {
20
+ async makeRequest(env, uri, method, data, context, useLegacyApi) {
21
+ const hostDict = useLegacyApi ? OLD_HOSTS : HOSTS;
22
+ const host = hostDict[env] || hostDict.staging;
23
+ const config = {
24
+ method,
25
+ url: host + uri,
26
+ headers: {
27
+ Authorization: context?.token && `Bearer ${context.token}`,
28
+ "X-Request-ID": context?.requestId && context.requestId || "",
29
+ "Content-Type": useLegacyApi ? "application/x-www-form-urlencoded" : "application/json"
30
+ }
31
+ };
32
+ if (method !== "GET" && data) {
33
+ config.data = data;
34
+ }
35
+ try {
36
+ const response = await axios(config);
37
+ return response.data;
38
+ } catch (error) {
39
+ if (isAxiosError(error)) {
40
+ const axiosError = error;
41
+ throw axiosError.response?.data || axiosError;
42
+ } else {
43
+ throw error;
44
+ }
45
+ }
46
+ }
47
+ };
48
+
49
+ // src/model/notification/index.ts
50
+ var notification_exports = {};
51
+ __export(notification_exports, {
52
+ CriteriaSchema: () => CriteriaSchema,
53
+ CriteriaType: () => CriteriaType,
54
+ Endpoints: () => Endpoints,
55
+ Frequency: () => Frequency,
56
+ HistorySchema: () => HistorySchema,
57
+ NotificationDetailSchema: () => NotificationDetailSchema,
58
+ NotificationItemSchema: () => NotificationItemSchema,
59
+ RecurrenceRuleSchema: () => RecurrenceRuleSchema,
60
+ Status: () => Status,
61
+ TransportType: () => TransportType,
62
+ TriggerSchema: () => TriggerSchema,
63
+ WeekDay: () => WeekDay
64
+ });
65
+
66
+ // src/model/notification/Notification.schema.ts
67
+ import { z } from "zod";
68
+ var Frequency = /* @__PURE__ */ ((Frequency2) => {
69
+ Frequency2["DAILY"] = "daily";
70
+ Frequency2["WEEKLY"] = "weekly";
71
+ Frequency2["MONTHLY"] = "monthly";
72
+ return Frequency2;
73
+ })(Frequency || {});
74
+ var WeekDay = /* @__PURE__ */ ((WeekDay2) => {
75
+ WeekDay2[WeekDay2["MONDAY"] = 1] = "MONDAY";
76
+ WeekDay2[WeekDay2["TUESDAY"] = 2] = "TUESDAY";
77
+ WeekDay2[WeekDay2["WEDNESDAY"] = 3] = "WEDNESDAY";
78
+ WeekDay2[WeekDay2["THURSDAY"] = 4] = "THURSDAY";
79
+ WeekDay2[WeekDay2["FRIDAY"] = 5] = "FRIDAY";
80
+ WeekDay2[WeekDay2["SATURDAY"] = 6] = "SATURDAY";
81
+ WeekDay2[WeekDay2["SUNDAY"] = 7] = "SUNDAY";
82
+ return WeekDay2;
83
+ })(WeekDay || {});
84
+ var CriteriaType = /* @__PURE__ */ ((CriteriaType2) => {
85
+ CriteriaType2["AllUsers"] = "allUsers";
86
+ CriteriaType2["NoProjects"] = "noProjects";
87
+ CriteriaType2["NoSubscription"] = "noSubscription";
88
+ CriteriaType2["UsersFromTier"] = "usersFromTier";
89
+ return CriteriaType2;
90
+ })(CriteriaType || {});
91
+ var TransportType = /* @__PURE__ */ ((TransportType2) => {
92
+ TransportType2["Push"] = "push";
93
+ TransportType2["Email"] = "email";
94
+ return TransportType2;
95
+ })(TransportType || {});
96
+ var Status = /* @__PURE__ */ ((Status3) => {
97
+ Status3["SCHEDULED"] = "scheduled";
98
+ Status3["RUNNING"] = "running";
99
+ Status3["COMPLETED"] = "completed";
100
+ Status3["FAILED"] = "failed";
101
+ Status3["PAUSED"] = "paused";
102
+ Status3["CANCELLED"] = "cancelled";
103
+ Status3["ACTIVE"] = "active";
104
+ Status3["EXPIRED"] = "expired";
105
+ return Status3;
106
+ })(Status || {});
107
+ var NotificationItemSchema = z.object({
108
+ id: z.string(),
109
+ userId: z.string(),
110
+ triggerId: z.string().optional(),
111
+ title: z.string(),
112
+ body: z.string(),
113
+ status: z.enum(["failed", "delivered", "deleted"]),
114
+ deliveredAt: z.number(),
115
+ openedAt: z.number().optional(),
116
+ deletedAt: z.number().optional(),
117
+ cta: z.object({ label: z.string(), url: z.string().url() }).optional(),
118
+ metadata: z.record(z.union([z.string(), z.number()])),
119
+ error: z.string().optional()
120
+ });
121
+ var NotificationDetailSchema = NotificationItemSchema.pick({
122
+ title: true,
123
+ body: true,
124
+ userId: true,
125
+ metadata: true
126
+ });
127
+ var CriteriaSchema = z.object({
128
+ type: z.nativeEnum(CriteriaType),
129
+ params: z.record(z.any())
130
+ });
131
+ var HistorySchema = z.object({
132
+ batchId: z.string(),
133
+ executedAt: z.number(),
134
+ timezone: z.string(),
135
+ status: z.enum(["success", "failed", "info", "warn"]),
136
+ users: z.object({
137
+ total: z.number(),
138
+ success: z.number(),
139
+ error: z.number()
140
+ }),
141
+ errorList: z.array(
142
+ z.object({
143
+ token: z.string(),
144
+ error: z.string()
145
+ })
146
+ ).optional(),
147
+ executionTimeDuration: z.number().optional()
148
+ });
149
+ var RecurrenceRuleSchema = z.object({
150
+ frequency: z.nativeEnum(Frequency),
151
+ interval: z.number(),
152
+ weekDays: z.array(z.nativeEnum(WeekDay)).optional(),
153
+ dayOfMonth: z.number().optional(),
154
+ endDate: z.string().optional(),
155
+ ocurrences: z.number().optional()
156
+ });
157
+ var TriggerSchema = z.object({
158
+ id: z.string(),
159
+ title: z.string(),
160
+ description: z.string(),
161
+ transportType: z.array(z.nativeEnum(TransportType)),
162
+ notification: NotificationDetailSchema,
163
+ history: z.array(HistorySchema).optional(),
164
+ status: z.nativeEnum(Status),
165
+ recurrence: RecurrenceRuleSchema.optional(),
166
+ timezone: z.string().nullable().optional(),
167
+ tenantIds: z.array(z.string()).optional(),
168
+ executionDate: z.string().optional(),
169
+ timeOfDay: z.string(),
170
+ criteria: CriteriaSchema,
171
+ nextExecution: z.number().optional(),
172
+ createdAt: z.number().optional(),
173
+ modified: z.number().optional()
174
+ });
175
+
176
+ // src/model/notification/Notification.api.ts
177
+ var Endpoints = {
178
+ Create: { uri: "/notifications/trigger/", method: "POST" },
179
+ List: { uri: "/notifications/trigger/list/", method: "GET" },
180
+ Update: { uri: "/notifications/trigger/:id/", method: "PUT" },
181
+ Delete: { uri: "/notifications/trigger/:id/", method: "DELETE" },
182
+ Push: { uri: "/notifications/push/", method: "POST" },
183
+ ListNotifications: { uri: "/notifications/list/", method: "GET" },
184
+ MarkAsRead: { uri: "/notifications/:id/read/", method: "PUT" },
185
+ ClearNotifications: { uri: "/notifications/clear/", method: "DELETE" }
186
+ };
187
+
188
+ // src/api/Notification.api.ts
189
+ var NotificationAPI = class {
190
+ constructor(env) {
191
+ this.env = env;
192
+ this.clientHTTP = new HTTPClient();
193
+ }
194
+ async clearNotifications(ctx) {
195
+ const endpointData = Endpoints.ClearNotifications;
196
+ const data = await this.clientHTTP.makeRequest(
197
+ this.env,
198
+ endpointData.uri,
199
+ endpointData.method,
200
+ null,
201
+ ctx
202
+ );
203
+ return data;
204
+ }
205
+ async markAsRead(ctx, id) {
206
+ const endpointData = Endpoints.MarkAsRead;
207
+ const endpoint = endpointData.uri.replace(":id", id);
208
+ const data = await this.clientHTTP.makeRequest(
209
+ this.env,
210
+ endpoint,
211
+ endpointData.method,
212
+ null,
213
+ ctx
214
+ );
215
+ return data;
216
+ }
217
+ async getNotifications(ctx) {
218
+ const endpointData = Endpoints.ListNotifications;
219
+ const data = await this.clientHTTP.makeRequest(
220
+ this.env,
221
+ endpointData.uri,
222
+ endpointData.method,
223
+ null,
224
+ ctx
225
+ );
226
+ return data;
227
+ }
228
+ async deleteTrigger(ctx, triggerId) {
229
+ const endpointData = Endpoints.Delete;
230
+ const endpoint = endpointData.uri.replace(":id", triggerId);
231
+ const data = await this.clientHTTP.makeRequest(
232
+ this.env,
233
+ endpoint,
234
+ endpointData.method,
235
+ null,
236
+ ctx
237
+ );
238
+ return data;
239
+ }
240
+ async updateTrigger(ctx, triggerId, t) {
241
+ const endpointData = Endpoints.Update;
242
+ const endpoint = endpointData.uri.replace(":id", triggerId);
243
+ const data = await this.clientHTTP.makeRequest(
244
+ this.env,
245
+ endpoint,
246
+ endpointData.method,
247
+ t,
248
+ ctx
249
+ );
250
+ return data;
251
+ }
252
+ async createTrigger(ctx, t) {
253
+ const endpointData = Endpoints.Create;
254
+ const data = await this.clientHTTP.makeRequest(
255
+ this.env,
256
+ endpointData.uri,
257
+ endpointData.method,
258
+ t,
259
+ ctx
260
+ );
261
+ return data;
262
+ }
263
+ async getTriggers(ctx) {
264
+ const endpointInfo = Endpoints.List;
265
+ const data = await this.clientHTTP.makeRequest(
266
+ this.env,
267
+ endpointInfo.uri,
268
+ endpointInfo.method,
269
+ null,
270
+ ctx
271
+ );
272
+ return data;
273
+ }
274
+ async push(ctx, notification) {
275
+ const endpointInfo = Endpoints.Push;
276
+ const data = await this.clientHTTP.makeRequest(
277
+ this.env,
278
+ endpointInfo.uri,
279
+ endpointInfo.method,
280
+ notification,
281
+ ctx
282
+ );
283
+ return data.success;
284
+ }
285
+ };
286
+ var Notification_api_default = NotificationAPI;
287
+
288
+ // src/api/Prompt.api.ts
289
+ var PromptAPI = class {
290
+ constructor(env) {
291
+ this.env = env;
292
+ this.clientHTTP = new HTTPClient();
293
+ }
294
+ async getPrompt(context) {
295
+ const endpointInfo = prompt_exports.Endpoints.GetPrompt;
296
+ const data = await this.clientHTTP.makeRequest(
297
+ this.env,
298
+ endpointInfo.uri,
299
+ endpointInfo.method,
300
+ null,
301
+ context
302
+ );
303
+ return data;
304
+ }
305
+ async getScripts(context) {
306
+ const endpointInfo = prompt_exports.Endpoints.ListScript;
307
+ const data = await this.clientHTTP.makeRequest(
308
+ this.env,
309
+ endpointInfo.uri,
310
+ endpointInfo.method,
311
+ null,
312
+ context
313
+ );
314
+ return data;
315
+ }
316
+ async updateScript(c, id, script) {
317
+ const endpointData = prompt_exports.Endpoints.UpdateScript;
318
+ const endpoint = endpointData.uri.replace(":id", id);
319
+ const data = await this.clientHTTP.makeRequest(
320
+ this.env,
321
+ endpoint,
322
+ endpointData.method,
323
+ { ...script },
324
+ c
325
+ );
326
+ return data;
327
+ }
328
+ async addScript(c, script) {
329
+ const endpointInfo = prompt_exports.Endpoints.AddScript;
330
+ const data = await this.clientHTTP.makeRequest(
331
+ this.env,
332
+ endpointInfo.uri,
333
+ endpointInfo.method,
334
+ { ...script },
335
+ c
336
+ );
337
+ return data;
338
+ }
339
+ async deleteScript(c, id) {
340
+ const endpointData = prompt_exports.Endpoints.DeleteScript;
341
+ const endpoint = endpointData.uri.replace(":id", id);
342
+ const data = await this.clientHTTP.makeRequest(
343
+ this.env,
344
+ endpoint,
345
+ endpointData.method,
346
+ null,
347
+ c
348
+ );
349
+ return data;
350
+ }
351
+ };
352
+ var Prompt_api_default = PromptAPI;
353
+
354
+ // src/api/Subscription.api.ts
355
+ var SubscriptionAPI = class {
356
+ constructor(env) {
357
+ this.env = env;
358
+ this.clientHTTP = new HTTPClient();
359
+ }
360
+ async updatePlan(ctx, planId) {
361
+ const endpointInfo = subscription_exports.Endpoints.UpdatePlan;
362
+ const data = await this.clientHTTP.makeRequest(
363
+ this.env,
364
+ endpointInfo.uri,
365
+ endpointInfo.method,
366
+ { planId },
367
+ ctx
368
+ );
369
+ return data;
370
+ }
371
+ async getProduct(id, context) {
372
+ const endpointInfo = subscription_exports.Endpoints.GetProduct;
373
+ const data = await this.clientHTTP.makeRequest(
374
+ this.env,
375
+ `${endpointInfo.uri}/${id}`,
376
+ endpointInfo.method,
377
+ null,
378
+ context
379
+ );
380
+ return data;
381
+ }
382
+ async getCharges(ctx) {
383
+ const endpointInfo = subscription_exports.Endpoints.GetCharges;
384
+ const data = await this.clientHTTP.makeRequest(
385
+ this.env,
386
+ `${endpointInfo.uri}`,
387
+ endpointInfo.method,
388
+ null,
389
+ ctx
390
+ );
391
+ return data;
392
+ }
393
+ async getSubscription(context, userId) {
394
+ const endpointInfo = subscription_exports.Endpoints.GetActiveSubscription;
395
+ let uri = endpointInfo.uri;
396
+ let method = endpointInfo.method;
397
+ if (userId) {
398
+ const endpointData = subscription_exports.Endpoints.GetUserActiveSubscription;
399
+ const endpoint = endpointData.uri.replace(":userId", userId);
400
+ uri = endpoint;
401
+ method = endpointData.method;
402
+ }
403
+ const data = await this.clientHTTP.makeRequest(
404
+ this.env,
405
+ uri,
406
+ method,
407
+ null,
408
+ context
409
+ );
410
+ return data;
411
+ }
412
+ async charge(ctx) {
413
+ const endpointInfo = subscription_exports.Endpoints.Charge;
414
+ const data = await this.clientHTTP.makeRequest(
415
+ this.env,
416
+ endpointInfo.uri,
417
+ endpointInfo.method,
418
+ null,
419
+ ctx
420
+ );
421
+ return data.success;
422
+ }
423
+ async pause(ctx) {
424
+ const endpointInfo = subscription_exports.Endpoints.Pause;
425
+ const data = await this.clientHTTP.makeRequest(
426
+ this.env,
427
+ endpointInfo.uri,
428
+ endpointInfo.method,
429
+ null,
430
+ ctx
431
+ );
432
+ return data;
433
+ }
434
+ async resume(ctx) {
435
+ const endpointInfo = subscription_exports.Endpoints.Resume;
436
+ const data = await this.clientHTTP.makeRequest(
437
+ this.env,
438
+ endpointInfo.uri,
439
+ endpointInfo.method,
440
+ null,
441
+ ctx
442
+ );
443
+ return data;
444
+ }
445
+ async getProducts(ctx) {
446
+ const endpointInfo = ctx ? subscription_exports.Endpoints.GetProductsByUser : subscription_exports.Endpoints.GetProducts;
447
+ const data = await this.clientHTTP.makeRequest(
448
+ this.env,
449
+ endpointInfo.uri,
450
+ endpointInfo.method,
451
+ null,
452
+ ctx
453
+ );
454
+ return data;
455
+ }
456
+ async createCheckout(planId, ctx) {
457
+ const endpointInfo = subscription_exports.Endpoints.Checkout;
458
+ const data = await this.clientHTTP.makeRequest(
459
+ this.env,
460
+ endpointInfo.uri,
461
+ endpointInfo.method,
462
+ { planId },
463
+ ctx
464
+ );
465
+ return data.url;
466
+ }
467
+ };
468
+ var Subscription_api_default = SubscriptionAPI;
469
+
470
+ // src/api/Tenant.api.ts
471
+ var TenantAPI = class {
472
+ constructor(env) {
473
+ this.env = env;
474
+ this.clientHTTP = new HTTPClient();
475
+ }
476
+ async getByInviteCode(inviteCode, context) {
477
+ const endpointInfo = tenant_exports.Endpoints.GetByInviteCode;
478
+ const data = await this.clientHTTP.makeRequest(
479
+ this.env,
480
+ `${endpointInfo.uri}/${inviteCode}`,
481
+ endpointInfo.method,
482
+ null,
483
+ context
484
+ );
485
+ return data;
486
+ }
487
+ async getTenant(context, tenantId) {
488
+ const endpointInfo = tenant_exports.Endpoints.GetTenant;
489
+ let uri = endpointInfo.uri;
490
+ let method = endpointInfo.method;
491
+ if (tenantId) {
492
+ const endpointData = tenant_exports.Endpoints.GetTenantById;
493
+ const endpoint = endpointData.uri.replace(":tenantId", tenantId);
494
+ uri = endpoint;
495
+ method = endpointData.method;
496
+ }
497
+ const data = await this.clientHTTP.makeRequest(
498
+ this.env,
499
+ uri,
500
+ method,
501
+ null,
502
+ context
503
+ );
504
+ return data;
505
+ }
506
+ async create(t, context) {
507
+ const endpointInfo = tenant_exports.Endpoints.CreateTenant;
508
+ const data = await this.clientHTTP.makeRequest(
509
+ this.env,
510
+ `${endpointInfo.uri}`,
511
+ endpointInfo.method,
512
+ { ...t },
513
+ context
514
+ );
515
+ return data;
516
+ }
517
+ async list(context) {
518
+ const endpointInfo = tenant_exports.Endpoints.ListAll;
519
+ const data = await this.clientHTTP.makeRequest(
520
+ this.env,
521
+ `${endpointInfo.uri}`,
522
+ endpointInfo.method,
523
+ null,
524
+ context
525
+ );
526
+ return data;
527
+ }
528
+ async update(tenantId, updateData, context) {
529
+ const endpointInfo = tenant_exports.Endpoints.UpdateTenant;
530
+ const data = await this.clientHTTP.makeRequest(
531
+ this.env,
532
+ `${endpointInfo.uri}`,
533
+ endpointInfo.method,
534
+ { tenantId, data: updateData },
535
+ context
536
+ );
537
+ return data;
538
+ }
539
+ };
540
+ var Tenant_api_default = TenantAPI;
541
+
542
+ // src/util/parseQuery.ts
543
+ var buildQueryString = (query) => {
544
+ const params = {};
545
+ if (query.perPage) {
546
+ params["perPage"] = [String(query.perPage)];
547
+ }
548
+ if (query.cursor !== void 0 && query.cursor !== null) {
549
+ params["cursor"] = [String(query.cursor)];
550
+ }
551
+ if (query.orderBy) {
552
+ params["orderBy"] = [
553
+ `${String(query.orderBy.field)}:${query.orderBy.direction}`
554
+ ];
555
+ }
556
+ if (query.wheres && query.wheres.length > 0) {
557
+ params["wheres"] = query.wheres.map(
558
+ (w) => `${String(w.field)}:${String(w.operation)}:${String(w.value)}`
559
+ );
560
+ }
561
+ const queryString = Object.entries(params).flatMap(
562
+ ([key, values]) => values.map((value) => `${key}=${encodeURIComponent(value)}`)
563
+ ).join("&");
564
+ return queryString ? `?${queryString}` : "";
565
+ };
566
+
567
+ // src/api/User.api.ts
568
+ var UserAPI = class {
569
+ constructor(env) {
570
+ this.env = env;
571
+ this.clientHTTP = new HTTPClient();
572
+ }
573
+ async search(ctx, query) {
574
+ const endpointData = user_exports.Endpoints.Search;
575
+ const qs = buildQueryString(query);
576
+ const data = await this.clientHTTP.makeRequest(
577
+ this.env,
578
+ `${endpointData.uri}${qs}`,
579
+ endpointData.method,
580
+ null,
581
+ ctx
582
+ );
583
+ return data;
584
+ }
585
+ async deleteAccount(ctx) {
586
+ const endpointData = user_exports.Endpoints.DeleteAccount;
587
+ const data = await this.clientHTTP.makeRequest(
588
+ this.env,
589
+ endpointData.uri,
590
+ endpointData.method,
591
+ null,
592
+ ctx
593
+ );
594
+ return data.success;
595
+ }
596
+ async createIntegrationToken(ctx) {
597
+ const endpointData = user_exports.Endpoints.CreateToken;
598
+ const data = await this.clientHTTP.makeRequest(
599
+ this.env,
600
+ `${endpointData.uri}`,
601
+ endpointData.method,
602
+ null,
603
+ ctx
604
+ );
605
+ return data.token;
606
+ }
607
+ async getIntegrationToken(ctx) {
608
+ const endpointData = user_exports.Endpoints.GetIntegrationToken;
609
+ const data = await this.clientHTTP.makeRequest(
610
+ this.env,
611
+ `${endpointData.uri}`,
612
+ endpointData.method,
613
+ null,
614
+ ctx
615
+ );
616
+ return data.token;
617
+ }
618
+ async sendValidationCode(email) {
619
+ const endpointData = user_exports.Endpoints.SendValidationCode;
620
+ const data = await this.clientHTTP.makeRequest(
621
+ this.env,
622
+ `${endpointData.uri}?email=${email}`,
623
+ endpointData.method
624
+ );
625
+ return data.success;
626
+ }
627
+ async changePassword(email, pass, passConfirm, code) {
628
+ const endpointData = user_exports.Endpoints.ChangePassword;
629
+ const data = await this.clientHTTP.makeRequest(
630
+ this.env,
631
+ endpointData.uri,
632
+ endpointData.method,
633
+ { email, pass, passConfirm, code }
634
+ );
635
+ return data.success;
636
+ }
637
+ async changeEmail(ctx, email, code) {
638
+ const endpointData = user_exports.Endpoints.ChangeEmail;
639
+ const data = await this.clientHTTP.makeRequest(
640
+ this.env,
641
+ endpointData.uri,
642
+ endpointData.method,
643
+ { email, code },
644
+ ctx
645
+ );
646
+ return data.success;
647
+ }
648
+ async confirmCode(email, code, keepCode) {
649
+ const endpointData = user_exports.Endpoints.ConfirmCode;
650
+ const data = await this.clientHTTP.makeRequest(
651
+ this.env,
652
+ `${endpointData.uri}?email=${email}&code=${code}&keepCode=${keepCode}`,
653
+ endpointData.method
654
+ );
655
+ return data.success;
656
+ }
657
+ async isEmailAvaliable(email) {
658
+ const endpointData = user_exports.Endpoints.IsEmailAvaliable;
659
+ const data = await this.clientHTTP.makeRequest(
660
+ this.env,
661
+ `${endpointData.uri}?email=${email}`,
662
+ endpointData.method
663
+ );
664
+ return data.isValid;
665
+ }
666
+ async update(context, update) {
667
+ const endpointData = user_exports.Endpoints.UpdateUser;
668
+ const data = await this.clientHTTP.makeRequest(
669
+ this.env,
670
+ `${endpointData.uri}`,
671
+ endpointData.method,
672
+ { ...update },
673
+ context
674
+ );
675
+ return data.isValid;
676
+ }
677
+ async getBindedUsers(context) {
678
+ const endpointData = user_exports.Endpoints.GetBindedUsers;
679
+ const data = await this.clientHTTP.makeRequest(
680
+ this.env,
681
+ `${endpointData.uri}`,
682
+ endpointData.method,
683
+ null,
684
+ context
685
+ );
686
+ return data;
687
+ }
688
+ async setup(context) {
689
+ const endpointData = user_exports.Endpoints.Setup;
690
+ const data = await this.clientHTTP.makeRequest(
691
+ this.env,
692
+ `${endpointData.uri}`,
693
+ endpointData.method,
694
+ null,
695
+ context
696
+ );
697
+ return data.success;
698
+ }
699
+ async authenticate(email, password, system) {
700
+ const endpointData = user_exports.Endpoints.Authenticate;
701
+ const data = await this.clientHTTP.makeRequest(
702
+ this.env,
703
+ `${endpointData.uri}`,
704
+ endpointData.method,
705
+ { system, email, password }
706
+ );
707
+ return data.token;
708
+ }
709
+ async createUser(email, name, password, passwordConfirmation, profession, invitationCode) {
710
+ const endpointData = user_exports.Endpoints.CreateUser;
711
+ const data = await this.clientHTTP.makeRequest(
712
+ this.env,
713
+ endpointData.uri,
714
+ endpointData.method,
715
+ {
716
+ email,
717
+ name,
718
+ password,
719
+ passwordConfirmation,
720
+ profession,
721
+ invitationCode
722
+ },
723
+ null
724
+ );
725
+ return data;
726
+ }
727
+ async getUserInfo(context) {
728
+ const endpointData = user_exports.Endpoints.GetUserInfo;
729
+ const data = await this.clientHTTP.makeRequest(
730
+ this.env,
731
+ endpointData.uri,
732
+ endpointData.method,
733
+ null,
734
+ context
735
+ );
736
+ return data;
737
+ }
738
+ };
739
+ var User_api_default = UserAPI;
740
+
741
+ // src/api/Track.api.ts
742
+ var TrackAPI = class {
743
+ constructor(env) {
744
+ this.env = env;
745
+ this.clientHTTP = new HTTPClient();
746
+ }
747
+ async send(t) {
748
+ const endpointInfo = track_exports.Endpoints.Track;
749
+ const data = await this.clientHTTP.makeRequest(
750
+ this.env,
751
+ `${endpointInfo.uri}`,
752
+ endpointInfo.method,
753
+ t
754
+ );
755
+ return data;
756
+ }
757
+ };
758
+ var Track_api_default = TrackAPI;
759
+
760
+ // src/model/email/index.ts
761
+ var email_exports = {};
762
+ __export(email_exports, {
763
+ EmailSchema: () => EmailSchema,
764
+ Endpoints: () => Endpoints2
765
+ });
766
+
767
+ // src/model/email/Email.schema.ts
768
+ import { z as z2 } from "zod";
769
+ var EmailSchema = z2.object({
770
+ to: z2.string().email().optional(),
771
+ subject: z2.string(),
772
+ body: z2.string()
773
+ });
774
+
775
+ // src/model/email/Email.api.ts
776
+ var Endpoints2 = {
777
+ SendEmail: {
778
+ uri: "/emails/public/send",
779
+ method: "POST"
780
+ }
781
+ };
782
+
783
+ // src/api/Email.api.ts
784
+ var EmailAPI = class {
785
+ constructor(env) {
786
+ this.env = env;
787
+ this.clientHTTP = new HTTPClient();
788
+ }
789
+ async send(email, ctx) {
790
+ const endpointInfo = Endpoints2.SendEmail;
791
+ const data = await this.clientHTTP.makeRequest(
792
+ this.env,
793
+ endpointInfo.uri,
794
+ endpointInfo.method,
795
+ email,
796
+ ctx
797
+ );
798
+ return data.result;
799
+ }
800
+ };
801
+ var Email_api_default = EmailAPI;
802
+
803
+ // src/model/project/index.ts
804
+ var project_exports = {};
805
+ __export(project_exports, {
806
+ CaptionStyle: () => CaptionStyle,
807
+ Endpoints: () => Endpoints3,
808
+ ProjectSchema: () => ProjectSchema,
809
+ Status: () => Status2,
810
+ Styles: () => Styles,
811
+ TimelineItemSchema: () => TimelineItemSchema
812
+ });
813
+
814
+ // src/model/project/Project.schema.ts
815
+ import { z as z4 } from "zod";
816
+
817
+ // src/model/asset/index.ts
818
+ var asset_exports = {};
819
+ __export(asset_exports, {
820
+ AssetSchema: () => AssetSchema
821
+ });
822
+
823
+ // src/model/asset/Asset.schema.ts
824
+ import { z as z3 } from "zod";
825
+ var AssetSchema = z3.object({
826
+ assetId: z3.string(),
827
+ fileName: z3.string(),
828
+ extension: z3.string(),
829
+ fileSize: z3.number(),
830
+ assetUrl: z3.string().url(),
831
+ thumbnailUrl: z3.string().url(),
832
+ type: z3.string(),
833
+ duration: z3.number().optional(),
834
+ progress: z3.number().optional(),
835
+ error: z3.string().optional(),
836
+ authorId: z3.string(),
837
+ uploadedAt: z3.number()
838
+ });
839
+
840
+ // src/model/project/Project.schema.ts
841
+ var Status2 = /* @__PURE__ */ ((Status3) => {
842
+ Status3[Status3["SUBMITTED"] = 0] = "SUBMITTED";
843
+ Status3[Status3["EDITING"] = 1] = "EDITING";
844
+ Status3[Status3["COMPLETED"] = 2] = "COMPLETED";
845
+ Status3[Status3["WAITING_APPROVE"] = 3] = "WAITING_APPROVE";
846
+ Status3[Status3["DENIED"] = 4] = "DENIED";
847
+ Status3[Status3["REVISIONING"] = 5] = "REVISIONING";
848
+ Status3[Status3["CANCELLED"] = 6] = "CANCELLED";
849
+ Status3[Status3["SCHEDULED"] = 7] = "SCHEDULED";
850
+ return Status3;
851
+ })(Status2 || {});
852
+ var CaptionStyle = /* @__PURE__ */ ((CaptionStyle2) => {
853
+ CaptionStyle2[CaptionStyle2["ONE_LINE"] = 1] = "ONE_LINE";
854
+ CaptionStyle2[CaptionStyle2["ONE_LINE_EMOJIS"] = 2] = "ONE_LINE_EMOJIS";
855
+ CaptionStyle2[CaptionStyle2["TWO_LINES"] = 5] = "TWO_LINES";
856
+ CaptionStyle2[CaptionStyle2["TWO_LINES_EMOJIS"] = 3] = "TWO_LINES_EMOJIS";
857
+ CaptionStyle2[CaptionStyle2["HOME_HIGHLIGHT"] = 4] = "HOME_HIGHLIGHT";
858
+ return CaptionStyle2;
859
+ })(CaptionStyle || {});
860
+ var StatusSchema = z4.nativeEnum(Status2);
861
+ var CaptionStyleStatus = z4.nativeEnum(CaptionStyle);
862
+ var Styles = [
863
+ { value: 1 /* ONE_LINE */, label: "One Line" },
864
+ { value: 2 /* ONE_LINE_EMOJIS */, label: "One Line + Emojis" },
865
+ { value: 5 /* TWO_LINES */, label: "Two Lines" },
866
+ { value: 3 /* TWO_LINES_EMOJIS */, label: "Two Lines + Emojis" },
867
+ { value: 4 /* HOME_HIGHLIGHT */, label: "Home Tour" }
868
+ ];
869
+ var TimelineItemSchema = z4.object({
870
+ status: z4.nativeEnum(Status2),
871
+ title: z4.string(),
872
+ description: z4.string(),
873
+ timestamp: z4.number(),
874
+ metadata: z4.record(z4.any())
875
+ });
876
+ var ProjectSchema = z4.object({
877
+ id: z4.string(),
878
+ title: z4.string(),
879
+ instructions: z4.string(),
880
+ submitMonth: z4.string(),
881
+ captionStyle: z4.nativeEnum(CaptionStyle),
882
+ finalVideoId: z4.string().optional(),
883
+ thumbnailUrl: z4.string().optional(),
884
+ modified: z4.number(),
885
+ captionSuggestion: z4.string().optional(),
886
+ editorId: z4.string(),
887
+ userId: z4.string(),
888
+ assets: z4.array(AssetSchema).optional(),
889
+ expirationTimestamp: z4.number(),
890
+ isFree: z4.boolean().optional(),
891
+ timeline: z4.array(TimelineItemSchema),
892
+ submitTimestamp: z4.number(),
893
+ tenantId: z4.string().optional(),
894
+ status: z4.nativeEnum(Status2)
895
+ });
896
+
897
+ // src/model/project/Project.api.ts
898
+ var Endpoints3 = {
899
+ List: { uri: "/projects/list", method: "GET" },
900
+ GetNext: { uri: "/projects/:userId/next", method: "GET" },
901
+ CreateProject: { uri: "/projects/create", method: "POST" },
902
+ FindOne: { uri: `/projects/:projectId/`, method: "GET" },
903
+ GetGoals: { uri: `/projects/goals/list/`, method: "GET" },
904
+ Review: { uri: "/projects/:projectId/review/", method: "POST" },
905
+ Cancel: { uri: "/projects/:projectId/cancel/", method: "DELETE" },
906
+ StartEdition: { uri: "/projects/:projectId/start/", method: "PUT" },
907
+ SendToApproval: {
908
+ uri: "/projects/:projectId/sendToApproval/",
909
+ method: "PUT"
910
+ },
911
+ IsEligibleForFreeProject: {
912
+ uri: "/projects/free/allowed/",
913
+ method: "GET"
914
+ },
915
+ Approve: { uri: "/projects/:projectId/approve/", method: "POST" },
916
+ Unschedule: { uri: "/projects/:projectId/unschedule/", method: "POST" },
917
+ Rollback: { uri: "/projects/:projectId/rollback/", method: "POST" },
918
+ Deny: { uri: "/projects/:projectId/deny/", method: "POST" },
919
+ GetUserHistory: { uri: "/projects/user/:userId/history/", method: "GET" }
920
+ };
921
+
922
+ // src/api/Project.api.ts
923
+ var ProjectAPI = class {
924
+ constructor(env) {
925
+ this.permissions = {
926
+ isEligibleForFreeProject: async (ctx) => {
927
+ const endpointData = Endpoints3.IsEligibleForFreeProject;
928
+ const data = await this.clientHTTP.makeRequest(
929
+ this.env,
930
+ endpointData.uri,
931
+ endpointData.method,
932
+ null,
933
+ ctx
934
+ );
935
+ return data.canCreate;
936
+ }
937
+ };
938
+ this.env = env;
939
+ this.clientHTTP = new HTTPClient();
940
+ }
941
+ async getNext(ctx, userId) {
942
+ const endpointData = Endpoints3.GetNext;
943
+ const endpoint = endpointData.uri.replace(":userId", userId);
944
+ const data = await this.clientHTTP.makeRequest(
945
+ this.env,
946
+ endpoint,
947
+ endpointData.method,
948
+ null,
949
+ ctx
950
+ );
951
+ return data;
952
+ }
953
+ async getUserHistory(context, userId) {
954
+ const endpointData = Endpoints3.GetUserHistory;
955
+ const endpoint = endpointData.uri.replace(":userId", userId);
956
+ const data = await this.clientHTTP.makeRequest(
957
+ this.env,
958
+ endpoint,
959
+ endpointData.method,
960
+ null,
961
+ context
962
+ );
963
+ return data;
964
+ }
965
+ async find(context, projectId) {
966
+ const endpointData = Endpoints3.FindOne;
967
+ const endpoint = endpointData.uri.replace(":projectId", projectId);
968
+ const data = await this.clientHTTP.makeRequest(
969
+ this.env,
970
+ endpoint,
971
+ endpointData.method,
972
+ null,
973
+ context
974
+ );
975
+ return data;
976
+ }
977
+ async create(context, createData) {
978
+ const endpointData = Endpoints3.CreateProject;
979
+ const data = await this.clientHTTP.makeRequest(
980
+ this.env,
981
+ endpointData.uri,
982
+ endpointData.method,
983
+ createData,
984
+ context
985
+ );
986
+ return data;
987
+ }
988
+ async review(ctx, pId, revision) {
989
+ const endpointData = Endpoints3.Review;
990
+ const endpoint = endpointData.uri.replace(":projectId", pId);
991
+ const data = await this.clientHTTP.makeRequest(
992
+ this.env,
993
+ endpoint,
994
+ endpointData.method,
995
+ { revision },
996
+ ctx
997
+ );
998
+ return data.success;
999
+ }
1000
+ async cancel(ctx, projectId) {
1001
+ const endpointData = Endpoints3.Cancel;
1002
+ const endpoint = endpointData.uri.replace(":projectId", projectId);
1003
+ const data = await this.clientHTTP.makeRequest(
1004
+ this.env,
1005
+ endpoint,
1006
+ endpointData.method,
1007
+ null,
1008
+ ctx
1009
+ );
1010
+ return data.success;
1011
+ }
1012
+ async list(context, query) {
1013
+ const endpointData = Endpoints3.List;
1014
+ const qs = buildQueryString(query);
1015
+ const data = await this.clientHTTP.makeRequest(
1016
+ this.env,
1017
+ `${endpointData.uri}${qs}`,
1018
+ endpointData.method,
1019
+ null,
1020
+ context
1021
+ );
1022
+ return data;
1023
+ }
1024
+ async deny(ctx, pId, denyFB, categories) {
1025
+ const endpointData = Endpoints3.Deny;
1026
+ const endpoint = endpointData.uri.replace(":projectId", pId);
1027
+ const data = await this.clientHTTP.makeRequest(
1028
+ this.env,
1029
+ endpoint,
1030
+ endpointData.method,
1031
+ { denyFeedback: denyFB, categories: categories || [] },
1032
+ ctx
1033
+ );
1034
+ return data.success;
1035
+ }
1036
+ async unschedule(context, projectId) {
1037
+ const endpointData = Endpoints3.Unschedule;
1038
+ const endpoint = endpointData.uri.replace(":projectId", projectId);
1039
+ const data = await this.clientHTTP.makeRequest(
1040
+ this.env,
1041
+ endpoint,
1042
+ endpointData.method,
1043
+ null,
1044
+ context
1045
+ );
1046
+ return data.success;
1047
+ }
1048
+ async rollback(context, projectId) {
1049
+ const endpointData = Endpoints3.Rollback;
1050
+ const endpoint = endpointData.uri.replace(":projectId", projectId);
1051
+ const data = await this.clientHTTP.makeRequest(
1052
+ this.env,
1053
+ endpoint,
1054
+ endpointData.method,
1055
+ null,
1056
+ context
1057
+ );
1058
+ return data.success;
1059
+ }
1060
+ async start(context, projectId) {
1061
+ const endpointData = Endpoints3.StartEdition;
1062
+ const endpoint = endpointData.uri.replace(":projectId", projectId);
1063
+ const data = await this.clientHTTP.makeRequest(
1064
+ this.env,
1065
+ endpoint,
1066
+ endpointData.method,
1067
+ null,
1068
+ context
1069
+ );
1070
+ return data.success;
1071
+ }
1072
+ async approve(ctx, pId, approve) {
1073
+ const endpointData = Endpoints3.Approve;
1074
+ const endpoint = endpointData.uri.replace(":projectId", pId);
1075
+ const data = await this.clientHTTP.makeRequest(
1076
+ this.env,
1077
+ endpoint,
1078
+ endpointData.method,
1079
+ approve,
1080
+ ctx
1081
+ );
1082
+ return data.success;
1083
+ }
1084
+ async sendToApproval(context, projectId, approval) {
1085
+ const endpointData = Endpoints3.SendToApproval;
1086
+ const endpoint = endpointData.uri.replace(":projectId", projectId);
1087
+ const data = await this.clientHTTP.makeRequest(
1088
+ this.env,
1089
+ endpoint,
1090
+ endpointData.method,
1091
+ approval,
1092
+ context
1093
+ );
1094
+ return data.success;
1095
+ }
1096
+ };
1097
+ var Project_api_default = ProjectAPI;
1098
+
1099
+ // src/model/goal/index.ts
1100
+ var goal_exports = {};
1101
+ __export(goal_exports, {
1102
+ DailyMilestoneSchema: () => DailyMilestoneSchema,
1103
+ Endpoints: () => Endpoints4,
1104
+ GoalSchema: () => GoalSchema,
1105
+ WeeklyMilestoneSchema: () => WeeklyMilestoneSchema
1106
+ });
1107
+
1108
+ // src/model/goal/Goal.schema.ts
1109
+ import { z as z5 } from "zod";
1110
+ var DailyMilestoneSchema = z5.object({
1111
+ id: z5.string(),
1112
+ date: z5.string(),
1113
+ target: z5.number(),
1114
+ progress: z5.number()
1115
+ });
1116
+ var WeeklyMilestoneSchema = z5.object({
1117
+ id: z5.string(),
1118
+ week: z5.string(),
1119
+ target: z5.number(),
1120
+ progress: z5.number(),
1121
+ dailyMilestones: z5.array(DailyMilestoneSchema)
1122
+ });
1123
+ var GoalSchema = z5.object({
1124
+ id: z5.string(),
1125
+ editorId: z5.string(),
1126
+ month: z5.string(),
1127
+ // ex: "2024-04"
1128
+ target: z5.number(),
1129
+ progress: z5.number(),
1130
+ createdAt: z5.number(),
1131
+ weeklyMilestones: z5.array(WeeklyMilestoneSchema)
1132
+ });
1133
+
1134
+ // src/model/goal/Goal.api.ts
1135
+ var Endpoints4 = {
1136
+ GetGoals: { uri: `/projects/goals/list/`, method: "GET" }
1137
+ };
1138
+
1139
+ // src/api/Goal.api.ts
1140
+ var GoalAPI = class {
1141
+ constructor(env) {
1142
+ this.env = env;
1143
+ this.clientHTTP = new HTTPClient();
1144
+ }
1145
+ async getGoals(context) {
1146
+ const endpointData = Endpoints4.GetGoals;
1147
+ const data = await this.clientHTTP.makeRequest(
1148
+ this.env,
1149
+ endpointData.uri,
1150
+ endpointData.method,
1151
+ null,
1152
+ context
1153
+ );
1154
+ return data;
1155
+ }
1156
+ };
1157
+ var Goal_api_default = GoalAPI;
1158
+
1159
+ // src/model/app-config/AppConfig.api.ts
1160
+ var Endpoints5 = {
1161
+ Version: {
1162
+ uri: "/app-config/public/version/latest",
1163
+ method: "GET"
1164
+ }
1165
+ };
1166
+
1167
+ // src/api/AppConfig.api.ts
1168
+ var AppConfigAPI = class {
1169
+ constructor(env) {
1170
+ this.env = env;
1171
+ this.clientHTTP = new HTTPClient();
1172
+ }
1173
+ async version() {
1174
+ const endpointInfo = Endpoints5.Version;
1175
+ const data = await this.clientHTTP.makeRequest(
1176
+ this.env,
1177
+ endpointInfo.uri,
1178
+ endpointInfo.method
1179
+ );
1180
+ return data.version;
1181
+ }
1182
+ };
1183
+ var AppConfig_api_default = AppConfigAPI;
1184
+
1185
+ // src/model/note/index.ts
1186
+ var note_exports = {};
1187
+ __export(note_exports, {
1188
+ Endpoints: () => Endpoints6,
1189
+ NoteHistorySchema: () => NoteHistorySchema,
1190
+ NoteSchema: () => NoteSchema
1191
+ });
1192
+
1193
+ // src/model/note/Note.schema.ts
1194
+ import { z as z6 } from "zod";
1195
+ var NoteHistorySchema = z6.object({
1196
+ type: z6.enum([
1197
+ "created",
1198
+ "updated",
1199
+ "deleted",
1200
+ "asset-added",
1201
+ "asset-removed"
1202
+ ]),
1203
+ actorEmail: z6.string().email(),
1204
+ timestamp: z6.number(),
1205
+ details: z6.string().optional()
1206
+ });
1207
+ var NoteSchema = z6.object({
1208
+ id: z6.string(),
1209
+ userId: z6.string(),
1210
+ authorEmail: z6.string().email(),
1211
+ assets: z6.array(AssetSchema),
1212
+ title: z6.string(),
1213
+ content: z6.string(),
1214
+ createdAt: z6.number(),
1215
+ modified: z6.number(),
1216
+ history: z6.array(NoteHistorySchema).optional()
1217
+ });
1218
+
1219
+ // src/model/note/Note.api.ts
1220
+ var Endpoints6 = {
1221
+ GetNotes: {
1222
+ uri: "/user-context/notes/user/:userId/",
1223
+ method: "GET"
1224
+ },
1225
+ AddNote: {
1226
+ uri: "/user-context/notes/",
1227
+ method: "PUT"
1228
+ },
1229
+ DeleteNote: {
1230
+ uri: "/user-context/notes/:id/",
1231
+ method: "DELETE"
1232
+ },
1233
+ UpdateNote: {
1234
+ uri: "/user-context/notes/:id/",
1235
+ method: "POST"
1236
+ }
1237
+ };
1238
+
1239
+ // src/api/Note.api.ts
1240
+ var NoteAPI = class {
1241
+ constructor(env) {
1242
+ this.env = env;
1243
+ this.clientHTTP = new HTTPClient();
1244
+ }
1245
+ async list(c, userId) {
1246
+ const endpointData = Endpoints6.GetNotes;
1247
+ const endpoint = endpointData.uri.replace(":userId", userId);
1248
+ const data = await this.clientHTTP.makeRequest(
1249
+ this.env,
1250
+ endpoint,
1251
+ endpointData.method,
1252
+ null,
1253
+ c
1254
+ );
1255
+ return data;
1256
+ }
1257
+ async add(c, note) {
1258
+ const endpointData = Endpoints6.AddNote;
1259
+ const data = await this.clientHTTP.makeRequest(
1260
+ this.env,
1261
+ endpointData.uri,
1262
+ endpointData.method,
1263
+ note,
1264
+ c
1265
+ );
1266
+ return data;
1267
+ }
1268
+ async update(c, id, toUpdate) {
1269
+ const endpointData = Endpoints6.UpdateNote;
1270
+ const endpoint = endpointData.uri.replace(":id", id);
1271
+ const data = await this.clientHTTP.makeRequest(
1272
+ this.env,
1273
+ endpoint,
1274
+ endpointData.method,
1275
+ toUpdate,
1276
+ c
1277
+ );
1278
+ return data;
1279
+ }
1280
+ async delete(c, id) {
1281
+ const endpointData = Endpoints6.DeleteNote;
1282
+ const endpoint = endpointData.uri.replace(":id", id);
1283
+ const data = await this.clientHTTP.makeRequest(
1284
+ this.env,
1285
+ endpoint,
1286
+ endpointData.method,
1287
+ null,
1288
+ c
1289
+ );
1290
+ return data;
1291
+ }
1292
+ };
1293
+ var Note_api_default = NoteAPI;
1294
+
1295
+ // src/model/Api.ts
1296
+ var ShredAPI = class {
1297
+ constructor(env) {
1298
+ this.user = new User_api_default(env);
1299
+ this.goal = new Goal_api_default(env);
1300
+ this.prompt = new Prompt_api_default(env);
1301
+ this.subscription = new Subscription_api_default(env);
1302
+ this.pushNotification = new Notification_api_default(env);
1303
+ this.email = new Email_api_default(env);
1304
+ this.tenant = new Tenant_api_default(env);
1305
+ this.project = new Project_api_default(env);
1306
+ this.app = new AppConfig_api_default(env);
1307
+ this.track = new Track_api_default(env);
1308
+ this.note = new Note_api_default(env);
1309
+ }
1310
+ };
1311
+
1312
+ // src/model/exceptions/index.ts
1313
+ var exceptions_exports = {};
1314
+ __export(exceptions_exports, {
1315
+ default: () => exceptions_default
1316
+ });
1317
+
1318
+ // src/model/exceptions/ShredException.ts
1319
+ var ShredException = class extends Error {
1320
+ constructor(message, status) {
1321
+ super(message);
1322
+ this.name = "ShredException";
1323
+ this.status = status;
1324
+ }
1325
+ };
1326
+
1327
+ // src/model/exceptions/ConflictException.ts
1328
+ var ConflictException = class extends ShredException {
1329
+ constructor(message) {
1330
+ super(message, 409);
1331
+ this.name = "ConflictException";
1332
+ }
1333
+ };
1334
+
1335
+ // src/model/exceptions/InvalidArgumentException.ts
1336
+ var InvalidArgumentException = class extends ShredException {
1337
+ constructor(message) {
1338
+ super(message, 400);
1339
+ this.name = "InvalidArgumentException";
1340
+ }
1341
+ };
1342
+
1343
+ // src/model/exceptions/ResourceNotFoundException.ts
1344
+ var ResourceNotFoundException = class extends ShredException {
1345
+ constructor(message) {
1346
+ super(message, 404);
1347
+ this.name = "ResourceNotFoundException";
1348
+ }
1349
+ };
1350
+
1351
+ // src/model/exceptions/UnauthorizedException.ts
1352
+ var UnauthorizedException = class extends ShredException {
1353
+ constructor(message) {
1354
+ super(message, 401);
1355
+ this.name = "UnauthorizedException";
1356
+ }
1357
+ };
1358
+
1359
+ // src/model/exceptions/ForbiddenException.ts
1360
+ var ForbiddenException = class extends ShredException {
1361
+ constructor(message) {
1362
+ super(message, 403);
1363
+ this.name = "ForbiddenException";
1364
+ }
1365
+ };
1366
+
1367
+ // src/model/exceptions/index.ts
1368
+ var Exceptions = {
1369
+ ConflictException,
1370
+ InvalidArgumentException,
1371
+ ResourceNotFoundException,
1372
+ ShredException,
1373
+ UnauthorizedException,
1374
+ ForbiddenException
1375
+ };
1376
+ var exceptions_default = Exceptions;
1377
+
1378
+ // src/model/prompt/index.ts
1379
+ var prompt_exports = {};
1380
+ __export(prompt_exports, {
1381
+ CategorySchema: () => CategorySchema,
1382
+ Endpoints: () => Endpoints7,
1383
+ PromptSchema: () => PromptSchema,
1384
+ ScriptSchema: () => ScriptSchema
1385
+ });
1386
+
1387
+ // src/model/prompt/Prompt.schema.ts
1388
+ import { z as z7 } from "zod";
1389
+ var ScriptSchema = z7.object({
1390
+ id: z7.string(),
1391
+ title: z7.string(),
1392
+ content: z7.string(),
1393
+ tags: z7.array(z7.string()).optional(),
1394
+ userId: z7.string().optional()
1395
+ });
1396
+ var CategorySchema = z7.object({
1397
+ id: z7.string(),
1398
+ title: z7.string(),
1399
+ pictureUrl: z7.string().url(),
1400
+ backgroundColor: z7.string(),
1401
+ active: z7.boolean(),
1402
+ scripts: z7.array(ScriptSchema)
1403
+ });
1404
+ var PromptSchema = z7.object({
1405
+ id: z7.string(),
1406
+ tenantId: z7.string(),
1407
+ categories: z7.array(CategorySchema)
1408
+ });
1409
+
1410
+ // src/model/prompt/Prompt.api.ts
1411
+ var Endpoints7 = {
1412
+ GetPrompt: {
1413
+ uri: "/prompts/getPrompt",
1414
+ method: "GET"
1415
+ },
1416
+ AddScript: {
1417
+ uri: "/prompts/script/new/",
1418
+ method: "POST"
1419
+ },
1420
+ DeleteScript: {
1421
+ uri: "/prompts/script/:id/delete/",
1422
+ method: "DELETE"
1423
+ },
1424
+ ListScript: {
1425
+ uri: "/prompts/script/list/",
1426
+ method: "GET"
1427
+ },
1428
+ UpdateScript: {
1429
+ uri: "/prompts/script/:id/update/",
1430
+ method: "PUT"
1431
+ }
1432
+ };
1433
+
1434
+ // src/model/tenant/index.ts
1435
+ var tenant_exports = {};
1436
+ __export(tenant_exports, {
1437
+ Endpoints: () => Endpoints8,
1438
+ PreferencesSchema: () => PreferencesSchema,
1439
+ TenantSchema: () => TenantSchema
1440
+ });
1441
+
1442
+ // src/model/tenant/Tenant.schema.ts
1443
+ import { z as z9 } from "zod";
1444
+
1445
+ // src/model/subscription/Subscription.schema.ts
1446
+ import { z as z8 } from "zod";
1447
+ var Type = /* @__PURE__ */ ((Type2) => {
1448
+ Type2[Type2["CUSTOMER_SUBSCRIPTION"] = 0] = "CUSTOMER_SUBSCRIPTION";
1449
+ Type2[Type2["TENANT_SUBSCRIPTION"] = 1] = "TENANT_SUBSCRIPTION";
1450
+ return Type2;
1451
+ })(Type || {});
1452
+ var SubscriptionTypeSchema = z8.nativeEnum(Type);
1453
+ var PlanSchema = z8.object({
1454
+ id: z8.string(),
1455
+ currency: z8.string(),
1456
+ price: z8.string(),
1457
+ interval: z8.string(),
1458
+ metadata: z8.record(z8.string()),
1459
+ subscriptionItemId: z8.string()
1460
+ });
1461
+ var DescriptionSchema = z8.object({
1462
+ description: z8.string(),
1463
+ subtitle: z8.string()
1464
+ });
1465
+ var ProductSchema = z8.object({
1466
+ id: z8.string(),
1467
+ name: z8.string(),
1468
+ descriptions: z8.array(DescriptionSchema),
1469
+ metadata: z8.any(),
1470
+ plans: z8.array(PlanSchema)
1471
+ });
1472
+ var ChargeSchema = z8.object({
1473
+ id: z8.number(),
1474
+ created: z8.number(),
1475
+ paid: z8.boolean(),
1476
+ receiptUrl: z8.string(),
1477
+ status: z8.string(),
1478
+ price: z8.string(),
1479
+ paymentType: z8.string(),
1480
+ last4: z8.string().optional(),
1481
+ brand: z8.string().optional()
1482
+ });
1483
+ var SubscriptionSchema = z8.object({
1484
+ id: z8.string(),
1485
+ status: z8.string(),
1486
+ startDate: z8.number().optional(),
1487
+ daysUntilDue: z8.number().optional(),
1488
+ renewAutomatically: z8.boolean().optional(),
1489
+ currentPeriodStart: z8.number().optional(),
1490
+ currentPeriodEnd: z8.number().optional(),
1491
+ paymentMethodId: z8.string().optional(),
1492
+ product: ProductSchema,
1493
+ type: z8.nativeEnum(Type).optional(),
1494
+ plan: PlanSchema.optional()
1495
+ });
1496
+
1497
+ // src/model/tenant/Tenant.schema.ts
1498
+ var PreferencesSchema = z9.object({
1499
+ iconUrl: z9.string().url(),
1500
+ logoUrl: z9.string().url(),
1501
+ primaryColor: z9.string(),
1502
+ secondaryColor: z9.string(),
1503
+ guidelinesUrl: z9.string().url().optional()
1504
+ });
1505
+ var TenantSchema = z9.object({
1506
+ id: z9.string(),
1507
+ name: z9.string(),
1508
+ isActive: z9.boolean(),
1509
+ isSubscriptionActive: z9.boolean(),
1510
+ preferences: PreferencesSchema,
1511
+ inviteCode: z9.string(),
1512
+ totalUsersAllowed: z9.number(),
1513
+ currentUsersSize: z9.number().optional(),
1514
+ chargeByEmail: z9.boolean(),
1515
+ defaultProductId: z9.string().optional(),
1516
+ defaultPlanId: z9.string().optional(),
1517
+ defaultCoupomCode: z9.string().optional(),
1518
+ allowedProducts: z9.array(z9.string()).optional(),
1519
+ useOwnScripts: z9.boolean().optional(),
1520
+ subscription: z9.optional(z9.lazy(() => SubscriptionSchema))
1521
+ });
1522
+
1523
+ // src/model/tenant/Tenant.api.ts
1524
+ var Endpoints8 = {
1525
+ GetByInviteCode: {
1526
+ uri: "/tenants/public/invitation/",
1527
+ method: "GET"
1528
+ },
1529
+ CreateTenant: {
1530
+ uri: "/tenants/create",
1531
+ method: "PUT"
1532
+ },
1533
+ GetTenant: {
1534
+ uri: "/tenants/me",
1535
+ method: "GET"
1536
+ },
1537
+ GetTenantById: {
1538
+ uri: "/tenants/:tenantId/find",
1539
+ method: "GET"
1540
+ },
1541
+ UpdateTenant: {
1542
+ uri: "/tenants/update",
1543
+ method: "POST"
1544
+ },
1545
+ ListAll: {
1546
+ uri: "/tenants/list",
1547
+ method: "GET"
1548
+ }
1549
+ };
1550
+
1551
+ // src/model/user/index.ts
1552
+ var user_exports = {};
1553
+ __export(user_exports, {
1554
+ Endpoints: () => Endpoints9,
1555
+ PreferencesSchema: () => PreferencesSchema2,
1556
+ Role: () => Role,
1557
+ System: () => System,
1558
+ UserSchema: () => UserSchema
1559
+ });
1560
+
1561
+ // src/model/user/User.schema.ts
1562
+ import { z as z10 } from "zod";
1563
+ var Role = /* @__PURE__ */ ((Role2) => {
1564
+ Role2["USER"] = "User";
1565
+ Role2["EDITOR"] = "Editor";
1566
+ Role2["QA"] = "QA";
1567
+ Role2["ADMIN"] = "ADMIN";
1568
+ Role2["SYSTEM"] = "SYSTEM";
1569
+ return Role2;
1570
+ })(Role || {});
1571
+ var System = /* @__PURE__ */ ((System2) => {
1572
+ System2["APP"] = "APP";
1573
+ System2["EDITOR"] = "EDITOR";
1574
+ System2["QA"] = "QA";
1575
+ System2["ADMIN"] = "ADMIN";
1576
+ return System2;
1577
+ })(System || {});
1578
+ var PreferencesSchema2 = z10.object({
1579
+ primaryColor: z10.string().optional(),
1580
+ secondaryColor: z10.string().optional(),
1581
+ facebookLink: z10.string().optional(),
1582
+ instagramLink: z10.string().optional(),
1583
+ bRoll: z10.boolean().optional(),
1584
+ logo: z10.string().optional()
1585
+ });
1586
+ var UserSchema = z10.object({
1587
+ id: z10.string(),
1588
+ name: z10.string(),
1589
+ email: z10.string().email(),
1590
+ fcmToken: z10.string().optional(),
1591
+ profession: z10.string().optional(),
1592
+ photoUrl: z10.string().optional(),
1593
+ preferences: PreferencesSchema2.optional(),
1594
+ tenantId: z10.string().optional(),
1595
+ editorId: z10.string().optional(),
1596
+ timezone: z10.string().optional(),
1597
+ experienceId: z10.string().optional(),
1598
+ customerId: z10.string(),
1599
+ role: z10.nativeEnum(Role)
1600
+ });
1601
+
1602
+ // src/model/user/User.api.ts
1603
+ var Endpoints9 = {
1604
+ ChangeEmail: { uri: "/accounts/user/changeEmail", method: "PUT" },
1605
+ GetUserInfo: { uri: "/accounts/user/info", method: "GET" },
1606
+ GetBindedUsers: { uri: "/accounts/binded/list", method: "GET" },
1607
+ EnableUser: { uri: "/api/user/register", method: "POST" },
1608
+ ChangePassword: { uri: "/accounts/public/changePassword/", method: "POST" },
1609
+ IsEmailAvaliable: { uri: "/accounts/public/email/avaliable", method: "GET" },
1610
+ GetIntegrationToken: { uri: "/accounts/user/getToken/", method: "GET" },
1611
+ CreateToken: { uri: "/accounts/user/createToken/", method: "POST" },
1612
+ ConfirmCode: { uri: "/accounts/public/email/validate", method: "POST" },
1613
+ DeleteAccount: { uri: "/accounts/user/delete/", method: "DELETE" },
1614
+ SendValidationCode: { uri: "/accounts/public/email/send", method: "POST" },
1615
+ Authenticate: { uri: "/accounts/public/login", method: "POST" },
1616
+ CreateUser: { uri: "/accounts/public/create", method: "POST" },
1617
+ UpdateUser: { uri: "/accounts/user/update", method: "PUT" },
1618
+ Setup: { uri: "/accounts/user/setup/", method: "POST" },
1619
+ Search: { uri: "/accounts/users/search/", method: "GET" }
1620
+ };
1621
+
1622
+ // src/model/subscription/index.ts
1623
+ var subscription_exports = {};
1624
+ __export(subscription_exports, {
1625
+ ChargeSchema: () => ChargeSchema,
1626
+ Endpoints: () => Endpoints10,
1627
+ PlanSchema: () => PlanSchema,
1628
+ ProductSchema: () => ProductSchema,
1629
+ SubscriptionSchema: () => SubscriptionSchema,
1630
+ SubscriptionTypeSchema: () => SubscriptionTypeSchema,
1631
+ Type: () => Type
1632
+ });
1633
+
1634
+ // src/model/subscription/Subscription.api.ts
1635
+ var Endpoints10 = {
1636
+ GetProduct: {
1637
+ uri: "/subscriptions/products/public/retrieve/",
1638
+ method: "GET"
1639
+ },
1640
+ GetActiveSubscription: {
1641
+ uri: "/subscriptions/active/",
1642
+ method: "GET"
1643
+ },
1644
+ GetCharges: {
1645
+ uri: "/subscriptions/payment/charge/list/",
1646
+ method: "GET"
1647
+ },
1648
+ GetUserActiveSubscription: {
1649
+ uri: "/subscriptions/:userId/find/",
1650
+ method: "GET"
1651
+ },
1652
+ GetProducts: {
1653
+ uri: "/subscriptions/products/public/list/",
1654
+ method: "GET"
1655
+ },
1656
+ GetProductsByUser: {
1657
+ uri: "/subscriptions/products/list/",
1658
+ method: "GET"
1659
+ },
1660
+ Checkout: {
1661
+ uri: "/subscriptions/payment/checkout/",
1662
+ method: "POST"
1663
+ },
1664
+ Charge: {
1665
+ uri: "/subscriptions/payment/charge/",
1666
+ method: "POST"
1667
+ },
1668
+ Pause: {
1669
+ uri: "/subscriptions/pause/",
1670
+ method: "PUT"
1671
+ },
1672
+ Resume: {
1673
+ uri: "/subscriptions/resume/",
1674
+ method: "PUT"
1675
+ },
1676
+ UpdatePlan: {
1677
+ uri: "/subscriptions/plan/update/",
1678
+ method: "PUT"
1679
+ }
1680
+ };
1681
+
1682
+ // src/model/track/index.ts
1683
+ var track_exports = {};
1684
+ __export(track_exports, {
1685
+ Endpoints: () => Endpoints11,
1686
+ TrackParamSchema: () => TrackParamSchema,
1687
+ TrackSchema: () => TrackSchema
1688
+ });
1689
+
1690
+ // src/model/track/Track.schema.ts
1691
+ import { z as z11 } from "zod";
1692
+ var TrackParamSchema = z11.object({
1693
+ name: z11.string(),
1694
+ value: z11.union([z11.string(), z11.number()])
1695
+ });
1696
+ var TrackSchema = z11.object({
1697
+ category: z11.string(),
1698
+ label: z11.string(),
1699
+ action: z11.string(),
1700
+ params: z11.array(TrackParamSchema).optional()
1701
+ });
1702
+
1703
+ // src/model/track/Track.api.ts
1704
+ var Endpoints11 = {
1705
+ Track: {
1706
+ uri: "/track/public/send/",
1707
+ method: "POST"
1708
+ }
1709
+ };
1710
+
1711
+ // src/model/core/index.ts
1712
+ var core_exports = {};
1713
+
1714
+ // src/index.ts
1715
+ var src_default = ShredAPI;
1716
+ export {
1717
+ asset_exports as Asset,
1718
+ core_exports as Core,
1719
+ email_exports as Email,
1720
+ exceptions_exports as Exceptions,
1721
+ goal_exports as Goal,
1722
+ note_exports as Note,
1723
+ notification_exports as Notification,
1724
+ project_exports as Project,
1725
+ prompt_exports as Prompt,
1726
+ subscription_exports as Subscription,
1727
+ tenant_exports as Tenant,
1728
+ track_exports as Track,
1729
+ user_exports as User,
1730
+ src_default as default
1731
+ };
1732
+ //# sourceMappingURL=index.mjs.map