@infuro/cms-core 1.0.31 → 1.0.34

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 (41) hide show
  1. package/README.md +12 -8
  2. package/dist/admin.cjs +1907 -1144
  3. package/dist/admin.cjs.map +1 -1
  4. package/dist/admin.d.cts +7 -2
  5. package/dist/admin.d.ts +7 -2
  6. package/dist/admin.js +1955 -1191
  7. package/dist/admin.js.map +1 -1
  8. package/dist/api.cjs +2704 -914
  9. package/dist/api.cjs.map +1 -1
  10. package/dist/api.d.cts +1 -1
  11. package/dist/api.d.ts +1 -1
  12. package/dist/api.js +2664 -875
  13. package/dist/api.js.map +1 -1
  14. package/dist/auth.cjs +251 -23
  15. package/dist/auth.cjs.map +1 -1
  16. package/dist/auth.d.cts +53 -22
  17. package/dist/auth.d.ts +53 -22
  18. package/dist/auth.js +240 -23
  19. package/dist/auth.js.map +1 -1
  20. package/dist/cli.cjs +42 -2
  21. package/dist/cli.cjs.map +1 -1
  22. package/dist/cli.js +42 -2
  23. package/dist/cli.js.map +1 -1
  24. package/dist/{index-BcMRGNjS.d.cts → index-Bf5GO8fu.d.cts} +4 -3
  25. package/dist/{index-Bda8D1Rm.d.ts → index-DOiJuMQA.d.ts} +4 -3
  26. package/dist/index.cjs +3408 -1284
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +121 -35
  29. package/dist/index.d.ts +121 -35
  30. package/dist/index.js +3334 -1226
  31. package/dist/index.js.map +1 -1
  32. package/dist/migrations/1778660000003-AddQrTokenToOrders.ts +32 -0
  33. package/dist/migrations/1778660000004-CreateCustomerAndCustomerContacts.ts +99 -0
  34. package/dist/migrations/1778660000005-AddCustomerIdToVendorCustomers.ts +39 -0
  35. package/dist/migrations/1778660000006-UpdateVendorCustomersContactNullable.ts +36 -0
  36. package/dist/migrations/1778660000007-VendorOwnerCustomerContactsPermission.ts +39 -0
  37. package/dist/migrations/1779100000000-ChatConversationLeadEmailSent.ts +16 -0
  38. package/dist/migrations/1779200000000-LlmAgentScope.ts +72 -0
  39. package/dist/migrations/1779300000000-VendorOwnerContactsPermission.ts +39 -0
  40. package/dist/migrations/1779400000000-AddCustomerContactIdToOrders.ts +33 -0
  41. package/package.json +5 -3
@@ -0,0 +1,32 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+
3
+ export class AddQrTokenToOrders1778660000003
4
+ implements MigrationInterface
5
+ {
6
+ name = 'AddQrTokenToOrders1778660000003';
7
+
8
+ public async up(queryRunner: QueryRunner): Promise<void> {
9
+ await queryRunner.query(`
10
+ ALTER TABLE "orders"
11
+ ADD COLUMN "qrToken" character varying
12
+ `);
13
+
14
+ await queryRunner.query(`
15
+ ALTER TABLE "orders"
16
+ ADD CONSTRAINT "UQ_orders_qrToken"
17
+ UNIQUE ("qrToken")
18
+ `);
19
+ }
20
+
21
+ public async down(queryRunner: QueryRunner): Promise<void> {
22
+ await queryRunner.query(`
23
+ ALTER TABLE "orders"
24
+ DROP CONSTRAINT "UQ_orders_qrToken"
25
+ `);
26
+
27
+ await queryRunner.query(`
28
+ ALTER TABLE "orders"
29
+ DROP COLUMN "qrToken"
30
+ `);
31
+ }
32
+ }
@@ -0,0 +1,99 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+
3
+ export class CreateCustomerAndCustomerContacts1778660000004
4
+ implements MigrationInterface
5
+ {
6
+ name = 'CreateCustomerAndCustomerContacts1778660000004';
7
+
8
+ public async up(queryRunner: QueryRunner): Promise<void> {
9
+ // Create customer table
10
+ await queryRunner.query(`
11
+ CREATE TABLE "customer" (
12
+ "id" SERIAL NOT NULL,
13
+ "userId" integer,
14
+ "name" character varying NOT NULL,
15
+ "email" character varying NOT NULL,
16
+ "phone" character varying NOT NULL,
17
+ "createdAt" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
18
+ "updatedAt" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
19
+ "deletedAt" TIMESTAMP,
20
+ "deleted" boolean NOT NULL DEFAULT false,
21
+ "createdBy" integer,
22
+ "updatedBy" integer,
23
+ "deletedBy" integer,
24
+ CONSTRAINT "PK_customer_id" PRIMARY KEY ("id"),
25
+ CONSTRAINT "UQ_customer_email" UNIQUE ("email"),
26
+ CONSTRAINT "UQ_customer_phone" UNIQUE ("phone")
27
+ )
28
+ `);
29
+
30
+ // Add foreign key for userId
31
+ await queryRunner.query(`
32
+ ALTER TABLE "customer"
33
+ ADD CONSTRAINT "FK_customer_user"
34
+ FOREIGN KEY ("userId")
35
+ REFERENCES "users"("id")
36
+ ON DELETE SET NULL
37
+ ON UPDATE NO ACTION
38
+ `);
39
+
40
+ // Create customer_contacts table
41
+ await queryRunner.query(`
42
+ CREATE TABLE "customer_contacts" (
43
+ "id" SERIAL NOT NULL,
44
+ "customerId" integer NOT NULL,
45
+ "contactId" integer NOT NULL,
46
+ CONSTRAINT "PK_customer_contacts_id" PRIMARY KEY ("id")
47
+ )
48
+ `);
49
+
50
+ // Add foreign key for customerId
51
+ await queryRunner.query(`
52
+ ALTER TABLE "customer_contacts"
53
+ ADD CONSTRAINT "FK_customer_contacts_customer"
54
+ FOREIGN KEY ("customerId")
55
+ REFERENCES "customer"("id")
56
+ ON DELETE CASCADE
57
+ ON UPDATE NO ACTION
58
+ `);
59
+
60
+ // Add foreign key for contactId
61
+ await queryRunner.query(`
62
+ ALTER TABLE "customer_contacts"
63
+ ADD CONSTRAINT "FK_customer_contacts_contact"
64
+ FOREIGN KEY ("contactId")
65
+ REFERENCES "contacts"("id")
66
+ ON DELETE CASCADE
67
+ ON UPDATE NO ACTION
68
+ `);
69
+ }
70
+
71
+ public async down(queryRunner: QueryRunner): Promise<void> {
72
+ // Drop foreign keys from customer_contacts
73
+ await queryRunner.query(`
74
+ ALTER TABLE "customer_contacts"
75
+ DROP CONSTRAINT "FK_customer_contacts_contact"
76
+ `);
77
+
78
+ await queryRunner.query(`
79
+ ALTER TABLE "customer_contacts"
80
+ DROP CONSTRAINT "FK_customer_contacts_customer"
81
+ `);
82
+
83
+ // Drop customer_contacts table
84
+ await queryRunner.query(`
85
+ DROP TABLE "customer_contacts"
86
+ `);
87
+
88
+ // Drop foreign key from customer
89
+ await queryRunner.query(`
90
+ ALTER TABLE "customer"
91
+ DROP CONSTRAINT "FK_customer_user"
92
+ `);
93
+
94
+ // Drop customer table
95
+ await queryRunner.query(`
96
+ DROP TABLE "customer"
97
+ `);
98
+ }
99
+ }
@@ -0,0 +1,39 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+
3
+ export class AddCustomerIdToVendorCustomers1778660000005
4
+ implements MigrationInterface
5
+ {
6
+ name = 'AddCustomerIdToVendorCustomers1778660000005';
7
+
8
+ public async up(queryRunner: QueryRunner): Promise<void> {
9
+ // Add customerId column
10
+ await queryRunner.query(`
11
+ ALTER TABLE "vendor_customers"
12
+ ADD COLUMN "customerId" integer
13
+ `);
14
+
15
+ // Add foreign key constraint
16
+ await queryRunner.query(`
17
+ ALTER TABLE "vendor_customers"
18
+ ADD CONSTRAINT "FK_vendor_customers_customer"
19
+ FOREIGN KEY ("customerId")
20
+ REFERENCES "customer"("id")
21
+ ON DELETE CASCADE
22
+ ON UPDATE NO ACTION
23
+ `);
24
+ }
25
+
26
+ public async down(queryRunner: QueryRunner): Promise<void> {
27
+ // Drop foreign key constraint
28
+ await queryRunner.query(`
29
+ ALTER TABLE "vendor_customers"
30
+ DROP CONSTRAINT "FK_vendor_customers_customer"
31
+ `);
32
+
33
+ // Drop customerId column
34
+ await queryRunner.query(`
35
+ ALTER TABLE "vendor_customers"
36
+ DROP COLUMN "customerId"
37
+ `);
38
+ }
39
+ }
@@ -0,0 +1,36 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+
3
+ export class UpdateVendorCustomersContactNullable1778660000006
4
+ implements MigrationInterface
5
+ {
6
+ name = 'UpdateVendorCustomersContactNullable1778660000006';
7
+
8
+ public async up(queryRunner: QueryRunner): Promise<void> {
9
+ // Drop unique constraint
10
+ await queryRunner.query(`
11
+ ALTER TABLE "vendor_customers"
12
+ DROP CONSTRAINT "UQ_vendor_customers_vendor_contact"
13
+ `);
14
+
15
+ // Make contactId nullable
16
+ await queryRunner.query(`
17
+ ALTER TABLE "vendor_customers"
18
+ ALTER COLUMN "contactId" DROP NOT NULL
19
+ `);
20
+ }
21
+
22
+ public async down(queryRunner: QueryRunner): Promise<void> {
23
+ // Make contactId NOT NULL again
24
+ await queryRunner.query(`
25
+ ALTER TABLE "vendor_customers"
26
+ ALTER COLUMN "contactId" SET NOT NULL
27
+ `);
28
+
29
+ // Recreate unique constraint
30
+ await queryRunner.query(`
31
+ ALTER TABLE "vendor_customers"
32
+ ADD CONSTRAINT "UQ_vendor_customers_vendor_contact"
33
+ UNIQUE ("vendorId", "contactId")
34
+ `);
35
+ }
36
+ }
@@ -0,0 +1,39 @@
1
+ import type { MigrationInterface, QueryRunner } from 'typeorm';
2
+
3
+ /** Vendor Owner group: access customer contacts in admin. */
4
+ export class VendorOwnerCustomerContactsPermission1778660000007
5
+ implements MigrationInterface
6
+ {
7
+ name = 'VendorOwnerCustomerContactsPermission1778660000007';
8
+
9
+ public async up(queryRunner: QueryRunner): Promise<void> {
10
+ await queryRunner.query(`
11
+ INSERT INTO "permissions"
12
+ ("groupId", "entity", "canCreate", "canRead", "canUpdate", "canDelete")
13
+ SELECT
14
+ g.id,
15
+ 'customer_contacts',
16
+ true,
17
+ true,
18
+ true,
19
+ false
20
+ FROM "user_groups" g
21
+ WHERE g.name = 'Vendor Owner'
22
+ AND g.deleted = false
23
+ ON CONFLICT ("groupId", "entity") DO UPDATE SET
24
+ "canCreate" = true,
25
+ "canRead" = true,
26
+ "canUpdate" = true
27
+ `);
28
+ }
29
+
30
+ public async down(queryRunner: QueryRunner): Promise<void> {
31
+ await queryRunner.query(`
32
+ DELETE FROM "permissions" p
33
+ USING "user_groups" g
34
+ WHERE p."groupId" = g.id
35
+ AND g.name = 'Vendor Owner'
36
+ AND p.entity = 'customer_contacts'
37
+ `);
38
+ }
39
+ }
@@ -0,0 +1,16 @@
1
+ import type { MigrationInterface, QueryRunner } from 'typeorm';
2
+
3
+ /** Tracks when a lead notification email was sent for a chat conversation (avoid duplicates). */
4
+ export class ChatConversationLeadEmailSent1779100000000 implements MigrationInterface {
5
+ name = 'ChatConversationLeadEmailSent1779100000000';
6
+
7
+ public async up(queryRunner: QueryRunner): Promise<void> {
8
+ await queryRunner.query(
9
+ `ALTER TABLE "chat_conversations" ADD COLUMN IF NOT EXISTS "leadEmailSentAt" TIMESTAMP`
10
+ );
11
+ }
12
+
13
+ public async down(queryRunner: QueryRunner): Promise<void> {
14
+ await queryRunner.query(`ALTER TABLE "chat_conversations" DROP COLUMN IF EXISTS "leadEmailSentAt"`);
15
+ }
16
+ }
@@ -0,0 +1,72 @@
1
+ import type { MigrationInterface, QueryRunner } from 'typeorm';
2
+
3
+ /**
4
+ * Adds `llm_agents.scope` (chatbot, blog_creation, social_media_post, blog_metadata, email_intent_chatbot),
5
+ * backfills existing rows by slug, seeds the email-intent classifier agent, and enforces one active row per scope.
6
+ */
7
+ const EMAIL_INTENT_AGENT_NAME = 'Chat Lead Intent Classifier';
8
+ const EMAIL_INTENT_AGENT_SLUG = 'email-intent-chatbot';
9
+ const EMAIL_INTENT_SCOPE = 'email_intent_chatbot';
10
+
11
+ const EMAIL_INTENT_SYSTEM = `Classify the visitor message using the configured intent table.
12
+ Prefer a specific business intent when the visitor shows clear buying, support, or partnership signals.
13
+ Use NONE for greetings-only, FAQ, spam, or off-topic messages.`;
14
+
15
+ export class LlmAgentScope1779200000000 implements MigrationInterface {
16
+ name = 'LlmAgentScope1779200000000';
17
+
18
+ public async up(queryRunner: QueryRunner): Promise<void> {
19
+ await queryRunner.query(`
20
+ ALTER TABLE "llm_agents"
21
+ ADD COLUMN IF NOT EXISTS "scope" character varying
22
+ `);
23
+
24
+ await queryRunner.query(`
25
+ UPDATE "llm_agents"
26
+ SET "scope" = 'chatbot'
27
+ WHERE "deleted" = false AND "scope" IS NULL AND "slug" = 'site-chat-assistant'
28
+ `);
29
+ await queryRunner.query(`
30
+ UPDATE "llm_agents"
31
+ SET "scope" = 'blog_creation'
32
+ WHERE "deleted" = false AND "scope" IS NULL AND "slug" = 'blog-generator'
33
+ `);
34
+ await queryRunner.query(`
35
+ UPDATE "llm_agents"
36
+ SET "scope" = 'social_media_post'
37
+ WHERE "deleted" = false AND "scope" IS NULL AND "slug" = 'blog-generator-social'
38
+ `);
39
+ await queryRunner.query(`
40
+ UPDATE "llm_agents"
41
+ SET "scope" = 'blog_metadata'
42
+ WHERE "deleted" = false AND "scope" IS NULL AND "slug" = 'blog-generator-metadata'
43
+ `);
44
+
45
+ await queryRunner.query(
46
+ `
47
+ INSERT INTO "llm_agents" ("name", "slug", "scope", "system_instruction", "enabled", "createdAt", "updatedAt", "deleted")
48
+ SELECT $1::varchar, $2::varchar, $3::varchar, $4::text, true, now(), now(), false
49
+ WHERE NOT EXISTS (
50
+ SELECT 1 FROM "llm_agents" a
51
+ WHERE a."deleted" = false AND (a."scope" = $3::varchar OR a."slug" = $2::varchar)
52
+ )
53
+ `,
54
+ [EMAIL_INTENT_AGENT_NAME, EMAIL_INTENT_AGENT_SLUG, EMAIL_INTENT_SCOPE, EMAIL_INTENT_SYSTEM]
55
+ );
56
+
57
+ await queryRunner.query(`
58
+ CREATE UNIQUE INDEX IF NOT EXISTS "UQ_llm_agents_scope_active"
59
+ ON "llm_agents" ("scope")
60
+ WHERE "deleted" = false AND "scope" IS NOT NULL
61
+ `);
62
+ }
63
+
64
+ public async down(queryRunner: QueryRunner): Promise<void> {
65
+ await queryRunner.query(`DROP INDEX IF EXISTS "UQ_llm_agents_scope_active"`);
66
+ await queryRunner.query(`
67
+ DELETE FROM "llm_agents"
68
+ WHERE "slug" = $1 AND "scope" = $2
69
+ `, [EMAIL_INTENT_AGENT_SLUG, EMAIL_INTENT_SCOPE]);
70
+ await queryRunner.query(`ALTER TABLE "llm_agents" DROP COLUMN IF EXISTS "scope"`);
71
+ }
72
+ }
@@ -0,0 +1,39 @@
1
+ import type { MigrationInterface, QueryRunner } from 'typeorm';
2
+
3
+ /** Vendor Owner group: access contacts in admin. */
4
+ export class VendorOwnerContactsPermission1779300000000
5
+ implements MigrationInterface
6
+ {
7
+ name = 'VendorOwnerContactsPermission1779300000000';
8
+
9
+ public async up(queryRunner: QueryRunner): Promise<void> {
10
+ await queryRunner.query(`
11
+ INSERT INTO "permissions"
12
+ ("groupId", "entity", "canCreate", "canRead", "canUpdate", "canDelete")
13
+ SELECT
14
+ g.id,
15
+ 'contacts',
16
+ true,
17
+ true,
18
+ true,
19
+ false
20
+ FROM "user_groups" g
21
+ WHERE g.name = 'Vendor Owner'
22
+ AND g.deleted = false
23
+ ON CONFLICT ("groupId", "entity") DO UPDATE SET
24
+ "canCreate" = true,
25
+ "canRead" = true,
26
+ "canUpdate" = true
27
+ `);
28
+ }
29
+
30
+ public async down(queryRunner: QueryRunner): Promise<void> {
31
+ await queryRunner.query(`
32
+ DELETE FROM "permissions" p
33
+ USING "user_groups" g
34
+ WHERE p."groupId" = g.id
35
+ AND g.name = 'Vendor Owner'
36
+ AND p.entity = 'contacts'
37
+ `);
38
+ }
39
+ }
@@ -0,0 +1,33 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+
3
+ export class AddCustomerContactIdToOrders1779400000000 implements MigrationInterface {
4
+ name = 'AddCustomerContactIdToOrders1779400000000';
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(`
8
+ ALTER TABLE "orders"
9
+ ADD COLUMN "customerContactId" integer
10
+ `);
11
+
12
+ await queryRunner.query(`
13
+ ALTER TABLE "orders"
14
+ ADD CONSTRAINT "FK_orders_customer_contact"
15
+ FOREIGN KEY ("customerContactId")
16
+ REFERENCES "customer_contacts"("id")
17
+ ON DELETE SET NULL
18
+ ON UPDATE NO ACTION
19
+ `);
20
+ }
21
+
22
+ public async down(queryRunner: QueryRunner): Promise<void> {
23
+ await queryRunner.query(`
24
+ ALTER TABLE "orders"
25
+ DROP CONSTRAINT "FK_orders_customer_contact"
26
+ `);
27
+
28
+ await queryRunner.query(`
29
+ ALTER TABLE "orders"
30
+ DROP COLUMN "customerContactId"
31
+ `);
32
+ }
33
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infuro/cms-core",
3
- "version": "1.0.31",
3
+ "version": "1.0.34",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -94,6 +94,7 @@
94
94
  "dependencies": {
95
95
  "@aws-sdk/client-s3": "^3.858.0",
96
96
  "@aws-sdk/client-ses": "^3.858.0",
97
+ "@aws-sdk/client-sts": "^3.1059.0",
97
98
  "@huggingface/inference": "^4.13.15",
98
99
  "@radix-ui/react-avatar": "^1.1.10",
99
100
  "@radix-ui/react-checkbox": "^1.3.2",
@@ -114,6 +115,7 @@
114
115
  "class-variance-authority": "^0.7.1",
115
116
  "clsx": "^2.1.1",
116
117
  "country-state-city": "^3.2.1",
118
+ "cron-parser": "^4.9.0",
117
119
  "fastq": "^1.20.0",
118
120
  "googleapis": "^154.1.0",
119
121
  "ioredis": "^5.7.0",
@@ -126,10 +128,10 @@
126
128
  "papaparse": "^5.4.1",
127
129
  "pdf-parse": "^1.1.1",
128
130
  "pg": "^8.20.0",
129
- "pg-boss": "^10.0.0",
130
- "cron-parser": "^4.9.0",
131
+ "pg-boss": ">=10.0.0",
131
132
  "razorpay": "^2.9.6",
132
133
  "react-chartjs-2": "^5.3.0",
134
+ "react-qr-code": "^2.0.21",
133
135
  "reflect-metadata": "^0.2.2",
134
136
  "rss-parser": "^3.13.0",
135
137
  "sonner": "^2.0.6",