@africanies/angular-web-sdk 0.1.5 → 0.1.7

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 (142) hide show
  1. package/.nx/cache/{13524438527920092277 → 13466509747676776487}/dist/libs/africanies-core/fesm2022/africanies-africanies-core.mjs +140 -52
  2. package/.nx/cache/13466509747676776487/dist/libs/africanies-core/fesm2022/africanies-africanies-core.mjs.map +1 -0
  3. package/.nx/cache/{13524438527920092277 → 13466509747676776487}/dist/libs/africanies-core/package.json +3 -3
  4. package/.nx/cache/{13524438527920092277 → 13466509747676776487}/dist/libs/africanies-core/types/africanies-africanies-core.d.ts +14 -11
  5. package/.nx/cache/{18132311043100376919 → 14995846848874973576}/dist/libs/africanies-ui/fesm2022/africanies-africanies-ui.mjs +539 -232
  6. package/.nx/cache/14995846848874973576/dist/libs/africanies-ui/fesm2022/africanies-africanies-ui.mjs.map +1 -0
  7. package/.nx/cache/{18132311043100376919 → 14995846848874973576}/dist/libs/africanies-ui/package.json +5 -5
  8. package/.nx/cache/{5741611231803799383 → 14995846848874973576}/dist/libs/africanies-ui/types/africanies-africanies-ui.d.ts +111 -28
  9. package/.nx/cache/{1275815545780424169 → 6673686859704879504}/dist/libs/africanies-theme/fesm2022/africanies-africanies-theme.mjs +16 -0
  10. package/.nx/cache/6673686859704879504/dist/libs/africanies-theme/fesm2022/africanies-africanies-theme.mjs.map +1 -0
  11. package/.nx/cache/{14153928176747262656 → 6673686859704879504}/dist/libs/africanies-theme/package.json +3 -3
  12. package/.nx/cache/{1275815545780424169 → 6673686859704879504}/dist/libs/africanies-theme/tailwind-preset.cjs +31 -14
  13. package/.nx/cache/{14153928176747262656 → 6673686859704879504}/dist/libs/africanies-theme/types/africanies-africanies-theme.d.ts +18 -1
  14. package/.nx/cache/run.json +18 -18
  15. package/.nx/cache/terminalOutputs/{4011892767661954819 → 13466509747676776487} +1 -1
  16. package/.nx/cache/terminalOutputs/1446890025183346611 +32 -0
  17. package/.nx/cache/terminalOutputs/{3064561615116090625 → 14995846848874973576} +7 -7
  18. package/.nx/cache/terminalOutputs/6337357866566791975 +6 -0
  19. package/.nx/cache/terminalOutputs/{1275815545780424169 → 6673686859704879504} +1 -1
  20. package/.nx/cache/terminalOutputs/{12148417737220755248 → 8032148447904822353} +182 -174
  21. package/.nx/workspace-data/0091ABA9-5C90-580D-953C-8C94E763ADB5-v3.db +0 -0
  22. package/.nx/workspace-data/0091ABA9-5C90-580D-953C-8C94E763ADB5-v3.db-shm +0 -0
  23. package/.nx/workspace-data/0091ABA9-5C90-580D-953C-8C94E763ADB5-v3.db-wal +0 -0
  24. package/.nx/workspace-data/d/daemon.log +2461 -0
  25. package/.nx/workspace-data/d/server-process.json +2 -2
  26. package/.nx/workspace-data/file-map.json +2747 -2747
  27. package/.nx/workspace-data/nx_files.nxt +0 -0
  28. package/.nx/workspace-data/project-graph.json +2 -2
  29. package/apps/playground/src/app/pages/button-page.ts +5 -3
  30. package/apps/playground/src/app/pages/feedback-page.ts +1 -1
  31. package/apps/playground/src/app/pages/home-page.ts +1 -1
  32. package/apps/playground/src/app/pages/icons-page.ts +3 -3
  33. package/apps/playground/src/app/pages/lecture-page.ts +3 -3
  34. package/apps/playground/src/app/pages/models-page.ts +1 -1
  35. package/apps/playground/src/app/pages/overlay-demos.ts +1 -1
  36. package/apps/playground/src/app/pages/tokens-page.ts +17 -3
  37. package/apps/playground/src/app/pages/usecases/onboarding-login.page.ts +1 -1
  38. package/apps/playground/src/app/pages/usecases/onboarding-reset-password.page.ts +1 -1
  39. package/apps/playground/src/app/pages/usecases/shipment-detail.page.ts +1 -1
  40. package/apps/playground/src/app/pages/viewport-preview.component.ts +1 -1
  41. package/apps/playground/src/app/snippets/button.snippets.ts +4 -3
  42. package/apps/playground/src/index.html +6 -0
  43. package/apps/playground/src/styles.css +4 -5
  44. package/dist/libs/africanies-core/fesm2022/africanies-africanies-core.mjs +131 -8
  45. package/dist/libs/africanies-core/fesm2022/africanies-africanies-core.mjs.map +1 -1
  46. package/dist/libs/africanies-core/types/africanies-africanies-core.d.ts +8 -6
  47. package/dist/libs/africanies-theme/fesm2022/africanies-africanies-theme.mjs +12 -2
  48. package/dist/libs/africanies-theme/fesm2022/africanies-africanies-theme.mjs.map +1 -1
  49. package/dist/libs/africanies-theme/tailwind-preset.cjs +16 -7
  50. package/dist/libs/africanies-theme/types/africanies-africanies-theme.d.ts +11 -3
  51. package/dist/libs/africanies-ui/fesm2022/africanies-africanies-ui.mjs +83 -63
  52. package/dist/libs/africanies-ui/fesm2022/africanies-africanies-ui.mjs.map +1 -1
  53. package/dist/libs/africanies-ui/types/africanies-africanies-ui.d.ts +11 -8
  54. package/libs/africanies-core/src/index.ts +1 -0
  55. package/libs/africanies-core/src/lib/notification/index.ts +1 -1
  56. package/libs/africanies-core/src/lib/notification/notification-link.spec.ts +40 -7
  57. package/libs/africanies-core/src/lib/notification/notification-link.ts +143 -7
  58. package/libs/africanies-theme/src/lib/mode-color.safelist.ts +8 -2
  59. package/libs/africanies-theme/src/lib/mode-color.service.ts +16 -0
  60. package/libs/africanies-theme/tailwind-preset.cjs +16 -7
  61. package/libs/africanies-ui/src/lib/button/button.component.ts +5 -1
  62. package/libs/africanies-ui/src/lib/feedback/empty-state.component.ts +1 -1
  63. package/libs/africanies-ui/src/lib/feedback/error-state.component.ts +1 -1
  64. package/libs/africanies-ui/src/lib/forms/file-upload/file-preview.dialog.ts +1 -1
  65. package/libs/africanies-ui/src/lib/forms/file-upload/file-upload.component.ts +4 -4
  66. package/libs/africanies-ui/src/lib/forms/form-field.classes.ts +2 -2
  67. package/libs/africanies-ui/src/lib/forms/select/select.component.ts +1 -1
  68. package/libs/africanies-ui/src/lib/layout/app-shell-header.component.ts +1 -1
  69. package/libs/africanies-ui/src/lib/layout/app-shell.component.ts +2 -2
  70. package/libs/africanies-ui/src/lib/navigation/shipping-mode-switch/shipping-mode-switch.component.ts +2 -2
  71. package/libs/africanies-ui/src/lib/navigation/side-nav/africanies-side-nav.component.html +2 -2
  72. package/libs/africanies-ui/src/lib/navigation/side-nav/africanies-side-nav.component.ts +10 -6
  73. package/libs/africanies-ui/src/lib/notifications/notification-drawer.panel.ts +21 -8
  74. package/libs/africanies-ui/src/lib/overlay/drawer.service.ts +1 -1
  75. package/libs/africanies-ui/src/lib/overlay/modal.service.ts +1 -1
  76. package/libs/africanies-ui/src/lib/pagination/pagination.component.ts +3 -3
  77. package/libs/africanies-ui/src/lib/table/table.component.ts +5 -5
  78. package/libs/africanies-ui/src/lib/toast/toast-host.component.ts +4 -4
  79. package/libs/africanies-ui/src/lib/toast/toast-item.component.ts +1 -1
  80. package/package.json +1 -1
  81. package/.nx/cache/1275815545780424169/dist/libs/africanies-theme/fesm2022/africanies-africanies-theme.mjs.map +0 -1
  82. package/.nx/cache/1275815545780424169/dist/libs/africanies-theme/package.json +0 -36
  83. package/.nx/cache/1275815545780424169/dist/libs/africanies-theme/types/africanies-africanies-theme.d.ts +0 -157
  84. package/.nx/cache/13524438527920092277/dist/libs/africanies-core/fesm2022/africanies-africanies-core.mjs.map +0 -1
  85. package/.nx/cache/14153928176747262656/dist/libs/africanies-theme/README.md +0 -46
  86. package/.nx/cache/14153928176747262656/dist/libs/africanies-theme/fesm2022/africanies-africanies-theme.mjs +0 -215
  87. package/.nx/cache/14153928176747262656/dist/libs/africanies-theme/fesm2022/africanies-africanies-theme.mjs.map +0 -1
  88. package/.nx/cache/14153928176747262656/dist/libs/africanies-theme/tailwind-preset.cjs +0 -245
  89. package/.nx/cache/18132311043100376919/dist/libs/africanies-ui/fesm2022/africanies-africanies-ui.mjs.map +0 -1
  90. package/.nx/cache/18132311043100376919/dist/libs/africanies-ui/types/africanies-africanies-ui.d.ts +0 -5410
  91. package/.nx/cache/2782605790118376385/dist/libs/africanies-icons/README.md +0 -69
  92. package/.nx/cache/2782605790118376385/dist/libs/africanies-icons/assets/icons.sprite.svg +0 -1844
  93. package/.nx/cache/2782605790118376385/dist/libs/africanies-icons/fesm2022/africanies-africanies-icons.mjs +0 -832
  94. package/.nx/cache/2782605790118376385/dist/libs/africanies-icons/fesm2022/africanies-africanies-icons.mjs.map +0 -1
  95. package/.nx/cache/2782605790118376385/dist/libs/africanies-icons/package.json +0 -31
  96. package/.nx/cache/2782605790118376385/dist/libs/africanies-icons/types/africanies-africanies-icons.d.ts +0 -108
  97. package/.nx/cache/3064561615116090625/dist/libs/africanies-storage/README.md +0 -31
  98. package/.nx/cache/3064561615116090625/dist/libs/africanies-storage/fesm2022/africanies-africanies-storage.mjs +0 -243
  99. package/.nx/cache/3064561615116090625/dist/libs/africanies-storage/fesm2022/africanies-africanies-storage.mjs.map +0 -1
  100. package/.nx/cache/3064561615116090625/dist/libs/africanies-storage/package.json +0 -27
  101. package/.nx/cache/3064561615116090625/dist/libs/africanies-storage/types/africanies-africanies-storage.d.ts +0 -210
  102. package/.nx/cache/4011892767661954819/dist/libs/africanies-core/README.md +0 -85
  103. package/.nx/cache/4011892767661954819/dist/libs/africanies-core/fesm2022/africanies-africanies-core.mjs +0 -4546
  104. package/.nx/cache/4011892767661954819/dist/libs/africanies-core/fesm2022/africanies-africanies-core.mjs.map +0 -1
  105. package/.nx/cache/4011892767661954819/dist/libs/africanies-core/package.json +0 -32
  106. package/.nx/cache/4011892767661954819/dist/libs/africanies-core/types/africanies-africanies-core.d.ts +0 -2740
  107. package/.nx/cache/5741611231803799383/dist/libs/africanies-ui/README.md +0 -68
  108. package/.nx/cache/5741611231803799383/dist/libs/africanies-ui/assets/brand/africanies-logo-mini.png +0 -0
  109. package/.nx/cache/5741611231803799383/dist/libs/africanies-ui/assets/brand/africanies-logo.png +0 -0
  110. package/.nx/cache/5741611231803799383/dist/libs/africanies-ui/assets/brand/africanies-logo.svg +0 -5
  111. package/.nx/cache/5741611231803799383/dist/libs/africanies-ui/assets/carriers/dhl.svg +0 -7
  112. package/.nx/cache/5741611231803799383/dist/libs/africanies-ui/fesm2022/africanies-africanies-ui.mjs +0 -19088
  113. package/.nx/cache/5741611231803799383/dist/libs/africanies-ui/fesm2022/africanies-africanies-ui.mjs.map +0 -1
  114. package/.nx/cache/5741611231803799383/dist/libs/africanies-ui/package.json +0 -36
  115. package/.nx/cache/6372470950255467653/dist/libs/africanies-models/README.md +0 -60
  116. package/.nx/cache/6372470950255467653/dist/libs/africanies-models/fesm2022/africanies-africanies-models.mjs +0 -599
  117. package/.nx/cache/6372470950255467653/dist/libs/africanies-models/fesm2022/africanies-africanies-models.mjs.map +0 -1
  118. package/.nx/cache/6372470950255467653/dist/libs/africanies-models/package.json +0 -24
  119. package/.nx/cache/6372470950255467653/dist/libs/africanies-models/types/africanies-africanies-models.d.ts +0 -1452
  120. package/.nx/cache/terminalOutputs/11768036696192889608 +0 -8
  121. package/.nx/cache/terminalOutputs/1227201614544602906 +0 -23
  122. package/.nx/cache/terminalOutputs/12538607787148205787 +0 -19
  123. package/.nx/cache/terminalOutputs/13524438527920092277 +0 -196
  124. package/.nx/cache/terminalOutputs/14153928176747262656 +0 -45
  125. package/.nx/cache/terminalOutputs/17404566492103808557 +0 -8
  126. package/.nx/cache/terminalOutputs/18132311043100376919 +0 -315
  127. package/.nx/cache/terminalOutputs/2436781291243085315 +0 -8
  128. package/.nx/cache/terminalOutputs/2782605790118376385 +0 -21
  129. package/.nx/cache/terminalOutputs/3681975492957101833 +0 -8
  130. package/.nx/cache/terminalOutputs/5741611231803799383 +0 -21
  131. package/.nx/cache/terminalOutputs/6037166070823946880 +0 -8
  132. package/.nx/cache/terminalOutputs/6372470950255467653 +0 -21
  133. package/.nx/cache/terminalOutputs/665190206482526466 +0 -175
  134. package/.nx/cache/terminalOutputs/7756595539965457927 +0 -23
  135. package/.nx/cache/terminalOutputs/9200013119269230075 +0 -8
  136. /package/.nx/cache/{13524438527920092277 → 13466509747676776487}/dist/libs/africanies-core/README.md +0 -0
  137. /package/.nx/cache/{18132311043100376919 → 14995846848874973576}/dist/libs/africanies-ui/README.md +0 -0
  138. /package/.nx/cache/{18132311043100376919 → 14995846848874973576}/dist/libs/africanies-ui/assets/brand/africanies-logo-mini.png +0 -0
  139. /package/.nx/cache/{18132311043100376919 → 14995846848874973576}/dist/libs/africanies-ui/assets/brand/africanies-logo.png +0 -0
  140. /package/.nx/cache/{18132311043100376919 → 14995846848874973576}/dist/libs/africanies-ui/assets/brand/africanies-logo.svg +0 -0
  141. /package/.nx/cache/{18132311043100376919 → 14995846848874973576}/dist/libs/africanies-ui/assets/carriers/dhl.svg +0 -0
  142. /package/.nx/cache/{1275815545780424169 → 6673686859704879504}/dist/libs/africanies-theme/README.md +0 -0
@@ -1,2740 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { InjectionToken, EnvironmentProviders, Signal, Type } from '@angular/core';
3
- import { HttpContextToken, HttpContext, HttpInterceptorFn, HttpFeature, HttpFeatureKind } from '@angular/common/http';
4
- import { Observable } from 'rxjs';
5
- import { ApiResponseModel, ShippingMode, PaginationQueryParamsModel, ApiJsonValue, PaginationMetaModel, ResourceId, ApiErrorDetailModel, ModeConfigDataModel, ModeRegionConfigModel, ModeAppType, CountryModel, CountryStateModel, DocumentModel, PlanModel, PlanPackageModel, ServiceModel, CurrencyModel, CurrencyPaymentMethodModel, CurrencyPaymentMethodPivotModel, CurrencyCreateRequestModel, CurrencyFlag01, CurrencyDeleteRequestModel, CurrencyUpdateRequestModel, PaymentMethodModel, PaymentMethodCurrencyModel, PaymentMethodFlag01, PaymentMethodUpdateRequestModel, ShipmentMethodModel, ShipmentMethodZoneLinkModel, ShipmentMethodZonePageModel, ShipmentZoneModel, WarehouseModel, WarehouseStateModel, ZoneModel, UserModel, UserAccountManagerModel, UserBusinessAccountModel, UserCountryModel, UserStateModel, UserGatewayPayloadModel, UserPaymentPayloadModel, UserPlanModel, UserPlanPackageModel, UserSubscriptionModel, ChangePasswordRequestModel, NotificationModel, NotificationInboxItemModel, NotificationPayloadModel, FileReadModel, FileReadRequestModel, ProductModel, ModuleFilterConfigModel, FilterOptionsSource, FilterFieldModel } from '@africanies/africanies-models';
6
-
7
- /**
8
- * Per-request toast flags for {@link httpToastInterceptor}.
9
- *
10
- * Attach with {@link withToast}. When the token is absent, the interceptor
11
- * stays quiet — toasting is opt-in per call.
12
- */
13
- interface ToastHttpOptions {
14
- /** Show a success toast when the response is OK. Default `true`. */
15
- success: boolean;
16
- /** Show an error toast when the request fails. Default `true`. */
17
- error: boolean;
18
- /** Override the default success copy. */
19
- successMessage?: string;
20
- /** Override the default error copy. */
21
- errorMessage?: string;
22
- }
23
- /**
24
- * Optional bridge from HTTP → toast UI.
25
- *
26
- * Provided by `@africanies/africanies-ui` {@link provideAfricaniesToasts}. When missing,
27
- * {@link httpToastInterceptor} is a no-op even if {@link withToast} is set.
28
- */
29
- interface AfricaniesHttpToastHandler {
30
- /** Timed success toast. */
31
- success(message: string): void;
32
- /** Persistent error toast (user must dismiss). */
33
- error(message: string): void;
34
- }
35
- /** DI token for the HTTP → toast bridge. */
36
- declare const AFRICANIES_HTTP_TOAST: InjectionToken<AfricaniesHttpToastHandler>;
37
- /**
38
- * Present only when the request was tagged with {@link withToast}.
39
- * Sentinel `null` means “not tagged”.
40
- */
41
- declare const TOAST_HTTP_OPTIONS: HttpContextToken<ToastHttpOptions | null>;
42
- /**
43
- * Opt a request into HTTP toasts.
44
- *
45
- * Defaults: `success: true`, `error: true`. Pass flags to silence either side.
46
- *
47
- * @param options - Partial overrides for the defaults.
48
- * @returns HttpContext ready to pass as `context` on HttpClient calls.
49
- *
50
- * @example
51
- * ```ts
52
- * // Success + error toasts
53
- * this.http.post(url, body, { context: withToast() });
54
- *
55
- * // Errors only
56
- * this.http.post(url, body, { context: withToast({ success: false }) });
57
- *
58
- * // Custom copy
59
- * this.http.post(url, body, {
60
- * context: withToast({
61
- * successMessage: 'Shipment saved',
62
- * errorMessage: 'Could not save shipment',
63
- * }),
64
- * });
65
- * ```
66
- */
67
- declare function withToast(options?: Partial<ToastHttpOptions>): HttpContext;
68
-
69
- /**
70
- * Default HTTP toast behaviour for {@link ApiClient} requests.
71
- *
72
- * - `'off'` (default) — no automatic tagging; use {@link withToast} on raw
73
- * HttpClient calls or {@link ApiRequestOptions.toast} per SDK call.
74
- * - `'errors'` — tag mutating SDK requests (POST / PUT / PATCH / DELETE) with
75
- * error toasts only. GET stays silent so list/detail screens own their empty
76
- * / error UI.
77
- * - `'all'` — success + error toasts on mutating SDK requests (GET still silent
78
- * unless the call opts in).
79
- * - Partial {@link ToastHttpOptions} — custom defaults merged per mutating request.
80
- */
81
- type AfricaniesSdkHttpToasts = 'off' | 'errors' | 'all' | Partial<ToastHttpOptions>;
82
- /**
83
- * Runtime configuration for the AFRICANIES SDK HTTP layer and related services.
84
- *
85
- * Provided once at bootstrap via {@link provideAfricaniesSdk} and injected
86
- * wherever the SDK needs the API origin or shared request defaults.
87
- *
88
- * @example
89
- * ```ts
90
- * // app.config.ts
91
- * import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
92
- * import { provideAfricaniesSdk, provideAfricaniesHttpClient } from '@africanies/africanies-core';
93
- *
94
- * export const appConfig: ApplicationConfig = {
95
- * providers: [
96
- * provideZoneChangeDetection({ eventCoalescing: true }),
97
- * provideAfricaniesSdk({
98
- * baseUrl: 'https://api.example.com',
99
- * timeout: 30_000,
100
- * defaultHeaders: { 'X-App': 'stn-web' },
101
- * }),
102
- * provideAfricaniesHttpClient(),
103
- * ],
104
- * };
105
- * ```
106
- */
107
- interface AfricaniesSdkConfig {
108
- /**
109
- * Absolute API origin used to resolve relative paths in {@link ApiClient}
110
- * (e.g. `'https://api.example.com'`). Trailing slashes are trimmed when
111
- * composing URLs so callers can pass either style.
112
- */
113
- baseUrl: string;
114
- /**
115
- * Per-request timeout in milliseconds applied by {@link ApiClient}.
116
- * Omitted when the consumer prefers HttpClient / browser defaults only.
117
- */
118
- timeout?: number;
119
- /**
120
- * Headers merged onto every {@link ApiClient} request.
121
- * Request-specific headers override these on key collision.
122
- */
123
- defaultHeaders?: Record<string, string>;
124
- /**
125
- * When true (default), fetch `/public/mode/config` on startup via
126
- * {@link provideModeConfig}. Set `false` for tests or offline-only shells.
127
- */
128
- loadModeConfig?: boolean;
129
- /**
130
- * Automatic {@link withToast} tagging for {@link ApiClient} HTTP calls.
131
- *
132
- * Defaults to `'off'` so production apps opt in explicitly. Admin shells use
133
- * `'errors'` so POST / PUT / PATCH / DELETE failures surface while GET list
134
- * failures stay in-page.
135
- */
136
- httpToasts?: AfricaniesSdkHttpToasts;
137
- }
138
- /**
139
- * DI token for the active {@link AfricaniesSdkConfig}.
140
- *
141
- * Apps must call {@link provideAfricaniesSdk} at bootstrap; injecting without that
142
- * provider throws so misconfiguration fails fast rather than silently using
143
- * an empty base URL.
144
- */
145
- declare const AFRICANIES_SDK_CONFIG: InjectionToken<AfricaniesSdkConfig>;
146
-
147
- /**
148
- * Registers SDK configuration and ensures browser storage is available.
149
- *
150
- * Also calls {@link provideLocalStorage} so theme / mode-config / auth-token
151
- * persistence works out of the box. {@link ShippingModeService} always uses
152
- * {@link SessionStorageService} so each tab can hold its own STN/SFN mode.
153
- * When {@link AfricaniesSdkConfig.loadModeConfig} is not `false`, {@link provideModeConfig}
154
- * runs on startup.
155
- *
156
- * @param config - API origin and optional timeout / default headers.
157
- * @returns Environment providers for `app.config.ts`.
158
- *
159
- * @example
160
- * ```ts
161
- * // app.config.ts
162
- * import { ApplicationConfig } from '@angular/core';
163
- * import {
164
- * provideAfricaniesSdk,
165
- * provideAfricaniesHttpClient,
166
- * } from '@africanies/africanies-core';
167
- * import { provideSessionStorage } from '@africanies/africanies-storage';
168
- *
169
- * export const appConfig: ApplicationConfig = {
170
- * providers: [
171
- * provideAfricaniesSdk({
172
- * baseUrl: import.meta.env['NG_APP_API_URL'],
173
- * timeout: 30_000,
174
- * }),
175
- * // Optional: override the localStorage default registered above
176
- * // provideSessionStorage(),
177
- * provideAfricaniesHttpClient(),
178
- * // Or with app interceptors:
179
- * // provideAfricaniesHttpClient({ interceptors: [loggingInterceptor] }),
180
- * ],
181
- * };
182
- * ```
183
- */
184
- declare function provideAfricaniesSdk(config: AfricaniesSdkConfig): EnvironmentProviders;
185
-
186
- /** Forgot-password path (relative to {@link AfricaniesSdkConfig.baseUrl}). */
187
- declare const AUTH_FORGOT_PASSWORD_PATH = "/auth/forgot/password";
188
-
189
- /**
190
- * Unauthenticated auth endpoints (`POST /auth/…`).
191
- *
192
- * **Forgot password is email-only.** `forgot()` POSTs `{ email }`; the
193
- * backend emails a reset link. This product UI never collects a new password
194
- * for that link (no token in the route, `/onboarding/reset-password` is
195
- * **not** that flow).
196
- *
197
- * `/onboarding/reset-password` is first login with a default password: after
198
- * login, if `user.default_password` is set, the host sends the user there to
199
- * change current → new via {@link UserService.changePassword}.
200
- *
201
- * Token persistence stays on {@link AuthTokenService}. These calls do not
202
- * require a bearer token — the interceptor omits `Authorization` when none
203
- * is stored. Admin user/partner screens reuse {@link forgot} with that
204
- * user’s email.
205
- *
206
- * @example
207
- * ```ts
208
- * const authApi = inject(AuthService);
209
- *
210
- * authApi.forgot('user@example.com').subscribe((res) => {
211
- * if (res.success) {
212
- * // Show res.message, then “Reset completed? Login here”.
213
- * }
214
- * });
215
- * ```
216
- */
217
- declare class AuthService {
218
- private readonly api;
219
- /**
220
- * Request a password-reset email (`POST /auth/forgot/password`).
221
- *
222
- * Enable submit only when the address looks valid. Wire `data` is an empty
223
- * array on success — use {@link ApiResponseModel.message} for the banner.
224
- *
225
- * @param email - Registered account email.
226
- * @returns Normalized envelope (`data` is typically `[]`).
227
- */
228
- forgot(email: string): Observable<ApiResponseModel<unknown[]>>;
229
- static ɵfac: i0.ɵɵFactoryDeclaration<AuthService, never>;
230
- static ɵprov: i0.ɵɵInjectableDeclaration<AuthService>;
231
- }
232
-
233
- /**
234
- * Holds the bearer access token used by {@link authInterceptor}.
235
- *
236
- * After login/register in the host app, call {@link set}. The SDK persists the
237
- * token via {@link STORAGE_TOKEN} and attaches `Authorization: Bearer …` on
238
- * outbound HTTP. On logout, call {@link UserService.logoutFromAllSessions}
239
- * while the token is still set, then {@link clear} (also clears the GET cache).
240
- *
241
- * @example
242
- * ```ts
243
- * const auth = inject(AuthTokenService);
244
- * const users = inject(UserService);
245
- *
246
- * // after login
247
- * auth.set(res.access_token);
248
- *
249
- * // later — UserService.me() is authenticated automatically
250
- * // on logout — POST while the token is still set, then drop it
251
- * users.logoutFromAllSessions().subscribe({
252
- * next: () => auth.clear(),
253
- * error: () => auth.clear(),
254
- * });
255
- * ```
256
- */
257
- declare class AuthTokenService {
258
- private readonly storage;
259
- private readonly api;
260
- private readonly _token;
261
- /** Read-only view of the current access token. */
262
- readonly token: Signal<string | null>;
263
- /**
264
- * Current access token, or `null` when logged out / unset.
265
- */
266
- get(): string | null;
267
- /**
268
- * Persist and activate an access token from login/register.
269
- *
270
- * @param accessToken - Bearer token string (whitespace-only is treated as clear).
271
- */
272
- set(accessToken: string): void;
273
- /**
274
- * Remove the token from memory and storage, and clear the HTTP GET cache.
275
- */
276
- clear(): void;
277
- private readInitialToken;
278
- static ɵfac: i0.ɵɵFactoryDeclaration<AuthTokenService, never>;
279
- static ɵprov: i0.ɵɵInjectableDeclaration<AuthTokenService>;
280
- }
281
-
282
- /**
283
- * Enable forgot-password submit when the address looks like an email.
284
- *
285
- * Intentionally loose (`local@host.tld`) — the API owns uniqueness and
286
- * deliverability. Empty / whitespace-only values fail.
287
- *
288
- * @param value - Raw field value.
289
- * @returns Whether submit should be enabled.
290
- */
291
- declare function isValidEmail(value: unknown): boolean;
292
-
293
- /**
294
- * Attaches the current shipping mode as an `x-shipment-mode` header.
295
- *
296
- * Uses {@link SHIPPING_MODE_OVERRIDE} when the request was tagged (via
297
- * {@link ApiRequestOptions.shippingMode} or {@link withShippingMode});
298
- * otherwise {@link ShippingModeService.mode}. The tab mode is never mutated.
299
- *
300
- * Some backends also expect `mode` as a query param (see {@link ApiClient.getResource});
301
- * this interceptor covers the header half so domain calls stay consistent
302
- * without each service remembering the header name.
303
- *
304
- * Prefer {@link provideAfricaniesHttpClient}, which registers this interceptor by
305
- * default. {@link ShippingModeService} is `providedIn: 'root'` and needs no
306
- * extra provider.
307
- *
308
- * @param req - Outgoing request.
309
- * @param next - Next handler in the interceptor chain.
310
- * @returns The downstream observable for the cloned request.
311
- * @example
312
- * ```ts
313
- * provideAfricaniesSdk({ baseUrl: 'https://api.example.com' }),
314
- * provideAfricaniesHttpClient(),
315
- *
316
- * api.post('/claim', body, { shippingMode: 'stn' });
317
- * ```
318
- */
319
- declare const shipmentModeInterceptor: HttpInterceptorFn;
320
-
321
- /**
322
- * Per-request shipping-mode override for {@link shipmentModeInterceptor}.
323
- *
324
- * When set, `x-shipment-mode` uses this value instead of
325
- * {@link ShippingModeService.mode}. The tab / session mode is unchanged.
326
- * Sentinel `null` means “use the active tab mode”.
327
- */
328
- declare const SHIPPING_MODE_OVERRIDE: HttpContextToken<ShippingMode | null>;
329
- /**
330
- * Narrow unknown JSON / option values to a {@link ShippingMode}.
331
- *
332
- * @param value - Candidate value.
333
- * @returns `'stn'` or `'sfn'` when valid; otherwise `undefined`.
334
- */
335
- declare function asShippingMode(value: unknown): ShippingMode | undefined;
336
- /**
337
- * Tag a request so {@link shipmentModeInterceptor} sends a different
338
- * `x-shipment-mode` without calling {@link ShippingModeService.setMode}.
339
- *
340
- * Prefer {@link ApiRequestOptions.shippingMode} on {@link ApiClient} calls.
341
- * Use this helper with raw `HttpClient`.
342
- *
343
- * @param mode - Mode for this request only.
344
- * @param context - Existing context to merge (e.g. from {@link withToast}).
345
- * @returns HttpContext with the override set.
346
- *
347
- * @example
348
- * ```ts
349
- * this.http.post(url, body, { context: withShippingMode('stn') });
350
- * ```
351
- */
352
- declare function withShippingMode(mode: ShippingMode, context?: HttpContext): HttpContext;
353
-
354
- /**
355
- * Optional gate before a shell mode switch applies.
356
- *
357
- * Return `true` to allow {@link ShippingModeService.requestModeChange} to
358
- * persist the new mode; `false` keeps the current mode.
359
- */
360
- type ShippingModeChangeGuard = (next: ShippingMode, current: ShippingMode) => Observable<boolean>;
361
- /**
362
- * Signal-based holder for the active {@link ShippingMode}.
363
- *
364
- * Persists through {@link SessionStorageService} under
365
- * {@link AFRICANIES_SHIPPING_MODE_KEY} so each browser tab can hold its own STN/SFN
366
- * context (refresh within the tab keeps the choice; other tabs are unaffected).
367
- * Defaults to `'sfn'` when nothing is stored or the stored value is not a known
368
- * mode — preferring a safe outbound default over failing open on corrupt storage.
369
- *
370
- * Changing mode clears {@link ApiClient}'s GET cache so `readAll` / by-id
371
- * dumps cannot cross STN↔SFN (cache keys omit the mode header). `ApiClient`
372
- * is resolved lazily via {@link Injector} to avoid a DI cycle.
373
- *
374
- * List screens should drop in-memory rows and show a blocking loader until
375
- * the new mode's page arrives — STN rows must not linger on SFN. Use
376
- * `listFetchKind` with `reason: 'mode'`.
377
- *
378
- * Features that must warn before a switch (e.g. mid Create Shipment) can
379
- * {@link registerModeChangeGuard}. The shell switch uses
380
- * {@link requestModeChange}; programmatic {@link setMode} bypasses the guard.
381
- *
382
- * Provided in root; no explicit provider registration is required.
383
- * Pair with {@link shipmentModeInterceptor} so HTTP calls advertise the mode.
384
- *
385
- * @example
386
- * ```ts
387
- * const shipping = inject(ShippingModeService);
388
- * shipping.setMode('stn');
389
- * console.log(shipping.mode()); // 'stn'
390
- * ```
391
- */
392
- declare class ShippingModeService {
393
- private readonly storage;
394
- private readonly injector;
395
- private readonly _mode;
396
- private modeChangeGuard;
397
- /**
398
- * Read-only view of the current shipping mode (`Signal` = Angular's
399
- * readonly signal surface; mutate only via {@link setMode} /
400
- * {@link requestModeChange}).
401
- */
402
- readonly mode: Signal<ShippingMode>;
403
- /**
404
- * Register a single guard for shell mode switches. Pass `null` to clear
405
- * (e.g. on feature destroy). Only one guard is active at a time.
406
- * @param guard
407
- */
408
- registerModeChangeGuard(guard: ShippingModeChangeGuard | null): void;
409
- /**
410
- * Shell switch entry point: runs any registered guard, then applies the
411
- * mode when allowed.
412
- *
413
- * @param mode - `'stn'` or `'sfn'`.
414
- * @returns Emits once with `true` when the mode changed, else `false`.
415
- */
416
- requestModeChange(mode: ShippingMode): Observable<boolean>;
417
- /**
418
- * Updates the active mode and persists it for the current tab.
419
- * No-ops when `mode` already matches the current value.
420
- * Bypasses {@link registerModeChangeGuard} — prefer
421
- * {@link requestModeChange} for user-driven switches.
422
- *
423
- * @param mode - `'stn'` or `'sfn'`.
424
- */
425
- setMode(mode: ShippingMode): void;
426
- private applyMode;
427
- private readInitialMode;
428
- static ɵfac: i0.ɵɵFactoryDeclaration<ShippingModeService, never>;
429
- static ɵprov: i0.ɵɵInjectableDeclaration<ShippingModeService>;
430
- }
431
-
432
- /**
433
- * Shared request options for {@link ApiClient} verbs.
434
- *
435
- * ## In-memory GET caching (`cacheTtlMs`)
436
- *
437
- * Optional short-TTL cache for identical GET URLs. See {@link HttpResponseCache}
438
- * for when **not** to enable it (volatile data, auth-sensitive payloads,
439
- * post-mutation lists). Prefer TanStack Query for app-level caching.
440
- */
441
- interface ApiRequestOptions {
442
- /**
443
- * `'wrapped'` (default) → {@link ApiResponseModel}; `'raw'` → payload `T`.
444
- * Both paths still run through {@link normalize} so null-safety is consistent.
445
- */
446
- responseMode?: 'wrapped' | 'raw';
447
- /** Extra headers; override {@link AfricaniesSdkConfig.defaultHeaders} on conflict. */
448
- headers?: Record<string, string>;
449
- /** Query string values; `null` / `undefined` / `''` entries are omitted. */
450
- params?: Record<string, string | number | boolean | null | undefined>;
451
- /**
452
- * When set on GET, serve/store the normalized result in the in-memory cache
453
- * for this many milliseconds. Omit for uncached reads (the common case).
454
- */
455
- cacheTtlMs?: number;
456
- /**
457
- * HTTP toast tagging for this request (via {@link httpToastInterceptor}).
458
- *
459
- * - Omitted — use {@link AfricaniesSdkConfig.httpToasts} when set (mutations only;
460
- * GET stays silent unless you opt in here).
461
- * - `false` — never toast this call (overrides config). Prefer only for rare
462
- * cases that fully own error UI; mutations should usually toast.
463
- * - Partial flags — merge with config defaults (same shape as {@link withToast}).
464
- */
465
- toast?: Partial<ToastHttpOptions> | false;
466
- /**
467
- * Override `x-shipment-mode` for this request only.
468
- *
469
- * Does not call {@link ShippingModeService.setMode} — the tab / session mode
470
- * stays unchanged. {@link getResource} also uses this for the `mode` query
471
- * param when provided.
472
- */
473
- shippingMode?: ShippingMode;
474
- }
475
- /**
476
- * Endpoint-agnostic HTTP façade over Angular {@link HttpClient}.
477
- *
478
- * Domain services own path strings — this client never hard-codes product
479
- * routes (except helpers like {@link getResource} that only know conventions).
480
- *
481
- * Features:
482
- * - `responseMode` overloads (`wrapped` | `raw`)
483
- * - {@link normalize} on every **2xx** body
484
- * - HTTP failures rethrown as `Error` whose `.message` is already
485
- * user-facing ({@link formatApiErrorMessage}) — consumers do not need to
486
- * parse `HttpErrorResponse` bodies
487
- * - Exponential-backoff retry (max 1) for **GET only**
488
- * - Optional per-GET TTL cache via `cacheTtlMs`
489
- *
490
- * @example
491
- * ```ts
492
- * const api = inject(ApiClient);
493
- * api.get<User>('/users/1').subscribe({
494
- * next: (res) => {
495
- * if (res.success) console.log(res.data);
496
- * else console.error(res.message); // already joined when a validation bag exists
497
- * },
498
- * error: (err: Error) => console.error(err.message),
499
- * });
500
- * ```
501
- */
502
- declare class ApiClient {
503
- private readonly http;
504
- private readonly config;
505
- private readonly shippingMode;
506
- private readonly cache;
507
- /**
508
- * GET with wrapped {@link ApiResponseModel} (default).
509
- *
510
- * @typeParam T - Payload type inside `data`.
511
- */
512
- get<T>(path: string, options?: ApiRequestOptions & {
513
- responseMode?: 'wrapped';
514
- }): Observable<ApiResponseModel<T>>;
515
- /**
516
- * GET returning the bare payload type (after normalize + unwrap).
517
- *
518
- * @typeParam T - Unwrapped payload type.
519
- */
520
- get<T>(path: string, options: ApiRequestOptions & {
521
- responseMode: 'raw';
522
- }): Observable<T>;
523
- /**
524
- * POST with wrapped envelope (default).
525
- *
526
- * @typeParam T - Payload type inside `data`.
527
- * @typeParam TBody - JSON body type.
528
- */
529
- post<T, TBody = unknown>(path: string, body: TBody, options?: ApiRequestOptions & {
530
- responseMode?: 'wrapped';
531
- }): Observable<ApiResponseModel<T>>;
532
- /**
533
- * POST returning bare payload `T`.
534
- *
535
- * @typeParam T - Unwrapped payload type.
536
- * @typeParam TBody - JSON body type.
537
- */
538
- post<T, TBody = unknown>(path: string, body: TBody, options: ApiRequestOptions & {
539
- responseMode: 'raw';
540
- }): Observable<T>;
541
- /**
542
- * PATCH with wrapped envelope (default).
543
- *
544
- * @typeParam T - Payload type inside `data`.
545
- * @typeParam TBody - JSON body type.
546
- */
547
- patch<T, TBody = unknown>(path: string, body: TBody, options?: ApiRequestOptions & {
548
- responseMode?: 'wrapped';
549
- }): Observable<ApiResponseModel<T>>;
550
- /**
551
- * PATCH returning bare payload `T`.
552
- *
553
- * @typeParam T - Unwrapped payload type.
554
- * @typeParam TBody - JSON body type.
555
- */
556
- patch<T, TBody = unknown>(path: string, body: TBody, options: ApiRequestOptions & {
557
- responseMode: 'raw';
558
- }): Observable<T>;
559
- /**
560
- * PUT with wrapped envelope (default).
561
- *
562
- * @typeParam T - Payload type inside `data`.
563
- * @typeParam TBody - JSON body type.
564
- */
565
- put<T, TBody = unknown>(path: string, body: TBody, options?: ApiRequestOptions & {
566
- responseMode?: 'wrapped';
567
- }): Observable<ApiResponseModel<T>>;
568
- /**
569
- * PUT returning bare payload `T`.
570
- *
571
- * @typeParam T - Unwrapped payload type.
572
- * @typeParam TBody - JSON body type.
573
- */
574
- put<T, TBody = unknown>(path: string, body: TBody, options: ApiRequestOptions & {
575
- responseMode: 'raw';
576
- }): Observable<T>;
577
- /**
578
- * DELETE with wrapped envelope (default).
579
- *
580
- * @typeParam T - Payload type inside `data`.
581
- * @typeParam TBody - Optional JSON body (Laravel deletes that expect `{ id }`).
582
- */
583
- delete<T, TBody = unknown>(path: string, body?: TBody, options?: ApiRequestOptions & {
584
- responseMode?: 'wrapped';
585
- }): Observable<ApiResponseModel<T>>;
586
- /**
587
- * DELETE returning bare payload `T`.
588
- *
589
- * @typeParam T - Unwrapped payload type.
590
- * @typeParam TBody - Optional JSON body.
591
- */
592
- delete<T, TBody = unknown>(path: string, body: TBody | undefined, options: ApiRequestOptions & {
593
- responseMode: 'raw';
594
- }): Observable<T>;
595
- /**
596
- * List/detail GET using the AFRICANIES {@link ResourceId} convention.
597
- *
598
- * Prefer the named helpers when exploring the API in the IDE:
599
- * - {@link getResourcePage} — `id: null` (paginated)
600
- * - {@link getResourceAll} — `id: 'all'`
601
- * - {@link getResourceById} — numeric id
602
- *
603
- * Always attaches `mode` from the active tab or {@link ApiRequestOptions.shippingMode}
604
- * (in addition to the `x-shipment-mode` header from {@link shipmentModeInterceptor}).
605
- *
606
- * @typeParam T - Element type for lists, or record type for by-id.
607
- *
608
- * @example
609
- * ```ts
610
- * api.getResource<Shipment>('shipments', null, { page: 1, size: 15 })
611
- * .subscribe((res) => console.log(res.data, res.pagination));
612
- * ```
613
- */
614
- getResource<T>(basePath: string, id: null, query?: PaginationQueryParamsModel, options?: ApiRequestOptions): Observable<ApiResponseModel<T[]>>;
615
- /**
616
- * Full unpaginated list: `GET {basePath}/all` (pagination query ignored).
617
- *
618
- * @typeParam T - Element type of the list.
619
- */
620
- getResource<T>(basePath: string, id: 'all', query?: PaginationQueryParamsModel, options?: ApiRequestOptions): Observable<ApiResponseModel<T[]>>;
621
- /**
622
- * Single record: `GET {basePath}/{id}` (pagination query ignored).
623
- *
624
- * @typeParam T - Record type.
625
- */
626
- getResource<T>(basePath: string, id: number, query?: PaginationQueryParamsModel, options?: ApiRequestOptions): Observable<ApiResponseModel<T>>;
627
- /**
628
- * Paginated list — {@link ResourceId} `null`.
629
- * IDE-friendly alias for `getResource(basePath, null, query)`.
630
- *
631
- * Page size defaults to {@link DEFAULT_PAGE_SIZE} (`15`) unless
632
- * `query.size` is set. Bind `res.pagination` to `africanies-pagination`.
633
- *
634
- * @typeParam T - Element type of the list.
635
- * @param basePath - Resource base path (no trailing id segment).
636
- * @param query - Optional page/size/order.
637
- */
638
- getResourcePage<T>(basePath: string, query?: PaginationQueryParamsModel): Observable<ApiResponseModel<T[]>>;
639
- /**
640
- * Full unpaginated dump — {@link ResourceId} `'all'`.
641
- * IDE-friendly alias for `getResource(basePath, 'all')`.
642
- *
643
- * @typeParam T - Element type of the list.
644
- * @param basePath - Resource base path.
645
- */
646
- getResourceAll<T>(basePath: string): Observable<ApiResponseModel<T[]>>;
647
- /**
648
- * Single record — {@link ResourceId} number.
649
- * IDE-friendly alias for `getResource(basePath, id)`.
650
- *
651
- * @typeParam T - Record type.
652
- * @param basePath - Resource base path.
653
- * @param id - Numeric primary key.
654
- */
655
- getResourceById<T>(basePath: string, id: number): Observable<ApiResponseModel<T>>;
656
- /**
657
- * Clears the in-memory GET cache (e.g. on logout).
658
- */
659
- clearCache(): void;
660
- private buildHttpContext;
661
- private request;
662
- private unwrap;
663
- private resolveUrl;
664
- private buildHeaders;
665
- private buildParams;
666
- static ɵfac: i0.ɵɵFactoryDeclaration<ApiClient, never>;
667
- static ɵprov: i0.ɵɵInjectableDeclaration<ApiClient>;
668
- }
669
-
670
- /**
671
- * Resolve user-facing error copy from an API envelope, raw body, or HttpClient error.
672
- *
673
- * Prefers joined field messages when present; otherwise envelope / HTTP `message`.
674
- *
675
- * Prefer relying on {@link ApiClient}: HTTP failures are already rethrown as
676
- * `Error` with this text on `.message`. Hosts mainly need this helper when
677
- * calling Angular `HttpClient` directly (e.g. toast interceptor).
678
- *
679
- * @param input - Normalized response, raw JSON body, or {@link HttpErrorResponse}.
680
- */
681
- declare function formatApiErrorMessage(input: unknown): string;
682
-
683
- /**
684
- * Functional interceptor that sets `Authorization: Bearer <token>` when
685
- * {@link AuthTokenService} has an access token (from {@link AuthTokenService.set}).
686
- *
687
- * Compose via {@link provideAfricaniesHttpClient} (preferred) or pass explicitly to
688
- * `provideHttpClient(withInterceptors([...]))`.
689
- * @param req
690
- * @param next
691
- */
692
- declare const authInterceptor: HttpInterceptorFn;
693
-
694
- /**
695
- * Tiny in-memory TTL cache for {@link ApiClient} GET responses.
696
- *
697
- * Intentionally process-local and non-persistent: it exists to skip identical
698
- * GETs within a short window (e.g. rapid remounts), not to replace TanStack
699
- * Query or server cache headers.
700
- *
701
- * ## When NOT to use caching (`cacheTtlMs`)
702
- *
703
- * - Frequently changing data (dashboards, live rates, inventory) — stale reads
704
- * are worse than an extra round-trip.
705
- * - User-specific or permission-sensitive payloads — another user/session in
706
- * the same SPA tab could theoretically share the in-memory map.
707
- * - After mutations that invalidate list/detail views — this cache has no
708
- * tag-based invalidation; prefer TanStack Query for that.
709
- * - Large payloads — every entry stays in heap until TTL expiry.
710
- *
711
- * Prefer omitting `cacheTtlMs` unless you have a measured hot-spot and a
712
- * known staleness budget.
713
- */
714
- /**
715
- * Key/value store with per-entry TTL eviction on read.
716
- */
717
- declare class HttpResponseCache {
718
- private readonly store;
719
- /**
720
- * Returns a cached value when present and not expired.
721
- *
722
- * @param key - Stable request identity (method + URL + relevant params).
723
- * @returns The stored value, or `null` on miss / expiry.
724
- */
725
- get<T>(key: string): T | null;
726
- /**
727
- * Stores a value until `ttlMs` elapses.
728
- *
729
- * @param key - Stable request identity.
730
- * @param value - Value to reuse for subsequent hits.
731
- * @param ttlMs - Time-to-live in milliseconds from now.
732
- */
733
- set(key: string, value: unknown, ttlMs: number): void;
734
- /**
735
- * Drops every entry. Useful after logout or global invalidation hooks.
736
- */
737
- clear(): void;
738
- }
739
-
740
- /**
741
- * Shows success / error toasts for requests tagged with {@link withToast}.
742
- *
743
- * Requires {@link AFRICANIES_HTTP_TOAST} (from `provideAfricaniesToasts` in `@africanies/africanies-ui`).
744
- * Untagged requests never toast. Missing handler → silent no-op.
745
- * @param req - Outgoing HTTP request.
746
- * @param next - Next interceptor handler.
747
- * @returns Observable for the HTTP response stream.
748
- */
749
- declare const httpToastInterceptor: HttpInterceptorFn;
750
-
751
- /**
752
- * Deep-map arbitrary JSON into {@link ApiJsonValue} with no `undefined`.
753
- *
754
- * - `undefined` / unsupported types → `null`
755
- * - Arrays → every element mapped (never sparse/`undefined` slots)
756
- * - Objects → every own key mapped to {@link ApiJsonValue}
757
- *
758
- * @param raw - Wire value (may be missing or malformed).
759
- * @returns Null-safe JSON tree, or `null` when `raw` is nullish/unusable.
760
- */
761
- declare function mapApiJsonValue(raw: unknown): ApiJsonValue | null;
762
- /**
763
- * Map a wire list into a null-safe {@link ApiJsonValue} array.
764
- * Non-arrays become `[]`.
765
- * @param raw - Candidate list.
766
- * @returns Mapped array (never null/undefined).
767
- */
768
- declare function mapApiJsonList(raw: unknown): ApiJsonValue[];
769
-
770
- /**
771
- * Map pagination from snake_case (preferred), legacy camelCase, or Laravel keys.
772
- * @param value
773
- */
774
- declare function normalizePagination(value: unknown): PaginationMetaModel | null;
775
- /**
776
- * Flatten a Laravel paginator in `data` into list payload + {@link PaginationMetaModel}.
777
- * @param raw
778
- */
779
- declare function unwrapLaravelPaginator<T>(raw: unknown): {
780
- data: T[] | null;
781
- pagination: PaginationMetaModel | null;
782
- };
783
- /**
784
- * Normalize any HTTP JSON body into a fully null-safe {@link ApiResponseModel}.
785
- *
786
- * Envelope fields use snake_case where the wire does (`status_code`,
787
- * pagination keys). Paginated list reads often embed a Laravel paginator in
788
- * `data` (`data.data` + totals) — that shape is flattened here so consumers
789
- * always see `data: T[]` and `pagination`.
790
- *
791
- * Validation failures that return a Laravel field bag in `errors` or `data`
792
- * are lifted into `errors: ApiErrorDetailModel[]`. On failure, a bag in
793
- * `data` is cleared (`data: null`) so it is not typed as success payload `T`.
794
- * Top-level `message` is enriched to the joined field messages when a bag
795
- * exists (API `message` alone is often only the first field).
796
- * @param raw
797
- */
798
- declare function normalize<T>(raw: unknown): ApiResponseModel<T>;
799
-
800
- /**
801
- * Options for {@link provideAfricaniesHttpClient}.
802
- */
803
- interface AfricaniesHttpClientOptions {
804
- /**
805
- * Extra interceptors appended **after** the SDK defaults
806
- * (`shipmentModeInterceptor`, `authInterceptor`, `httpToastInterceptor`).
807
- */
808
- interceptors?: HttpInterceptorFn[];
809
- }
810
- /**
811
- * Registers `HttpClient` with AFRICANIES default interceptors baked in.
812
- *
813
- * Defaults (in order):
814
- * 1. {@link shipmentModeInterceptor} — `x-shipment-mode`
815
- * 2. {@link authInterceptor} — `Authorization` when {@link AuthTokenService} has a token
816
- * 3. {@link httpToastInterceptor} — toasts for requests tagged with {@link withToast}
817
- * (no-op until `provideAfricaniesToasts()` registers {@link AFRICANIES_HTTP_TOAST})
818
- * 4. Any {@link AfricaniesHttpClientOptions.interceptors} from the host
819
- *
820
- * @param options - Optional extra interceptors.
821
- * @param features - Extra `provideHttpClient` features (`withFetch`, etc.).
822
- * @returns Environment providers for `app.config.ts`.
823
- *
824
- * @example
825
- * ```ts
826
- * provideAfricaniesSdk({ baseUrl: 'https://api.example.com' }),
827
- * provideAfricaniesHttpClient(),
828
- * provideAfricaniesToasts(), // from @africanies/africanies-ui — enables HTTP toasts
829
- * ```
830
- */
831
- declare function provideAfricaniesHttpClient(options?: AfricaniesHttpClientOptions, ...features: HttpFeature<HttpFeatureKind>[]): EnvironmentProviders;
832
-
833
- /**
834
- * Optional query bag for {@link ResourceId} GETs.
835
- *
836
- * `page` / `size` / `order` apply only when `id` is `null` (paginated list).
837
- * Extra keys are always forwarded (filters, includes, etc.).
838
- *
839
- * App Settings list screens commonly send `search`, `from`, and `to` on the
840
- * paginated read — use this type directly; do not invent per-domain
841
- * `*ReadParams` aliases for the same bag.
842
- */
843
- type ResourceQueryParams = PaginationQueryParamsModel & Record<string, string | number | boolean | null | undefined>;
844
- /**
845
- * Build a path for the AFRICANIES list/detail `ResourceId` convention.
846
- *
847
- * | `id` | Path |
848
- * |------|------|
849
- * | `null` | `{basePath}` — paginated |
850
- * | `'all'` | `{basePath}/all` — full list |
851
- * | `number` | `{basePath}/{id}` — single record |
852
- *
853
- * @param basePath - Endpoint base (e.g. `/product/read`).
854
- * @param id - {@link ResourceId}; defaults to `null` (paginated).
855
- * @returns Absolute-or-relative path segment for {@link ApiClient.get}.
856
- *
857
- * @example
858
- * ```ts
859
- * buildResourcePath('/product/read') // '/product/read'
860
- * buildResourcePath('/product/read', 'all') // '/product/read/all'
861
- * buildResourcePath('/product/read', 42) // '/product/read/42'
862
- * ```
863
- */
864
- declare function buildResourcePath(basePath: string, id?: ResourceId): string;
865
- /**
866
- * Build query params for a {@link ResourceId} request.
867
- *
868
- * Pagination fields (`page`, `size`, `order`) are included only when
869
- * `id === null`. Other keys are always passed through.
870
- *
871
- * Paginated lists (`id === null`) always send `size`, defaulting to
872
- * {@link DEFAULT_PAGE_SIZE} (`15`) when omitted.
873
- *
874
- * @param id - Active resource id mode.
875
- * @param params - Optional pagination + filter bag.
876
- * @returns Params object for {@link ApiClient}, or `undefined` when empty.
877
- */
878
- declare function buildResourceQueryParams(id: ResourceId, params?: ResourceQueryParams): Record<string, string | number | boolean | null | undefined> | undefined;
879
- /**
880
- * In-memory GET cache TTL for reference reads.
881
- *
882
- * Paginated lists (`id === null`) are never cached — page contents change.
883
- * `'all'` and by-id may use a short TTL for stable catalogs.
884
- *
885
- * @param id - Active resource id mode.
886
- * @param ttlMs - Desired TTL for stable reads.
887
- * @returns TTL to pass to {@link ApiClient}, or `undefined` to skip cache.
888
- */
889
- declare function resourceCacheTtlMs(id: ResourceId, ttlMs: number): number | undefined;
890
- /**
891
- * Map wire `data` according to {@link ResourceId} shape.
892
- *
893
- * - `null` / `'all'` → list mapper → `T[]`
894
- * - `number` → one mapper → `T` (first element if the wire sent an array)
895
- *
896
- * @typeParam T - Domain model type.
897
- * @param id - Active resource id mode.
898
- * @param raw - Envelope `data` payload.
899
- * @param mapOne - Mapper for a single record.
900
- * @param mapMany - Mapper for a list (or single object coerced to list).
901
- * @returns Mapped payload, or `null` when by-id data is missing.
902
- * List reads (`null` / `'all'`) return `[]` when `raw` is nullish.
903
- */
904
- declare function mapResourcePayload<T>(id: ResourceId, raw: unknown, mapOne: (raw: unknown) => T, mapMany: (raw: unknown) => T[]): T | T[] | null;
905
-
906
- /**
907
- * Laravel-style validation bag: `{ field: ["msg", ...] }`.
908
- * @param value - Candidate JSON object.
909
- */
910
- declare function isLaravelValidationBag(value: unknown): boolean;
911
- /**
912
- * Flatten a validation bag into {@link ApiErrorDetailModel} rows.
913
- *
914
- * Uses messages in order; the first message per field is what
915
- * {@link fieldErrorsMap} exposes for form binding.
916
- * @param bag - Field → messages map.
917
- */
918
- declare function mapLaravelValidationBag(bag: Record<string, unknown>): ApiErrorDetailModel[];
919
- /**
920
- * Join field errors for toast / banner copy (one line per message, de-duped).
921
- * Prefer this over top-level `message` when a bag is present — the envelope
922
- * `message` is often only the first field.
923
- * @param errors - Normalized field errors.
924
- */
925
- declare function joinApiErrorMessages(errors: ApiErrorDetailModel[] | null | undefined): string | null;
926
- /**
927
- * First message per field for form control binding.
928
- * @param errors - Normalized field errors.
929
- */
930
- declare function fieldErrorsMap(errors: ApiErrorDetailModel[] | null | undefined): Record<string, string>;
931
-
932
- /**
933
- * Null-safe coercions for AFRICANIES wire JSON.
934
- *
935
- * Mappers should run every request/response field through these helpers so
936
- * missing keys, `null`, and wrong JSON types never throw at `.map` / `.trim`.
937
- */
938
- /**
939
- * Narrow unknown JSON into a plain object record.
940
- * @param value - Candidate value.
941
- * @returns Record when a non-array object; otherwise `null`.
942
- */
943
- declare function asRecord(value: unknown): Record<string, unknown> | null;
944
- /**
945
- * Coerce a value to an array. Non-arrays become `[]`.
946
- * @param value - Candidate list.
947
- */
948
- declare function asArray<T = unknown>(value: unknown): T[];
949
- /**
950
- * Map every element of a wire list. Non-arrays yield `[]`.
951
- * @param value - Candidate list.
952
- * @param mapOne - Per-item mapper.
953
- */
954
- declare function mapArray<T>(value: unknown, mapOne: (entry: unknown) => T): T[];
955
- /**
956
- * Map a list-or-single payload (Laravel sometimes sends one object).
957
- *
958
- * - `null` / `undefined` → `[]`
959
- * - paginator / `{ data | items }` → mapped inner rows
960
- * - array → mapped items
961
- * - anything else → one mapped item
962
- *
963
- * @param value - Envelope `data` (or a nested list field).
964
- * @param mapOne - Per-item mapper.
965
- */
966
- declare function mapList<T>(value: unknown, mapOne: (entry: unknown) => T): T[];
967
- /**
968
- * Finite number, or `fallback` when missing/invalid.
969
- * @param value - Raw numeric field.
970
- * @param fallback - Default when not a finite number.
971
- */
972
- declare function asNumber(value: unknown, fallback?: number): number;
973
- /**
974
- * Finite number, or `null` when missing/invalid.
975
- * @param value - Raw numeric field.
976
- */
977
- declare function asNullableNumber(value: unknown): number | null;
978
- /**
979
- * String, or `fallback` when the value cannot be stringified usefully.
980
- * @param value - Raw string field.
981
- * @param fallback - Default when nullish / non-scalar.
982
- */
983
- declare function asString(value: unknown, fallback?: string): string;
984
- /**
985
- * String or `null` (never `undefined`).
986
- * @param value - Raw string field.
987
- */
988
- declare function asNullableString(value: unknown): string | null;
989
- /**
990
- * Boolean from wire flags (`true` / `false` / `1` / `0` / `"true"` / `"1"`).
991
- * Missing values are `false`.
992
- * @param value - Raw flag.
993
- */
994
- declare function asBoolean(value: unknown): boolean;
995
- /**
996
- * Boolean or `null` when the field is absent / unparseable.
997
- * @param value - Raw flag.
998
- */
999
- declare function asNullableBoolean(value: unknown): boolean | null;
1000
- /**
1001
- * Wire `"1"` / `"0"` from a boolean, number, or string flag.
1002
- * @param value - Host or wire flag.
1003
- */
1004
- declare function toFlag01(value: unknown): '0' | '1';
1005
- /**
1006
- * User-model `0` / `1` flag, or `null` when absent.
1007
- * @param value - Raw flag.
1008
- */
1009
- declare function asNullableFlag01(value: unknown): 0 | 1 | null;
1010
-
1011
- /**
1012
- * Why a list screen is fetching.
1013
- *
1014
- * - `initial` — first paint (no rows yet).
1015
- * - `focus` — tab/window became visible again.
1016
- * - `refresh` — toolbar Refresh.
1017
- * - `page` — pager page or size change.
1018
- * - `mode` — {@link ShippingModeService} switched STN ↔ SFN.
1019
- */
1020
- type ListFetchReason = 'initial' | 'focus' | 'refresh' | 'page' | 'mode';
1021
- /**
1022
- * How to bind the list table while that fetch is in flight.
1023
- *
1024
- * - `loading` — body spinner. Use when there is no data, or the shipping
1025
- * mode changed (previous rows belong to the other mode — drop them).
1026
- * - `pagination` — keep rows; pager spinner.
1027
- * - `refreshing` — keep rows; refresh icon spins (focus / Refresh).
1028
- */
1029
- type ListFetchKind = 'loading' | 'pagination' | 'refreshing';
1030
- /**
1031
- * Pick blocking vs keep-rows fetch for a list table.
1032
- *
1033
- * Body loading only when there is no initial data or the shipping mode
1034
- * switched. Page/size keeps rows. Tab focus and Refresh keep rows.
1035
- *
1036
- * @param options
1037
- * @param options.hasData - Rows from the *current* mode are already on screen.
1038
- * @param options.reason - What triggered this fetch.
1039
- * @returns Kind to map onto `loading` / `pageLoading` / `refreshing`.
1040
- *
1041
- * @example
1042
- * ```ts
1043
- * const kind = listFetchKind({
1044
- * hasData: this.rows().length > 0,
1045
- * reason: 'mode',
1046
- * });
1047
- * this.isLoading.set(kind === 'loading');
1048
- * if (kind === 'loading') {
1049
- * this.rows.set([]);
1050
- * }
1051
- * ```
1052
- */
1053
- declare function listFetchKind(options: {
1054
- hasData: boolean;
1055
- reason: ListFetchReason;
1056
- }): ListFetchKind;
1057
-
1058
- /**
1059
- * Shared TanStack Query defaults for AFRICANIES consuming apps.
1060
- *
1061
- * `@tanstack/angular-query-experimental` is **not** a dependency of this SDK —
1062
- * query cache lifetime is app state. These helpers return a plain
1063
- * `defaultOptions` object you pass into your own `QueryClient`.
1064
- *
1065
- * Pin an **exact** `@tanstack/angular-query-experimental` version in the app
1066
- * (no caret/tilde): TanStack marks the Angular adapter experimental and
1067
- * breaking changes land without major bumps.
1068
- *
1069
- * Retry/backoff here mirrors {@link ApiClient}'s GET retry (max 3,
1070
- * exponential) so HTTP-layer and query-layer behavior stay aligned.
1071
- */
1072
- /**
1073
- * Shape compatible with TanStack `QueryClient` `defaultOptions` without
1074
- * importing `@tanstack/*` into the SDK.
1075
- */
1076
- interface AfricaniesQueryClientDefaults {
1077
- queries: {
1078
- /** Time before a successful query is considered stale (ms). */
1079
- staleTime: number;
1080
- /** Unused-query garbage-collection time (ms). */
1081
- gcTime: number;
1082
- /** Max failed-fetch retries for queries. */
1083
- retry: number;
1084
- /** Exponential delay matching ApiClient GET backoff. */
1085
- retryDelay: (attemptIndex: number) => number;
1086
- };
1087
- mutations: {
1088
- /** Mutations are not retried by default — side effects must stay explicit. */
1089
- retry: number;
1090
- };
1091
- }
1092
- /**
1093
- * Factory for TanStack `QueryClient` `defaultOptions`.
1094
- *
1095
- * @returns Plain defaults object — no Angular providers, no TanStack imports.
1096
- *
1097
- * @example
1098
- * ```ts
1099
- * // app.config.ts — pin exact experimental version in package.json
1100
- * import {
1101
- * provideAngularQuery,
1102
- * QueryClient,
1103
- * } from '@tanstack/angular-query-experimental';
1104
- * import { createAfricaniesQueryClientDefaults } from '@africanies/africanies-core';
1105
- *
1106
- * const queryClient = new QueryClient({
1107
- * defaultOptions: createAfricaniesQueryClientDefaults(),
1108
- * });
1109
- *
1110
- * export const appConfig = {
1111
- * providers: [provideAngularQuery(queryClient)],
1112
- * };
1113
- * ```
1114
- *
1115
- * @example
1116
- * ```ts
1117
- * // Map injectQuery() signals → AsyncQueryStateModel for <africanies-async-state>
1118
- * import type { AsyncQueryStateModel } from '@africanies/africanies-models';
1119
- * import { injectQuery } from '@tanstack/angular-query-experimental';
1120
- *
1121
- * const query = injectQuery(() => ({
1122
- * queryKey: ['shipments'],
1123
- * queryFn: () => firstValueFrom(api.getResource<Shipment>('shipments', null)),
1124
- * }));
1125
- *
1126
- * const state: AsyncQueryStateModel<Shipment[] | null> = {
1127
- * data: query.data()?.data ?? undefined,
1128
- * isLoading: query.isLoading(),
1129
- * isFetching: query.isFetching(),
1130
- * isError: query.isError(),
1131
- * error: query.error()?.message ?? null,
1132
- * };
1133
- * ```
1134
- */
1135
- declare function createAfricaniesQueryClientDefaults(): AfricaniesQueryClientDefaults;
1136
- /**
1137
- * Alias of {@link createAfricaniesQueryClientDefaults} for apps that prefer a
1138
- * `provide*` naming style beside {@link provideAfricaniesSdk}.
1139
- *
1140
- * Returns a plain object (not `EnvironmentProviders`) so it can be passed
1141
- * straight into `new QueryClient({ defaultOptions: ... })`.
1142
- *
1143
- * @returns Same object as {@link createAfricaniesQueryClientDefaults}.
1144
- *
1145
- * @example
1146
- * ```ts
1147
- * const queryClient = new QueryClient({
1148
- * defaultOptions: provideAfricaniesQueryDefaults(),
1149
- * });
1150
- * ```
1151
- */
1152
- declare function provideAfricaniesQueryDefaults(): AfricaniesQueryClientDefaults;
1153
-
1154
- /** Public mode-config endpoint path (relative to {@link AfricaniesSdkConfig.baseUrl}). */
1155
- declare const MODE_CONFIG_PATH = "/public/mode/config";
1156
- /**
1157
- * Deep-map mode config preserving snake_case region fields.
1158
- * @param raw
1159
- */
1160
- declare function mapModeConfigData(raw: ModeConfigDataModel | Record<string, unknown>): ModeConfigDataModel;
1161
- /**
1162
- * Resolve currency and measurement units for a country within a shipping mode.
1163
- * @param config
1164
- * @param mode
1165
- * @param countryCode
1166
- */
1167
- declare function resolveModeRegionConfig(config: ModeConfigDataModel | null | undefined, mode: ShippingMode, countryCode: string | null | undefined): ModeRegionConfigModel;
1168
-
1169
- /**
1170
- * Source of truth for region currency and measurement units (STN / SFN).
1171
- *
1172
- * On startup (via {@link provideModeConfig}), loads
1173
- * `GET /public/mode/config`, normalizes snake_case wire fields once, and
1174
- * persists the mapped record to storage. {@link getRegionConfig} reads that
1175
- * saved record and resolves by country code + active shipping mode.
1176
- *
1177
- * @example
1178
- * ```ts
1179
- * // app.config.ts
1180
- * providers: [
1181
- * provideAfricaniesSdk({ baseUrl: 'https://test-api-export.africaniestest.com/api' }),
1182
- * provideHttpClient(withInterceptors([shipmentModeInterceptor])),
1183
- * provideModeConfig(),
1184
- * ];
1185
- *
1186
- * // feature — format for shipment origin country
1187
- * const modeConfig = inject(ModeConfigService);
1188
- * const region = modeConfig.getRegionConfig('us');
1189
- * if (region) {
1190
- * console.log(region.currency_symbol, region.mass_unit);
1191
- * }
1192
- * ```
1193
- */
1194
- declare class ModeConfigService {
1195
- private readonly api;
1196
- private readonly storage;
1197
- private readonly shippingMode;
1198
- private readonly _config;
1199
- private readonly _loading;
1200
- /** Latest mode-config record (storage hydrate or last successful fetch). */
1201
- readonly config: Signal<ModeConfigDataModel | null>;
1202
- /** `true` while {@link loadConfig} is in flight. */
1203
- readonly loading: Signal<boolean>;
1204
- constructor();
1205
- /**
1206
- * Fetches mode config from the server, updates {@link config}, and persists.
1207
- *
1208
- * @returns Normalized API envelope; errors propagate to subscribers.
1209
- */
1210
- loadConfig(): Observable<ApiResponseModel<ModeConfigDataModel>>;
1211
- /**
1212
- * Region units and currency for a country code under the active (or given) mode.
1213
- *
1214
- * @param countryCode - e.g. `'ng'`, `'us'`, `'cn'` — unknown keys use `default`.
1215
- * @param appType - Defaults to {@link ShippingModeService.mode}.
1216
- * @returns Resolved region, or `null` before the first load/hydrate.
1217
- */
1218
- getRegionConfig(countryCode: string | null | undefined, appType?: ModeAppType): ModeRegionConfigModel | null;
1219
- /**
1220
- * Replace the in-memory record and persist — used after {@link loadConfig}.
1221
- * @param config
1222
- */
1223
- private saveRecord;
1224
- /** Restore the last saved server record so region lookups work offline. */
1225
- private hydrateFromStorage;
1226
- static ɵfac: i0.ɵɵFactoryDeclaration<ModeConfigService, never>;
1227
- static ɵprov: i0.ɵɵInjectableDeclaration<ModeConfigService>;
1228
- }
1229
-
1230
- /**
1231
- * Fetches `/public/mode/config` on app startup and hydrates {@link ModeConfigService}.
1232
- *
1233
- * Failures do not block bootstrap — cached storage (if any) remains usable.
1234
- * Pair with {@link provideAfricaniesSdk} and a real {@link AfricaniesSdkConfig.baseUrl}.
1235
- *
1236
- * @returns Environment providers that run the mode-config initializer.
1237
- */
1238
- declare function provideModeConfig(): EnvironmentProviders;
1239
-
1240
- /** Public country-read base path (relative to {@link AfricaniesSdkConfig.baseUrl}). */
1241
- declare const COUNTRY_READ_PATH = "/public/country/read";
1242
- /**
1243
- * Map a wire state object into {@link CountryStateModel} (snake_case preserved).
1244
- * @param raw - State object from the wire.
1245
- * @returns Normalized {@link CountryStateModel}.
1246
- */
1247
- declare function mapCountryState(raw: unknown): CountryStateModel;
1248
- /**
1249
- * Map a wire country object into {@link CountryModel} (snake_case preserved).
1250
- * @param raw - Country object from the wire.
1251
- * @returns Normalized {@link CountryModel}.
1252
- */
1253
- declare function mapCountry(raw: unknown): CountryModel;
1254
- /**
1255
- * Map a list (or single object) payload into {@link CountryModel}[].
1256
- *
1257
- * @param raw - `data` payload from `/public/country/read/{id|all}`.
1258
- * @returns Mapped country list (empty when `raw` is null/undefined).
1259
- */
1260
- declare function mapCountryList(raw: unknown): CountryModel[];
1261
-
1262
- /**
1263
- * Public country utility reads (`GET /public/country/read/{id?}`).
1264
- *
1265
- * Uses the AFRICANIES {@link ResourceId} convention:
1266
- * - `null` (default) → paginated page
1267
- * - `'all'` → full list
1268
- * - `number` → single {@link CountryModel}
1269
- *
1270
- * @example
1271
- * ```ts
1272
- * const countries = inject(CountryService);
1273
- *
1274
- * countries.read(null, { page: 1 }).subscribe((res) => {
1275
- * console.log(res.data, res.pagination);
1276
- * });
1277
- *
1278
- * countries.readAll().subscribe((res) => console.log(res.data?.length));
1279
- * countries.readById(1).subscribe((res) => console.log(res.data?.name));
1280
- * ```
1281
- */
1282
- declare class CountryService {
1283
- private readonly api;
1284
- /**
1285
- * Paginated country page — {@link ResourceId} `null`.
1286
- *
1287
- * @param id - Omit or pass `null` for a paginated list.
1288
- * @param params - Optional page/size/order and filters.
1289
- */
1290
- read(id?: null, params?: ResourceQueryParams): Observable<ApiResponseModel<CountryModel[]>>;
1291
- /**
1292
- * Full country list — {@link ResourceId} `'all'`.
1293
- *
1294
- * @param id - Must be `'all'`.
1295
- * @param params - Optional filters (pagination fields ignored).
1296
- */
1297
- read(id: 'all', params?: ResourceQueryParams): Observable<ApiResponseModel<CountryModel[]>>;
1298
- /**
1299
- * Single country — {@link ResourceId} number.
1300
- *
1301
- * @param id - Country id.
1302
- * @param params - Optional filters (pagination fields ignored).
1303
- */
1304
- read(id: number, params?: ResourceQueryParams): Observable<ApiResponseModel<CountryModel>>;
1305
- /**
1306
- * Paginated page — alias for {@link read}(`null`, params).
1307
- * @param params
1308
- */
1309
- readPage(params?: ResourceQueryParams): Observable<ApiResponseModel<CountryModel[]>>;
1310
- /**
1311
- * Full list — alias for {@link read}(`'all'`).
1312
- * @param params
1313
- */
1314
- readAll(params?: ResourceQueryParams): Observable<ApiResponseModel<CountryModel[]>>;
1315
- /**
1316
- * Single record — alias for {@link read}(id).
1317
- * @param id
1318
- * @param params
1319
- */
1320
- readById(id: number, params?: ResourceQueryParams): Observable<ApiResponseModel<CountryModel>>;
1321
- static ɵfac: i0.ɵɵFactoryDeclaration<CountryService, never>;
1322
- static ɵprov: i0.ɵɵInjectableDeclaration<CountryService>;
1323
- }
1324
-
1325
- /** Default CDN for ISO country flags ([flagcdn.com](https://flagcdn.com)). */
1326
- declare const COUNTRY_FLAG_CDN_BASE = "https://flagcdn.com";
1327
- /** Image format supported by the flag CDN. */
1328
- type CountryFlagFormat = 'png' | 'webp' | 'jpg' | 'svg';
1329
- /**
1330
- * Options for {@link countryFlagUrl}.
1331
- */
1332
- interface CountryFlagUrlOptions {
1333
- /** Pixel width (`w{width}` on flagcdn). Default `40`. */
1334
- width?: number;
1335
- /** Pixel height (`h{height}` on flagcdn). Used instead of {@link width} when set. */
1336
- height?: number;
1337
- /** Image format. Default `'png'`. */
1338
- format?: CountryFlagFormat;
1339
- }
1340
- /**
1341
- * Select row shape for country pickers (maps cleanly to {@link SelectOption.prefixImageUrl} in UI).
1342
- */
1343
- interface CountrySelectOption {
1344
- label: string;
1345
- value: number;
1346
- iso2: string;
1347
- prefixImageUrl: string;
1348
- }
1349
- /**
1350
- * Build a flagcdn.com URL from an ISO 3166-1 alpha-2 code.
1351
- *
1352
- * Examples:
1353
- * - `countryFlagUrl('NG')` → `https://flagcdn.com/w40/ng.png`
1354
- * - `countryFlagUrl('us', { width: 80, format: 'webp' })` → `https://flagcdn.com/w80/us.webp`
1355
- *
1356
- * @param iso2 - Two-letter country code (case-insensitive).
1357
- * @param options - Width, height, or format overrides.
1358
- * @returns CDN URL, or `''` when `iso2` is not two letters.
1359
- */
1360
- declare function countryFlagUrl(iso2: string, options?: CountryFlagUrlOptions): string;
1361
- /**
1362
- * Map {@link CountryModel} rows into select options with flag CDN URLs.
1363
- *
1364
- * @param countries - Countries from {@link CountryService.readAll} / `readPage`.
1365
- * @param options - Passed through to {@link countryFlagUrl}.
1366
- */
1367
- declare function mapCountrySelectOptions(countries: CountryModel[] | null | undefined, options?: CountryFlagUrlOptions): CountrySelectOption[];
1368
-
1369
- /** Public document read base path (relative to {@link AfricaniesSdkConfig.baseUrl}). */
1370
- declare const DOCUMENT_READ_PATH = "/public/document/read";
1371
- /**
1372
- * Map a wire document into {@link DocumentModel} (snake_case preserved).
1373
- * @param raw - Single document object from the API.
1374
- * @returns Normalized {@link DocumentModel}.
1375
- */
1376
- declare function mapDocument(raw: unknown): DocumentModel;
1377
- /**
1378
- * Map a list (or single object) payload into {@link DocumentModel}[].
1379
- * @param raw - `data` payload from `/public/document/read/{id|all}`.
1380
- * @returns Mapped document list.
1381
- */
1382
- declare function mapDocumentList(raw: unknown): DocumentModel[];
1383
-
1384
- /**
1385
- * Public document catalog reads (`GET /public/document/read/{id?}`).
1386
- *
1387
- * Uses the AFRICANIES {@link ResourceId} convention:
1388
- * - `null` (default) → paginated page
1389
- * - `'all'` → full list
1390
- * - `number` → single {@link DocumentModel} (may include preview `url` / `base_64`)
1391
- *
1392
- * @example
1393
- * ```ts
1394
- * const documents = inject(DocumentService);
1395
- *
1396
- * documents.readPage({ page: 1 }).subscribe((res) => {
1397
- * console.log(res.data, res.pagination);
1398
- * });
1399
- * documents.readById(12).subscribe((res) => {
1400
- * console.log(res.data?.url ?? res.data?.base_64);
1401
- * });
1402
- * ```
1403
- */
1404
- declare class DocumentService {
1405
- private readonly api;
1406
- /** Paginated document page — {@link ResourceId} `null`. */
1407
- read(id?: null, params?: ResourceQueryParams): Observable<ApiResponseModel<DocumentModel[]>>;
1408
- /** Full document list — {@link ResourceId} `'all'`. */
1409
- read(id: 'all', params?: ResourceQueryParams): Observable<ApiResponseModel<DocumentModel[]>>;
1410
- /** Single document — {@link ResourceId} number. */
1411
- read(id: number, params?: ResourceQueryParams): Observable<ApiResponseModel<DocumentModel>>;
1412
- /**
1413
- * Paginated page — alias for {@link read}(`null`, params).
1414
- * @param params
1415
- */
1416
- readPage(params?: ResourceQueryParams): Observable<ApiResponseModel<DocumentModel[]>>;
1417
- /**
1418
- * Full list — alias for {@link read}(`'all'`).
1419
- * @param params
1420
- */
1421
- readAll(params?: ResourceQueryParams): Observable<ApiResponseModel<DocumentModel[]>>;
1422
- /**
1423
- * Single record — alias for {@link read}(id).
1424
- * @param id
1425
- * @param params
1426
- */
1427
- readById(id: number, params?: ResourceQueryParams): Observable<ApiResponseModel<DocumentModel>>;
1428
- static ɵfac: i0.ɵɵFactoryDeclaration<DocumentService, never>;
1429
- static ɵprov: i0.ɵɵInjectableDeclaration<DocumentService>;
1430
- }
1431
-
1432
- /** Public plan read base path (relative to {@link AfricaniesSdkConfig.baseUrl}). */
1433
- declare const PLAN_READ_PATH = "/public/plan/read";
1434
- /**
1435
- * Map a wire plan package into {@link PlanPackageModel}.
1436
- * @param raw - Package object nested under a plan.
1437
- * @returns Normalized {@link PlanPackageModel}.
1438
- */
1439
- declare function mapPlanPackage(raw: unknown): PlanPackageModel;
1440
- /**
1441
- * Map a wire plan into {@link PlanModel} (snake_case preserved).
1442
- * @param raw - Single plan object from the API.
1443
- * @returns Normalized {@link PlanModel}.
1444
- */
1445
- declare function mapPlan(raw: unknown): PlanModel;
1446
- /**
1447
- * Map a list (or single object) payload into {@link PlanModel}[].
1448
- * @param raw - `data` payload from `/public/plan/read/{id|all}`.
1449
- * @returns Mapped plan list.
1450
- */
1451
- declare function mapPlanList(raw: unknown): PlanModel[];
1452
-
1453
- /**
1454
- * Public subscription-plan reads (`GET /public/plan/read/{id?}`).
1455
- *
1456
- * Uses the AFRICANIES {@link ResourceId} convention:
1457
- * - `null` (default) → paginated page
1458
- * - `'all'` → full list
1459
- * - `number` → single {@link PlanModel}
1460
- *
1461
- * @example
1462
- * ```ts
1463
- * const plans = inject(PlanService);
1464
- *
1465
- * plans.readPage({ page: 1, order: 'desc' }).subscribe((res) => {
1466
- * console.log(res.data, res.pagination);
1467
- * });
1468
- * plans.readById(1).subscribe((res) => {
1469
- * console.log(res.data?.packages?.length);
1470
- * });
1471
- * ```
1472
- */
1473
- declare class PlanService {
1474
- private readonly api;
1475
- /** Paginated plan page — {@link ResourceId} `null`. */
1476
- read(id?: null, params?: ResourceQueryParams): Observable<ApiResponseModel<PlanModel[]>>;
1477
- /** Full plan list — {@link ResourceId} `'all'`. */
1478
- read(id: 'all', params?: ResourceQueryParams): Observable<ApiResponseModel<PlanModel[]>>;
1479
- /** Single plan — {@link ResourceId} number. */
1480
- read(id: number, params?: ResourceQueryParams): Observable<ApiResponseModel<PlanModel>>;
1481
- /**
1482
- * Paginated page — alias for {@link read}(`null`, params).
1483
- * @param params
1484
- */
1485
- readPage(params?: ResourceQueryParams): Observable<ApiResponseModel<PlanModel[]>>;
1486
- /**
1487
- * Full list — alias for {@link read}(`'all'`).
1488
- * @param params
1489
- */
1490
- readAll(params?: ResourceQueryParams): Observable<ApiResponseModel<PlanModel[]>>;
1491
- /**
1492
- * Single record — alias for {@link read}(id).
1493
- * @param id
1494
- * @param params
1495
- */
1496
- readById(id: number, params?: ResourceQueryParams): Observable<ApiResponseModel<PlanModel>>;
1497
- static ɵfac: i0.ɵɵFactoryDeclaration<PlanService, never>;
1498
- static ɵprov: i0.ɵɵInjectableDeclaration<PlanService>;
1499
- }
1500
-
1501
- /** Public service read base path (relative to {@link AfricaniesSdkConfig.baseUrl}). */
1502
- declare const SERVICE_READ_PATH = "/public/service/read";
1503
- /**
1504
- * Map a wire service into {@link ServiceModel} (snake_case preserved).
1505
- * @param raw - Single service object from the API.
1506
- * @returns Normalized {@link ServiceModel}.
1507
- */
1508
- declare function mapService(raw: unknown): ServiceModel;
1509
- /**
1510
- * Map a list (or single object) payload into {@link ServiceModel}[].
1511
- * @param raw - `data` payload from `/public/service/read/{id|all}`.
1512
- * @returns Mapped service list.
1513
- */
1514
- declare function mapServiceList(raw: unknown): ServiceModel[];
1515
-
1516
- /**
1517
- * Public subscription-service reads (`GET /public/service/read/{id?}`).
1518
- *
1519
- * Uses the AFRICANIES {@link ResourceId} convention:
1520
- * - `null` (default) → paginated page
1521
- * - `'all'` → full list
1522
- * - `number` → single {@link ServiceModel}
1523
- *
1524
- * @example
1525
- * ```ts
1526
- * const services = inject(ServiceService);
1527
- *
1528
- * services.readPage({ page: 1, search: 'box' }).subscribe((res) => {
1529
- * console.log(res.data, res.pagination);
1530
- * });
1531
- * services.readAll().subscribe((res) => console.log(res.data?.length));
1532
- * services.readById(3).subscribe((res) => console.log(res.data?.name));
1533
- * ```
1534
- */
1535
- declare class ServiceService {
1536
- private readonly api;
1537
- /** Paginated service page — {@link ResourceId} `null`. */
1538
- read(id?: null, params?: ResourceQueryParams): Observable<ApiResponseModel<ServiceModel[]>>;
1539
- /** Full service list — {@link ResourceId} `'all'`. */
1540
- read(id: 'all', params?: ResourceQueryParams): Observable<ApiResponseModel<ServiceModel[]>>;
1541
- /** Single service — {@link ResourceId} number. */
1542
- read(id: number, params?: ResourceQueryParams): Observable<ApiResponseModel<ServiceModel>>;
1543
- /**
1544
- * Paginated page — alias for {@link read}(`null`, params).
1545
- * @param params
1546
- */
1547
- readPage(params?: ResourceQueryParams): Observable<ApiResponseModel<ServiceModel[]>>;
1548
- /**
1549
- * Full list — alias for {@link read}(`'all'`).
1550
- * @param params
1551
- */
1552
- readAll(params?: ResourceQueryParams): Observable<ApiResponseModel<ServiceModel[]>>;
1553
- /**
1554
- * Single record — alias for {@link read}(id).
1555
- * @param id
1556
- * @param params
1557
- */
1558
- readById(id: number, params?: ResourceQueryParams): Observable<ApiResponseModel<ServiceModel>>;
1559
- static ɵfac: i0.ɵɵFactoryDeclaration<ServiceService, never>;
1560
- static ɵprov: i0.ɵɵInjectableDeclaration<ServiceService>;
1561
- }
1562
-
1563
- /** Currency read base path (relative to {@link AfricaniesSdkConfig.baseUrl}). */
1564
- declare const CURRENCY_READ_PATH = "/currency/read";
1565
- /** Create path (App Settings → Currencies). */
1566
- declare const CURRENCY_CREATE_PATH = "/currency/create";
1567
- /** Update path — name / short_code are not sent. */
1568
- declare const CURRENCY_UPDATE_PATH = "/currency/update";
1569
- /** Delete path — JSON body `{ id }`. */
1570
- declare const CURRENCY_DELETE_PATH = "/currency/delete";
1571
- /**
1572
- * Serialize a boolean / `"1"` / `"0"` flag for currency create/update.
1573
- * @param value - Host boolean or wire flag.
1574
- * @returns `"1"` or `"0"`.
1575
- */
1576
- declare function toCurrencyFlag01(value: boolean | CurrencyFlag01 | number | null | undefined): CurrencyFlag01;
1577
- /**
1578
- * Map a currency ↔ payment-method pivot (snake_case preserved).
1579
- * @param raw - Pivot object from the wire.
1580
- * @returns Normalized {@link CurrencyPaymentMethodPivotModel}.
1581
- */
1582
- declare function mapCurrencyPaymentMethodPivot(raw: unknown): CurrencyPaymentMethodPivotModel;
1583
- /**
1584
- * Map a wire payment method into {@link CurrencyPaymentMethodModel}.
1585
- * @param raw - Payment-method object from the wire.
1586
- * @returns Normalized {@link CurrencyPaymentMethodModel}.
1587
- */
1588
- declare function mapCurrencyPaymentMethod(raw: unknown): CurrencyPaymentMethodModel;
1589
- /**
1590
- * Map a wire currency into {@link CurrencyModel} (snake_case preserved).
1591
- * @param raw - Currency object from the API.
1592
- * @returns Normalized {@link CurrencyModel}.
1593
- */
1594
- declare function mapCurrency(raw: unknown): CurrencyModel;
1595
- /**
1596
- * Map a list (or single object) payload into {@link CurrencyModel}[].
1597
- *
1598
- * @param raw - `data` payload from `/currency/read/{id|all}`.
1599
- * @returns Mapped currency list (empty when `raw` is null/undefined).
1600
- */
1601
- declare function mapCurrencyList(raw: unknown): CurrencyModel[];
1602
- /**
1603
- * Wire body for `POST /currency/create`.
1604
- * @param body - Host create payload.
1605
- * @returns JSON body with `"1"` / `"0"` flags.
1606
- */
1607
- declare function toCurrencyCreateBody(body: CurrencyCreateRequestModel | null | undefined): {
1608
- name: string;
1609
- short_code: string;
1610
- multiplication_rate: string;
1611
- division_rate: string;
1612
- active: CurrencyFlag01;
1613
- is_naira_greater: CurrencyFlag01;
1614
- payment_method_ids: number[];
1615
- };
1616
- /**
1617
- * Wire body for `PUT /currency/update` (no name / short_code).
1618
- * @param body - Host update payload.
1619
- * @returns JSON body with `"1"` / `"0"` flags.
1620
- */
1621
- declare function toCurrencyUpdateBody(body: CurrencyUpdateRequestModel | null | undefined): {
1622
- id: number;
1623
- multiplication_rate: string;
1624
- division_rate: string;
1625
- active: CurrencyFlag01;
1626
- is_naira_greater: CurrencyFlag01;
1627
- payment_method_ids: number[];
1628
- };
1629
- /**
1630
- * Wire body for `DELETE /currency/delete`.
1631
- * @param body - Currency id wrapper.
1632
- * @returns `{ id }`.
1633
- */
1634
- declare function toCurrencyDeleteBody(body: CurrencyDeleteRequestModel | number | null | undefined): {
1635
- id: number;
1636
- };
1637
-
1638
- /**
1639
- * Currency App Settings API (`GET /currency/read/{id?}` plus create / update / delete).
1640
- *
1641
- * Uses the AFRICANIES {@link ResourceId} convention for reads:
1642
- * - `null` (default) → paginated page
1643
- * - `'all'` → full list
1644
- * - `number` → single {@link CurrencyModel}
1645
- *
1646
- * Paginated responses embed a Laravel paginator in `data`; {@link ApiClient}
1647
- * flattens that to `data: CurrencyModel[]` plus `pagination`.
1648
- *
1649
- * Writes send `"1"` / `"0"` flags. Delete uses a JSON `{ id }` body (not query
1650
- * params). After each write, show `res.message` and call {@link readPage} again.
1651
- *
1652
- * @example
1653
- * ```ts
1654
- * const currencies = inject(CurrencyService);
1655
- *
1656
- * currencies.readPage({ page: 1, order: 'desc' }).subscribe((res) => {
1657
- * console.log(res.data, res.pagination);
1658
- * });
1659
- * currencies.readAll().subscribe((res) => console.log(res.data?.[0]?.short_code));
1660
- * currencies.readById(5).subscribe((res) => console.log(res.data?.name));
1661
- * ```
1662
- */
1663
- declare class CurrencyService {
1664
- private readonly api;
1665
- /** Paginated currency page — {@link ResourceId} `null`. */
1666
- read(id?: null, params?: ResourceQueryParams): Observable<ApiResponseModel<CurrencyModel[]>>;
1667
- /** Full currency list — {@link ResourceId} `'all'`. */
1668
- read(id: 'all', params?: ResourceQueryParams): Observable<ApiResponseModel<CurrencyModel[]>>;
1669
- /** Single currency — {@link ResourceId} number. */
1670
- read(id: number, params?: ResourceQueryParams): Observable<ApiResponseModel<CurrencyModel>>;
1671
- /**
1672
- * Paginated page — alias for {@link read}(`null`, params).
1673
- * @param params
1674
- */
1675
- readPage(params?: ResourceQueryParams): Observable<ApiResponseModel<CurrencyModel[]>>;
1676
- /**
1677
- * Full list — alias for {@link read}(`'all'`).
1678
- * @param params
1679
- */
1680
- readAll(params?: ResourceQueryParams): Observable<ApiResponseModel<CurrencyModel[]>>;
1681
- /**
1682
- * Single record — alias for {@link read}(id).
1683
- * @param id
1684
- * @param params
1685
- */
1686
- readById(id: number, params?: ResourceQueryParams): Observable<ApiResponseModel<CurrencyModel>>;
1687
- /**
1688
- * Create a currency (`POST /currency/create`).
1689
- *
1690
- * `name` / `short_code` come from the host’s local currency list, not GET.
1691
- * Flags may be boolean or `"1"` / `"0"`; they are serialized to `"1"` / `"0"`.
1692
- *
1693
- * @param body - Create payload.
1694
- * @returns Normalized envelope — use {@link ApiResponseModel.message}.
1695
- */
1696
- create(body: CurrencyCreateRequestModel): Observable<ApiResponseModel<unknown>>;
1697
- /**
1698
- * Update rates, flags, and payment methods (`PUT /currency/update`).
1699
- *
1700
- * Name and short code are not sent. Before edit, copy the row into the form
1701
- * (`true` / `false` may stay booleans — this method serializes flags).
1702
- *
1703
- * @param body - Update payload including `id`.
1704
- * @returns Normalized envelope — use {@link ApiResponseModel.message}.
1705
- */
1706
- update(body: CurrencyUpdateRequestModel): Observable<ApiResponseModel<unknown>>;
1707
- /**
1708
- * Delete a currency (`DELETE /currency/delete`) with JSON body `{ id }`.
1709
- *
1710
- * @param body - Currency id or `{ id }`.
1711
- * @returns Normalized envelope — use {@link ApiResponseModel.message}.
1712
- */
1713
- remove(body: CurrencyDeleteRequestModel | number): Observable<ApiResponseModel<unknown>>;
1714
- static ɵfac: i0.ɵɵFactoryDeclaration<CurrencyService, never>;
1715
- static ɵprov: i0.ɵɵInjectableDeclaration<CurrencyService>;
1716
- }
1717
-
1718
- /** Payment-method read base path (relative to {@link AfricaniesSdkConfig.baseUrl}). */
1719
- declare const PAYMENT_METHOD_READ_PATH = "/payment_method/read";
1720
- /** Payment-method update path (`PUT`). */
1721
- declare const PAYMENT_METHOD_UPDATE_PATH = "/payment_method/update";
1722
- /**
1723
- * Serialize a boolean / `"1"` / `"0"` flag for payment-method update.
1724
- * @param value - Host boolean or wire flag.
1725
- * @returns `"1"` or `"0"`.
1726
- */
1727
- declare function toPaymentMethodFlag01(value: boolean | PaymentMethodFlag01 | number | null | undefined): PaymentMethodFlag01;
1728
- /**
1729
- * Build the wire body for `PUT /payment_method/update`.
1730
- *
1731
- * @param body - Host update payload (`active` may be boolean).
1732
- * @returns Body with `active` as `"1"` / `"0"`.
1733
- */
1734
- declare function toPaymentMethodUpdateBody(body: PaymentMethodUpdateRequestModel): {
1735
- id: number;
1736
- name: string;
1737
- model: string;
1738
- active: PaymentMethodFlag01;
1739
- };
1740
- /**
1741
- * Map a currency nested on a payment method (rates + pivot, no processors).
1742
- * @param raw - Currency object from `currencies[]`.
1743
- * @returns Normalized {@link PaymentMethodCurrencyModel}.
1744
- */
1745
- declare function mapPaymentMethodCurrency(raw: unknown): PaymentMethodCurrencyModel;
1746
- /**
1747
- * Map a wire payment method into {@link PaymentMethodModel}.
1748
- * @param raw - Payment-method object from the API.
1749
- * @returns Normalized {@link PaymentMethodModel}.
1750
- */
1751
- declare function mapPaymentMethod(raw: unknown): PaymentMethodModel;
1752
- /**
1753
- * Map a list (or single object) payload into {@link PaymentMethodModel}[].
1754
- *
1755
- * @param raw - `data` payload from `/payment_method/read/{id|all}`.
1756
- * @returns Mapped payment-method list (empty when `raw` is null/undefined).
1757
- */
1758
- declare function mapPaymentMethodList(raw: unknown): PaymentMethodModel[];
1759
-
1760
- /**
1761
- * Payment-method App Settings API (`GET /payment_method/read/{id?}` plus update).
1762
- *
1763
- * Uses the AFRICANIES {@link ResourceId} convention for reads:
1764
- * - `null` (default) → paginated page
1765
- * - `'all'` → full list
1766
- * - `number` → single {@link PaymentMethodModel}
1767
- *
1768
- * Paginated responses embed a Laravel paginator in `data`; {@link ApiClient}
1769
- * flattens that to `data: PaymentMethodModel[]` plus `pagination`.
1770
- *
1771
- * The only write is {@link update} (active toggle). There is no create or
1772
- * delete on this board — processors are linked from Currencies via
1773
- * `payment_method_ids`. After update, show `res.message` and patch the row’s
1774
- * local `updated_at` — do not reload the full list.
1775
- *
1776
- * @example
1777
- * ```ts
1778
- * const methods = inject(PaymentMethodService);
1779
- *
1780
- * methods.readPage({ page: 1, order: 'desc' }).subscribe((res) => {
1781
- * console.log(res.data, res.pagination);
1782
- * });
1783
- * methods.readAll().subscribe((res) => console.log(res.data?.[0]?.name));
1784
- * methods.readById(4).subscribe((res) => console.log(res.data?.currencies));
1785
- *
1786
- * methods.update({
1787
- * id: row.id,
1788
- * name: row.name,
1789
- * model: row.model,
1790
- * active: nextActive,
1791
- * }).subscribe((res) => {
1792
- * // toast res.message; patch row.updated_at locally
1793
- * });
1794
- * ```
1795
- */
1796
- declare class PaymentMethodService {
1797
- private readonly api;
1798
- /** Paginated payment-method page — {@link ResourceId} `null`. */
1799
- read(id?: null, params?: ResourceQueryParams): Observable<ApiResponseModel<PaymentMethodModel[]>>;
1800
- /** Full payment-method list — {@link ResourceId} `'all'`. */
1801
- read(id: 'all', params?: ResourceQueryParams): Observable<ApiResponseModel<PaymentMethodModel[]>>;
1802
- /** Single payment method — {@link ResourceId} number. */
1803
- read(id: number, params?: ResourceQueryParams): Observable<ApiResponseModel<PaymentMethodModel>>;
1804
- /**
1805
- * Paginated page — alias for {@link read}(`null`, params).
1806
- * @param params
1807
- */
1808
- readPage(params?: ResourceQueryParams): Observable<ApiResponseModel<PaymentMethodModel[]>>;
1809
- /**
1810
- * Full list — alias for {@link read}(`'all'`).
1811
- * @param params
1812
- */
1813
- readAll(params?: ResourceQueryParams): Observable<ApiResponseModel<PaymentMethodModel[]>>;
1814
- /**
1815
- * Single record — alias for {@link read}(id).
1816
- * @param id
1817
- * @param params
1818
- */
1819
- readById(id: number, params?: ResourceQueryParams): Observable<ApiResponseModel<PaymentMethodModel>>;
1820
- /**
1821
- * Toggle / update a payment method (`PUT /payment_method/update`).
1822
- *
1823
- * App Settings only edits `active` (status switch). Resend `name` and
1824
- * `model` from the current row. `active` may be boolean or `"1"` / `"0"`;
1825
- * this method serializes to `"1"` / `"0"`.
1826
- *
1827
- * On success: show {@link ApiResponseModel.message}, patch that row’s
1828
- * local `updated_at`, and do **not** call {@link readPage} again.
1829
- *
1830
- * @param body - Update payload including `id`.
1831
- * @returns Normalized envelope — use {@link ApiResponseModel.message}.
1832
- */
1833
- update(body: PaymentMethodUpdateRequestModel): Observable<ApiResponseModel<unknown>>;
1834
- static ɵfac: i0.ɵɵFactoryDeclaration<PaymentMethodService, never>;
1835
- static ɵprov: i0.ɵɵInjectableDeclaration<PaymentMethodService>;
1836
- }
1837
-
1838
- /** Shipment-method read base path (relative to {@link AfricaniesSdkConfig.baseUrl}). */
1839
- declare const SHIPMENT_METHOD_READ_PATH = "/shipment_method/read";
1840
- /**
1841
- * Map a nested zone object into {@link ShipmentZoneModel}.
1842
- * @param raw
1843
- */
1844
- declare function mapShipmentZone(raw: unknown): ShipmentZoneModel | null;
1845
- /**
1846
- * Map a method↔zone link into {@link ShipmentMethodZoneLinkModel}.
1847
- * @param raw
1848
- */
1849
- declare function mapShipmentMethodZoneLink(raw: unknown): ShipmentMethodZoneLinkModel;
1850
- /**
1851
- * Map a Laravel-style `zone_values` page into {@link ShipmentMethodZonePageModel}.
1852
- * @param raw
1853
- */
1854
- declare function mapShipmentMethodZonePage(raw: unknown): ShipmentMethodZonePageModel;
1855
- /**
1856
- * Map a wire shipment method into {@link ShipmentMethodModel} (snake_case).
1857
- * @param raw
1858
- */
1859
- declare function mapShipmentMethod(raw: unknown): ShipmentMethodModel;
1860
- /**
1861
- * Map a list (or single object) payload into {@link ShipmentMethodModel}[].
1862
- * @param raw
1863
- */
1864
- declare function mapShipmentMethodList(raw: unknown): ShipmentMethodModel[];
1865
-
1866
- /**
1867
- * Shipment method / carrier utility reads (`GET /shipment_method/read/{id?}`).
1868
- *
1869
- * Uses the AFRICANIES {@link ResourceId} convention:
1870
- * - `null` (default) → paginated page
1871
- * - `'all'` → full list
1872
- * - `number` → single {@link ShipmentMethodModel}
1873
- *
1874
- * @example
1875
- * ```ts
1876
- * const methods = inject(ShipmentMethodService);
1877
- *
1878
- * methods.readPage({ page: 1 }).subscribe((res) => {
1879
- * console.log(res.data, res.pagination);
1880
- * });
1881
- * methods.readAll().subscribe((res) => console.log(res.data?.[0]?.name));
1882
- * methods.readById(12).subscribe((res) => console.log(res.data?.name));
1883
- * ```
1884
- */
1885
- declare class ShipmentMethodService {
1886
- private readonly api;
1887
- /** Paginated method page — {@link ResourceId} `null`. */
1888
- read(id?: null, params?: ResourceQueryParams): Observable<ApiResponseModel<ShipmentMethodModel[]>>;
1889
- /** Full method list — {@link ResourceId} `'all'`. */
1890
- read(id: 'all', params?: ResourceQueryParams): Observable<ApiResponseModel<ShipmentMethodModel[]>>;
1891
- /** Single method — {@link ResourceId} number. */
1892
- read(id: number, params?: ResourceQueryParams): Observable<ApiResponseModel<ShipmentMethodModel>>;
1893
- /**
1894
- * Paginated page — alias for {@link read}(`null`, params).
1895
- * @param params
1896
- */
1897
- readPage(params?: ResourceQueryParams): Observable<ApiResponseModel<ShipmentMethodModel[]>>;
1898
- /**
1899
- * Full list — alias for {@link read}(`'all'`).
1900
- * @param params
1901
- */
1902
- readAll(params?: ResourceQueryParams): Observable<ApiResponseModel<ShipmentMethodModel[]>>;
1903
- /**
1904
- * Single record — alias for {@link read}(id).
1905
- * @param id
1906
- * @param params
1907
- */
1908
- readById(id: number, params?: ResourceQueryParams): Observable<ApiResponseModel<ShipmentMethodModel>>;
1909
- static ɵfac: i0.ɵɵFactoryDeclaration<ShipmentMethodService, never>;
1910
- static ɵprov: i0.ɵɵInjectableDeclaration<ShipmentMethodService>;
1911
- }
1912
-
1913
- /** Warehouse read base path (relative to {@link AfricaniesSdkConfig.baseUrl}). */
1914
- declare const WAREHOUSE_READ_PATH = "/warehouse/read";
1915
- /**
1916
- * Map warehouse state into {@link WarehouseStateModel} (snake_case).
1917
- * @param raw
1918
- */
1919
- declare function mapWarehouseState(raw: unknown): WarehouseStateModel | null;
1920
- /**
1921
- * Map nested country (same shape as public country utility).
1922
- * @param raw
1923
- */
1924
- declare function mapWarehouseCountry(raw: unknown): CountryModel | null;
1925
- /**
1926
- * Map a wire warehouse into {@link WarehouseModel} (snake_case preserved).
1927
- * @param raw
1928
- */
1929
- declare function mapWarehouse(raw: unknown): WarehouseModel;
1930
- /**
1931
- * Map a list (or single object) payload into {@link WarehouseModel}[].
1932
- * @param raw
1933
- */
1934
- declare function mapWarehouseList(raw: unknown): WarehouseModel[];
1935
-
1936
- /**
1937
- * Warehouse utility reads (`GET /warehouse/read/{id?}`).
1938
- *
1939
- * Uses the AFRICANIES {@link ResourceId} convention:
1940
- * - `null` (default) → paginated page
1941
- * - `'all'` → full list
1942
- * - `number` → single {@link WarehouseModel}
1943
- *
1944
- * @example
1945
- * ```ts
1946
- * const warehouses = inject(WarehouseService);
1947
- *
1948
- * warehouses.readPage({ page: 1 }).subscribe((res) => {
1949
- * console.log(res.data, res.pagination);
1950
- * });
1951
- * warehouses.readAll().subscribe((res) => console.log(res.data?.length));
1952
- * warehouses.readById(37).subscribe((res) => console.log(res.data?.name));
1953
- * ```
1954
- */
1955
- declare class WarehouseService {
1956
- private readonly api;
1957
- /** Paginated warehouse page — {@link ResourceId} `null`. */
1958
- read(id?: null, params?: ResourceQueryParams): Observable<ApiResponseModel<WarehouseModel[]>>;
1959
- /** Full warehouse list — {@link ResourceId} `'all'`. */
1960
- read(id: 'all', params?: ResourceQueryParams): Observable<ApiResponseModel<WarehouseModel[]>>;
1961
- /** Single warehouse — {@link ResourceId} number. */
1962
- read(id: number, params?: ResourceQueryParams): Observable<ApiResponseModel<WarehouseModel>>;
1963
- /**
1964
- * Paginated page — alias for {@link read}(`null`, params).
1965
- * @param params
1966
- */
1967
- readPage(params?: ResourceQueryParams): Observable<ApiResponseModel<WarehouseModel[]>>;
1968
- /**
1969
- * Full list — alias for {@link read}(`'all'`).
1970
- * @param params
1971
- */
1972
- readAll(params?: ResourceQueryParams): Observable<ApiResponseModel<WarehouseModel[]>>;
1973
- /**
1974
- * Single record — alias for {@link read}(id).
1975
- * @param id
1976
- * @param params
1977
- */
1978
- readById(id: number, params?: ResourceQueryParams): Observable<ApiResponseModel<WarehouseModel>>;
1979
- static ɵfac: i0.ɵɵFactoryDeclaration<WarehouseService, never>;
1980
- static ɵprov: i0.ɵɵInjectableDeclaration<WarehouseService>;
1981
- }
1982
-
1983
- /** Zone read base path (relative to {@link AfricaniesSdkConfig.baseUrl}). */
1984
- declare const ZONE_READ_PATH = "/zone/read/records";
1985
- /**
1986
- * Map a wire zone into {@link ZoneModel} (snake_case preserved).
1987
- * @param raw
1988
- */
1989
- declare function mapZone(raw: unknown): ZoneModel;
1990
- /**
1991
- * Map a list (or single object) payload into {@link ZoneModel}[].
1992
- * @param raw
1993
- */
1994
- declare function mapZoneList(raw: unknown): ZoneModel[];
1995
-
1996
- /**
1997
- * Zone utility reads (`GET /zone/read/records/{id?}`).
1998
- *
1999
- * Uses the AFRICANIES {@link ResourceId} convention:
2000
- * - `null` (default) → paginated page
2001
- * - `'all'` → full list
2002
- * - `number` → single {@link ZoneModel}
2003
- *
2004
- * @example
2005
- * ```ts
2006
- * const zones = inject(ZoneService);
2007
- *
2008
- * zones.readPage({ page: 1 }).subscribe((res) => {
2009
- * console.log(res.data, res.pagination);
2010
- * });
2011
- * zones.readAll().subscribe((res) => console.log(res.data?.length));
2012
- * zones.readById(1).subscribe((res) => console.log(res.data?.name));
2013
- * ```
2014
- */
2015
- declare class ZoneService {
2016
- private readonly api;
2017
- /** Paginated zone page — {@link ResourceId} `null`. */
2018
- read(id?: null, params?: ResourceQueryParams): Observable<ApiResponseModel<ZoneModel[]>>;
2019
- /** Full zone list — {@link ResourceId} `'all'`. */
2020
- read(id: 'all', params?: ResourceQueryParams): Observable<ApiResponseModel<ZoneModel[]>>;
2021
- /** Single zone — {@link ResourceId} number. */
2022
- read(id: number, params?: ResourceQueryParams): Observable<ApiResponseModel<ZoneModel>>;
2023
- /**
2024
- * Paginated page — alias for {@link read}(`null`, params).
2025
- * @param params
2026
- */
2027
- readPage(params?: ResourceQueryParams): Observable<ApiResponseModel<ZoneModel[]>>;
2028
- /**
2029
- * Full list — alias for {@link read}(`'all'`).
2030
- * @param params
2031
- */
2032
- readAll(params?: ResourceQueryParams): Observable<ApiResponseModel<ZoneModel[]>>;
2033
- /**
2034
- * Single record — alias for {@link read}(id).
2035
- * @param id
2036
- * @param params
2037
- */
2038
- readById(id: number, params?: ResourceQueryParams): Observable<ApiResponseModel<ZoneModel>>;
2039
- static ɵfac: i0.ɵɵFactoryDeclaration<ZoneService, never>;
2040
- static ɵprov: i0.ɵɵInjectableDeclaration<ZoneService>;
2041
- }
2042
-
2043
- /** Current-user path (relative to {@link AfricaniesSdkConfig.baseUrl}). */
2044
- declare const USER_PATH = "/user";
2045
- /** Change-password path after a default-password first login. */
2046
- declare const USER_CHANGE_PASSWORD_PATH = "/user/change/password";
2047
- /** Invalidate every session for the signed-in user. */
2048
- declare const USER_LOGOUT_FROM_ALL_SESSIONS_PATH = "/user/logout-from-all-sessions";
2049
- /**
2050
- * Map a state row under country.states.
2051
- * @param raw - State object from the wire.
2052
- * @returns {@link UserStateModel}, or `null`.
2053
- */
2054
- declare function mapUserCountryState(raw: unknown): UserStateModel | null;
2055
- /**
2056
- * Map nested country on the user profile.
2057
- * @param raw - Country object from the wire.
2058
- * @returns {@link UserCountryModel}, or `null`.
2059
- */
2060
- declare function mapUserCountry(raw: unknown): UserCountryModel | null;
2061
- /**
2062
- * Normalize `state` when the API returns a string (or an object with `name`).
2063
- * @param raw - Wire `state` field.
2064
- * @returns String label, or `null`.
2065
- */
2066
- declare function mapUserStateLabel(raw: unknown): string | null;
2067
- /**
2068
- * @param raw - Plan package object.
2069
- * @returns {@link UserPlanPackageModel}, or `null`.
2070
- */
2071
- declare function mapUserPlanPackage(raw: unknown): UserPlanPackageModel | null;
2072
- /**
2073
- * @param raw - Plan object.
2074
- * @returns {@link UserPlanModel}, or `null`.
2075
- */
2076
- declare function mapUserPlan(raw: unknown): UserPlanModel | null;
2077
- /**
2078
- * @param raw - Gateway payload object.
2079
- * @returns {@link UserGatewayPayloadModel}, or `null`.
2080
- */
2081
- declare function mapUserGatewayPayload(raw: unknown): UserGatewayPayloadModel | null;
2082
- /**
2083
- * @param raw - Payment payload object (already parsed).
2084
- * @returns {@link UserPaymentPayloadModel}, or `null`.
2085
- */
2086
- declare function mapUserPaymentPayload(raw: unknown): UserPaymentPayloadModel | null;
2087
- /**
2088
- * @param raw - Subscription object.
2089
- * @returns {@link UserSubscriptionModel}, or `null`.
2090
- */
2091
- declare function mapUserSubscription(raw: unknown): UserSubscriptionModel | null;
2092
- /**
2093
- * @param raw - Business account object.
2094
- * @returns {@link UserBusinessAccountModel}, or `null`.
2095
- */
2096
- declare function mapUserBusinessAccount(raw: unknown): UserBusinessAccountModel | null;
2097
- /**
2098
- * @param raw - Account manager object.
2099
- * @returns {@link UserAccountManagerModel}, or `null`.
2100
- */
2101
- declare function mapUserAccountManager(raw: unknown): UserAccountManagerModel | null;
2102
- /**
2103
- * Map a bare wire user object into {@link UserModel} (snake_case preserved).
2104
- * @param raw - User object from `GET /user` (unwrapped).
2105
- * @returns Normalized {@link UserModel}.
2106
- */
2107
- declare function mapUser(raw: unknown): UserModel;
2108
-
2109
- /**
2110
- * Current authenticated user (`GET /user`).
2111
- *
2112
- * The backend returns a **bare** user object (no `{ success, data }` wrapper).
2113
- * {@link ApiClient} normalizes that into {@link ApiResponseModel}; this service
2114
- * maps wire fields once into {@link UserModel} (snake_case preserved).
2115
- *
2116
- * Requires an access token via {@link AuthTokenService.set}. Not cached — profile
2117
- * data is auth-sensitive and can change per session.
2118
- *
2119
- * After login, if `user.default_password` is set, send the user to
2120
- * `/onboarding/reset-password` and call {@link changePassword} (current → new).
2121
- * That page is **not** the email-link forgot-password flow.
2122
- *
2123
- * On logout, call {@link logoutFromAllSessions} while the bearer token is still
2124
- * set, then {@link AuthTokenService.clear}.
2125
- *
2126
- * @example
2127
- * ```ts
2128
- * const users = inject(UserService);
2129
- *
2130
- * users.me().subscribe((res) => {
2131
- * if (res.success) console.log(res.data?.email);
2132
- * });
2133
- * ```
2134
- */
2135
- declare class UserService {
2136
- private readonly api;
2137
- /**
2138
- * Fetch the current user.
2139
- *
2140
- * @returns Normalized envelope with mapped {@link UserModel} (or `null` data).
2141
- */
2142
- me(): Observable<ApiResponseModel<UserModel>>;
2143
- /**
2144
- * Change the signed-in user’s password (`POST /user/change/password`).
2145
- *
2146
- * Used on first login when {@link UserModel.default_password} is true —
2147
- * not the email-only {@link AuthService.forgot} flow.
2148
- *
2149
- * @param body - Current password plus new password and confirmation.
2150
- * @returns Normalized envelope (`data` is typically unused).
2151
- */
2152
- changePassword(body: ChangePasswordRequestModel): Observable<ApiResponseModel<unknown>>;
2153
- /**
2154
- * Sign out of this device and every other session
2155
- * (`POST /user/logout-from-all-sessions`).
2156
- *
2157
- * Call while the bearer token is still set so the interceptor can attach
2158
- * `Authorization`. Then {@link AuthTokenService.clear} locally.
2159
- *
2160
- * @returns Normalized envelope (`data` is typically unused).
2161
- */
2162
- logoutFromAllSessions(): Observable<ApiResponseModel<unknown>>;
2163
- static ɵfac: i0.ɵɵFactoryDeclaration<UserService, never>;
2164
- static ɵprov: i0.ɵɵInjectableDeclaration<UserService>;
2165
- }
2166
-
2167
- /** User notifications read base path (relative to {@link AfricaniesSdkConfig.baseUrl}). */
2168
- declare const NOTIFICATION_READ_PATH = "/user/notifications/read";
2169
- /** Mark read endpoint (single `{ id }` or `{}` for all). */
2170
- declare const NOTIFICATION_UPDATE_PATH = "/user/notifications/update";
2171
- /**
2172
- * Parse the Laravel `data` column (JSON string or object) into
2173
- * {@link NotificationPayloadModel}.
2174
- * @param raw
2175
- */
2176
- declare function mapNotificationPayload(raw: unknown): NotificationPayloadModel;
2177
- /**
2178
- * Map a wire notification row into {@link NotificationModel}.
2179
- * @param raw
2180
- */
2181
- declare function mapNotification(raw: unknown): NotificationModel;
2182
- /**
2183
- * Map wire list payloads into {@link NotificationModel}[].
2184
- * @param raw
2185
- */
2186
- declare function mapNotificationList(raw: unknown): NotificationModel[];
2187
- /**
2188
- * Derive a header/drawer inbox item from a mapped notification.
2189
- * @param notification
2190
- */
2191
- declare function mapNotificationInboxItem(notification: NotificationModel | null | undefined): NotificationInboxItemModel;
2192
-
2193
- /**
2194
- * Authenticated user notifications (`GET /user/notifications/read/{id?}`).
2195
- *
2196
- * Uses the AFRICANIES {@link ResourceId} convention for paginated / full-list reads.
2197
- * Notification primary keys are UUID strings — use {@link readOne} for a single row.
2198
- *
2199
- * Requires an access token via {@link AuthTokenService.set}. Not cached — inbox
2200
- * data is auth-sensitive and changes frequently.
2201
- *
2202
- * @example
2203
- * ```ts
2204
- * const notifications = inject(NotificationService);
2205
- *
2206
- * notifications.readAll().subscribe((res) => {
2207
- * console.log(res.data?.length);
2208
- * });
2209
- * ```
2210
- */
2211
- declare class NotificationService {
2212
- private readonly api;
2213
- /** Paginated inbox page — {@link ResourceId} `null`. */
2214
- read(id?: null, params?: ResourceQueryParams): Observable<ApiResponseModel<NotificationModel[]>>;
2215
- /** Full inbox list — {@link ResourceId} `'all'`. */
2216
- read(id: 'all', params?: ResourceQueryParams): Observable<ApiResponseModel<NotificationModel[]>>;
2217
- /**
2218
- * Paginated page — alias for {@link read}(`null`, params).
2219
- * Size defaults to {@link NOTIFICATION_PAGE_SIZE} (`30`).
2220
- * @param params
2221
- */
2222
- readPage(params?: ResourceQueryParams): Observable<ApiResponseModel<NotificationModel[]>>;
2223
- /**
2224
- * Full list — alias for {@link read}(`'all'`).
2225
- * @param params
2226
- */
2227
- readAll(params?: ResourceQueryParams): Observable<ApiResponseModel<NotificationModel[]>>;
2228
- /**
2229
- * Single notification by UUID (`GET /user/notifications/read/{uuid}`).
2230
- * @param id
2231
- */
2232
- readOne(id: string): Observable<ApiResponseModel<NotificationModel>>;
2233
- /**
2234
- * Mark one or all notifications read (`PUT /user/notifications/update`).
2235
- *
2236
- * @param id - When set, marks that notification read; omit to mark all read.
2237
- */
2238
- markRead(id?: string): Observable<ApiResponseModel<unknown>>;
2239
- static ɵfac: i0.ɵɵFactoryDeclaration<NotificationService, never>;
2240
- static ɵprov: i0.ɵɵInjectableDeclaration<NotificationService>;
2241
- }
2242
-
2243
- /**
2244
- * Rewrite a notification portal URL for the active {@link ShippingMode}.
2245
- *
2246
- * Swaps `-export` / `-import` host segments and sets `shipment_app` to
2247
- * `shipfromnaija` (SFN) or `shiptonaija` (STN).
2248
- * @param link
2249
- * @param mode
2250
- */
2251
- declare function resolveNotificationLinkForMode(link: string | null | undefined, mode: ShippingMode): string;
2252
-
2253
- /** File read path (relative to {@link AfricaniesSdkConfig.baseUrl}). */
2254
- declare const FILE_READ_PATH = "/file/read";
2255
- /** Query flag for multi-file waybill reads (`POST /file/read?multiple=yes`). */
2256
- declare const FILE_READ_MULTIPLE_PARAM = "yes";
2257
- /**
2258
- * Map wire `data` into {@link FileReadModel} (snake_case preserved).
2259
- *
2260
- * `POST /file/read` returns a single object in `data` (not a list).
2261
- * If the wire unexpectedly sends a one-element array, the first entry is used.
2262
- *
2263
- * @param raw - Envelope `data` from `POST /file/read`.
2264
- * @returns Normalized {@link FileReadModel}.
2265
- */
2266
- declare function mapFileRead(raw: unknown): FileReadModel;
2267
- /**
2268
- * Map a list (or single object) payload into {@link FileReadModel}[].
2269
- *
2270
- * Used for `POST /file/read?multiple=yes` (e-commerce waybills).
2271
- *
2272
- * @param raw - Envelope `data` from multi-file reads.
2273
- * @returns Mapped file list (empty when `raw` is null/undefined).
2274
- */
2275
- declare function mapFileReadList(raw: unknown): FileReadModel[];
2276
-
2277
- /**
2278
- * File utility reads (`POST /file/read`).
2279
- *
2280
- * Primary preview path when a record stores a `file_ref` string (shipments,
2281
- * tracking items, waybills, KYC, etc.). Body `{ ref }` → `data` with
2282
- * `mime_type` and `base_64` for `<img>` / PDF viewers.
2283
- *
2284
- * Document catalog previews use {@link DocumentService.readById} instead
2285
- * (`GET /public/document/read/{id}` → `data.file_ref.base_64`).
2286
- *
2287
- * @example
2288
- * ```ts
2289
- * const files = inject(FileService);
2290
- *
2291
- * files.read(item.file_ref).subscribe((res) => {
2292
- * if (res.success) console.log(res.data?.base_64);
2293
- * });
2294
- *
2295
- * files.readMultiple(waybillRef).subscribe((res) => {
2296
- * console.log(res.data?.map((f) => f.mime_type));
2297
- * });
2298
- * ```
2299
- */
2300
- declare class FileService {
2301
- private readonly api;
2302
- /**
2303
- * Resolve one file reference (`POST /file/read`, body `{ ref }`).
2304
- *
2305
- * @param ref - Storage / document UUID from `file_ref` on a record.
2306
- * @returns Normalized envelope with mapped {@link FileReadModel}.
2307
- */
2308
- read(ref: string): Observable<ApiResponseModel<FileReadModel>>;
2309
- /**
2310
- * Resolve multiple files for one ref (`POST /file/read?multiple=yes`).
2311
- *
2312
- * E-commerce waybill flows may return several pages in `data[]`.
2313
- *
2314
- * @param ref - Storage reference token.
2315
- * @returns Normalized envelope with mapped {@link FileReadModel}[].
2316
- */
2317
- readMultiple(ref: string): Observable<ApiResponseModel<FileReadModel[]>>;
2318
- /**
2319
- * Resolve a file from an explicit request body.
2320
- *
2321
- * @param body - Wire body (`{ ref }`).
2322
- * @returns Normalized envelope with mapped {@link FileReadModel}.
2323
- */
2324
- readByBody(body: FileReadRequestModel): Observable<ApiResponseModel<FileReadModel>>;
2325
- /**
2326
- * Multi-file variant of {@link readByBody}.
2327
- *
2328
- * @param body - Wire body (`{ ref }`).
2329
- * @returns Normalized envelope with mapped {@link FileReadModel}[].
2330
- */
2331
- readByBodyMultiple(body: FileReadRequestModel): Observable<ApiResponseModel<FileReadModel[]>>;
2332
- static ɵfac: i0.ɵɵFactoryDeclaration<FileService, never>;
2333
- static ɵprov: i0.ɵɵInjectableDeclaration<FileService>;
2334
- }
2335
-
2336
- /** Product read base path (relative to {@link AfricaniesSdkConfig.baseUrl}). */
2337
- declare const PRODUCT_READ_PATH = "/product/read";
2338
- /**
2339
- * Map a wire product into {@link ProductModel} (snake_case preserved).
2340
- * @param raw - Single product object from the API.
2341
- * @returns Normalized {@link ProductModel}.
2342
- */
2343
- declare function mapProduct(raw: unknown): ProductModel;
2344
- /**
2345
- * Map a list (or single object) payload into {@link ProductModel}[].
2346
- * @param raw - `data` payload from `/product/read/{id|all}`.
2347
- * @returns Mapped product list.
2348
- */
2349
- declare function mapProductList(raw: unknown): ProductModel[];
2350
-
2351
- /**
2352
- * Product utility reads (`GET /product/read/{id?}`).
2353
- *
2354
- * Uses the AFRICANIES {@link ResourceId} convention:
2355
- * - `null` (default) → paginated page
2356
- * - `'all'` → full list
2357
- * - `number` → single {@link ProductModel}
2358
- *
2359
- * @example
2360
- * ```ts
2361
- * const products = inject(ProductService);
2362
- *
2363
- * products.readPage({ page: 1 }).subscribe((res) => {
2364
- * console.log(res.data, res.pagination);
2365
- * });
2366
- * products.readAll().subscribe((res) => console.log(res.data?.[0]?.hs_code));
2367
- * products.readById(6280).subscribe((res) => console.log(res.data?.name));
2368
- * ```
2369
- */
2370
- declare class ProductService {
2371
- private readonly api;
2372
- /** Paginated product page — {@link ResourceId} `null`. */
2373
- read(id?: null, params?: ResourceQueryParams): Observable<ApiResponseModel<ProductModel[]>>;
2374
- /** Full product list — {@link ResourceId} `'all'`. */
2375
- read(id: 'all', params?: ResourceQueryParams): Observable<ApiResponseModel<ProductModel[]>>;
2376
- /** Single product — {@link ResourceId} number. */
2377
- read(id: number, params?: ResourceQueryParams): Observable<ApiResponseModel<ProductModel>>;
2378
- /**
2379
- * Paginated page — alias for {@link read}(`null`, params).
2380
- * @param params
2381
- */
2382
- readPage(params?: ResourceQueryParams): Observable<ApiResponseModel<ProductModel[]>>;
2383
- /**
2384
- * Full list — alias for {@link read}(`'all'`).
2385
- * @param params
2386
- */
2387
- readAll(params?: ResourceQueryParams): Observable<ApiResponseModel<ProductModel[]>>;
2388
- /**
2389
- * Single record — alias for {@link read}(id).
2390
- * @param id
2391
- * @param params
2392
- */
2393
- readById(id: number, params?: ResourceQueryParams): Observable<ApiResponseModel<ProductModel>>;
2394
- static ɵfac: i0.ɵɵFactoryDeclaration<ProductService, never>;
2395
- static ɵprov: i0.ɵɵInjectableDeclaration<ProductService>;
2396
- }
2397
-
2398
- /** One select row for filter drawer `optionLists` (wire value + label). */
2399
- interface FilterSelectOption {
2400
- value: string;
2401
- label: string;
2402
- /** Optional leading text/emoji (e.g. country flag emoji) in select rows. */
2403
- prefixText?: string;
2404
- /** Optional leading image URL (e.g. {@link countryFlagUrl} flag CDN). */
2405
- prefixImageUrl?: string;
2406
- }
2407
- /** Host bag keyed by {@link FilterFieldModel.key}. */
2408
- type FilterOptionLists = Record<string, FilterSelectOption[]>;
2409
- /** Select field with a required, non-static {@link FilterOptionsSource}. */
2410
- type ResolvableSelectField = Omit<FilterFieldModel, 'optionsSource' | 'type'> & {
2411
- type: 'select';
2412
- optionsSource: Exclude<FilterOptionsSource, 'static'>;
2413
- };
2414
- /**
2415
- * Select fields that declare a non-static {@link FilterOptionsSource}.
2416
- *
2417
- * @param config - Module filter schema.
2418
- * @returns Fields that need async option resolution.
2419
- */
2420
- declare function collectResolvableSelectFields(config: ModuleFilterConfigModel | null | undefined): ResolvableSelectField[];
2421
- /**
2422
- * Unique {@link FilterOptionsSource} values referenced by a config (excluding static).
2423
- *
2424
- * @param config - Module filter schema.
2425
- */
2426
- declare function collectFilterOptionsSources(config: ModuleFilterConfigModel): FilterOptionsSource[];
2427
- /**
2428
- * Map {@link WarehouseModel}[] into filter select options (`value` = id string).
2429
- *
2430
- * @param rows - Warehouses from {@link WarehouseService.readAll}.
2431
- */
2432
- declare function mapWarehouseFilterOptions(rows: WarehouseModel[] | null | undefined): FilterSelectOption[];
2433
- /**
2434
- * Map {@link ShipmentMethodModel}[] into filter select options.
2435
- *
2436
- * @param rows - Methods from {@link ShipmentMethodService.readAll}.
2437
- */
2438
- declare function mapShipmentMethodFilterOptions(rows: ShipmentMethodModel[] | null | undefined): FilterSelectOption[];
2439
- /**
2440
- * Merge SDK-resolved lists with host overrides (host wins per field key).
2441
- *
2442
- * @param resolved - Output from {@link FilterOptionsResolver.resolve}.
2443
- * @param overrides - Host catalogs (e.g. manifests without a built-in service).
2444
- */
2445
- declare function mergeFilterOptionLists(resolved: FilterOptionLists, overrides?: FilterOptionLists | null): FilterOptionLists;
2446
-
2447
- /**
2448
- * Resolves filter drawer select options from built-in SDK catalog services.
2449
- *
2450
- * Prefer opening {@link FilterDrawerService} immediately — the drawer lazy-loads
2451
- * per field via {@link resolveField}. {@link resolve} remains for bulk prefetch.
2452
- *
2453
- * @example
2454
- * ```ts
2455
- * const resolver = inject(FilterOptionsResolver);
2456
- *
2457
- * filterDrawer.open({
2458
- * config: updateShipmentsFilterConfig,
2459
- * optionLists: { shipment_manifest_id: hostManifests },
2460
- * });
2461
- * ```
2462
- */
2463
- declare class FilterOptionsResolver {
2464
- private readonly warehouses;
2465
- private readonly shipmentMethods;
2466
- /**
2467
- * Resolve SDK-backed options for one select field (lazy drawer load).
2468
- *
2469
- * @param field - Filter schema field with `optionsSource`.
2470
- * @returns Select rows or an error when the catalog HTTP call fails.
2471
- */
2472
- resolveField(field: FilterFieldModel): Observable<FilterSelectOption[]>;
2473
- /**
2474
- * Resolve all SDK-backed select options for a module config (bulk prefetch).
2475
- *
2476
- * @param config - Module filter schema.
2477
- * @returns `optionLists` keyed by field.key.
2478
- */
2479
- resolve(config: ModuleFilterConfigModel): Observable<FilterOptionLists>;
2480
- private staticFieldOptions;
2481
- private fetchSource;
2482
- static ɵfac: i0.ɵɵFactoryDeclaration<FilterOptionsResolver, never>;
2483
- static ɵprov: i0.ɵɵInjectableDeclaration<FilterOptionsResolver>;
2484
- }
2485
-
2486
- /**
2487
- * Maps a query-param value to a component and overlay surface.
2488
- *
2489
- * Used by {@link RouteOverlayService} when a registered param key's value
2490
- * matches a key in {@link OverlayRouteConfig.routes}.
2491
- */
2492
- interface OverlayRouteEntry {
2493
- /** Standalone component type to open in the overlay. */
2494
- component: Type<unknown>;
2495
- /**
2496
- * Which overlay host to use.
2497
- * `'modal'` → {@link MODAL_SERVICE}; `'drawer'` → {@link DRAWER_SERVICE}.
2498
- */
2499
- overlay: 'modal' | 'drawer';
2500
- }
2501
- /**
2502
- * One query-param namespace and its value → component map.
2503
- *
2504
- * Multiple configs can coexist (e.g. `modal` and `drawer` param keys) so
2505
- * both surfaces can be driven from the URL at once.
2506
- *
2507
- * @example
2508
- * ```ts
2509
- * const config: OverlayRouteConfig = {
2510
- * paramKey: 'modal',
2511
- * routes: {
2512
- * 'edit-shipment': { component: EditShipmentModal, overlay: 'modal' },
2513
- * },
2514
- * };
2515
- * ```
2516
- */
2517
- interface OverlayRouteConfig {
2518
- /**
2519
- * Query param name that triggers overlays (e.g. `'modal'` or `'drawer'`).
2520
- */
2521
- paramKey: string;
2522
- /**
2523
- * Map of param values to overlay entries.
2524
- * Unknown values are ignored (no open, no error).
2525
- */
2526
- routes: Record<string, OverlayRouteEntry>;
2527
- }
2528
-
2529
- /**
2530
- * Handle returned by modal/drawer openers so route sync can close and
2531
- * observe dismissal without depending on `@africanies/africanies-ui`.
2532
- *
2533
- * @typeParam TResult - Value passed to `close(result)` by the overlay content.
2534
- */
2535
- interface OverlayHandle<TResult = unknown> {
2536
- /**
2537
- * Closes the overlay, optionally with a result.
2538
- *
2539
- * @param result - Value forwarded to `afterClosed` subscribers.
2540
- */
2541
- close(result?: TResult): void;
2542
- /**
2543
- * Emits once when the overlay finishes closing, then completes.
2544
- */
2545
- afterClosed(): Observable<TResult | undefined>;
2546
- }
2547
- /**
2548
- * Minimal opener contract implemented by UI `ModalService` / `DrawerService`.
2549
- *
2550
- * Defined in `africanies-core` (and provided from `africanies-ui`) so route-driven
2551
- * overlays do not create a circular package dependency.
2552
- */
2553
- interface OverlayOpener {
2554
- /**
2555
- * Opens `component` in an overlay host.
2556
- *
2557
- * @param component - Standalone component type to instantiate.
2558
- * @param config - Optional data bag (other query params) and close behavior.
2559
- */
2560
- open<TData = unknown, TResult = unknown>(component: Type<unknown>, config?: {
2561
- data?: TData;
2562
- dismissible?: boolean;
2563
- }): OverlayHandle<TResult>;
2564
- }
2565
- /**
2566
- * Optional token for the app's modal opener (provided by `@africanies/africanies-ui`).
2567
- *
2568
- * {@link RouteOverlayService} injects this with `{ optional: true }` so apps
2569
- * can register route overlays before UI is wired — opens are skipped until
2570
- * a provider exists.
2571
- */
2572
- declare const MODAL_SERVICE: InjectionToken<OverlayOpener>;
2573
- /**
2574
- * Optional token for the app's drawer opener (provided by `@africanies/africanies-ui`).
2575
- *
2576
- * Same optional pattern as {@link MODAL_SERVICE}.
2577
- */
2578
- declare const DRAWER_SERVICE: InjectionToken<OverlayOpener>;
2579
- /**
2580
- * DI token for the list of {@link OverlayRouteConfig} registered via
2581
- * {@link provideOverlayRoutes}.
2582
- */
2583
- declare const OVERLAY_ROUTE_CONFIGS: InjectionToken<OverlayRouteConfig[]>;
2584
-
2585
- /**
2586
- * Registers query-param → overlay maps and eagerly starts {@link RouteOverlayService}.
2587
- *
2588
- * Call beside {@link provideAfricaniesSdk} in `app.config.ts`. Modal/drawer openers
2589
- * must still be provided by `@africanies/africanies-ui` (`MODAL_SERVICE` / `DRAWER_SERVICE`).
2590
- *
2591
- * @param configs - One or more param-key namespaces (e.g. `modal` and `drawer`).
2592
- * @returns Environment providers including an app initializer.
2593
- *
2594
- * @example
2595
- * ```ts
2596
- * // app.config.ts
2597
- * import { provideRouter, Routes } from '@angular/router';
2598
- * import {
2599
- * provideAfricaniesSdk,
2600
- * provideOverlayRoutes,
2601
- * } from '@africanies/africanies-core';
2602
- * import { EditShipmentModal } from './edit-shipment.modal';
2603
- *
2604
- * export const appConfig = {
2605
- * providers: [
2606
- * provideAfricaniesSdk({ baseUrl: 'https://api.example.com' }),
2607
- * provideRouter(routes),
2608
- * provideOverlayRoutes([
2609
- * {
2610
- * paramKey: 'modal',
2611
- * routes: {
2612
- * 'edit-shipment': {
2613
- * component: EditShipmentModal,
2614
- * overlay: 'modal',
2615
- * },
2616
- * },
2617
- * },
2618
- * ]),
2619
- * // From @africanies/africanies-ui — binds MODAL_SERVICE / DRAWER_SERVICE
2620
- * // provideAfricaniesOverlays(),
2621
- * ],
2622
- * };
2623
- *
2624
- * // Template — open via query params (refresh with the same URL reopens):
2625
- * // <a routerLink="." [queryParams]="{ modal: 'edit-shipment', id: row.id }">
2626
- * // Edit
2627
- * // </a>
2628
- * ```
2629
- */
2630
- declare function provideOverlayRoutes(configs: OverlayRouteConfig[]): EnvironmentProviders;
2631
-
2632
- /**
2633
- * Keeps query-param state in sync with modal/drawer overlays.
2634
- *
2635
- * Instantiated eagerly via {@link provideOverlayRoutes}'s `provideAppInitializer`
2636
- * so a hard refresh with `?modal=…` already present reopens the overlay.
2637
- *
2638
- * Bidirectional sync:
2639
- * - Param appears / matches a route → open (passing sibling query params as data)
2640
- * - Param removed (e.g. browser back) → close without navigating again
2641
- * - Overlay closed by UI → strip the trigger param with `queryParamsHandling: 'merge'`
2642
- *
2643
- * Modal/drawer implementations live in `@africanies/africanies-ui` and are injected through
2644
- * {@link MODAL_SERVICE} / {@link DRAWER_SERVICE} to avoid a circular dependency.
2645
- */
2646
- declare class RouteOverlayService {
2647
- private readonly route;
2648
- private readonly router;
2649
- private readonly configs;
2650
- private readonly modal;
2651
- private readonly drawer;
2652
- private readonly openByKey;
2653
- constructor();
2654
- private onQueryParams;
2655
- private syncConfig;
2656
- private siblingParams;
2657
- private teardown;
2658
- static ɵfac: i0.ɵɵFactoryDeclaration<RouteOverlayService, never>;
2659
- static ɵprov: i0.ɵɵInjectableDeclaration<RouteOverlayService>;
2660
- }
2661
-
2662
- /**
2663
- * Copy plain text to the system clipboard.
2664
- *
2665
- * Prefers `navigator.clipboard.writeText`. Falls back to a temporary
2666
- * `textarea` + `document.execCommand('copy')` when the Clipboard API is
2667
- * missing or throws (older browsers, some embedded / non-secure contexts).
2668
- *
2669
- * Safe to call during SSR — returns `false` when `document` is unavailable.
2670
- *
2671
- * @param value - Text to place on the clipboard.
2672
- * @returns `true` when the write succeeded; `false` otherwise.
2673
- *
2674
- * @example
2675
- * ```ts
2676
- * const ok = await copyToClipboard(iconName);
2677
- * if (ok) {
2678
- * toast.success(`Copied “${iconName}”`);
2679
- * }
2680
- * ```
2681
- */
2682
- declare function copyToClipboard(value: string): Promise<boolean>;
2683
-
2684
- /** Value that can be serialized into a CSV cell. */
2685
- type CsvCellValue = string | number | boolean | null | undefined;
2686
- /**
2687
- * Options for {@link downloadCsv}.
2688
- */
2689
- interface DownloadCsvOptions {
2690
- /** Download filename, including `.csv`. */
2691
- filename: string;
2692
- /** Optional header row. */
2693
- headers?: readonly CsvCellValue[];
2694
- /** Data rows. Each inner array is one CSV record. */
2695
- rows: readonly (readonly CsvCellValue[])[];
2696
- /**
2697
- * Prefix a UTF-8 BOM so Excel opens the file as UTF-8. Defaults to `true`.
2698
- */
2699
- bom?: boolean;
2700
- }
2701
- /**
2702
- * Escape a single CSV field (RFC 4180).
2703
- *
2704
- * Quotes fields that contain commas, quotes, or line breaks. `null` /
2705
- * `undefined` become an empty cell.
2706
- *
2707
- * @param value - Cell value.
2708
- */
2709
- declare function csvCell(value: CsvCellValue): string;
2710
- /**
2711
- * Build a CSV document string (optional BOM + header + rows).
2712
- *
2713
- * @param options - Headers, rows, and BOM flag (filename is ignored).
2714
- */
2715
- declare function toCsvString(options: Pick<DownloadCsvOptions, 'headers' | 'rows' | 'bom'>): string;
2716
- /**
2717
- * Download a CSV file in the browser.
2718
- *
2719
- * Hosts supply filename, headers, and already-mapped row values. Safe during
2720
- * SSR — returns `false` when `document` is unavailable.
2721
- *
2722
- * @param options - Filename, headers, and row cells.
2723
- * @returns `true` when the download was triggered.
2724
- *
2725
- * @example
2726
- * ```ts
2727
- * downloadCsv({
2728
- * filename: 'warehouses.csv',
2729
- * headers: ['Name', 'Status'],
2730
- * rows: warehouses.map((row) => [
2731
- * row.name,
2732
- * row.active ? 'Active' : 'In-Active',
2733
- * ]),
2734
- * });
2735
- * ```
2736
- */
2737
- declare function downloadCsv(options: DownloadCsvOptions): boolean;
2738
-
2739
- export { AFRICANIES_HTTP_TOAST, AFRICANIES_SDK_CONFIG, AUTH_FORGOT_PASSWORD_PATH, ApiClient, AuthService, AuthTokenService, COUNTRY_FLAG_CDN_BASE, COUNTRY_READ_PATH, CURRENCY_CREATE_PATH, CURRENCY_DELETE_PATH, CURRENCY_READ_PATH, CURRENCY_UPDATE_PATH, CountryService, CurrencyService, DOCUMENT_READ_PATH, DRAWER_SERVICE, DocumentService, FILE_READ_MULTIPLE_PARAM, FILE_READ_PATH, FileService, FilterOptionsResolver, HttpResponseCache, MODAL_SERVICE, MODE_CONFIG_PATH, ModeConfigService, NOTIFICATION_READ_PATH, NOTIFICATION_UPDATE_PATH, NotificationService, OVERLAY_ROUTE_CONFIGS, PAYMENT_METHOD_READ_PATH, PAYMENT_METHOD_UPDATE_PATH, PLAN_READ_PATH, PRODUCT_READ_PATH, PaymentMethodService, PlanService, ProductService, RouteOverlayService, SERVICE_READ_PATH, SHIPMENT_METHOD_READ_PATH, SHIPPING_MODE_OVERRIDE, ServiceService, ShipmentMethodService, ShippingModeService, TOAST_HTTP_OPTIONS, USER_CHANGE_PASSWORD_PATH, USER_LOGOUT_FROM_ALL_SESSIONS_PATH, USER_PATH, UserService, WAREHOUSE_READ_PATH, WarehouseService, ZONE_READ_PATH, ZoneService, asArray, asBoolean, asNullableBoolean, asNullableFlag01, asNullableNumber, asNullableString, asNumber, asRecord, asShippingMode, asString, authInterceptor, buildResourcePath, buildResourceQueryParams, collectFilterOptionsSources, collectResolvableSelectFields, copyToClipboard, countryFlagUrl, createAfricaniesQueryClientDefaults, csvCell, downloadCsv, fieldErrorsMap, formatApiErrorMessage, httpToastInterceptor, isLaravelValidationBag, isValidEmail, joinApiErrorMessages, listFetchKind, mapApiJsonList, mapApiJsonValue, mapArray, mapCountry, mapCountryList, mapCountrySelectOptions, mapCountryState, mapCurrency, mapCurrencyList, mapCurrencyPaymentMethod, mapCurrencyPaymentMethodPivot, mapDocument, mapDocumentList, mapFileRead, mapFileReadList, mapLaravelValidationBag, mapList, mapModeConfigData, mapNotification, mapNotificationInboxItem, mapNotificationList, mapNotificationPayload, mapPaymentMethod, mapPaymentMethodCurrency, mapPaymentMethodList, mapPlan, mapPlanList, mapPlanPackage, mapProduct, mapProductList, mapResourcePayload, mapService, mapServiceList, mapShipmentMethod, mapShipmentMethodFilterOptions, mapShipmentMethodList, mapShipmentMethodZoneLink, mapShipmentMethodZonePage, mapShipmentZone, mapUser, mapUserAccountManager, mapUserBusinessAccount, mapUserCountry, mapUserCountryState, mapUserGatewayPayload, mapUserPaymentPayload, mapUserPlan, mapUserPlanPackage, mapUserStateLabel, mapUserSubscription, mapWarehouse, mapWarehouseCountry, mapWarehouseFilterOptions, mapWarehouseList, mapWarehouseState, mapZone, mapZoneList, mergeFilterOptionLists, normalize, normalizePagination, provideAfricaniesHttpClient, provideAfricaniesQueryDefaults, provideAfricaniesSdk, provideModeConfig, provideOverlayRoutes, resolveModeRegionConfig, resolveNotificationLinkForMode, resourceCacheTtlMs, shipmentModeInterceptor, toCsvString, toCurrencyCreateBody, toCurrencyDeleteBody, toCurrencyFlag01, toCurrencyUpdateBody, toFlag01, toPaymentMethodFlag01, toPaymentMethodUpdateBody, unwrapLaravelPaginator, withShippingMode, withToast };
2740
- export type { AfricaniesHttpClientOptions, AfricaniesHttpToastHandler, AfricaniesQueryClientDefaults, AfricaniesSdkConfig, AfricaniesSdkHttpToasts, ApiRequestOptions, CountryFlagFormat, CountryFlagUrlOptions, CountrySelectOption, CsvCellValue, DownloadCsvOptions, FilterOptionLists, FilterSelectOption, ListFetchKind, ListFetchReason, OverlayHandle, OverlayOpener, OverlayRouteConfig, OverlayRouteEntry, ResourceQueryParams, ShippingModeChangeGuard, ToastHttpOptions };