ngx-t-forms-types 0.0.26 → 0.0.27

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.
@@ -38,7 +38,9 @@ export declare enum ElementEditorTypes {
38
38
  MapMatOptionsKeys = "mapMatOptionsKeys",
39
39
  FormPayloadProjection = "formPayloadProjection",
40
40
  /** Opt-in JSON body template ({@link PayloadTemplate}) for a POST value/options fetch. */
41
- PayloadTemplate = "payloadTemplate"
41
+ PayloadTemplate = "payloadTemplate",
42
+ /** JSON request-header template ({@link HeaderTemplate}) for a value/options fetch (GET and POST alike). */
43
+ HeaderTemplate = "headerTemplate"
42
44
  }
43
45
  export interface ElementEditorConfigInterface {
44
46
  editorSections: Array<ElementEditorConfigSectionInterface>;
@@ -33,6 +33,8 @@ export var ElementEditorTypes;
33
33
  ElementEditorTypes["FormPayloadProjection"] = "formPayloadProjection";
34
34
  /** Opt-in JSON body template ({@link PayloadTemplate}) for a POST value/options fetch. */
35
35
  ElementEditorTypes["PayloadTemplate"] = "payloadTemplate";
36
+ /** JSON request-header template ({@link HeaderTemplate}) for a value/options fetch (GET and POST alike). */
37
+ ElementEditorTypes["HeaderTemplate"] = "headerTemplate";
36
38
  })(ElementEditorTypes || (ElementEditorTypes = {}));
37
39
  // interface TStringExpressionValidationTest{
38
40
  // expression: string;
@@ -848,6 +848,26 @@ export var ElementConfig = {
848
848
  label: 'Configure MongoDB pipeline',
849
849
  id: "7b2989ae-2f54-4849-93d0-aff56ac12ef2"
850
850
  },
851
+ {
852
+ name: SpecialElementKeys.Default,
853
+ deepBind: ['matOptions', 'fetch', 'value', 'headerTemplate'],
854
+ additionalTest: [
855
+ {
856
+ // Headers are a transport concern — offered for GET and POST
857
+ // alike, but only once an API endpoint has been selected.
858
+ expression: `source === ${DataSources.Api}`,
859
+ deepBind: ['matOptions', 'fetch', 'value', 'source'],
860
+ },
861
+ {
862
+ testType: 'exists',
863
+ deepBind: ['matOptions', 'fetch', 'value', 'httpEndPoint'],
864
+ },
865
+ ],
866
+ hint: `Author the request headers as JSON. Type $ to bind a header to a live field value; every other literal is a fixed default. The fetch waits until every bound field has a value.`,
867
+ editType: ElementEditorTypes.HeaderTemplate,
868
+ label: 'Request headers',
869
+ id: "f4b1c8d2-6e35-4a71-9f08-3c7d2b6a5e14"
870
+ },
851
871
  {
852
872
  name: SpecialElementKeys.Default,
853
873
  deepBind: ['matOptions', 'fetch', 'value', 'backEndConfig', 'requestBodyMode'],
@@ -1035,6 +1055,26 @@ export var ElementConfig = {
1035
1055
  label: 'Select API to fetch data from',
1036
1056
  id: "df9e2a34-7bf5-411e-a265-14ca4f85166d"
1037
1057
  },
1058
+ {
1059
+ name: SpecialElementKeys.Default,
1060
+ deepBind: ['matOptions', 'fetch', 'options', 'headerTemplate'],
1061
+ additionalTest: [
1062
+ {
1063
+ // Headers are a transport concern — offered for GET and POST
1064
+ // alike, but only once an API endpoint has been selected.
1065
+ expression: `source === ${DataSources.Api}`,
1066
+ deepBind: ['matOptions', 'fetch', 'options', 'source'],
1067
+ },
1068
+ {
1069
+ testType: 'exists',
1070
+ deepBind: ['matOptions', 'fetch', 'options', 'httpEndPoint'],
1071
+ },
1072
+ ],
1073
+ hint: `Author the request headers as JSON. Type $ to bind a header to a live field value; every other literal is a fixed default. The fetch waits until every bound field has a value.`,
1074
+ editType: ElementEditorTypes.HeaderTemplate,
1075
+ label: 'Request headers',
1076
+ id: "9a5e7c30-2d84-4b16-8e5f-6b0c4d1a7f92"
1077
+ },
1038
1078
  {
1039
1079
  name: SpecialElementKeys.Default,
1040
1080
  deepBind: ['matOptions', 'fetch', 'options', 'backEndConfig', 'requestBodyMode'],
@@ -1,5 +1,6 @@
1
1
  import { IStoreFunctions } from "./IStoreFunctions.js";
2
2
  import { Moment } from 'moment';
3
+ import type { FormSubmissionHandleInterface } from "../Form/formSubmissionHandleInterface.js";
3
4
  export interface IFinancialCycles {
4
5
  CURRENT_FINANCIAL_CYCLE: string;
5
6
  CURRENT_FINANCIAL_CYCLE_START_DATE: Moment;
@@ -16,5 +17,37 @@ export interface IFinancialCycles {
16
17
  export interface NgxTFormsConfig {
17
18
  base_url?: string;
18
19
  formBuilder: IStoreFunctions;
20
+ /**
21
+ * Submission configuration pre-inserted into every NEW form the builder creates.
22
+ *
23
+ * Applies ONLY at new-form creation. Forms loaded from storage keep whatever they
24
+ * already carry — including nothing — so an author can delete the pre-inserted
25
+ * endpoints and have that stick. Changing this value never rewrites existing forms.
26
+ *
27
+ * The value is deep-copied per form, so the builder editing one form's submission
28
+ * config can never mutate this object or leak into the next new form. API entry
29
+ * `_id`s are copied verbatim, so the same default yields the same ids across forms.
30
+ *
31
+ * Omit it and new forms start with `{ submissionAPI: [] }`, exactly as before.
32
+ *
33
+ * @example
34
+ * provideNgxTForms({
35
+ * formBuilder: myStoreFunctions,
36
+ * defaultSubmissionHandle: {
37
+ * innerComponentShowSubmitButton: false,
38
+ * submissionAPI: [{
39
+ * _id: '80eca6b1-923a-4c0e-a863-2f56a7e52a67',
40
+ * name: 'Generate/Update WF Document',
41
+ * httpEndPoint: '{{$iserve-back-end-url}}/api/form/generateWFFormValues',
42
+ * httpMethod: 'POST',
43
+ * postFormData: true,
44
+ * backEndConfig: { minimumInputRequired: [] },
45
+ * source: DataSources.Api,
46
+ * projectFormData: 'data:{$formValue}',
47
+ * }],
48
+ * },
49
+ * })
50
+ */
51
+ defaultSubmissionHandle?: FormSubmissionHandleInterface;
19
52
  [key: string]: string | Object | undefined;
20
53
  }
@@ -65,6 +65,44 @@ export type PayloadTemplate = {
65
65
  * configuration.
66
66
  */
67
67
  export type RequestBodyMode = 'mappedInputs' | 'template';
68
+ /**
69
+ * A single header value in a {@link HeaderTemplate}.
70
+ *
71
+ * Scalars only — an HTTP header value is text on the wire, so a number/boolean
72
+ * literal is stringified at request time. Nesting is deliberately not expressible:
73
+ * a header has no structure to nest into.
74
+ */
75
+ export type HeaderTemplateValue = string | number | boolean;
76
+ /**
77
+ * Declarative request headers for a value/options fetch, authored in the same
78
+ * JSON editor as {@link PayloadTemplate} and resolved with the same
79
+ * `{{inputId}}` token syntax.
80
+ *
81
+ * A value that is EXACTLY `"{{inputId}}"` is replaced by that input's live value
82
+ * (stringified); a value that merely CONTAINS token(s) is interpolated
83
+ * (`"Bearer {{accessToken}}"`); every other literal is a fixed default. Header
84
+ * names are always literal.
85
+ *
86
+ * Applies to GET as well as POST — headers are a transport concern, not a body
87
+ * concern. The resolved map is merged into
88
+ * {@link APIDataFetchingConfigurationInterface.httpHeaderOptions}`.headers`
89
+ * (the template wins on a name collision) before the request is issued.
90
+ *
91
+ * Like a payload template, a token that resolves empty keeps the fetch **idle**:
92
+ * a request that would go out without its `Authorization`/tenant header is a
93
+ * request that fails, so the engine waits for the bound field instead of issuing
94
+ * a doomed call.
95
+ *
96
+ * @example
97
+ * headerTemplate: {
98
+ * Authorization: 'Bearer {{accessToken}}',
99
+ * 'x-tenant-id': '{{municipality}}',
100
+ * 'Content-Type': 'application/json',
101
+ * }
102
+ */
103
+ export type HeaderTemplate = {
104
+ [headerName: string]: HeaderTemplateValue;
105
+ };
68
106
  export interface APIDataFetchingConfigurationInterface extends DataFetchingBaseConfig {
69
107
  _id: string;
70
108
  name: string;
@@ -89,6 +127,19 @@ export interface APIDataFetchingConfigurationInterface extends DataFetchingBaseC
89
127
  includeHeaders?: string[];
90
128
  } | boolean;
91
129
  };
130
+ /**
131
+ * Author-configured request headers, optionally bound to live form values (see
132
+ * {@link HeaderTemplate}). Merged over {@link httpHeaderOptions}`.headers` at
133
+ * request time; absent means "send exactly what `httpHeaderOptions` says",
134
+ * which is the historical behaviour.
135
+ */
136
+ headerTemplate?: HeaderTemplate;
137
+ /**
138
+ * The headers captured from the selected endpoint (e.g. the Postman request's
139
+ * enabled headers). Persisted only to seed {@link headerTemplate}'s editor so
140
+ * it never opens blank; never sent on its own.
141
+ */
142
+ capturedHeaders?: HeaderTemplate;
92
143
  backEndConfig: {
93
144
  /**
94
145
  * The default/mapTo mapping that shapes the POST body in `'mappedInputs'` mode.
@@ -1,7 +1,7 @@
1
1
  import { IFolderItem, IPostmanCollection } from "../FormBuilder/postmanCollection.js";
2
2
  import { IWorkflowDocListCols, IWorkflowStepOption } from "../FormBuilder/workflowSelectionConfig.js";
3
3
  import { TreeNode } from "../FormSlide/accessTree.js";
4
- import { APIDataFetchingConfigurationInterface, InputAPIDataId, MongoDbPipeLineConfigInterface, PayloadTemplate, PayloadTemplateValue, RequestBodyMode } from "./APIDataFetchingConfigurationInterface.js";
4
+ import { APIDataFetchingConfigurationInterface, HeaderTemplate, HeaderTemplateValue, InputAPIDataId, MongoDbPipeLineConfigInterface, PayloadTemplate, PayloadTemplateValue, RequestBodyMode } from "./APIDataFetchingConfigurationInterface.js";
5
5
  import { AutocapitalizeOptions, AutocompleteOptions, ElementTypes, IBasicFormInput, IFormElementTemplate, InputDataTypes, InputPipeTypes, InputTypes, OptionSelectTypes } from "./BasicFormInputInterface.js";
6
6
  import { IDateRangePickerInput } from "./DateRangePickerInput.js";
7
7
  import { AllDocumentFileExtensions, AllImageFileExtensions, FileUploadInputValueInterface, IFileUploadInput, InputFileType, UploadTypes } from "./FileUploadInputInterface.js";
@@ -25,4 +25,4 @@ import { CalculationFunctions, calculationVariableInterface } from "./calculatio
25
25
  import { IRichTextEditor, RichTextEditorType } from "./RichTextEditorInput.js";
26
26
  import { ValidationError, ValidationOptions } from "./schema.js";
27
27
  import { IUserSignature } from "./userSignature.js";
28
- export { ElementTypes, InputTypes, InputPipeTypes, AutocapitalizeOptions, AutocompleteOptions, InputDataTypes, MinInputTypes, IFormElementTemplate, IBasicFormInput, IFileUploadInput, IDateRangePickerInput, ITextareaProperties, IToggleInput, IMatrixInput, IMultiple, IMultipleInputCal, IScoaInput, TableConfigurationsInterface, TableColumnConfigInterface, FormControlCustomValidatorsInterface, InputObservedForChange, DraftFormControlCustomValidator, IFormValidationOverride, MinimumInputRequiredInterface, MinInputMapInput, CalculatedFieldRules, calculationVariableInterface, APIDataFetchingConfigurationInterface, PayloadTemplate, PayloadTemplateValue, RequestBodyMode, IGetTreeResponse, CalculationFunctions, TreeNode, IPostmanCollection, IFolderItem, FileUploadInputValueInterface, AllDocumentFileExtensions, AllImageFileExtensions, UploadTypes, InputFileType, IScoaAccount, IScoaInputConfig, ITableScoaSelectionRow, ScoaSegmentValue, ScoaSegmentValueBag, IIncludedSegmentConfig, AccountingBasis, ScoaAccountTree, IUserSignature, ValidationOptions, ValidationError, MatDataOptionsInterface, MongoDbPipeLineConfigInterface, InputAPIDataId, FormInputBasicOptionInterface, ScoaInterface, ScoaInnerInput, IAccountSegmentTreeKeys, IWorkflowDocumentPicker, IWorkflowDocumentPickerConfig, IWorkflowDocumentStepFilter, IDocumentPickerFilter, IDocumentPage, IDocumentQueryRequest, IDocumentReference, DocumentPickerFilterOperator, DocumentPickerFilterValueSource, DocumentPickerFilterValueType, DOCUMENT_PICKER_FILTER_OPERATORS, DOCUMENT_PICKER_FILTER_VALUE_SOURCES, DOCUMENT_PICKER_FILTER_VALUE_TYPES, workflowStepStatus, IWorkflowDocListCols, IWorkflowStepOption, JsDataTypes, AdjudicationSteps, IWorkflowAdjudicationInput, WorkflowAdjudicationScoreSheetValue, WorkflowAdjudicationMicroFlowReviewValue, WorkflowAdjudicationResponseElectedSupplierSelectionValue, ScoreSheetItem, AdjResponseReviewColumnMapping, OptionSelectTypes, ISelectInputInterface, MultipleInputAvailableOperations, RichTextEditorType, IRichTextEditor, };
28
+ export { ElementTypes, InputTypes, InputPipeTypes, AutocapitalizeOptions, AutocompleteOptions, InputDataTypes, MinInputTypes, IFormElementTemplate, IBasicFormInput, IFileUploadInput, IDateRangePickerInput, ITextareaProperties, IToggleInput, IMatrixInput, IMultiple, IMultipleInputCal, IScoaInput, TableConfigurationsInterface, TableColumnConfigInterface, FormControlCustomValidatorsInterface, InputObservedForChange, DraftFormControlCustomValidator, IFormValidationOverride, MinimumInputRequiredInterface, MinInputMapInput, CalculatedFieldRules, calculationVariableInterface, APIDataFetchingConfigurationInterface, PayloadTemplate, PayloadTemplateValue, RequestBodyMode, HeaderTemplate, HeaderTemplateValue, IGetTreeResponse, CalculationFunctions, TreeNode, IPostmanCollection, IFolderItem, FileUploadInputValueInterface, AllDocumentFileExtensions, AllImageFileExtensions, UploadTypes, InputFileType, IScoaAccount, IScoaInputConfig, ITableScoaSelectionRow, ScoaSegmentValue, ScoaSegmentValueBag, IIncludedSegmentConfig, AccountingBasis, ScoaAccountTree, IUserSignature, ValidationOptions, ValidationError, MatDataOptionsInterface, MongoDbPipeLineConfigInterface, InputAPIDataId, FormInputBasicOptionInterface, ScoaInterface, ScoaInnerInput, IAccountSegmentTreeKeys, IWorkflowDocumentPicker, IWorkflowDocumentPickerConfig, IWorkflowDocumentStepFilter, IDocumentPickerFilter, IDocumentPage, IDocumentQueryRequest, IDocumentReference, DocumentPickerFilterOperator, DocumentPickerFilterValueSource, DocumentPickerFilterValueType, DOCUMENT_PICKER_FILTER_OPERATORS, DOCUMENT_PICKER_FILTER_VALUE_SOURCES, DOCUMENT_PICKER_FILTER_VALUE_TYPES, workflowStepStatus, IWorkflowDocListCols, IWorkflowStepOption, JsDataTypes, AdjudicationSteps, IWorkflowAdjudicationInput, WorkflowAdjudicationScoreSheetValue, WorkflowAdjudicationMicroFlowReviewValue, WorkflowAdjudicationResponseElectedSupplierSelectionValue, ScoreSheetItem, AdjResponseReviewColumnMapping, OptionSelectTypes, ISelectInputInterface, MultipleInputAvailableOperations, RichTextEditorType, IRichTextEditor, };
@@ -22,6 +22,8 @@ const minimumInputRequiredSchema = Joi.object({
22
22
  activeChangeId: Joi.string().optional(),
23
23
  primaryKey: Joi.boolean().optional()
24
24
  });
25
+ /** A flat `header name → scalar value` map (see `HeaderTemplate`). */
26
+ const headerTemplateSchema = Joi.object().pattern(Joi.string(), Joi.alternatives().try(Joi.string().allow(''), Joi.number(), Joi.boolean()));
25
27
  const APIDataFetchingConfigurationSchema = Joi.object({
26
28
  _id: Joi.string().required(),
27
29
  name: Joi.string().required(),
@@ -42,6 +44,12 @@ const APIDataFetchingConfigurationSchema = Joi.object({
42
44
  withCredentials: Joi.boolean().optional(),
43
45
  transferCache: Joi.alternatives().try(Joi.object({ includeHeaders: Joi.array().items(Joi.string()).optional() }), Joi.boolean()).optional()
44
46
  }).optional(),
47
+ // Author-configured headers, values optionally carrying {{inputId}} tokens bound to
48
+ // live form values. Flat by construction — a header value is text on the wire, so
49
+ // only scalars are accepted (numbers/booleans are stringified at request time).
50
+ headerTemplate: headerTemplateSchema.optional(),
51
+ // Headers captured from the selected endpoint; seeds the editor, never sent alone.
52
+ capturedHeaders: headerTemplateSchema.optional(),
45
53
  backEndConfig: Joi.object({
46
54
  // Optional: a 'template'-mode fetch shapes its body from payloadTemplate and
47
55
  // carries no mapping; GET fetches never had one. Readers default it to [].
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngx-t-forms-types",
3
- "version": "0.0.26",
3
+ "version": "0.0.27",
4
4
  "description": "Typings and interfaces for the ngx-t-forms library for dynamic forms.",
5
5
  "keywords": [
6
6
  "typings",