akeyless-server-commons 1.0.203 → 1.0.205

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 (107) hide show
  1. package/dist/cjs/helpers/index.d.ts +1 -1
  2. package/dist/cjs/helpers/index.js +1 -1
  3. package/dist/cjs/helpers/index.js.map +1 -1
  4. package/dist/cjs/helpers/postponed_actions.d.ts +113 -0
  5. package/dist/cjs/helpers/postponed_actions.js +363 -0
  6. package/dist/cjs/helpers/postponed_actions.js.map +1 -0
  7. package/dist/cjs/helpers/start.js +16 -18
  8. package/dist/cjs/helpers/start.js.map +1 -1
  9. package/dist/cjs/managers/index.d.ts +1 -0
  10. package/dist/cjs/managers/index.js +1 -0
  11. package/dist/cjs/managers/index.js.map +1 -1
  12. package/dist/cjs/managers/rabbitmq_manager.d.ts +60 -0
  13. package/dist/cjs/managers/rabbitmq_manager.js +190 -0
  14. package/dist/cjs/managers/rabbitmq_manager.js.map +1 -0
  15. package/dist/esm/helpers/index.d.ts +1 -1
  16. package/dist/esm/helpers/index.js +1 -1
  17. package/dist/esm/helpers/index.js.map +1 -1
  18. package/dist/esm/helpers/postponed_actions.d.ts +113 -0
  19. package/dist/esm/helpers/postponed_actions.js +359 -0
  20. package/dist/esm/helpers/postponed_actions.js.map +1 -0
  21. package/dist/esm/helpers/start.js +16 -18
  22. package/dist/esm/helpers/start.js.map +1 -1
  23. package/dist/esm/managers/index.d.ts +1 -0
  24. package/dist/esm/managers/index.js +1 -0
  25. package/dist/esm/managers/index.js.map +1 -1
  26. package/dist/esm/managers/rabbitmq_manager.d.ts +60 -0
  27. package/dist/esm/managers/rabbitmq_manager.js +183 -0
  28. package/dist/esm/managers/rabbitmq_manager.js.map +1 -0
  29. package/dist/helpers/boards_helpers.js +62 -0
  30. package/dist/helpers/email_helpers.js +153 -0
  31. package/dist/helpers/firebase_helpers.js +601 -0
  32. package/dist/helpers/global_helpers.js +147 -0
  33. package/dist/helpers/index.js +13 -0
  34. package/dist/helpers/location_helpers.js +15 -0
  35. package/dist/helpers/login_helpers.js +18 -0
  36. package/dist/helpers/notification_helpers.js +248 -0
  37. package/dist/helpers/phone_number_helpers.js +96 -0
  38. package/dist/helpers/postponed_actions.js +358 -0
  39. package/dist/helpers/redis/helpers.js +215 -0
  40. package/dist/helpers/redis/index.js +4 -0
  41. package/dist/helpers/redis/initialize.js +139 -0
  42. package/dist/helpers/redis/keys.js +23 -0
  43. package/dist/helpers/redis/snapshot.js +166 -0
  44. package/dist/helpers/start.js +83 -0
  45. package/dist/helpers/tasks_helpers.js +139 -0
  46. package/dist/helpers/time_helpers.js +167 -0
  47. package/dist/index.js +5 -0
  48. package/dist/managers/cache_manager.js +37 -0
  49. package/dist/managers/index.js +4 -0
  50. package/dist/managers/logger_manager.js +68 -0
  51. package/dist/managers/rabbitmq_manager.js +182 -0
  52. package/dist/managers/translation_manager.js +38 -0
  53. package/dist/middlewares/auth_mw.js +50 -0
  54. package/dist/middlewares/error_handling.js +20 -0
  55. package/dist/middlewares/global_mw.js +119 -0
  56. package/dist/middlewares/index.js +4 -0
  57. package/dist/middlewares/trim_mw.js +7 -0
  58. package/dist/test.js +1 -0
  59. package/dist/types/enums/global.js +8 -0
  60. package/dist/types/enums/index.js +1 -0
  61. package/dist/types/helpers/boards_helpers.d.ts +10 -0
  62. package/dist/types/helpers/email_helpers.d.ts +12 -0
  63. package/dist/types/helpers/firebase_helpers.d.ts +56 -0
  64. package/dist/types/helpers/global_helpers.d.ts +16 -0
  65. package/dist/types/helpers/index.d.ts +13 -0
  66. package/dist/types/helpers/location_helpers.d.ts +3 -0
  67. package/dist/types/helpers/login_helpers.d.ts +4 -0
  68. package/dist/types/helpers/notification_helpers.d.ts +11 -0
  69. package/dist/types/helpers/phone_number_helpers.d.ts +19 -0
  70. package/dist/types/helpers/postponed_actions.d.ts +113 -0
  71. package/dist/types/helpers/redis/helpers.d.ts +11 -0
  72. package/dist/types/helpers/redis/index.d.ts +4 -0
  73. package/dist/types/helpers/redis/initialize.d.ts +6 -0
  74. package/dist/types/helpers/redis/keys.d.ts +5 -0
  75. package/dist/types/helpers/redis/snapshot.d.ts +2 -0
  76. package/dist/types/helpers/start.d.ts +4 -0
  77. package/dist/types/helpers/tasks_helpers.d.ts +25 -0
  78. package/dist/types/helpers/time_helpers.d.ts +40 -0
  79. package/dist/types/index.d.ts +5 -0
  80. package/dist/types/index.js +3 -0
  81. package/dist/types/interfaces/email.js +1 -0
  82. package/dist/types/interfaces/global.js +1 -0
  83. package/dist/types/interfaces/index.js +2 -0
  84. package/dist/types/managers/cache_manager.d.ts +12 -0
  85. package/dist/types/managers/index.d.ts +4 -0
  86. package/dist/types/managers/logger_manager.d.ts +14 -0
  87. package/dist/types/managers/rabbitmq_manager.d.ts +60 -0
  88. package/dist/types/managers/translation_manager.d.ts +14 -0
  89. package/dist/types/middlewares/auth_mw.d.ts +4 -0
  90. package/dist/types/middlewares/error_handling.d.ts +11 -0
  91. package/dist/types/middlewares/global_mw.d.ts +5 -0
  92. package/dist/types/middlewares/index.d.ts +4 -0
  93. package/dist/types/middlewares/trim_mw.d.ts +2 -0
  94. package/dist/types/test.d.ts +0 -0
  95. package/dist/types/types/enums/global.d.ts +9 -0
  96. package/dist/types/types/enums/index.d.ts +1 -0
  97. package/dist/types/types/firebase_types.js +1 -0
  98. package/dist/types/types/global.js +1 -0
  99. package/dist/types/types/index.d.ts +3 -0
  100. package/dist/types/types/index.js +2 -0
  101. package/dist/types/types/interfaces/email.d.ts +33 -0
  102. package/dist/types/types/interfaces/global.d.ts +27 -0
  103. package/dist/types/types/interfaces/index.d.ts +2 -0
  104. package/dist/types/types/types/firebase_types.d.ts +50 -0
  105. package/dist/types/types/types/global.d.ts +17 -0
  106. package/dist/types/types/types/index.d.ts +2 -0
  107. package/package.json +1 -1
@@ -0,0 +1,119 @@
1
+ import { json_failed } from "../helpers";
2
+ import { logger } from "../managers";
3
+ const validateParameter = (data, parameter, is_mandatory) => {
4
+ if (data[parameter.key] === undefined) {
5
+ if (is_mandatory) {
6
+ throw `missing mandatory parameter: ${parameter.key}`;
7
+ }
8
+ else {
9
+ return;
10
+ }
11
+ }
12
+ if (parameter.type === "array" && !Array.isArray(data[parameter.key])) {
13
+ throw `parameter ${parameter.key} must be of type: Array`;
14
+ }
15
+ if (typeof data[parameter.key] !== parameter.type && parameter.type !== "array") {
16
+ throw `parameter ${parameter.key} must be of type: ${parameter.type}`;
17
+ }
18
+ if (parameter.type === "string" && parameter.length && data[parameter.key].length < parameter.length) {
19
+ throw `parameter ${parameter.key} must be string and must have minimum length of: ${parameter.length}`;
20
+ }
21
+ const is_array = Array.isArray(data[parameter.key]);
22
+ if (is_array) {
23
+ if (parameter.length && data[parameter.key].length < parameter.length) {
24
+ throw `parameter ${parameter.key} must be array and must have minimum length of: ${parameter.length}`;
25
+ }
26
+ if (Array.isArray(parameter.array_types) && parameter.array_types.length > 0) {
27
+ data[parameter.key].forEach((item, index) => {
28
+ const item_type = typeof item;
29
+ if (!parameter.array_types.includes(item_type)) {
30
+ throw `item at index ${index} in parameter ${parameter.key} must be of type: ${parameter.array_types.join(" | ")}`;
31
+ }
32
+ });
33
+ }
34
+ }
35
+ if (parameter.type === "object" && parameter.required_keys) {
36
+ const missingKeys = parameter.required_keys.filter((key) => data[parameter.key][key] === undefined);
37
+ if (missingKeys.length > 0) {
38
+ throw `parameter ${parameter.key} is missing required keys: ${missingKeys.join(", ")}`;
39
+ }
40
+ parameter.required_keys.forEach((key) => {
41
+ const value = data[parameter.key][key];
42
+ if ((typeof value === "string" || Array.isArray(value)) && value.length === 0) {
43
+ throw `parameter ${key} in ${parameter.key} must have some length `;
44
+ }
45
+ });
46
+ }
47
+ };
48
+ export const mandatory = ({ body, headers }) => {
49
+ return (req, res, next) => {
50
+ try {
51
+ const body_data = req.body;
52
+ const headers_data = req.headers;
53
+ if (body) {
54
+ body.forEach((parameter) => {
55
+ validateParameter(body_data, parameter, true);
56
+ });
57
+ }
58
+ if (headers) {
59
+ headers.forEach((parameter) => {
60
+ validateParameter(headers_data, parameter, true);
61
+ });
62
+ }
63
+ next();
64
+ }
65
+ catch (error) {
66
+ return res.send(json_failed(error));
67
+ }
68
+ };
69
+ };
70
+ export const optional = ({ body, headers }) => {
71
+ return (req, res, next) => {
72
+ try {
73
+ const body_data = req.body;
74
+ const headers_data = req.headers;
75
+ if (body) {
76
+ body.forEach((parameter) => {
77
+ validateParameter(body_data, parameter, false);
78
+ });
79
+ }
80
+ if (headers) {
81
+ headers.forEach((parameter) => {
82
+ validateParameter(headers_data, parameter, false);
83
+ });
84
+ }
85
+ next();
86
+ }
87
+ catch (error) {
88
+ return res.send(json_failed(error));
89
+ }
90
+ };
91
+ };
92
+ const is_gcp_request = (req) => {
93
+ const user_agent = req.get("user-agent")?.toLowerCase();
94
+ return !!(user_agent?.startsWith("googlehc") ||
95
+ user_agent?.startsWith("kube-probe") ||
96
+ user_agent?.startsWith("googlestackdrivermonitoring"));
97
+ };
98
+ export const request_logger = (log_requests) => {
99
+ return (req, res, next) => {
100
+ if (!log_requests?.gcp && is_gcp_request(req)) {
101
+ return next();
102
+ }
103
+ if (log_requests?.url || log_requests?.headers || log_requests?.query || log_requests?.body) {
104
+ logger.log(`${req.method} ${req.originalUrl}`);
105
+ }
106
+ if (log_requests?.headers) {
107
+ logger.log("Headers:", req.headers);
108
+ }
109
+ if (log_requests?.query) {
110
+ logger.log("Query:", req.query);
111
+ }
112
+ if (log_requests?.body) {
113
+ if (["POST", "PUT", "PATCH"].includes(req.method)) {
114
+ logger.log("Body:", req.body);
115
+ }
116
+ }
117
+ next();
118
+ };
119
+ };
@@ -0,0 +1,4 @@
1
+ export * from "./global_mw";
2
+ export * from "./auth_mw";
3
+ export * from "./error_handling";
4
+ export * from "./trim_mw";
@@ -0,0 +1,7 @@
1
+ import { trim_strings } from "../helpers";
2
+ export const trim_body_middleware = () => (req, res, next) => {
3
+ if (req.body && typeof req.body === "object") {
4
+ req.body = trim_strings(req.body);
5
+ }
6
+ return next();
7
+ };
package/dist/test.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,8 @@
1
+ export var SimProvider;
2
+ (function (SimProvider) {
3
+ SimProvider["partner"] = "partner";
4
+ SimProvider["pelephone"] = "pelephone";
5
+ SimProvider["celcom"] = "celcom";
6
+ SimProvider["monogoto"] = "monogoto";
7
+ SimProvider["unknown"] = "unknown";
8
+ })(SimProvider || (SimProvider = {}));
@@ -0,0 +1 @@
1
+ export * from "./global";
@@ -0,0 +1,10 @@
1
+ import { Car, TObject } from "akeyless-types-commons";
2
+ interface BoardProviderWithBoardTypes {
3
+ board_provider: "erm" | "jimi" | "ruptela" | "servision" | "jimi_iothub";
4
+ board_types: string[];
5
+ }
6
+ export declare const extract_board_types_from_settings: (settings: TObject<any>) => BoardProviderWithBoardTypes[];
7
+ export type BoardMakerResult = "erm" | "jimi" | "ruptela" | "servision" | "jimi_iothub";
8
+ export declare const get_board_maker_by_board_type: (type: string) => BoardMakerResult;
9
+ export declare const get_board_maker_by_car: (car: Car) => BoardMakerResult;
10
+ export {};
@@ -0,0 +1,12 @@
1
+ import { EmailData, EmailAttachment } from "../types";
2
+ export declare const create_attachment_from_file: (file_path: string, filename?: string, disposition?: "attachment" | "inline") => Promise<EmailAttachment>;
3
+ export declare const create_attachment_from_buffer: (buffer: Buffer | Uint8Array, filename: string, mime_type: string, disposition?: "attachment" | "inline") => EmailAttachment;
4
+ export declare const create_attachment_from_url: (url: string, filename: string) => Promise<{
5
+ content: string;
6
+ filename: string;
7
+ type: string;
8
+ disposition: string;
9
+ }>;
10
+ export declare const send_email: (email_data: EmailData, options?: {
11
+ debug?: boolean;
12
+ }) => Promise<void>;
@@ -0,0 +1,56 @@
1
+ import firebase_admin from "firebase-admin";
2
+ import { AddAuditRecord, ExtraSnapshotConfig, InitSnapshotsOptions, OnSnapshotCallback, OnSnapshotParsers, QueryDocument, QueryDocumentByConditions, QueryDocumentOptional, QueryDocuments, QueryDocumentsByConditions, Snapshot, SnapshotBulk, SnapshotBulkByNames } from "../types";
3
+ import { DecodedIdToken } from "firebase-admin/auth";
4
+ import { TObject } from "akeyless-types-commons";
5
+ export declare const service_account_firebase: {
6
+ type: string;
7
+ project_id: string;
8
+ private_key_id: string;
9
+ private_key: string;
10
+ client_email: string;
11
+ client_id: string;
12
+ auth_uri: string;
13
+ token_uri: string;
14
+ auth_provider_x509_cert_url: string;
15
+ client_x509_cert_url: string;
16
+ universe_domain: string;
17
+ };
18
+ export declare const db: firebase_admin.firestore.Firestore;
19
+ export declare const messaging: import("firebase-admin/messaging").Messaging;
20
+ export declare const auth: import("firebase-admin/auth").Auth;
21
+ export declare const storage: import("firebase-admin/lib/storage/storage").Storage;
22
+ export declare const simple_extract_data: (doc: FirebaseFirestore.DocumentSnapshot) => TObject<any>;
23
+ export declare const get_all_documents: (collection_path: string) => Promise<any[]>;
24
+ export declare const query_documents: QueryDocuments;
25
+ export declare const query_documents_by_conditions: QueryDocumentsByConditions;
26
+ export declare const query_document_by_conditions: QueryDocumentByConditions;
27
+ export declare const query_document: QueryDocument;
28
+ export declare const query_document_optional: QueryDocumentOptional;
29
+ export declare const get_document_by_id: (collection_path: string, doc_id: string) => Promise<TObject<any>>;
30
+ export declare const get_document_by_id_optional: (collection_path: string, doc_id: string) => Promise<TObject<any> | null>;
31
+ export declare const set_document: (collection_path: string, doc_id: string, data: {}, merge?: boolean) => Promise<void>;
32
+ export declare const add_document: (collection_path: string, data: {}, include_id?: boolean, custom_id?: string) => Promise<string>;
33
+ export declare const delete_document: (collection_path: string, doc_id: string) => Promise<void>;
34
+ export declare const verify_token: (authorization: string | undefined, ignore_log?: boolean) => Promise<DecodedIdToken>;
35
+ export declare const parse_add_update_as_object: OnSnapshotCallback;
36
+ export declare const parse_delete_as_object: OnSnapshotCallback;
37
+ export declare const parse_add_update_as_array: OnSnapshotCallback;
38
+ export declare const parse_delete_as_array: OnSnapshotCallback;
39
+ export declare const snapshot: Snapshot;
40
+ export declare const init_snapshots: (options?: InitSnapshotsOptions) => Promise<void>;
41
+ export declare const snapshot_bulk: SnapshotBulk;
42
+ export declare const get_default_parsers: (parse_as: ExtraSnapshotConfig["parse_as"]) => OnSnapshotParsers;
43
+ export declare const snapshot_bulk_by_names: SnapshotBulkByNames;
44
+ export declare const add_audit_record: AddAuditRecord;
45
+ export declare const add_nx_problem: (problem: string, key: string, details: TObject<any>) => Promise<void>;
46
+ export interface SaveFileOptions {
47
+ content_type?: string;
48
+ content_disposition?: string;
49
+ cache_control?: string;
50
+ make_public?: boolean;
51
+ signed_url_ttl_ms?: number;
52
+ resumable?: boolean;
53
+ }
54
+ export declare const save_file_in_storage: (file_path: string, buffer: Buffer | Uint8Array, options?: SaveFileOptions) => Promise<string>;
55
+ export declare const get_file_url_from_storage: (file_path: string) => Promise<string>;
56
+ export declare const get_nx_settings: () => Promise<any>;
@@ -0,0 +1,16 @@
1
+ import { JsonFailed, JsonOK, NxServiceNameMap } from "../types";
2
+ import { Geo, LanguageOptions, TObject } from "akeyless-types-commons";
3
+ import { AxiosRequestConfig } from "axios";
4
+ export declare const init_env_variables: (required_vars?: string[]) => TObject<string>;
5
+ export declare const json_ok: JsonOK<TObject<any> | TObject<any>[]>;
6
+ export declare const json_failed: JsonFailed;
7
+ export declare const parse_error: (error: any) => any;
8
+ export declare const get_version: (packageJsonPath: string) => string;
9
+ export declare const sleep: (ms?: number) => Promise<unknown>;
10
+ export declare function get_nx_service_urls(env_name?: string): NxServiceNameMap;
11
+ export declare const get_address_by_geo: ({ lat, lng }: Geo, currentLanguage: LanguageOptions) => Promise<string>;
12
+ export declare const validate_and_cast: <T extends any>(variable: any, condition: Boolean) => variable is T;
13
+ export declare const get_or_default: <T>(value: T | undefined, default_value: T | (() => T)) => T;
14
+ export declare const trim_strings: <T>(input: any) => any;
15
+ export declare const remove_nulls_and_undefined: (obj: Record<string, any>) => Record<string, any>;
16
+ export declare const ignore_ssl_request: (config: AxiosRequestConfig) => Promise<import("axios").AxiosResponse<any, any>>;
@@ -0,0 +1,13 @@
1
+ export * from "./global_helpers";
2
+ export * from "./firebase_helpers";
3
+ export * from "./start";
4
+ export * from "./time_helpers";
5
+ export * from "./login_helpers";
6
+ export * from "./notification_helpers";
7
+ export * from "./email_helpers";
8
+ export * from "./phone_number_helpers";
9
+ export * from "./tasks_helpers";
10
+ export * from "./postponed_actions";
11
+ export * from "./boards_helpers";
12
+ export * from "./redis";
13
+ export * from "./location_helpers";
@@ -0,0 +1,3 @@
1
+ import { Geo } from "akeyless-types-commons";
2
+ export declare const get_distance_in_meters_between_geo_points: (location1: Geo, location2: Geo) => number;
3
+ export declare const get_location_url: (location: Geo) => string;
@@ -0,0 +1,4 @@
1
+ import { NxUser, MobileAppUser } from "akeyless-types-commons";
2
+ export declare const convert_to_short_phone_number: (phone_number: string) => string;
3
+ export declare const get_user_by_identifier: (identifier: string, ignore_log?: boolean) => Promise<NxUser | null>;
4
+ export declare const get_mobile_app_user_by_uid: (uid: string, ignore_log?: boolean) => Promise<MobileAppUser | null>;
@@ -0,0 +1,11 @@
1
+ import { EventFromDevice, TObject } from "akeyless-types-commons";
2
+ export declare const send_sms: (recepient: string, text: string, entity_for_audit: string, details?: TObject<any>) => Promise<void>;
3
+ export declare const push_event_to_mobile_users: (event: EventFromDevice) => Promise<void>;
4
+ type FuncSendFcmMessage = (title: string, body: string, fcm_tokens: string[], custom_sound?: string) => Promise<{
5
+ success: boolean;
6
+ response: string;
7
+ success_count?: number;
8
+ failure_count?: number;
9
+ }>;
10
+ export declare const send_fcm_message: FuncSendFcmMessage;
11
+ export {};
@@ -0,0 +1,19 @@
1
+ import { SimProvider } from "../types/enums";
2
+ export declare const is_long_phone_number: (phone_number: string) => boolean;
3
+ export declare const is_israel_long_phone_number: (phone_number: string) => boolean;
4
+ export declare const is_thailand_long_phone_number: (phone_number: string) => boolean;
5
+ export declare const is_international_phone_number: (phone_number: string) => boolean;
6
+ export declare const is_iccid: (number: string) => boolean;
7
+ export declare const convert_to_short_israel_phone: (international_number: string) => string;
8
+ export declare const is_sim_provider_partner: (phone_number: string) => boolean;
9
+ export declare const is_sim_provider_pelephone: (phone_number: string) => boolean;
10
+ export declare const is_sim_provider_celcom: (phone_number: string) => boolean;
11
+ export declare const is_sim_provider_monogoto: (phone_number: string) => boolean;
12
+ export declare const get_sim_provider: (phone_number: string) => SimProvider;
13
+ interface LongShortPhoneNumbers {
14
+ short_phone_number: string;
15
+ long_phone_number: string;
16
+ is_israeli: boolean;
17
+ }
18
+ export declare const long_short_phone_numbers: (phone_number: string) => LongShortPhoneNumbers;
19
+ export {};
@@ -0,0 +1,113 @@
1
+ import { TObject } from "akeyless-types-commons";
2
+ export declare enum PostponedActionStatus {
3
+ pending = "pending",
4
+ processing = "processing",
5
+ completed = "completed",
6
+ cancelled = "cancelled",
7
+ failed = "failed"
8
+ }
9
+ export type PostponedActionTime = Date | string | {
10
+ minutes?: number;
11
+ hours?: number;
12
+ };
13
+ export type JsonPayload = TObject<any>;
14
+ export interface PostponedAction {
15
+ key: string;
16
+ details: JsonPayload;
17
+ action_type: string;
18
+ description: string;
19
+ execute_at: Date;
20
+ status: PostponedActionStatus;
21
+ attempt_count: number;
22
+ created_at: Date;
23
+ updated_at: Date;
24
+ started_at?: Date;
25
+ completed_at?: Date;
26
+ cancelled_at?: Date;
27
+ failed_at?: Date;
28
+ error?: string;
29
+ }
30
+ export interface AddPostponedAction {
31
+ key: string;
32
+ details: JsonPayload;
33
+ action_type: string;
34
+ description: string;
35
+ execute_at: PostponedActionTime;
36
+ }
37
+ export interface UpdatePostponedAction {
38
+ details?: JsonPayload;
39
+ action_type?: string;
40
+ description?: string;
41
+ execute_at?: PostponedActionTime;
42
+ }
43
+ export declare const resolve_postponed_action_time: (value: PostponedActionTime, now?: Date) => Date;
44
+ export declare const get_postponed_action: (key: string) => Promise<PostponedAction | null>;
45
+ export declare const add_postponed_action: (input: AddPostponedAction) => Promise<PostponedAction>;
46
+ export declare const update_postponed_action: (key: string, input: UpdatePostponedAction) => Promise<void>;
47
+ export declare const repostpone_postponed_action: (key: string, execute_at: PostponedActionTime) => Promise<void>;
48
+ export declare const cancel_postponed_action: (key: string) => Promise<void>;
49
+ export declare const complete_postponed_action: (key: string) => Promise<void>;
50
+ export declare const fail_postponed_action: (key: string, error: unknown) => Promise<void>;
51
+ export declare const delete_postponed_action: (key: string) => Promise<void>;
52
+ export declare const claim_postponed_action: (key: string, action_type: string, now?: Date | undefined) => Promise<PostponedAction | null>;
53
+ export declare const claim_due_postponed_actions: (action_type: string, limit?: number | undefined, now?: Date | undefined) => Promise<PostponedAction[]>;
54
+ /**
55
+ * @example Add an action for a specific date and time.
56
+ * ```ts
57
+ * await postponed_actions.add({
58
+ * key: "subscription:123:expire",
59
+ * action_type: "subscription_expiration",
60
+ * description: "Expire subscription 123",
61
+ * details: { subscription_id: "123", notify_customer: true },
62
+ * execute_at: new Date("2026-08-01T12:00:00Z"),
63
+ * });
64
+ * ```
65
+ *
66
+ * @example Add an action relative to the current time. Adding the same key
67
+ * updates the pending action.
68
+ * ```ts
69
+ * await postponed_actions.add({
70
+ * key: "invoice:456:reminder",
71
+ * action_type: "invoice_reminder",
72
+ * description: "Send invoice 456 reminder",
73
+ * details: { invoice_id: "456" },
74
+ * execute_at: { hours: 2, minutes: 30 },
75
+ * });
76
+ * ```
77
+ *
78
+ * @example Update, repostpone, or cancel a pending action.
79
+ * ```ts
80
+ * await postponed_actions.update("invoice:456:reminder", {
81
+ * description: "Send the final invoice reminder",
82
+ * execute_at: { minutes: 15 },
83
+ * });
84
+ * await postponed_actions.repostpone("invoice:456:reminder", { hours: 1 });
85
+ * await postponed_actions.cancel("invoice:456:reminder");
86
+ * ```
87
+ *
88
+ * @example Claim and execute due actions. Claiming is atomic, so concurrent
89
+ * workers cannot claim the same action.
90
+ * ```ts
91
+ * const actions = await postponed_actions.claim_due("invoice_reminder", 25);
92
+ * for (const action of actions) {
93
+ * try {
94
+ * await execute_action(action.details);
95
+ * await postponed_actions.complete(action.key);
96
+ * } catch (error) {
97
+ * await postponed_actions.fail(action.key, error);
98
+ * }
99
+ * }
100
+ * ```
101
+ */
102
+ export declare const postponed_actions: {
103
+ get: (key: string) => Promise<PostponedAction | null>;
104
+ add: (input: AddPostponedAction) => Promise<PostponedAction>;
105
+ update: (key: string, input: UpdatePostponedAction) => Promise<void>;
106
+ repostpone: (key: string, execute_at: PostponedActionTime) => Promise<void>;
107
+ cancel: (key: string) => Promise<void>;
108
+ complete: (key: string) => Promise<void>;
109
+ fail: (key: string, error: unknown) => Promise<void>;
110
+ delete: (key: string) => Promise<void>;
111
+ claim: (key: string, action_type: string, now?: Date | undefined) => Promise<PostponedAction | null>;
112
+ claim_due: (action_type: string, limit?: number | undefined, now?: Date | undefined) => Promise<PostponedAction[]>;
113
+ };
@@ -0,0 +1,11 @@
1
+ import { TObject } from "akeyless-types-commons";
2
+ import { WhereCondition } from "../../types";
3
+ export declare const redis_simple_extract_data: (raw: string) => TObject<any>;
4
+ export declare const redis_get_all_documents: (collection_path: string) => Promise<TObject<any>[]>;
5
+ export declare const redis_query_documents: (collection_path: string, field_name: string, operator: FirebaseFirestore.WhereFilterOp, value: any) => Promise<TObject<any>[]>;
6
+ export declare const redis_query_documents_by_conditions: (collection_path: string, where_conditions: WhereCondition[]) => Promise<TObject<any>[]>;
7
+ export declare const redis_query_document_by_conditions: (collection_path: string, where_conditions: WhereCondition[], ignore_logs?: boolean) => Promise<TObject<any>>;
8
+ export declare const redis_query_document: (collection_path: string, field_name: string, operator: FirebaseFirestore.WhereFilterOp, value: any, ignore_log?: boolean) => Promise<TObject<any>>;
9
+ export declare const redis_query_document_optional: (collection_path: string, field_name: string, operator: FirebaseFirestore.WhereFilterOp, value: any, ignore_log?: boolean) => Promise<TObject<any> | null>;
10
+ export declare const redis_get_document_by_id: (collection_path: string, doc_id: string) => Promise<TObject<any>>;
11
+ export declare const redis_get_document_by_id_optional: (collection_path: string, doc_id: string) => Promise<TObject<any> | null>;
@@ -0,0 +1,4 @@
1
+ export * from "./initialize";
2
+ export * from "./keys";
3
+ export * from "./snapshot";
4
+ export * from "./helpers";
@@ -0,0 +1,6 @@
1
+ import Redis from "ioredis";
2
+ export declare let redis_commander_connected: boolean;
3
+ export declare let redis_listener_connected: boolean;
4
+ export declare const init_redis: () => Promise<void>;
5
+ export declare const get_redis_commander: () => Redis;
6
+ export declare const get_redis_listener: () => Redis;
@@ -0,0 +1,5 @@
1
+ import Redis from "ioredis";
2
+ export declare const get_doc_key: (collection: string, doc_id: string) => string;
3
+ export declare const get_collection_keys: (collection: string) => string;
4
+ export declare const get_channel: (...args: string[]) => string;
5
+ export declare const scan_redis_keys: (pattern: string, redis_publisher: Redis) => Promise<string[]>;
@@ -0,0 +1,2 @@
1
+ import { OnSnapshotConfig } from "../../types";
2
+ export declare const redis_snapshots_bulk: (configs: OnSnapshotConfig[]) => Promise<void>;
@@ -0,0 +1,4 @@
1
+ import { Express } from "express";
2
+ import { AppOptions, MainRouter } from "../types";
3
+ export declare const start_server: (main_router: MainRouter, project_name: string, version: string, options?: AppOptions) => Promise<Express>;
4
+ export declare const basic_init: (main_router: MainRouter, project_name: string, version: string, options?: AppOptions) => Promise<Express>;
@@ -0,0 +1,25 @@
1
+ import { TObject } from "akeyless-types-commons";
2
+ export declare enum TaskName {
3
+ send_reset_sms = "send_reset_sms",
4
+ collect_devices_health = "collect_devices_health",
5
+ collect_charge_locations = "collect_charge_locations",
6
+ collect_charge_cdrs = "collect_charge_cdrs",
7
+ auto_connect_to_call_center = "auto_connect_to_call_center",
8
+ make_erm_ev_events = "make_erm_ev_events",
9
+ collect_jimi_cars_odometer = "collect_jimi_cars_odometer"
10
+ }
11
+ export declare enum TaskStatus {
12
+ running = "running",
13
+ completed = "completed",
14
+ failed = "failed",
15
+ suspeneded = "suspeneded"
16
+ }
17
+ export type TaskSaveOptions = "storage" | "db" | "none";
18
+ export interface ExecuteTaskOptions {
19
+ save_in?: TaskSaveOptions;
20
+ debug_logs?: boolean;
21
+ }
22
+ export declare const execute_task: <T = any>(source: string, task_name: TaskName, task: () => Promise<T>, options?: ExecuteTaskOptions) => Promise<void>;
23
+ export declare const get_task_data: <T = any>(task_name: TaskName) => Promise<T>;
24
+ export declare const get_task_data_from_storage: <T = any>(task_name: TaskName) => Promise<T | null>;
25
+ export declare const keep_task_data_in_storage: (task_name: TaskName, data: any[] | TObject<any>) => Promise<string>;
@@ -0,0 +1,40 @@
1
+ import { Timestamp } from "firebase-admin/firestore";
2
+ import { firebase_timestamp } from "akeyless-types-commons";
3
+ export declare function sort_by_timestamp(a: Timestamp, b: Timestamp, reverse?: boolean): number;
4
+ export interface TimePassedByDate {
5
+ seconds_passed: number;
6
+ minutes_passed: number;
7
+ hours_passed: number;
8
+ days_passed: number;
9
+ time_passed_formatted_short: string;
10
+ time_passed_formatted_long: string;
11
+ }
12
+ export declare const calculate_time_passed: (datetime: Date) => TimePassedByDate;
13
+ interface TimeToStringOptions {
14
+ format?: string;
15
+ fromFormat?: string;
16
+ tz?: string;
17
+ defaultReturnedValue?: string;
18
+ debug?: boolean;
19
+ }
20
+ export declare function any_datetime_to_string(firebaseTimestamp: Timestamp | Date | string | firebase_timestamp | number, options?: TimeToStringOptions): string;
21
+ interface TimeToMillisOptions extends Omit<TimeToStringOptions, "defaultReturnedValue" | "format"> {
22
+ defaultReturnedValue?: number;
23
+ }
24
+ export declare function any_datetime_to_millis(firebaseTimestamp: Timestamp | Date | string | number | firebase_timestamp, options?: TimeToMillisOptions): number;
25
+ /**
26
+ * Converts a Firebase Timestamp object into a formatted string.
27
+ *
28
+ * @param {firebase_timestamp} firebaseTimestamp - The Firebase timestamp object containing _seconds and _nanoseconds.
29
+ * @param {string} [format="DD-MM-YYYY HH:mm:ss"] - Optional the format string used to format the date. Default is "DD-MM-YYYY HH:mm:ss".
30
+ * @returns {string} - A formatted date string according to the specified format or the default format.
31
+ */
32
+ export declare function timestamp_to_string(firebaseTimestamp: firebase_timestamp, format?: string): string;
33
+ /**
34
+ * Converts a Firebase Timestamp object into milliseconds since the Unix epoch.
35
+ *
36
+ * @param {firebase_timestamp} firebaseTimestamp - The Firebase timestamp object containing _seconds and _nanoseconds.
37
+ * @returns {number} - Time in milliseconds
38
+ */
39
+ export declare function timestamp_to_millis(firebaseTimestamp: firebase_timestamp): number;
40
+ export {};
@@ -0,0 +1,5 @@
1
+ import * as helpers from "./helpers";
2
+ import * as managers from "./managers";
3
+ import * as middlewares from "./middlewares";
4
+ import * as types from "./types";
5
+ export { helpers, managers, middlewares, types };
@@ -0,0 +1,3 @@
1
+ export * from './types';
2
+ export * from './interfaces';
3
+ export * from './enums';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './global';
2
+ export * from './email';
@@ -0,0 +1,12 @@
1
+ export declare class CacheManager {
2
+ private static instance;
3
+ private data;
4
+ private constructor();
5
+ static getInstance(): CacheManager;
6
+ setArrayData(key: string, data: any[]): void;
7
+ getArrayData(key: string): any[];
8
+ setObjectData(key: string, data: any): void;
9
+ getObjectData(key: string, default_value?: any): any;
10
+ getObjectDataAsArray(key: string, default_value?: any): any[];
11
+ }
12
+ export declare const cache_manager: CacheManager;
@@ -0,0 +1,4 @@
1
+ export * from "./cache_manager";
2
+ export * from "./translation_manager";
3
+ export * from "./logger_manager";
4
+ export * from "./rabbitmq_manager";
@@ -0,0 +1,14 @@
1
+ import { TObject } from "akeyless-types-commons";
2
+ declare class LoggerManager {
3
+ private static instance;
4
+ private constructor();
5
+ static getInstance(): LoggerManager;
6
+ private get_date;
7
+ private is_gcp;
8
+ private emit;
9
+ log(msg: string, data?: TObject<any> | any[]): void;
10
+ error(msg: string, data?: any): void;
11
+ warn(msg: string, data?: any): void;
12
+ }
13
+ export declare const logger: LoggerManager;
14
+ export {};