akeyless-server-commons 1.0.13 → 1.0.15

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 (63) hide show
  1. package/dist/cjs/helpers/global_helpers.d.ts +1 -0
  2. package/dist/cjs/helpers/global_helpers.js +3 -1
  3. package/dist/cjs/helpers/global_helpers.js.map +1 -1
  4. package/dist/esm/helpers/global_helpers.d.ts +1 -0
  5. package/dist/esm/helpers/global_helpers.js +1 -0
  6. package/dist/esm/helpers/global_helpers.js.map +1 -1
  7. package/package.json +1 -1
  8. package/dist/helpers/email_helpers.js +0 -69
  9. package/dist/helpers/firebase_helpers.js +0 -370
  10. package/dist/helpers/global_helpers.js +0 -113
  11. package/dist/helpers/index.js +0 -8
  12. package/dist/helpers/login_helpers.js +0 -18
  13. package/dist/helpers/notification_helpers.js +0 -230
  14. package/dist/helpers/phone_number_helpers.js +0 -88
  15. package/dist/helpers/start.js +0 -42
  16. package/dist/helpers/time_helpers.js +0 -26
  17. package/dist/index.js +0 -5
  18. package/dist/managers/cache_manager.js +0 -27
  19. package/dist/managers/index.js +0 -3
  20. package/dist/managers/logger_manager.js +0 -49
  21. package/dist/managers/translation_manager.js +0 -38
  22. package/dist/middlewares/auth_mw.js +0 -46
  23. package/dist/middlewares/error_handling.js +0 -19
  24. package/dist/middlewares/global_mw.js +0 -50
  25. package/dist/middlewares/index.js +0 -3
  26. package/dist/test.js +0 -15
  27. package/dist/types/enums/global.js +0 -18
  28. package/dist/types/enums/index.js +0 -1
  29. package/dist/types/helpers/email_helpers.d.ts +0 -2
  30. package/dist/types/helpers/firebase_helpers.d.ts +0 -24
  31. package/dist/types/helpers/global_helpers.d.ts +0 -11
  32. package/dist/types/helpers/index.d.ts +0 -8
  33. package/dist/types/helpers/login_helpers.d.ts +0 -3
  34. package/dist/types/helpers/notification_helpers.d.ts +0 -11
  35. package/dist/types/helpers/phone_number_helpers.d.ts +0 -13
  36. package/dist/types/helpers/start.d.ts +0 -5
  37. package/dist/types/helpers/time_helpers.d.ts +0 -17
  38. package/dist/types/index.d.ts +0 -5
  39. package/dist/types/index.js +0 -3
  40. package/dist/types/interfaces/email.js +0 -1
  41. package/dist/types/interfaces/global.js +0 -1
  42. package/dist/types/interfaces/index.js +0 -2
  43. package/dist/types/managers/cache_manager.d.ts +0 -11
  44. package/dist/types/managers/index.d.ts +0 -3
  45. package/dist/types/managers/logger_manager.d.ts +0 -12
  46. package/dist/types/managers/translation_manager.d.ts +0 -14
  47. package/dist/types/middlewares/auth_mw.d.ts +0 -4
  48. package/dist/types/middlewares/error_handling.d.ts +0 -11
  49. package/dist/types/middlewares/global_mw.d.ts +0 -2
  50. package/dist/types/middlewares/index.d.ts +0 -3
  51. package/dist/types/test.d.ts +0 -1
  52. package/dist/types/types/enums/global.d.ts +0 -16
  53. package/dist/types/types/enums/index.d.ts +0 -1
  54. package/dist/types/types/firebase_types.js +0 -1
  55. package/dist/types/types/global.js +0 -1
  56. package/dist/types/types/index.d.ts +0 -3
  57. package/dist/types/types/index.js +0 -2
  58. package/dist/types/types/interfaces/email.d.ts +0 -24
  59. package/dist/types/types/interfaces/global.d.ts +0 -12
  60. package/dist/types/types/interfaces/index.d.ts +0 -2
  61. package/dist/types/types/types/firebase_types.d.ts +0 -30
  62. package/dist/types/types/types/global.d.ts +0 -15
  63. package/dist/types/types/types/index.d.ts +0 -2
@@ -1,18 +0,0 @@
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 = {}));
9
- export var NxServiceName;
10
- (function (NxServiceName) {
11
- NxServiceName["bi"] = "bi";
12
- NxServiceName["call_center"] = "call_center";
13
- NxServiceName["dashboard"] = "dashboard";
14
- NxServiceName["devices"] = "devices";
15
- NxServiceName["installer"] = "installer";
16
- NxServiceName["ox_server"] = "ox_server";
17
- NxServiceName["toolbox"] = "toolbox";
18
- })(NxServiceName || (NxServiceName = {}));
@@ -1 +0,0 @@
1
- export * from "./global";
@@ -1,2 +0,0 @@
1
- import { EmailData } from "../types";
2
- export declare const send_email: (email_data: EmailData) => Promise<void>;
@@ -1,24 +0,0 @@
1
- import firebase_admin from "firebase-admin";
2
- import { 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 db: firebase_admin.firestore.Firestore;
6
- export declare const messaging: import("firebase-admin/messaging").Messaging;
7
- export declare const auth: import("firebase-admin/auth").Auth;
8
- export declare const simple_extract_data: (doc: FirebaseFirestore.DocumentSnapshot) => TObject<any>;
9
- export declare const get_all_documents: (collection_path: string) => Promise<any[]>;
10
- export declare const query_documents: QueryDocuments;
11
- export declare const query_documents_by_conditions: QueryDocumentsByConditions;
12
- export declare const query_document_by_conditions: QueryDocumentByConditions;
13
- export declare const query_document: QueryDocument;
14
- export declare const query_document_optional: QueryDocumentOptional;
15
- export declare const get_document_by_id: (collection_path: string, doc_id: string) => Promise<TObject<any>>;
16
- export declare const get_document_by_id_optional: (collection_path: string, doc_id: string) => Promise<TObject<any> | null>;
17
- export declare const set_document: (collection_path: string, doc_id: string, data: {}, merge?: boolean) => Promise<void>;
18
- export declare const add_document: (collection_path: string, data: {}, include_id?: boolean) => Promise<void>;
19
- export declare const delete_document: (collection_path: string, doc_id: string) => Promise<void>;
20
- export declare const verify_token: (authorization: string | undefined) => Promise<DecodedIdToken>;
21
- export declare const snapshot: Snapshot;
22
- export declare const init_snapshots: () => Promise<void>;
23
- export declare const snapshot_bulk: SnapshotBulk;
24
- export declare const snapshot_bulk_by_names: SnapshotBulkByNames;
@@ -1,11 +0,0 @@
1
- import { AddAuditRecord, JsonFailed, JsonOK } from "../types";
2
- import { Geo, LanguageOptions, TObject } from "akeyless-types-commons";
3
- export declare const init_env_variables: (required_vars?: string[]) => TObject<string>;
4
- export declare const json_ok: JsonOK<TObject<any> | TObject<any>[]>;
5
- export declare const json_failed: JsonFailed;
6
- export declare const parse_error: (error: any) => any;
7
- export declare const get_version: (packageJsonPath: string) => string;
8
- export declare const sleep: (ms?: number) => Promise<unknown>;
9
- export declare const add_audit_record: AddAuditRecord;
10
- export declare const get_nx_service_urls: (env_name?: string) => TObject<string>;
11
- export declare const get_address_by_geo: ({ lat, lng }: Geo, currentLanguage: LanguageOptions) => Promise<string>;
@@ -1,8 +0,0 @@
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";
@@ -1,3 +0,0 @@
1
- import { NxUser } 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) => Promise<NxUser>;
@@ -1,11 +0,0 @@
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 {};
@@ -1,13 +0,0 @@
1
- import { TObject } from "akeyless-types-commons";
2
- import { SimProvider } from "../types/enums";
3
- export declare const is_long_phone_number: (phone_number: string) => boolean;
4
- export declare const is_israel_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) => any;
9
- export declare const is_sim_provider_pelephone: (phone_number: string) => any;
10
- export declare const is_sim_provider_celcom: (phone_number: string) => any;
11
- export declare const is_sim_provider_monogoto: (phone_number: string) => boolean;
12
- export declare const get_sim_provider: (phone_number: string) => SimProvider;
13
- export declare const long_short_phone_numbers: (phone_number: string) => TObject<any>;
@@ -1,5 +0,0 @@
1
- import { Express } from "express";
2
- import { MainRouter } from "../types";
3
- export declare const start_server: (main_router: MainRouter, project_name: string, version: string) => Promise<Express>;
4
- export declare const basic_init: (main_router: MainRouter, project_name: string, version: string) => Promise<Express>;
5
- export declare const nextjs_init: (project_name: string, version: string) => Promise<void>;
@@ -1,17 +0,0 @@
1
- import { firebase_timestamp } from "akeyless-types-commons";
2
- /**
3
- * Converts a Firebase Timestamp object into a formatted string.
4
- *
5
- * @param {firebase_timestamp} firebaseTimestamp - The Firebase timestamp object containing _seconds and _nanoseconds.
6
- * @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".
7
- * @returns {string} - A formatted date string according to the specified format or the default format.
8
- */
9
- export declare function timestamp_to_string(firebaseTimestamp: firebase_timestamp, format?: string): string;
10
- /**
11
- * Converts a Firebase Timestamp object into milliseconds since the Unix epoch.
12
- *
13
- * @param {firebase_timestamp} firebaseTimestamp - The Firebase timestamp object containing _seconds and _nanoseconds.
14
- * @returns {number} - Time in milliseconds
15
- */
16
- export declare function timestamp_to_millis(firebaseTimestamp: firebase_timestamp): number;
17
- export declare function sort_by_timestamp(a: firebase_timestamp, b: firebase_timestamp, reverse?: boolean): number;
@@ -1,5 +0,0 @@
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 };
@@ -1,3 +0,0 @@
1
- export * from './types';
2
- export * from './interfaces';
3
- export * from './enums';
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- export * from './global';
2
- export * from './email';
@@ -1,11 +0,0 @@
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
- }
11
- export declare const cache_manager: CacheManager;
@@ -1,3 +0,0 @@
1
- export * from "./cache_manager";
2
- export * from "./translation_manager";
3
- export * from "./logger_manager";
@@ -1,12 +0,0 @@
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
- log(msg: string, data?: TObject<any> | any[]): void;
8
- error(msg: string, data?: any): void;
9
- warn(msg: string, data?: any): void;
10
- }
11
- export declare const logger: LoggerManager;
12
- export {};
@@ -1,14 +0,0 @@
1
- import { TObject } from "akeyless-types-commons";
2
- import { EntityOptions, LangOptions } from "../types";
3
- export declare class TranslationManager {
4
- private static instance;
5
- private data;
6
- private constructor();
7
- static getInstance(): TranslationManager;
8
- setTranslationData(data: TObject<any>): void;
9
- getTranslationData(): TObject<any>;
10
- get_translation(scope: string, lang: string, entity: string, key: string): string;
11
- get_sms(lang: LangOptions, entity: EntityOptions, key: string): string;
12
- get_email(lang: LangOptions, entity: EntityOptions, key: string): string;
13
- }
14
- export declare const translation_manager: TranslationManager;
@@ -1,4 +0,0 @@
1
- import { MW } from "../types";
2
- export declare const verify_user_auth: MW;
3
- export declare const nx_user_login: MW;
4
- export declare const client_login: MW;
@@ -1,11 +0,0 @@
1
- import { Request, Response, NextFunction } from "express";
2
- import { Service } from "../types";
3
- /**
4
- * Utility to handle async errors
5
- */
6
- declare const async_error_handler: (service: Service) => (req: Request, res: Response, next: NextFunction) => void;
7
- /**
8
- * Global error-handling middleware.
9
- */
10
- declare const error_handler: (err: Error, req: Request, res: Response, next: NextFunction) => void;
11
- export { error_handler, async_error_handler };
@@ -1,2 +0,0 @@
1
- import { MandatoryParams, MW } from "../types";
2
- export declare const mandatory: ({ body, headers }: MandatoryParams) => MW;
@@ -1,3 +0,0 @@
1
- export * from "./global_mw";
2
- export * from "./auth_mw";
3
- export * from "./error_handling";
@@ -1 +0,0 @@
1
- export {};
@@ -1,16 +0,0 @@
1
- export declare enum SimProvider {
2
- partner = "partner",
3
- pelephone = "pelephone",
4
- celcom = "celcom",
5
- monogoto = "monogoto",
6
- unknown = "unknown"
7
- }
8
- export declare enum NxServiceName {
9
- bi = "bi",
10
- call_center = "call_center",
11
- dashboard = "dashboard",
12
- devices = "devices",
13
- installer = "installer",
14
- ox_server = "ox_server",
15
- toolbox = "toolbox"
16
- }
@@ -1 +0,0 @@
1
- export * from "./global";
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- export * from './types';
2
- export * from './interfaces';
3
- export * from './enums';
@@ -1,2 +0,0 @@
1
- export * from "./global";
2
- export * from "./firebase_types";
@@ -1,24 +0,0 @@
1
- export interface EmailData {
2
- subject: string;
3
- entity_for_audit: string;
4
- to?: string | string[];
5
- from?: string | {
6
- email: string;
7
- name?: string;
8
- };
9
- group_name?: string;
10
- cc?: string | string[];
11
- body_plain_text?: string;
12
- body_html?: string;
13
- }
14
- export interface EmailSettings {
15
- default_from: {
16
- email: string;
17
- name?: string;
18
- };
19
- groups: Record<string, {
20
- cc?: string[];
21
- to: string[];
22
- }>;
23
- sendgrid_api_key: string;
24
- }
@@ -1,12 +0,0 @@
1
- export interface MandatoryObject {
2
- key: string;
3
- type: "string" | "number" | "boolean" | "object" | "array";
4
- length?: number;
5
- required_keys?: string[];
6
- }
7
- export interface MandatoryParams {
8
- body?: MandatoryObject[];
9
- headers?: MandatoryObject[];
10
- }
11
- export type LangOptions = "he" | "en" | "ru" | (string & {});
12
- export type EntityOptions = "nx_devices" | (string & {});
@@ -1,2 +0,0 @@
1
- export * from './global';
2
- export * from './email';
@@ -1,30 +0,0 @@
1
- import { TObject } from "akeyless-types-commons";
2
- export type QueryDocuments = (collection_path: string, field_name: string, operator: FirebaseFirestore.WhereFilterOp, value: any) => Promise<TObject<any>[]>;
3
- export type WhereCondition = {
4
- field_name: string;
5
- operator: FirebaseFirestore.WhereFilterOp;
6
- value: any;
7
- };
8
- export type QueryDocumentsByConditions = (collection_path: string, where_conditions: WhereCondition[]) => Promise<TObject<any>[]>;
9
- export type QueryDocumentByConditions = (collection_path: string, where_conditions: WhereCondition[], log?: boolean) => Promise<TObject<any>>;
10
- export type QueryDocument = (collection_path: string, field_name: string, operator: FirebaseFirestore.WhereFilterOp, value: any, ignore_log?: boolean) => Promise<TObject<any>>;
11
- export type QueryDocumentOptional = (collection_path: string, field_name: string, operator: FirebaseFirestore.WhereFilterOp, value: any) => Promise<TObject<any> | null>;
12
- export type OnSnapshotCallback = (documents: any[], config: OnSnapshotConfig) => void;
13
- export interface OnSnapshotParsers {
14
- on_first_time?: OnSnapshotCallback;
15
- on_add?: OnSnapshotCallback;
16
- on_modify?: OnSnapshotCallback;
17
- on_remove?: OnSnapshotCallback;
18
- }
19
- export interface OnSnapshotConfig extends OnSnapshotParsers {
20
- collection_name: string;
21
- extra_parsers?: OnSnapshotParsers[];
22
- }
23
- export type Snapshot = (config: OnSnapshotConfig) => Promise<void>;
24
- export type SnapshotBulk = (snapshots: ReturnType<Snapshot>[], label?: string) => Promise<void>;
25
- export type SnapshotBulkByNamesParamObject = {
26
- collection_name: string;
27
- extra_parsers: OnSnapshotParsers[];
28
- };
29
- export type SnapshotBulkByNamesParam = string | SnapshotBulkByNamesParamObject;
30
- export type SnapshotBulkByNames = (params: SnapshotBulkByNamesParam[]) => Promise<void>;
@@ -1,15 +0,0 @@
1
- import { Request, Response, Express, NextFunction } from "express";
2
- import { NxUser, TObject } from "akeyless-types-commons";
3
- export type JsonOK<T> = (data?: T) => {
4
- success: true;
5
- data: T | undefined;
6
- };
7
- export type JsonFailed = (error?: any, msg?: string) => {
8
- success: false;
9
- error: any;
10
- };
11
- export type MainRouter = (app: Express) => void;
12
- export type MW = (req: Request, res: Response, next: NextFunction) => void;
13
- export type Service = (req: Request, res: Response) => void;
14
- export type Route = (req: Request, res: Response, next?: NextFunction) => Response;
15
- export type AddAuditRecord = (action: string, entity: string, details: TObject<any>, user?: NxUser) => Promise<void>;
@@ -1,2 +0,0 @@
1
- export * from "./global";
2
- export * from "./firebase_types";