vidspotai-shared 1.0.0

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 (142) hide show
  1. package/lib/globals/aiModels.d.ts +60 -0
  2. package/lib/globals/aiModels.d.ts.map +1 -0
  3. package/lib/globals/aiModels.js +463 -0
  4. package/lib/globals/config.d.ts +4 -0
  5. package/lib/globals/config.d.ts.map +1 -0
  6. package/lib/globals/config.js +20 -0
  7. package/lib/globals/index.d.ts +6 -0
  8. package/lib/globals/index.d.ts.map +1 -0
  9. package/lib/globals/index.js +21 -0
  10. package/lib/globals/plans.d.ts +3 -0
  11. package/lib/globals/plans.d.ts.map +1 -0
  12. package/lib/globals/plans.js +60 -0
  13. package/lib/globals/schemas.d.ts +3 -0
  14. package/lib/globals/schemas.d.ts.map +1 -0
  15. package/lib/globals/schemas.js +18 -0
  16. package/lib/globals/types.d.ts +90 -0
  17. package/lib/globals/types.d.ts.map +1 -0
  18. package/lib/globals/types.js +93 -0
  19. package/lib/index.d.ts +6 -0
  20. package/lib/index.d.ts.map +1 -0
  21. package/lib/index.js +21 -0
  22. package/lib/libs/firebase.d.ts +7 -0
  23. package/lib/libs/firebase.d.ts.map +1 -0
  24. package/lib/libs/firebase.js +60 -0
  25. package/lib/libs/index.d.ts +2 -0
  26. package/lib/libs/index.d.ts.map +1 -0
  27. package/lib/libs/index.js +17 -0
  28. package/lib/models/index.d.ts +4 -0
  29. package/lib/models/index.d.ts.map +1 -0
  30. package/lib/models/index.js +19 -0
  31. package/lib/models/script.model.d.ts +39 -0
  32. package/lib/models/script.model.d.ts.map +1 -0
  33. package/lib/models/script.model.js +26 -0
  34. package/lib/models/user.model.d.ts +46 -0
  35. package/lib/models/user.model.d.ts.map +1 -0
  36. package/lib/models/user.model.js +2 -0
  37. package/lib/models/video.model.d.ts +43 -0
  38. package/lib/models/video.model.d.ts.map +1 -0
  39. package/lib/models/video.model.js +2 -0
  40. package/lib/services/aiGen/aiGenFactory.service.d.ts +8 -0
  41. package/lib/services/aiGen/aiGenFactory.service.d.ts.map +1 -0
  42. package/lib/services/aiGen/aiGenFactory.service.js +56 -0
  43. package/lib/services/aiGen/atypes.d.ts +5 -0
  44. package/lib/services/aiGen/atypes.d.ts.map +1 -0
  45. package/lib/services/aiGen/atypes.js +8 -0
  46. package/lib/services/aiGen/helpers.d.ts +3 -0
  47. package/lib/services/aiGen/helpers.d.ts.map +1 -0
  48. package/lib/services/aiGen/helpers.js +76 -0
  49. package/lib/services/aiGen/index.d.ts +5 -0
  50. package/lib/services/aiGen/index.d.ts.map +1 -0
  51. package/lib/services/aiGen/index.js +20 -0
  52. package/lib/services/aiGen/providers/alibaba/alibaba.d.ts +12 -0
  53. package/lib/services/aiGen/providers/alibaba/alibaba.d.ts.map +1 -0
  54. package/lib/services/aiGen/providers/alibaba/alibaba.js +146 -0
  55. package/lib/services/aiGen/providers/alibaba/helpers.d.ts +3 -0
  56. package/lib/services/aiGen/providers/alibaba/helpers.d.ts.map +1 -0
  57. package/lib/services/aiGen/providers/alibaba/helpers.js +31 -0
  58. package/lib/services/aiGen/providers/azure/azure.d.ts +1 -0
  59. package/lib/services/aiGen/providers/azure/azure.d.ts.map +1 -0
  60. package/lib/services/aiGen/providers/azure/azure.js +1 -0
  61. package/lib/services/aiGen/providers/azure/azure.service.d.ts +14 -0
  62. package/lib/services/aiGen/providers/azure/azure.service.d.ts.map +1 -0
  63. package/lib/services/aiGen/providers/azure/azure.service.js +125 -0
  64. package/lib/services/aiGen/providers/azure/index.d.ts +2 -0
  65. package/lib/services/aiGen/providers/azure/index.d.ts.map +1 -0
  66. package/lib/services/aiGen/providers/azure/index.js +17 -0
  67. package/lib/services/aiGen/providers/baseAiGenProvider.service.d.ts +8 -0
  68. package/lib/services/aiGen/providers/baseAiGenProvider.service.d.ts.map +1 -0
  69. package/lib/services/aiGen/providers/baseAiGenProvider.service.js +12 -0
  70. package/lib/services/aiGen/providers/google/google.service.d.ts +10 -0
  71. package/lib/services/aiGen/providers/google/google.service.d.ts.map +1 -0
  72. package/lib/services/aiGen/providers/google/google.service.js +96 -0
  73. package/lib/services/aiGen/providers/google/index.d.ts +2 -0
  74. package/lib/services/aiGen/providers/google/index.d.ts.map +1 -0
  75. package/lib/services/aiGen/providers/google/index.js +17 -0
  76. package/lib/services/aiGen/providers/index.d.ts +8 -0
  77. package/lib/services/aiGen/providers/index.d.ts.map +1 -0
  78. package/lib/services/aiGen/providers/index.js +23 -0
  79. package/lib/services/aiGen/providers/kling/btypes.d.ts +73 -0
  80. package/lib/services/aiGen/providers/kling/btypes.d.ts.map +1 -0
  81. package/lib/services/aiGen/providers/kling/btypes.js +2 -0
  82. package/lib/services/aiGen/providers/kling/index.d.ts +3 -0
  83. package/lib/services/aiGen/providers/kling/index.d.ts.map +1 -0
  84. package/lib/services/aiGen/providers/kling/index.js +18 -0
  85. package/lib/services/aiGen/providers/kling/kling.service.d.ts +13 -0
  86. package/lib/services/aiGen/providers/kling/kling.service.d.ts.map +1 -0
  87. package/lib/services/aiGen/providers/kling/kling.service.js +139 -0
  88. package/lib/services/aiGen/providers/kling/types.d.ts +73 -0
  89. package/lib/services/aiGen/providers/kling/types.d.ts.map +1 -0
  90. package/lib/services/aiGen/providers/kling/types.js +2 -0
  91. package/lib/services/aiGen/providers/minimax/ctypes.d.ts +26 -0
  92. package/lib/services/aiGen/providers/minimax/ctypes.d.ts.map +1 -0
  93. package/lib/services/aiGen/providers/minimax/ctypes.js +3 -0
  94. package/lib/services/aiGen/providers/minimax/index.d.ts +3 -0
  95. package/lib/services/aiGen/providers/minimax/index.d.ts.map +1 -0
  96. package/lib/services/aiGen/providers/minimax/index.js +18 -0
  97. package/lib/services/aiGen/providers/minimax/minimax.service.d.ts +12 -0
  98. package/lib/services/aiGen/providers/minimax/minimax.service.d.ts.map +1 -0
  99. package/lib/services/aiGen/providers/minimax/minimax.service.js +115 -0
  100. package/lib/services/aiGen/providers/minimax/types.d.ts +26 -0
  101. package/lib/services/aiGen/providers/minimax/types.d.ts.map +1 -0
  102. package/lib/services/aiGen/providers/minimax/types.js +3 -0
  103. package/lib/services/aiGen/providers/openai/index.d.ts +2 -0
  104. package/lib/services/aiGen/providers/openai/index.d.ts.map +1 -0
  105. package/lib/services/aiGen/providers/openai/index.js +17 -0
  106. package/lib/services/aiGen/providers/openai/openai.service.d.ts +12 -0
  107. package/lib/services/aiGen/providers/openai/openai.service.d.ts.map +1 -0
  108. package/lib/services/aiGen/providers/openai/openai.service.js +97 -0
  109. package/lib/services/aiGen/providers/runway/dtypes.d.ts +14 -0
  110. package/lib/services/aiGen/providers/runway/dtypes.d.ts.map +1 -0
  111. package/lib/services/aiGen/providers/runway/dtypes.js +27 -0
  112. package/lib/services/aiGen/providers/runway/index.d.ts +3 -0
  113. package/lib/services/aiGen/providers/runway/index.d.ts.map +1 -0
  114. package/lib/services/aiGen/providers/runway/index.js +18 -0
  115. package/lib/services/aiGen/providers/runway/runway.service.d.ts +12 -0
  116. package/lib/services/aiGen/providers/runway/runway.service.d.ts.map +1 -0
  117. package/lib/services/aiGen/providers/runway/runway.service.js +122 -0
  118. package/lib/services/aiGen/providers/runway/types.d.ts +14 -0
  119. package/lib/services/aiGen/providers/runway/types.d.ts.map +1 -0
  120. package/lib/services/aiGen/providers/runway/types.js +27 -0
  121. package/lib/services/aiGen/providers/types.d.ts +49 -0
  122. package/lib/services/aiGen/providers/types.d.ts.map +1 -0
  123. package/lib/services/aiGen/providers/types.js +2 -0
  124. package/lib/services/aiGen/types.d.ts +5 -0
  125. package/lib/services/aiGen/types.d.ts.map +1 -0
  126. package/lib/services/aiGen/types.js +8 -0
  127. package/lib/services/firestore.service.d.ts +66 -0
  128. package/lib/services/firestore.service.d.ts.map +1 -0
  129. package/lib/services/firestore.service.js +118 -0
  130. package/lib/services/index.d.ts +4 -0
  131. package/lib/services/index.d.ts.map +1 -0
  132. package/lib/services/index.js +19 -0
  133. package/lib/services/redis.service.d.ts +19 -0
  134. package/lib/services/redis.service.d.ts.map +1 -0
  135. package/lib/services/redis.service.js +97 -0
  136. package/lib/utils/helpers.d.ts +6 -0
  137. package/lib/utils/helpers.d.ts.map +1 -0
  138. package/lib/utils/helpers.js +55 -0
  139. package/lib/utils/index.d.ts +2 -0
  140. package/lib/utils/index.d.ts.map +1 -0
  141. package/lib/utils/index.js +17 -0
  142. package/package.json +31 -0
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FirestoreService = void 0;
4
+ const firebase_1 = require("../libs/firebase");
5
+ /** Generic converter for typed Firestore collections */
6
+ function collectionConverter() {
7
+ const converter = {
8
+ toFirestore(data) {
9
+ return { ...data };
10
+ },
11
+ fromFirestore(snapshot) {
12
+ return snapshot.data();
13
+ },
14
+ };
15
+ return converter;
16
+ }
17
+ /**
18
+ * FirestoreService
19
+ * ----------------
20
+ * Centralized Firestore access with typed collections & static CRUD utilities.
21
+ */
22
+ class FirestoreService {
23
+ // 🔹 CRUD / Utility methods
24
+ /** Add new document with generated ID */
25
+ static async appendNewRecord(collectionRef, data) {
26
+ const docRef = collectionRef.doc();
27
+ await docRef.set(data);
28
+ return docRef;
29
+ }
30
+ /** Add or overwrite a document with a specific ID */
31
+ static async addData(collectionRef, id, data) {
32
+ const docRef = collectionRef.doc(id);
33
+ await docRef.set(data);
34
+ return docRef;
35
+ }
36
+ /** Get all documents from a collection */
37
+ static async getAllData(collectionRef) {
38
+ const snapshot = await collectionRef.get();
39
+ return snapshot.docs.map((doc) => ({ id: doc.id, ...doc.data() }));
40
+ }
41
+ /** Get a single document by ID */
42
+ static async getDataById(collectionRef, id) {
43
+ const docRef = collectionRef.doc(id);
44
+ const docSnap = await docRef.get();
45
+ if (!docSnap.exists)
46
+ return undefined;
47
+ return { id: docSnap.id, ...docSnap.data() };
48
+ }
49
+ /** Get a user by ID (typed) */
50
+ static async getUserById(id) {
51
+ return this.getDataById(this.usersCol, id);
52
+ }
53
+ /** Get a user by ID (typed) */
54
+ static async getUserByEmail(email) {
55
+ return this.getDataByKeyField(this.usersCol, "email", "==", email).then((users) => users[0]);
56
+ }
57
+ /** Query collection by field */
58
+ static async getDataByKeyField(collectionRef, fieldName, operator, value, options) {
59
+ let q = collectionRef.where(fieldName, operator, value);
60
+ if (options?.orderByField) {
61
+ q = q.orderBy(options.orderByField, options.orderDirection || "asc");
62
+ }
63
+ if (options?.limit) {
64
+ q = q.limit(options.limit);
65
+ }
66
+ const snapshot = await q.get();
67
+ return snapshot.docs.map((doc) => ({
68
+ id: doc.id,
69
+ ...doc.data(),
70
+ }));
71
+ }
72
+ /** Update document fields (partial update) */
73
+ static async updateData(collectionRef, id, newFieldRecord, options = { deepMerge: true }) {
74
+ const docRef = collectionRef.doc(id);
75
+ if (options?.deepMerge) {
76
+ const flattened = this.flattenObject(newFieldRecord);
77
+ await docRef.update(flattened);
78
+ }
79
+ else {
80
+ await docRef.update(newFieldRecord);
81
+ }
82
+ }
83
+ static flattenObject(obj, prefix = "") {
84
+ return Object.entries(obj).reduce((acc, [key, value]) => {
85
+ const path = prefix ? `${prefix}.${key}` : key;
86
+ if (value &&
87
+ typeof value === "object" &&
88
+ !Array.isArray(value) &&
89
+ !(value instanceof Date)) {
90
+ Object.assign(acc, this.flattenObject(value, path));
91
+ }
92
+ else {
93
+ acc[path] = value;
94
+ }
95
+ return acc;
96
+ }, {});
97
+ }
98
+ /** Update user document (typed helper) */
99
+ static async updateUserData(id, newFieldRecord) {
100
+ await this.updateData(this.usersCol, id, newFieldRecord);
101
+ }
102
+ /** Delete document */
103
+ static async deleteData(collectionRef, id) {
104
+ const docRef = collectionRef.doc(id);
105
+ await docRef.delete();
106
+ }
107
+ }
108
+ exports.FirestoreService = FirestoreService;
109
+ // 🔹 Typed collections (static)
110
+ FirestoreService.videoJobsCol = firebase_1.firestore
111
+ .collection("videoJobs")
112
+ .withConverter(collectionConverter());
113
+ FirestoreService.usersCol = firebase_1.firestore
114
+ .collection("users")
115
+ .withConverter(collectionConverter());
116
+ FirestoreService.scriptsCol = firebase_1.firestore
117
+ .collection("scripts")
118
+ .withConverter(collectionConverter());
@@ -0,0 +1,4 @@
1
+ export * from "./redis.service";
2
+ export * from "./firestore.service";
3
+ export * from "./aiGen";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC"}
@@ -0,0 +1,19 @@
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("./redis.service"), exports);
18
+ __exportStar(require("./firestore.service"), exports);
19
+ __exportStar(require("./aiGen"), exports);
@@ -0,0 +1,19 @@
1
+ export declare class RedisService {
2
+ private static instance;
3
+ private client;
4
+ private connected;
5
+ private constructor();
6
+ static getInstance(): RedisService;
7
+ connect(): Promise<void>;
8
+ set<T>(key: string, value: T, ttlSeconds?: number): Promise<void>;
9
+ get<T>(key: string): Promise<T | null>;
10
+ delete(key: string): Promise<void>;
11
+ pushToList<T>(listName: string, value: T): Promise<void>;
12
+ popFromList<T>(listName: string): Promise<T | null>;
13
+ blockingPopFromList<T>(listName: string, timeout?: number): Promise<T | null>;
14
+ getList<T>(listName: string): Promise<T[]>;
15
+ flushAll(): Promise<void>;
16
+ }
17
+ export declare const redis: RedisService;
18
+ export declare function initRedis(): Promise<void>;
19
+ //# sourceMappingURL=redis.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis.service.d.ts","sourceRoot":"","sources":["../../src/services/redis.service.ts"],"names":[],"mappings":"AAEA,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAe;IACtC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,SAAS,CAAS;IAE1B,OAAO;WAcO,WAAW,IAAI,YAAY;IAQ5B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAaxB,GAAG,CAAC,CAAC,EAChB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,CAAC,EACR,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC;IAUH,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAMtC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKlC,UAAU,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAKxD,WAAW,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAMnD,mBAAmB,CAAC,CAAC,EAChC,QAAQ,EAAE,MAAM,EAChB,OAAO,SAAI,GACV,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAUP,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAM1C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAGvC;AAED,eAAO,MAAM,KAAK,cAA6B,CAAC;AAEhD,wBAAsB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAO/C"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.redis = exports.RedisService = void 0;
7
+ exports.initRedis = initRedis;
8
+ const ioredis_1 = __importDefault(require("ioredis"));
9
+ class RedisService {
10
+ constructor() {
11
+ this.connected = false;
12
+ this.client = new ioredis_1.default(process.env.REDIS_URL ?? "");
13
+ this.client.on("error", (err) => console.error("❌ Redis Client Error:", err));
14
+ this.client.on("connect", () => {
15
+ this.connected = true;
16
+ console.log("✅ Connected to Redis Cloud");
17
+ });
18
+ }
19
+ // Singleton instance
20
+ static getInstance() {
21
+ if (!RedisService.instance) {
22
+ RedisService.instance = new RedisService();
23
+ }
24
+ return RedisService.instance;
25
+ }
26
+ // Connect (ioredis connects automatically)
27
+ async connect() {
28
+ if (this.connected)
29
+ return;
30
+ try {
31
+ await this.client.ping();
32
+ this.connected = true;
33
+ // console.log("✅ Redis connection verified");
34
+ }
35
+ catch (error) {
36
+ console.error("❌ Redis connection failed:", error);
37
+ throw error;
38
+ }
39
+ }
40
+ // Set key with optional expiration (in seconds)
41
+ async set(key, value, ttlSeconds) {
42
+ const strValue = JSON.stringify(value);
43
+ if (ttlSeconds) {
44
+ await this.client.set(key, strValue, "EX", ttlSeconds);
45
+ }
46
+ else {
47
+ await this.client.set(key, strValue);
48
+ }
49
+ }
50
+ // Get and parse key value
51
+ async get(key) {
52
+ const data = await this.client.get(key);
53
+ return data ? JSON.parse(data) : null;
54
+ }
55
+ // Delete key
56
+ async delete(key) {
57
+ await this.client.del(key);
58
+ }
59
+ // Push item to end of list (queue)
60
+ async pushToList(listName, value) {
61
+ await this.client.rpush(listName, JSON.stringify(value));
62
+ }
63
+ // Pop item from start of list (queue)
64
+ async popFromList(listName) {
65
+ const value = await this.client.lpop(listName);
66
+ return value ? JSON.parse(value) : null;
67
+ }
68
+ // Blocking pop from list
69
+ async blockingPopFromList(listName, timeout = 0) {
70
+ const result = await this.client.blpop(listName, timeout);
71
+ if (result && result.length === 2) {
72
+ const value = result[1];
73
+ return JSON.parse(value);
74
+ }
75
+ return null;
76
+ }
77
+ // Get full list
78
+ async getList(listName) {
79
+ const items = await this.client.lrange(listName, 0, -1);
80
+ return items.map((i) => JSON.parse(i));
81
+ }
82
+ // Flush all data
83
+ async flushAll() {
84
+ await this.client.flushall();
85
+ }
86
+ }
87
+ exports.RedisService = RedisService;
88
+ exports.redis = RedisService.getInstance();
89
+ async function initRedis() {
90
+ try {
91
+ await exports.redis.connect();
92
+ // console.log("✅ Redis connected and ready to use!");
93
+ }
94
+ catch (err) {
95
+ console.error("❌ Redis connection failed:", err);
96
+ }
97
+ }
@@ -0,0 +1,6 @@
1
+ import { ERENEWAL_FREQUENCY, ESUBSCRIPTION_PLANS } from "../globals/types";
2
+ export declare const getPlanTypeById: (priceId: string) => ESUBSCRIPTION_PLANS | null;
3
+ export declare const getFreqById: (priceId: string) => ERENEWAL_FREQUENCY | null;
4
+ export declare const getPriceIdByType: (type: ESUBSCRIPTION_PLANS, freq?: ERENEWAL_FREQUENCY) => string;
5
+ export declare const getCreditsFromCost: (cost: number) => number;
6
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE3E,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,KACd,mBAAmB,GAAG,IASxB,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,KAAG,kBAAkB,GAAG,IASlE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,MAAM,mBAAmB,EACzB,OAAM,kBAA+C,WAkBtD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,KAAG,MAajD,CAAC"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCreditsFromCost = exports.getPriceIdByType = exports.getFreqById = exports.getPlanTypeById = void 0;
4
+ const plans_1 = require("../globals/plans");
5
+ const types_1 = require("../globals/types");
6
+ const getPlanTypeById = (priceId) => {
7
+ for (const [planType, durations] of Object.entries(plans_1.PAYMENT_PLANS)) {
8
+ for (const [duration, details] of Object.entries(durations)) {
9
+ if (details.id?.includes(priceId)) {
10
+ return planType;
11
+ }
12
+ }
13
+ }
14
+ return null;
15
+ };
16
+ exports.getPlanTypeById = getPlanTypeById;
17
+ const getFreqById = (priceId) => {
18
+ for (const [planType, durations] of Object.entries(plans_1.PAYMENT_PLANS)) {
19
+ for (const [duration, details] of Object.entries(durations)) {
20
+ if (details.id?.includes(priceId)) {
21
+ return duration;
22
+ }
23
+ }
24
+ }
25
+ return null;
26
+ };
27
+ exports.getFreqById = getFreqById;
28
+ const getPriceIdByType = (type, freq = types_1.ERENEWAL_FREQUENCY.MONTHLY) => {
29
+ const planDetails = plans_1.PAYMENT_PLANS[type];
30
+ if (freq === types_1.ERENEWAL_FREQUENCY.QUARTERLY) {
31
+ return planDetails?.quarterly?.id;
32
+ }
33
+ else if (freq === types_1.ERENEWAL_FREQUENCY.YEARLY) {
34
+ if (Array.isArray(planDetails?.yearly?.id)) {
35
+ return planDetails?.yearly?.id[planDetails?.yearly?.id?.length - 1];
36
+ }
37
+ return planDetails?.yearly?.id;
38
+ }
39
+ return Array.isArray(planDetails?.monthly?.id)
40
+ ? planDetails?.monthly?.id[planDetails?.monthly?.id?.length - 1]
41
+ : planDetails?.monthly?.id;
42
+ };
43
+ exports.getPriceIdByType = getPriceIdByType;
44
+ const getCreditsFromCost = (cost) => {
45
+ const margin = 0.2;
46
+ const costPerCredit = 0.1;
47
+ const minCredits = 10;
48
+ if (cost <= 0)
49
+ return 0;
50
+ const totalCost = cost * (1 + margin);
51
+ const rawCredits = totalCost / costPerCredit;
52
+ const credits = Math.ceil(rawCredits);
53
+ return Math.max(credits, minCredits);
54
+ };
55
+ exports.getCreditsFromCost = getCreditsFromCost;
@@ -0,0 +1,2 @@
1
+ export * from "./helpers";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
@@ -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("./helpers"), exports);
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "vidspotai-shared",
3
+ "version": "1.0.0",
4
+ "main": "lib/index.js",
5
+ "types": "lib/index.d.ts",
6
+ "files": [
7
+ "lib"
8
+ ],
9
+ "dependencies": {
10
+ "@google-cloud/storage": "*",
11
+ "@google/genai": "^1.22.0",
12
+ "@runwayml/sdk": "^2.11.0",
13
+ "axios": "^1.12.2",
14
+ "firebase-admin": "^13.5.0",
15
+ "jsonwebtoken": "^9.0.2",
16
+ "openai": "^6.1.0",
17
+ "zod": "^4.1.11"
18
+ },
19
+ "devDependencies": {
20
+ "@types/jsonwebtoken": "^9.0.10",
21
+ "@types/node": "^24.6.2"
22
+ },
23
+ "peerDependencies": {
24
+ "firebase-admin": "^13.5.0",
25
+ "ioredis": "^5.8.0"
26
+ },
27
+ "scripts": {
28
+ "build": "tsc -p tsconfig.json",
29
+ "watch": "tsc -p tsconfig.json --watch"
30
+ }
31
+ }