@esolve/ng-esolve-connect 0.143.0 → 0.144.0
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/fesm2022/esolve-ng-esolve-connect.mjs +437 -4
- package/fesm2022/esolve-ng-esolve-connect.mjs.map +1 -1
- package/index.d.ts +1190 -678
- package/package.json +1 -1
|
@@ -304,7 +304,7 @@ class EsolveCategoryTreeItem {
|
|
|
304
304
|
get tiny_image_src() {
|
|
305
305
|
return this.getImagePath('tiny');
|
|
306
306
|
}
|
|
307
|
-
constructor(type, esolve_id, parent_id, description, sef_description, short_description, sort_priority, active, display_only, image_name, seo_title, seo_keywords, seo_description, children) {
|
|
307
|
+
constructor(type, esolve_id, parent_id, description, sef_description, short_description, sort_priority, active, display_only, image_name, seo_title, seo_keywords, seo_description, children, cart_sort, stock_sort) {
|
|
308
308
|
this.type = type;
|
|
309
309
|
this.esolve_id = esolve_id;
|
|
310
310
|
this.parent_id = parent_id;
|
|
@@ -316,6 +316,8 @@ class EsolveCategoryTreeItem {
|
|
|
316
316
|
this.display_only = display_only;
|
|
317
317
|
this.image_name = image_name;
|
|
318
318
|
this.id = '';
|
|
319
|
+
this.cart_sort = null;
|
|
320
|
+
this.stock_sort = null;
|
|
319
321
|
this.image_path = '';
|
|
320
322
|
if (this.type === 'category') {
|
|
321
323
|
this.id = `<<CAT>>${this.esolve_id}`;
|
|
@@ -332,6 +334,18 @@ class EsolveCategoryTreeItem {
|
|
|
332
334
|
seo_title = this.description;
|
|
333
335
|
}
|
|
334
336
|
this.seo_details = new EsolveSeoInfo(seo_title, seo_description, seo_keywords);
|
|
337
|
+
if (cart_sort) {
|
|
338
|
+
this.cart_sort = {
|
|
339
|
+
field: cart_sort.sort,
|
|
340
|
+
order: cart_sort.order,
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
if (stock_sort) {
|
|
344
|
+
this.stock_sort = {
|
|
345
|
+
field: stock_sort.sort,
|
|
346
|
+
order: stock_sort.order,
|
|
347
|
+
};
|
|
348
|
+
}
|
|
335
349
|
}
|
|
336
350
|
getImagePath(image_size) {
|
|
337
351
|
if (this.image_name !== '') {
|
|
@@ -473,13 +487,13 @@ class EsolveCategoryTreeService {
|
|
|
473
487
|
esolve_id = tree_record.id;
|
|
474
488
|
parent_id = tree_record.menu_id;
|
|
475
489
|
}
|
|
476
|
-
tree_items.push(new EsolveCategoryTreeItem(tree_record.type, esolve_id, parent_id, tree_record.description, tree_record.sef_description, tree_record.seo_description, tree_record.sort_priority, tree_record.active, tree_record.display_only, tree_record.image, tree_record.seo_page_title, tree_record.seo_keywords, tree_record.short_description, children));
|
|
490
|
+
tree_items.push(new EsolveCategoryTreeItem(tree_record.type, esolve_id, parent_id, tree_record.description, tree_record.sef_description, tree_record.seo_description, tree_record.sort_priority, tree_record.active, tree_record.display_only, tree_record.image, tree_record.seo_page_title, tree_record.seo_keywords, tree_record.short_description, children, tree_record.cart_sort, tree_record.stock_sort));
|
|
477
491
|
}
|
|
478
492
|
}
|
|
479
493
|
return tree_items;
|
|
480
494
|
}
|
|
481
495
|
processTreeItem(record) {
|
|
482
|
-
return new EsolveCategoryTreeItem(record.type, record.id, record.parent_id, record.description, record.sef_description, record.short_description, record.sort_priority, record.active, record.display_only, record.image, record.seo_page_title, record.seo_keywords, record.seo_description);
|
|
496
|
+
return new EsolveCategoryTreeItem(record.type, record.id, record.parent_id, record.description, record.sef_description, record.short_description, record.sort_priority, record.active, record.display_only, record.image, record.seo_page_title, record.seo_keywords, record.seo_description, undefined, record.cart_sort, record.stock_sort);
|
|
483
497
|
}
|
|
484
498
|
processID(id) {
|
|
485
499
|
let type;
|
|
@@ -6207,6 +6221,7 @@ class EsolveLocation {
|
|
|
6207
6221
|
this.website_url = record.website_url;
|
|
6208
6222
|
this.image_name = record.image_name ?? '';
|
|
6209
6223
|
this.image_last_modified = record.image_last_modified ?? '';
|
|
6224
|
+
this.sef_name = record.sef_name ?? '';
|
|
6210
6225
|
this.address = new EsolveLocationAddress(record.street, record.suburb, record.city, record.province, record.country, record.postal_code, +record.latitude, +record.longitude);
|
|
6211
6226
|
this.pobox_address = new EsolveLocationPOBoxAddress(record.pobox, record.pobox_city, record.pobox_postal_code);
|
|
6212
6227
|
const telnumbers = [];
|
|
@@ -8941,6 +8956,79 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImpo
|
|
|
8941
8956
|
}]
|
|
8942
8957
|
}] });
|
|
8943
8958
|
|
|
8959
|
+
class EsolveEnquiryFormField {
|
|
8960
|
+
constructor(record) {
|
|
8961
|
+
this.id = 0;
|
|
8962
|
+
this.identifier = '';
|
|
8963
|
+
this.type = '';
|
|
8964
|
+
this.label = '';
|
|
8965
|
+
this.description = '';
|
|
8966
|
+
this.required = false;
|
|
8967
|
+
this.placeholder = '';
|
|
8968
|
+
this.character_length = 255;
|
|
8969
|
+
this.options = [];
|
|
8970
|
+
this.accept = '';
|
|
8971
|
+
this.layout_row = 0;
|
|
8972
|
+
if (record) {
|
|
8973
|
+
this.id = +(record.id ?? 0);
|
|
8974
|
+
this.identifier = record.identifier ?? '';
|
|
8975
|
+
this.type = record.type ?? '';
|
|
8976
|
+
this.label = record.label ?? '';
|
|
8977
|
+
this.description = record.description ?? '';
|
|
8978
|
+
this.required = !!record.required;
|
|
8979
|
+
this.layout_row = +(record.layout_row ?? 0);
|
|
8980
|
+
if ('placeholder' in record) {
|
|
8981
|
+
this.placeholder = record.placeholder ?? '';
|
|
8982
|
+
}
|
|
8983
|
+
if ('character_length' in record) {
|
|
8984
|
+
this.character_length = +(record.character_length ?? 255);
|
|
8985
|
+
}
|
|
8986
|
+
if ('options' in record) {
|
|
8987
|
+
this.options = record.options ?? [];
|
|
8988
|
+
}
|
|
8989
|
+
if ('accept' in record) {
|
|
8990
|
+
this.accept = record.accept ?? '';
|
|
8991
|
+
}
|
|
8992
|
+
}
|
|
8993
|
+
}
|
|
8994
|
+
}
|
|
8995
|
+
|
|
8996
|
+
class EsolveEnquiryFormSubmissionResult {
|
|
8997
|
+
constructor(result) {
|
|
8998
|
+
this.success = false;
|
|
8999
|
+
this.message = '';
|
|
9000
|
+
this.invalid_field_identifiers = [];
|
|
9001
|
+
this.success = result.success;
|
|
9002
|
+
this.message = result.message;
|
|
9003
|
+
this.invalid_field_identifiers =
|
|
9004
|
+
result.invalid_field_identifiers ?? [];
|
|
9005
|
+
}
|
|
9006
|
+
}
|
|
9007
|
+
|
|
9008
|
+
class EsolveEnquiryForm {
|
|
9009
|
+
constructor(record) {
|
|
9010
|
+
this.id = 0;
|
|
9011
|
+
this.identifier = '';
|
|
9012
|
+
this.title = '';
|
|
9013
|
+
this.description = '';
|
|
9014
|
+
this.success_message = '';
|
|
9015
|
+
this.fields = [];
|
|
9016
|
+
if (record) {
|
|
9017
|
+
this.id = +(record.id ?? 0);
|
|
9018
|
+
this.identifier = record.identifier ?? '';
|
|
9019
|
+
this.title = record.title ?? '';
|
|
9020
|
+
this.description = record.description ?? '';
|
|
9021
|
+
this.success_message = record.success_message ?? '';
|
|
9022
|
+
this.fields = this.processFields(record.fields ?? []);
|
|
9023
|
+
}
|
|
9024
|
+
}
|
|
9025
|
+
processFields(fields) {
|
|
9026
|
+
return fields.map((field) => {
|
|
9027
|
+
return new EsolveEnquiryFormField(field);
|
|
9028
|
+
});
|
|
9029
|
+
}
|
|
9030
|
+
}
|
|
9031
|
+
|
|
8944
9032
|
class EsolveEnquiryResult extends EsolveResponseResult {
|
|
8945
9033
|
constructor(response) {
|
|
8946
9034
|
super(response);
|
|
@@ -8949,6 +9037,80 @@ class EsolveEnquiryResult extends EsolveResponseResult {
|
|
|
8949
9037
|
}
|
|
8950
9038
|
}
|
|
8951
9039
|
|
|
9040
|
+
class EsolveEnquiryFormsService {
|
|
9041
|
+
constructor() {
|
|
9042
|
+
this.http = inject(HttpClient);
|
|
9043
|
+
this.config = inject(EsolveConfigService);
|
|
9044
|
+
this.errorHandler = inject(EsolveErrorHandlerService);
|
|
9045
|
+
}
|
|
9046
|
+
/**
|
|
9047
|
+
* Fetch an enquiry form definition by its id or string identifier.
|
|
9048
|
+
*
|
|
9049
|
+
* @param params - Either `{ id: number }` or `{ identifier: string }`
|
|
9050
|
+
*
|
|
9051
|
+
* @returns an Observable of type EsolveEnquiryForm
|
|
9052
|
+
*/
|
|
9053
|
+
getEnquiryForm(params) {
|
|
9054
|
+
let httpParams = new HttpParams();
|
|
9055
|
+
if ('id' in params) {
|
|
9056
|
+
httpParams = httpParams.set('enquiry_forms_id', params.id);
|
|
9057
|
+
}
|
|
9058
|
+
else {
|
|
9059
|
+
httpParams = httpParams.set('identifier', params.identifier);
|
|
9060
|
+
}
|
|
9061
|
+
return this.http
|
|
9062
|
+
.get(`${this.config.api_url}/get-enquiry-form.php`, { params: httpParams })
|
|
9063
|
+
.pipe(map((response) => {
|
|
9064
|
+
const record = response.records;
|
|
9065
|
+
if (!record || Array.isArray(record)) {
|
|
9066
|
+
throw response;
|
|
9067
|
+
}
|
|
9068
|
+
return new EsolveEnquiryForm(record);
|
|
9069
|
+
}));
|
|
9070
|
+
}
|
|
9071
|
+
/**
|
|
9072
|
+
* Submit a completed enquiry form.
|
|
9073
|
+
*
|
|
9074
|
+
* Resolves with the submit result — does not reject on validation failure.
|
|
9075
|
+
* Check `result.success` and `result.invalid_field_identifiers` to handle
|
|
9076
|
+
* field-level validation errors without clearing the form.
|
|
9077
|
+
*
|
|
9078
|
+
* Captcha fields (`captcha_key`, `captcha_code`) should be appended to
|
|
9079
|
+
* `form_data` by the caller when captcha is enabled.
|
|
9080
|
+
*
|
|
9081
|
+
* @param params - Either `{ id: number }` or `{ identifier: string }`
|
|
9082
|
+
* @param form_data - Completed form data; file fields appended as `File` objects
|
|
9083
|
+
*
|
|
9084
|
+
* @returns an Observable of type EsolveEnquiryFormSubmissionResult
|
|
9085
|
+
*/
|
|
9086
|
+
submitEnquiryForm(params, form_data) {
|
|
9087
|
+
let http_params = new HttpParams();
|
|
9088
|
+
if ('id' in params) {
|
|
9089
|
+
http_params = http_params.set('enquiry_forms_id', params.id);
|
|
9090
|
+
}
|
|
9091
|
+
else {
|
|
9092
|
+
http_params = http_params.set('identifier', params.identifier);
|
|
9093
|
+
}
|
|
9094
|
+
return this.http
|
|
9095
|
+
.post(`${this.config.api_url}/set-enquiry-form-submission.php`, form_data, {
|
|
9096
|
+
responseType: 'json',
|
|
9097
|
+
observe: 'body',
|
|
9098
|
+
params: http_params,
|
|
9099
|
+
})
|
|
9100
|
+
.pipe(map((http_response) => new EsolveEnquiryFormSubmissionResult(http_response.additional_data)), catchError((errorRes) => {
|
|
9101
|
+
return this.errorHandler.handleHttpPostError('set-enquiry-form-submission', errorRes);
|
|
9102
|
+
}));
|
|
9103
|
+
}
|
|
9104
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: EsolveEnquiryFormsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
9105
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: EsolveEnquiryFormsService, providedIn: 'root' }); }
|
|
9106
|
+
}
|
|
9107
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: EsolveEnquiryFormsService, decorators: [{
|
|
9108
|
+
type: Injectable,
|
|
9109
|
+
args: [{
|
|
9110
|
+
providedIn: 'root',
|
|
9111
|
+
}]
|
|
9112
|
+
}] });
|
|
9113
|
+
|
|
8952
9114
|
class EsolveEnquiryService {
|
|
8953
9115
|
constructor() {
|
|
8954
9116
|
this.config = inject(EsolveConfigService);
|
|
@@ -9652,6 +9814,76 @@ class EsolveCompetitionEntryResult extends EsolveResponseResult {
|
|
|
9652
9814
|
}
|
|
9653
9815
|
}
|
|
9654
9816
|
|
|
9817
|
+
class EsolveCompetitionEntry {
|
|
9818
|
+
constructor(record) {
|
|
9819
|
+
this.id = '';
|
|
9820
|
+
this.code = '';
|
|
9821
|
+
this.title = '';
|
|
9822
|
+
this.submitted_by = '';
|
|
9823
|
+
this.file_type = 'image';
|
|
9824
|
+
this.file_url = '';
|
|
9825
|
+
this.preview_url = '';
|
|
9826
|
+
this.date_submitted = '';
|
|
9827
|
+
this.status = 'pending';
|
|
9828
|
+
this.up_votes = 0;
|
|
9829
|
+
this.down_votes = 0;
|
|
9830
|
+
this.has_voted = false;
|
|
9831
|
+
if (record) {
|
|
9832
|
+
this.id = record.id ?? '';
|
|
9833
|
+
this.code = record.code ?? '';
|
|
9834
|
+
this.title = record.title ?? '';
|
|
9835
|
+
this.submitted_by = record.submitted_by ?? '';
|
|
9836
|
+
this.file_type = record.file_type ?? 'image';
|
|
9837
|
+
this.file_url = record.file_url ?? '';
|
|
9838
|
+
this.preview_url = record.preview_url ?? '';
|
|
9839
|
+
this.date_submitted = record.date_submitted ?? '';
|
|
9840
|
+
this.status = record.status ?? 'pending';
|
|
9841
|
+
this.up_votes = +(record.up_votes ?? 0);
|
|
9842
|
+
this.down_votes = +(record.down_votes ?? 0);
|
|
9843
|
+
this.has_voted = !!record.has_voted;
|
|
9844
|
+
this.text_content = record.text_content;
|
|
9845
|
+
}
|
|
9846
|
+
}
|
|
9847
|
+
}
|
|
9848
|
+
|
|
9849
|
+
/**
|
|
9850
|
+
* Public competition statistics returned by the `get-competitions.php` service.
|
|
9851
|
+
*/
|
|
9852
|
+
class EsolveCompetitionStats {
|
|
9853
|
+
constructor(record) {
|
|
9854
|
+
/**
|
|
9855
|
+
* Total approved entries submitted to the competition.
|
|
9856
|
+
*/
|
|
9857
|
+
this.total_entries = 0;
|
|
9858
|
+
/**
|
|
9859
|
+
* Total up + down votes cast across all competition entries.
|
|
9860
|
+
*/
|
|
9861
|
+
this.total_votes = 0;
|
|
9862
|
+
if (record) {
|
|
9863
|
+
this.total_entries = +(record.total_entries ?? 0);
|
|
9864
|
+
this.total_votes = +(record.total_votes ?? 0);
|
|
9865
|
+
}
|
|
9866
|
+
}
|
|
9867
|
+
}
|
|
9868
|
+
|
|
9869
|
+
class EsolveCompetitionVoteResult extends EsolveResponseResult {
|
|
9870
|
+
constructor(record) {
|
|
9871
|
+
super(record);
|
|
9872
|
+
this.success = false;
|
|
9873
|
+
this.entry_id = '';
|
|
9874
|
+
this.dowhat = 'up';
|
|
9875
|
+
this.up_votes = 0;
|
|
9876
|
+
this.down_votes = 0;
|
|
9877
|
+
this.has_voted = false;
|
|
9878
|
+
this.success = true;
|
|
9879
|
+
this.entry_id = record.entry_id ?? '';
|
|
9880
|
+
this.dowhat = record.dowhat ?? 'up';
|
|
9881
|
+
this.up_votes = +(record.up_votes ?? 0);
|
|
9882
|
+
this.down_votes = +(record.down_votes ?? 0);
|
|
9883
|
+
this.has_voted = !!record.has_voted;
|
|
9884
|
+
}
|
|
9885
|
+
}
|
|
9886
|
+
|
|
9655
9887
|
class EsolveCompetitionWinner {
|
|
9656
9888
|
constructor(record) {
|
|
9657
9889
|
/**
|
|
@@ -9732,6 +9964,18 @@ class EsolveCompetition {
|
|
|
9732
9964
|
* Competition requires text submission
|
|
9733
9965
|
*/
|
|
9734
9966
|
this.require_text = false;
|
|
9967
|
+
/**
|
|
9968
|
+
* Allow document (PDF/PPTX/DOCX) submissions
|
|
9969
|
+
*/
|
|
9970
|
+
this.require_document = false;
|
|
9971
|
+
/**
|
|
9972
|
+
* Whether public voting on entries is enabled for this competition
|
|
9973
|
+
*/
|
|
9974
|
+
this.enable_voting = true;
|
|
9975
|
+
/**
|
|
9976
|
+
* Whether new entries require moderator approval before they appear
|
|
9977
|
+
*/
|
|
9978
|
+
this.require_approval = false;
|
|
9735
9979
|
/**
|
|
9736
9980
|
* List of competition winners
|
|
9737
9981
|
*/
|
|
@@ -9740,6 +9984,10 @@ class EsolveCompetition {
|
|
|
9740
9984
|
* Display a count down timer
|
|
9741
9985
|
*/
|
|
9742
9986
|
this.display_timer = false;
|
|
9987
|
+
/**
|
|
9988
|
+
* Public competition statistics (entries and votes)
|
|
9989
|
+
*/
|
|
9990
|
+
this.stats = new EsolveCompetitionStats();
|
|
9743
9991
|
if (record) {
|
|
9744
9992
|
this.id = +(record.id ?? 0);
|
|
9745
9993
|
this.identifier = record.identifier ?? '';
|
|
@@ -9762,8 +10010,14 @@ class EsolveCompetition {
|
|
|
9762
10010
|
this.require_audio = !!+(record.audio_attachment ?? false);
|
|
9763
10011
|
this.require_video = !!+(record.video_attachment ?? false);
|
|
9764
10012
|
this.require_image = !!+(record.image_attachment ?? false);
|
|
10013
|
+
this.require_document = !!+(record.document_attachment ?? false);
|
|
9765
10014
|
this.require_text = !!+(record.text ?? false);
|
|
10015
|
+
this.enable_voting = !!+(record.enable_voting ?? true);
|
|
10016
|
+
this.require_approval = !!+(record.require_approval ?? false);
|
|
9766
10017
|
this.display_timer = !!+(record.display_timer ?? false);
|
|
10018
|
+
if (record.stats) {
|
|
10019
|
+
this.stats = new EsolveCompetitionStats(record.stats);
|
|
10020
|
+
}
|
|
9767
10021
|
const winners = record.winners;
|
|
9768
10022
|
if (winners && winners.length > 0) {
|
|
9769
10023
|
for (const winner of winners) {
|
|
@@ -9859,6 +10113,49 @@ class EsolveCompetitionsService {
|
|
|
9859
10113
|
return this.errorHandler.handleHttpPostError('set-competition-entry', errorRes);
|
|
9860
10114
|
}));
|
|
9861
10115
|
}
|
|
10116
|
+
/**
|
|
10117
|
+
* Retrieve a paginated list of approved entries for a competition.
|
|
10118
|
+
*
|
|
10119
|
+
* @param competitions_id - eSolve ID of the competition.
|
|
10120
|
+
* @param page - 1-based page number (optional).
|
|
10121
|
+
* @param rows - entries per page (optional).
|
|
10122
|
+
*
|
|
10123
|
+
* @returns an Observable of EsolveCompetitionEntry[].
|
|
10124
|
+
*/
|
|
10125
|
+
getCompetitionEntries(competitions_id, page, rows) {
|
|
10126
|
+
let params = new HttpParams({
|
|
10127
|
+
fromObject: { competitions_id },
|
|
10128
|
+
});
|
|
10129
|
+
if (page != null) {
|
|
10130
|
+
params = params.set('page', page);
|
|
10131
|
+
}
|
|
10132
|
+
if (rows != null) {
|
|
10133
|
+
params = params.set('rows', rows);
|
|
10134
|
+
}
|
|
10135
|
+
return this.http
|
|
10136
|
+
.get(`${this.config.api_url}/get-competition-entries.php`, { params })
|
|
10137
|
+
.pipe(map$1((response) => (response.records ?? []).map((record) => new EsolveCompetitionEntry(record))), catchError$1(() => of([])));
|
|
10138
|
+
}
|
|
10139
|
+
/**
|
|
10140
|
+
* Cast or retract a vote on a competition entry.
|
|
10141
|
+
*
|
|
10142
|
+
* @param competition_entry_id - UUID of the entry to vote on.
|
|
10143
|
+
* @param dowhat - `'up'` to upvote (default) or `'down'` to downvote.
|
|
10144
|
+
*
|
|
10145
|
+
* @returns an Observable of EsolveCompetitionVoteResult.
|
|
10146
|
+
*/
|
|
10147
|
+
setCompetitionVote(competition_entry_id, dowhat = 'up') {
|
|
10148
|
+
const body = { competition_entry_id, dowhat };
|
|
10149
|
+
return this.http
|
|
10150
|
+
.post(`${this.config.api_url}/set-competition-vote.php`, body, {
|
|
10151
|
+
headers: {
|
|
10152
|
+
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
|
|
10153
|
+
},
|
|
10154
|
+
responseType: 'json',
|
|
10155
|
+
observe: 'body',
|
|
10156
|
+
})
|
|
10157
|
+
.pipe(map$1((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => new EsolveCompetitionVoteResult(response))), catchError$1((errorRes) => this.errorHandler.handleHttpPostError('set-competition-vote', errorRes)));
|
|
10158
|
+
}
|
|
9862
10159
|
getCompetitionSingle(params) {
|
|
9863
10160
|
return this.getCompetitionRecords(params).pipe(map$1((records) => {
|
|
9864
10161
|
const record = records[0];
|
|
@@ -11047,6 +11344,142 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImpo
|
|
|
11047
11344
|
}]
|
|
11048
11345
|
}] });
|
|
11049
11346
|
|
|
11347
|
+
/**
|
|
11348
|
+
* One labelled product grid within a `product_catalog` (`multi_grid`) chat
|
|
11349
|
+
* result — e.g. "Under R500", "Best sellers". `items` are built the same way
|
|
11350
|
+
* `EsolveChatIntentResult.items` builds `product_search` results, just
|
|
11351
|
+
* grouped under a label instead of a single flat list. `link` is an optional
|
|
11352
|
+
* "View more" target the consumer can build a route from — `null` when the
|
|
11353
|
+
* server couldn't resolve any of this group's filters to a real
|
|
11354
|
+
* category/subcategory/brand/tag.
|
|
11355
|
+
*/
|
|
11356
|
+
class EsolveChatProductGroup {
|
|
11357
|
+
constructor(record) {
|
|
11358
|
+
this.label = record.label ?? '';
|
|
11359
|
+
this.items = (record.items ?? []).map((r) => new EsolveStockItemBase(r));
|
|
11360
|
+
this.link = record.link ?? null;
|
|
11361
|
+
}
|
|
11362
|
+
}
|
|
11363
|
+
|
|
11364
|
+
class EsolveChatIntentResult {
|
|
11365
|
+
constructor(response) {
|
|
11366
|
+
this.intent = response.intent;
|
|
11367
|
+
this.parameters = response.parameters;
|
|
11368
|
+
this.reply = response.reply;
|
|
11369
|
+
this.history = response.history;
|
|
11370
|
+
this.context = response.context ?? '';
|
|
11371
|
+
this.display_hint = response.display_hint ?? 'text';
|
|
11372
|
+
this.suggestions = response.suggestions ?? [];
|
|
11373
|
+
const data = response.data;
|
|
11374
|
+
if ((this.intent === 'product_search' || this.intent === 'add_to_basket') &&
|
|
11375
|
+
Array.isArray(data)) {
|
|
11376
|
+
// For `add_to_basket`, `items` holds the single item that was added
|
|
11377
|
+
// to the cart (empty when no match was found or the add failed).
|
|
11378
|
+
this.items = data.map((r) => new EsolveStockItemBase(r));
|
|
11379
|
+
this.groups = [];
|
|
11380
|
+
this.locations = [];
|
|
11381
|
+
this.brands = [];
|
|
11382
|
+
}
|
|
11383
|
+
else if (this.intent === 'product_catalog' && Array.isArray(data)) {
|
|
11384
|
+
this.items = [];
|
|
11385
|
+
this.groups = data.map((g) => new EsolveChatProductGroup(g));
|
|
11386
|
+
this.locations = [];
|
|
11387
|
+
this.brands = [];
|
|
11388
|
+
}
|
|
11389
|
+
else if (this.intent === 'directions' && Array.isArray(data)) {
|
|
11390
|
+
this.items = [];
|
|
11391
|
+
this.groups = [];
|
|
11392
|
+
this.locations = data.map((r) => new EsolveLocation(r));
|
|
11393
|
+
this.brands = [];
|
|
11394
|
+
}
|
|
11395
|
+
else if (this.intent === 'list_brands' && Array.isArray(data)) {
|
|
11396
|
+
this.items = [];
|
|
11397
|
+
this.groups = [];
|
|
11398
|
+
this.locations = [];
|
|
11399
|
+
this.brands = data.map((r) => new EsolveManufacturer(r));
|
|
11400
|
+
}
|
|
11401
|
+
else {
|
|
11402
|
+
this.items = [];
|
|
11403
|
+
this.groups = [];
|
|
11404
|
+
this.locations = [];
|
|
11405
|
+
this.brands = [];
|
|
11406
|
+
}
|
|
11407
|
+
}
|
|
11408
|
+
}
|
|
11409
|
+
|
|
11410
|
+
class EsolveChatService {
|
|
11411
|
+
constructor() {
|
|
11412
|
+
this.http = inject(HttpClient);
|
|
11413
|
+
this.config = inject(EsolveConfigService);
|
|
11414
|
+
this.errorHandler = inject(EsolveErrorHandlerService);
|
|
11415
|
+
}
|
|
11416
|
+
/**
|
|
11417
|
+
* Send a free-text message to the chat assistant (AI classification).
|
|
11418
|
+
*
|
|
11419
|
+
* The caller is responsible for persisting `result.history` and
|
|
11420
|
+
* `result.context` between turns and passing them back on the next call.
|
|
11421
|
+
* The server caps history at 50 messages and summarises automatically.
|
|
11422
|
+
*
|
|
11423
|
+
* @param message The user's message (max 1024 chars; truncated server-side).
|
|
11424
|
+
* @param history History from the previous `EsolveChatIntentResult.history`.
|
|
11425
|
+
* Pass an empty array to start a new conversation.
|
|
11426
|
+
* @param context Pass back `EsolveChatIntentResult.context` from the previous
|
|
11427
|
+
* turn so the AI can answer follow-up questions about results
|
|
11428
|
+
* currently shown on screen. Omit or pass `null` / `''` when
|
|
11429
|
+
* there are no current results. Never stored in history.
|
|
11430
|
+
*/
|
|
11431
|
+
sendMessage(message, history = [], context) {
|
|
11432
|
+
const body = { message, history };
|
|
11433
|
+
if (context) {
|
|
11434
|
+
body.context = context;
|
|
11435
|
+
}
|
|
11436
|
+
return this.post(body);
|
|
11437
|
+
}
|
|
11438
|
+
/**
|
|
11439
|
+
* Dispatch a structured suggestion-chip tap directly — no AI round trip.
|
|
11440
|
+
*
|
|
11441
|
+
* Use this when the consumer taps a chip whose `intent` is a server intent
|
|
11442
|
+
* (`product_search`, `product_catalog`, `add_to_basket`, `directions`,
|
|
11443
|
+
* `list_brands`). Client-action intents (`view_cart`, `checkout`) are handled
|
|
11444
|
+
* locally by the consumer and never reach this method.
|
|
11445
|
+
*
|
|
11446
|
+
* @param intent One of the 5 server intents.
|
|
11447
|
+
* @param parameters The chip's `parameters` (sent back verbatim).
|
|
11448
|
+
* @param history History from the previous `EsolveChatIntentResult.history`.
|
|
11449
|
+
* @param phrase The chip's phrase, recorded as the user turn in history.
|
|
11450
|
+
* Omit to let the server fall back to `parameters.query`.
|
|
11451
|
+
*/
|
|
11452
|
+
dispatchIntent(intent, parameters, history = [], phrase) {
|
|
11453
|
+
const body = { intent, parameters, history };
|
|
11454
|
+
if (phrase) {
|
|
11455
|
+
body.phrase = phrase;
|
|
11456
|
+
}
|
|
11457
|
+
return this.post(body);
|
|
11458
|
+
}
|
|
11459
|
+
post(body) {
|
|
11460
|
+
return this.http
|
|
11461
|
+
.post(`${this.config.api_url}/set-chat-intent.php`, body)
|
|
11462
|
+
.pipe(map$1((response) => {
|
|
11463
|
+
if (response.type === 'error') {
|
|
11464
|
+
throw response;
|
|
11465
|
+
}
|
|
11466
|
+
const data = response.additional_data;
|
|
11467
|
+
if (Array.isArray(data) || !data) {
|
|
11468
|
+
throw response;
|
|
11469
|
+
}
|
|
11470
|
+
return new EsolveChatIntentResult(data);
|
|
11471
|
+
}), catchError$1((errorRes) => this.errorHandler.handleHttpPostError('set-chat-intent', errorRes)));
|
|
11472
|
+
}
|
|
11473
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: EsolveChatService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
11474
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: EsolveChatService, providedIn: 'root' }); }
|
|
11475
|
+
}
|
|
11476
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: EsolveChatService, decorators: [{
|
|
11477
|
+
type: Injectable,
|
|
11478
|
+
args: [{
|
|
11479
|
+
providedIn: 'root',
|
|
11480
|
+
}]
|
|
11481
|
+
}] });
|
|
11482
|
+
|
|
11050
11483
|
/*
|
|
11051
11484
|
* Public API Surface of ng-esolve-connect
|
|
11052
11485
|
*/
|
|
@@ -11055,5 +11488,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImpo
|
|
|
11055
11488
|
* Generated bundle index. Do not edit.
|
|
11056
11489
|
*/
|
|
11057
11490
|
|
|
11058
|
-
export { ESOLVE_CONNECT_CONFIG, ESOLVE_EURUS_AUTO_LOGIN, EsolveAccountConfirmationResult, EsolveAccountPayment, EsolveAccountService, EsolveAdditionalStockImage, EsolveAddress, EsolveAddressResult, EsolveAffiliate, EsolveAffiliateCheckResult, EsolveAffiliateLinkResult, EsolveAffiliateService, EsolveAlbum, EsolveAlbumImage, EsolveAlbumImageList, EsolveAlbumList, EsolveAlbumsService, EsolveAsset, EsolveAssetsService, EsolveAuthService, EsolveBankingDetails, EsolveBanner, EsolveBannerImage, EsolveBannerImageHotspot, EsolveBannerService, EsolveBannerVideo, EsolveCaptcha, EsolveCaptchaService, EsolveCareer, EsolveCareersService, EsolveCartAlternative, EsolveCartErrorHandlerService, EsolveCartItem, EsolveCartItemError, EsolveCartPromotionProgressItem, EsolveCartPromotionProgressQualifyingItem, EsolveCartService, EsolveCartStockItem, EsolveCartTaxBreakdown, EsolveCartTotals, EsolveCategoryTreeItem, EsolveCategoryTreeService, EsolveCdnSrcDirective, EsolveChangePasswordResult, EsolveCheckoutResult, EsolveClientAsset, EsolveClientAssetList, EsolveColour, EsolveColoursService, EsolveCompetition, EsolveCompetitionDates, EsolveCompetitionEntryResult, EsolveCompetitionWinner, EsolveCompetitionsService, EsolveConfigService, EsolveCookieService, EsolveCountry, EsolveCountryService, EsolveCoupon, EsolveCouponsService, EsolveDeliveriesService, EsolveDelivery, EsolveDeliveryCategoryTotals, EsolveDeliveryList, EsolveDeliveryStatus, EsolveDependantItem, EsolveDeviceService, EsolveEmptyCartResult, EsolveEmptyWishlistResult, EsolveEnquiryResult, EsolveEnquiryService, EsolveErpDocumentRequest, EsolveErpDocumentsRequestResult, EsolveErrorHandlerService, EsolveEvent, EsolveEventTargetService, EsolveEventType, EsolveFilterFactory, EsolveGenericFilter, EsolveGeocodeAddressResult, EsolveGeocodeCoordsResult, EsolveGeocodeResult, EsolveGeocoderService, EsolveHttpError, EsolveLinkedAsset, EsolveLinkedStockItem, EsolveList, EsolveLocation, EsolveLocationAddress, EsolveLocationContactInfo, EsolveLocationGEO, EsolveLocationList, EsolveLocationPOBoxAddress, EsolveLocationTradingDay, EsolveLocationTradingTimes, EsolveLocationUpdateResult, EsolveLocationsService, EsolveManufacturer, EsolveManufacturersService, EsolveMaterial, EsolveMaterialsService, EsolveMediaStockItem, EsolveMenuItem, EsolveMenuService, EsolveMultipleSelectFilter, EsolveNewsArticle, EsolveNewsArticleAuthor, EsolveNewsArticleList, EsolveNewsGroup, EsolveNewsService, EsolveNewsletterResult, EsolveNotificationButtonAction, EsolveNotificationDates, EsolveNotificationsService, EsolveOtp, EsolveOtpService, EsolveOtpValidation, EsolvePaymentMethod, EsolvePaymentResult, EsolvePaymentService, EsolveRange, EsolveRangeFilter, EsolveRangesService, EsolveRecipeStockItem, EsolveRegistrationResult, EsolveResetPasswordResult, EsolveResponseHandlerService, EsolveResponseResult, EsolveResult, EsolveReview, EsolveReviewList, EsolveReviewResult, EsolveReviewsService, EsolveSearchCleanResult, EsolveSearchResult, EsolveSearchResultItem, EsolveSearchService, EsolveSearchVectorizeResult, EsolveSeoInfo, EsolveSeoService, EsolveSessionAddressUpdateResult, EsolveSessionClientUpdateResult, EsolveSessionMetadataService, EsolveSessionService, EsolveSessionShippingUpdateResult, EsolveSetDeviceResult, EsolveSetNotifyResult, EsolveSettings, EsolveSettingsService, EsolveShippingCost, EsolveShippingCostItem, EsolveShippingMethod, EsolveShippingService, EsolveShippingTotals, EsolveSingleSelectFilter, EsolveSpecial, EsolveSpecialDates, EsolveSpecialImage, EsolveSpecialImageCollection, EsolveSpecialsService, EsolveStatement, EsolveStatementAgeing, EsolveStatementBalances, EsolveStatementTransaction, EsolveStockBadge, EsolveStockBarcode, EsolveStockGroup, EsolveStockGroupItem, EsolveStockImage, EsolveStockImageCollection, EsolveStockItem, EsolveStockItemBase, EsolveStockItemList, EsolveStockItemLocationLevel, EsolveStockLeadTimes, EsolveStockLinkedCategory, EsolveStockPrice, EsolveStockReviewsReport, EsolveStockService, EsolveStockTransactionSales, EsolveSuggestedStockItem, EsolveSupplier, EsolveSuppliersService, EsolveSystemNotification, EsolveSystemNotificationType, EsolveTag, EsolveTagsService, EsolveTimeSlot, EsolveTimeSlotConfig, EsolveTimeSlotDate, EsolveTimeSlotDays, EsolveTimeSlotTimes, EsolveToggleFilter, EsolveTopic, EsolveTopicService, EsolveTransaction, EsolveTransactionAddress, EsolveTransactionAnalyticsData, EsolveTransactionApprovalResult, EsolveTransactionClient, EsolveTransactionDelivery, EsolveTransactionItem, EsolveTransactionItemPrice, EsolveTransactionList, EsolveTransactionLocation, EsolveTransactionPaymentMethod, EsolveTransactionPick, EsolveTransactionShippingMethod, EsolveTransactionTimeSlot, EsolveTransactionUser, EsolveTransactionsService, EsolveUserAccount, EsolveUserAccountBusiness, EsolveUserAccountContact, EsolveUserAccountResult, EsolveUserClientAccount, EsolveUserClientAccountBalances, EsolveUserDevice, EsolveVaultItem, EsolveVaultItemResult, EsolveVoucher, EsolveVouchersService, EsolveWalletBalances, EsolveWalletService, EsolveWalletTransaction, EsolveWalletTransactionsList, EsolveWishlistItem, EsolveWishlistService, NgEsolveConnectModule, esolveAuthInterceptor, esolveHexHash, esolveUnauthorizedErrorInterceptor, isEsolveCdnPath, isFtgCdnPath, isLegacyEsolveCdnPath, processEsolveImageSrc, provideEsolveImageLoader, provideNgEsolveConnect };
|
|
11491
|
+
export { ESOLVE_CONNECT_CONFIG, ESOLVE_EURUS_AUTO_LOGIN, EsolveAccountConfirmationResult, EsolveAccountPayment, EsolveAccountService, EsolveAdditionalStockImage, EsolveAddress, EsolveAddressResult, EsolveAffiliate, EsolveAffiliateCheckResult, EsolveAffiliateLinkResult, EsolveAffiliateService, EsolveAlbum, EsolveAlbumImage, EsolveAlbumImageList, EsolveAlbumList, EsolveAlbumsService, EsolveAsset, EsolveAssetsService, EsolveAuthService, EsolveBankingDetails, EsolveBanner, EsolveBannerImage, EsolveBannerImageHotspot, EsolveBannerService, EsolveBannerVideo, EsolveCaptcha, EsolveCaptchaService, EsolveCareer, EsolveCareersService, EsolveCartAlternative, EsolveCartErrorHandlerService, EsolveCartItem, EsolveCartItemError, EsolveCartPromotionProgressItem, EsolveCartPromotionProgressQualifyingItem, EsolveCartService, EsolveCartStockItem, EsolveCartTaxBreakdown, EsolveCartTotals, EsolveCategoryTreeItem, EsolveCategoryTreeService, EsolveCdnSrcDirective, EsolveChangePasswordResult, EsolveChatIntentResult, EsolveChatProductGroup, EsolveChatService, EsolveCheckoutResult, EsolveClientAsset, EsolveClientAssetList, EsolveColour, EsolveColoursService, EsolveCompetition, EsolveCompetitionDates, EsolveCompetitionEntry, EsolveCompetitionEntryResult, EsolveCompetitionStats, EsolveCompetitionVoteResult, EsolveCompetitionWinner, EsolveCompetitionsService, EsolveConfigService, EsolveCookieService, EsolveCountry, EsolveCountryService, EsolveCoupon, EsolveCouponsService, EsolveDeliveriesService, EsolveDelivery, EsolveDeliveryCategoryTotals, EsolveDeliveryList, EsolveDeliveryStatus, EsolveDependantItem, EsolveDeviceService, EsolveEmptyCartResult, EsolveEmptyWishlistResult, EsolveEnquiryForm, EsolveEnquiryFormField, EsolveEnquiryFormSubmissionResult, EsolveEnquiryFormsService, EsolveEnquiryResult, EsolveEnquiryService, EsolveErpDocumentRequest, EsolveErpDocumentsRequestResult, EsolveErrorHandlerService, EsolveEvent, EsolveEventTargetService, EsolveEventType, EsolveFilterFactory, EsolveGenericFilter, EsolveGeocodeAddressResult, EsolveGeocodeCoordsResult, EsolveGeocodeResult, EsolveGeocoderService, EsolveHttpError, EsolveLinkedAsset, EsolveLinkedStockItem, EsolveList, EsolveLocation, EsolveLocationAddress, EsolveLocationContactInfo, EsolveLocationGEO, EsolveLocationList, EsolveLocationPOBoxAddress, EsolveLocationTradingDay, EsolveLocationTradingTimes, EsolveLocationUpdateResult, EsolveLocationsService, EsolveManufacturer, EsolveManufacturersService, EsolveMaterial, EsolveMaterialsService, EsolveMediaStockItem, EsolveMenuItem, EsolveMenuService, EsolveMultipleSelectFilter, EsolveNewsArticle, EsolveNewsArticleAuthor, EsolveNewsArticleList, EsolveNewsGroup, EsolveNewsService, EsolveNewsletterResult, EsolveNotificationButtonAction, EsolveNotificationDates, EsolveNotificationsService, EsolveOtp, EsolveOtpService, EsolveOtpValidation, EsolvePaymentMethod, EsolvePaymentResult, EsolvePaymentService, EsolveRange, EsolveRangeFilter, EsolveRangesService, EsolveRecipeStockItem, EsolveRegistrationResult, EsolveResetPasswordResult, EsolveResponseHandlerService, EsolveResponseResult, EsolveResult, EsolveReview, EsolveReviewList, EsolveReviewResult, EsolveReviewsService, EsolveSearchCleanResult, EsolveSearchResult, EsolveSearchResultItem, EsolveSearchService, EsolveSearchVectorizeResult, EsolveSeoInfo, EsolveSeoService, EsolveSessionAddressUpdateResult, EsolveSessionClientUpdateResult, EsolveSessionMetadataService, EsolveSessionService, EsolveSessionShippingUpdateResult, EsolveSetDeviceResult, EsolveSetNotifyResult, EsolveSettings, EsolveSettingsService, EsolveShippingCost, EsolveShippingCostItem, EsolveShippingMethod, EsolveShippingService, EsolveShippingTotals, EsolveSingleSelectFilter, EsolveSpecial, EsolveSpecialDates, EsolveSpecialImage, EsolveSpecialImageCollection, EsolveSpecialsService, EsolveStatement, EsolveStatementAgeing, EsolveStatementBalances, EsolveStatementTransaction, EsolveStockBadge, EsolveStockBarcode, EsolveStockGroup, EsolveStockGroupItem, EsolveStockImage, EsolveStockImageCollection, EsolveStockItem, EsolveStockItemBase, EsolveStockItemList, EsolveStockItemLocationLevel, EsolveStockLeadTimes, EsolveStockLinkedCategory, EsolveStockPrice, EsolveStockReviewsReport, EsolveStockService, EsolveStockTransactionSales, EsolveSuggestedStockItem, EsolveSupplier, EsolveSuppliersService, EsolveSystemNotification, EsolveSystemNotificationType, EsolveTag, EsolveTagsService, EsolveTimeSlot, EsolveTimeSlotConfig, EsolveTimeSlotDate, EsolveTimeSlotDays, EsolveTimeSlotTimes, EsolveToggleFilter, EsolveTopic, EsolveTopicService, EsolveTransaction, EsolveTransactionAddress, EsolveTransactionAnalyticsData, EsolveTransactionApprovalResult, EsolveTransactionClient, EsolveTransactionDelivery, EsolveTransactionItem, EsolveTransactionItemPrice, EsolveTransactionList, EsolveTransactionLocation, EsolveTransactionPaymentMethod, EsolveTransactionPick, EsolveTransactionShippingMethod, EsolveTransactionTimeSlot, EsolveTransactionUser, EsolveTransactionsService, EsolveUserAccount, EsolveUserAccountBusiness, EsolveUserAccountContact, EsolveUserAccountResult, EsolveUserClientAccount, EsolveUserClientAccountBalances, EsolveUserDevice, EsolveVaultItem, EsolveVaultItemResult, EsolveVoucher, EsolveVouchersService, EsolveWalletBalances, EsolveWalletService, EsolveWalletTransaction, EsolveWalletTransactionsList, EsolveWishlistItem, EsolveWishlistService, NgEsolveConnectModule, esolveAuthInterceptor, esolveHexHash, esolveUnauthorizedErrorInterceptor, isEsolveCdnPath, isFtgCdnPath, isLegacyEsolveCdnPath, processEsolveImageSrc, provideEsolveImageLoader, provideNgEsolveConnect };
|
|
11059
11492
|
//# sourceMappingURL=esolve-ng-esolve-connect.mjs.map
|