@researchdatabox/sails-ng-common 0.2.1 → 5.0.0-RC1

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 (237) hide show
  1. package/dist/src/config/base-field-component.model.d.ts +26 -0
  2. package/dist/src/config/base-field-component.model.js +29 -0
  3. package/dist/src/config/base-field-component.outline.d.ts +108 -0
  4. package/dist/src/config/base-field-component.outline.js +3 -0
  5. package/dist/src/config/component/accordion.model.d.ts +103 -0
  6. package/dist/src/config/component/accordion.model.js +127 -0
  7. package/dist/src/config/component/accordion.outline.d.ts +162 -0
  8. package/dist/src/config/component/accordion.outline.js +13 -0
  9. package/dist/src/config/component/action-row-layout.model.d.ts +28 -0
  10. package/dist/src/config/component/action-row-layout.model.js +35 -0
  11. package/dist/src/config/component/action-row-layout.outline.d.ts +36 -0
  12. package/dist/src/config/component/action-row-layout.outline.js +6 -0
  13. package/dist/src/config/component/cancel-button.model.d.ts +48 -0
  14. package/dist/src/config/component/cancel-button.model.js +58 -0
  15. package/dist/src/config/component/cancel-button.outline.d.ts +85 -0
  16. package/dist/src/config/component/cancel-button.outline.js +6 -0
  17. package/dist/src/config/component/checkbox-input.model.d.ts +67 -0
  18. package/dist/src/config/component/checkbox-input.model.js +79 -0
  19. package/dist/src/config/component/checkbox-input.outline.d.ts +93 -0
  20. package/dist/src/config/component/checkbox-input.outline.js +8 -0
  21. package/dist/src/config/component/checkbox-tree.model.d.ts +68 -0
  22. package/dist/src/config/component/checkbox-tree.model.js +80 -0
  23. package/dist/src/config/component/checkbox-tree.outline.d.ts +105 -0
  24. package/dist/src/config/component/checkbox-tree.outline.js +8 -0
  25. package/dist/src/config/component/content.model.d.ts +46 -0
  26. package/dist/src/config/component/content.model.js +56 -0
  27. package/dist/src/config/component/content.outline.d.ts +74 -0
  28. package/dist/src/config/component/content.outline.js +6 -0
  29. package/dist/src/config/component/data-location.model.d.ts +83 -0
  30. package/dist/src/config/component/data-location.model.js +95 -0
  31. package/dist/src/config/component/data-location.outline.d.ts +124 -0
  32. package/dist/src/config/component/data-location.outline.js +6 -0
  33. package/dist/src/config/component/date-input.model.d.ts +67 -0
  34. package/dist/src/config/component/date-input.model.js +80 -0
  35. package/dist/src/config/component/date-input.outline.d.ts +88 -0
  36. package/dist/src/config/component/date-input.outline.js +8 -0
  37. package/dist/src/config/component/default-layout.model.d.ts +22 -0
  38. package/dist/src/config/component/default-layout.model.js +30 -0
  39. package/dist/src/config/component/default-layout.outline.d.ts +29 -0
  40. package/dist/src/config/component/default-layout.outline.js +5 -0
  41. package/dist/src/config/component/delete-button.model.d.ts +46 -0
  42. package/dist/src/config/component/delete-button.model.js +48 -0
  43. package/dist/src/config/component/delete-button.outline.d.ts +89 -0
  44. package/dist/src/config/component/delete-button.outline.js +5 -0
  45. package/dist/src/config/component/dropdown-input.model.d.ts +65 -0
  46. package/dist/src/config/component/dropdown-input.model.js +78 -0
  47. package/dist/src/config/component/dropdown-input.outline.d.ts +92 -0
  48. package/dist/src/config/component/dropdown-input.outline.js +8 -0
  49. package/dist/src/config/component/file-upload.model.d.ts +67 -0
  50. package/dist/src/config/component/file-upload.model.js +81 -0
  51. package/dist/src/config/component/file-upload.outline.d.ts +99 -0
  52. package/dist/src/config/component/file-upload.outline.js +8 -0
  53. package/dist/src/config/component/group.model.d.ts +61 -0
  54. package/dist/src/config/component/group.model.js +75 -0
  55. package/dist/src/config/component/group.outline.d.ts +83 -0
  56. package/dist/src/config/component/group.outline.js +8 -0
  57. package/dist/src/config/component/inline-layout.model.d.ts +22 -0
  58. package/dist/src/config/component/inline-layout.model.js +29 -0
  59. package/dist/src/config/component/inline-layout.outline.d.ts +29 -0
  60. package/dist/src/config/component/inline-layout.outline.js +5 -0
  61. package/dist/src/config/component/integration-status.model.d.ts +49 -0
  62. package/dist/src/config/component/integration-status.model.js +65 -0
  63. package/dist/src/config/component/integration-status.outline.d.ts +61 -0
  64. package/dist/src/config/component/integration-status.outline.js +5 -0
  65. package/dist/src/config/component/map.model.d.ts +69 -0
  66. package/dist/src/config/component/map.model.js +86 -0
  67. package/dist/src/config/component/map.outline.d.ts +110 -0
  68. package/dist/src/config/component/map.outline.js +8 -0
  69. package/dist/src/config/component/pdf-list.model.d.ts +68 -0
  70. package/dist/src/config/component/pdf-list.model.js +71 -0
  71. package/dist/src/config/component/pdf-list.outline.d.ts +97 -0
  72. package/dist/src/config/component/pdf-list.outline.js +6 -0
  73. package/dist/src/config/component/publish-data-location-refresh.model.d.ts +39 -0
  74. package/dist/src/config/component/publish-data-location-refresh.model.js +52 -0
  75. package/dist/src/config/component/publish-data-location-refresh.outline.d.ts +58 -0
  76. package/dist/src/config/component/publish-data-location-refresh.outline.js +5 -0
  77. package/dist/src/config/component/publish-data-location-selector.model.d.ts +78 -0
  78. package/dist/src/config/component/publish-data-location-selector.model.js +104 -0
  79. package/dist/src/config/component/publish-data-location-selector.outline.d.ts +110 -0
  80. package/dist/src/config/component/publish-data-location-selector.outline.js +6 -0
  81. package/dist/src/config/component/question-tree.helper.d.ts +58 -0
  82. package/dist/src/config/component/question-tree.helper.js +291 -0
  83. package/dist/src/config/component/question-tree.model.d.ts +64 -0
  84. package/dist/src/config/component/question-tree.model.js +80 -0
  85. package/dist/src/config/component/question-tree.outline.d.ts +314 -0
  86. package/dist/src/config/component/question-tree.outline.js +9 -0
  87. package/dist/src/config/component/radio-input.model.d.ts +65 -0
  88. package/dist/src/config/component/radio-input.model.js +77 -0
  89. package/dist/src/config/component/radio-input.outline.d.ts +91 -0
  90. package/dist/src/config/component/radio-input.outline.js +8 -0
  91. package/dist/src/config/component/record-metadata-retriever.model.d.ts +41 -0
  92. package/dist/src/config/component/record-metadata-retriever.model.js +57 -0
  93. package/dist/src/config/component/record-metadata-retriever.outline.d.ts +53 -0
  94. package/dist/src/config/component/record-metadata-retriever.outline.js +5 -0
  95. package/dist/src/config/component/record-selector.model.d.ts +61 -0
  96. package/dist/src/config/component/record-selector.model.js +61 -0
  97. package/dist/src/config/component/record-selector.outline.d.ts +91 -0
  98. package/dist/src/config/component/record-selector.outline.js +6 -0
  99. package/dist/src/config/component/repeatable.model.d.ts +91 -0
  100. package/dist/src/config/component/repeatable.model.js +112 -0
  101. package/dist/src/config/component/repeatable.outline.d.ts +115 -0
  102. package/dist/src/config/component/repeatable.outline.js +10 -0
  103. package/dist/src/config/component/reusable.model.d.ts +42 -0
  104. package/dist/src/config/component/reusable.model.js +57 -0
  105. package/dist/src/config/component/reusable.outline.d.ts +55 -0
  106. package/dist/src/config/component/reusable.outline.js +6 -0
  107. package/dist/src/config/component/rich-text-editor.model.d.ts +65 -0
  108. package/dist/src/config/component/rich-text-editor.model.js +79 -0
  109. package/dist/src/config/component/rich-text-editor.outline.d.ts +92 -0
  110. package/dist/src/config/component/rich-text-editor.outline.js +8 -0
  111. package/dist/src/config/component/save-button.model.d.ts +49 -0
  112. package/dist/src/config/component/save-button.model.js +59 -0
  113. package/dist/src/config/component/save-button.outline.d.ts +90 -0
  114. package/dist/src/config/component/save-button.outline.js +6 -0
  115. package/dist/src/config/component/save-status.model.d.ts +42 -0
  116. package/dist/src/config/component/save-status.model.js +60 -0
  117. package/dist/src/config/component/save-status.outline.d.ts +58 -0
  118. package/dist/src/config/component/save-status.outline.js +6 -0
  119. package/dist/src/config/component/simple-input.model.d.ts +62 -0
  120. package/dist/src/config/component/simple-input.model.js +75 -0
  121. package/dist/src/config/component/simple-input.outline.d.ts +86 -0
  122. package/dist/src/config/component/simple-input.outline.js +9 -0
  123. package/dist/src/config/component/suggested-validation-summary.model.d.ts +45 -0
  124. package/dist/src/config/component/suggested-validation-summary.model.js +61 -0
  125. package/dist/src/config/component/suggested-validation-summary.outline.d.ts +57 -0
  126. package/dist/src/config/component/suggested-validation-summary.outline.js +5 -0
  127. package/dist/src/config/component/tab-content.model.d.ts +63 -0
  128. package/dist/src/config/component/tab-content.model.js +77 -0
  129. package/dist/src/config/component/tab-content.outline.d.ts +98 -0
  130. package/dist/src/config/component/tab-content.outline.js +8 -0
  131. package/dist/src/config/component/tab-nav-button.model.d.ts +45 -0
  132. package/dist/src/config/component/tab-nav-button.model.js +55 -0
  133. package/dist/src/config/component/tab-nav-button.outline.d.ts +70 -0
  134. package/dist/src/config/component/tab-nav-button.outline.js +6 -0
  135. package/dist/src/config/component/tab.model.d.ts +71 -0
  136. package/dist/src/config/component/tab.model.js +84 -0
  137. package/dist/src/config/component/tab.outline.d.ts +112 -0
  138. package/dist/src/config/component/tab.outline.js +9 -0
  139. package/dist/src/config/component/text-area.model.d.ts +63 -0
  140. package/dist/src/config/component/text-area.model.js +76 -0
  141. package/dist/src/config/component/text-area.outline.d.ts +87 -0
  142. package/dist/src/config/component/text-area.outline.js +8 -0
  143. package/dist/src/config/component/typeahead-input.model.d.ts +83 -0
  144. package/dist/src/config/component/typeahead-input.model.js +97 -0
  145. package/dist/src/config/component/typeahead-input.outline.d.ts +199 -0
  146. package/dist/src/config/component/typeahead-input.outline.js +10 -0
  147. package/dist/src/config/component/validation-summary.model.d.ts +42 -0
  148. package/dist/src/config/component/validation-summary.model.js +60 -0
  149. package/dist/src/config/component/validation-summary.outline.d.ts +63 -0
  150. package/dist/src/config/component/validation-summary.outline.js +6 -0
  151. package/dist/src/config/dictionary.model.d.ts +648 -0
  152. package/dist/src/config/dictionary.model.js +181 -0
  153. package/dist/src/config/dictionary.outline.d.ts +96 -0
  154. package/dist/src/config/dictionary.outline.js +3 -0
  155. package/dist/src/config/field-component.model.d.ts +7 -0
  156. package/dist/src/config/field-component.model.js +11 -0
  157. package/dist/src/config/field-component.outline.d.ts +20 -0
  158. package/dist/src/config/field-component.outline.js +3 -0
  159. package/dist/src/config/field-layout.model.d.ts +19 -0
  160. package/dist/src/config/field-layout.model.js +23 -0
  161. package/dist/src/config/field-layout.outline.d.ts +42 -0
  162. package/dist/src/config/field-layout.outline.js +3 -0
  163. package/dist/src/config/field-model.model.d.ts +21 -0
  164. package/dist/src/config/field-model.model.js +24 -0
  165. package/dist/src/config/field-model.outline.d.ts +63 -0
  166. package/dist/src/config/field-model.outline.js +3 -0
  167. package/dist/src/config/field.model.d.ts +12 -0
  168. package/dist/src/config/field.model.js +12 -0
  169. package/dist/src/config/field.outline.d.ts +19 -0
  170. package/dist/src/config/field.outline.js +3 -0
  171. package/dist/src/config/form-behaviour.outline.d.ts +128 -0
  172. package/dist/src/config/form-behaviour.outline.js +40 -0
  173. package/dist/src/config/form-component.model.d.ts +38 -0
  174. package/dist/src/config/form-component.model.js +36 -0
  175. package/dist/src/config/form-component.outline.d.ts +305 -0
  176. package/dist/src/config/form-component.outline.js +27 -0
  177. package/dist/src/config/form-config.model.d.ts +33 -0
  178. package/dist/src/config/form-config.model.js +36 -0
  179. package/dist/src/config/form-config.outline.d.ts +111 -0
  180. package/dist/src/config/form-config.outline.js +3 -0
  181. package/dist/src/config/form-override.model.d.ts +146 -0
  182. package/dist/src/config/form-override.model.js +1523 -0
  183. package/dist/src/config/form-override.outline.d.ts +15 -0
  184. package/dist/src/config/form-override.outline.js +3 -0
  185. package/dist/src/config/form-prehydrate.outline.d.ts +17 -0
  186. package/dist/src/config/form-prehydrate.outline.js +5 -0
  187. package/dist/src/config/form-types.model.d.ts +6 -0
  188. package/dist/src/config/form-types.model.js +23 -0
  189. package/dist/src/config/form-types.outline.d.ts +48 -0
  190. package/dist/src/config/form-types.outline.js +137 -0
  191. package/dist/src/config/helpers.d.ts +31 -0
  192. package/dist/src/config/helpers.js +122 -0
  193. package/dist/src/config/names/naming-helpers.d.ts +112 -0
  194. package/dist/src/config/names/naming-helpers.js +188 -0
  195. package/dist/src/config/names/query-helpers.d.ts +43 -0
  196. package/dist/src/config/names/query-helpers.js +59 -0
  197. package/dist/src/config/shared.outline.d.ts +54 -0
  198. package/dist/src/config/shared.outline.js +41 -0
  199. package/dist/src/config/visitor/base.model.d.ts +143 -0
  200. package/dist/src/config/visitor/base.model.js +336 -0
  201. package/dist/src/config/visitor/base.outline.d.ts +146 -0
  202. package/dist/src/config/visitor/base.outline.js +3 -0
  203. package/dist/src/config/visitor/common.model.d.ts +119 -0
  204. package/dist/src/config/visitor/common.model.js +422 -0
  205. package/dist/src/date-format-helpers.d.ts +1 -0
  206. package/dist/src/date-format-helpers.js +21 -0
  207. package/dist/src/handlebars-helpers.d.ts +258 -0
  208. package/dist/src/handlebars-helpers.js +715 -0
  209. package/dist/src/html-helpers.d.ts +15 -0
  210. package/dist/src/html-helpers.js +42 -0
  211. package/dist/src/index.d.ts +118 -3
  212. package/dist/src/index.js +127 -2
  213. package/dist/src/jsonata-helpers.d.ts +40 -0
  214. package/dist/src/jsonata-helpers.js +118 -0
  215. package/dist/src/logger.interface.d.ts +14 -0
  216. package/dist/src/logger.interface.js +3 -0
  217. package/dist/src/record.model.d.ts +23 -0
  218. package/dist/src/record.model.js +19 -1
  219. package/dist/src/report.model.d.ts +46 -0
  220. package/dist/src/status.model.d.ts +22 -0
  221. package/dist/src/status.model.js +28 -0
  222. package/dist/src/template.outline.d.ts +82 -0
  223. package/dist/src/template.outline.js +14 -0
  224. package/dist/src/translation-helpers.d.ts +26 -0
  225. package/dist/src/translation-helpers.js +71 -0
  226. package/dist/src/validation/form.model.d.ts +306 -24
  227. package/dist/src/validation/form.model.js +29 -1
  228. package/dist/src/validation/helpers.d.ts +15 -7
  229. package/dist/src/validation/helpers.js +49 -13
  230. package/dist/src/validation/validators-support.d.ts +39 -2
  231. package/dist/src/validation/validators-support.js +162 -12
  232. package/dist/src/validation/validators.d.ts +28 -0
  233. package/dist/src/validation/validators.js +531 -0
  234. package/package.json +51 -34
  235. package/LICENSE +0 -674
  236. package/dist/src/validation/index.d.ts +0 -3
  237. package/dist/src/validation/index.js +0 -20
@@ -0,0 +1,15 @@
1
+ import { FormModesConfig } from "./shared.outline";
2
+ import { AllFormComponentDefinitionOutlines } from "./dictionary.outline";
3
+ import { VisitorComponentClassNamesType } from "./dictionary.model";
4
+ import { FormOverrideModesClassConfig } from "./form-component.outline";
5
+ /**
6
+ * The type that specifies the known transformations.
7
+ */
8
+ export type KnownTransformsType = Partial<{
9
+ [key in VisitorComponentClassNamesType]: Partial<{
10
+ [key in VisitorComponentClassNamesType]: (source: any, formMode: FormModesConfig) => AllFormComponentDefinitionOutlines;
11
+ }>;
12
+ }>;
13
+ export type DefaultTransformsType = Partial<{
14
+ [key in VisitorComponentClassNamesType]: FormOverrideModesClassConfig;
15
+ }>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9ybS1vdmVycmlkZS5vdXRsaW5lLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NvbmZpZy9mb3JtLW92ZXJyaWRlLm91dGxpbmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
@@ -0,0 +1,17 @@
1
+ import { CheckboxTreeNode } from './component/checkbox-tree.outline';
2
+ export declare const FormPrehydrateRootKey: "__root__";
3
+ export interface VocabTreeChildrenResponse {
4
+ data: CheckboxTreeNode[];
5
+ meta: {
6
+ vocabularyId: string;
7
+ parentId: string | null;
8
+ total: number;
9
+ };
10
+ }
11
+ export interface FormPrehydrateVocabTreePayload {
12
+ childrenByParentId: Record<string, VocabTreeChildrenResponse>;
13
+ selectedNotations: string[];
14
+ }
15
+ export interface FormPrehydratePayload {
16
+ vocabTrees?: Record<string, FormPrehydrateVocabTreePayload>;
17
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FormPrehydrateRootKey = void 0;
4
+ exports.FormPrehydrateRootKey = '__root__';
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9ybS1wcmVoeWRyYXRlLm91dGxpbmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY29uZmlnL2Zvcm0tcHJlaHlkcmF0ZS5vdXRsaW5lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUVhLFFBQUEscUJBQXFCLEdBQUcsVUFBbUIsQ0FBQyJ9
@@ -0,0 +1,6 @@
1
+ import { FormValidatorDefinition } from "../validation/form.model";
2
+ /**
3
+ * Check if the item is a valid form validation definition.
4
+ * @param item The item to check.
5
+ */
6
+ export declare function isTypeFormValidatorDefinition(item: unknown): item is FormValidatorDefinition;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isTypeFormValidatorDefinition = isTypeFormValidatorDefinition;
4
+ const helpers_1 = require("./helpers");
5
+ /**
6
+ * Check if the item is a valid form validation definition.
7
+ * @param item The item to check.
8
+ */
9
+ function isTypeFormValidatorDefinition(item) {
10
+ if (item === undefined || item === null) {
11
+ return false;
12
+ }
13
+ const i = item;
14
+ const hasExpectedPropClass = 'class' in i && (0, helpers_1.guessType)(i.class) === 'string';
15
+ const hasExpectedPropClassValue = i.class?.toString()?.trim().length > 0;
16
+ const hasExpectedPropMessage = 'message' in i && (0, helpers_1.guessType)(i.message) === 'string';
17
+ const hasExpectedPropMessageValue = i.message?.toString()?.trim().length > 0;
18
+ const hasExpectedPropCreate = 'create' in i || 'createAsync' in i;
19
+ return hasExpectedPropClass && hasExpectedPropClassValue
20
+ && hasExpectedPropMessage && hasExpectedPropMessageValue
21
+ && hasExpectedPropCreate;
22
+ }
23
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9ybS10eXBlcy5tb2RlbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jb25maWcvZm9ybS10eXBlcy5tb2RlbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQVFBLHNFQWlCQztBQXpCRCx1Q0FBb0M7QUFJcEM7OztHQUdHO0FBQ0gsU0FBZ0IsNkJBQTZCLENBQUMsSUFBYTtJQUN2RCxJQUFJLElBQUksS0FBSyxTQUFTLElBQUksSUFBSSxLQUFLLElBQUksRUFBRSxDQUFDO1FBQ3RDLE9BQU8sS0FBSyxDQUFDO0lBQ2pCLENBQUM7SUFDRCxNQUFNLENBQUMsR0FBRyxJQUErQixDQUFDO0lBRTFDLE1BQU0sb0JBQW9CLEdBQUcsT0FBTyxJQUFJLENBQUMsSUFBSSxJQUFBLG1CQUFTLEVBQUMsQ0FBQyxDQUFDLEtBQUssQ0FBQyxLQUFLLFFBQVEsQ0FBQztJQUM3RSxNQUFNLHlCQUF5QixHQUFHLENBQUMsQ0FBQyxLQUFLLEVBQUUsUUFBUSxFQUFFLEVBQUUsSUFBSSxFQUFFLENBQUMsTUFBTSxHQUFHLENBQUMsQ0FBQztJQUV6RSxNQUFNLHNCQUFzQixHQUFHLFNBQVMsSUFBSSxDQUFDLElBQUksSUFBQSxtQkFBUyxFQUFDLENBQUMsQ0FBQyxPQUFPLENBQUMsS0FBSyxRQUFRLENBQUM7SUFDbkYsTUFBTSwyQkFBMkIsR0FBRyxDQUFDLENBQUMsT0FBTyxFQUFFLFFBQVEsRUFBRSxFQUFFLElBQUksRUFBRSxDQUFDLE1BQU0sR0FBRyxDQUFDLENBQUM7SUFFN0UsTUFBTSxxQkFBcUIsR0FBRyxRQUFRLElBQUksQ0FBQyxJQUFJLGFBQWEsSUFBSSxDQUFDLENBQUM7SUFFbEUsT0FBTyxvQkFBb0IsSUFBSSx5QkFBeUI7V0FDakQsc0JBQXNCLElBQUksMkJBQTJCO1dBQ3JELHFCQUFxQixDQUFDO0FBQ2pDLENBQUMifQ==
@@ -0,0 +1,48 @@
1
+ import { FormComponentDefinitionFrame } from "./form-component.outline";
2
+ import { FormConfigFrame } from "./form-config.outline";
3
+ import { FieldDefinitionFrame } from "./field.outline";
4
+ import { ReusableFormComponentDefinitionFrame } from "./component/reusable.outline";
5
+ import { AvailableFormComponentDefinitionFrames } from "./dictionary.outline";
6
+ /**
7
+ * Check if the item is a field definition (it has at least 'class' and optional 'config' properties).
8
+ * @param item The item to check.
9
+ */
10
+ export declare function isTypeFieldDefinition(item: unknown): item is FieldDefinitionFrame;
11
+ /**
12
+ * Check if the item is a field definition of a particular type by comparing the class name
13
+ * (class name is the discriminator in the type union).
14
+ * @param item The item to check.
15
+ * @param name The class name to check.
16
+ */
17
+ export declare function isTypeFieldDefinitionName<T extends FieldDefinitionFrame>(item: unknown, name: string): item is T;
18
+ /**
19
+ * Check if the item is a form component definition (it has at least 'name' and 'component' properties).
20
+ * @param item The item to check.
21
+ */
22
+ export declare function isTypeFormComponentDefinition(item: unknown): item is FormComponentDefinitionFrame;
23
+ /**
24
+ * Check if the item is a form definition of a particular type by comparing the component class
25
+ * (component class name is the discriminator in the type union).
26
+ * @param item The item to check.
27
+ * @param name The class name to check.
28
+ */
29
+ export declare function isTypeFormComponentDefinitionName<T extends FormComponentDefinitionFrame>(item: unknown, name: string): item is T;
30
+ /**
31
+ * Check if the item has a componentDefinitions array property.
32
+ * @param item The item to check.
33
+ */
34
+ export declare function isTypeWithComponentDefinitions<T extends {
35
+ componentDefinitions: unknown[];
36
+ }>(item: unknown): item is T;
37
+ /**
38
+ * Check if the item is a FormConfig (it has a name and componentDefinitions array property).
39
+ * @param item The item to check.
40
+ */
41
+ export declare function isTypeFormConfig<T extends FormConfigFrame>(item: unknown): item is T;
42
+ /**
43
+ * Check if a form component definition specifies to use a reusable form config.
44
+ * @param item The form component definition.
45
+ * @param reusableFormDefNames The names of the available reusable form definitions.
46
+ * @protected
47
+ */
48
+ export declare function isTypeReusableComponent(item: AvailableFormComponentDefinitionFrames, reusableFormDefNames: string[]): item is ReusableFormComponentDefinitionFrame;
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isTypeFieldDefinition = isTypeFieldDefinition;
4
+ exports.isTypeFieldDefinitionName = isTypeFieldDefinitionName;
5
+ exports.isTypeFormComponentDefinition = isTypeFormComponentDefinition;
6
+ exports.isTypeFormComponentDefinitionName = isTypeFormComponentDefinitionName;
7
+ exports.isTypeWithComponentDefinitions = isTypeWithComponentDefinitions;
8
+ exports.isTypeFormConfig = isTypeFormConfig;
9
+ exports.isTypeReusableComponent = isTypeReusableComponent;
10
+ const helpers_1 = require("./helpers");
11
+ const reusable_outline_1 = require("./component/reusable.outline");
12
+ /*
13
+ * The functions starting with 'isType*' use typescript narrowing to check the value
14
+ * see: https://www.typescriptlang.org/docs/handbook/2/narrowing.html
15
+ */
16
+ /**
17
+ * Check if the item is a field definition (it has at least 'class' and optional 'config' properties).
18
+ * @param item The item to check.
19
+ */
20
+ function isTypeFieldDefinition(item) {
21
+ if (item === undefined || item === null) {
22
+ return false;
23
+ }
24
+ const i = item;
25
+ const propClassGuessType = (0, helpers_1.guessType)(i?.class);
26
+ const hasExpectedPropClass = 'class' in i && propClassGuessType === 'string';
27
+ // 'config' can be null or object or not set
28
+ const propConfigGuessType = (0, helpers_1.guessType)(i.config);
29
+ const hasExpectedPropConfig = ('config' in i && ["object", "null"].includes(propConfigGuessType)) || i?.config === undefined;
30
+ const isFieldDefinition = hasExpectedPropClass && hasExpectedPropConfig;
31
+ if (!isFieldDefinition) {
32
+ console.log(`isTypeFieldDefinition propClassGuessType ${propClassGuessType} propConfigGuessType ${propConfigGuessType}`);
33
+ }
34
+ return isFieldDefinition;
35
+ }
36
+ /**
37
+ * Check if the item is a field definition of a particular type by comparing the class name
38
+ * (class name is the discriminator in the type union).
39
+ * @param item The item to check.
40
+ * @param name The class name to check.
41
+ */
42
+ function isTypeFieldDefinitionName(item, name) {
43
+ if (item === undefined || item === null) {
44
+ return false;
45
+ }
46
+ const hasExpectedFieldDefClass = isTypeFieldDefinition(item) && item?.class === name;
47
+ return hasExpectedFieldDefClass;
48
+ }
49
+ /**
50
+ * Check if the item is a form component definition (it has at least 'name' and 'component' properties).
51
+ * @param item The item to check.
52
+ */
53
+ function isTypeFormComponentDefinition(item) {
54
+ if (item === undefined || item === null) {
55
+ return false;
56
+ }
57
+ // use typescript narrowing to check the value
58
+ const i = item;
59
+ // only name and component are required
60
+ const hasName = 'name' in i;
61
+ const hasExpectedNameValue = ["null", "string"].includes((0, helpers_1.guessType)(i?.name));
62
+ const hasComponent = 'component' in i;
63
+ const isFormFieldComponent = isTypeFieldDefinition(i?.component);
64
+ return hasName && hasExpectedNameValue && hasComponent && isFormFieldComponent;
65
+ }
66
+ /**
67
+ * Check if the item is a form definition of a particular type by comparing the component class
68
+ * (component class name is the discriminator in the type union).
69
+ * @param item The item to check.
70
+ * @param name The class name to check.
71
+ */
72
+ function isTypeFormComponentDefinitionName(item, name) {
73
+ if (item === undefined || item === null) {
74
+ return false;
75
+ }
76
+ const hasExpectedFormDefClass = isTypeFormComponentDefinition(item) && item?.component?.class === name;
77
+ return hasExpectedFormDefClass;
78
+ }
79
+ /**
80
+ * Check if the item has a componentDefinitions array property.
81
+ * @param item The item to check.
82
+ */
83
+ function isTypeWithComponentDefinitions(item) {
84
+ if (item === undefined || item === null) {
85
+ return false;
86
+ }
87
+ // use typescript narrowing to check the value
88
+ const i = item;
89
+ const hasExpectedPropCompDefs = 'componentDefinitions' in i && (0, helpers_1.guessType)(i?.componentDefinitions) === 'array';
90
+ return hasExpectedPropCompDefs;
91
+ }
92
+ /**
93
+ * Check if the item is a FormConfig (it has a name and componentDefinitions array property).
94
+ * @param item The item to check.
95
+ */
96
+ function isTypeFormConfig(item) {
97
+ if (item === undefined || item === null) {
98
+ return false;
99
+ }
100
+ const i = item;
101
+ const hasExpectedPropName = 'name' in i && (0, helpers_1.guessType)(i.name) === 'string';
102
+ const hasExpectedPropCompDefs = isTypeWithComponentDefinitions(item);
103
+ return hasExpectedPropName && hasExpectedPropCompDefs;
104
+ }
105
+ /**
106
+ * Check if a form component definition specifies to use a reusable form config.
107
+ * @param item The form component definition.
108
+ * @param reusableFormDefNames The names of the available reusable form definitions.
109
+ * @protected
110
+ */
111
+ function isTypeReusableComponent(item, reusableFormDefNames) {
112
+ const componentClassName = item?.component?.class ?? "";
113
+ const itemReusableFormName = item?.overrides?.reusableFormName ?? "";
114
+ const isReusableComponent = componentClassName === reusable_outline_1.ReusableComponentName;
115
+ const hasReusableFormName = itemReusableFormName && reusableFormDefNames.includes(itemReusableFormName);
116
+ if (!isReusableComponent && !hasReusableFormName) {
117
+ return false;
118
+ }
119
+ if (hasReusableFormName && isTypeFormComponentDefinitionName(item, reusable_outline_1.ReusableComponentName)) {
120
+ const overrides = item?.overrides ?? {};
121
+ const overrideKeys = Object.keys(overrides);
122
+ const reusableFormNameOnly = overrideKeys.includes('reusableFormName') && overrideKeys.length === 1;
123
+ const noKeys = overrideKeys.length === 0;
124
+ if (!reusableFormNameOnly && !noKeys) {
125
+ throw new Error("Invalid usage of reusable form config. " +
126
+ `Override for component name '${item.name}' class '${item.component.class}' must contain only 'reusableFormName', ` +
127
+ `it cannot be combined with other properties '${JSON.stringify(overrides)}'. ` +
128
+ `Change the form component name by setting the 'replaceName' property for the relevant componentDefinition. ` +
129
+ `The 'formModeClasses' can only be changed on subcomponents.`);
130
+ }
131
+ return true;
132
+ }
133
+ throw new Error("Invalid usage of reusable form config. " +
134
+ `Component class '${componentClassName}' must be '${reusable_outline_1.ReusableComponentName}' ` +
135
+ `and reusableFormName '${itemReusableFormName}' must be one of '${reusableFormDefNames.join(', ') || '(none available)'}'.`);
136
+ }
137
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9ybS10eXBlcy5vdXRsaW5lLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NvbmZpZy9mb3JtLXR5cGVzLm91dGxpbmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFpQkEsc0RBbUJDO0FBUUQsOERBUUM7QUFNRCxzRUFhQztBQVFELDhFQVFDO0FBTUQsd0VBWUM7QUFNRCw0Q0FXQztBQVFELDB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UFBTSxFQUFFLENBQUM7WUFDbkMsTUFBTSxJQUFJLEtBQUssQ0FBQyx5Q0FBeUM7Z0JBQ3JELGdDQUFnQyxJQUFJLENBQUMsSUFBSSxZQUFZLElBQUksQ0FBQyxTQUFTLENBQUMsS0FBSywwQ0FBMEM7Z0JBQ25ILGdEQUFnRCxJQUFJLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQyxLQUFLO2dCQUM5RSw2R0FBNkc7Z0JBQzdHLDZEQUE2RCxDQUFDLENBQUM7UUFDdkUsQ0FBQztRQUNELE9BQU8sSUFBSSxDQUFDO0lBQ2hCLENBQUM7SUFFRCxNQUFNLElBQUksS0FBSyxDQUFDLHlDQUF5QztRQUNyRCxvQkFBb0Isa0JBQWtCLGNBQWMsd0NBQXFCLElBQUk7UUFDN0UseUJBQXlCLG9CQUFvQixxQkFBcUIsb0JBQW9CLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxJQUFJLGtCQUFrQixJQUFJLENBQUMsQ0FBQztBQUNySSxDQUFDIn0=
@@ -0,0 +1,31 @@
1
+ export type GuessedType = "null" | "undefined" | "boolean" | "number" | "array" | "object" | "function" | "timestamp" | "string" | "unknown";
2
+ /**
3
+ * Guess the type of the value.
4
+ * @param value Guess the type of this value.
5
+ * @private
6
+ */
7
+ export declare function guessType(value: unknown): GuessedType;
8
+ /**
9
+ * Apply conventions to convert a value to a boolean.
10
+ * @param value A value to convert to boolean.
11
+ */
12
+ export declare function toBoolean(value: unknown): boolean;
13
+ /**
14
+ * Check whether a 'check' array starts with a 'base' array.
15
+ * Both arrays must have at least one element.
16
+ * @param base The shorter array.
17
+ * @param check The longer array.
18
+ * @private
19
+ */
20
+ export declare function arrayStartsWithArray(base: unknown[], check: unknown[]): boolean;
21
+ /**
22
+ * Extract all properties of the type T that are of the type U.
23
+ */
24
+ export type ExtractPropertyNamesOfType<T, U> = {
25
+ [K in keyof T]: T[K] extends U ? K : never;
26
+ }[keyof T];
27
+ /**
28
+ * Extract all properties from each of the types in the union type T, where the properties are of type U.
29
+ * This uses the distributive feature of conditional types (T extends T ? ...).
30
+ */
31
+ export type ExtractPropertyNamesOfTypeFromTypeUnion<T, U> = T extends T ? ExtractPropertyNamesOfType<T, U> : never;
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.guessType = guessType;
4
+ exports.toBoolean = toBoolean;
5
+ exports.arrayStartsWithArray = arrayStartsWithArray;
6
+ const lodash_1 = require("lodash");
7
+ const luxon_1 = require("luxon");
8
+ /**
9
+ * Guess the type of the value.
10
+ * @param value Guess the type of this value.
11
+ * @private
12
+ */
13
+ function guessType(value) {
14
+ if (value === null) {
15
+ return "null";
16
+ }
17
+ if (value === undefined) {
18
+ return "undefined";
19
+ }
20
+ if ((0, lodash_1.isBoolean)(value)) {
21
+ return "boolean";
22
+ }
23
+ if (Number.isFinite(value)) {
24
+ return "number";
25
+ }
26
+ if ((0, lodash_1.isArray)(value)) {
27
+ return "array";
28
+ }
29
+ if ((0, lodash_1.isPlainObject)(value)) {
30
+ return "object";
31
+ }
32
+ // Check for custom Object.
33
+ try {
34
+ const valueInfo = valueProtoInfo(value);
35
+ if (valueInfo.isObjectLike && valueInfo.isValueStringTagObject &&
36
+ valueInfo.isValueProtoCtorFunc && !valueInfo.isValueProtoCtorFuncObj) {
37
+ return "object";
38
+ }
39
+ }
40
+ catch (err) {
41
+ console.debug(`guessType custom object error with value '${value}': ${err}`);
42
+ }
43
+ if ((0, lodash_1.isFunction)(value)) {
44
+ return "function";
45
+ }
46
+ // check for date
47
+ const dateTimeFormats = [
48
+ luxon_1.DateTime.fromISO,
49
+ luxon_1.DateTime.fromRFC2822,
50
+ luxon_1.DateTime.fromHTTP,
51
+ ];
52
+ try {
53
+ for (const dateTimeFormat of dateTimeFormats) {
54
+ const result = dateTimeFormat(value?.toString() ?? "");
55
+ if (result && result.isValid) {
56
+ return "timestamp";
57
+ }
58
+ }
59
+ }
60
+ catch (err) {
61
+ console.debug(`guessType parse error with value '${value}' formats ${JSON.stringify(dateTimeFormats)}: ${err}`);
62
+ }
63
+ if ((0, lodash_1.isString)(value)) {
64
+ return "string";
65
+ }
66
+ console.debug(`guessType unknown type for '${value}' info ${JSON.stringify(valueProtoInfo(value))}`);
67
+ return "unknown";
68
+ }
69
+ function valueProtoInfo(value) {
70
+ const isObjectLike = (0, lodash_1.isObjectLike)(value);
71
+ const isValueStringTagObject = Object.prototype.toString.call(value) === '[object Object]';
72
+ const valuePrototypeCtor = Object.getPrototypeOf(value).constructor;
73
+ const isValueProtoCtorFunc = typeof valuePrototypeCtor === 'function';
74
+ const isValueProtoCtorFuncObj = Function.prototype.toString.call(valuePrototypeCtor) === Function.prototype.toString.call(Object);
75
+ return {
76
+ isObjectLike,
77
+ isValueStringTagObject,
78
+ valuePrototypeCtor,
79
+ isValueProtoCtorFunc,
80
+ isValueProtoCtorFuncObj,
81
+ };
82
+ }
83
+ /**
84
+ * Apply conventions to convert a value to a boolean.
85
+ * @param value A value to convert to boolean.
86
+ */
87
+ function toBoolean(value) {
88
+ if (typeof value === 'boolean') {
89
+ return value;
90
+ }
91
+ if (typeof value === 'number') {
92
+ return !Number.isNaN(value) && value !== 0;
93
+ }
94
+ const normalized = String(value ?? '').trim().toLowerCase();
95
+ const trueValues = ["true", "t", "1", "yes", "y", "on", "enable", "enabled"];
96
+ return trueValues.includes(normalized);
97
+ }
98
+ /**
99
+ * Check whether a 'check' array starts with a 'base' array.
100
+ * Both arrays must have at least one element.
101
+ * @param base The shorter array.
102
+ * @param check The longer array.
103
+ * @private
104
+ */
105
+ function arrayStartsWithArray(base, check) {
106
+ if (!base || !check) {
107
+ return false;
108
+ }
109
+ if (base.length > check.length) {
110
+ return false;
111
+ }
112
+ return base.every((value, index) => check[index] === value);
113
+ }
114
+ // TODO: consider trying to type the access to the config properties.
115
+ // type FormFieldComponentOrLayoutDefinitionConfig = FormFieldComponentOrLayoutDefinition['config'];
116
+ // type FormFieldComponentOrLayoutStringKeys = NonNullable<ExtractPropertyNamesOfTypeFromTypeUnion<
117
+ // FormFieldComponentOrLayoutDefinitionConfig, string | undefined | null
118
+ // >>;
119
+ // type FormFieldComponentOrLayoutBooleanKeys = NonNullable<ExtractPropertyNamesOfTypeFromTypeUnion<
120
+ // FormFieldComponentOrLayoutDefinitionConfig, boolean | undefined | null
121
+ // >>;
122
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jb25maWcvaGVscGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQTJCQSw4QkErREM7QUFxQkQsOEJBVUM7QUFTRCxvREFRQztBQTFJRCxtQ0FRZ0I7QUFDaEIsaUNBQStCO0FBYS9COzs7O0dBSUc7QUFDSCxTQUFnQixTQUFTLENBQUMsS0FBYztJQUNwQyxJQUFJLEtBQUssS0FBSyxJQUFJLEVBQUUsQ0FBQztRQUNqQixPQUFPLE1BQU0sQ0FBQztJQUNsQixDQUFDO0lBQ0QsSUFBSSxLQUFLLEtBQUssU0FBUyxFQUFFLENBQUM7UUFDdEIsT0FBTyxXQUFXLENBQUM7SUFDdkIsQ0FBQztJQUVELElBQUksSUFBQSxrQkFBVSxFQUFDLEtBQUssQ0FBQyxFQUFFLENBQUM7UUFDcEIsT0FBTyxTQUFTLENBQUM7SUFDckIsQ0FBQztJQUVELElBQUksTUFBTSxDQUFDLFFBQVEsQ0FBQyxLQUFLLENBQUMsRUFBRSxDQUFDO1FBQ3pCLE9BQU8sUUFBUSxDQUFDO0lBQ3BCLENBQUM7SUFFRCxJQUFJLElBQUEsZ0JBQVEsRUFBQyxLQUFLLENBQUMsRUFBRSxDQUFDO1FBQ2xCLE9BQU8sT0FBTyxDQUFDO0lBQ25CLENBQUM7SUFFRCxJQUFJLElBQUEsc0JBQWMsRUFBQyxLQUFLLENBQUMsR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ztJQUNELE9BQU8sSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFDLEtBQUssRUFBRSxLQUFLLEVBQUUsRUFBRSxDQUFDLEtBQUssQ0FBQyxLQUFLLENBQUMsS0FBSyxLQUFLLENBQUMsQ0FBQztBQUM5RCxDQUFDO0FBYUQscUVBQXFFO0FBQ3JFLG9HQUFvRztBQUNwRyxtR0FBbUc7QUFDbkcsMEVBQTBFO0FBQzFFLE1BQU07QUFDTixvR0FBb0c7QUFDcEcsMkVBQTJFO0FBQzNFLE1BQU0ifQ==
@@ -0,0 +1,112 @@
1
+ /**
2
+ * A lineage path is an ordered list of keys (string|number) describing a path lineage for
3
+ * different domains of form configuration.
4
+ * A string key is a property name or array index number as a string, a number key is an array index.
5
+ */
6
+ export type LineagePath = (string | number)[];
7
+ /**
8
+ * A collection of lineage paths that describe different relationships.
9
+ */
10
+ export interface LineagePaths {
11
+ /**
12
+ * The path to the item in the form config.
13
+ */
14
+ formConfig: LineagePath;
15
+ /**
16
+ * The path to the item in the form data model.
17
+ */
18
+ dataModel: LineagePath;
19
+ /**
20
+ * The path to the item in the angular control hierarchy.
21
+ */
22
+ angularComponents: LineagePath;
23
+ /**
24
+ * The JSONPointer to the angular control.
25
+ */
26
+ angularComponentsJsonPointer?: string;
27
+ /**
28
+ * The path to the item in the layout hierarchy.
29
+ * Uses the component name with a "-layout" suffix.
30
+ */
31
+ layout: LineagePath;
32
+ /**
33
+ * The JSONPointer to the layout item.
34
+ */
35
+ layoutJsonPointer?: string;
36
+ }
37
+ /**
38
+ * Allow providing a partial lineage paths object.
39
+ * This is for adding to an existing lineage path.
40
+ *
41
+ * This does not include the calculated json pointer fields on purpose.
42
+ * Use LineagePathsOptional to include the json pointer fields.
43
+ */
44
+ export interface LineagePathsPartial {
45
+ formConfig?: LineagePath;
46
+ dataModel?: LineagePath;
47
+ angularComponents?: LineagePath;
48
+ layout?: LineagePath;
49
+ }
50
+ /**
51
+ * Allow providing any of the lineage paths properties.
52
+ *
53
+ * This does include the calculated json pointer fields on purpose.
54
+ * Use LineagePathsPartial to include only the fields that are not calculated.
55
+ */
56
+ export type LineagePathsOptional = Partial<LineagePaths>;
57
+ /**
58
+ * Build the lineage paths from a base item, and add the entries in `more` as relative
59
+ * parts at the end of each lineage path. Undefined inputs default to empty arrays.
60
+ * This was previously an instance method of FormService.
61
+ */
62
+ export declare function buildLineagePaths(base?: LineagePaths, more?: LineagePathsPartial): LineagePaths;
63
+ /**
64
+ * Get a JSON Pointer string from an array of path segments.
65
+ *
66
+ * @param paths
67
+ * @returns JSON Pointer string
68
+ */
69
+ export declare function getJSONPointerByArrayPaths(paths: (string | number)[]): string;
70
+ /**
71
+ * Retrieve any object property using a JSON Pointer or an array of path segments.
72
+ *
73
+ * @param obj
74
+ * @param pointer
75
+ * @returns JSON Pointer reference: {key: 'key', val: 'object value at key', obj: 'context object, 1 level up from key'}
76
+ */
77
+ export declare function getObjectWithJsonPointer(obj: any, pointer: string | string[]): any;
78
+ /**
79
+ * Retrieve the last segment of a JSONPointer string
80
+ */
81
+ export declare function getLastSegmentFromJSONPointer(pointer: string): string;
82
+ /**
83
+ * Normalise a string to reduce the potential variations in how characters are specified.
84
+ *
85
+ * @param value The value to normalise.
86
+ * @return The string normalised to remove visual variants.
87
+ */
88
+ export declare function normaliseVisual(value: unknown): string;
89
+ /**
90
+ * Determine if every key present in both lineage paths match.
91
+ * @param a The first lineage paths object.
92
+ * @param b The second lineage paths object.
93
+ */
94
+ export declare function isMatchingLineagePaths(a: LineagePathsOptional, b: LineagePathsOptional): boolean;
95
+ /**
96
+ * Determine if two lineage paths or strings are equal.
97
+ * @param a The first lineage path or string.
98
+ * @param b The second lineage path or string.
99
+ */
100
+ export declare function isMatchingLineagePath(a: LineagePath | string, b: LineagePath | string): boolean;
101
+ /**
102
+ * Determine if every key (present in both lineage paths) of a lineage path starts with a base lineage path.
103
+ * @param base The prefix lineage paths object.
104
+ * @param check The lineage paths object that should start with the prefix.
105
+ */
106
+ export declare function isPrefixLineagePaths(base: LineagePathsOptional, check: LineagePathsOptional): boolean;
107
+ /**
108
+ * Determine if a check lineage path starts with a base lineage path.
109
+ * @param base The prefix.
110
+ * @param check The item that should start with prefix.
111
+ */
112
+ export declare function isPrefixLineagePath(base: LineagePath | string, check: LineagePath | string): boolean;