@deallony/shared 1.2.64 → 1.2.69

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 (67) hide show
  1. package/dist/cjs/constants/company/Company.d.ts +12 -0
  2. package/dist/cjs/constants/company/Company.js +13 -1
  3. package/dist/cjs/constants/events/Event.js +3 -0
  4. package/dist/cjs/constants/events/EventPricing.d.ts +44 -0
  5. package/dist/cjs/constants/events/EventPricing.js +18 -0
  6. package/dist/cjs/constants/events/index.d.ts +1 -0
  7. package/dist/cjs/constants/events/index.js +1 -0
  8. package/dist/cjs/constants/routes/app.d.ts +30 -1
  9. package/dist/cjs/constants/routes/app.js +7 -1
  10. package/dist/cjs/dto/ai/gemini-api-key.dto.d.ts +4 -1
  11. package/dist/cjs/dto/analysis/Analysis.dto.d.ts +4 -0
  12. package/dist/cjs/dto/analysis/Analysis.dto.js +2 -0
  13. package/dist/cjs/dto/events/Event.dto.d.ts +3 -1
  14. package/dist/cjs/dto/index.d.ts +1 -0
  15. package/dist/cjs/dto/index.js +2 -1
  16. package/dist/cjs/schema/ad/save-ad.schema.d.ts +35 -0
  17. package/dist/cjs/schema/ad/save-ad.schema.js +23 -1
  18. package/dist/cjs/schema/ai/gemini-api-key.schema.d.ts +46 -3
  19. package/dist/cjs/schema/ai/gemini-api-key.schema.js +36 -9
  20. package/dist/cjs/schema/analysis/analysis-report.schema.d.ts +17 -0
  21. package/dist/cjs/schema/analysis/analysis-report.schema.js +29 -0
  22. package/dist/cjs/schema/analysis/index.d.ts +1 -0
  23. package/dist/cjs/schema/analysis/index.js +17 -0
  24. package/dist/cjs/schema/communication/index.d.ts +1 -0
  25. package/dist/cjs/schema/communication/index.js +1 -0
  26. package/dist/cjs/schema/communication/offer.schema.d.ts +49 -0
  27. package/dist/cjs/schema/communication/offer.schema.js +31 -0
  28. package/dist/cjs/schema/communication/support-ticket.schema.d.ts +3 -3
  29. package/dist/cjs/schema/events/Event.schema.d.ts +20 -0
  30. package/dist/cjs/schema/events/Event.schema.js +11 -1
  31. package/dist/cjs/schema/index.d.ts +1 -0
  32. package/dist/cjs/schema/index.js +2 -1
  33. package/dist/cjs/types/ad/Ad.d.ts +27 -1
  34. package/dist/cjs/types/ad-common/PriceType.d.ts +2 -0
  35. package/dist/cjs/types/analysis/AnalysisDailySnapshot.d.ts +98 -0
  36. package/dist/cjs/types/common/MetaData.d.ts +3 -0
  37. package/dist/cjs/types/communication/Chat.d.ts +30 -1
  38. package/dist/cjs/types/communication/Chat.js +10 -1
  39. package/dist/cjs/types/company/Company.d.ts +26 -0
  40. package/dist/cjs/types/events/Event.d.ts +8 -0
  41. package/dist/cjs/types/integrations/GeminiApiKey.d.ts +11 -2
  42. package/dist/cjs/utils/analysis.d.ts +7 -0
  43. package/dist/cjs/utils/analysis.js +14 -0
  44. package/dist/cjs/utils/index.d.ts +2 -0
  45. package/dist/cjs/utils/index.js +2 -0
  46. package/dist/cjs/utils/rentPrices.d.ts +8 -0
  47. package/dist/cjs/utils/rentPrices.js +33 -0
  48. package/dist/esm/constants/company/Company.js +12 -0
  49. package/dist/esm/constants/events/Event.js +3 -0
  50. package/dist/esm/constants/events/EventPricing.js +15 -0
  51. package/dist/esm/constants/events/index.js +1 -0
  52. package/dist/esm/constants/routes/app.js +7 -1
  53. package/dist/esm/dto/analysis/Analysis.dto.js +1 -0
  54. package/dist/esm/dto/index.js +1 -0
  55. package/dist/esm/schema/ad/save-ad.schema.js +22 -0
  56. package/dist/esm/schema/ai/gemini-api-key.schema.js +35 -8
  57. package/dist/esm/schema/analysis/analysis-report.schema.js +26 -0
  58. package/dist/esm/schema/analysis/index.js +1 -0
  59. package/dist/esm/schema/communication/index.js +1 -0
  60. package/dist/esm/schema/communication/offer.schema.js +28 -0
  61. package/dist/esm/schema/events/Event.schema.js +11 -1
  62. package/dist/esm/schema/index.js +1 -0
  63. package/dist/esm/types/communication/Chat.js +9 -0
  64. package/dist/esm/utils/analysis.js +10 -0
  65. package/dist/esm/utils/index.js +2 -0
  66. package/dist/esm/utils/rentPrices.js +26 -0
  67. package/package.json +58 -58
@@ -7,3 +7,15 @@ export declare const CompanyStatusOptions: {
7
7
  value: string;
8
8
  label: string;
9
9
  }[];
10
+ /** A user's role inside a company; a company has exactly one owner */
11
+ export declare const COMPANY_MEMBER_ROLE: {
12
+ readonly OWNER: "owner";
13
+ readonly ADMIN: "admin";
14
+ readonly MEMBER: "member";
15
+ };
16
+ /** What the account represents; all three behave the same */
17
+ export declare const COMPANY_TYPE: {
18
+ readonly COMPANY: "company";
19
+ readonly TEAM: "team";
20
+ readonly OTHER: "other";
21
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CompanyStatusOptions = exports.COMPANY_STATUS = void 0;
3
+ exports.COMPANY_TYPE = exports.COMPANY_MEMBER_ROLE = exports.CompanyStatusOptions = exports.COMPANY_STATUS = void 0;
4
4
  exports.COMPANY_STATUS = {
5
5
  PENDING: 'pending',
6
6
  APPROVED: 'approved',
@@ -10,3 +10,15 @@ exports.CompanyStatusOptions = Object.values(exports.COMPANY_STATUS).map((status
10
10
  value: status,
11
11
  label: status.charAt(0).toUpperCase() + status.slice(1),
12
12
  }));
13
+ /** A user's role inside a company; a company has exactly one owner */
14
+ exports.COMPANY_MEMBER_ROLE = {
15
+ OWNER: 'owner',
16
+ ADMIN: 'admin',
17
+ MEMBER: 'member',
18
+ };
19
+ /** What the account represents; all three behave the same */
20
+ exports.COMPANY_TYPE = {
21
+ COMPANY: 'company',
22
+ TEAM: 'team',
23
+ OTHER: 'other',
24
+ };
@@ -14,6 +14,9 @@ exports.emptyEvent = {
14
14
  event_template: null,
15
15
  slug: "",
16
16
  invitation_scan_type: "none",
17
+ venue_id: null,
18
+ venue_name: null,
19
+ location_label: null,
17
20
  wedding: {
18
21
  ...EventWedding_1.emptyEventWedding,
19
22
  id: undefined,
@@ -0,0 +1,44 @@
1
+ export declare const EVENT_CREATION_PRICE_SETTING = "event_creation_price";
2
+ export type EventCreationPriceSetting = {
3
+ currencyKey: string;
4
+ company_price: number;
5
+ user_price: number;
6
+ loyalty_point_value?: number;
7
+ };
8
+ export declare const EventOwnerTypes: {
9
+ readonly COMPANY: {
10
+ readonly value: "company";
11
+ readonly name: {
12
+ readonly en: "Company";
13
+ readonly ar: "شركة";
14
+ };
15
+ };
16
+ readonly USER: {
17
+ readonly value: "user";
18
+ readonly name: {
19
+ readonly en: "Personal";
20
+ readonly ar: "شخصي";
21
+ };
22
+ };
23
+ };
24
+ export declare const EventOwnerTypeValues: readonly ["company", "user"];
25
+ export type EventOwnerType = (typeof EventOwnerTypeValues)[number];
26
+ export declare const EventOwnerTypeOptions: {
27
+ value: "company" | "user";
28
+ name: {
29
+ readonly en: "Company";
30
+ readonly ar: "شركة";
31
+ } | {
32
+ readonly en: "Personal";
33
+ readonly ar: "شخصي";
34
+ };
35
+ }[];
36
+ export declare const EventPublishPaymentMethodValues: readonly ["balance", "loyalty", "combined"];
37
+ export type EventPublishPaymentMethod = (typeof EventPublishPaymentMethodValues)[number];
38
+ export type EventPublishPrice = {
39
+ owner_type: EventOwnerType;
40
+ price_syp: number;
41
+ point_value_syp: number;
42
+ rate_badge: string;
43
+ already_paid: boolean;
44
+ };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EventPublishPaymentMethodValues = exports.EventOwnerTypeOptions = exports.EventOwnerTypeValues = exports.EventOwnerTypes = exports.EVENT_CREATION_PRICE_SETTING = void 0;
4
+ exports.EVENT_CREATION_PRICE_SETTING = "event_creation_price";
5
+ exports.EventOwnerTypes = {
6
+ COMPANY: { value: "company", name: { en: "Company", ar: "شركة" } },
7
+ USER: { value: "user", name: { en: "Personal", ar: "شخصي" } },
8
+ };
9
+ exports.EventOwnerTypeValues = ["company", "user"];
10
+ exports.EventOwnerTypeOptions = Object.values(exports.EventOwnerTypes).map((t) => ({
11
+ value: t.value,
12
+ name: t.name,
13
+ }));
14
+ exports.EventPublishPaymentMethodValues = [
15
+ "balance",
16
+ "loyalty",
17
+ "combined",
18
+ ];
@@ -4,3 +4,4 @@ export * from "./EventWedding";
4
4
  export * from "./EventTemplate";
5
5
  export * from "./EventTimeline";
6
6
  export * from "./EventInvitationScanType";
7
+ export * from "./EventPricing";
@@ -20,3 +20,4 @@ __exportStar(require("./EventWedding"), exports);
20
20
  __exportStar(require("./EventTemplate"), exports);
21
21
  __exportStar(require("./EventTimeline"), exports);
22
22
  __exportStar(require("./EventInvitationScanType"), exports);
23
+ __exportStar(require("./EventPricing"), exports);
@@ -300,6 +300,8 @@ export declare const APP_ROUTES: {
300
300
  by_message: string;
301
301
  by_whatsapp: string;
302
302
  phone: string;
303
+ /** Rent ads: JSON of [{ price_type_id, price }]; the modal then sends a rent offer */
304
+ rent_prices?: string;
303
305
  }) => {
304
306
  pathname: string;
305
307
  params: {
@@ -312,6 +314,7 @@ export declare const APP_ROUTES: {
312
314
  by_whatsapp: string;
313
315
  phone: string;
314
316
  ad_price: number;
317
+ rent_prices: string | undefined;
315
318
  };
316
319
  };
317
320
  };
@@ -378,6 +381,13 @@ export declare const APP_ROUTES: {
378
381
  id: string | number;
379
382
  };
380
383
  };
384
+ /** Public profile with the company's ads */
385
+ readonly profile: (id: number | string) => {
386
+ pathname: string;
387
+ params: {
388
+ id: string | number;
389
+ };
390
+ };
381
391
  };
382
392
  readonly venue: {
383
393
  readonly new: (companyId: number | string) => {
@@ -400,10 +410,29 @@ export declare const APP_ROUTES: {
400
410
  };
401
411
  };
402
412
  readonly event: {
403
- readonly new: (venueId: number | string) => {
413
+ readonly new: (venueId?: number | string) => {
404
414
  pathname: string;
405
415
  params: {
406
416
  venue_id: string | number;
417
+ personal?: undefined;
418
+ };
419
+ } | {
420
+ pathname: string;
421
+ params: {
422
+ personal: string;
423
+ venue_id?: undefined;
424
+ };
425
+ };
426
+ readonly start: () => {
427
+ pathname: string;
428
+ };
429
+ readonly mine: () => {
430
+ pathname: string;
431
+ };
432
+ readonly publish: (id: number | string) => {
433
+ pathname: string;
434
+ params: {
435
+ id: string | number;
407
436
  };
408
437
  };
409
438
  readonly edit: (id: number | string) => {
@@ -138,6 +138,7 @@ exports.APP_ROUTES = {
138
138
  by_whatsapp: props.by_whatsapp,
139
139
  phone: props.phone,
140
140
  ad_price: props.ad_price,
141
+ rent_prices: props.rent_prices,
141
142
  },
142
143
  }),
143
144
  },
@@ -168,6 +169,8 @@ exports.APP_ROUTES = {
168
169
  new: () => ({ pathname: "/company/new" }),
169
170
  edit: (id) => ({ pathname: "/company/new", params: { id } }),
170
171
  details: (id) => ({ pathname: "/company/details/[id]", params: { id } }),
172
+ /** Public profile with the company's ads */
173
+ profile: (id) => ({ pathname: "/company/profile/[id]", params: { id } }),
171
174
  },
172
175
  venue: {
173
176
  new: (companyId) => ({ pathname: "/venue/new", params: { company_id: companyId } }),
@@ -175,7 +178,10 @@ exports.APP_ROUTES = {
175
178
  details: (id) => ({ pathname: "/venue/details/[id]", params: { id } }),
176
179
  },
177
180
  event: {
178
- new: (venueId) => ({ pathname: "/event/new", params: { venue_id: venueId } }),
181
+ new: (venueId) => venueId ? { pathname: "/event/new", params: { venue_id: venueId } } : { pathname: "/event/new", params: { personal: "1" } },
182
+ start: () => ({ pathname: "/event/start" }),
183
+ mine: () => ({ pathname: "/event/mine" }),
184
+ publish: (id) => ({ pathname: "/event/publish/[id]", params: { id } }),
179
185
  edit: (id) => ({ pathname: "/event/new", params: { id } }),
180
186
  details: (id) => ({ pathname: "/event/details/[id]", params: { id } }),
181
187
  },
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { createGeminiApiKeySchema, geminiApiKeyIdBodySchema, leasedGeminiApiKeySchema, leaseGeminiApiKeySchema, reorderGeminiApiKeysSchema, reportGeminiApiKeyUsageSchema, updateGeminiApiKeySchema } from '../../schema/ai/gemini-api-key.schema';
2
+ import { aiKeySettingsSchema, aiProviderSchema, aiKeySelectionModeSchema, createGeminiApiKeySchema, geminiApiKeyIdBodySchema, leasedGeminiApiKeySchema, leaseGeminiApiKeySchema, reorderGeminiApiKeysSchema, reportGeminiApiKeyUsageSchema, updateGeminiApiKeySchema } from '../../schema/ai/gemini-api-key.schema';
3
3
  export type CreateGeminiApiKeyDto = z.input<typeof createGeminiApiKeySchema>;
4
4
  export type UpdateGeminiApiKeyDto = z.input<typeof updateGeminiApiKeySchema>;
5
5
  export type GeminiApiKeyIdBodyDto = z.input<typeof geminiApiKeyIdBodySchema>;
@@ -7,3 +7,6 @@ export type ReorderGeminiApiKeysDto = z.input<typeof reorderGeminiApiKeysSchema>
7
7
  export type LeaseGeminiApiKeyDto = z.input<typeof leaseGeminiApiKeySchema>;
8
8
  export type LeasedGeminiApiKey = z.infer<typeof leasedGeminiApiKeySchema>;
9
9
  export type ReportGeminiApiKeyUsageDto = z.input<typeof reportGeminiApiKeyUsageSchema>;
10
+ export type AiProvider = z.infer<typeof aiProviderSchema>;
11
+ export type AiKeySelectionMode = z.infer<typeof aiKeySelectionModeSchema>;
12
+ export type AiKeySettingsDto = z.input<typeof aiKeySettingsSchema>;
@@ -0,0 +1,4 @@
1
+ import { z } from "zod";
2
+ import { analysisRebuildSchema, analysisReportSchema } from "../../schema/analysis/analysis-report.schema";
3
+ export type AnalysisReportDto = z.input<typeof analysisReportSchema>;
4
+ export type AnalysisRebuildDto = z.input<typeof analysisRebuildSchema>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,8 @@
1
1
  import { z } from 'zod';
2
- import { createEventSchema, getEventsFilterSchema, saveEventSchema, updateEventSchema } from '../../schema/events/Event.schema';
2
+ import { createEventSchema, eventIdSchema, getEventsFilterSchema, publishEventSchema, saveEventSchema, updateEventSchema } from '../../schema/events/Event.schema';
3
3
  export type CreateEventDto = z.infer<typeof createEventSchema>;
4
4
  export type UpdateEventDto = z.infer<typeof updateEventSchema>;
5
5
  export type SaveEventDto = z.infer<typeof saveEventSchema>;
6
6
  export type GetEventsFilterDto = z.infer<typeof getEventsFilterSchema>;
7
+ export type PublishEventDto = z.infer<typeof publishEventSchema>;
8
+ export type EventIdDto = z.infer<typeof eventIdSchema>;
@@ -6,3 +6,4 @@ export * as GEMINI_API_KEYS from './ai/gemini-api-key.dto';
6
6
  export * as PAYMENTS from './payments';
7
7
  export * as ADDRESSES from './addresses/addresses.dto';
8
8
  export * as POTENTIAL_USERS from './potential-users/potential-user-import.dto';
9
+ export * as ANALYSIS from './analysis/Analysis.dto';
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.POTENTIAL_USERS = exports.ADDRESSES = exports.PAYMENTS = exports.GEMINI_API_KEYS = exports.Ai = exports.EVENTS = exports.AD = exports.AdDto = void 0;
36
+ exports.ANALYSIS = exports.POTENTIAL_USERS = exports.ADDRESSES = exports.PAYMENTS = exports.GEMINI_API_KEYS = exports.Ai = exports.EVENTS = exports.AD = exports.AdDto = void 0;
37
37
  var Ad_dto_1 = require("./ad/Ad.dto");
38
38
  Object.defineProperty(exports, "AdDto", { enumerable: true, get: function () { return Ad_dto_1.AdDto; } });
39
39
  exports.AD = __importStar(require("./ad/Ad.dto"));
@@ -43,3 +43,4 @@ exports.GEMINI_API_KEYS = __importStar(require("./ai/gemini-api-key.dto"));
43
43
  exports.PAYMENTS = __importStar(require("./payments"));
44
44
  exports.ADDRESSES = __importStar(require("./addresses/addresses.dto"));
45
45
  exports.POTENTIAL_USERS = __importStar(require("./potential-users/potential-user-import.dto"));
46
+ exports.ANALYSIS = __importStar(require("./analysis/Analysis.dto"));
@@ -6,6 +6,17 @@ export declare const subjectTypeSchema: z.ZodEnum<{
6
6
  used_products: "used_products";
7
7
  }>;
8
8
  export declare const adMediaSchema: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodAny>>>;
9
+ /** One rent price per period. Backend checks the period belongs to "For Rent". */
10
+ export declare const adRentPriceSchema: z.ZodObject<{
11
+ price_type_id: z.ZodCoercedNumber<unknown>;
12
+ price: z.ZodCoercedNumber<unknown>;
13
+ is_main: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
14
+ }, z.core.$strip>;
15
+ export declare const adRentPricesSchema: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
16
+ price_type_id: z.ZodCoercedNumber<unknown>;
17
+ price: z.ZodCoercedNumber<unknown>;
18
+ is_main: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
19
+ }, z.core.$strip>>>>;
9
20
  export declare const createAdSchema: z.ZodObject<{
10
21
  motor: z.ZodNullable<z.ZodOptional<z.ZodObject<{
11
22
  ad_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
@@ -92,11 +103,17 @@ export declare const createAdSchema: z.ZodObject<{
92
103
  by_call: z.ZodOptional<z.ZodBoolean>;
93
104
  }, z.core.$strip>>>;
94
105
  selected_phone: z.ZodNullable<z.ZodOptional<z.ZodString>>;
106
+ company_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
95
107
  expires_at: z.ZodNullable<z.ZodOptional<z.ZodISODateTime>>;
96
108
  adLocations: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
97
109
  ad_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
98
110
  admin_boundary_id: z.ZodCoercedNumber<unknown>;
99
111
  }, z.core.$strip>>>>;
112
+ rent_prices: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
113
+ price_type_id: z.ZodCoercedNumber<unknown>;
114
+ price: z.ZodCoercedNumber<unknown>;
115
+ is_main: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
116
+ }, z.core.$strip>>>>;
100
117
  user_id: z.ZodCoercedNumber<unknown>;
101
118
  id: z.ZodOptional<z.ZodNull>;
102
119
  }, z.core.$strip>;
@@ -190,11 +207,17 @@ export declare const updateAdSchema: z.ZodObject<{
190
207
  by_call: z.ZodOptional<z.ZodBoolean>;
191
208
  }, z.core.$strip>>>;
192
209
  selected_phone: z.ZodNullable<z.ZodOptional<z.ZodString>>;
210
+ company_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
193
211
  expires_at: z.ZodNullable<z.ZodOptional<z.ZodISODateTime>>;
194
212
  adLocations: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
195
213
  ad_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
196
214
  admin_boundary_id: z.ZodCoercedNumber<unknown>;
197
215
  }, z.core.$strip>>>>;
216
+ rent_prices: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
217
+ price_type_id: z.ZodCoercedNumber<unknown>;
218
+ price: z.ZodCoercedNumber<unknown>;
219
+ is_main: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
220
+ }, z.core.$strip>>>>;
198
221
  user_id: z.ZodCoercedNumber<unknown>;
199
222
  }, z.core.$strip>;
200
223
  export declare const saveAdSchema: z.ZodUnion<readonly [z.ZodObject<{
@@ -283,11 +306,17 @@ export declare const saveAdSchema: z.ZodUnion<readonly [z.ZodObject<{
283
306
  by_call: z.ZodOptional<z.ZodBoolean>;
284
307
  }, z.core.$strip>>>;
285
308
  selected_phone: z.ZodNullable<z.ZodOptional<z.ZodString>>;
309
+ company_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
286
310
  expires_at: z.ZodNullable<z.ZodOptional<z.ZodISODateTime>>;
287
311
  adLocations: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
288
312
  ad_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
289
313
  admin_boundary_id: z.ZodCoercedNumber<unknown>;
290
314
  }, z.core.$strip>>>>;
315
+ rent_prices: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
316
+ price_type_id: z.ZodCoercedNumber<unknown>;
317
+ price: z.ZodCoercedNumber<unknown>;
318
+ is_main: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
319
+ }, z.core.$strip>>>>;
291
320
  user_id: z.ZodCoercedNumber<unknown>;
292
321
  id: z.ZodOptional<z.ZodNull>;
293
322
  }, z.core.$strip>, z.ZodObject<{
@@ -380,10 +409,16 @@ export declare const saveAdSchema: z.ZodUnion<readonly [z.ZodObject<{
380
409
  by_call: z.ZodOptional<z.ZodBoolean>;
381
410
  }, z.core.$strip>>>;
382
411
  selected_phone: z.ZodNullable<z.ZodOptional<z.ZodString>>;
412
+ company_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
383
413
  expires_at: z.ZodNullable<z.ZodOptional<z.ZodISODateTime>>;
384
414
  adLocations: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
385
415
  ad_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
386
416
  admin_boundary_id: z.ZodCoercedNumber<unknown>;
387
417
  }, z.core.$strip>>>>;
418
+ rent_prices: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
419
+ price_type_id: z.ZodCoercedNumber<unknown>;
420
+ price: z.ZodCoercedNumber<unknown>;
421
+ is_main: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
422
+ }, z.core.$strip>>>>;
388
423
  user_id: z.ZodCoercedNumber<unknown>;
389
424
  }, z.core.$strip>]>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.saveAdSchema = exports.updateAdSchema = exports.createAdSchema = exports.adMediaSchema = exports.subjectTypeSchema = void 0;
3
+ exports.saveAdSchema = exports.updateAdSchema = exports.createAdSchema = exports.adRentPricesSchema = exports.adRentPriceSchema = exports.adMediaSchema = exports.subjectTypeSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const AdMedia_1 = require("../../constants/ad/AdMedia");
6
6
  const adMedia_1 = require("../../utils/adMedia");
@@ -166,6 +166,26 @@ exports.adMediaSchema = zod_1.z
166
166
  })
167
167
  .optional()
168
168
  .nullable();
169
+ /** One rent price per period. Backend checks the period belongs to "For Rent". */
170
+ exports.adRentPriceSchema = zod_1.z.object({
171
+ price_type_id: zod_1.z.coerce.number().int().positive(),
172
+ price: zod_1.z.coerce.number().positive(),
173
+ is_main: zod_1.z.coerce.boolean().optional(),
174
+ });
175
+ exports.adRentPricesSchema = zod_1.z
176
+ .array(exports.adRentPriceSchema)
177
+ .max(10)
178
+ .superRefine((prices, ctx) => {
179
+ const ids = prices.map((item) => item.price_type_id);
180
+ if (new Set(ids).size !== ids.length) {
181
+ ctx.addIssue({ code: "custom", message: "Each rent period can be listed once" });
182
+ }
183
+ if (prices.filter((item) => item.is_main).length > 1) {
184
+ ctx.addIssue({ code: "custom", message: "Only one rent price can be the main price" });
185
+ }
186
+ })
187
+ .optional()
188
+ .nullable();
169
189
  const baseAdCommon = zod_1.z.object({
170
190
  title: zod_1.z.string().trim().optional(),
171
191
  status_id: zod_1.z.coerce.number().int().positive().optional(),
@@ -194,8 +214,10 @@ const baseAdCommon = zod_1.z.object({
194
214
  .optional()
195
215
  .nullable(),
196
216
  selected_phone: zod_1.z.string().trim().optional().nullable(),
217
+ company_id: zod_1.z.coerce.number().int().positive().optional().nullable(),
197
218
  expires_at: zod_1.z.iso.datetime().optional().nullable(),
198
219
  adLocations: zod_1.z.array(adLocationSchema).optional().nullable(),
220
+ rent_prices: exports.adRentPricesSchema,
199
221
  });
200
222
  exports.createAdSchema = zod_1.z.object({
201
223
  user_id: zod_1.z.coerce.number().int().positive(),
@@ -1,8 +1,29 @@
1
1
  import { z } from 'zod';
2
- /** Gemini model ID, e.g. gemini-3.1-flash-lite */
2
+ /** Which company's API a key belongs to: Google Gemini or Anthropic Claude */
3
+ export declare const AI_PROVIDERS: readonly ["gemini", "anthropic"];
4
+ export declare const aiProviderSchema: z.ZodEnum<{
5
+ gemini: "gemini";
6
+ anthropic: "anthropic";
7
+ }>;
8
+ /** Models offered in the dashboard for each provider; any other model ID can still be typed */
9
+ export declare const AI_PROVIDER_MODELS: Record<(typeof AI_PROVIDERS)[number], readonly string[]>;
10
+ /**
11
+ * How backend-core picks a key: `priority` always takes the first available key in the dashboard
12
+ * order, `balanced` takes the key with the fewest tokens used today.
13
+ */
14
+ export declare const AI_KEY_SELECTION_MODES: readonly ["priority", "balanced"];
15
+ export declare const aiKeySelectionModeSchema: z.ZodEnum<{
16
+ priority: "priority";
17
+ balanced: "balanced";
18
+ }>;
19
+ /** Default model ID of a key, e.g. gemini-3.1-flash-lite or claude-haiku-5-5 */
3
20
  export declare const geminiModelNameSchema: z.ZodString;
4
21
  export declare const createGeminiApiKeySchema: z.ZodObject<{
5
22
  name: z.ZodString;
23
+ provider: z.ZodDefault<z.ZodEnum<{
24
+ gemini: "gemini";
25
+ anthropic: "anthropic";
26
+ }>>;
6
27
  api_key: z.ZodString;
7
28
  model_name: z.ZodString;
8
29
  is_active: z.ZodDefault<z.ZodBoolean>;
@@ -11,6 +32,10 @@ export declare const createGeminiApiKeySchema: z.ZodObject<{
11
32
  export declare const updateGeminiApiKeySchema: z.ZodObject<{
12
33
  id: z.ZodCoercedNumber<unknown>;
13
34
  name: z.ZodOptional<z.ZodString>;
35
+ provider: z.ZodOptional<z.ZodEnum<{
36
+ gemini: "gemini";
37
+ anthropic: "anthropic";
38
+ }>>;
14
39
  api_key: z.ZodOptional<z.ZodString>;
15
40
  model_name: z.ZodOptional<z.ZodString>;
16
41
  is_active: z.ZodOptional<z.ZodBoolean>;
@@ -22,16 +47,34 @@ export declare const geminiApiKeyIdBodySchema: z.ZodObject<{
22
47
  export declare const reorderGeminiApiKeysSchema: z.ZodObject<{
23
48
  ids: z.ZodArray<z.ZodCoercedNumber<unknown>>;
24
49
  }, z.core.$strip>;
25
- /** Ask backend-core for the least-used available key, optionally only keys for one model. */
50
+ export declare const aiKeySettingsSchema: z.ZodObject<{
51
+ selection_mode: z.ZodEnum<{
52
+ priority: "priority";
53
+ balanced: "balanced";
54
+ }>;
55
+ }, z.core.$strip>;
56
+ /**
57
+ * Ask backend-core for the next available key. `exclude_ids` are keys that already failed for
58
+ * this call, so a retry moves on to the next key in the order.
59
+ */
26
60
  export declare const leaseGeminiApiKeySchema: z.ZodObject<{
27
61
  model_name: z.ZodOptional<z.ZodString>;
62
+ providers: z.ZodOptional<z.ZodArray<z.ZodEnum<{
63
+ gemini: "gemini";
64
+ anthropic: "anthropic";
65
+ }>>>;
66
+ exclude_ids: z.ZodOptional<z.ZodArray<z.ZodCoercedNumber<unknown>>>;
28
67
  }, z.core.$strip>;
29
68
  export declare const leasedGeminiApiKeySchema: z.ZodObject<{
30
69
  id: z.ZodNumber;
70
+ provider: z.ZodEnum<{
71
+ gemini: "gemini";
72
+ anthropic: "anthropic";
73
+ }>;
31
74
  api_key: z.ZodString;
32
75
  model_name: z.ZodString;
33
76
  }, z.core.$strip>;
34
- /** Sent after every Gemini call made with a leased key. */
77
+ /** Sent after every AI call made with a leased key. */
35
78
  export declare const reportGeminiApiKeyUsageSchema: z.ZodObject<{
36
79
  id: z.ZodCoercedNumber<unknown>;
37
80
  total_tokens: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
@@ -1,18 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.reportGeminiApiKeyUsageSchema = exports.leasedGeminiApiKeySchema = exports.leaseGeminiApiKeySchema = exports.reorderGeminiApiKeysSchema = exports.geminiApiKeyIdBodySchema = exports.updateGeminiApiKeySchema = exports.createGeminiApiKeySchema = exports.geminiModelNameSchema = void 0;
3
+ exports.reportGeminiApiKeyUsageSchema = exports.leasedGeminiApiKeySchema = exports.leaseGeminiApiKeySchema = exports.aiKeySettingsSchema = exports.reorderGeminiApiKeysSchema = exports.geminiApiKeyIdBodySchema = exports.updateGeminiApiKeySchema = exports.createGeminiApiKeySchema = exports.geminiModelNameSchema = exports.aiKeySelectionModeSchema = exports.AI_KEY_SELECTION_MODES = exports.AI_PROVIDER_MODELS = exports.aiProviderSchema = exports.AI_PROVIDERS = void 0;
4
4
  const zod_1 = require("zod");
5
5
  /**
6
- * Gemini API keys are stored in backend-core (one table) and shared by every Deallony service.
7
- * The dashboard manages them through the admin schemas; other services lease a key and report
8
- * the tokens they used through the internal schemas.
6
+ * AI API keys (Gemini and Claude) are stored in backend-core (one table) and shared by every
7
+ * Deallony service. The dashboard manages them through the admin schemas; other services lease a
8
+ * key and report the tokens they used through the internal schemas.
9
9
  */
10
10
  const geminiApiKeyIdSchema = zod_1.z.coerce.number().int().positive();
11
- /** Gemini model ID, e.g. gemini-3.1-flash-lite */
11
+ /** Which company's API a key belongs to: Google Gemini or Anthropic Claude */
12
+ exports.AI_PROVIDERS = ['gemini', 'anthropic'];
13
+ exports.aiProviderSchema = zod_1.z.enum(exports.AI_PROVIDERS);
14
+ /** Models offered in the dashboard for each provider; any other model ID can still be typed */
15
+ exports.AI_PROVIDER_MODELS = {
16
+ gemini: ['gemini-3.5-flash-lite', 'gemini-3.1-flash-lite'],
17
+ anthropic: ['claude-haiku-5-5', 'claude-sonnet-5-5', 'claude-opus-5-5'],
18
+ };
19
+ /**
20
+ * How backend-core picks a key: `priority` always takes the first available key in the dashboard
21
+ * order, `balanced` takes the key with the fewest tokens used today.
22
+ */
23
+ exports.AI_KEY_SELECTION_MODES = ['priority', 'balanced'];
24
+ exports.aiKeySelectionModeSchema = zod_1.z.enum(exports.AI_KEY_SELECTION_MODES);
25
+ /** Default model ID of a key, e.g. gemini-3.1-flash-lite or claude-haiku-5-5 */
12
26
  exports.geminiModelNameSchema = zod_1.z.string().trim().min(1).max(100);
13
27
  // ---------- Admin (dashboard) ----------
14
28
  exports.createGeminiApiKeySchema = zod_1.z.object({
15
29
  name: zod_1.z.string().trim().min(1).max(255),
30
+ provider: exports.aiProviderSchema.default('gemini'),
16
31
  api_key: zod_1.z.string().trim().min(20).max(512),
17
32
  model_name: exports.geminiModelNameSchema,
18
33
  is_active: zod_1.z.boolean().default(true),
@@ -21,6 +36,7 @@ exports.createGeminiApiKeySchema = zod_1.z.object({
21
36
  exports.updateGeminiApiKeySchema = zod_1.z.object({
22
37
  id: geminiApiKeyIdSchema,
23
38
  name: zod_1.z.string().trim().min(1).max(255).optional(),
39
+ provider: exports.aiProviderSchema.optional(),
24
40
  api_key: zod_1.z.string().trim().min(20).max(512).optional(),
25
41
  model_name: exports.geminiModelNameSchema.optional(),
26
42
  is_active: zod_1.z.boolean().optional(),
@@ -32,23 +48,34 @@ exports.geminiApiKeyIdBodySchema = zod_1.z.object({
32
48
  exports.reorderGeminiApiKeysSchema = zod_1.z.object({
33
49
  ids: zod_1.z.array(geminiApiKeyIdSchema).min(1),
34
50
  });
51
+ exports.aiKeySettingsSchema = zod_1.z.object({
52
+ selection_mode: exports.aiKeySelectionModeSchema,
53
+ });
35
54
  // ---------- Internal (other services) ----------
36
- /** Ask backend-core for the least-used available key, optionally only keys for one model. */
55
+ /**
56
+ * Ask backend-core for the next available key. `exclude_ids` are keys that already failed for
57
+ * this call, so a retry moves on to the next key in the order.
58
+ */
37
59
  exports.leaseGeminiApiKeySchema = zod_1.z.object({
60
+ /** Only keys whose default model is this one */
38
61
  model_name: exports.geminiModelNameSchema.optional(),
62
+ /** Only keys of these providers; all providers when left out */
63
+ providers: zod_1.z.array(exports.aiProviderSchema).min(1).optional(),
64
+ exclude_ids: zod_1.z.array(geminiApiKeyIdSchema).optional(),
39
65
  });
40
66
  exports.leasedGeminiApiKeySchema = zod_1.z.object({
41
67
  id: zod_1.z.number().int().positive(),
68
+ provider: exports.aiProviderSchema,
42
69
  api_key: zod_1.z.string(),
43
70
  model_name: zod_1.z.string(),
44
71
  });
45
- /** Sent after every Gemini call made with a leased key. */
72
+ /** Sent after every AI call made with a leased key. */
46
73
  exports.reportGeminiApiKeyUsageSchema = zod_1.z.object({
47
74
  id: geminiApiKeyIdSchema,
48
- /** usageMetadata.totalTokenCount of the Gemini response; 0 when the call failed */
75
+ /** Total tokens of the response (input + output); 0 when the call failed */
49
76
  total_tokens: zod_1.z.coerce.number().int().min(0).default(0),
50
77
  success: zod_1.z.boolean().default(true),
51
- /** HTTP status Gemini answered with, e.g. 429 */
78
+ /** HTTP status the provider answered with, e.g. 429 */
52
79
  error_code: zod_1.z.coerce.number().int().optional(),
53
80
  error_message: zod_1.z.string().trim().max(2000).optional(),
54
81
  });
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+ /** `metrics_version` of snapshots holding daily views (older snapshots held all-time totals) */
3
+ export declare const ANALYSIS_METRICS_VERSION = 2;
4
+ /** Longest period one analysis report covers */
5
+ export declare const ANALYSIS_REPORT_MAX_DAYS = 366;
6
+ /** Longest period rebuilt in one request; daily view records older than 180 days are deleted anyway */
7
+ export declare const ANALYSIS_REBUILD_MAX_DAYS = 180;
8
+ /** Body of `POST admin/analysis/snapshots/report`: one day when `from` equals `to` */
9
+ export declare const analysisReportSchema: z.ZodObject<{
10
+ from: z.ZodString;
11
+ to: z.ZodString;
12
+ }, z.core.$strip>;
13
+ /** Body of `POST admin/analysis/snapshots/rebuild`: recalculates the snapshots of these days */
14
+ export declare const analysisRebuildSchema: z.ZodObject<{
15
+ from: z.ZodString;
16
+ to: z.ZodString;
17
+ }, z.core.$strip>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.analysisRebuildSchema = exports.analysisReportSchema = exports.ANALYSIS_REBUILD_MAX_DAYS = exports.ANALYSIS_REPORT_MAX_DAYS = exports.ANALYSIS_METRICS_VERSION = void 0;
4
+ const zod_1 = require("zod");
5
+ /** `metrics_version` of snapshots holding daily views (older snapshots held all-time totals) */
6
+ exports.ANALYSIS_METRICS_VERSION = 2;
7
+ /** Longest period one analysis report covers */
8
+ exports.ANALYSIS_REPORT_MAX_DAYS = 366;
9
+ /** Longest period rebuilt in one request; daily view records older than 180 days are deleted anyway */
10
+ exports.ANALYSIS_REBUILD_MAX_DAYS = 180;
11
+ const DAY_MS = 24 * 60 * 60 * 1000;
12
+ const day = zod_1.z
13
+ .string()
14
+ .trim()
15
+ .regex(/^\d{4}-\d{2}-\d{2}$/, 'Use YYYY-MM-DD')
16
+ .refine((value) => !Number.isNaN(Date.parse(`${value}T00:00:00Z`)), 'Invalid date');
17
+ /** Days in `from`..`to`, both included */
18
+ const spanDays = ({ from, to }) => Math.round((Date.parse(`${to}T00:00:00Z`) - Date.parse(`${from}T00:00:00Z`)) / DAY_MS) + 1;
19
+ const period = (maxDays) => zod_1.z
20
+ .object({ from: day, to: day })
21
+ .refine((value) => value.from <= value.to, { message: '`from` must not be after `to`', path: ['to'] })
22
+ .refine((value) => spanDays(value) <= maxDays, {
23
+ message: `The period can be at most ${maxDays} days`,
24
+ path: ['from'],
25
+ });
26
+ /** Body of `POST admin/analysis/snapshots/report`: one day when `from` equals `to` */
27
+ exports.analysisReportSchema = period(exports.ANALYSIS_REPORT_MAX_DAYS);
28
+ /** Body of `POST admin/analysis/snapshots/rebuild`: recalculates the snapshots of these days */
29
+ exports.analysisRebuildSchema = period(exports.ANALYSIS_REBUILD_MAX_DAYS);
@@ -0,0 +1 @@
1
+ export * from './analysis-report.schema';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./analysis-report.schema"), exports);