@vendasta/forms_microservice 0.0.4 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,35 @@ import * as i1 from '@angular/common/http';
4
4
  import { HttpHeaders } from '@angular/common/http';
5
5
  import { map } from 'rxjs/operators';
6
6
 
7
+ // *********************************
8
+ // Code generated by sdkgen
9
+ // DO NOT EDIT!.
10
+ //
11
+ // Enums.
12
+ // *********************************
13
+ var FieldType;
14
+ (function (FieldType) {
15
+ FieldType[FieldType["FIELD_TYPE_INVALID"] = 0] = "FIELD_TYPE_INVALID";
16
+ FieldType[FieldType["FIELD_TYPE_STRING"] = 1] = "FIELD_TYPE_STRING";
17
+ FieldType[FieldType["FIELD_TYPE_INTEGER"] = 2] = "FIELD_TYPE_INTEGER";
18
+ FieldType[FieldType["FIELD_TYPE_DATE"] = 3] = "FIELD_TYPE_DATE";
19
+ FieldType[FieldType["FIELD_TYPE_DROPDOWN"] = 4] = "FIELD_TYPE_DROPDOWN";
20
+ FieldType[FieldType["FIELD_TYPE_CURRENCY"] = 5] = "FIELD_TYPE_CURRENCY";
21
+ })(FieldType || (FieldType = {}));
22
+ var RenderFormRequestJsonSchemaLibrary;
23
+ (function (RenderFormRequestJsonSchemaLibrary) {
24
+ RenderFormRequestJsonSchemaLibrary[RenderFormRequestJsonSchemaLibrary["RENDER_FORM_REQUEST_JSON_SCHEMA_LIBRARY_UNDEFINED"] = 0] = "RENDER_FORM_REQUEST_JSON_SCHEMA_LIBRARY_UNDEFINED";
25
+ RenderFormRequestJsonSchemaLibrary[RenderFormRequestJsonSchemaLibrary["RENDER_FORM_REQUEST_JSON_SCHEMA_LIBRARY_JSONFORM"] = 1] = "RENDER_FORM_REQUEST_JSON_SCHEMA_LIBRARY_JSONFORM";
26
+ })(RenderFormRequestJsonSchemaLibrary || (RenderFormRequestJsonSchemaLibrary = {}));
27
+
28
+ // *********************************
29
+
30
+ function enumStringToValue$1(enumRef, value) {
31
+ if (typeof value === 'number') {
32
+ return value;
33
+ }
34
+ return enumRef[value];
35
+ }
7
36
  class PagedRequestOptions {
8
37
  constructor(kwargs) {
9
38
  if (!kwargs) {
@@ -60,6 +89,12 @@ class PagedResponseMetadata {
60
89
  }
61
90
  }
62
91
 
92
+ function enumStringToValue(enumRef, value) {
93
+ if (typeof value === 'number') {
94
+ return value;
95
+ }
96
+ return enumRef[value];
97
+ }
63
98
  class CreateFormRequest {
64
99
  constructor(kwargs) {
65
100
  if (!kwargs) {
@@ -129,6 +164,134 @@ class CreateFormSubmissionRequest {
129
164
  return toReturn;
130
165
  }
131
166
  }
167
+ class FormConfigFieldDefault {
168
+ constructor(kwargs) {
169
+ if (!kwargs) {
170
+ return;
171
+ }
172
+ Object.assign(this, kwargs);
173
+ }
174
+ static fromProto(proto) {
175
+ let m = new FormConfigFieldDefault();
176
+ m = Object.assign(m, proto);
177
+ if (proto.integer) {
178
+ m.integer = parseInt(proto.integer, 10);
179
+ }
180
+ if (proto.date) {
181
+ m.date = new Date(proto.date);
182
+ }
183
+ if (proto.currency) {
184
+ m.currency = parseInt(proto.currency, 10);
185
+ }
186
+ return m;
187
+ }
188
+ toApiJson() {
189
+ const toReturn = {};
190
+ if (typeof this.invalid !== 'undefined') {
191
+ toReturn['invalid'] = this.invalid;
192
+ }
193
+ if (typeof this.integer !== 'undefined') {
194
+ toReturn['integer'] = this.integer;
195
+ }
196
+ if (typeof this.string !== 'undefined') {
197
+ toReturn['string'] = this.string;
198
+ }
199
+ if (typeof this.date !== 'undefined' && this.date !== null) {
200
+ toReturn['date'] = 'toApiJson' in this.date ? this.date.toApiJson() : this.date;
201
+ }
202
+ if (typeof this.dropdown !== 'undefined') {
203
+ toReturn['dropdown'] = this.dropdown;
204
+ }
205
+ if (typeof this.currency !== 'undefined') {
206
+ toReturn['currency'] = this.currency;
207
+ }
208
+ return toReturn;
209
+ }
210
+ }
211
+ class DeleteFormRequest {
212
+ constructor(kwargs) {
213
+ if (!kwargs) {
214
+ return;
215
+ }
216
+ Object.assign(this, kwargs);
217
+ }
218
+ static fromProto(proto) {
219
+ let m = new DeleteFormRequest();
220
+ m = Object.assign(m, proto);
221
+ return m;
222
+ }
223
+ toApiJson() {
224
+ const toReturn = {};
225
+ if (typeof this.formId !== 'undefined') {
226
+ toReturn['formId'] = this.formId;
227
+ }
228
+ if (typeof this.version !== 'undefined') {
229
+ toReturn['version'] = this.version;
230
+ }
231
+ return toReturn;
232
+ }
233
+ }
234
+ class FormConfigFieldUnmappedFieldDropdownOption {
235
+ constructor(kwargs) {
236
+ if (!kwargs) {
237
+ return;
238
+ }
239
+ Object.assign(this, kwargs);
240
+ }
241
+ static fromProto(proto) {
242
+ let m = new FormConfigFieldUnmappedFieldDropdownOption();
243
+ m = Object.assign(m, proto);
244
+ return m;
245
+ }
246
+ toApiJson() {
247
+ const toReturn = {};
248
+ if (typeof this.value !== 'undefined') {
249
+ toReturn['value'] = this.value;
250
+ }
251
+ if (typeof this.label !== 'undefined') {
252
+ toReturn['label'] = this.label;
253
+ }
254
+ return toReturn;
255
+ }
256
+ }
257
+ class FormConfigField {
258
+ constructor(kwargs) {
259
+ if (!kwargs) {
260
+ return;
261
+ }
262
+ Object.assign(this, kwargs);
263
+ }
264
+ static fromProto(proto) {
265
+ let m = new FormConfigField();
266
+ m = Object.assign(m, proto);
267
+ if (proto.schema) {
268
+ m.schema = FormConfigFieldSchema.fromProto(proto.schema);
269
+ }
270
+ if (proto.default) {
271
+ m.default = FormConfigFieldDefault.fromProto(proto.default);
272
+ }
273
+ return m;
274
+ }
275
+ toApiJson() {
276
+ const toReturn = {};
277
+ if (typeof this.schema !== 'undefined' && this.schema !== null) {
278
+ toReturn['schema'] = 'toApiJson' in this.schema ? this.schema.toApiJson() : this.schema;
279
+ }
280
+ if (typeof this.label !== 'undefined') {
281
+ toReturn['label'] = this.label;
282
+ }
283
+ if (typeof this.default !== 'undefined' && this.default !== null) {
284
+ toReturn['default'] = 'toApiJson' in this.default ? this.default.toApiJson() : this.default;
285
+ }
286
+ if (typeof this.required !== 'undefined') {
287
+ toReturn['required'] = this.required;
288
+ }
289
+ if (typeof this.hidden !== 'undefined') {
290
+ toReturn['hidden'] = this.hidden;
291
+ }
292
+ return toReturn;
293
+ }
294
+ }
132
295
  class ListFormsRequestFilters {
133
296
  constructor(kwargs) {
134
297
  if (!kwargs) {
@@ -162,6 +325,9 @@ class FormConfig {
162
325
  if (proto.styles) {
163
326
  m.styles = Styles.fromProto(proto.styles);
164
327
  }
328
+ if (proto.fields) {
329
+ m.fields = proto.fields.map(FormConfigField.fromProto);
330
+ }
165
331
  if (proto.created) {
166
332
  m.created = new Date(proto.created);
167
333
  }
@@ -181,11 +347,8 @@ class FormConfig {
181
347
  if (typeof this.styles !== 'undefined' && this.styles !== null) {
182
348
  toReturn['styles'] = 'toApiJson' in this.styles ? this.styles.toApiJson() : this.styles;
183
349
  }
184
- if (typeof this.schema !== 'undefined') {
185
- toReturn['schema'] = this.schema;
186
- }
187
- if (typeof this.uiSchema !== 'undefined') {
188
- toReturn['uiSchema'] = this.uiSchema;
350
+ if (typeof this.fields !== 'undefined' && this.fields !== null) {
351
+ toReturn['fields'] = 'toApiJson' in this.fields ? this.fields.toApiJson() : this.fields;
189
352
  }
190
353
  if (typeof this.formType !== 'undefined') {
191
354
  toReturn['formType'] = this.formType;
@@ -218,6 +381,9 @@ class ListFormsResponseFormRow {
218
381
  if (proto.form) {
219
382
  m.form = FormConfig.fromProto(proto.form);
220
383
  }
384
+ if (proto.numberOfSubmissions) {
385
+ m.numberOfSubmissions = parseInt(proto.numberOfSubmissions, 10);
386
+ }
221
387
  return m;
222
388
  }
223
389
  toApiJson() {
@@ -225,6 +391,9 @@ class ListFormsResponseFormRow {
225
391
  if (typeof this.form !== 'undefined' && this.form !== null) {
226
392
  toReturn['form'] = 'toApiJson' in this.form ? this.form.toApiJson() : this.form;
227
393
  }
394
+ if (typeof this.numberOfSubmissions !== 'undefined') {
395
+ toReturn['numberOfSubmissions'] = this.numberOfSubmissions;
396
+ }
228
397
  return toReturn;
229
398
  }
230
399
  }
@@ -395,6 +564,84 @@ class ListFormsResponse {
395
564
  return toReturn;
396
565
  }
397
566
  }
567
+ class RenderFormRequest {
568
+ constructor(kwargs) {
569
+ if (!kwargs) {
570
+ return;
571
+ }
572
+ Object.assign(this, kwargs);
573
+ }
574
+ static fromProto(proto) {
575
+ let m = new RenderFormRequest();
576
+ m = Object.assign(m, proto);
577
+ if (proto.library) {
578
+ m.library = enumStringToValue(RenderFormRequestJsonSchemaLibrary, proto.library);
579
+ }
580
+ return m;
581
+ }
582
+ toApiJson() {
583
+ const toReturn = {};
584
+ if (typeof this.formId !== 'undefined') {
585
+ toReturn['formId'] = this.formId;
586
+ }
587
+ if (typeof this.library !== 'undefined') {
588
+ toReturn['library'] = this.library;
589
+ }
590
+ return toReturn;
591
+ }
592
+ }
593
+ class RenderFormResponse {
594
+ constructor(kwargs) {
595
+ if (!kwargs) {
596
+ return;
597
+ }
598
+ Object.assign(this, kwargs);
599
+ }
600
+ static fromProto(proto) {
601
+ let m = new RenderFormResponse();
602
+ m = Object.assign(m, proto);
603
+ if (proto.styles) {
604
+ m.styles = Styles.fromProto(proto.styles);
605
+ }
606
+ return m;
607
+ }
608
+ toApiJson() {
609
+ const toReturn = {};
610
+ if (typeof this.jsonSchema !== 'undefined') {
611
+ toReturn['jsonSchema'] = this.jsonSchema;
612
+ }
613
+ if (typeof this.jsonUiSchema !== 'undefined') {
614
+ toReturn['jsonUiSchema'] = this.jsonUiSchema;
615
+ }
616
+ if (typeof this.styles !== 'undefined' && this.styles !== null) {
617
+ toReturn['styles'] = 'toApiJson' in this.styles ? this.styles.toApiJson() : this.styles;
618
+ }
619
+ return toReturn;
620
+ }
621
+ }
622
+ class FormConfigFieldSchema {
623
+ constructor(kwargs) {
624
+ if (!kwargs) {
625
+ return;
626
+ }
627
+ Object.assign(this, kwargs);
628
+ }
629
+ static fromProto(proto) {
630
+ let m = new FormConfigFieldSchema();
631
+ m = Object.assign(m, proto);
632
+ if (proto.unmappedField) {
633
+ m.unmappedField = FormConfigFieldUnmappedField.fromProto(proto.unmappedField);
634
+ }
635
+ return m;
636
+ }
637
+ toApiJson() {
638
+ const toReturn = {};
639
+ if (typeof this.unmappedField !== 'undefined' && this.unmappedField !== null) {
640
+ toReturn['unmappedField'] = 'toApiJson' in this.unmappedField ? this.unmappedField.toApiJson() : this.unmappedField;
641
+ }
642
+ return toReturn;
643
+ }
644
+ }
398
645
  class Styles {
399
646
  constructor(kwargs) {
400
647
  if (!kwargs) {
@@ -436,6 +683,41 @@ class Styles {
436
683
  return toReturn;
437
684
  }
438
685
  }
686
+ class FormConfigFieldUnmappedField {
687
+ constructor(kwargs) {
688
+ if (!kwargs) {
689
+ return;
690
+ }
691
+ Object.assign(this, kwargs);
692
+ }
693
+ static fromProto(proto) {
694
+ let m = new FormConfigFieldUnmappedField();
695
+ m = Object.assign(m, proto);
696
+ if (proto.type) {
697
+ m.type = enumStringToValue(FieldType, proto.type);
698
+ }
699
+ if (proto.dropdownOptions) {
700
+ m.dropdownOptions = proto.dropdownOptions.map(FormConfigFieldUnmappedFieldDropdownOption.fromProto);
701
+ }
702
+ return m;
703
+ }
704
+ toApiJson() {
705
+ const toReturn = {};
706
+ if (typeof this.id !== 'undefined') {
707
+ toReturn['id'] = this.id;
708
+ }
709
+ if (typeof this.type !== 'undefined') {
710
+ toReturn['type'] = this.type;
711
+ }
712
+ if (typeof this.dropdownOptions !== 'undefined' && this.dropdownOptions !== null) {
713
+ toReturn['dropdownOptions'] = 'toApiJson' in this.dropdownOptions ? this.dropdownOptions.toApiJson() : this.dropdownOptions;
714
+ }
715
+ if (typeof this.currencyCode !== 'undefined') {
716
+ toReturn['currencyCode'] = this.currencyCode;
717
+ }
718
+ return toReturn;
719
+ }
720
+ }
439
721
  class UpdateFormRequest {
440
722
  constructor(kwargs) {
441
723
  if (!kwargs) {
@@ -647,6 +929,15 @@ class FormsApiService {
647
929
  return this.http.post(this._host + "/forms.v1.Forms/ValidateForm", request.toApiJson(), this.apiOptions())
648
930
  .pipe(map(resp => ValidateFormResponse.fromProto(resp)));
649
931
  }
932
+ renderForm(r) {
933
+ const request = (r.toApiJson) ? r : new RenderFormRequest(r);
934
+ return this.http.post(this._host + "/forms.v1.Forms/RenderForm", request.toApiJson(), this.apiOptions())
935
+ .pipe(map(resp => RenderFormResponse.fromProto(resp)));
936
+ }
937
+ deleteForm(r) {
938
+ const request = (r.toApiJson) ? r : new DeleteFormRequest(r);
939
+ return this.http.post(this._host + "/forms.v1.Forms/DeleteForm", request.toApiJson(), Object.assign(Object.assign({}, this.apiOptions()), { observe: 'response' }));
940
+ }
650
941
  }
651
942
  FormsApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: FormsApiService, deps: [{ token: i1.HttpClient }, { token: HostService }], target: i0.ɵɵFactoryTarget.Injectable });
652
943
  FormsApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: FormsApiService, providedIn: 'root' });
@@ -663,5 +954,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImpor
663
954
  * Generated bundle index. Do not edit.
664
955
  */
665
956
 
666
- export { CreateFormRequest, CreateFormResponse, CreateFormSubmissionRequest, FormConfig, FormSubmission, FormSubmissionApiService, FormsApiService, GetEmbedCodeRequest, GetEmbedCodeResponse, GetFormRequest, GetFormResponse, HostService, ListFormsRequest, ListFormsRequestFilters, ListFormsResponse, ListFormsResponseFormRow, PagedRequestOptions, PagedResponseMetadata, Styles, UpdateFormRequest, UpdateFormResponse, ValidateFormRequest, ValidateFormResponse, ValidateFormResponseValidationError };
957
+ export { CreateFormRequest, CreateFormResponse, CreateFormSubmissionRequest, DeleteFormRequest, FieldType, FormConfig, FormConfigField, FormConfigFieldDefault, FormConfigFieldSchema, FormConfigFieldUnmappedField, FormConfigFieldUnmappedFieldDropdownOption, FormSubmission, FormSubmissionApiService, FormsApiService, GetEmbedCodeRequest, GetEmbedCodeResponse, GetFormRequest, GetFormResponse, HostService, ListFormsRequest, ListFormsRequestFilters, ListFormsResponse, ListFormsResponseFormRow, PagedRequestOptions, PagedResponseMetadata, RenderFormRequest, RenderFormRequestJsonSchemaLibrary, RenderFormResponse, Styles, UpdateFormRequest, UpdateFormResponse, ValidateFormRequest, ValidateFormResponse, ValidateFormResponseValidationError };
667
958
  //# sourceMappingURL=vendasta-forms_microservice.mjs.map