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