@africanies/angular-web-sdk 0.1.4 → 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.
Files changed (46) hide show
  1. package/.nx/cache/14876618240301288353/dist/libs/africanies-ui/README.md +68 -0
  2. package/.nx/cache/14876618240301288353/dist/libs/africanies-ui/assets/brand/africanies-logo-mini.png +0 -0
  3. package/.nx/cache/14876618240301288353/dist/libs/africanies-ui/assets/brand/africanies-logo.png +0 -0
  4. package/.nx/cache/14876618240301288353/dist/libs/africanies-ui/assets/brand/africanies-logo.svg +5 -0
  5. package/.nx/cache/14876618240301288353/dist/libs/africanies-ui/assets/carriers/dhl.svg +7 -0
  6. package/.nx/cache/14876618240301288353/dist/libs/africanies-ui/fesm2022/africanies-africanies-ui.mjs +19375 -0
  7. package/.nx/cache/14876618240301288353/dist/libs/africanies-ui/fesm2022/africanies-africanies-ui.mjs.map +1 -0
  8. package/.nx/cache/14876618240301288353/dist/libs/africanies-ui/package.json +35 -0
  9. package/.nx/cache/14876618240301288353/dist/libs/africanies-ui/types/africanies-africanies-ui.d.ts +5490 -0
  10. package/.nx/cache/17626862048742598274/dist/libs/africanies-theme/README.md +46 -0
  11. package/.nx/cache/17626862048742598274/dist/libs/africanies-theme/fesm2022/africanies-africanies-theme.mjs +221 -0
  12. package/.nx/cache/17626862048742598274/dist/libs/africanies-theme/fesm2022/africanies-africanies-theme.mjs.map +1 -0
  13. package/.nx/cache/17626862048742598274/dist/libs/africanies-theme/package.json +35 -0
  14. package/.nx/cache/17626862048742598274/dist/libs/africanies-theme/tailwind-preset.cjs +253 -0
  15. package/.nx/cache/17626862048742598274/dist/libs/africanies-theme/types/africanies-africanies-theme.d.ts +166 -0
  16. package/.nx/cache/9040451482998546630/dist/libs/africanies-core/README.md +85 -0
  17. package/.nx/cache/9040451482998546630/dist/libs/africanies-core/fesm2022/africanies-africanies-core.mjs +4511 -0
  18. package/.nx/cache/9040451482998546630/dist/libs/africanies-core/fesm2022/africanies-africanies-core.mjs.map +1 -0
  19. package/.nx/cache/9040451482998546630/dist/libs/africanies-core/package.json +31 -0
  20. package/.nx/cache/9040451482998546630/dist/libs/africanies-core/types/africanies-africanies-core.d.ts +2741 -0
  21. package/.nx/cache/run.json +25 -25
  22. package/.nx/cache/terminalOutputs/13555699813138069787 +6 -0
  23. package/.nx/cache/terminalOutputs/14061940909886036014 +173 -0
  24. package/.nx/cache/terminalOutputs/14876618240301288353 +21 -0
  25. package/.nx/cache/terminalOutputs/17626862048742598274 +21 -0
  26. package/.nx/cache/terminalOutputs/7978448102466861029 +32 -0
  27. package/.nx/cache/terminalOutputs/9040451482998546630 +21 -0
  28. package/.nx/workspace-data/0091ABA9-5C90-580D-953C-8C94E763ADB5-v3.db +0 -0
  29. package/.nx/workspace-data/0091ABA9-5C90-580D-953C-8C94E763ADB5-v3.db-shm +0 -0
  30. package/.nx/workspace-data/0091ABA9-5C90-580D-953C-8C94E763ADB5-v3.db-wal +0 -0
  31. package/.nx/workspace-data/d/daemon.log +1518 -0
  32. package/.nx/workspace-data/d/server-process.json +2 -2
  33. package/.nx/workspace-data/file-map.json +3240 -3240
  34. package/.nx/workspace-data/nx_files.nxt +0 -0
  35. package/.nx/workspace-data/project-graph.json +2 -2
  36. package/apps/playground/src/app/app.routes.ts +15 -4
  37. package/apps/playground/src/app/app.ts +2 -2
  38. package/apps/playground/src/app/pages/home-page.ts +14 -14
  39. package/dist/libs/africanies-core/fesm2022/africanies-africanies-core.mjs +8 -43
  40. package/dist/libs/africanies-core/fesm2022/africanies-africanies-core.mjs.map +1 -1
  41. package/dist/libs/africanies-core/types/africanies-africanies-core.d.ts +6 -5
  42. package/dist/libs/africanies-ui/types/africanies-africanies-ui.d.ts +11 -11
  43. package/libs/africanies-core/src/lib/http/api-client.ts +4 -18
  44. package/libs/africanies-core/src/lib/http/is-retryable-get-error.ts +8 -4
  45. package/libs/africanies-core/src/lib/query/provide-africanies-query-defaults.ts +5 -6
  46. package/package.json +1 -1
@@ -0,0 +1,166 @@
1
+ import * as i0 from '@angular/core';
2
+
3
+ /**
4
+ * Tailwind safelist side-effect for shipping-mode color utilities.
5
+ *
6
+ * WHY this file exists: JIT/content scanning only keeps class names that appear
7
+ * as *literal strings* in scanned sources. {@link ModeColorService} already
8
+ * returns these literals, but keeping a dedicated comment list makes the
9
+ * contract obvious for consumers who configure `safelist` or purge plugins.
10
+ *
11
+ * Do not rename these strings without updating ModeColorService and THEME.md.
12
+ *
13
+ * SFN (export / green):
14
+ * text-export bg-export bg-export-subtle bg-export-light border-export
15
+ * hover:bg-export-light hover:bg-export-subtle dark:bg-export/15 dark:hover:bg-export/15
16
+ * dark:bg-[color-mix(in_srgb,#1cbd5d_15%,#212529)]
17
+ *
18
+ * STN (import / orange):
19
+ * text-import bg-import bg-import-subtle bg-import-light border-import
20
+ * hover:bg-import-light hover:bg-import-subtle dark:bg-import/15 dark:hover:bg-import/15
21
+ * dark:bg-[color-mix(in_srgb,#f08829_15%,#212529)]
22
+ */
23
+ declare const MODE_COLOR_SAFELIST: readonly ["text-export", "bg-export", "bg-export-subtle", "bg-export-light", "border-export", "hover:bg-export-light", "hover:bg-export-subtle", "dark:bg-export/15", "dark:hover:bg-export/15", "dark:bg-[color-mix(in_srgb,#1cbd5d_15%,#212529)]", "text-import", "bg-import", "bg-import-subtle", "bg-import-light", "border-import", "hover:bg-import-light", "hover:bg-import-subtle", "dark:bg-import/15", "dark:hover:bg-import/15", "dark:bg-[color-mix(in_srgb,#f08829_15%,#212529)]"];
24
+
25
+ /**
26
+ * Tailwind class bundle for the active shipping mode (SFN export / STN import).
27
+ *
28
+ * Use these for **primary** product chrome: CTAs, selected controls, progress,
29
+ * and accent text. Semantic colors (danger / warning) stay mode-independent.
30
+ */
31
+ interface ModeColorClasses {
32
+ /** Text color utility, e.g. `text-export`. */
33
+ text: string;
34
+ /** Solid background utility, e.g. `bg-export`. */
35
+ bg: string;
36
+ /** Soft background utility, e.g. `bg-export-subtle`. */
37
+ bgSubtle: string;
38
+ /** Border matching the mode accent, e.g. `border-export`. */
39
+ border: string;
40
+ /**
41
+ * Filled primary CTA — `variant="primary"` on buttons.
42
+ * Includes hover utility as a literal so Tailwind keeps it.
43
+ */
44
+ primary: string;
45
+ /**
46
+ * Transparent / text-only CTA — `variant="ghost-primary"` on buttons.
47
+ * Mode accent text + soft hover fill.
48
+ */
49
+ ghostPrimary: string;
50
+ /**
51
+ * Soft highlight for selected / active rows (works in dark mode).
52
+ * Dark uses a translucent tint — fine over solid surfaces, not for
53
+ * sticky overlays (see {@link softSolid}).
54
+ */
55
+ soft: string;
56
+ /**
57
+ * Opaque soft fill — same tint as {@link soft}, but dark mode mixes into
58
+ * ink so scrolled content cannot show through (sticky table headers/cells).
59
+ */
60
+ softSolid: string;
61
+ /**
62
+ * Soft hover highlight for menus and lists.
63
+ */
64
+ softHover: string;
65
+ }
66
+ /**
67
+ * Maps {@link ShippingModeService} to mode-accent Tailwind classes.
68
+ *
69
+ * - **SFN** → export green is primary
70
+ * - **STN** → import orange is primary
71
+ *
72
+ * WHY literal class strings: Tailwind's scanner cannot see dynamically built
73
+ * names like `` `text-${token}` ``. Returning full literals (`text-export`, …)
74
+ * keeps utilities in the compiled CSS. See {@link MODE_COLOR_SAFELIST}.
75
+ *
76
+ * @example
77
+ * ```html
78
+ * @let colors = modeColor.classes();
79
+ * <button type="button" [class]="colors.primary">Save</button>
80
+ * <span [class]="colors.text">Mode accent</span>
81
+ * ```
82
+ */
83
+ declare class ModeColorService {
84
+ private readonly shippingMode;
85
+ /**
86
+ * Mode-dependent utility classes. Recomputes when shipping mode changes.
87
+ */
88
+ readonly classes: i0.Signal<ModeColorClasses>;
89
+ static ɵfac: i0.ɵɵFactoryDeclaration<ModeColorService, never>;
90
+ static ɵprov: i0.ɵɵInjectableDeclaration<ModeColorService>;
91
+ }
92
+
93
+ /**
94
+ * Supported UI color schemes for {@link ThemeService}.
95
+ *
96
+ * Kept as a closed string union so storage values and DOM class toggles stay
97
+ * aligned — unknown persisted strings are ignored and fall back to system
98
+ * preference / light.
99
+ */
100
+ type Theme = 'light' | 'dark';
101
+
102
+ /**
103
+ * Application light/dark theme preference.
104
+ *
105
+ * WHY signals (not BehaviorSubject): theme is synchronous UI state read from
106
+ * templates and other services; a signal avoids RxJS subscription boilerplate
107
+ * and matches Angular 22 change detection. Persistence goes through
108
+ * {@link STORAGE_TOKEN} so tests can swap storage without touching `localStorage`.
109
+ *
110
+ * Applies the Tailwind `darkMode: 'class'` contract by toggling `dark` on
111
+ * `document.documentElement`, and sets `color-scheme` so native UI (date
112
+ * pickers, scrollbars, form controls) matches the app theme — class-based
113
+ * dark mode alone does not restyle browser chrome.
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * // app.config.ts
118
+ * import { inject, provideAppInitializer } from '@angular/core';
119
+ * import { ThemeService } from '@africanies/africanies-theme';
120
+ *
121
+ * export const appConfig = {
122
+ * providers: [
123
+ * provideAppInitializer(() => {
124
+ * inject(ThemeService); // applies stored / system theme once
125
+ * }),
126
+ * ],
127
+ * };
128
+ *
129
+ * // In a component
130
+ * const theme = inject(ThemeService);
131
+ * theme.toggle();
132
+ * theme.setTheme('dark');
133
+ * const current = theme.theme(); // 'light' | 'dark'
134
+ * ```
135
+ */
136
+ declare class ThemeService {
137
+ private readonly storage;
138
+ private readonly document;
139
+ /**
140
+ * Current theme. Prefer reading via `theme()` in templates / computed values
141
+ * rather than caching the string, so dark-class consumers stay in sync.
142
+ */
143
+ readonly theme: i0.WritableSignal<Theme>;
144
+ constructor();
145
+ /**
146
+ * Sets and persists the theme, updating the `dark` class and `color-scheme`
147
+ * on `<html>`.
148
+ *
149
+ * @param theme - Absolute preference to store.
150
+ */
151
+ setTheme(theme: Theme): void;
152
+ /**
153
+ * Flips between light and dark.
154
+ *
155
+ * @returns The theme after the toggle.
156
+ */
157
+ toggle(): Theme;
158
+ private resolveInitialTheme;
159
+ private prefersDark;
160
+ private applyToDocument;
161
+ static ɵfac: i0.ɵɵFactoryDeclaration<ThemeService, never>;
162
+ static ɵprov: i0.ɵɵInjectableDeclaration<ThemeService>;
163
+ }
164
+
165
+ export { MODE_COLOR_SAFELIST, ModeColorService, ThemeService };
166
+ export type { ModeColorClasses, Theme };
@@ -0,0 +1,85 @@
1
+ # @africanies/africanies-core
2
+
3
+ API and app-wiring layer for the AFRICANIES Web SDK: SDK config, HTTP client,
4
+ shipping mode, mode-region metadata, TanStack Query default helpers, and
5
+ route-driven overlay registration.
6
+
7
+ ## Install peers
8
+
9
+ ```bash
10
+ # Published on npm (@africanies scope)
11
+ npm install @africanies/africanies-core @africanies/africanies-models @africanies/africanies-storage
12
+ ```
13
+
14
+ Peer dependencies: `@angular/common`, `@angular/core`, `@angular/router`,
15
+ `rxjs`, `@africanies/africanies-models`, `@africanies/africanies-storage`.
16
+
17
+ ## Quick start
18
+
19
+ ```ts
20
+ import { ApplicationConfig } from '@angular/core';
21
+ import {
22
+ provideAfricaniesSdk,
23
+ provideAfricaniesHttpClient,
24
+ provideOverlayRoutes,
25
+ createAfricaniesQueryClientDefaults,
26
+ } from '@africanies/africanies-core';
27
+
28
+ export const appConfig: ApplicationConfig = {
29
+ providers: [
30
+ provideAfricaniesSdk({ baseUrl: 'https://api.example.com', timeout: 30_000 }),
31
+ provideAfricaniesHttpClient(),
32
+ // optional extras:
33
+ // provideAfricaniesHttpClient({ interceptors: [correlationInterceptor] }),
34
+ // optional: provideOverlayRoutes([{ paramKey: 'modal', routes: { ... } }]),
35
+ ],
36
+ };
37
+
38
+ // TanStack Query (app dependency — pin exact experimental version):
39
+ // new QueryClient({ defaultOptions: createAfricaniesQueryClientDefaults() })
40
+ ```
41
+
42
+ ## Modules
43
+
44
+ | Area | Exports |
45
+ |------|---------|
46
+ | Config | `provideAfricaniesSdk`, `AFRICANIES_SDK_CONFIG`, `httpToasts` (`'off'` \| `'errors'` \| `'all'`) |
47
+ | Auth | `AuthService` (`forgot`), `isValidEmail`, `AuthTokenService` (`set` / `clear` / `get`) |
48
+ | Shipping | `ShippingModeService` (tab-scoped via `sessionStorage`), `shipmentModeInterceptor`, per-request `ApiRequestOptions.shippingMode` / `withShippingMode` |
49
+ | HTTP | `provideAfricaniesHttpClient`, `ApiClient` (auto-tags `withToast` from config / `ApiRequestOptions.toast`; optional `shippingMode` per call; HTTP failures → `Error` with formatted `.message`), `withToast`, `withShippingMode`, `httpToastInterceptor`, `normalize` (lifts Laravel validation bags into `errors` + joined `message`), `formatApiErrorMessage` (used internally; rare for hosts), `fieldErrorsMap`, `authInterceptor` |
50
+ | Query | `createAfricaniesQueryClientDefaults`, `provideAfricaniesQueryDefaults`, `listFetchKind` (body loader on first load / STN↔SFN; keep rows on focus / Refresh / pager) |
51
+ | Mode | `ModeConfigService`, `provideModeConfig`, `MODE_CONFIG_PATH` |
52
+ | Country | `CountryService`, `countryFlagUrl` / `mapCountrySelectOptions` (flagcdn.com), `COUNTRY_READ_PATH`, mappers |
53
+ | Service | `ServiceService` (`readPage` / `readAll` / `readById`), `SERVICE_READ_PATH` (`/public/service/read`), mappers |
54
+ | Document | `DocumentService` (`readPage` / `readAll` / `readById`), `DOCUMENT_READ_PATH` (`/public/document/read`) — preview via `file_ref` on by-id |
55
+ | Plan | `PlanService` (`readPage` / `readAll` / `readById`), `PLAN_READ_PATH` (`/public/plan/read`), mappers |
56
+ | Currency | `CurrencyService` (`readPage` / `readAll` / `readById`, `create` / `update` / `remove`), `CURRENCY_*_PATH`, mappers |
57
+ | Payment method | `PaymentMethodService` (`readPage` / `readAll` / `readById`, `update`), `PAYMENT_METHOD_READ_PATH` / `PAYMENT_METHOD_UPDATE_PATH`, mappers |
58
+ | Shipment method | `ShipmentMethodService` (`readPage` / `readAll` / `readById`), `SHIPMENT_METHOD_READ_PATH`, mappers |
59
+ | Warehouse | `WarehouseService` (`readPage` / `readAll` / `readById`), `WAREHOUSE_READ_PATH`, mappers |
60
+ | Zone | `ZoneService` (`readPage` / `readAll` / `readById`), `ZONE_READ_PATH`, mappers |
61
+ | Product | `ProductService` (`readPage` / `readAll` / `readById`), `PRODUCT_READ_PATH`, mappers |
62
+ | User | `UserService` (`me`, `changePassword`, `logoutFromAllSessions`), `USER_PATH`, `mapUser` (bare `/user` body; needs `AuthTokenService.set`) |
63
+ | Notification | `NotificationService` (`readPage` / `readAll` / `readOne`), `NOTIFICATION_READ_PATH`, `mapNotification` / `mapNotificationInboxItem` |
64
+ | File | `FileService` (`read` / `readMultiple` → `POST /file/read`), `FILE_READ_PATH`, `mapFileRead` / `mapFileReadList` |
65
+ | Overlay | `provideOverlayRoutes`, `RouteOverlayService`, `MODAL_SERVICE`, `DRAWER_SERVICE` |
66
+ | Filters | `FilterOptionsResolver` (`resolveField` lazy in drawer), `mergeFilterOptionLists`, warehouse/method mappers |
67
+ | Browser | `copyToClipboard`, `downloadCsv` / `csvCell` (UTF-8 CSV download) |
68
+
69
+ List-style GETs follow `ResourceId`: `null` (paginated), `'all'` (full dump), `number` (single).
70
+
71
+ | Filter `optionsSource` | SDK resolver |
72
+ |------------------------|--------------|
73
+ | `warehouses` | Lazy `FilterOptionsResolver.resolveField` → `WarehouseService.readAll()` |
74
+ | `shipmentMethods` | Lazy `FilterOptionsResolver.resolveField` → `ShipmentMethodService.readAll()` |
75
+ | `shipmentManifests` | Host `optionLists` (no built-in service yet) |
76
+
77
+ `MODAL_SERVICE` / `DRAWER_SERVICE` are tokens only — implementations ship in
78
+ `@africanies/africanies-ui` to avoid circular dependencies.
79
+
80
+ ## Build / test
81
+
82
+ ```bash
83
+ npx nx build africanies-core
84
+ npx nx test africanies-core
85
+ ```