@plyaz/core 1.1.0 → 1.2.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/dist/backend/featureFlags/config/feature-flag.config.d.ts +111 -0
- package/dist/backend/featureFlags/config/feature-flag.config.d.ts.map +1 -0
- package/dist/backend/featureFlags/config/validation.d.ts +181 -0
- package/dist/backend/featureFlags/config/validation.d.ts.map +1 -0
- package/dist/backend/featureFlags/database/connection.d.ts +321 -0
- package/dist/backend/featureFlags/database/connection.d.ts.map +1 -0
- package/dist/backend/featureFlags/database/repository.d.ts +518 -0
- package/dist/backend/featureFlags/database/repository.d.ts.map +1 -0
- package/dist/backend/featureFlags/decorators/feature-disabled.decorator.d.ts +6 -0
- package/dist/backend/featureFlags/decorators/feature-disabled.decorator.d.ts.map +1 -0
- package/dist/backend/featureFlags/decorators/feature-enabled.decorator.d.ts +8 -0
- package/dist/backend/featureFlags/decorators/feature-enabled.decorator.d.ts.map +1 -0
- package/dist/backend/featureFlags/decorators/feature-flag.decorator.d.ts +11 -0
- package/dist/backend/featureFlags/decorators/feature-flag.decorator.d.ts.map +1 -0
- package/dist/backend/featureFlags/feature-flag.controller.d.ts +1 -2
- package/dist/backend/featureFlags/feature-flag.controller.d.ts.map +1 -1
- package/dist/backend/featureFlags/feature-flag.module.d.ts +2 -3
- package/dist/backend/featureFlags/feature-flag.module.d.ts.map +1 -1
- package/dist/backend/featureFlags/feature-flag.service.d.ts +149 -8
- package/dist/backend/featureFlags/feature-flag.service.d.ts.map +1 -1
- package/dist/backend/featureFlags/guards/feature-flag.guard.d.ts +19 -0
- package/dist/backend/featureFlags/guards/feature-flag.guard.d.ts.map +1 -0
- package/dist/backend/featureFlags/index.d.ts +10 -36
- package/dist/backend/featureFlags/index.d.ts.map +1 -1
- package/dist/backend/featureFlags/interceptors/error-handling-interceptor.d.ts +16 -0
- package/dist/backend/featureFlags/interceptors/error-handling-interceptor.d.ts.map +1 -0
- package/dist/backend/featureFlags/interceptors/feature-flag-logging-interceptor.d.ts +18 -0
- package/dist/backend/featureFlags/interceptors/feature-flag-logging-interceptor.d.ts.map +1 -0
- package/dist/backend/featureFlags/middleware/feature-flag-middleware.d.ts +167 -0
- package/dist/backend/featureFlags/middleware/feature-flag-middleware.d.ts.map +1 -0
- package/dist/base/cache/feature/caching.d.ts +16 -0
- package/dist/base/cache/feature/caching.d.ts.map +1 -0
- package/dist/base/cache/index.d.ts +1 -0
- package/dist/base/cache/index.d.ts.map +1 -1
- package/dist/domain/featureFlags/providers/database.d.ts +17 -12
- package/dist/domain/featureFlags/providers/database.d.ts.map +1 -1
- package/dist/frontend/index.d.ts +1 -0
- package/dist/frontend/index.d.ts.map +1 -1
- package/dist/frontend/providers/ApiProvider.d.ts +41 -0
- package/dist/frontend/providers/ApiProvider.d.ts.map +1 -0
- package/dist/frontend/providers/index.d.ts +7 -0
- package/dist/frontend/providers/index.d.ts.map +1 -0
- package/dist/index.cjs +2325 -273
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +2315 -275
- package/dist/index.mjs.map +1 -1
- package/dist/services/ApiClientService.d.ts +90 -0
- package/dist/services/ApiClientService.d.ts.map +1 -0
- package/dist/services/index.d.ts +8 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/utils/common/index.d.ts +1 -1
- package/dist/utils/common/index.d.ts.map +1 -1
- package/dist/utils/common/validation.d.ts +20 -0
- package/dist/utils/common/validation.d.ts.map +1 -0
- package/dist/utils/db/databaseService.d.ts +6 -0
- package/dist/utils/db/databaseService.d.ts.map +1 -0
- package/dist/utils/db/index.d.ts +2 -0
- package/dist/utils/db/index.d.ts.map +1 -0
- package/dist/web_app/auth/add_user.d.ts +3 -0
- package/dist/web_app/auth/add_user.d.ts.map +1 -0
- package/dist/web_app/auth/update_user.d.ts +2 -0
- package/dist/web_app/auth/update_user.d.ts.map +1 -0
- package/package.json +20 -7
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Client Singleton Service (@plyaz/core)
|
|
3
|
+
* Manages the API client with environment-specific configurations and intelligent defaults
|
|
4
|
+
*
|
|
5
|
+
* The app reads process.env and constructs ApiClientOptions, then passes to this service.
|
|
6
|
+
* Service never touches process.env directly - all env reading happens in the app layer.
|
|
7
|
+
*
|
|
8
|
+
* @module services/ApiClientService
|
|
9
|
+
*/
|
|
10
|
+
import type { ApiClientWithEvents, ApiClientOptions } from '@plyaz/types/api';
|
|
11
|
+
import { type ClientEventManager, type EndpointsList } from '@plyaz/api';
|
|
12
|
+
import type { ApiEnvironmentConfig } from '@plyaz/types/core';
|
|
13
|
+
/**
|
|
14
|
+
* API Client Singleton Service
|
|
15
|
+
* Manages API client instance lifecycle with environment-specific configurations
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* // In your app initialization (Next.js, React, etc.)
|
|
20
|
+
* import { ApiClientService } from '@plyaz/core';
|
|
21
|
+
*
|
|
22
|
+
* // Environment metadata
|
|
23
|
+
* const envConfig = {
|
|
24
|
+
* env: process.env.NODE_ENV as 'production',
|
|
25
|
+
* apiKey: process.env.API_KEY,
|
|
26
|
+
* };
|
|
27
|
+
*
|
|
28
|
+
* // API configuration with event handlers
|
|
29
|
+
* await ApiClientService.init(envConfig, {
|
|
30
|
+
* baseURL: process.env.API_URL!,
|
|
31
|
+
* encryption: {
|
|
32
|
+
* key: {
|
|
33
|
+
* id: 'prod-key-v1',
|
|
34
|
+
* key: process.env.ENCRYPTION_KEY!,
|
|
35
|
+
* algorithm: 'AES-GCM'
|
|
36
|
+
* }
|
|
37
|
+
* },
|
|
38
|
+
* clientEvents: {
|
|
39
|
+
* onRequestStart: (event) => apiStore.trackRequest(event),
|
|
40
|
+
* },
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* // Later, anywhere in your app
|
|
44
|
+
* const client = ApiClientService.getClient();
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare class ApiClientService {
|
|
48
|
+
private static instance;
|
|
49
|
+
private static isInitializing;
|
|
50
|
+
private static initPromise;
|
|
51
|
+
/**
|
|
52
|
+
* Initialize the API client with environment config and API options
|
|
53
|
+
*
|
|
54
|
+
* @param envConfig - Environment metadata (env, apiKey)
|
|
55
|
+
* @param apiConfig - API configuration (baseURL, encryption, timeout, event handlers, etc.)
|
|
56
|
+
* @returns Promise that resolves to the initialized client
|
|
57
|
+
*/
|
|
58
|
+
static init(envConfig: ApiEnvironmentConfig, apiConfig?: Partial<ApiClientOptions>): Promise<ApiClientWithEvents<ClientEventManager, EndpointsList>>;
|
|
59
|
+
/**
|
|
60
|
+
* Internal initialization logic
|
|
61
|
+
* Merges environment-specific defaults with API configuration
|
|
62
|
+
*
|
|
63
|
+
* Merge Priority (lowest to highest):
|
|
64
|
+
* 1. Environment defaults (PRODUCTION_CONFIG / STAGING_CONFIG / DEVELOPMENT_CONFIG)
|
|
65
|
+
* 2. Environment metadata (envConfig - apiKey)
|
|
66
|
+
* 3. API configuration (apiConfig - baseURL, encryption, timeout, etc.)
|
|
67
|
+
*/
|
|
68
|
+
private static createClient;
|
|
69
|
+
/**
|
|
70
|
+
* Get the initialized client instance
|
|
71
|
+
*
|
|
72
|
+
* @throws {ApiPackageError} If client not initialized
|
|
73
|
+
*/
|
|
74
|
+
static getClient(): ApiClientWithEvents<ClientEventManager, EndpointsList>;
|
|
75
|
+
/**
|
|
76
|
+
* Check if client is initialized
|
|
77
|
+
*/
|
|
78
|
+
static isInitialized(): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Reinitialize with new config and options
|
|
81
|
+
*/
|
|
82
|
+
static reinitialize(envConfig: ApiEnvironmentConfig, apiConfig?: Partial<ApiClientOptions>): Promise<ApiClientWithEvents<ClientEventManager, EndpointsList>>;
|
|
83
|
+
/**
|
|
84
|
+
* Dispose of the client instance
|
|
85
|
+
*/
|
|
86
|
+
static dispose(): void;
|
|
87
|
+
}
|
|
88
|
+
export declare const getApiClient: () => ApiClientWithEvents<ClientEventManager, EndpointsList>;
|
|
89
|
+
export declare const initApiClient: (envConfig: ApiEnvironmentConfig, apiConfig?: Partial<ApiClientOptions>) => Promise<ApiClientWithEvents<ClientEventManager, EndpointsList>>;
|
|
90
|
+
//# sourceMappingURL=ApiClientService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiClientService.d.ts","sourceRoot":"","sources":["../../src/services/ApiClientService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAa,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,aAAa,EAAmB,MAAM,YAAY,CAAC;AAG1F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AA2c9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAuE;IAC9F,OAAO,CAAC,MAAM,CAAC,cAAc,CAAS;IACtC,OAAO,CAAC,MAAM,CAAC,WAAW,CAA8B;IAExD;;;;;;OAMG;WACU,IAAI,CACf,SAAS,EAAE,oBAAoB,EAC/B,SAAS,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GACpC,OAAO,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;IA4BlE;;;;;;;;OAQG;mBACkB,YAAY;IA6CjC;;;;OAIG;IACH,MAAM,CAAC,SAAS,IAAI,mBAAmB,CAAC,kBAAkB,EAAE,aAAa,CAAC;IAmB1E;;OAEG;IACH,MAAM,CAAC,aAAa,IAAI,OAAO;IAI/B;;OAEG;WACU,YAAY,CACvB,SAAS,EAAE,oBAAoB,EAC/B,SAAS,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GACpC,OAAO,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;IAKlE;;OAEG;IACH,MAAM,CAAC,OAAO,IAAI,IAAI;CAQvB;AAGD,eAAO,MAAM,YAAY,QAAO,mBAAmB,CAAC,kBAAkB,EAAE,aAAa,CACvD,CAAC;AAE/B,eAAO,MAAM,aAAa,GACxB,WAAW,oBAAoB,EAC/B,YAAY,OAAO,CAAC,gBAAgB,CAAC,KACpC,OAAO,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,aAAa,CAAC,CACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,oBAAoB,CAAC"}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Exports all common utility functions that can be reused across the application.
|
|
5
5
|
*
|
|
6
6
|
* @fileoverview Common utilities export
|
|
7
|
-
* @version 1.0.0
|
|
8
7
|
*/
|
|
9
8
|
export { hashString, isInRollout, createRolloutIdentifier, HashUtils } from './hash';
|
|
10
9
|
export { isTruthy, toBoolean, ValueUtils } from './values';
|
|
10
|
+
export * from './validation';
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/common/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/common/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGrF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3D,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation Utility Functions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Type guard to check if value is string
|
|
6
|
+
*/
|
|
7
|
+
export declare const isString: (value: unknown) => value is string;
|
|
8
|
+
/**
|
|
9
|
+
* Type guard to check if value is defined (not undefined)
|
|
10
|
+
*/
|
|
11
|
+
export declare const isDefined: <T>(value: T | undefined) => value is T;
|
|
12
|
+
/**
|
|
13
|
+
* Type guard to check if value is number
|
|
14
|
+
*/
|
|
15
|
+
export declare const isNumber: (value: unknown) => value is number;
|
|
16
|
+
/**
|
|
17
|
+
* Helper function to get all valid provider types as array
|
|
18
|
+
*/
|
|
19
|
+
export declare const getValidProviders: () => string[];
|
|
20
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/utils/common/validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAAmC,CAAC;AAEvF;;GAEG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,OAAO,CAAC,GAAG,SAAS,KAAG,KAAK,IAAI,CAAwB,CAAC;AAEtF;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAAmC,CAAC;AAEvF;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAO,MAAM,EAA2C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"databaseService.d.ts","sourceRoot":"","sources":["../../../src/utils/db/databaseService.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAEvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAwBlD,QAAA,IAAI,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAAC;AAE1D,wBAAsB,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,CAS9C;AAED,OAAO,EAAE,EAAE,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add_user.d.ts","sourceRoot":"","sources":["../../../src/web_app/auth/add_user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,eAAO,MAAM,QAAQ,EAAE,MAiBtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update_user.d.ts","sourceRoot":"","sources":["../../../src/web_app/auth/update_user.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,GAAU,CAAC,SAAS,MAAM,EAC/C,OAAO,MAAM,EACb,IAAI,MAAM,EACV,OAAO,CAAC,KACP,OAAO,CAAC,OAAO,CAIjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plyaz/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Shared core logic and utilities for Plyaz apps, services, and future SDKs – centralized, reusable, and scalable.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [],
|
|
@@ -28,12 +28,23 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@nestjs/common": "^11.1.3",
|
|
31
|
-
"@
|
|
32
|
-
"@plyaz/
|
|
31
|
+
"@nestjs/core": "^11.1.6",
|
|
32
|
+
"@plyaz/api": "^1.2.2",
|
|
33
|
+
"@plyaz/config": "^1.7.18",
|
|
34
|
+
"@plyaz/db": "^0.1.0",
|
|
35
|
+
"@plyaz/errors": "^1.3.7",
|
|
36
|
+
"@plyaz/logger": "^1.3.2",
|
|
37
|
+
"@plyaz/translations": "^1.4.5",
|
|
38
|
+
"@plyaz/types": "^1.15.19",
|
|
39
|
+
"@supabase/supabase-js": "^2.79.0",
|
|
40
|
+
"dotenv": "^17.2.3",
|
|
41
|
+
"drizzle-orm": "^0.36.4",
|
|
33
42
|
"ioredis": "^5.6.1",
|
|
34
43
|
"next": "15.4.7",
|
|
44
|
+
"postgres": "^3.4.7",
|
|
35
45
|
"react": "^19.1.0",
|
|
36
46
|
"react-dom": "^19.1.0",
|
|
47
|
+
"rxjs": "^7.8.2",
|
|
37
48
|
"viem": "^2.31.7",
|
|
38
49
|
"yaml": "^2.8.0"
|
|
39
50
|
},
|
|
@@ -44,12 +55,12 @@
|
|
|
44
55
|
"@eslint/js": "^9.15.0",
|
|
45
56
|
"@eslint/markdown": "^6.5.0",
|
|
46
57
|
"@next/eslint-plugin-next": "^15.0.3",
|
|
47
|
-
"@plyaz/devtools": "^1.
|
|
48
|
-
"@plyaz/testing": "^1.
|
|
49
|
-
"@plyaz/types": "^1.7.7",
|
|
58
|
+
"@plyaz/devtools": "^1.9.4",
|
|
59
|
+
"@plyaz/testing": "^1.5.1",
|
|
50
60
|
"@testing-library/jest-dom": "^6.6.3",
|
|
51
61
|
"@testing-library/react": "^16.3.0",
|
|
52
62
|
"@testing-library/user-event": "^14.6.1",
|
|
63
|
+
"@types/express": "^5.0.5",
|
|
53
64
|
"@types/node": "^22.14.0",
|
|
54
65
|
"@types/react": "^19.1.8",
|
|
55
66
|
"@types/react-dom": "^19.1.6",
|
|
@@ -86,6 +97,7 @@
|
|
|
86
97
|
"eslint-plugin-testing-library": "^6.5.0",
|
|
87
98
|
"eslint-plugin-unicorn": "^56.0.1",
|
|
88
99
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
100
|
+
"express": "^5.1.0",
|
|
89
101
|
"glob": "11.0.3",
|
|
90
102
|
"jiti": "^2.4.2",
|
|
91
103
|
"jsdom": "^26.1.0",
|
|
@@ -140,6 +152,7 @@
|
|
|
140
152
|
"remove:unused": "pnpm remove:unused:fnc && pnpm remove:unused:interfaces",
|
|
141
153
|
"remove:unused:interfaces": "npx tsx check_types.ts --remove --report=./internal-reports/unused-types-report.md",
|
|
142
154
|
"remove:unused:fnc": "npx tsx check_fnc.ts --report=./internal-reports/unused-declarations.md",
|
|
143
|
-
"check:dependencies": "npx tsx check_dependencies_versions.ts --report=./internal-reports/dependency-report.md"
|
|
155
|
+
"check:dependencies": "npx tsx check_dependencies_versions.ts --report=./internal-reports/dependency-report.md",
|
|
156
|
+
"pre:deploy": "pnpm run build && pnpm run lint && pnpm run format && pnpm run type:check && pnpm run test"
|
|
144
157
|
}
|
|
145
158
|
}
|