shred-api-client 2.3.5-rc.0 → 2.3.5-rc.2

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