@plyaz/types 1.28.0 → 1.29.1

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.
@@ -741,6 +741,64 @@ export interface CoreBaseFrontendServiceConfig<TData = Record<string, unknown>,
741
741
  * @default undefined (no unwrapping, response.data used as-is)
742
742
  */
743
743
  responseDataKey?: string;
744
+ /**
745
+ * Key to extract success status from API response.
746
+ *
747
+ * Allows services to work with different API response formats:
748
+ * - Internal APIs: `'success'` or `'isSuccess'`
749
+ * - Fetchff: `'ok'`
750
+ * - Custom APIs: any property name or nested key
751
+ *
752
+ * Supports nested keys via dot notation (e.g., `'meta.success'`).
753
+ *
754
+ * If not set, falls back to checking common properties in order:
755
+ * `isSuccess` → `success` → `ok` → HTTP status 200-299
756
+ *
757
+ * @example
758
+ * ```typescript
759
+ * // Internal API returns: { success: true, data: [...] }
760
+ * responseSuccessKey: 'success'
761
+ *
762
+ * // Fetchff returns: { ok: true, status: 200, data: [...] }
763
+ * responseSuccessKey: 'ok'
764
+ *
765
+ * // Custom API returns: { meta: { succeeded: true }, payload: [...] }
766
+ * responseSuccessKey: 'meta.succeeded'
767
+ * ```
768
+ *
769
+ * @default undefined (auto-detect from common properties)
770
+ */
771
+ responseSuccessKey?: string;
772
+ /**
773
+ * Key to extract error from API response.
774
+ *
775
+ * Allows services to work with different API error formats:
776
+ * - Internal APIs: `'error'` or `'errors'`
777
+ * - Fetchff: `'error'`
778
+ * - Custom 3rd party APIs: any property name or nested key
779
+ *
780
+ * Supports nested keys via dot notation (e.g., `'meta.error'`, `'response.errors'`).
781
+ *
782
+ * The extracted error will be transformed through `@plyaz/errors` middleware.
783
+ *
784
+ * @example
785
+ * ```typescript
786
+ * // Internal API returns: { success: false, error: { code: 'ERR', message: '...' } }
787
+ * responseErrorKey: 'error'
788
+ *
789
+ * // 3rd party API returns: { status: 'failed', errors: [...] }
790
+ * responseErrorKey: 'errors'
791
+ *
792
+ * // Nested format: { meta: { error: { code: '...', details: [...] } } }
793
+ * responseErrorKey: 'meta.error'
794
+ *
795
+ * // GraphQL-style: { data: null, errors: [{ message: '...' }] }
796
+ * responseErrorKey: 'errors'
797
+ * ```
798
+ *
799
+ * @default undefined (auto-detect from 'error' or 'errors')
800
+ */
801
+ responseErrorKey?: string;
744
802
  /** Fetcher functions for API operations (replaces direct apiClient usage) */
745
803
  fetchers?: CoreServiceFetchers<unknown, unknown, unknown, unknown, unknown, unknown, unknown>;
746
804
  /**
@@ -37,4 +37,11 @@ export interface CoreErrorOptions {
37
37
  correlationId?: string;
38
38
  /** HTTP status code override */
39
39
  statusCode?: number;
40
+ /**
41
+ * Raw error details extracted from API response.
42
+ * Used when the error is not an Error instance but contains useful data
43
+ * (e.g., validation errors array, 3rd party API error objects).
44
+ * Will be transformed through @plyaz/errors middleware.
45
+ */
46
+ details?: unknown;
40
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plyaz/types",
3
- "version": "1.28.0",
3
+ "version": "1.29.1",
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.",