shred-api-client 2.0.9 → 2.0.10-rc.1

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