@purpleschool/gptbot 0.13.21 → 0.14.1-stage-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.
Files changed (174) hide show
  1. package/api/controllers/http/agents/agent-dialog.ts +0 -11
  2. package/api/controllers/http/agents/agent-lead-form.ts +0 -2
  3. package/api/controllers/http/agents/agent-lead.ts +0 -1
  4. package/api/controllers/http/agents/agent-template.ts +0 -4
  5. package/api/controllers/http/agents/agent-tool.ts +1 -2
  6. package/api/controllers/http/agents/agent.ts +3 -0
  7. package/api/controllers/http/agents/index.ts +0 -1
  8. package/api/controllers/http/b2b-compatible.ts +14 -0
  9. package/api/controllers/http/b2b-usage-log.ts +5 -0
  10. package/api/controllers/http/index.ts +2 -2
  11. package/api/routes.ts +19 -38
  12. package/build/api/controllers/http/agents/agent-dialog.js +0 -7
  13. package/build/api/controllers/http/agents/agent-lead-form.js +0 -2
  14. package/build/api/controllers/http/agents/agent-lead.js +0 -1
  15. package/build/api/controllers/http/agents/agent-template.js +0 -4
  16. package/build/api/controllers/http/agents/agent-tool.js +1 -2
  17. package/build/api/controllers/http/agents/agent.js +2 -0
  18. package/build/api/controllers/http/agents/index.js +0 -1
  19. package/build/api/controllers/http/b2b-compatible.js +15 -0
  20. package/build/api/controllers/http/b2b-usage-log.js +7 -0
  21. package/build/api/controllers/http/index.js +2 -2
  22. package/build/api/routes.js +16 -22
  23. package/build/commands/agents/agent-dialog/find-agent-dialogs.command.js +0 -1
  24. package/build/commands/agents/agent-dialog/index.js +0 -5
  25. package/build/commands/agents/agent-dialog/send-cabinet-message.command.js +4 -4
  26. package/build/commands/agents/agent-lead/find-agent-leads.command.js +4 -2
  27. package/build/commands/agents/agent-template/index.js +0 -1
  28. package/build/commands/agents/agent-tool/find-agent-tools-catalog.command.js +0 -2
  29. package/build/commands/agents/agent-tool/find-agent-tools.command.js +0 -2
  30. package/build/commands/agents/agents/index.js +0 -1
  31. package/build/commands/ai-studio/canvas-tool/index.js +0 -1
  32. package/build/commands/b2b/send-text-request.command.js +8 -1
  33. package/build/commands/b2b-compatible/anthropic-files.command.js +21 -0
  34. package/build/commands/b2b-compatible/anthropic-messages.command.js +217 -0
  35. package/build/commands/b2b-compatible/anthropic-models.command.js +26 -0
  36. package/build/commands/b2b-compatible/common.schemas.js +46 -0
  37. package/build/commands/{ai-studio/canvas-tool/var-gen → b2b-compatible}/index.js +7 -3
  38. package/build/commands/b2b-compatible/openai-files.command.js +26 -0
  39. package/build/commands/b2b-compatible/openai-models.command.js +24 -0
  40. package/build/commands/b2b-compatible/openai-responses.command.js +171 -0
  41. package/build/commands/b2b-usage-log/get-b2b-usage-statistics.command.js +111 -0
  42. package/build/{constants/photo-studio/enums → commands/b2b-usage-log}/index.js +1 -1
  43. package/build/commands/index.js +2 -1
  44. package/build/constants/b2b/enums/b2b-debit-status.enum.js +9 -0
  45. package/build/constants/b2b/enums/b2b-endpoint-family.enum.js +9 -0
  46. package/build/constants/b2b/enums/b2b-statistics-granularity.enum.js +8 -0
  47. package/build/constants/b2b/enums/b2b-statistics-period.enum.js +13 -0
  48. package/build/constants/b2b/enums/b2b-usage-operation.enum.js +8 -0
  49. package/build/constants/b2b/enums/b2b-usage-spend-component.enum.js +12 -0
  50. package/build/constants/b2b/enums/b2b-usage-status.enum.js +8 -0
  51. package/build/{models/photo-studio → constants/b2b/enums}/index.js +7 -4
  52. package/build/constants/index.js +1 -1
  53. package/build/models/agents/index.js +0 -2
  54. package/build/models/b2b/b2b-usage-statistics.schema.js +69 -0
  55. package/build/models/b2b/index.js +1 -0
  56. package/build/models/canvas-node.schema.js +2 -2
  57. package/build/models/file.schema.js +1 -7
  58. package/build/models/index.js +0 -1
  59. package/build/models/tools/image-generation/image-generation-job.schema.js +0 -3
  60. package/commands/agents/agent-dialog/find-agent-dialogs.command.ts +0 -1
  61. package/commands/agents/agent-dialog/index.ts +0 -5
  62. package/commands/agents/agent-dialog/send-cabinet-message.command.ts +10 -18
  63. package/commands/agents/agent-lead/find-agent-leads.command.ts +4 -2
  64. package/commands/agents/agent-template/index.ts +0 -1
  65. package/commands/agents/agent-tool/find-agent-tools-catalog.command.ts +0 -2
  66. package/commands/agents/agent-tool/find-agent-tools.command.ts +0 -2
  67. package/commands/agents/agents/index.ts +0 -1
  68. package/commands/ai-studio/canvas-tool/index.ts +0 -1
  69. package/commands/b2b/send-text-request.command.ts +10 -1
  70. package/commands/b2b-compatible/anthropic-files.command.ts +29 -0
  71. package/commands/b2b-compatible/anthropic-messages.command.ts +244 -0
  72. package/commands/b2b-compatible/anthropic-models.command.ts +31 -0
  73. package/commands/b2b-compatible/common.schemas.ts +55 -0
  74. package/commands/b2b-compatible/index.ts +7 -0
  75. package/commands/b2b-compatible/openai-files.command.ts +37 -0
  76. package/commands/b2b-compatible/openai-models.command.ts +29 -0
  77. package/commands/b2b-compatible/openai-responses.command.ts +191 -0
  78. package/commands/b2b-usage-log/get-b2b-usage-statistics.command.ts +128 -0
  79. package/commands/b2b-usage-log/index.ts +1 -0
  80. package/commands/index.ts +2 -1
  81. package/constants/b2b/enums/b2b-debit-status.enum.ts +5 -0
  82. package/constants/b2b/enums/b2b-endpoint-family.enum.ts +5 -0
  83. package/constants/b2b/enums/b2b-statistics-granularity.enum.ts +4 -0
  84. package/constants/b2b/enums/b2b-statistics-period.enum.ts +9 -0
  85. package/constants/b2b/enums/b2b-usage-operation.enum.ts +4 -0
  86. package/constants/b2b/enums/b2b-usage-spend-component.enum.ts +8 -0
  87. package/constants/b2b/enums/b2b-usage-status.enum.ts +4 -0
  88. package/constants/b2b/enums/index.ts +7 -0
  89. package/constants/index.ts +1 -1
  90. package/models/agents/index.ts +0 -2
  91. package/models/b2b/b2b-usage-statistics.schema.ts +81 -0
  92. package/models/b2b/index.ts +1 -0
  93. package/models/canvas-node.schema.ts +2 -2
  94. package/models/file.schema.ts +0 -8
  95. package/models/index.ts +0 -1
  96. package/models/tools/image-generation/image-generation-job.schema.ts +0 -3
  97. package/package.json +1 -1
  98. package/api/controllers/http/agents/agent-statistics.ts +0 -5
  99. package/api/controllers/http/canvas-var-generation.ts +0 -7
  100. package/api/controllers/http/photo-studio.ts +0 -21
  101. package/build/api/controllers/http/agents/agent-statistics.js +0 -7
  102. package/build/api/controllers/http/canvas-var-generation.js +0 -9
  103. package/build/api/controllers/http/photo-studio.js +0 -21
  104. package/build/commands/agents/agent-dialog/get-cabinet-config.command.js +0 -12
  105. package/build/commands/agents/agent-dialog/get-cabinet-price-preview.command.js +0 -28
  106. package/build/commands/agents/agent-dialog/get-dialog-context-length.command.js +0 -30
  107. package/build/commands/agents/agent-dialog/rename-agent-dialog.command.js +0 -17
  108. package/build/commands/agents/agent-dialog/stop-cabinet-stream.command.js +0 -15
  109. package/build/commands/agents/agent-template/get-agent-template-instructions-by-template.command.js +0 -14
  110. package/build/commands/agents/agents/get-agent-statistics.command.js +0 -20
  111. package/build/commands/ai-studio/canvas-tool/var-gen/generate-variables.command.js +0 -18
  112. package/build/commands/ai-studio/canvas-tool/var-gen/get-var-gen-config.command.js +0 -11
  113. package/build/commands/ai-studio/canvas-tool/var-gen/get-var-gen-price.command.js +0 -18
  114. package/build/commands/photo-studio/add-photo-studio-checkpoint.command.js +0 -17
  115. package/build/commands/photo-studio/clear-photo-studio-checkpoints.command.js +0 -12
  116. package/build/commands/photo-studio/create-photo-studio-canvas.command.js +0 -15
  117. package/build/commands/photo-studio/delete-photo-studio-canvas.command.js +0 -11
  118. package/build/commands/photo-studio/delete-photo-studio-checkpoint.command.js +0 -14
  119. package/build/commands/photo-studio/execute-photo-studio-action.command.js +0 -47
  120. package/build/commands/photo-studio/find-photo-studio-canvas-by-uuid.query.js +0 -12
  121. package/build/commands/photo-studio/find-photo-studio-canvases.query.js +0 -18
  122. package/build/commands/photo-studio/find-photo-studio-checkpoints.query.js +0 -12
  123. package/build/commands/photo-studio/find-photo-studio-job-by-id.query.js +0 -32
  124. package/build/commands/photo-studio/find-photo-studio-jobs.query.js +0 -18
  125. package/build/commands/photo-studio/get-photo-studio-actions.query.js +0 -11
  126. package/build/commands/photo-studio/index.js +0 -31
  127. package/build/commands/photo-studio/save-photo-studio-canvas.command.js +0 -18
  128. package/build/commands/photo-studio/update-photo-studio-canvas.command.js +0 -15
  129. package/build/commands/photo-studio/update-photo-studio-checkpoint.command.js +0 -19
  130. package/build/constants/photo-studio/enums/photo-studio-checkpoint-action-type.enum.js +0 -11
  131. package/build/models/agents/agent-statistics.schema.js +0 -33
  132. package/build/models/agents/message-attachment.schema.js +0 -21
  133. package/build/models/photo-studio/photo-studio-action.schema.js +0 -17
  134. package/build/models/photo-studio/photo-studio-checkpoint.schema.js +0 -21
  135. package/build/models/photo-studio/photo-studio-image-node.schema.js +0 -19
  136. package/build/models/photo-studio/photo-studio.schema.js +0 -15
  137. package/commands/agents/agent-dialog/get-cabinet-config.command.ts +0 -11
  138. package/commands/agents/agent-dialog/get-cabinet-price-preview.command.ts +0 -30
  139. package/commands/agents/agent-dialog/get-dialog-context-length.command.ts +0 -33
  140. package/commands/agents/agent-dialog/rename-agent-dialog.command.ts +0 -19
  141. package/commands/agents/agent-dialog/stop-cabinet-stream.command.ts +0 -15
  142. package/commands/agents/agent-template/get-agent-template-instructions-by-template.command.ts +0 -14
  143. package/commands/agents/agents/get-agent-statistics.command.ts +0 -28
  144. package/commands/ai-studio/canvas-tool/var-gen/generate-variables.command.ts +0 -20
  145. package/commands/ai-studio/canvas-tool/var-gen/get-var-gen-config.command.ts +0 -9
  146. package/commands/ai-studio/canvas-tool/var-gen/get-var-gen-price.command.ts +0 -18
  147. package/commands/ai-studio/canvas-tool/var-gen/index.ts +0 -3
  148. package/commands/photo-studio/add-photo-studio-checkpoint.command.ts +0 -23
  149. package/commands/photo-studio/clear-photo-studio-checkpoints.command.ts +0 -12
  150. package/commands/photo-studio/create-photo-studio-canvas.command.ts +0 -16
  151. package/commands/photo-studio/delete-photo-studio-canvas.command.ts +0 -11
  152. package/commands/photo-studio/delete-photo-studio-checkpoint.command.ts +0 -14
  153. package/commands/photo-studio/execute-photo-studio-action.command.ts +0 -49
  154. package/commands/photo-studio/find-photo-studio-canvas-by-uuid.query.ts +0 -12
  155. package/commands/photo-studio/find-photo-studio-canvases.query.ts +0 -20
  156. package/commands/photo-studio/find-photo-studio-checkpoints.query.ts +0 -12
  157. package/commands/photo-studio/find-photo-studio-job-by-id.query.ts +0 -36
  158. package/commands/photo-studio/find-photo-studio-jobs.query.ts +0 -20
  159. package/commands/photo-studio/get-photo-studio-actions.query.ts +0 -10
  160. package/commands/photo-studio/index.ts +0 -15
  161. package/commands/photo-studio/save-photo-studio-canvas.command.ts +0 -24
  162. package/commands/photo-studio/update-photo-studio-canvas.command.ts +0 -17
  163. package/commands/photo-studio/update-photo-studio-checkpoint.command.ts +0 -25
  164. package/constants/photo-studio/enums/index.ts +0 -1
  165. package/constants/photo-studio/enums/photo-studio-checkpoint-action-type.enum.ts +0 -7
  166. package/models/agents/agent-statistics.schema.ts +0 -38
  167. package/models/agents/message-attachment.schema.ts +0 -22
  168. package/models/photo-studio/index.ts +0 -4
  169. package/models/photo-studio/photo-studio-action.schema.ts +0 -18
  170. package/models/photo-studio/photo-studio-checkpoint.schema.ts +0 -22
  171. package/models/photo-studio/photo-studio-image-node.schema.ts +0 -22
  172. package/models/photo-studio/photo-studio.schema.ts +0 -16
  173. /package/build/constants/{photo-studio → b2b}/index.js +0 -0
  174. /package/constants/{photo-studio → b2b}/index.ts +0 -0
@@ -0,0 +1,128 @@
1
+ import { z } from 'zod';
2
+ import { B2B_STATISTICS_PERIOD } from '../../constants';
3
+ import { B2bUsageStatisticsSchema } from '../../models/b2b';
4
+
5
+ const DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
6
+ const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;
7
+
8
+ const DateOnlySchema = z
9
+ .string()
10
+ .regex(DATE_ONLY_PATTERN)
11
+ .refine(
12
+ (value) => {
13
+ const [year, month, day] = value.split('-').map(Number);
14
+ const date = new Date(Date.UTC(year, month - 1, day));
15
+
16
+ return (
17
+ date.getUTCFullYear() === year &&
18
+ date.getUTCMonth() === month - 1 &&
19
+ date.getUTCDate() === day
20
+ );
21
+ },
22
+ { message: 'Invalid calendar date' },
23
+ );
24
+
25
+ const formatLocalDate = (date: Date): string => {
26
+ const year = date.getFullYear();
27
+ const month = String(date.getMonth() + 1).padStart(2, '0');
28
+ const day = String(date.getDate()).padStart(2, '0');
29
+
30
+ return `${year}-${month}-${day}`;
31
+ };
32
+
33
+ const toUtcCalendarTimestamp = (value: string): number => {
34
+ const [year, month, day] = value.split('-').map(Number);
35
+ return Date.UTC(year, month - 1, day);
36
+ };
37
+
38
+ export namespace GetB2bUsageStatisticsCommand {
39
+ export const RequestQuerySchema = z
40
+ .object({
41
+ period: z.nativeEnum(B2B_STATISTICS_PERIOD).default(B2B_STATISTICS_PERIOD.THIRTY_DAYS),
42
+ dateFrom: DateOnlySchema.optional(),
43
+ dateTo: DateOnlySchema.optional(),
44
+ apiKeyId: z.string().uuid().optional(),
45
+ })
46
+ .superRefine((query, context) => {
47
+ const isCustom = query.period === B2B_STATISTICS_PERIOD.CUSTOM;
48
+
49
+ if (!isCustom) {
50
+ if (query.dateFrom !== undefined) {
51
+ context.addIssue({
52
+ code: z.ZodIssueCode.custom,
53
+ path: ['dateFrom'],
54
+ message: 'dateFrom is only allowed for custom period',
55
+ });
56
+ }
57
+ if (query.dateTo !== undefined) {
58
+ context.addIssue({
59
+ code: z.ZodIssueCode.custom,
60
+ path: ['dateTo'],
61
+ message: 'dateTo is only allowed for custom period',
62
+ });
63
+ }
64
+ return;
65
+ }
66
+
67
+ if (query.dateFrom === undefined) {
68
+ context.addIssue({
69
+ code: z.ZodIssueCode.custom,
70
+ path: ['dateFrom'],
71
+ message: 'dateFrom is required for custom period',
72
+ });
73
+ }
74
+ if (query.dateTo === undefined) {
75
+ context.addIssue({
76
+ code: z.ZodIssueCode.custom,
77
+ path: ['dateTo'],
78
+ message: 'dateTo is required for custom period',
79
+ });
80
+ }
81
+ if (query.dateFrom === undefined || query.dateTo === undefined) {
82
+ return;
83
+ }
84
+
85
+ const today = formatLocalDate(new Date());
86
+ if (query.dateFrom > today) {
87
+ context.addIssue({
88
+ code: z.ZodIssueCode.custom,
89
+ path: ['dateFrom'],
90
+ message: 'dateFrom cannot be in the future',
91
+ });
92
+ }
93
+ if (query.dateTo > today) {
94
+ context.addIssue({
95
+ code: z.ZodIssueCode.custom,
96
+ path: ['dateTo'],
97
+ message: 'dateTo cannot be in the future',
98
+ });
99
+ }
100
+ if (query.dateFrom > query.dateTo) {
101
+ context.addIssue({
102
+ code: z.ZodIssueCode.custom,
103
+ path: ['dateTo'],
104
+ message: 'dateTo must be on or after dateFrom',
105
+ });
106
+ return;
107
+ }
108
+
109
+ const inclusiveDays =
110
+ (toUtcCalendarTimestamp(query.dateTo) - toUtcCalendarTimestamp(query.dateFrom)) /
111
+ MILLISECONDS_PER_DAY +
112
+ 1;
113
+ if (inclusiveDays > 90) {
114
+ context.addIssue({
115
+ code: z.ZodIssueCode.custom,
116
+ path: ['dateTo'],
117
+ message: 'Custom period cannot exceed 90 calendar days',
118
+ });
119
+ }
120
+ });
121
+
122
+ export const ResponseSchema = z.object({
123
+ data: B2bUsageStatisticsSchema,
124
+ });
125
+
126
+ export type RequestQuery = z.infer<typeof RequestQuerySchema>;
127
+ export type Response = z.infer<typeof ResponseSchema>;
128
+ }
@@ -0,0 +1 @@
1
+ export * from './get-b2b-usage-statistics.command';
package/commands/index.ts CHANGED
@@ -21,7 +21,6 @@ export * from './midjourney';
21
21
  export * from './page';
22
22
  export * from './order';
23
23
  export * from './payment';
24
- export * from './photo-studio';
25
24
  export * from './product';
26
25
  export * from './question';
27
26
  export * from './referral';
@@ -50,6 +49,8 @@ export * from './cabinet';
50
49
  export * from './webmaster';
51
50
  export * from './webmaster-click';
52
51
  export * from './b2b';
52
+ export * from './b2b-usage-log';
53
+ export * from './b2b-compatible';
53
54
  export * from './community';
54
55
  export * from './user-profile';
55
56
  export * from './team-account';
@@ -0,0 +1,5 @@
1
+ export enum B2B_DEBIT_STATUS {
2
+ NOT_APPLICABLE = 'not_applicable',
3
+ SUCCESS = 'success',
4
+ FAILED = 'failed',
5
+ }
@@ -0,0 +1,5 @@
1
+ export enum B2B_ENDPOINT_FAMILY {
2
+ RUGPT = 'rugpt',
3
+ OPENAI = 'openai',
4
+ ANTHROPIC = 'anthropic',
5
+ }
@@ -0,0 +1,4 @@
1
+ export enum B2B_STATISTICS_GRANULARITY {
2
+ HOUR = 'hour',
3
+ DAY = 'day',
4
+ }
@@ -0,0 +1,9 @@
1
+ export enum B2B_STATISTICS_PERIOD {
2
+ TODAY = 'today',
3
+ SEVEN_DAYS = '7_days',
4
+ THIRTY_DAYS = '30_days',
5
+ NINETY_DAYS = '90_days',
6
+ CURRENT_MONTH = 'current_month',
7
+ PREVIOUS_MONTH = 'previous_month',
8
+ CUSTOM = 'custom',
9
+ }
@@ -0,0 +1,4 @@
1
+ export enum B2B_USAGE_OPERATION {
2
+ TEXT_GENERATION = 'text_generation',
3
+ FILE_UPLOAD = 'file_upload',
4
+ }
@@ -0,0 +1,8 @@
1
+ export enum B2B_USAGE_SPEND_COMPONENT {
2
+ INPUT = 'input',
3
+ OUTPUT = 'output',
4
+ CACHE_READ = 'cache_read',
5
+ CACHE_WRITE = 'cache_write',
6
+ WEB_SEARCH = 'web_search',
7
+ VISION = 'vision',
8
+ }
@@ -0,0 +1,4 @@
1
+ export enum B2B_USAGE_STATUS {
2
+ SUCCESS = 'success',
3
+ ERROR = 'error',
4
+ }
@@ -0,0 +1,7 @@
1
+ export * from './b2b-debit-status.enum';
2
+ export * from './b2b-endpoint-family.enum';
3
+ export * from './b2b-statistics-granularity.enum';
4
+ export * from './b2b-statistics-period.enum';
5
+ export * from './b2b-usage-operation.enum';
6
+ export * from './b2b-usage-spend-component.enum';
7
+ export * from './b2b-usage-status.enum';
@@ -1,4 +1,5 @@
1
1
  export * from './ai-model';
2
+ export * from './b2b';
2
3
  export * from './api-key';
3
4
  export * from './agents';
4
5
  export * from './blog';
@@ -18,7 +19,6 @@ export * from './order';
18
19
  export * from './page';
19
20
  export * from './payment';
20
21
  export * from './presentation';
21
- export * from './photo-studio';
22
22
  export * from './product';
23
23
  export * from './referral';
24
24
  export * from './roles';
@@ -22,6 +22,4 @@ export * from './agent-document-find-result.schema';
22
22
  export * from './agent-document-chunk.schema';
23
23
  export * from './agent.schema';
24
24
  export * from './agent-aggregate.schema';
25
- export * from './agent-statistics.schema';
26
25
  export * from './channel.schema';
27
- export * from './message-attachment.schema';
@@ -0,0 +1,81 @@
1
+ import { z } from 'zod';
2
+ import {
3
+ API_KEY_STATUS,
4
+ B2B_STATISTICS_GRANULARITY,
5
+ B2B_STATISTICS_PERIOD,
6
+ B2B_USAGE_SPEND_COMPONENT,
7
+ } from '../../constants';
8
+ import { IconVariantsSchema } from '../icon-variants.schema';
9
+
10
+ const NonNegativeNumberSchema = z.number().finite().nonnegative();
11
+ const PercentageSchema = z.number().finite().min(0).max(100);
12
+ const ChangePercentageSchema = z.number().finite().nullable();
13
+
14
+ export const B2bUsageStatisticsAppliedFilterSchema = z.object({
15
+ period: z.nativeEnum(B2B_STATISTICS_PERIOD),
16
+ dateFrom: z.string().datetime({ offset: true }),
17
+ dateTo: z.string().datetime({ offset: true }),
18
+ apiKeyId: z.string().uuid().nullable(),
19
+ granularity: z.nativeEnum(B2B_STATISTICS_GRANULARITY),
20
+ });
21
+
22
+ export const B2bUsageStatisticsSummarySchema = z.object({
23
+ totalSpent: NonNegativeNumberSchema.int(),
24
+ totalRequests: NonNegativeNumberSchema.int(),
25
+ averageCost: NonNegativeNumberSchema,
26
+ activeKeys: NonNegativeNumberSchema.int(),
27
+ totalKeys: NonNegativeNumberSchema.int(),
28
+ changes: z.object({
29
+ totalSpentPercent: ChangePercentageSchema,
30
+ totalRequestsPercent: ChangePercentageSchema,
31
+ averageCostPercent: ChangePercentageSchema,
32
+ activeKeysPercent: ChangePercentageSchema,
33
+ }),
34
+ });
35
+
36
+ export const B2bUsageStatisticsGraphPointSchema = z.object({
37
+ startAt: z.string().datetime({ offset: true }),
38
+ endAt: z.string().datetime({ offset: true }),
39
+ label: z.string(),
40
+ spent: NonNegativeNumberSchema,
41
+ requests: NonNegativeNumberSchema.int(),
42
+ });
43
+
44
+ export const B2bUsageStatisticsKeySchema = z.object({
45
+ apiKeyId: z.string().uuid(),
46
+ title: z.string(),
47
+ status: z.nativeEnum(API_KEY_STATUS),
48
+ isRevoked: z.boolean(),
49
+ isSelected: z.boolean(),
50
+ requests: NonNegativeNumberSchema.int(),
51
+ spent: NonNegativeNumberSchema,
52
+ sharePercent: PercentageSchema,
53
+ });
54
+
55
+ export const B2bUsageStatisticsModelSchema = z.object({
56
+ aiModelId: z.string().uuid().nullable(),
57
+ model: z.string(),
58
+ title: z.string(),
59
+ iconVariants: IconVariantsSchema.nullable(),
60
+ requests: NonNegativeNumberSchema.int(),
61
+ spent: NonNegativeNumberSchema,
62
+ sharePercent: PercentageSchema,
63
+ });
64
+
65
+ export const B2bUsageStatisticsSpendStructureItemSchema = z.object({
66
+ component: z.nativeEnum(B2B_USAGE_SPEND_COMPONENT),
67
+ spent: NonNegativeNumberSchema,
68
+ sharePercent: PercentageSchema,
69
+ });
70
+
71
+ export const B2bUsageStatisticsSchema = z.object({
72
+ hasData: z.boolean(),
73
+ appliedFilter: B2bUsageStatisticsAppliedFilterSchema,
74
+ summary: B2bUsageStatisticsSummarySchema,
75
+ graph: z.array(B2bUsageStatisticsGraphPointSchema),
76
+ keys: z.array(B2bUsageStatisticsKeySchema),
77
+ models: z.array(B2bUsageStatisticsModelSchema),
78
+ spendStructure: z.array(B2bUsageStatisticsSpendStructureItemSchema),
79
+ });
80
+
81
+ export type B2bUsageStatistics = z.infer<typeof B2bUsageStatisticsSchema>;
@@ -1,2 +1,3 @@
1
1
  export * from './b2b-completions-stream-chunk.schema';
2
2
  export * from './b2b-file-upload-response.schema';
3
+ export * from './b2b-usage-statistics.schema';
@@ -84,7 +84,7 @@ export const MotionControlParamsSchema = strictObject({
84
84
  export type MotionControlParams = z.infer<typeof MotionControlParamsSchema>;
85
85
 
86
86
  export const VarGenParamsSchema = strictObject({
87
- prompt: z.string().min(1).optional(),
87
+ prompt: z.string(),
88
88
  modelId: z.string(),
89
89
  modelName: z.string(),
90
90
  });
@@ -137,7 +137,7 @@ export const MotionControlOutputSchema = strictObject({
137
137
  export type MotionControlOutput = z.infer<typeof MotionControlOutputSchema>;
138
138
 
139
139
  export const VarGenOutputSchema = strictObject({
140
- variables: z.record(z.string().min(1), z.string()),
140
+ variables: z.record(z.string()),
141
141
  });
142
142
  export type VarGenOutput = z.infer<typeof VarGenOutputSchema>;
143
143
 
@@ -1,18 +1,10 @@
1
1
  import { z } from 'zod';
2
2
  import { FILE_TYPE } from '../constants';
3
3
 
4
- export const FileResolutionSchema = z.object({
5
- width: z.number().int().positive(),
6
- height: z.number().int().positive(),
7
- });
8
- export type FileResolution = z.infer<typeof FileResolutionSchema>;
9
-
10
4
  export const FileSchema = z.object({
11
5
  uuid: z.string().uuid(),
12
6
  name: z.string(),
13
7
  size: z.number(),
14
- originalName: z.string().nullable().optional(),
15
- resolution: FileResolutionSchema.nullable().optional(),
16
8
  mimeType: z.string(),
17
9
  url: z.string(),
18
10
  key: z.string(),
package/models/index.ts CHANGED
@@ -22,7 +22,6 @@ export * from './file.schema';
22
22
  export * from './key-value.schema';
23
23
  export * from './form-submission.schema';
24
24
  export * from './icon-variants.schema';
25
- export * from './photo-studio';
26
25
  export * from './lesson.schema';
27
26
  export * from './lesson-translation.schema';
28
27
  export * from './message.schema';
@@ -1,7 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { ToolJobSchema } from '../../tool-job.schema';
3
3
  import { IMAGE_GENERATION_RESOLUTION, USER_REACTION } from '../../../constants';
4
- import { FileResolutionSchema } from '../../file.schema';
5
4
 
6
5
  export const ImageGenerationFileAttachmentSchema = z.object({
7
6
  uuid: z.string(),
@@ -33,8 +32,6 @@ export const ImageGenerationJobSchema = ToolJobSchema.extend({
33
32
  z.object({
34
33
  uuid: z.string(),
35
34
  url: z.string(),
36
- originalName: z.string().nullable().optional(),
37
- resolution: FileResolutionSchema.nullable().optional(),
38
35
  }),
39
36
  )
40
37
  .nullable(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.13.21",
3
+ "version": "0.14.1-stage-2",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -1,5 +0,0 @@
1
- export const AGENT_STATISTICS_CONTROLLER_PRIVATE = 'private/agents-statistics' as const;
2
-
3
- export const AGENT_STATISTICS_ROUTES = {
4
- GET: (agentId: string) => `${agentId}`,
5
- } as const;
@@ -1,7 +0,0 @@
1
- export const CANVAS_VAR_GENERATION_PRIVATE = 'private/ai-canvas/tools/var-gen' as const;
2
-
3
- export const CANVAS_VAR_GENERATION_ROUTES = {
4
- CONFIG: 'config',
5
- PRICE: 'price',
6
- GENERATE: 'generate',
7
- } as const;
@@ -1,21 +0,0 @@
1
- export const PHOTO_STUDIO_PRIVATE_CONTROLLER = 'private/photo-studio' as const;
2
-
3
- export const PHOTO_STUDIO_ROUTES = {
4
- ACTIONS: 'actions',
5
- EXECUTE: (canvasId: string) => `canvases/${canvasId}/execute`,
6
- CREATE_CANVAS: 'canvases',
7
- GET_CANVASES: 'canvases',
8
- GET_CANVAS: (uuid: string) => `canvases/${uuid}`,
9
- GET_JOBS: (canvasId: string) => `canvases/${canvasId}/jobs`,
10
- GET_JOB: (canvasId: string, jobId: string) => `canvases/${canvasId}/jobs/${jobId}`,
11
- SAVE_CANVAS: (uuid: string) => `canvases/${uuid}/save`,
12
- UPDATE_CANVAS: (uuid: string) => `canvases/${uuid}`,
13
- DELETE_CANVAS: (uuid: string) => `canvases/${uuid}`,
14
- GET_CHECKPOINTS: (canvasId: string) => `canvases/${canvasId}/checkpoints`,
15
- ADD_CHECKPOINT: (canvasId: string) => `canvases/${canvasId}/checkpoints`,
16
- UPDATE_CHECKPOINT: (canvasId: string, checkpointId: string) =>
17
- `canvases/${canvasId}/checkpoints/${checkpointId}`,
18
- DELETE_CHECKPOINT: (canvasId: string, checkpointId: string) =>
19
- `canvases/${canvasId}/checkpoints/${checkpointId}`,
20
- CLEAR_CHECKPOINTS: (canvasId: string) => `canvases/${canvasId}/checkpoints`,
21
- } as const;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AGENT_STATISTICS_ROUTES = exports.AGENT_STATISTICS_CONTROLLER_PRIVATE = void 0;
4
- exports.AGENT_STATISTICS_CONTROLLER_PRIVATE = 'private/agents-statistics';
5
- exports.AGENT_STATISTICS_ROUTES = {
6
- GET: (agentId) => `${agentId}`,
7
- };
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CANVAS_VAR_GENERATION_ROUTES = exports.CANVAS_VAR_GENERATION_PRIVATE = void 0;
4
- exports.CANVAS_VAR_GENERATION_PRIVATE = 'private/ai-canvas/tools/var-gen';
5
- exports.CANVAS_VAR_GENERATION_ROUTES = {
6
- CONFIG: 'config',
7
- PRICE: 'price',
8
- GENERATE: 'generate',
9
- };
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PHOTO_STUDIO_ROUTES = exports.PHOTO_STUDIO_PRIVATE_CONTROLLER = void 0;
4
- exports.PHOTO_STUDIO_PRIVATE_CONTROLLER = 'private/photo-studio';
5
- exports.PHOTO_STUDIO_ROUTES = {
6
- ACTIONS: 'actions',
7
- EXECUTE: (canvasId) => `canvases/${canvasId}/execute`,
8
- CREATE_CANVAS: 'canvases',
9
- GET_CANVASES: 'canvases',
10
- GET_CANVAS: (uuid) => `canvases/${uuid}`,
11
- GET_JOBS: (canvasId) => `canvases/${canvasId}/jobs`,
12
- GET_JOB: (canvasId, jobId) => `canvases/${canvasId}/jobs/${jobId}`,
13
- SAVE_CANVAS: (uuid) => `canvases/${uuid}/save`,
14
- UPDATE_CANVAS: (uuid) => `canvases/${uuid}`,
15
- DELETE_CANVAS: (uuid) => `canvases/${uuid}`,
16
- GET_CHECKPOINTS: (canvasId) => `canvases/${canvasId}/checkpoints`,
17
- ADD_CHECKPOINT: (canvasId) => `canvases/${canvasId}/checkpoints`,
18
- UPDATE_CHECKPOINT: (canvasId, checkpointId) => `canvases/${canvasId}/checkpoints/${checkpointId}`,
19
- DELETE_CHECKPOINT: (canvasId, checkpointId) => `canvases/${canvasId}/checkpoints/${checkpointId}`,
20
- CLEAR_CHECKPOINTS: (canvasId) => `canvases/${canvasId}/checkpoints`,
21
- };
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetCabinetConfigCommand = void 0;
4
- const zod_1 = require("zod");
5
- var GetCabinetConfigCommand;
6
- (function (GetCabinetConfigCommand) {
7
- GetCabinetConfigCommand.ResponseSchema = zod_1.z.object({
8
- data: zod_1.z.object({
9
- maxPromptLength: zod_1.z.number().int().positive(),
10
- }),
11
- });
12
- })(GetCabinetConfigCommand || (exports.GetCabinetConfigCommand = GetCabinetConfigCommand = {}));
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetCabinetPricePreviewCommand = void 0;
4
- const zod_1 = require("zod");
5
- var GetCabinetPricePreviewCommand;
6
- (function (GetCabinetPricePreviewCommand) {
7
- GetCabinetPricePreviewCommand.RequestParamsSchema = zod_1.z.object({
8
- agentId: zod_1.z.string().uuid(),
9
- dialogId: zod_1.z.string().uuid(),
10
- });
11
- GetCabinetPricePreviewCommand.RequestBodySchema = zod_1.z.object({
12
- inputLength: zod_1.z.number().int().min(0),
13
- fileIds: zod_1.z.array(zod_1.z.string().uuid()).optional(),
14
- useWebSearch: zod_1.z.boolean().optional(),
15
- });
16
- GetCabinetPricePreviewCommand.ResponseSchema = zod_1.z.object({
17
- data: zod_1.z.object({
18
- price: zod_1.z.number().int().min(0),
19
- breakdown: zod_1.z.object({
20
- textCost: zod_1.z.number().int().min(0),
21
- attachmentsCost: zod_1.z.number().int().min(0),
22
- webSearchCost: zod_1.z.number().int().min(0),
23
- }),
24
- charsUntilNextPriceIncrease: zod_1.z.number().int().min(1).nullable(),
25
- charsUntilNextPriceDecrease: zod_1.z.number().int().min(1).nullable(),
26
- }),
27
- });
28
- })(GetCabinetPricePreviewCommand || (exports.GetCabinetPricePreviewCommand = GetCabinetPricePreviewCommand = {}));
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetDialogContextLengthCommand = void 0;
4
- const zod_1 = require("zod");
5
- const message_attachment_schema_1 = require("../../../models/agents/message-attachment.schema");
6
- var GetDialogContextLengthCommand;
7
- (function (GetDialogContextLengthCommand) {
8
- GetDialogContextLengthCommand.RequestSchema = zod_1.z.object({
9
- teamAccountId: zod_1.z.string().uuid(),
10
- dialogId: zod_1.z.string().uuid(),
11
- inputLength: zod_1.z.number().int().min(0),
12
- attachments: zod_1.z
13
- .array(zod_1.z.object({
14
- type: message_attachment_schema_1.MessageAttachmentTypeEnum,
15
- contentLength: zod_1.z.number().int().optional(),
16
- }))
17
- .default([]),
18
- });
19
- GetDialogContextLengthCommand.ResponseSchema = zod_1.z.object({
20
- isSuccess: zod_1.z.literal(true),
21
- data: zod_1.z.object({
22
- historyChars: zod_1.z.number().int().min(0),
23
- totalInputChars: zod_1.z.number().int().min(0),
24
- modelPricing: zod_1.z.object({
25
- inputPrice: zod_1.z.number(),
26
- outputPrice: zod_1.z.number(),
27
- }),
28
- }),
29
- });
30
- })(GetDialogContextLengthCommand || (exports.GetDialogContextLengthCommand = GetDialogContextLengthCommand = {}));
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RenameAgentDialogCommand = void 0;
4
- const zod_1 = require("zod");
5
- const dialog_schema_1 = require("../../../models/agents/dialog.schema");
6
- var RenameAgentDialogCommand;
7
- (function (RenameAgentDialogCommand) {
8
- RenameAgentDialogCommand.RequestParamsSchema = zod_1.z.object({
9
- dialogId: zod_1.z.string().uuid(),
10
- });
11
- RenameAgentDialogCommand.RequestBodySchema = zod_1.z.object({
12
- title: zod_1.z.string(),
13
- });
14
- RenameAgentDialogCommand.ResponseSchema = zod_1.z.object({
15
- data: dialog_schema_1.DialogSchema,
16
- });
17
- })(RenameAgentDialogCommand || (exports.RenameAgentDialogCommand = RenameAgentDialogCommand = {}));
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StopCabinetStreamCommand = void 0;
4
- const zod_1 = require("zod");
5
- var StopCabinetStreamCommand;
6
- (function (StopCabinetStreamCommand) {
7
- StopCabinetStreamCommand.RequestParamsSchema = zod_1.z.object({
8
- agentId: zod_1.z.string().uuid(),
9
- dialogId: zod_1.z.string().uuid(),
10
- messageId: zod_1.z.string().uuid(),
11
- });
12
- StopCabinetStreamCommand.ResponseSchema = zod_1.z.object({
13
- stopped: zod_1.z.boolean(),
14
- });
15
- })(StopCabinetStreamCommand || (exports.StopCabinetStreamCommand = StopCabinetStreamCommand = {}));
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetAgentTemplateInstructionsByTemplateCommand = void 0;
4
- const zod_1 = require("zod");
5
- const agent_template_instruction_schema_1 = require("../../../models/agents/agent-template-instruction.schema");
6
- var GetAgentTemplateInstructionsByTemplateCommand;
7
- (function (GetAgentTemplateInstructionsByTemplateCommand) {
8
- GetAgentTemplateInstructionsByTemplateCommand.RequestParamsSchema = zod_1.z.object({
9
- templateId: zod_1.z.string().uuid(),
10
- });
11
- GetAgentTemplateInstructionsByTemplateCommand.ResponseSchema = zod_1.z.object({
12
- data: zod_1.z.array(agent_template_instruction_schema_1.AgentTemplateInstructionSchema),
13
- });
14
- })(GetAgentTemplateInstructionsByTemplateCommand || (exports.GetAgentTemplateInstructionsByTemplateCommand = GetAgentTemplateInstructionsByTemplateCommand = {}));
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetAgentStatisticsCommand = void 0;
4
- const zod_1 = require("zod");
5
- const agent_statistics_schema_1 = require("../../../models/agents/agent-statistics.schema");
6
- var GetAgentStatisticsCommand;
7
- (function (GetAgentStatisticsCommand) {
8
- GetAgentStatisticsCommand.RequestQuerySchema = zod_1.z.object({
9
- from: zod_1.z.string().datetime().optional(),
10
- to: zod_1.z.string().datetime().optional(),
11
- granularity: zod_1.z.enum(['day', 'week', 'month']).optional().default('day'),
12
- source: zod_1.z.string().optional(),
13
- });
14
- GetAgentStatisticsCommand.RequestParamsSchema = zod_1.z.object({
15
- agentId: zod_1.z.string().uuid(),
16
- });
17
- GetAgentStatisticsCommand.ResponseSchema = zod_1.z.object({
18
- data: agent_statistics_schema_1.AgentStatisticsDataSchema,
19
- });
20
- })(GetAgentStatisticsCommand || (exports.GetAgentStatisticsCommand = GetAgentStatisticsCommand = {}));
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GenerateVariablesCommand = void 0;
4
- const zod_1 = require("zod");
5
- const models_1 = require("../../../../models");
6
- var GenerateVariablesCommand;
7
- (function (GenerateVariablesCommand) {
8
- GenerateVariablesCommand.OutputSchema = models_1.VarGenOutputSchema;
9
- GenerateVariablesCommand.RequestSchema = zod_1.z.object({
10
- nodeUuid: zod_1.z.string().uuid(),
11
- canvasId: zod_1.z.string().uuid(),
12
- modelId: zod_1.z.string().uuid(),
13
- prompt: zod_1.z.string().min(1),
14
- });
15
- GenerateVariablesCommand.ResponseSchema = zod_1.z.object({
16
- data: GenerateVariablesCommand.OutputSchema,
17
- });
18
- })(GenerateVariablesCommand || (exports.GenerateVariablesCommand = GenerateVariablesCommand = {}));
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetVarGenConfigCommand = void 0;
4
- const zod_1 = require("zod");
5
- const models_1 = require("../../../../models");
6
- var GetVarGenConfigCommand;
7
- (function (GetVarGenConfigCommand) {
8
- GetVarGenConfigCommand.ResponseSchema = zod_1.z.object({
9
- data: zod_1.z.array(models_1.AiModelSchema),
10
- });
11
- })(GetVarGenConfigCommand || (exports.GetVarGenConfigCommand = GetVarGenConfigCommand = {}));