@plyaz/types 1.19.4 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/api/client/types.d.ts +59 -0
  2. package/dist/api/index.cjs +29 -0
  3. package/dist/api/index.cjs.map +1 -1
  4. package/dist/api/index.js +29 -0
  5. package/dist/api/index.js.map +1 -1
  6. package/dist/core/auth/types.d.ts +1 -1
  7. package/dist/core/domain/index.d.ts +5 -0
  8. package/dist/core/domain/types.d.ts +123 -0
  9. package/dist/core/events/enums.d.ts +25 -1
  10. package/dist/core/events/index.d.ts +3 -3
  11. package/dist/core/events/payloads.d.ts +80 -1
  12. package/dist/core/featureFlag/types.d.ts +16 -16
  13. package/dist/core/frontend/featureFlags.d.ts +106 -0
  14. package/dist/core/frontend/index.d.ts +6 -0
  15. package/dist/core/frontend/types.d.ts +318 -0
  16. package/dist/core/index.d.ts +6 -2
  17. package/dist/core/init/index.d.ts +5 -0
  18. package/dist/core/init/types.d.ts +347 -0
  19. package/dist/core/modules.d.ts +19 -3
  20. package/dist/core/services/index.d.ts +5 -0
  21. package/dist/core/{services.d.ts → services/types.d.ts} +74 -6
  22. package/dist/errors/codes.d.ts +3 -0
  23. package/dist/errors/index.cjs +29 -0
  24. package/dist/errors/index.cjs.map +1 -1
  25. package/dist/errors/index.d.ts +2 -0
  26. package/dist/errors/index.js +29 -0
  27. package/dist/errors/index.js.map +1 -1
  28. package/dist/errors/middleware.d.ts +105 -0
  29. package/dist/errors/store.d.ts +140 -0
  30. package/dist/examples/index.d.ts +1 -1
  31. package/dist/examples/types.d.ts +64 -0
  32. package/dist/features/feature-flag/dto.types.d.ts +67 -0
  33. package/dist/features/feature-flag/index.d.ts +3 -0
  34. package/dist/features/feature-flag/service.types.d.ts +184 -0
  35. package/dist/features/feature-flag/store.types.d.ts +166 -0
  36. package/dist/features/feature-flag/types.d.ts +16 -4
  37. package/dist/globals.d.ts +23 -0
  38. package/dist/index.cjs +49 -0
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.js +49 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/store/index.cjs +13 -0
  43. package/dist/store/index.cjs.map +1 -1
  44. package/dist/store/index.d.ts +2 -0
  45. package/dist/store/index.js +11 -0
  46. package/dist/store/index.js.map +1 -1
  47. package/dist/store/keys.d.ts +23 -0
  48. package/dist/store/types.d.ts +62 -71
  49. package/dist/testing/features/feature-flags/types.d.ts +3 -3
  50. package/package.json +6 -2
@@ -1,4 +1,17 @@
1
1
  'use strict';
2
2
 
3
+ // @plyaz package - Built with tsup
4
+
5
+ // src/store/keys.ts
6
+ var STORE_KEYS = {
7
+ /** Error store slice - tracks application errors */
8
+ ERROR: "error",
9
+ /** Feature flags store slice - manages feature flag state */
10
+ FEATURE_FLAGS: "featureFlags"
11
+ };
12
+ var ALL_STORE_KEYS = Object.values(STORE_KEYS);
13
+
14
+ exports.ALL_STORE_KEYS = ALL_STORE_KEYS;
15
+ exports.STORE_KEYS = STORE_KEYS;
3
16
  //# sourceMappingURL=index.cjs.map
4
17
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
1
+ {"version":3,"sources":["../../src/store/keys.ts"],"names":[],"mappings":";;;;;AAUO,IAAM,UAAA,GAAa;AAAA;AAAA,EAExB,KAAA,EAAO,OAAA;AAAA;AAAA,EAEP,aAAA,EAAe;AACjB;AAUO,IAAM,cAAA,GAAiB,MAAA,CAAO,MAAA,CAAO,UAAU","file":"index.cjs","sourcesContent":["/**\n * Store Keys Types\n *\n * Type definitions for store keys used across packages.\n * The actual runtime values are defined in @plyaz/store.\n */\n\n/**\n * Keys for all available store slices.\n */\nexport const STORE_KEYS = {\n /** Error store slice - tracks application errors */\n ERROR: 'error',\n /** Feature flags store slice - manages feature flag state */\n FEATURE_FLAGS: 'featureFlags',\n} as const;\n\n/**\n * Type for store keys.\n */\nexport type StoreKey = (typeof STORE_KEYS)[keyof typeof STORE_KEYS];\n\n/**\n * Array of all store keys for iteration.\n */\nexport const ALL_STORE_KEYS = Object.values(STORE_KEYS) as StoreKey[];\n"]}
@@ -1 +1,3 @@
1
1
  export type * from './types';
2
+ export { STORE_KEYS, ALL_STORE_KEYS } from './keys';
3
+ export type { StoreKey } from './keys';
@@ -1,3 +1,14 @@
1
+ // @plyaz package - Built with tsup
1
2
 
3
+ // src/store/keys.ts
4
+ var STORE_KEYS = {
5
+ /** Error store slice - tracks application errors */
6
+ ERROR: "error",
7
+ /** Feature flags store slice - manages feature flag state */
8
+ FEATURE_FLAGS: "featureFlags"
9
+ };
10
+ var ALL_STORE_KEYS = Object.values(STORE_KEYS);
11
+
12
+ export { ALL_STORE_KEYS, STORE_KEYS };
2
13
  //# sourceMappingURL=index.js.map
3
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
1
+ {"version":3,"sources":["../../src/store/keys.ts"],"names":[],"mappings":";;;AAUO,IAAM,UAAA,GAAa;AAAA;AAAA,EAExB,KAAA,EAAO,OAAA;AAAA;AAAA,EAEP,aAAA,EAAe;AACjB;AAUO,IAAM,cAAA,GAAiB,MAAA,CAAO,MAAA,CAAO,UAAU","file":"index.js","sourcesContent":["/**\n * Store Keys Types\n *\n * Type definitions for store keys used across packages.\n * The actual runtime values are defined in @plyaz/store.\n */\n\n/**\n * Keys for all available store slices.\n */\nexport const STORE_KEYS = {\n /** Error store slice - tracks application errors */\n ERROR: 'error',\n /** Feature flags store slice - manages feature flag state */\n FEATURE_FLAGS: 'featureFlags',\n} as const;\n\n/**\n * Type for store keys.\n */\nexport type StoreKey = (typeof STORE_KEYS)[keyof typeof STORE_KEYS];\n\n/**\n * Array of all store keys for iteration.\n */\nexport const ALL_STORE_KEYS = Object.values(STORE_KEYS) as StoreKey[];\n"]}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Store Keys Types
3
+ *
4
+ * Type definitions for store keys used across packages.
5
+ * The actual runtime values are defined in @plyaz/store.
6
+ */
7
+ /**
8
+ * Keys for all available store slices.
9
+ */
10
+ export declare const STORE_KEYS: {
11
+ /** Error store slice - tracks application errors */
12
+ readonly ERROR: "error";
13
+ /** Feature flags store slice - manages feature flag state */
14
+ readonly FEATURE_FLAGS: "featureFlags";
15
+ };
16
+ /**
17
+ * Type for store keys.
18
+ */
19
+ export type StoreKey = (typeof STORE_KEYS)[keyof typeof STORE_KEYS];
20
+ /**
21
+ * Array of all store keys for iteration.
22
+ */
23
+ export declare const ALL_STORE_KEYS: StoreKey[];
@@ -1,82 +1,73 @@
1
- import type { StateCreator } from 'zustand';
2
- import type { BaseErrorContext } from '../errors';
3
1
  /**
4
- * Represents the error state and actions available for managing global errors.
2
+ * Store Types
5
3
  *
6
- * @typedef {Object} ErrorSliceType
7
- * @property {ReturnResponseType | null} error - The current error state, or `null` if no error exists.
8
- * @property {(error: ReturnResponseType) => void} addError - Adds or updates the global error state.
9
- * @property {() => void} clearError - Clears the current error from the store.
4
+ * Type definitions for Zustand store configurations used by @plyaz/store.
5
+ *
6
+ * @fileoverview Store configuration and hook result types
7
+ * @version 2.0.0
10
8
  */
11
- type ErrorSeverity = 'critical' | 'error' | 'warning' | 'info';
12
- interface BaseError {
13
- statusCode: number;
14
- message: string;
15
- timestamp: string;
16
- type: string;
17
- context?: BaseErrorContext;
18
- }
19
- export interface ErrorLogEntry {
20
- id: string;
21
- error: BaseError;
22
- timestamp: string;
23
- severity?: ErrorSeverity;
24
- source?: string;
25
- correlationId?: string;
26
- dismissed?: boolean;
27
- context?: Record<string, object>;
28
- }
29
- export interface ErrorOptions {
30
- source?: string;
31
- context?: Record<string, object>;
32
- severity?: ErrorSeverity;
33
- correlationId?: string;
9
+ import type { SerializedError, ErrorStoreActions, ErrorStoreSlice } from '../errors/store';
10
+ import type { FeatureFlagStoreState, FeatureFlagStoreSlice } from '../features/feature-flag/store.types';
11
+ /**
12
+ * Configuration for creating an error store.
13
+ */
14
+ export interface ErrorStoreConfig {
15
+ /** Maximum errors to keep (default: 100) */
16
+ maxErrors?: number;
34
17
  }
35
- export interface ErrorSliceType {
36
- errors: ErrorLogEntry[];
37
- maxErrors: number;
38
- addError: (error: BaseError, options?: ErrorOptions) => void;
39
- addErrors: (errors: BaseError[], options?: ErrorOptions) => void;
40
- clearError: (errorId: string) => void;
41
- clearErrors: (errorIds: string[]) => void;
42
- clearErrorsByType: (type: string) => void;
43
- clearErrorsBySeverity: (severity: ErrorSeverity) => void;
44
- clearAll: () => void;
45
- dismissError: (errorId: string) => void;
46
- dismissErrors: (errorIds: string[]) => void;
47
- dismissAll: () => void;
48
- getLatestError: () => ErrorLogEntry | null;
49
- getErrorsByType: (type: string) => ErrorLogEntry[];
50
- getErrorsBySeverity: (severity: ErrorSeverity) => ErrorLogEntry[];
51
- getErrorsBySource: (source: string) => ErrorLogEntry[];
52
- getUndismissedErrors: () => ErrorLogEntry[];
53
- getActiveErrors: () => ErrorLogEntry[];
54
- hasActiveErrors: () => boolean;
55
- getErrorCount: () => number;
56
- getActiveErrorCount: () => number;
18
+ /**
19
+ * Result type for useErrorState hook.
20
+ * Combines error state with actions.
21
+ */
22
+ export interface UseErrorStateResult extends ErrorStoreActions {
23
+ /** All errors in the store */
24
+ errors: SerializedError[];
25
+ /** Active (undismissed) errors */
26
+ activeErrors: SerializedError[];
27
+ /** Most recent error */
28
+ lastError: SerializedError | null;
29
+ /** Total error count */
30
+ errorCount: number;
31
+ /** Active (undismissed) error count */
32
+ activeErrorCount: number;
33
+ /** Whether there are any errors */
34
+ hasErrors: boolean;
35
+ /** Whether there are any active errors */
36
+ hasActiveErrors: boolean;
37
+ /** Whether error middleware is connected */
38
+ isConnected: boolean;
57
39
  }
58
40
  /**
59
- * Base Zustand slice creator type.
60
- *
61
- * Used for slices **without** middleware such as `persist` or `immer`.
41
+ * Configuration for creating a Zustand feature flag store.
42
+ * Used by createFeatureFlagStore in @plyaz/store.
62
43
  */
63
- export type BaseSliceCreator<T> = StateCreator<T>;
64
- type MiddlewareMutators = [never, unknown][];
44
+ export interface FeatureFlagStoreConfig {
45
+ /** Enable Redux DevTools integration */
46
+ devtools?: boolean;
47
+ /** DevTools store name */
48
+ devtoolsName?: string;
49
+ /** Enable persistence */
50
+ persist?: boolean;
51
+ /** Persistence storage name */
52
+ persistName?: string;
53
+ /** Keys to persist (defaults to ['flags', 'defaults']) */
54
+ persistPartialize?: (keyof FeatureFlagStoreState)[];
55
+ }
65
56
  /**
66
- * Zustand slice creator type for slices that use middleware
67
- * like `persist` and `immer`.
68
- *
69
- * Note: You don't need to manually specify middleware type tuples
70
- * (like `["zustand/persist", T]`) since Zustand automatically infers them.
57
+ * Combined root store state and actions.
58
+ * Merges all slice types into a single store interface.
71
59
  */
72
- export type PersistentSliceCreator<T> = StateCreator<T, [], MiddlewareMutators, T>;
60
+ export type RootStoreSlice = ErrorStoreSlice & FeatureFlagStoreSlice;
73
61
  /**
74
- * Root store type that combines multiple Zustand slices.
75
- *
76
- * Currently includes only `ErrorSliceType`, but can later be extended
77
- * to include other slices such as `AuthSliceType`, `UserSliceType`, etc.
78
- *
79
- * @typedef {ErrorSliceType} RootStore
62
+ * Configuration for creating the root store.
80
63
  */
81
- export type RootStore = ErrorSliceType;
82
- export {};
64
+ export interface RootStoreConfig {
65
+ /** Error store configuration */
66
+ errors?: ErrorStoreConfig;
67
+ /** Feature flag store configuration */
68
+ featureFlags?: FeatureFlagStoreConfig;
69
+ /** Enable Redux DevTools integration */
70
+ devtools?: boolean;
71
+ /** DevTools store name */
72
+ devtoolsName?: string;
73
+ }
@@ -46,7 +46,7 @@
46
46
  import type * as Vitest from 'vitest';
47
47
  import type * as React from 'react';
48
48
  import type { UnknownRecord, UnknownArray, Arrayable, SetOptional } from 'type-fest';
49
- import type { FeatureFlag, FeatureFlagCondition, FeatureFlagConfig, FeatureFlagContext, FeatureFlagEvaluation, FeatureFlagRule, FeatureFlagValue, FeatureFlagProvider as IFeatureFlagProvider, FeatureFlagContextValue } from '../../../features';
49
+ import type { FeatureFlag, FeatureFlagCondition, FeatureFlagConfig, FeatureFlagContext, FeatureFlagEvaluation, FeatureFlagRule, FeatureFlagValue, FeatureFlagProvider as IFeatureFlagProvider, FeatureFlagContextValue, FeatureFlagProviderType } from '../../../features';
50
50
  import type { MockLogger, RenderFunction, RenderHookFunction } from '../../common';
51
51
  import type { Promisable } from 'type-fest';
52
52
  import type { Describable, KeyValuePair, Resettable, WithMetadata, WithTimestamp } from '../../../common';
@@ -461,7 +461,7 @@ export interface FeatureFlagTestOptions<FeatureFlagKey extends string> {
461
461
  /** Default evaluation context */
462
462
  context?: FeatureFlagContext;
463
463
  /** Provider type to use */
464
- provider?: 'memory' | 'file' | 'database' | 'api' | 'redis';
464
+ provider?: FeatureFlagProviderType;
465
465
  /** Enable caching */
466
466
  cache?: boolean;
467
467
  /** Enable auto-refresh */
@@ -643,7 +643,7 @@ export interface FeatureFlagHelpersMock<FeatureFlagKey extends string> {
643
643
  */
644
644
  export interface FeatureFlagTestConfig {
645
645
  /** Default provider type */
646
- defaultProvider: 'memory' | 'file' | 'database' | 'api' | 'redis';
646
+ defaultProvider: FeatureFlagProviderType;
647
647
  /** Default request timeout */
648
648
  defaultTimeout: number;
649
649
  /** Enable caching */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plyaz/types",
3
- "version": "1.19.4",
3
+ "version": "1.20.0",
4
4
  "author": "Redeemer Pace",
5
5
  "license": "ISC",
6
6
  "description": "Provides shared TypeScript types and schema utilities for validation and parsing in the @playz ecosystem.",
@@ -210,6 +210,9 @@
210
210
  "import": "./dist/campaign/index.js",
211
211
  "require": "./dist/campaign/index.cjs"
212
212
  },
213
+ "./globals": {
214
+ "types": "./dist/globals.d.ts"
215
+ },
213
216
  "./package.json": "./package.json"
214
217
  },
215
218
  "files": [
@@ -300,9 +303,10 @@
300
303
  }
301
304
  },
302
305
  "scripts": {
303
- "build": "pnpm clean && pnpm build:js && pnpm build:types",
306
+ "build": "pnpm clean && pnpm build:js && pnpm build:types && pnpm build:globals",
304
307
  "build:js": "tsup",
305
308
  "build:types": "tsc src/index.ts --emitDeclarationOnly --esModuleInterop --outDir dist --declaration --skipLibCheck",
309
+ "build:globals": "cp src/globals.d.ts dist/globals.d.ts",
306
310
  "build:watch": "tsup --watch",
307
311
  "dev": "tsup --watch",
308
312
  "lint": "eslint ./src",