@deallony/shared 1.2.54 → 1.2.55

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.
@@ -4,3 +4,4 @@ export * as EVENTS from './events';
4
4
  export * as Ai from './ai/Ai.dto';
5
5
  export * as PAYMENTS from './payments';
6
6
  export * as ADDRESSES from './addresses/addresses.dto';
7
+ export * as POTENTIAL_USERS from './potential-users/potential-user-import.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.ADDRESSES = exports.PAYMENTS = exports.Ai = exports.EVENTS = exports.AD = exports.AdDto = void 0;
36
+ exports.POTENTIAL_USERS = exports.ADDRESSES = exports.PAYMENTS = 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"));
@@ -41,3 +41,4 @@ exports.EVENTS = __importStar(require("./events"));
41
41
  exports.Ai = __importStar(require("./ai/Ai.dto"));
42
42
  exports.PAYMENTS = __importStar(require("./payments"));
43
43
  exports.ADDRESSES = __importStar(require("./addresses/addresses.dto"));
44
+ exports.POTENTIAL_USERS = __importStar(require("./potential-users/potential-user-import.dto"));
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+ import { PotentialUserImportContactSchema, PotentialUserImportResultSchema, PotentialUserImportSchema, PotentialUserSourceTypeSchema } from '../../schema/potential-users/potential-user-import.schema';
3
+ export type PotentialUserSourceType = z.infer<typeof PotentialUserSourceTypeSchema>;
4
+ export type PotentialUserImportContact = z.input<typeof PotentialUserImportContactSchema>;
5
+ export type PotentialUserImport = z.input<typeof PotentialUserImportSchema>;
6
+ export type PotentialUserImportResult = z.infer<typeof PotentialUserImportResultSchema>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -6,8 +6,8 @@ export declare const MarketingSubjectTypeSchema: z.ZodEnum<{
6
6
  used_products: "used_products";
7
7
  }>;
8
8
  export declare const ConversationLanguageSchema: z.ZodEnum<{
9
- en: "en";
10
9
  ar: "ar";
10
+ en: "en";
11
11
  }>;
12
12
  export declare const StartAiConversationSchema: z.ZodObject<{
13
13
  request_id: z.ZodString;
@@ -15,8 +15,8 @@ export declare const StartAiConversationSchema: z.ZodObject<{
15
15
  user_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
16
16
  phone: z.ZodString;
17
17
  language: z.ZodDefault<z.ZodEnum<{
18
- en: "en";
19
18
  ar: "ar";
19
+ en: "en";
20
20
  }>>;
21
21
  purpose: z.ZodLiteral<"marketing">;
22
22
  subject_type: z.ZodEnum<{
@@ -5,3 +5,4 @@ export * as EVENTS from './events';
5
5
  export * as PAYMENTS from './payments';
6
6
  export * as COMMUNICATION from './communication';
7
7
  export * as ADDRESSES from './addresses/addresses.schema';
8
+ export * as POTENTIAL_USERS from './potential-users';
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ADDRESSES = exports.COMMUNICATION = exports.PAYMENTS = exports.EVENTS = exports.COMMON = exports.AI = exports.AD = void 0;
36
+ exports.POTENTIAL_USERS = exports.ADDRESSES = exports.COMMUNICATION = exports.PAYMENTS = exports.EVENTS = exports.COMMON = exports.AI = exports.AD = void 0;
37
37
  exports.AD = __importStar(require("./ad"));
38
38
  exports.AI = __importStar(require("./ai"));
39
39
  exports.COMMON = __importStar(require("./common"));
@@ -41,3 +41,4 @@ exports.EVENTS = __importStar(require("./events"));
41
41
  exports.PAYMENTS = __importStar(require("./payments"));
42
42
  exports.COMMUNICATION = __importStar(require("./communication"));
43
43
  exports.ADDRESSES = __importStar(require("./addresses/addresses.schema"));
44
+ exports.POTENTIAL_USERS = __importStar(require("./potential-users"));
@@ -0,0 +1 @@
1
+ export * from './potential-user-import.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("./potential-user-import.schema"), exports);
@@ -0,0 +1,52 @@
1
+ import { z } from 'zod';
2
+ /** Where a potential user came from. One person can have several sources. */
3
+ export declare const PotentialUserSourceTypeSchema: z.ZodEnum<{
4
+ employee: "employee";
5
+ qatayef_collect: "qatayef_collect";
6
+ }>;
7
+ /** Most contacts one import request may carry */
8
+ export declare const POTENTIAL_USER_IMPORT_MAX_BATCH = 500;
9
+ /** One contact found by an internal service, e.g. a phone collected from a website. */
10
+ export declare const PotentialUserImportContactSchema: z.ZodObject<{
11
+ external_id: z.ZodString;
12
+ phone: z.ZodString;
13
+ name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
14
+ website: z.ZodString;
15
+ source_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
16
+ subject_type: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
17
+ properties: "properties";
18
+ services: "services";
19
+ motors: "motors";
20
+ used_products: "used_products";
21
+ }>>>;
22
+ data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
23
+ }, z.core.$strip>;
24
+ export declare const PotentialUserImportSchema: z.ZodObject<{
25
+ source_type: z.ZodDefault<z.ZodEnum<{
26
+ qatayef_collect: "qatayef_collect";
27
+ }>>;
28
+ contacts: z.ZodArray<z.ZodObject<{
29
+ external_id: z.ZodString;
30
+ phone: z.ZodString;
31
+ name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
32
+ website: z.ZodString;
33
+ source_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
34
+ subject_type: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
35
+ properties: "properties";
36
+ services: "services";
37
+ motors: "motors";
38
+ used_products: "used_products";
39
+ }>>>;
40
+ data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
41
+ }, z.core.$strip>>;
42
+ }, z.core.$strip>;
43
+ export declare const PotentialUserImportResultSchema: z.ZodObject<{
44
+ external_id: z.ZodString;
45
+ status: z.ZodEnum<{
46
+ created: "created";
47
+ updated: "updated";
48
+ skipped: "skipped";
49
+ }>;
50
+ potential_user_id: z.ZodNullable<z.ZodNumber>;
51
+ reason: z.ZodNullable<z.ZodString>;
52
+ }, z.core.$strip>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PotentialUserImportResultSchema = exports.PotentialUserImportSchema = exports.PotentialUserImportContactSchema = exports.POTENTIAL_USER_IMPORT_MAX_BATCH = exports.PotentialUserSourceTypeSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const ai_conversation_schema_1 = require("../communication/ai-conversation.schema");
6
+ /** Where a potential user came from. One person can have several sources. */
7
+ exports.PotentialUserSourceTypeSchema = zod_1.z.enum(['employee', 'qatayef_collect']);
8
+ /** Most contacts one import request may carry */
9
+ exports.POTENTIAL_USER_IMPORT_MAX_BATCH = 500;
10
+ /** One contact found by an internal service, e.g. a phone collected from a website. */
11
+ exports.PotentialUserImportContactSchema = zod_1.z.object({
12
+ /** The caller's own ID for this contact, echoed back in the result */
13
+ external_id: zod_1.z.string().trim().min(1).max(100),
14
+ /** E.164, e.g. +971501234567 */
15
+ phone: zod_1.z.string().trim().regex(/^\+[1-9]\d{6,14}$/, 'phone must be in E.164 format'),
16
+ name: zod_1.z.string().trim().max(255).nullish(),
17
+ /** The website the contact was found on, e.g. dubizzle.com; one source per website */
18
+ website: zod_1.z.string().trim().min(1).max(253),
19
+ source_url: zod_1.z.string().trim().url().max(2048).nullish(),
20
+ subject_type: ai_conversation_schema_1.MarketingSubjectTypeSchema.nullish(),
21
+ /** Fields without a column (email, price, listing title, listings count, ...) */
22
+ data: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).default({}),
23
+ });
24
+ exports.PotentialUserImportSchema = zod_1.z.object({
25
+ source_type: exports.PotentialUserSourceTypeSchema.exclude(['employee']).default('qatayef_collect'),
26
+ contacts: zod_1.z.array(exports.PotentialUserImportContactSchema).min(1).max(exports.POTENTIAL_USER_IMPORT_MAX_BATCH),
27
+ });
28
+ exports.PotentialUserImportResultSchema = zod_1.z.object({
29
+ external_id: zod_1.z.string(),
30
+ status: zod_1.z.enum(['created', 'updated', 'skipped']),
31
+ potential_user_id: zod_1.z.number().int().positive().nullable(),
32
+ /** Why the contact was skipped */
33
+ reason: zod_1.z.string().nullable(),
34
+ });
@@ -1,3 +1,23 @@
1
+ import type { PotentialUserSourceType } from "../../dto/potential-users/potential-user-import.dto";
2
+ /**
3
+ * One way a potential user reached the list: an employee, or a website a service found it on.
4
+ * Stored in the potential user's `sources` JSON, one entry per source_key.
5
+ */
6
+ export type IPotentialUserSource = {
7
+ source_type: PotentialUserSourceType;
8
+ /** What makes the source unique: "employee:<id>" or "website:<domain>" */
9
+ source_key: string;
10
+ /** The employee who added it, for "employee" sources */
11
+ employee_id?: number | null;
12
+ /** The internal service that reported it, e.g. "qatayef-collect" */
13
+ service_name?: string | null;
14
+ website?: string | null;
15
+ source_url?: string | null;
16
+ external_id?: string | null;
17
+ name_seen?: string | null;
18
+ first_seen_at: string;
19
+ last_seen_at: string;
20
+ };
1
21
  export type IPotentialUser = {
2
22
  id: number;
3
23
  name?: string;
@@ -26,6 +46,13 @@ export type IPotentialUser = {
26
46
  last_conversation_id?: string | null;
27
47
  last_ai_summary?: string | null;
28
48
  is_blocked?: boolean;
49
+ /** Distinct sources (websites and employees) that added this phone */
50
+ added_count?: number | null;
51
+ first_source?: PotentialUserSourceType | null;
52
+ last_added_at?: string | null;
53
+ /** Fields without a column, merged from every source */
54
+ extra_data?: Record<string, unknown> | null;
55
+ sources?: IPotentialUserSource[] | null;
29
56
  };
30
57
  export type CreatePotentialUserDto = {
31
58
  name?: string;
@@ -4,3 +4,4 @@ export * as EVENTS from './events/index.js';
4
4
  export * as Ai from './ai/Ai.dto.js';
5
5
  export * as PAYMENTS from './payments/index.js';
6
6
  export * as ADDRESSES from './addresses/addresses.dto.js';
7
+ export * as POTENTIAL_USERS from './potential-users/potential-user-import.dto.js';
@@ -5,3 +5,4 @@ export * as EVENTS from './events/index.js';
5
5
  export * as PAYMENTS from './payments/index.js';
6
6
  export * as COMMUNICATION from './communication/index.js';
7
7
  export * as ADDRESSES from './addresses/addresses.schema.js';
8
+ export * as POTENTIAL_USERS from './potential-users/index.js';
@@ -0,0 +1 @@
1
+ export * from './potential-user-import.schema.js';
@@ -0,0 +1,31 @@
1
+ import { z } from 'zod';
2
+ import { MarketingSubjectTypeSchema } from '../communication/ai-conversation.schema.js';
3
+ /** Where a potential user came from. One person can have several sources. */
4
+ export const PotentialUserSourceTypeSchema = z.enum(['employee', 'qatayef_collect']);
5
+ /** Most contacts one import request may carry */
6
+ export const POTENTIAL_USER_IMPORT_MAX_BATCH = 500;
7
+ /** One contact found by an internal service, e.g. a phone collected from a website. */
8
+ export const PotentialUserImportContactSchema = z.object({
9
+ /** The caller's own ID for this contact, echoed back in the result */
10
+ external_id: z.string().trim().min(1).max(100),
11
+ /** E.164, e.g. +971501234567 */
12
+ phone: z.string().trim().regex(/^\+[1-9]\d{6,14}$/, 'phone must be in E.164 format'),
13
+ name: z.string().trim().max(255).nullish(),
14
+ /** The website the contact was found on, e.g. dubizzle.com; one source per website */
15
+ website: z.string().trim().min(1).max(253),
16
+ source_url: z.string().trim().url().max(2048).nullish(),
17
+ subject_type: MarketingSubjectTypeSchema.nullish(),
18
+ /** Fields without a column (email, price, listing title, listings count, ...) */
19
+ data: z.record(z.string(), z.unknown()).default({}),
20
+ });
21
+ export const PotentialUserImportSchema = z.object({
22
+ source_type: PotentialUserSourceTypeSchema.exclude(['employee']).default('qatayef_collect'),
23
+ contacts: z.array(PotentialUserImportContactSchema).min(1).max(POTENTIAL_USER_IMPORT_MAX_BATCH),
24
+ });
25
+ export const PotentialUserImportResultSchema = z.object({
26
+ external_id: z.string(),
27
+ status: z.enum(['created', 'updated', 'skipped']),
28
+ potential_user_id: z.number().int().positive().nullable(),
29
+ /** Why the contact was skipped */
30
+ reason: z.string().nullable(),
31
+ });
package/package.json CHANGED
@@ -1,58 +1,59 @@
1
- {
2
- "name": "@deallony/shared",
3
- "version": "1.2.54",
4
- "private": false,
5
- "main": "dist/cjs/index.js",
6
- "module": "dist/esm/index.js",
7
- "react-native": "dist/esm/index.js",
8
- "types": "dist/cjs/index.d.ts",
9
- "sideEffects": false,
10
- "exports": {
11
- ".": {
12
- "require": "./dist/cjs/index.js",
13
- "import": "./dist/esm/index.js",
14
- "types": "./dist/cjs/index.d.ts"
15
- }
16
- },
17
- "files": [
18
- "dist"
19
- ],
20
- "scripts": {
21
- "deploy": "node ./scripts/publish.js npm patch",
22
- "=========": "============= UPDATE APPS LIBRARY =============",
23
- "all:update": "npm run mobile:update && npm run backend:update && npm run dashboard:update && npm run whatsapp:update",
24
- "mobile:update": "cd ../app && npm run upgrade:deallony:shared",
25
- "backend:update": "cd ../backend-service-marketplace && pnpm install gitlab:qatayef-tech-aloo/deallony-development/shared-deallony",
26
- "dashboard:update": "cd ../frontend-react-aloo && pnpm install gitlab:qatayef-tech-aloo/deallony-development/shared-deallony",
27
- "whatsapp:update": "cd ../backend-nest-whatsapp-service-aloo && pnpm install gitlab:qatayef-tech-aloo/deallony-development/shared-deallony",
28
- "current": "node -p \"require('./package.json').version\"",
29
- "============================= Links with project =============================": "",
30
- "link:backend": "cd ../backend-service-marketplace && pnpm add @deallony/shared@file:../shared-deallony",
31
- "link:dashboard": "cd ../frontend-react-aloo && pnpm add @deallony/shared@file:../shared-deallony",
32
- "link:mobile": "cd ../app && npm install ../shared-deallony",
33
- "========": "============ DEFAULT ============",
34
- "build": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && node ./scripts/fix-esm-imports.mjs",
35
- "watch": "tsc -p tsconfig.cjs.json --watch",
36
- "deploy:patch": "node ./scripts/publish.js npm patch",
37
- "deploy:minor": "node ./scripts/publish.js npm minor",
38
- "deploy:major": "node ./scripts/publish.js npm major",
39
- "deploy:dry-run": "node ./scripts/publish.js npm patch --dry-run",
40
- "deploy:git": "node ./scripts/publish.js git patch",
41
- "deploy:git:minor": "node ./scripts/publish.js git minor",
42
- "deploy:git:major": "node ./scripts/publish.js git major",
43
- "deploy:git:dry-run": "node ./scripts/publish.js git patch --dry-run",
44
- "test:release": "node --test scripts/publish.test.js",
45
- "prepublishOnly": "npm run build"
46
- },
47
- "dependencies": {
48
- "zod": "^4.2.1"
49
- },
50
- "devDependencies": {
51
- "@types/node": "^25.0.3",
52
- "typescript": "^5.9.3"
53
- },
54
- "publishConfig": {
55
- "registry": "https://registry.npmjs.org/",
56
- "access": "public"
57
- }
58
- }
1
+ {
2
+ "name": "@deallony/shared",
3
+ "version": "1.2.55",
4
+ "private": false,
5
+ "main": "dist/cjs/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "react-native": "dist/esm/index.js",
8
+ "types": "dist/cjs/index.d.ts",
9
+ "sideEffects": false,
10
+ "exports": {
11
+ ".": {
12
+ "require": "./dist/cjs/index.js",
13
+ "import": "./dist/esm/index.js",
14
+ "types": "./dist/cjs/index.d.ts"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "deploy": "node ./scripts/publish.js npm patch",
22
+ "=========": "============= UPDATE APPS LIBRARY =============",
23
+ "all:update": "npm run mobile:update && npm run backend:update && npm run dashboard:update && npm run whatsapp:update && npm run collect:update",
24
+ "mobile:update": "cd ../app && npm run upgrade:deallony:shared",
25
+ "backend:update": "cd ../backend-service-marketplace && pnpm run upgrade:deallony:shared",
26
+ "dashboard:update": "cd ../frontend-react-aloo && pnpm run upgrade:deallony:shared",
27
+ "whatsapp:update": "cd ../backend-nest-whatsapp-service-aloo && pnpm run upgrade:deallony:shared",
28
+ "collect:update": "cd ../qatayef-collect/backend && npm run upgrade:deallony:shared",
29
+ "current": "node -p \"require('./package.json').version\"",
30
+ "============================= Links with project =============================": "",
31
+ "link:backend": "cd ../backend-service-marketplace && pnpm add @deallony/shared@file:../shared-deallony",
32
+ "link:dashboard": "cd ../frontend-react-aloo && pnpm add @deallony/shared@file:../shared-deallony",
33
+ "link:mobile": "cd ../app && npm install ../shared-deallony",
34
+ "========": "============ DEFAULT ============",
35
+ "build": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && node ./scripts/fix-esm-imports.mjs",
36
+ "watch": "tsc -p tsconfig.cjs.json --watch",
37
+ "deploy:patch": "node ./scripts/publish.js npm patch",
38
+ "deploy:minor": "node ./scripts/publish.js npm minor",
39
+ "deploy:major": "node ./scripts/publish.js npm major",
40
+ "deploy:dry-run": "node ./scripts/publish.js npm patch --dry-run",
41
+ "deploy:git": "node ./scripts/publish.js git patch",
42
+ "deploy:git:minor": "node ./scripts/publish.js git minor",
43
+ "deploy:git:major": "node ./scripts/publish.js git major",
44
+ "deploy:git:dry-run": "node ./scripts/publish.js git patch --dry-run",
45
+ "test:release": "node --test scripts/publish.test.js",
46
+ "prepublishOnly": "npm run build"
47
+ },
48
+ "dependencies": {
49
+ "zod": "^4.2.1"
50
+ },
51
+ "devDependencies": {
52
+ "@types/node": "^25.0.3",
53
+ "typescript": "^5.9.3"
54
+ },
55
+ "publishConfig": {
56
+ "registry": "https://registry.npmjs.org/",
57
+ "access": "public"
58
+ }
59
+ }