mn-angular-lib 1.0.50 → 1.0.51
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.
|
@@ -8117,6 +8117,105 @@ class CrudService {
|
|
|
8117
8117
|
}
|
|
8118
8118
|
}
|
|
8119
8119
|
|
|
8120
|
+
/**
|
|
8121
|
+
* Lightweight abstract HTTP base class that removes common boilerplate
|
|
8122
|
+
* from API services.
|
|
8123
|
+
*
|
|
8124
|
+
* Provides typed `get`, `post`, `patch`, `put`, and `delete` methods
|
|
8125
|
+
* that return Promises, automatic query-param building, and base-URL
|
|
8126
|
+
* injection via the `API_BASE_URL` token.
|
|
8127
|
+
*
|
|
8128
|
+
* Subclass this directly for services with static or mixed endpoints.
|
|
8129
|
+
* No CRUD structure is imposed — every method accepts a free-form path.
|
|
8130
|
+
*/
|
|
8131
|
+
class MnHttpService {
|
|
8132
|
+
/** Angular HTTP client injected automatically. */
|
|
8133
|
+
http = inject(HttpClient);
|
|
8134
|
+
/** Base API URL provided via the `API_BASE_URL` injection token. */
|
|
8135
|
+
baseUrl = inject(API_BASE_URL);
|
|
8136
|
+
/**
|
|
8137
|
+
* Sends a typed GET request.
|
|
8138
|
+
* @param path The path appended to the base URL.
|
|
8139
|
+
* @param query Optional query parameters.
|
|
8140
|
+
* @returns A promise resolving to the typed response body.
|
|
8141
|
+
*/
|
|
8142
|
+
get(path, query) {
|
|
8143
|
+
return firstValueFrom(this.http.get(`${this.baseUrl}${path}`, {
|
|
8144
|
+
params: this.toHttpParams(query),
|
|
8145
|
+
}));
|
|
8146
|
+
}
|
|
8147
|
+
/**
|
|
8148
|
+
* Sends a typed POST request.
|
|
8149
|
+
* @param path The path appended to the base URL.
|
|
8150
|
+
* @param body Optional request body.
|
|
8151
|
+
* @param query Optional query parameters.
|
|
8152
|
+
* @returns A promise resolving to the typed response body.
|
|
8153
|
+
*/
|
|
8154
|
+
post(path, body, query) {
|
|
8155
|
+
return firstValueFrom(this.http.post(`${this.baseUrl}${path}`, body ?? {}, {
|
|
8156
|
+
params: this.toHttpParams(query),
|
|
8157
|
+
}));
|
|
8158
|
+
}
|
|
8159
|
+
/**
|
|
8160
|
+
* Sends a typed PATCH request.
|
|
8161
|
+
* @param path The path appended to the base URL.
|
|
8162
|
+
* @param body Optional request body.
|
|
8163
|
+
* @param query Optional query parameters.
|
|
8164
|
+
* @returns A promise resolving to the typed response body.
|
|
8165
|
+
*/
|
|
8166
|
+
patch(path, body, query) {
|
|
8167
|
+
return firstValueFrom(this.http.patch(`${this.baseUrl}${path}`, body ?? {}, {
|
|
8168
|
+
params: this.toHttpParams(query),
|
|
8169
|
+
}));
|
|
8170
|
+
}
|
|
8171
|
+
/**
|
|
8172
|
+
* Sends a typed PUT request.
|
|
8173
|
+
* @param path The path appended to the base URL.
|
|
8174
|
+
* @param body Optional request body.
|
|
8175
|
+
* @param query Optional query parameters.
|
|
8176
|
+
* @returns A promise resolving to the typed response body.
|
|
8177
|
+
*/
|
|
8178
|
+
put(path, body, query) {
|
|
8179
|
+
return firstValueFrom(this.http.put(`${this.baseUrl}${path}`, body ?? {}, {
|
|
8180
|
+
params: this.toHttpParams(query),
|
|
8181
|
+
}));
|
|
8182
|
+
}
|
|
8183
|
+
/**
|
|
8184
|
+
* Sends a typed DELETE request.
|
|
8185
|
+
* @param path The path appended to the base URL.
|
|
8186
|
+
* @param query Optional query parameters.
|
|
8187
|
+
* @returns A promise resolving to the typed response body.
|
|
8188
|
+
*/
|
|
8189
|
+
delete(path, query) {
|
|
8190
|
+
return firstValueFrom(this.http.delete(`${this.baseUrl}${path}`, {
|
|
8191
|
+
params: this.toHttpParams(query),
|
|
8192
|
+
}));
|
|
8193
|
+
}
|
|
8194
|
+
/**
|
|
8195
|
+
* Converts a query-params record to Angular `HttpParams`.
|
|
8196
|
+
* Null and undefined values are silently skipped.
|
|
8197
|
+
* Array values are appended as multiple entries for the same key.
|
|
8198
|
+
* @param query The query parameter record to convert.
|
|
8199
|
+
* @returns An `HttpParams` instance, or `undefined` when no parameters are provided.
|
|
8200
|
+
*/
|
|
8201
|
+
toHttpParams(query) {
|
|
8202
|
+
if (!query)
|
|
8203
|
+
return undefined;
|
|
8204
|
+
let params = new HttpParams();
|
|
8205
|
+
for (const [key, rawValue] of Object.entries(query)) {
|
|
8206
|
+
if (rawValue === null || rawValue === undefined)
|
|
8207
|
+
continue;
|
|
8208
|
+
const values = Array.isArray(rawValue) ? rawValue : [rawValue];
|
|
8209
|
+
for (const value of values) {
|
|
8210
|
+
if (value === null || value === undefined)
|
|
8211
|
+
continue;
|
|
8212
|
+
params = params.append(key, String(value));
|
|
8213
|
+
}
|
|
8214
|
+
}
|
|
8215
|
+
return params;
|
|
8216
|
+
}
|
|
8217
|
+
}
|
|
8218
|
+
|
|
8120
8219
|
/**
|
|
8121
8220
|
* Enable live preview mode. Listens for postMessage events from
|
|
8122
8221
|
* Mn Web Manager and hot-swaps config/translations at runtime.
|
|
@@ -8161,5 +8260,5 @@ function enableMnPreviewMode(configService, langService, allowedOrigins) {
|
|
|
8161
8260
|
* Generated bundle index. Do not edit.
|
|
8162
8261
|
*/
|
|
8163
8262
|
|
|
8164
|
-
export { API_BASE_URL, ActionStyle, BackdropMode, BaseModalBuilder, CALENDAR_CONFIG, CALENDAR_DATE_FORMATTER, CalendarDayComponent, CalendarEventComponent, CalendarEventDefaultComponent, CalendarEventLayoutService, CalendarMonthComponent, CalendarUtility, CalendarView, CalendarViewComponent, CalendarWeekComponent, CloseMode, ColumnSortType, ConfirmationModalBuilder, ConfirmationTone, CrudService, CustomModalBuilder, DEFAULT_CALENDAR_CONFIG, DEFAULT_MN_ALERT_CONFIG, DefaultCalendarDateFormatter, FieldAppearance, FieldKind, FormLayoutMode, FormModalBuilder, KeyboardMode, MN_ALERT_CONFIG, MN_CALENDAR_COMPONENT_NAME, MN_CALENDAR_CONFIG, MN_CHECKBOX_CONFIG, MN_DATETIME_CONFIG, MN_ICON_MAP, MN_INPUT_FIELD_CONFIG, MN_INSTANCE_ID, MN_LIB_DUAL_HORIZONTAL_IMAGE, MN_MULTI_SELECT_CONFIG, MN_SECTION_PATH, MN_SELECT_CONFIG, MN_TEXTAREA_CONFIG, MnAlertOutletComponent, MnAlertService, MnAlertStore, MnBadge, MnButton, MnCheckbox, MnConfigService, MnConfirmationBodyComponent, MnCustomBodyHostComponent, MnDatetime, MnDualHorizontalImage, MnFormBodyComponent, MnHiddenBelowDirective, MnIcon, MnIconAttributes, MnInformationCard, MnInputField, MnInstanceDirective, MnLanguageService, MnList, MnModalRef, MnModalService, MnModalShellComponent, MnMultiSelect, MnSectionDirective, MnSelect, MnTabComponent, MnTable, MnTextarea, MnTranslatePipe, MnWizardBodyComponent, ModalBuilder, ModalCloseReason, ModalIntent, ModalKind, ModalSize, NavigationDirection, OptionState, SelectionMode, StepBuilder, StepState, SubmitMode, UpcomingEventRowComponent, UpcomingEventsComponent, ValidationCode, ValidationStatus, WizardFlowMode, WizardModalBuilder, dateTimeAdapter, defaultTextAdapter, enableMnPreviewMode, isTranslatable, mnAlertVariants, mnBadgeVariants, mnButtonVariants, mnCheckboxVariants, mnCheckboxWrapperVariants, mnDatetimeVariants, mnIconVariants, mnInformationCardVariants, mnInputFieldVariants, mnMultiSelectVariants, mnSelectVariants, mnTextareaVariants, numberAdapter, pickAdapter, provideMnAlerts, provideMnCalendarConfig, provideMnComponentConfig, provideMnConfig, provideMnLanguage, resolveCalendarConfig };
|
|
8263
|
+
export { API_BASE_URL, ActionStyle, BackdropMode, BaseModalBuilder, CALENDAR_CONFIG, CALENDAR_DATE_FORMATTER, CalendarDayComponent, CalendarEventComponent, CalendarEventDefaultComponent, CalendarEventLayoutService, CalendarMonthComponent, CalendarUtility, CalendarView, CalendarViewComponent, CalendarWeekComponent, CloseMode, ColumnSortType, ConfirmationModalBuilder, ConfirmationTone, CrudService, CustomModalBuilder, DEFAULT_CALENDAR_CONFIG, DEFAULT_MN_ALERT_CONFIG, DefaultCalendarDateFormatter, FieldAppearance, FieldKind, FormLayoutMode, FormModalBuilder, KeyboardMode, MN_ALERT_CONFIG, MN_CALENDAR_COMPONENT_NAME, MN_CALENDAR_CONFIG, MN_CHECKBOX_CONFIG, MN_DATETIME_CONFIG, MN_ICON_MAP, MN_INPUT_FIELD_CONFIG, MN_INSTANCE_ID, MN_LIB_DUAL_HORIZONTAL_IMAGE, MN_MULTI_SELECT_CONFIG, MN_SECTION_PATH, MN_SELECT_CONFIG, MN_TEXTAREA_CONFIG, MnAlertOutletComponent, MnAlertService, MnAlertStore, MnBadge, MnButton, MnCheckbox, MnConfigService, MnConfirmationBodyComponent, MnCustomBodyHostComponent, MnDatetime, MnDualHorizontalImage, MnFormBodyComponent, MnHiddenBelowDirective, MnHttpService, MnIcon, MnIconAttributes, MnInformationCard, MnInputField, MnInstanceDirective, MnLanguageService, MnList, MnModalRef, MnModalService, MnModalShellComponent, MnMultiSelect, MnSectionDirective, MnSelect, MnTabComponent, MnTable, MnTextarea, MnTranslatePipe, MnWizardBodyComponent, ModalBuilder, ModalCloseReason, ModalIntent, ModalKind, ModalSize, NavigationDirection, OptionState, SelectionMode, StepBuilder, StepState, SubmitMode, UpcomingEventRowComponent, UpcomingEventsComponent, ValidationCode, ValidationStatus, WizardFlowMode, WizardModalBuilder, dateTimeAdapter, defaultTextAdapter, enableMnPreviewMode, isTranslatable, mnAlertVariants, mnBadgeVariants, mnButtonVariants, mnCheckboxVariants, mnCheckboxWrapperVariants, mnDatetimeVariants, mnIconVariants, mnInformationCardVariants, mnInputFieldVariants, mnMultiSelectVariants, mnSelectVariants, mnTextareaVariants, numberAdapter, pickAdapter, provideMnAlerts, provideMnCalendarConfig, provideMnComponentConfig, provideMnConfig, provideMnLanguage, resolveCalendarConfig };
|
|
8165
8264
|
//# sourceMappingURL=mn-angular-lib.mjs.map
|