@purpleschool/multisite 0.0.28 → 0.0.29

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 (54) hide show
  1. package/build/commands/image-editor/execute-image-editor.command.d.ts +12 -0
  2. package/build/commands/image-editor/execute-image-editor.command.d.ts.map +1 -1
  3. package/build/commands/image-editor/proxy-image-editor-callback.command.js +1 -1
  4. package/build/commands/image-editor/retry-image-editor-job.command.d.ts +12 -0
  5. package/build/commands/image-editor/retry-image-editor-job.command.d.ts.map +1 -1
  6. package/build/commands/image-editor/set-reaction-to-image-editor-job.command.d.ts +7 -0
  7. package/build/commands/image-editor/set-reaction-to-image-editor-job.command.d.ts.map +1 -1
  8. package/build/commands/image-editor/update-image-editor-job-title.command.d.ts +7 -0
  9. package/build/commands/image-editor/update-image-editor-job-title.command.d.ts.map +1 -1
  10. package/build/constants/image-editor/enums/image-editing-strategy.enum.d.ts +2 -1
  11. package/build/constants/image-editor/enums/image-editing-strategy.enum.d.ts.map +1 -1
  12. package/build/constants/image-editor/enums/image-editing-strategy.enum.js +1 -0
  13. package/build/helpers/image-generation/calculate-image-generation-price.helper.d.ts +4 -2
  14. package/build/helpers/image-generation/calculate-image-generation-price.helper.d.ts.map +1 -1
  15. package/build/helpers/index.d.ts +1 -0
  16. package/build/helpers/index.d.ts.map +1 -1
  17. package/build/helpers/index.js +1 -0
  18. package/build/helpers/openai-image-2/calculate-openai-image-2-price.helper.d.ts +20 -0
  19. package/build/helpers/openai-image-2/calculate-openai-image-2-price.helper.d.ts.map +1 -0
  20. package/build/helpers/openai-image-2/calculate-openai-image-2-price.helper.js +125 -0
  21. package/build/helpers/openai-image-2/index.d.ts +2 -0
  22. package/build/helpers/openai-image-2/index.d.ts.map +1 -0
  23. package/build/helpers/openai-image-2/index.js +17 -0
  24. package/build/models/image-editor/image-editor-config.schema.d.ts +25 -0
  25. package/build/models/image-editor/image-editor-config.schema.d.ts.map +1 -1
  26. package/build/models/image-editor/image-editor-job-params.schema.d.ts +3 -0
  27. package/build/models/image-editor/image-editor-job-params.schema.d.ts.map +1 -1
  28. package/build/models/image-editor/image-editor-job-params.schema.js +1 -0
  29. package/build/models/image-editor/image-editor-job-request-params.schema.d.ts +3 -0
  30. package/build/models/image-editor/image-editor-job-request-params.schema.d.ts.map +1 -1
  31. package/build/models/image-editor/image-editor-job-request-params.schema.js +1 -0
  32. package/build/models/image-editor/image-editor-job.schema.d.ts +5 -0
  33. package/build/models/image-editor/image-editor-job.schema.d.ts.map +1 -1
  34. package/build/models/image-editor/image-editor-model-params.schema.d.ts +13 -0
  35. package/build/models/image-editor/image-editor-model-params.schema.d.ts.map +1 -1
  36. package/build/models/image-editor/image-editor-model-params.schema.js +5 -0
  37. package/build/models/image-editor/image-editor-model.schema.d.ts +19 -0
  38. package/build/models/image-editor/image-editor-model.schema.d.ts.map +1 -1
  39. package/build/queries/image-editor/find-image-editor-jobs.command.d.ts +7 -0
  40. package/build/queries/image-editor/find-image-editor-jobs.command.d.ts.map +1 -1
  41. package/build/queries/image-editor/get-image-editor-config.command.d.ts +31 -0
  42. package/build/queries/image-editor/get-image-editor-config.command.d.ts.map +1 -1
  43. package/build/queries/image-editor/get-image-editor-job.command.d.ts +7 -0
  44. package/build/queries/image-editor/get-image-editor-job.command.d.ts.map +1 -1
  45. package/commands/image-editor/proxy-image-editor-callback.command.ts +1 -1
  46. package/constants/image-editor/enums/image-editing-strategy.enum.ts +1 -0
  47. package/helpers/image-generation/calculate-image-generation-price.helper.ts +4 -2
  48. package/helpers/index.ts +1 -0
  49. package/helpers/openai-image-2/calculate-openai-image-2-price.helper.ts +160 -0
  50. package/helpers/openai-image-2/index.ts +1 -0
  51. package/models/image-editor/image-editor-job-params.schema.ts +1 -0
  52. package/models/image-editor/image-editor-job-request-params.schema.ts +1 -0
  53. package/models/image-editor/image-editor-model-params.schema.ts +5 -0
  54. package/package.json +1 -1
@@ -28,6 +28,7 @@ export declare const ImageEditorJobParamsSchema: z.ZodObject<{
28
28
  imageUrls: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
29
29
  systemPromptId: z.ZodOptional<z.ZodString>;
30
30
  aspectRatio: z.ZodOptional<z.ZodString>;
31
+ resolution: z.ZodOptional<z.ZodString>;
31
32
  userHasActiveSubscriptionOrProduct: z.ZodOptional<z.ZodBoolean>;
32
33
  }, "strip", z.ZodTypeAny, {
33
34
  attachedFiles?: {
@@ -42,6 +43,7 @@ export declare const ImageEditorJobParamsSchema: z.ZodObject<{
42
43
  imageUrls?: string[] | undefined;
43
44
  systemPromptId?: string | undefined;
44
45
  aspectRatio?: string | undefined;
46
+ resolution?: string | undefined;
45
47
  userHasActiveSubscriptionOrProduct?: boolean | undefined;
46
48
  }, {
47
49
  attachedFiles?: {
@@ -56,6 +58,7 @@ export declare const ImageEditorJobParamsSchema: z.ZodObject<{
56
58
  imageUrls?: string[] | undefined;
57
59
  systemPromptId?: string | undefined;
58
60
  aspectRatio?: string | undefined;
61
+ resolution?: string | undefined;
59
62
  userHasActiveSubscriptionOrProduct?: boolean | undefined;
60
63
  }>;
61
64
  export type ImageEditorJobParams = z.infer<typeof ImageEditorJobParamsSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"image-editor-job-params.schema.d.ts","sourceRoot":"","sources":["../../../models/image-editor/image-editor-job-params.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC"}
1
+ {"version":3,"file":"image-editor-job-params.schema.d.ts","sourceRoot":"","sources":["../../../models/image-editor/image-editor-job-params.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC"}
@@ -8,5 +8,6 @@ exports.ImageEditorJobParamsSchema = zod_1.z.object({
8
8
  imageUrls: zod_1.z.array(zod_1.z.string()).optional(),
9
9
  systemPromptId: zod_1.z.string().uuid().optional(),
10
10
  aspectRatio: zod_1.z.string().optional(),
11
+ resolution: zod_1.z.string().optional(),
11
12
  userHasActiveSubscriptionOrProduct: zod_1.z.boolean().optional(),
12
13
  });
@@ -3,14 +3,17 @@ export declare const ImageEditorJobRequestParamsSchema: z.ZodObject<{
3
3
  imageUrls: z.ZodArray<z.ZodString, "many">;
4
4
  systemPromptId: z.ZodOptional<z.ZodString>;
5
5
  aspectRatio: z.ZodOptional<z.ZodString>;
6
+ resolution: z.ZodOptional<z.ZodString>;
6
7
  }, "strip", z.ZodTypeAny, {
7
8
  imageUrls: string[];
8
9
  systemPromptId?: string | undefined;
9
10
  aspectRatio?: string | undefined;
11
+ resolution?: string | undefined;
10
12
  }, {
11
13
  imageUrls: string[];
12
14
  systemPromptId?: string | undefined;
13
15
  aspectRatio?: string | undefined;
16
+ resolution?: string | undefined;
14
17
  }>;
15
18
  export type ImageEditorJobRequestParams = z.infer<typeof ImageEditorJobRequestParamsSchema>;
16
19
  //# sourceMappingURL=image-editor-job-request-params.schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"image-editor-job-request-params.schema.d.ts","sourceRoot":"","sources":["../../../models/image-editor/image-editor-job-request-params.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,iCAAiC;;;;;;;;;;;;EAI5C,CAAC;AAEH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC"}
1
+ {"version":3,"file":"image-editor-job-request-params.schema.d.ts","sourceRoot":"","sources":["../../../models/image-editor/image-editor-job-request-params.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;EAK5C,CAAC;AAEH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC"}
@@ -6,4 +6,5 @@ exports.ImageEditorJobRequestParamsSchema = zod_1.z.object({
6
6
  imageUrls: zod_1.z.array(zod_1.z.string().uuid()).min(1),
7
7
  systemPromptId: zod_1.z.string().uuid().optional(),
8
8
  aspectRatio: zod_1.z.string().optional(),
9
+ resolution: zod_1.z.string().optional(),
9
10
  });
@@ -41,6 +41,7 @@ export declare const ImageEditorJobSchema: z.ZodObject<{
41
41
  imageUrls: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
42
42
  systemPromptId: z.ZodOptional<z.ZodString>;
43
43
  aspectRatio: z.ZodOptional<z.ZodString>;
44
+ resolution: z.ZodOptional<z.ZodString>;
44
45
  userHasActiveSubscriptionOrProduct: z.ZodOptional<z.ZodBoolean>;
45
46
  }, "strip", z.ZodTypeAny, {
46
47
  attachedFiles?: {
@@ -55,6 +56,7 @@ export declare const ImageEditorJobSchema: z.ZodObject<{
55
56
  imageUrls?: string[] | undefined;
56
57
  systemPromptId?: string | undefined;
57
58
  aspectRatio?: string | undefined;
59
+ resolution?: string | undefined;
58
60
  userHasActiveSubscriptionOrProduct?: boolean | undefined;
59
61
  }, {
60
62
  attachedFiles?: {
@@ -69,6 +71,7 @@ export declare const ImageEditorJobSchema: z.ZodObject<{
69
71
  imageUrls?: string[] | undefined;
70
72
  systemPromptId?: string | undefined;
71
73
  aspectRatio?: string | undefined;
74
+ resolution?: string | undefined;
72
75
  userHasActiveSubscriptionOrProduct?: boolean | undefined;
73
76
  }>;
74
77
  imageUrls: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
@@ -106,6 +109,7 @@ export declare const ImageEditorJobSchema: z.ZodObject<{
106
109
  imageUrls?: string[] | undefined;
107
110
  systemPromptId?: string | undefined;
108
111
  aspectRatio?: string | undefined;
112
+ resolution?: string | undefined;
109
113
  userHasActiveSubscriptionOrProduct?: boolean | undefined;
110
114
  };
111
115
  imageUrls: string[];
@@ -143,6 +147,7 @@ export declare const ImageEditorJobSchema: z.ZodObject<{
143
147
  imageUrls?: string[] | undefined;
144
148
  systemPromptId?: string | undefined;
145
149
  aspectRatio?: string | undefined;
150
+ resolution?: string | undefined;
146
151
  userHasActiveSubscriptionOrProduct?: boolean | undefined;
147
152
  };
148
153
  imageUrls?: string[] | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"image-editor-job.schema.d.ts","sourceRoot":"","sources":["../../../models/image-editor/image-editor-job.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG5D,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuB/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
1
+ {"version":3,"file":"image-editor-job.schema.d.ts","sourceRoot":"","sources":["../../../models/image-editor/image-editor-job.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG5D,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuB/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
@@ -23,6 +23,13 @@ export declare const ImageEditorModelParamsSchema: z.ZodObject<{
23
23
  width: number;
24
24
  height: number;
25
25
  }>>;
26
+ resolution: z.ZodOptional<z.ZodObject<{
27
+ options: z.ZodArray<z.ZodString, "many">;
28
+ }, "strip", z.ZodTypeAny, {
29
+ options: string[];
30
+ }, {
31
+ options: string[];
32
+ }>>;
26
33
  }, "strip", z.ZodTypeAny, {
27
34
  imageAttachment: {
28
35
  supported: boolean;
@@ -33,6 +40,9 @@ export declare const ImageEditorModelParamsSchema: z.ZodObject<{
33
40
  width: number;
34
41
  height: number;
35
42
  }>;
43
+ resolution?: {
44
+ options: string[];
45
+ } | undefined;
36
46
  }, {
37
47
  imageAttachment: {
38
48
  supported: boolean;
@@ -43,6 +53,9 @@ export declare const ImageEditorModelParamsSchema: z.ZodObject<{
43
53
  width: number;
44
54
  height: number;
45
55
  }>;
56
+ resolution?: {
57
+ options: string[];
58
+ } | undefined;
46
59
  }>;
47
60
  export type ImageEditorModelParams = z.infer<typeof ImageEditorModelParamsSchema>;
48
61
  //# sourceMappingURL=image-editor-model-params.schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"image-editor-model-params.schema.d.ts","sourceRoot":"","sources":["../../../models/image-editor/image-editor-model-params.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAavC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC"}
1
+ {"version":3,"file":"image-editor-model-params.schema.d.ts","sourceRoot":"","sources":["../../../models/image-editor/image-editor-model-params.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBvC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC"}
@@ -12,4 +12,9 @@ exports.ImageEditorModelParamsSchema = zod_1.z.object({
12
12
  width: zod_1.z.number().int().positive(),
13
13
  height: zod_1.z.number().int().positive(),
14
14
  })),
15
+ resolution: zod_1.z
16
+ .object({
17
+ options: zod_1.z.array(zod_1.z.string()),
18
+ })
19
+ .optional(),
15
20
  });
@@ -76,6 +76,13 @@ export declare const ImageEditorModelSchema: z.ZodObject<{
76
76
  width: number;
77
77
  height: number;
78
78
  }>>;
79
+ resolution: z.ZodOptional<z.ZodObject<{
80
+ options: z.ZodArray<z.ZodString, "many">;
81
+ }, "strip", z.ZodTypeAny, {
82
+ options: string[];
83
+ }, {
84
+ options: string[];
85
+ }>>;
79
86
  }, "strip", z.ZodTypeAny, {
80
87
  imageAttachment: {
81
88
  supported: boolean;
@@ -86,6 +93,9 @@ export declare const ImageEditorModelSchema: z.ZodObject<{
86
93
  width: number;
87
94
  height: number;
88
95
  }>;
96
+ resolution?: {
97
+ options: string[];
98
+ } | undefined;
89
99
  }, {
90
100
  imageAttachment: {
91
101
  supported: boolean;
@@ -96,6 +106,9 @@ export declare const ImageEditorModelSchema: z.ZodObject<{
96
106
  width: number;
97
107
  height: number;
98
108
  }>;
109
+ resolution?: {
110
+ options: string[];
111
+ } | undefined;
99
112
  }>;
100
113
  pricingRules: z.ZodArray<z.ZodObject<{
101
114
  condition: z.ZodObject<{
@@ -153,6 +166,9 @@ export declare const ImageEditorModelSchema: z.ZodObject<{
153
166
  width: number;
154
167
  height: number;
155
168
  }>;
169
+ resolution?: {
170
+ options: string[];
171
+ } | undefined;
156
172
  };
157
173
  pricingRules: {
158
174
  condition: {
@@ -196,6 +212,9 @@ export declare const ImageEditorModelSchema: z.ZodObject<{
196
212
  width: number;
197
213
  height: number;
198
214
  }>;
215
+ resolution?: {
216
+ options: string[];
217
+ } | undefined;
199
218
  };
200
219
  pricingRules: {
201
220
  condition: {
@@ -1 +1 @@
1
- {"version":3,"file":"image-editor-model.schema.d.ts","sourceRoot":"","sources":["../../../models/image-editor/image-editor-model.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAK5E,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmBjC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
1
+ {"version":3,"file":"image-editor-model.schema.d.ts","sourceRoot":"","sources":["../../../models/image-editor/image-editor-model.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAK5E,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmBjC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
@@ -56,6 +56,7 @@ export declare namespace FindImageEditorJobsCommand {
56
56
  imageUrls: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
57
57
  systemPromptId: z.ZodOptional<z.ZodString>;
58
58
  aspectRatio: z.ZodOptional<z.ZodString>;
59
+ resolution: z.ZodOptional<z.ZodString>;
59
60
  userHasActiveSubscriptionOrProduct: z.ZodOptional<z.ZodBoolean>;
60
61
  }, "strip", z.ZodTypeAny, {
61
62
  attachedFiles?: {
@@ -70,6 +71,7 @@ export declare namespace FindImageEditorJobsCommand {
70
71
  imageUrls?: string[] | undefined;
71
72
  systemPromptId?: string | undefined;
72
73
  aspectRatio?: string | undefined;
74
+ resolution?: string | undefined;
73
75
  userHasActiveSubscriptionOrProduct?: boolean | undefined;
74
76
  }, {
75
77
  attachedFiles?: {
@@ -84,6 +86,7 @@ export declare namespace FindImageEditorJobsCommand {
84
86
  imageUrls?: string[] | undefined;
85
87
  systemPromptId?: string | undefined;
86
88
  aspectRatio?: string | undefined;
89
+ resolution?: string | undefined;
87
90
  userHasActiveSubscriptionOrProduct?: boolean | undefined;
88
91
  }>;
89
92
  imageUrls: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
@@ -121,6 +124,7 @@ export declare namespace FindImageEditorJobsCommand {
121
124
  imageUrls?: string[] | undefined;
122
125
  systemPromptId?: string | undefined;
123
126
  aspectRatio?: string | undefined;
127
+ resolution?: string | undefined;
124
128
  userHasActiveSubscriptionOrProduct?: boolean | undefined;
125
129
  };
126
130
  imageUrls: string[];
@@ -158,6 +162,7 @@ export declare namespace FindImageEditorJobsCommand {
158
162
  imageUrls?: string[] | undefined;
159
163
  systemPromptId?: string | undefined;
160
164
  aspectRatio?: string | undefined;
165
+ resolution?: string | undefined;
161
166
  userHasActiveSubscriptionOrProduct?: boolean | undefined;
162
167
  };
163
168
  imageUrls?: string[] | undefined;
@@ -210,6 +215,7 @@ export declare namespace FindImageEditorJobsCommand {
210
215
  imageUrls?: string[] | undefined;
211
216
  systemPromptId?: string | undefined;
212
217
  aspectRatio?: string | undefined;
218
+ resolution?: string | undefined;
213
219
  userHasActiveSubscriptionOrProduct?: boolean | undefined;
214
220
  };
215
221
  imageUrls: string[];
@@ -254,6 +260,7 @@ export declare namespace FindImageEditorJobsCommand {
254
260
  imageUrls?: string[] | undefined;
255
261
  systemPromptId?: string | undefined;
256
262
  aspectRatio?: string | undefined;
263
+ resolution?: string | undefined;
257
264
  userHasActiveSubscriptionOrProduct?: boolean | undefined;
258
265
  };
259
266
  imageUrls?: string[] | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"find-image-editor-jobs.command.d.ts","sourceRoot":"","sources":["../../../queries/image-editor/find-image-editor-jobs.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,yBAAiB,0BAA0B,CAAC;IACjC,MAAM,kBAAkB;;;;;;;;;;;;MAI7B,CAAC;IACH,KAAY,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;IAEvD,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAOzB,CAAC;IACH,KAAY,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;CACzD"}
1
+ {"version":3,"file":"find-image-editor-jobs.command.d.ts","sourceRoot":"","sources":["../../../queries/image-editor/find-image-editor-jobs.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,yBAAiB,0BAA0B,CAAC;IACjC,MAAM,kBAAkB;;;;;;;;;;;;MAI7B,CAAC;IACH,KAAY,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;IAEvD,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAOzB,CAAC;IACH,KAAY,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;CACzD"}
@@ -78,6 +78,13 @@ export declare namespace GetImageEditorConfigCommand {
78
78
  width: number;
79
79
  height: number;
80
80
  }>>;
81
+ resolution: z.ZodOptional<z.ZodObject<{
82
+ options: z.ZodArray<z.ZodString, "many">;
83
+ }, "strip", z.ZodTypeAny, {
84
+ options: string[];
85
+ }, {
86
+ options: string[];
87
+ }>>;
81
88
  }, "strip", z.ZodTypeAny, {
82
89
  imageAttachment: {
83
90
  supported: boolean;
@@ -88,6 +95,9 @@ export declare namespace GetImageEditorConfigCommand {
88
95
  width: number;
89
96
  height: number;
90
97
  }>;
98
+ resolution?: {
99
+ options: string[];
100
+ } | undefined;
91
101
  }, {
92
102
  imageAttachment: {
93
103
  supported: boolean;
@@ -98,6 +108,9 @@ export declare namespace GetImageEditorConfigCommand {
98
108
  width: number;
99
109
  height: number;
100
110
  }>;
111
+ resolution?: {
112
+ options: string[];
113
+ } | undefined;
101
114
  }>;
102
115
  pricingRules: z.ZodArray<z.ZodObject<{
103
116
  condition: z.ZodObject<{
@@ -155,6 +168,9 @@ export declare namespace GetImageEditorConfigCommand {
155
168
  width: number;
156
169
  height: number;
157
170
  }>;
171
+ resolution?: {
172
+ options: string[];
173
+ } | undefined;
158
174
  };
159
175
  pricingRules: {
160
176
  condition: {
@@ -198,6 +214,9 @@ export declare namespace GetImageEditorConfigCommand {
198
214
  width: number;
199
215
  height: number;
200
216
  }>;
217
+ resolution?: {
218
+ options: string[];
219
+ } | undefined;
201
220
  };
202
221
  pricingRules: {
203
222
  condition: {
@@ -389,6 +408,9 @@ export declare namespace GetImageEditorConfigCommand {
389
408
  width: number;
390
409
  height: number;
391
410
  }>;
411
+ resolution?: {
412
+ options: string[];
413
+ } | undefined;
392
414
  };
393
415
  pricingRules: {
394
416
  condition: {
@@ -464,6 +486,9 @@ export declare namespace GetImageEditorConfigCommand {
464
486
  width: number;
465
487
  height: number;
466
488
  }>;
489
+ resolution?: {
490
+ options: string[];
491
+ } | undefined;
467
492
  };
468
493
  pricingRules: {
469
494
  condition: {
@@ -541,6 +566,9 @@ export declare namespace GetImageEditorConfigCommand {
541
566
  width: number;
542
567
  height: number;
543
568
  }>;
569
+ resolution?: {
570
+ options: string[];
571
+ } | undefined;
544
572
  };
545
573
  pricingRules: {
546
574
  condition: {
@@ -618,6 +646,9 @@ export declare namespace GetImageEditorConfigCommand {
618
646
  width: number;
619
647
  height: number;
620
648
  }>;
649
+ resolution?: {
650
+ options: string[];
651
+ } | undefined;
621
652
  };
622
653
  pricingRules: {
623
654
  condition: {
@@ -1 +1 @@
1
- {"version":3,"file":"get-image-editor-config.command.d.ts","sourceRoot":"","sources":["../../../queries/image-editor/get-image-editor-config.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,yBAAiB,2BAA2B,CAAC;IAClC,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAEzB,CAAC;IACH,KAAY,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;CACzD"}
1
+ {"version":3,"file":"get-image-editor-config.command.d.ts","sourceRoot":"","sources":["../../../queries/image-editor/get-image-editor-config.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,yBAAiB,2BAA2B,CAAC;IAClC,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAEzB,CAAC;IACH,KAAY,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;CACzD"}
@@ -50,6 +50,7 @@ export declare namespace GetImageEditorJobCommand {
50
50
  imageUrls: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
51
51
  systemPromptId: z.ZodOptional<z.ZodString>;
52
52
  aspectRatio: z.ZodOptional<z.ZodString>;
53
+ resolution: z.ZodOptional<z.ZodString>;
53
54
  userHasActiveSubscriptionOrProduct: z.ZodOptional<z.ZodBoolean>;
54
55
  }, "strip", z.ZodTypeAny, {
55
56
  attachedFiles?: {
@@ -64,6 +65,7 @@ export declare namespace GetImageEditorJobCommand {
64
65
  imageUrls?: string[] | undefined;
65
66
  systemPromptId?: string | undefined;
66
67
  aspectRatio?: string | undefined;
68
+ resolution?: string | undefined;
67
69
  userHasActiveSubscriptionOrProduct?: boolean | undefined;
68
70
  }, {
69
71
  attachedFiles?: {
@@ -78,6 +80,7 @@ export declare namespace GetImageEditorJobCommand {
78
80
  imageUrls?: string[] | undefined;
79
81
  systemPromptId?: string | undefined;
80
82
  aspectRatio?: string | undefined;
83
+ resolution?: string | undefined;
81
84
  userHasActiveSubscriptionOrProduct?: boolean | undefined;
82
85
  }>;
83
86
  imageUrls: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
@@ -115,6 +118,7 @@ export declare namespace GetImageEditorJobCommand {
115
118
  imageUrls?: string[] | undefined;
116
119
  systemPromptId?: string | undefined;
117
120
  aspectRatio?: string | undefined;
121
+ resolution?: string | undefined;
118
122
  userHasActiveSubscriptionOrProduct?: boolean | undefined;
119
123
  };
120
124
  imageUrls: string[];
@@ -152,6 +156,7 @@ export declare namespace GetImageEditorJobCommand {
152
156
  imageUrls?: string[] | undefined;
153
157
  systemPromptId?: string | undefined;
154
158
  aspectRatio?: string | undefined;
159
+ resolution?: string | undefined;
155
160
  userHasActiveSubscriptionOrProduct?: boolean | undefined;
156
161
  };
157
162
  imageUrls?: string[] | undefined;
@@ -191,6 +196,7 @@ export declare namespace GetImageEditorJobCommand {
191
196
  imageUrls?: string[] | undefined;
192
197
  systemPromptId?: string | undefined;
193
198
  aspectRatio?: string | undefined;
199
+ resolution?: string | undefined;
194
200
  userHasActiveSubscriptionOrProduct?: boolean | undefined;
195
201
  };
196
202
  imageUrls: string[];
@@ -230,6 +236,7 @@ export declare namespace GetImageEditorJobCommand {
230
236
  imageUrls?: string[] | undefined;
231
237
  systemPromptId?: string | undefined;
232
238
  aspectRatio?: string | undefined;
239
+ resolution?: string | undefined;
233
240
  userHasActiveSubscriptionOrProduct?: boolean | undefined;
234
241
  };
235
242
  imageUrls?: string[] | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"get-image-editor-job.command.d.ts","sourceRoot":"","sources":["../../../queries/image-editor/get-image-editor-job.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,yBAAiB,wBAAwB,CAAC;IAC/B,MAAM,kBAAkB;;;;;;MAE7B,CAAC;IACH,KAAY,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;IAEvD,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAEzB,CAAC;IACH,KAAY,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;CACzD"}
1
+ {"version":3,"file":"get-image-editor-job.command.d.ts","sourceRoot":"","sources":["../../../queries/image-editor/get-image-editor-job.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,yBAAiB,wBAAwB,CAAC;IAC/B,MAAM,kBAAkB;;;;;;MAE7B,CAAC;IACH,KAAY,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;IAEvD,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAEzB,CAAC;IACH,KAAY,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;CACzD"}
@@ -3,7 +3,7 @@ import { z } from 'zod';
3
3
  export namespace ProxyImageEditorCallbackCommand {
4
4
  export const RequestSchema = z.object({
5
5
  jobId: z.string().min(1),
6
- imageUrl: z.string().url().optional(),
6
+ imageUrl: z.string().min(1).optional(),
7
7
  error: z.string().optional(),
8
8
  });
9
9
  export type Request = z.infer<typeof RequestSchema>;
@@ -6,4 +6,5 @@ export enum IMAGE_EDITING_STRATEGY {
6
6
  NANO_BANANA_PRO_CALLBACK = 'NANO_BANANA_PRO_CALLBACK',
7
7
  NANO_BANANA_PRO_POLLING = 'NANO_BANANA_PRO_POLLING',
8
8
  SEEDREAM_EDITING_CALLBACK = 'SEEDREAM_EDITING_CALLBACK',
9
+ OPENAI_IMAGE_2_CALLBACK = 'OPENAI_IMAGE_2_CALLBACK',
9
10
  }
@@ -1,4 +1,4 @@
1
- import { ImageGenerationJobParams, ImageGenerationPricingRules } from '../../models';
1
+ import { ImageGenerationPricingRules } from '../../models';
2
2
 
3
3
  export function calculateImageGenerationPrice({
4
4
  basePrice,
@@ -7,7 +7,9 @@ export function calculateImageGenerationPrice({
7
7
  rules,
8
8
  }: {
9
9
  basePrice: number;
10
- params: Pick<ImageGenerationJobParams, 'resolution'>;
10
+ params: {
11
+ resolution?: string;
12
+ };
11
13
  userHasActiveSubscriptionOrProduct: boolean;
12
14
  rules: ImageGenerationPricingRules;
13
15
  }): number {
package/helpers/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './image-generation';
2
2
  export * from './image-editor';
3
+ export * from './openai-image-2';
@@ -0,0 +1,160 @@
1
+ type Image2Quality = 'low' | 'medium' | 'high';
2
+ type Image2Resolution = '1K' | '2K' | '4K';
3
+ type Image2Size = { width: number; height: number };
4
+
5
+ export type OpenAIImage2PricedModel = {
6
+ aiModel: string;
7
+ params?: {
8
+ quality?: unknown;
9
+ aspectRatio?: Partial<Record<string, Image2Size | 'auto'>>;
10
+ };
11
+ };
12
+
13
+ const LOW_QUALITY_SURCHARGE_STARS = 2;
14
+ const OPENAI_OUTPUT_PRICE_PER_1M_USD = 30;
15
+ const STAR_PRICE_USD = 0.018;
16
+ const TARGET_MARGIN = 0.6;
17
+ const IMAGE_2_INPUT_IMAGE_SURCHARGE_STARS = 2;
18
+
19
+ const IMAGE_2_QUALITY_BASE_TOKENS: Record<Image2Quality, number> = {
20
+ low: 16,
21
+ medium: 48,
22
+ high: 96,
23
+ };
24
+
25
+ const IMAGE_2_RESOLUTION_MULTIPLIER: Record<Image2Resolution, number> = {
26
+ '1K': 1,
27
+ '2K': 2,
28
+ '4K': 4,
29
+ };
30
+
31
+ const IMAGE_2_MAX_EDGE = 3840;
32
+ const IMAGE_2_MAX_PIXEL_BUDGET = 8_294_400;
33
+ const IMAGE_2_SIZE_STEP = 16;
34
+
35
+ export function isOpenAIImage2Model(model: Pick<OpenAIImage2PricedModel, 'aiModel'>): boolean {
36
+ return model.aiModel.toLowerCase().startsWith('gpt-image-2');
37
+ }
38
+
39
+ export function calculateOpenAIImage2InternalPrice(params: {
40
+ model: OpenAIImage2PricedModel;
41
+ aspectRatio: string;
42
+ resolution?: string;
43
+ hasAttachedImage?: boolean;
44
+ }): number | null {
45
+ const { model, aspectRatio, resolution, hasAttachedImage = false } = params;
46
+
47
+ const quality = resolveQuality(model.aiModel, model.params?.quality);
48
+ const normalizedResolution = normalizeResolution(resolution);
49
+ const baseSize = model.params?.aspectRatio?.[aspectRatio];
50
+ if (!quality || !isImage2Size(baseSize) || !normalizedResolution) {
51
+ return null;
52
+ }
53
+
54
+ const multiplier = IMAGE_2_RESOLUTION_MULTIPLIER[normalizedResolution];
55
+ const normalizedSize = normalizeImage2SizeToOpenAILimits({
56
+ width: Math.round(baseSize.width * multiplier),
57
+ height: Math.round(baseSize.height * multiplier),
58
+ });
59
+ const outputTokens = calculateImage2OutputTokens({
60
+ quality,
61
+ ...normalizedSize,
62
+ });
63
+
64
+ const costUsd = (outputTokens / 1_000_000) * OPENAI_OUTPUT_PRICE_PER_1M_USD;
65
+ const sellUsd = costUsd / (1 - TARGET_MARGIN);
66
+
67
+ let finalStars = Math.max(1, Math.ceil(sellUsd / STAR_PRICE_USD));
68
+ if (hasAttachedImage) {
69
+ finalStars += IMAGE_2_INPUT_IMAGE_SURCHARGE_STARS;
70
+ }
71
+
72
+ if (quality === 'low') {
73
+ finalStars += LOW_QUALITY_SURCHARGE_STARS;
74
+ }
75
+
76
+ return finalStars;
77
+ }
78
+
79
+ function isImage2Size(value: unknown): value is Image2Size {
80
+ if (!value || typeof value !== 'object') return false;
81
+ const candidate = value as Partial<Image2Size>;
82
+ return typeof candidate.width === 'number' && typeof candidate.height === 'number';
83
+ }
84
+
85
+ function resolveQuality(aiModel: string, rawQuality: unknown): Image2Quality | null {
86
+ const normalizedModel = aiModel.toLowerCase();
87
+ if (normalizedModel.endsWith('-low')) return 'low';
88
+ if (normalizedModel.endsWith('-medium')) return 'medium';
89
+ if (normalizedModel.endsWith('-high')) return 'high';
90
+
91
+ if (typeof rawQuality === 'string') {
92
+ return normalizeQuality(rawQuality);
93
+ }
94
+
95
+ if (rawQuality && typeof rawQuality === 'object') {
96
+ const values = Object.values(rawQuality as Record<string, unknown>);
97
+ for (const value of values) {
98
+ if (typeof value !== 'string') continue;
99
+ const normalized = normalizeQuality(value);
100
+ if (normalized) return normalized;
101
+ }
102
+ }
103
+
104
+ return null;
105
+ }
106
+
107
+ function normalizeQuality(value: string): Image2Quality | null {
108
+ const normalized = value.trim().toLowerCase();
109
+ if (normalized === 'low') return 'low';
110
+ if (normalized === 'medium') return 'medium';
111
+ if (normalized === 'high') return 'high';
112
+ return null;
113
+ }
114
+
115
+ function normalizeResolution(value?: string): Image2Resolution | null {
116
+ if (!value) return '1K';
117
+ if (value === '1K' || value === '2K' || value === '4K') {
118
+ return value;
119
+ }
120
+ return null;
121
+ }
122
+
123
+ function normalizeImage2SizeToOpenAILimits(size: Image2Size): Image2Size {
124
+ let scale = 1;
125
+ const longestEdge = Math.max(size.width, size.height);
126
+ if (longestEdge > IMAGE_2_MAX_EDGE) {
127
+ scale = Math.min(scale, IMAGE_2_MAX_EDGE / longestEdge);
128
+ }
129
+
130
+ const pixelCount = size.width * size.height;
131
+ if (pixelCount > IMAGE_2_MAX_PIXEL_BUDGET) {
132
+ scale = Math.min(scale, Math.sqrt(IMAGE_2_MAX_PIXEL_BUDGET / pixelCount));
133
+ }
134
+
135
+ const normalizedWidth =
136
+ Math.floor((size.width * scale) / IMAGE_2_SIZE_STEP) * IMAGE_2_SIZE_STEP;
137
+ const normalizedHeight =
138
+ Math.floor((size.height * scale) / IMAGE_2_SIZE_STEP) * IMAGE_2_SIZE_STEP;
139
+
140
+ return {
141
+ width: Math.max(IMAGE_2_SIZE_STEP, normalizedWidth),
142
+ height: Math.max(IMAGE_2_SIZE_STEP, normalizedHeight),
143
+ };
144
+ }
145
+
146
+ function calculateImage2OutputTokens(params: {
147
+ quality: Image2Quality;
148
+ width: number;
149
+ height: number;
150
+ }): number {
151
+ const { quality, width, height } = params;
152
+ const longestEdge = Math.max(width, height);
153
+ const shortestEdge = Math.min(width, height);
154
+ const qualityBaseTokens = IMAGE_2_QUALITY_BASE_TOKENS[quality];
155
+ const scaledShortEdgeTokens = Math.round((qualityBaseTokens * shortestEdge) / longestEdge);
156
+ const widthTokens = width >= height ? qualityBaseTokens : scaledShortEdgeTokens;
157
+ const heightTokens = width >= height ? scaledShortEdgeTokens : qualityBaseTokens;
158
+
159
+ return Math.ceil((widthTokens * heightTokens * (2_000_000 + width * height)) / 4_000_000);
160
+ }
@@ -0,0 +1 @@
1
+ export * from './calculate-openai-image-2-price.helper';
@@ -6,6 +6,7 @@ export const ImageEditorJobParamsSchema = z.object({
6
6
  imageUrls: z.array(z.string()).optional(),
7
7
  systemPromptId: z.string().uuid().optional(),
8
8
  aspectRatio: z.string().optional(),
9
+ resolution: z.string().optional(),
9
10
  userHasActiveSubscriptionOrProduct: z.boolean().optional(),
10
11
  });
11
12