@arcraz/common 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.
- package/LICENSE +190 -0
- package/README.md +373 -0
- package/dist/aws/bedrock/client-factory.d.ts +45 -0
- package/dist/aws/bedrock/client-factory.d.ts.map +1 -0
- package/dist/aws/bedrock/client-factory.js +113 -0
- package/dist/aws/bedrock/index.d.ts +3 -0
- package/dist/aws/bedrock/index.d.ts.map +1 -0
- package/dist/aws/bedrock/index.js +1 -0
- package/dist/aws/bedrock/types.d.ts +95 -0
- package/dist/aws/bedrock/types.d.ts.map +1 -0
- package/dist/aws/bedrock/types.js +1 -0
- package/dist/aws/cloudfront/index.d.ts +3 -0
- package/dist/aws/cloudfront/index.d.ts.map +1 -0
- package/dist/aws/cloudfront/index.js +1 -0
- package/dist/aws/cloudfront/signer-factory.d.ts +36 -0
- package/dist/aws/cloudfront/signer-factory.d.ts.map +1 -0
- package/dist/aws/cloudfront/signer-factory.js +75 -0
- package/dist/aws/cloudfront/types.d.ts +52 -0
- package/dist/aws/cloudfront/types.d.ts.map +1 -0
- package/dist/aws/cloudfront/types.js +1 -0
- package/dist/aws/s3/client-factory.d.ts +13 -0
- package/dist/aws/s3/client-factory.d.ts.map +1 -0
- package/dist/aws/s3/client-factory.js +25 -0
- package/dist/aws/s3/index.d.ts +4 -0
- package/dist/aws/s3/index.d.ts.map +1 -0
- package/dist/aws/s3/index.js +2 -0
- package/dist/aws/s3/operations.d.ts +106 -0
- package/dist/aws/s3/operations.d.ts.map +1 -0
- package/dist/aws/s3/operations.js +234 -0
- package/dist/aws/s3/types.d.ts +88 -0
- package/dist/aws/s3/types.d.ts.map +1 -0
- package/dist/aws/s3/types.js +1 -0
- package/dist/caches/api-cache.d.ts +40 -0
- package/dist/caches/api-cache.d.ts.map +1 -0
- package/dist/caches/api-cache.js +65 -0
- package/dist/caches/database-cache.d.ts +40 -0
- package/dist/caches/database-cache.d.ts.map +1 -0
- package/dist/caches/database-cache.js +65 -0
- package/dist/caches/index.d.ts +3 -0
- package/dist/caches/index.d.ts.map +1 -0
- package/dist/caches/index.js +2 -0
- package/dist/config/env-loader.d.ts +28 -0
- package/dist/config/env-loader.d.ts.map +1 -0
- package/dist/config/env-loader.js +39 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +2 -0
- package/dist/config/schemas.d.ts +193 -0
- package/dist/config/schemas.d.ts.map +1 -0
- package/dist/config/schemas.js +92 -0
- package/dist/config/types.d.ts +23 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +2 -0
- package/dist/constants/cache-durations.d.ts +29 -0
- package/dist/constants/cache-durations.d.ts.map +1 -0
- package/dist/constants/cache-durations.js +27 -0
- package/dist/constants/defaults.d.ts +50 -0
- package/dist/constants/defaults.d.ts.map +1 -0
- package/dist/constants/defaults.js +49 -0
- package/dist/constants/index.d.ts +4 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +2 -0
- package/dist/database/base-repository.d.ts +45 -0
- package/dist/database/base-repository.d.ts.map +1 -0
- package/dist/database/base-repository.js +57 -0
- package/dist/database/helpers/converter-helper.d.ts +9 -0
- package/dist/database/helpers/converter-helper.d.ts.map +1 -0
- package/dist/database/helpers/converter-helper.js +20 -0
- package/dist/database/helpers/index.d.ts +3 -0
- package/dist/database/helpers/index.d.ts.map +1 -0
- package/dist/database/helpers/index.js +2 -0
- package/dist/database/helpers/paged-response-helper.d.ts +33 -0
- package/dist/database/helpers/paged-response-helper.d.ts.map +1 -0
- package/dist/database/helpers/paged-response-helper.js +64 -0
- package/dist/database/index.d.ts +6 -0
- package/dist/database/index.d.ts.map +1 -0
- package/dist/database/index.js +4 -0
- package/dist/database/pool-factory.d.ts +24 -0
- package/dist/database/pool-factory.d.ts.map +1 -0
- package/dist/database/pool-factory.js +91 -0
- package/dist/database/query-helpers.d.ts +36 -0
- package/dist/database/query-helpers.d.ts.map +1 -0
- package/dist/database/query-helpers.js +68 -0
- package/dist/database/types.d.ts +55 -0
- package/dist/database/types.d.ts.map +1 -0
- package/dist/database/types.js +1 -0
- package/dist/helpers/data-obscurer.d.ts +18 -0
- package/dist/helpers/data-obscurer.d.ts.map +1 -0
- package/dist/helpers/data-obscurer.js +29 -0
- package/dist/helpers/enum-converters.d.ts +27 -0
- package/dist/helpers/enum-converters.d.ts.map +1 -0
- package/dist/helpers/enum-converters.js +37 -0
- package/dist/helpers/index.d.ts +5 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +3 -0
- package/dist/helpers/remove-sensitive-values.d.ts +20 -0
- package/dist/helpers/remove-sensitive-values.d.ts.map +1 -0
- package/dist/helpers/remove-sensitive-values.js +72 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/logging/formatters.d.ts +19 -0
- package/dist/logging/formatters.d.ts.map +1 -0
- package/dist/logging/formatters.js +94 -0
- package/dist/logging/index.d.ts +4 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +2 -0
- package/dist/logging/logger-factory.d.ts +8 -0
- package/dist/logging/logger-factory.d.ts.map +1 -0
- package/dist/logging/logger-factory.js +86 -0
- package/dist/logging/types.d.ts +52 -0
- package/dist/logging/types.d.ts.map +1 -0
- package/dist/logging/types.js +1 -0
- package/dist/rabbitmq/connection-factory.d.ts +8 -0
- package/dist/rabbitmq/connection-factory.d.ts.map +1 -0
- package/dist/rabbitmq/connection-factory.js +117 -0
- package/dist/rabbitmq/consumer.d.ts +44 -0
- package/dist/rabbitmq/consumer.d.ts.map +1 -0
- package/dist/rabbitmq/consumer.js +107 -0
- package/dist/rabbitmq/index.d.ts +6 -0
- package/dist/rabbitmq/index.d.ts.map +1 -0
- package/dist/rabbitmq/index.js +4 -0
- package/dist/rabbitmq/namespace-helpers.d.ts +33 -0
- package/dist/rabbitmq/namespace-helpers.d.ts.map +1 -0
- package/dist/rabbitmq/namespace-helpers.js +44 -0
- package/dist/rabbitmq/publisher.d.ts +27 -0
- package/dist/rabbitmq/publisher.d.ts.map +1 -0
- package/dist/rabbitmq/publisher.js +94 -0
- package/dist/rabbitmq/types.d.ts +94 -0
- package/dist/rabbitmq/types.d.ts.map +1 -0
- package/dist/rabbitmq/types.js +1 -0
- package/dist/redis/client-factory.d.ts +14 -0
- package/dist/redis/client-factory.d.ts.map +1 -0
- package/dist/redis/client-factory.js +98 -0
- package/dist/redis/index.d.ts +6 -0
- package/dist/redis/index.d.ts.map +1 -0
- package/dist/redis/index.js +4 -0
- package/dist/redis/namespace-helpers.d.ts +33 -0
- package/dist/redis/namespace-helpers.d.ts.map +1 -0
- package/dist/redis/namespace-helpers.js +43 -0
- package/dist/redis/operations/index.d.ts +3 -0
- package/dist/redis/operations/index.d.ts.map +1 -0
- package/dist/redis/operations/index.js +2 -0
- package/dist/redis/operations/list.d.ts +102 -0
- package/dist/redis/operations/list.d.ts.map +1 -0
- package/dist/redis/operations/list.js +136 -0
- package/dist/redis/operations/standard.d.ts +85 -0
- package/dist/redis/operations/standard.d.ts.map +1 -0
- package/dist/redis/operations/standard.js +136 -0
- package/dist/redis/types.d.ts +81 -0
- package/dist/redis/types.d.ts.map +1 -0
- package/dist/redis/types.js +8 -0
- package/dist/security/cors-factory.d.ts +28 -0
- package/dist/security/cors-factory.d.ts.map +1 -0
- package/dist/security/cors-factory.js +73 -0
- package/dist/security/helmet-factory.d.ts +14 -0
- package/dist/security/helmet-factory.d.ts.map +1 -0
- package/dist/security/helmet-factory.js +80 -0
- package/dist/security/index.d.ts +4 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +2 -0
- package/dist/security/types.d.ts +103 -0
- package/dist/security/types.d.ts.map +1 -0
- package/dist/security/types.js +1 -0
- package/dist/types/custom-types.d.ts +102 -0
- package/dist/types/custom-types.d.ts.map +1 -0
- package/dist/types/custom-types.js +45 -0
- package/dist/types/enums.d.ts +26 -0
- package/dist/types/enums.d.ts.map +1 -0
- package/dist/types/enums.js +30 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/package.json +154 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helmet configuration options
|
|
3
|
+
*/
|
|
4
|
+
export interface HelmetConfig {
|
|
5
|
+
/** Content Security Policy configuration */
|
|
6
|
+
contentSecurityPolicy?: boolean | ContentSecurityPolicyConfig;
|
|
7
|
+
/** Cross-Origin-Embedder-Policy header */
|
|
8
|
+
crossOriginEmbedderPolicy?: boolean;
|
|
9
|
+
/** Cross-Origin-Opener-Policy header */
|
|
10
|
+
crossOriginOpenerPolicy?: boolean | {
|
|
11
|
+
policy: string;
|
|
12
|
+
};
|
|
13
|
+
/** Cross-Origin-Resource-Policy header */
|
|
14
|
+
crossOriginResourcePolicy?: boolean | {
|
|
15
|
+
policy: string;
|
|
16
|
+
};
|
|
17
|
+
/** DNS Prefetch Control */
|
|
18
|
+
dnsPrefetchControl?: boolean | {
|
|
19
|
+
allow: boolean;
|
|
20
|
+
};
|
|
21
|
+
/** Frameguard (X-Frame-Options) */
|
|
22
|
+
frameguard?: boolean | {
|
|
23
|
+
action: 'deny' | 'sameorigin';
|
|
24
|
+
};
|
|
25
|
+
/** Hide Powered By header */
|
|
26
|
+
hidePoweredBy?: boolean;
|
|
27
|
+
/** HSTS configuration */
|
|
28
|
+
hsts?: boolean | HstsConfig;
|
|
29
|
+
/** IE No Open */
|
|
30
|
+
ieNoOpen?: boolean;
|
|
31
|
+
/** No Sniff (X-Content-Type-Options) */
|
|
32
|
+
noSniff?: boolean;
|
|
33
|
+
/** Origin Agent Cluster */
|
|
34
|
+
originAgentCluster?: boolean;
|
|
35
|
+
/** Permitted Cross-Domain Policies */
|
|
36
|
+
permittedCrossDomainPolicies?: boolean | {
|
|
37
|
+
permittedPolicies: string;
|
|
38
|
+
};
|
|
39
|
+
/** Referrer Policy */
|
|
40
|
+
referrerPolicy?: boolean | {
|
|
41
|
+
policy: string | string[];
|
|
42
|
+
};
|
|
43
|
+
/** XSS Filter */
|
|
44
|
+
xssFilter?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Content Security Policy configuration
|
|
48
|
+
*/
|
|
49
|
+
export interface ContentSecurityPolicyConfig {
|
|
50
|
+
directives?: Record<string, string[] | string | boolean>;
|
|
51
|
+
reportOnly?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* HSTS configuration
|
|
55
|
+
*/
|
|
56
|
+
export interface HstsConfig {
|
|
57
|
+
maxAge?: number;
|
|
58
|
+
includeSubDomains?: boolean;
|
|
59
|
+
preload?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Origin callback function type
|
|
63
|
+
*/
|
|
64
|
+
export type CorsOriginCallback = (origin: string | undefined, callback: (err: Error | null, allow?: boolean) => void) => void;
|
|
65
|
+
/**
|
|
66
|
+
* CORS configuration options
|
|
67
|
+
*/
|
|
68
|
+
export interface CorsConfig {
|
|
69
|
+
/** Allowed origins - string, array, regex, boolean, or callback function */
|
|
70
|
+
origin?: string | string[] | RegExp | boolean | CorsOriginCallback;
|
|
71
|
+
/** Allowed HTTP methods */
|
|
72
|
+
methods?: string | string[];
|
|
73
|
+
/** Allowed headers */
|
|
74
|
+
allowedHeaders?: string | string[];
|
|
75
|
+
/** Headers to expose to the client */
|
|
76
|
+
exposedHeaders?: string | string[];
|
|
77
|
+
/** Allow credentials (cookies, authorization headers) */
|
|
78
|
+
credentials?: boolean;
|
|
79
|
+
/** Preflight request cache duration in seconds */
|
|
80
|
+
maxAge?: number;
|
|
81
|
+
/** Pass the CORS preflight response to the next handler */
|
|
82
|
+
preflightContinue?: boolean;
|
|
83
|
+
/** Success status code for OPTIONS requests */
|
|
84
|
+
optionsSuccessStatus?: number;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Rate limiting configuration
|
|
88
|
+
*/
|
|
89
|
+
export interface RateLimitConfig {
|
|
90
|
+
/** Time window in milliseconds */
|
|
91
|
+
windowMs?: number;
|
|
92
|
+
/** Maximum requests per window */
|
|
93
|
+
max?: number;
|
|
94
|
+
/** Message to return when rate limited */
|
|
95
|
+
message?: string;
|
|
96
|
+
/** HTTP status code when rate limited */
|
|
97
|
+
statusCode?: number;
|
|
98
|
+
/** Skip rate limiting for certain requests */
|
|
99
|
+
skip?: (req: unknown) => boolean;
|
|
100
|
+
/** Key generator for rate limiting */
|
|
101
|
+
keyGenerator?: (req: unknown) => string;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/security/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,4CAA4C;IAC5C,qBAAqB,CAAC,EAAE,OAAO,GAAG,2BAA2B,CAAC;IAC9D,0CAA0C;IAC1C,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,wCAAwC;IACxC,uBAAuB,CAAC,EAAE,OAAO,GAAG;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACvD,0CAA0C;IAC1C,yBAAyB,CAAC,EAAE,OAAO,GAAG;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACzD,2BAA2B;IAC3B,kBAAkB,CAAC,EAAE,OAAO,GAAG;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;IAClD,mCAAmC;IACnC,UAAU,CAAC,EAAE,OAAO,GAAG;QAAE,MAAM,EAAE,MAAM,GAAG,YAAY,CAAA;KAAE,CAAC;IACzD,6BAA6B;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,yBAAyB;IACzB,IAAI,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAC5B,iBAAiB;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC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M,EAAE,CAAC;IACnC,yDAAyD;IACzD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,+CAA+C;IAC/C,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,kCAAkC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kCAAkC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC;IACjC,sCAAsC;IACtC,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,MAAM,CAAC;CACzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stringified UUIDv4.
|
|
3
|
+
* See [RFC 4112](https://tools.ietf.org/html/rfc4122)
|
|
4
|
+
* @pattern [0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}
|
|
5
|
+
* @format uuid
|
|
6
|
+
*/
|
|
7
|
+
export type UUID = string;
|
|
8
|
+
/**
|
|
9
|
+
* Key-value pair type
|
|
10
|
+
*/
|
|
11
|
+
export interface KeyValuePair<K = string | number, V = unknown> {
|
|
12
|
+
key: K;
|
|
13
|
+
value: V;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Count response type
|
|
17
|
+
*/
|
|
18
|
+
export interface Count {
|
|
19
|
+
count: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Result type for operations that can fail
|
|
23
|
+
* Provides type-safe error handling without exceptions
|
|
24
|
+
*/
|
|
25
|
+
export type Result<T, E = Error> = {
|
|
26
|
+
success: true;
|
|
27
|
+
data: T;
|
|
28
|
+
} | {
|
|
29
|
+
success: false;
|
|
30
|
+
error: E;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Creates a successful result
|
|
34
|
+
*/
|
|
35
|
+
export declare function ok<T>(data: T): Result<T, never>;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a failed result
|
|
38
|
+
*/
|
|
39
|
+
export declare function err<E>(error: E): Result<never, E>;
|
|
40
|
+
/**
|
|
41
|
+
* Checks if a result is successful
|
|
42
|
+
*/
|
|
43
|
+
export declare function isOk<T, E>(result: Result<T, E>): result is {
|
|
44
|
+
success: true;
|
|
45
|
+
data: T;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Checks if a result is an error
|
|
49
|
+
*/
|
|
50
|
+
export declare function isErr<T, E>(result: Result<T, E>): result is {
|
|
51
|
+
success: false;
|
|
52
|
+
error: E;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Unwraps a result or throws the error
|
|
56
|
+
*/
|
|
57
|
+
export declare function unwrap<T, E>(result: Result<T, E>): T;
|
|
58
|
+
/**
|
|
59
|
+
* Unwraps a result or returns a default value
|
|
60
|
+
*/
|
|
61
|
+
export declare function unwrapOr<T, E>(result: Result<T, E>, defaultValue: T): T;
|
|
62
|
+
/**
|
|
63
|
+
* Async result type alias
|
|
64
|
+
*/
|
|
65
|
+
export type AsyncResult<T, E = Error> = Promise<Result<T, E>>;
|
|
66
|
+
/**
|
|
67
|
+
* Nullable type helper
|
|
68
|
+
*/
|
|
69
|
+
export type Nullable<T> = T | null;
|
|
70
|
+
/**
|
|
71
|
+
* Optional type helper
|
|
72
|
+
*/
|
|
73
|
+
export type Optional<T> = T | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Deep partial type helper
|
|
76
|
+
*/
|
|
77
|
+
export type DeepPartial<T> = {
|
|
78
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Deep readonly type helper
|
|
82
|
+
*/
|
|
83
|
+
export type DeepReadonly<T> = {
|
|
84
|
+
readonly [P in keyof T]: T[P] extends object ? DeepReadonly<T[P]> : T[P];
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* JSON primitive types
|
|
88
|
+
*/
|
|
89
|
+
export type JsonPrimitive = string | number | boolean | null;
|
|
90
|
+
/**
|
|
91
|
+
* JSON value type
|
|
92
|
+
*/
|
|
93
|
+
export type JsonValue = JsonPrimitive | JsonValue[] | {
|
|
94
|
+
[key: string]: JsonValue;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* JSON object type
|
|
98
|
+
*/
|
|
99
|
+
export type JsonObject = {
|
|
100
|
+
[key: string]: JsonValue;
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=custom-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-types.d.ts","sourceRoot":"","sources":["../../src/types/custom-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,OAAO;IAC5D,GAAG,EAAE,CAAC,CAAC;IACP,KAAK,EAAE,CAAC,CAAC;CACV;AAED;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,IAAI;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE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M,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAChE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAC5B,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACzE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,SAAS,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEnF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a successful result
|
|
3
|
+
*/
|
|
4
|
+
export function ok(data) {
|
|
5
|
+
return { success: true, data };
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Creates a failed result
|
|
9
|
+
*/
|
|
10
|
+
export function err(error) {
|
|
11
|
+
return { success: false, error };
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Checks if a result is successful
|
|
15
|
+
*/
|
|
16
|
+
export function isOk(result) {
|
|
17
|
+
return result.success;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Checks if a result is an error
|
|
21
|
+
*/
|
|
22
|
+
export function isErr(result) {
|
|
23
|
+
return !result.success;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Unwraps a result or throws the error
|
|
27
|
+
*/
|
|
28
|
+
export function unwrap(result) {
|
|
29
|
+
if (result.success) {
|
|
30
|
+
return result.data;
|
|
31
|
+
}
|
|
32
|
+
if (result.error instanceof Error) {
|
|
33
|
+
throw result.error;
|
|
34
|
+
}
|
|
35
|
+
throw new Error(String(result.error));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Unwraps a result or returns a default value
|
|
39
|
+
*/
|
|
40
|
+
export function unwrapOr(result, defaultValue) {
|
|
41
|
+
if (result.success) {
|
|
42
|
+
return result.data;
|
|
43
|
+
}
|
|
44
|
+
return defaultValue;
|
|
45
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare enum BillingTier {
|
|
2
|
+
Standard = "standard"
|
|
3
|
+
}
|
|
4
|
+
export declare enum BillingType {
|
|
5
|
+
ACH = "ach",
|
|
6
|
+
Stripe = "stripe"
|
|
7
|
+
}
|
|
8
|
+
export declare enum BillingStatus {
|
|
9
|
+
Failure = "failure",
|
|
10
|
+
Success = "success"
|
|
11
|
+
}
|
|
12
|
+
export declare enum EmailTypes {
|
|
13
|
+
InsightReportShared = "insight-report-shared",
|
|
14
|
+
OrganizationUserInvite = "organization-user-invite",
|
|
15
|
+
ResetPassword = "reset-password",
|
|
16
|
+
UserInvite = "user-invite"
|
|
17
|
+
}
|
|
18
|
+
export declare enum RabbitQueue {
|
|
19
|
+
LogError = "log:error",
|
|
20
|
+
LogInfo = "log:info",
|
|
21
|
+
LogWarning = "log:warning",
|
|
22
|
+
WebhookProcess = "webhook:process",
|
|
23
|
+
TelemetryData = "telemetry:data",
|
|
24
|
+
TelemetryMetric = "telemetry:metric"
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=enums.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../src/types/enums.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,QAAQ,aAAa;CACtB;AAED,oBAAY,WAAW;IACrB,GAAG,QAAQ;IACX,MAAM,WAAW;CAClB;AAED,oBAAY,aAAa;IACvB,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AAED,oBAAY,UAAU;IACpB,mBAAmB,0BAA0B;IAC7C,sBAAsB,6BAA6B;IACnD,aAAa,mBAAmB;IAChC,UAAU,gBAAgB;CAC3B;AAED,oBAAY,WAAW;IACrB,QAAQ,cAAc;IACtB,OAAO,aAAa;IACpB,UAAU,gBAAgB;IAC1B,cAAc,oBAAoB;IAClC,aAAa,mBAAmB;IAChC,eAAe,qBAAqB;CACrC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export var BillingTier;
|
|
2
|
+
(function (BillingTier) {
|
|
3
|
+
BillingTier["Standard"] = "standard";
|
|
4
|
+
})(BillingTier || (BillingTier = {}));
|
|
5
|
+
export var BillingType;
|
|
6
|
+
(function (BillingType) {
|
|
7
|
+
BillingType["ACH"] = "ach";
|
|
8
|
+
BillingType["Stripe"] = "stripe";
|
|
9
|
+
})(BillingType || (BillingType = {}));
|
|
10
|
+
export var BillingStatus;
|
|
11
|
+
(function (BillingStatus) {
|
|
12
|
+
BillingStatus["Failure"] = "failure";
|
|
13
|
+
BillingStatus["Success"] = "success";
|
|
14
|
+
})(BillingStatus || (BillingStatus = {}));
|
|
15
|
+
export var EmailTypes;
|
|
16
|
+
(function (EmailTypes) {
|
|
17
|
+
EmailTypes["InsightReportShared"] = "insight-report-shared";
|
|
18
|
+
EmailTypes["OrganizationUserInvite"] = "organization-user-invite";
|
|
19
|
+
EmailTypes["ResetPassword"] = "reset-password";
|
|
20
|
+
EmailTypes["UserInvite"] = "user-invite";
|
|
21
|
+
})(EmailTypes || (EmailTypes = {}));
|
|
22
|
+
export var RabbitQueue;
|
|
23
|
+
(function (RabbitQueue) {
|
|
24
|
+
RabbitQueue["LogError"] = "log:error";
|
|
25
|
+
RabbitQueue["LogInfo"] = "log:info";
|
|
26
|
+
RabbitQueue["LogWarning"] = "log:warning";
|
|
27
|
+
RabbitQueue["WebhookProcess"] = "webhook:process";
|
|
28
|
+
RabbitQueue["TelemetryData"] = "telemetry:data";
|
|
29
|
+
RabbitQueue["TelemetryMetric"] = "telemetry:metric";
|
|
30
|
+
})(RabbitQueue || (RabbitQueue = {}));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { UUID, KeyValuePair, Count, Result, AsyncResult, Nullable, Optional, DeepPartial, DeepReadonly, JsonPrimitive, JsonValue, JsonObject } from './custom-types.js';
|
|
2
|
+
export { ok, err, isOk, isErr, unwrap, unwrapOr } from './custom-types.js';
|
|
3
|
+
export { BillingTier, BillingType, BillingStatus, EmailTypes, RabbitQueue } from './enums.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE7K,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE3E,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@arcraz/common",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Common utilities for the arcraz ecosystem",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=24.0.0"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./config": {
|
|
17
|
+
"import": "./dist/config/index.js",
|
|
18
|
+
"types": "./dist/config/index.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./database": {
|
|
21
|
+
"import": "./dist/database/index.js",
|
|
22
|
+
"types": "./dist/database/index.d.ts"
|
|
23
|
+
},
|
|
24
|
+
"./redis": {
|
|
25
|
+
"import": "./dist/redis/index.js",
|
|
26
|
+
"types": "./dist/redis/index.d.ts"
|
|
27
|
+
},
|
|
28
|
+
"./rabbitmq": {
|
|
29
|
+
"import": "./dist/rabbitmq/index.js",
|
|
30
|
+
"types": "./dist/rabbitmq/index.d.ts"
|
|
31
|
+
},
|
|
32
|
+
"./logging": {
|
|
33
|
+
"import": "./dist/logging/index.js",
|
|
34
|
+
"types": "./dist/logging/index.d.ts"
|
|
35
|
+
},
|
|
36
|
+
"./security": {
|
|
37
|
+
"import": "./dist/security/index.js",
|
|
38
|
+
"types": "./dist/security/index.d.ts"
|
|
39
|
+
},
|
|
40
|
+
"./aws/s3": {
|
|
41
|
+
"import": "./dist/aws/s3/index.js",
|
|
42
|
+
"types": "./dist/aws/s3/index.d.ts"
|
|
43
|
+
},
|
|
44
|
+
"./aws/cloudfront": {
|
|
45
|
+
"import": "./dist/aws/cloudfront/index.js",
|
|
46
|
+
"types": "./dist/aws/cloudfront/index.d.ts"
|
|
47
|
+
},
|
|
48
|
+
"./aws/bedrock": {
|
|
49
|
+
"import": "./dist/aws/bedrock/index.js",
|
|
50
|
+
"types": "./dist/aws/bedrock/index.d.ts"
|
|
51
|
+
},
|
|
52
|
+
"./caches": {
|
|
53
|
+
"import": "./dist/caches/index.js",
|
|
54
|
+
"types": "./dist/caches/index.d.ts"
|
|
55
|
+
},
|
|
56
|
+
"./helpers": {
|
|
57
|
+
"import": "./dist/helpers/index.js",
|
|
58
|
+
"types": "./dist/helpers/index.d.ts"
|
|
59
|
+
},
|
|
60
|
+
"./constants": {
|
|
61
|
+
"import": "./dist/constants/index.js",
|
|
62
|
+
"types": "./dist/constants/index.d.ts"
|
|
63
|
+
},
|
|
64
|
+
"./types": {
|
|
65
|
+
"import": "./dist/types/index.js",
|
|
66
|
+
"types": "./dist/types/index.d.ts"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"license": "Apache-2.0",
|
|
70
|
+
"scripts": {
|
|
71
|
+
"lint": "eslint .",
|
|
72
|
+
"lint:fix": "eslint . --fix",
|
|
73
|
+
"build": "rm -rf dist && tsc",
|
|
74
|
+
"test": "vitest run",
|
|
75
|
+
"test:watch": "vitest",
|
|
76
|
+
"test:coverage": "vitest run --coverage",
|
|
77
|
+
"dev": "tsc --watch",
|
|
78
|
+
"semantic-release": "semantic-release"
|
|
79
|
+
},
|
|
80
|
+
"publishConfig": {
|
|
81
|
+
"access": "public",
|
|
82
|
+
"registry": "https://registry.npmjs.org"
|
|
83
|
+
},
|
|
84
|
+
"files": [
|
|
85
|
+
"dist",
|
|
86
|
+
"package.json",
|
|
87
|
+
"README.md"
|
|
88
|
+
],
|
|
89
|
+
"dependencies": {
|
|
90
|
+
"amqplib": "^0.10.4",
|
|
91
|
+
"dotenv": "^16.4.5",
|
|
92
|
+
"hide-text": "^1.0.4",
|
|
93
|
+
"humps": "^2.0.1",
|
|
94
|
+
"ioredis": "^5.4.1",
|
|
95
|
+
"pg": "^8.13.1",
|
|
96
|
+
"zod": "^3.23.8"
|
|
97
|
+
},
|
|
98
|
+
"devDependencies": {
|
|
99
|
+
"@aws-sdk/client-bedrock-runtime": "^3.980.0",
|
|
100
|
+
"@aws-sdk/client-s3": "^3.980.0",
|
|
101
|
+
"@aws-sdk/cloudfront-signer": "^3.978.0",
|
|
102
|
+
"@aws-sdk/s3-request-presigner": "^3.980.0",
|
|
103
|
+
"@eslint/js": "^9.0.0",
|
|
104
|
+
"@semantic-release/git": "^10.0.1",
|
|
105
|
+
"@semantic-release/github": "^11.0.1",
|
|
106
|
+
"@semantic-release/npm": "^12.0.1",
|
|
107
|
+
"@types/amqplib": "^0.10.5",
|
|
108
|
+
"@types/eslint": "^9.6.1",
|
|
109
|
+
"@types/humps": "^2.0.6",
|
|
110
|
+
"@types/node": "^24.5.2",
|
|
111
|
+
"@types/pg": "^8.11.6",
|
|
112
|
+
"@types/semantic-release": "^20.0.6",
|
|
113
|
+
"@typescript-eslint/eslint-plugin": "^8.30.1",
|
|
114
|
+
"@typescript-eslint/parser": "^8.30.1",
|
|
115
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
116
|
+
"eslint": "^9.0.0",
|
|
117
|
+
"eslint-config-prettier": "^10.1.2",
|
|
118
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
119
|
+
"globals": "^16.0.0",
|
|
120
|
+
"prettier": "^3.2.5",
|
|
121
|
+
"semantic-release": "^24.2.0",
|
|
122
|
+
"ts-node": "^10.9.2",
|
|
123
|
+
"typescript": "^5.6.3",
|
|
124
|
+
"vitest": "^4.0.18"
|
|
125
|
+
},
|
|
126
|
+
"peerDependencies": {
|
|
127
|
+
"@aws-sdk/client-bedrock-runtime": "^3.0.0",
|
|
128
|
+
"@aws-sdk/client-s3": "^3.0.0",
|
|
129
|
+
"@aws-sdk/cloudfront-signer": "^3.0.0",
|
|
130
|
+
"@aws-sdk/s3-request-presigner": "^3.0.0",
|
|
131
|
+
"cors": "^2.8.5",
|
|
132
|
+
"helmet": "^8.0.0"
|
|
133
|
+
},
|
|
134
|
+
"peerDependenciesMeta": {
|
|
135
|
+
"@aws-sdk/client-bedrock-runtime": {
|
|
136
|
+
"optional": true
|
|
137
|
+
},
|
|
138
|
+
"@aws-sdk/client-s3": {
|
|
139
|
+
"optional": true
|
|
140
|
+
},
|
|
141
|
+
"@aws-sdk/cloudfront-signer": {
|
|
142
|
+
"optional": true
|
|
143
|
+
},
|
|
144
|
+
"@aws-sdk/s3-request-presigner": {
|
|
145
|
+
"optional": true
|
|
146
|
+
},
|
|
147
|
+
"cors": {
|
|
148
|
+
"optional": true
|
|
149
|
+
},
|
|
150
|
+
"helmet": {
|
|
151
|
+
"optional": true
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|