@fgv/ts-res 5.0.0-21 → 5.0.0-23

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 (197) hide show
  1. package/README.md +794 -137
  2. package/dist/ts-res.d.ts +506 -33
  3. package/lib/packlets/common/convert.d.ts +10 -0
  4. package/lib/packlets/common/convert.js +11 -1
  5. package/lib/packlets/common/resources.d.ts +40 -1
  6. package/lib/packlets/common/validate/regularExpressions.d.ts +4 -0
  7. package/lib/packlets/common/validate/regularExpressions.js +5 -1
  8. package/lib/packlets/common/validate/resources.d.ts +35 -1
  9. package/lib/packlets/common/validate/resources.js +54 -0
  10. package/lib/packlets/config/convert.js +1 -1
  11. package/lib/packlets/config/json.d.ts +1 -1
  12. package/lib/packlets/qualifier-types/config/convert.d.ts +22 -1
  13. package/lib/packlets/qualifier-types/config/convert.js +67 -2
  14. package/lib/packlets/qualifier-types/config/json.d.ts +11 -2
  15. package/lib/packlets/qualifier-types/helpers.d.ts +1 -2
  16. package/lib/packlets/qualifier-types/languageQualifierType.d.ts +27 -1
  17. package/lib/packlets/qualifier-types/languageQualifierType.js +75 -0
  18. package/lib/packlets/qualifier-types/literalQualifierType.d.ts +30 -4
  19. package/lib/packlets/qualifier-types/literalQualifierType.js +77 -0
  20. package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts +6 -10
  21. package/lib/packlets/qualifier-types/literalValueHierarchy.js +10 -0
  22. package/lib/packlets/qualifier-types/qualifierType.d.ts +28 -0
  23. package/lib/packlets/qualifier-types/territoryQualifierType.d.ts +28 -4
  24. package/lib/packlets/qualifier-types/territoryQualifierType.js +77 -0
  25. package/lib/packlets/resource-json/compiled/convert.js +2 -1
  26. package/lib/packlets/resource-json/compiled/json.d.ts +6 -2
  27. package/lib/packlets/resource-types/config/convert.js +3 -1
  28. package/lib/packlets/resource-types/config/json.d.ts +2 -0
  29. package/lib/packlets/resource-types/jsonResourceType.d.ts +10 -6
  30. package/lib/packlets/resource-types/jsonResourceType.js +7 -10
  31. package/lib/packlets/resource-types/resourceType.d.ts +20 -8
  32. package/lib/packlets/resource-types/resourceType.js +20 -16
  33. package/lib/packlets/resources/candidateValue.d.ts +92 -0
  34. package/lib/packlets/resources/candidateValue.js +128 -0
  35. package/lib/packlets/resources/candidateValueCollector.d.ts +55 -0
  36. package/lib/packlets/resources/candidateValueCollector.js +96 -0
  37. package/lib/packlets/resources/index.d.ts +2 -0
  38. package/lib/packlets/resources/index.js +2 -0
  39. package/lib/packlets/resources/resource.js +2 -2
  40. package/lib/packlets/resources/resourceBuilder.d.ts +6 -0
  41. package/lib/packlets/resources/resourceBuilder.js +3 -1
  42. package/lib/packlets/resources/resourceCandidate.d.ts +10 -1
  43. package/lib/packlets/resources/resourceCandidate.js +11 -5
  44. package/lib/packlets/resources/resourceManagerBuilder.d.ts +7 -0
  45. package/lib/packlets/resources/resourceManagerBuilder.js +13 -6
  46. package/lib/packlets/runtime/compiledResourceCollection.d.ts +20 -8
  47. package/lib/packlets/runtime/compiledResourceCollection.js +25 -4
  48. package/lib/packlets/runtime/resource-tree/common.d.ts +1 -1
  49. package/lib/packlets/runtime/resourceResolver.d.ts +39 -1
  50. package/lib/packlets/runtime/resourceResolver.js +45 -28
  51. package/lib/test/unit/qualifier-types/testQualifierType.d.ts +4 -0
  52. package/lib/test/unit/qualifier-types/testQualifierType.js +24 -0
  53. package/lib/test/unit/resource-types/derivedResourceType.test.d.ts +2 -0
  54. package/lib/test/unit/resource-types/testDerivedResourceType.d.ts +79 -0
  55. package/lib/test/unit/resource-types/testDerivedResourceType.js +113 -0
  56. package/lib/test/unit/resources/candidateValue.test.d.ts +2 -0
  57. package/lib/test/unit/resources/candidateValueCollector.test.d.ts +2 -0
  58. package/lib/test/unit/runtime/resourceResolver.coverage.test.d.ts +2 -0
  59. package/lib/test/unit/runtime/resourceResolver.newFeatures.test.d.ts +2 -0
  60. package/package.json +7 -7
  61. package/src/index.ts +0 -75
  62. package/src/packlets/bundle/bundleBuilder.ts +0 -159
  63. package/src/packlets/bundle/bundleLoader.ts +0 -157
  64. package/src/packlets/bundle/bundleNormalizer.ts +0 -173
  65. package/src/packlets/bundle/bundleUtils.ts +0 -142
  66. package/src/packlets/bundle/convert.ts +0 -87
  67. package/src/packlets/bundle/index.ts +0 -52
  68. package/src/packlets/bundle/model.ts +0 -138
  69. package/src/packlets/common/conditions.ts +0 -226
  70. package/src/packlets/common/convert.ts +0 -184
  71. package/src/packlets/common/helpers/conditions.ts +0 -84
  72. package/src/packlets/common/helpers/context.ts +0 -88
  73. package/src/packlets/common/helpers/index.ts +0 -26
  74. package/src/packlets/common/helpers/qualifierDefaultValues.ts +0 -91
  75. package/src/packlets/common/helpers/resources.ts +0 -96
  76. package/src/packlets/common/index.ts +0 -30
  77. package/src/packlets/common/resources.ts +0 -78
  78. package/src/packlets/common/validate/conditions.ts +0 -595
  79. package/src/packlets/common/validate/index.ts +0 -27
  80. package/src/packlets/common/validate/regularExpressions.ts +0 -92
  81. package/src/packlets/common/validate/resources.ts +0 -170
  82. package/src/packlets/conditions/condition.ts +0 -351
  83. package/src/packlets/conditions/conditionCollector.ts +0 -103
  84. package/src/packlets/conditions/conditionDecls.ts +0 -50
  85. package/src/packlets/conditions/conditionSet.ts +0 -318
  86. package/src/packlets/conditions/conditionSetCollector.ts +0 -127
  87. package/src/packlets/conditions/conditionSetDecls.ts +0 -41
  88. package/src/packlets/conditions/conditionToken.ts +0 -180
  89. package/src/packlets/conditions/convert/conditionSetDecls.ts +0 -72
  90. package/src/packlets/conditions/convert/decls.ts +0 -95
  91. package/src/packlets/conditions/convert/index.ts +0 -24
  92. package/src/packlets/conditions/index.ts +0 -33
  93. package/src/packlets/config/common.ts +0 -107
  94. package/src/packlets/config/configInitFactory.ts +0 -142
  95. package/src/packlets/config/convert.ts +0 -61
  96. package/src/packlets/config/index.ts +0 -30
  97. package/src/packlets/config/json.ts +0 -43
  98. package/src/packlets/config/predefined/default.ts +0 -150
  99. package/src/packlets/config/predefined/extended.ts +0 -198
  100. package/src/packlets/config/predefined/index.ts +0 -26
  101. package/src/packlets/config/systemConfiguration.ts +0 -217
  102. package/src/packlets/context/contextDecls.ts +0 -76
  103. package/src/packlets/context/contextToken.ts +0 -252
  104. package/src/packlets/context/convert/decls.ts +0 -126
  105. package/src/packlets/context/convert/index.ts +0 -23
  106. package/src/packlets/context/index.ts +0 -27
  107. package/src/packlets/decisions/abstractDecision.ts +0 -87
  108. package/src/packlets/decisions/abstractDecisionCollector.ts +0 -122
  109. package/src/packlets/decisions/candidate.ts +0 -101
  110. package/src/packlets/decisions/common.ts +0 -37
  111. package/src/packlets/decisions/concreteDecision.ts +0 -157
  112. package/src/packlets/decisions/decision.ts +0 -172
  113. package/src/packlets/decisions/index.ts +0 -28
  114. package/src/packlets/import/fsItem.ts +0 -212
  115. package/src/packlets/import/importContext.ts +0 -183
  116. package/src/packlets/import/importManager.ts +0 -187
  117. package/src/packlets/import/importable.ts +0 -107
  118. package/src/packlets/import/importers/collectionImporter.ts +0 -153
  119. package/src/packlets/import/importers/fsItemImporter.ts +0 -154
  120. package/src/packlets/import/importers/importer.ts +0 -58
  121. package/src/packlets/import/importers/index.ts +0 -27
  122. package/src/packlets/import/importers/jsonImporter.ts +0 -133
  123. package/src/packlets/import/importers/pathImporter.ts +0 -134
  124. package/src/packlets/import/index.ts +0 -29
  125. package/src/packlets/qualifier-types/config/convert.ts +0 -108
  126. package/src/packlets/qualifier-types/config/index.ts +0 -27
  127. package/src/packlets/qualifier-types/config/json.ts +0 -126
  128. package/src/packlets/qualifier-types/convert.ts +0 -77
  129. package/src/packlets/qualifier-types/helpers.ts +0 -94
  130. package/src/packlets/qualifier-types/index.ts +0 -34
  131. package/src/packlets/qualifier-types/languageQualifierType.ts +0 -143
  132. package/src/packlets/qualifier-types/literalQualifierType.ts +0 -244
  133. package/src/packlets/qualifier-types/literalValueHierarchy.ts +0 -332
  134. package/src/packlets/qualifier-types/qualifierType.ts +0 -360
  135. package/src/packlets/qualifier-types/qualifierTypeCollector.ts +0 -102
  136. package/src/packlets/qualifier-types/territoryQualifierType.ts +0 -255
  137. package/src/packlets/qualifiers/convert/decls.ts +0 -90
  138. package/src/packlets/qualifiers/convert/index.ts +0 -24
  139. package/src/packlets/qualifiers/convert/qualifier.ts +0 -55
  140. package/src/packlets/qualifiers/index.ts +0 -31
  141. package/src/packlets/qualifiers/qualifier.ts +0 -169
  142. package/src/packlets/qualifiers/qualifierCollector.ts +0 -194
  143. package/src/packlets/qualifiers/qualifierDecl.ts +0 -80
  144. package/src/packlets/qualifiers/qualifierDefaultValueDecls.ts +0 -57
  145. package/src/packlets/qualifiers/qualifierDefaultValueToken.ts +0 -230
  146. package/src/packlets/resource-json/compiled/common.ts +0 -35
  147. package/src/packlets/resource-json/compiled/convert.ts +0 -143
  148. package/src/packlets/resource-json/compiled/index.ts +0 -27
  149. package/src/packlets/resource-json/compiled/json.ts +0 -239
  150. package/src/packlets/resource-json/convert.ts +0 -236
  151. package/src/packlets/resource-json/helpers.ts +0 -284
  152. package/src/packlets/resource-json/index.ts +0 -33
  153. package/src/packlets/resource-json/json.ts +0 -295
  154. package/src/packlets/resource-json/normalized.ts +0 -211
  155. package/src/packlets/resource-json/resourceDeclCollection.ts +0 -117
  156. package/src/packlets/resource-json/resourceDeclContainer.ts +0 -48
  157. package/src/packlets/resource-json/resourceDeclTree.ts +0 -116
  158. package/src/packlets/resource-types/config/convert.ts +0 -36
  159. package/src/packlets/resource-types/config/index.ts +0 -27
  160. package/src/packlets/resource-types/config/json.ts +0 -30
  161. package/src/packlets/resource-types/helpers.ts +0 -44
  162. package/src/packlets/resource-types/index.ts +0 -30
  163. package/src/packlets/resource-types/jsonResourceType.ts +0 -104
  164. package/src/packlets/resource-types/resourceType.ts +0 -259
  165. package/src/packlets/resource-types/resourceTypeCollector.ts +0 -79
  166. package/src/packlets/resources/candidateReducer.ts +0 -331
  167. package/src/packlets/resources/common.ts +0 -114
  168. package/src/packlets/resources/index.ts +0 -28
  169. package/src/packlets/resources/resource.ts +0 -307
  170. package/src/packlets/resources/resourceBuilder.ts +0 -269
  171. package/src/packlets/resources/resourceCandidate.ts +0 -333
  172. package/src/packlets/resources/resourceManagerBuilder.ts +0 -1169
  173. package/src/packlets/runtime/cacheListener.ts +0 -113
  174. package/src/packlets/runtime/cacheMetrics.ts +0 -206
  175. package/src/packlets/runtime/compiledResourceCollection.ts +0 -607
  176. package/src/packlets/runtime/conditionSetResolutionResult.ts +0 -160
  177. package/src/packlets/runtime/context/contextQualifierProvider.ts +0 -117
  178. package/src/packlets/runtime/context/contextQualifierProviderValidator.ts +0 -281
  179. package/src/packlets/runtime/context/index.ts +0 -26
  180. package/src/packlets/runtime/context/simpleContextQualifierProvider.ts +0 -225
  181. package/src/packlets/runtime/context/validatingSimpleContextQualifierProvider.ts +0 -96
  182. package/src/packlets/runtime/iResourceManager.ts +0 -130
  183. package/src/packlets/runtime/index.ts +0 -35
  184. package/src/packlets/runtime/resource-tree/common.ts +0 -126
  185. package/src/packlets/runtime/resource-tree/index.ts +0 -26
  186. package/src/packlets/runtime/resource-tree/readOnlyResourceTree.ts +0 -342
  187. package/src/packlets/runtime/resource-tree/resourceTreeChildren.ts +0 -125
  188. package/src/packlets/runtime/resource-tree/resourceTreeChildrenValidator.ts +0 -187
  189. package/src/packlets/runtime/resourceResolver.ts +0 -626
  190. package/src/packlets/runtime/validate.ts +0 -63
  191. package/src/packlets/zip-archive/convert.ts +0 -121
  192. package/src/packlets/zip-archive/index.ts +0 -76
  193. package/src/packlets/zip-archive/json.ts +0 -91
  194. package/src/packlets/zip-archive/types.ts +0 -140
  195. package/src/packlets/zip-archive/zipArchiveCreator.ts +0 -229
  196. package/src/packlets/zip-archive/zipArchiveFormat.ts +0 -158
  197. package/src/packlets/zip-archive/zipArchiveLoader.ts +0 -370
@@ -1,8 +1,9 @@
1
1
  import { Result } from '@fgv/ts-utils';
2
- import { ConditionOperator, QualifierConditionValue, QualifierContextValue, QualifierMatchScore } from '../common';
2
+ import { ConditionOperator, QualifierConditionValue, QualifierContextValue, QualifierMatchScore, QualifierTypeName } from '../common';
3
3
  import { QualifierType } from './qualifierType';
4
- import { LiteralValueHierarchy, LiteralValueHierarchyDecl } from './literalValueHierarchy';
4
+ import { LiteralValueHierarchy } from './literalValueHierarchy';
5
5
  import * as Config from './config';
6
+ import { JsonObject } from '@fgv/ts-json-base';
6
7
  /**
7
8
  * Interface defining the parameters that can be used to create a new
8
9
  * {@link QualifierTypes.LiteralQualifierType | LiteralQualifierType}.
@@ -29,10 +30,10 @@ export interface ILiteralQualifierTypeCreateParams {
29
30
  */
30
31
  enumeratedValues?: ReadonlyArray<string>;
31
32
  /**
32
- * Optional {@link QualifierTypes.LiteralValueHierarchyDecl | hierarchy declaration}
33
+ * Optional {@link QualifierTypes.Config.LiteralValueHierarchyDecl | hierarchy declaration}
33
34
  * of literal values to use for matching. If not provided, no hierarchy will be used.
34
35
  */
35
- hierarchy?: LiteralValueHierarchyDecl<string>;
36
+ hierarchy?: Config.LiteralValueHierarchyDecl<string>;
36
37
  /**
37
38
  * Global index for this qualifier type.
38
39
  */
@@ -44,6 +45,10 @@ export interface ILiteralQualifierTypeCreateParams {
44
45
  * @public
45
46
  */
46
47
  export declare class LiteralQualifierType extends QualifierType {
48
+ /**
49
+ * {@inheritdoc QualifierTypes.IQualifierType.systemTypeName}
50
+ */
51
+ readonly systemTypeName: QualifierTypeName;
47
52
  /**
48
53
  * Indicates whether the qualifier match is case-sensitive.
49
54
  */
@@ -79,6 +84,27 @@ export declare class LiteralQualifierType extends QualifierType {
79
84
  * {@inheritdoc QualifierTypes.IQualifierType.isPotentialMatch}
80
85
  */
81
86
  isPotentialMatch(conditionValue: string, contextValue: string): boolean;
87
+ /**
88
+ * Gets a {@link QualifierTypes.Config.ISystemLiteralQualifierTypeConfig | strongly typed configuration object}
89
+ * for this qualifier type.
90
+ * @returns `Success` with the configuration if successful, `Failure` with an error message otherwise.
91
+ */
92
+ getConfiguration(): Result<Config.ISystemLiteralQualifierTypeConfig>;
93
+ /**
94
+ * {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
95
+ */
96
+ getConfigurationJson(): Result<JsonObject>;
97
+ /**
98
+ * {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
99
+ */
100
+ validateConfigurationJson(from: unknown): Result<JsonObject>;
101
+ /**
102
+ * Validates a {@link QualifierTypes.Config.ISystemLiteralQualifierTypeConfig | strongly typed configuration object}
103
+ * for this qualifier type.
104
+ * @param from - The unknown data to validate as a configuration object.
105
+ * @returns `Success` with the validated configuration if successful, `Failure` with an error message otherwise.
106
+ */
107
+ validateConfiguration(from: unknown): Result<Config.ISystemLiteralQualifierTypeConfig>;
82
108
  /**
83
109
  * {@inheritdoc QualifierTypes.QualifierType._matchOne}
84
110
  */
@@ -20,12 +20,46 @@
20
20
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  * SOFTWARE.
22
22
  */
23
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ var desc = Object.getOwnPropertyDescriptor(m, k);
26
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
27
+ desc = { enumerable: true, get: function() { return m[k]; } };
28
+ }
29
+ Object.defineProperty(o, k2, desc);
30
+ }) : (function(o, m, k, k2) {
31
+ if (k2 === undefined) k2 = k;
32
+ o[k2] = m[k];
33
+ }));
34
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
35
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
36
+ }) : function(o, v) {
37
+ o["default"] = v;
38
+ });
39
+ var __importStar = (this && this.__importStar) || (function () {
40
+ var ownKeys = function(o) {
41
+ ownKeys = Object.getOwnPropertyNames || function (o) {
42
+ var ar = [];
43
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
44
+ return ar;
45
+ };
46
+ return ownKeys(o);
47
+ };
48
+ return function (mod) {
49
+ if (mod && mod.__esModule) return mod;
50
+ var result = {};
51
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
52
+ __setModuleDefault(result, mod);
53
+ return result;
54
+ };
55
+ })();
23
56
  Object.defineProperty(exports, "__esModule", { value: true });
24
57
  exports.LiteralQualifierType = void 0;
25
58
  const ts_utils_1 = require("@fgv/ts-utils");
26
59
  const common_1 = require("../common");
27
60
  const qualifierType_1 = require("./qualifierType");
28
61
  const literalValueHierarchy_1 = require("./literalValueHierarchy");
62
+ const Config = __importStar(require("./config"));
29
63
  const ts_json_base_1 = require("@fgv/ts-json-base");
30
64
  /**
31
65
  * A {@link QualifierTypes.QualifierType | qualifier} that matches a literal value,
@@ -49,6 +83,10 @@ class LiteralQualifierType extends qualifierType_1.QualifierType {
49
83
  allowContextList,
50
84
  index: index !== undefined ? common_1.Convert.qualifierTypeIndex.convert(index).orThrow() : undefined
51
85
  });
86
+ /**
87
+ * {@inheritdoc QualifierTypes.IQualifierType.systemTypeName}
88
+ */
89
+ this.systemTypeName = common_1.Convert.qualifierTypeName.convert('literal').orThrow();
52
90
  this.caseSensitive = caseSensitive === true;
53
91
  this.enumeratedValues = enumeratedValues
54
92
  ? (0, ts_utils_1.mapResults)(Array.from(enumeratedValues).map(LiteralQualifierType.toLiteralConditionValue)).orThrow()
@@ -91,6 +129,45 @@ class LiteralQualifierType extends qualifierType_1.QualifierType {
91
129
  }
92
130
  return false;
93
131
  }
132
+ /**
133
+ * Gets a {@link QualifierTypes.Config.ISystemLiteralQualifierTypeConfig | strongly typed configuration object}
134
+ * for this qualifier type.
135
+ * @returns `Success` with the configuration if successful, `Failure` with an error message otherwise.
136
+ */
137
+ getConfiguration() {
138
+ return this.getConfigurationJson().onSuccess((json) => Config.Convert.systemLiteralQualifierTypeConfig.convert(json));
139
+ }
140
+ /**
141
+ * {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
142
+ */
143
+ getConfigurationJson() {
144
+ const hierarchy = this.hierarchy ? { hierarchy: this.hierarchy.asRecord() } : {};
145
+ const enumeratedValues = this.enumeratedValues
146
+ ? { enumeratedValues: [...this.enumeratedValues] }
147
+ : {};
148
+ return (0, ts_utils_1.succeed)({
149
+ name: this.name,
150
+ systemType: 'literal',
151
+ configuration: Object.assign(Object.assign({ allowContextList: this.allowContextList, caseSensitive: this.caseSensitive }, enumeratedValues), hierarchy)
152
+ });
153
+ }
154
+ /**
155
+ * {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
156
+ */
157
+ validateConfigurationJson(from) {
158
+ return Config.Convert.systemLiteralQualifierTypeConfig
159
+ .convert(from)
160
+ .onSuccess((config) => (0, ts_utils_1.succeed)(config));
161
+ }
162
+ /**
163
+ * Validates a {@link QualifierTypes.Config.ISystemLiteralQualifierTypeConfig | strongly typed configuration object}
164
+ * for this qualifier type.
165
+ * @param from - The unknown data to validate as a configuration object.
166
+ * @returns `Success` with the validated configuration if successful, `Failure` with an error message otherwise.
167
+ */
168
+ validateConfiguration(from) {
169
+ return this.validateConfigurationJson(from).onSuccess((json) => Config.Convert.systemLiteralQualifierTypeConfig.convert(json));
170
+ }
94
171
  /**
95
172
  * {@inheritdoc QualifierTypes.QualifierType._matchOne}
96
173
  */
@@ -1,15 +1,6 @@
1
1
  import { Result } from '@fgv/ts-utils';
2
2
  import { ConditionOperator, QualifierConditionValue, QualifierContextValue, QualifierMatchScore } from '../common';
3
- /**
4
- * Declares a hierarchy of literal values. The keys are the names of the values, and the
5
- * values are the names of their parents.
6
- * @remarks
7
- * The hierarchy is defined as a tree, where each value can have multiple children but
8
- * only one parent. The root of the tree has no parent. The hierarchy is used to
9
- * determine the relationship between values when matching conditions and contexts.
10
- * @public
11
- */
12
- export type LiteralValueHierarchyDecl<T extends string> = Partial<Record<T, T>>;
3
+ import { LiteralValueHierarchyDecl } from './config';
13
4
  /**
14
5
  * Describes a single valid literal value including optional parent and child values.
15
6
  * @public
@@ -110,5 +101,10 @@ export declare class LiteralValueHierarchy<T extends string = string> {
110
101
  */
111
102
  match(condition: QualifierConditionValue, context: QualifierContextValue, __operator?: ConditionOperator): QualifierMatchScore;
112
103
  protected static _buildValuesFromHierarchy<T extends string>(params: ILiteralValueHierarchyCreateParams<T>): Result<ReadonlyMap<T, ILiteralValue<T>>>;
104
+ /**
105
+ * Converts the hierarchy to a record of parent-child relationships.
106
+ * @returns A record of parent-child relationships.
107
+ */
108
+ asRecord(): Record<string, string>;
113
109
  }
114
110
  //# sourceMappingURL=literalValueHierarchy.d.ts.map
@@ -223,6 +223,16 @@ class LiteralValueHierarchy {
223
223
  }
224
224
  return errors.returnOrReport((0, ts_utils_1.succeed)(valueMap));
225
225
  }
226
+ /**
227
+ * Converts the hierarchy to a record of parent-child relationships.
228
+ * @returns A record of parent-child relationships.
229
+ */
230
+ asRecord() {
231
+ const entries = Array.from(this.values.values())
232
+ .filter((v) => v.parent !== undefined)
233
+ .map((v) => [v.name, v.parent.name]);
234
+ return Object.fromEntries(entries);
235
+ }
226
236
  }
227
237
  exports.LiteralValueHierarchy = LiteralValueHierarchy;
228
238
  //# sourceMappingURL=literalValueHierarchy.js.map
@@ -1,5 +1,6 @@
1
1
  import { Collections, ICollectible, Result } from '@fgv/ts-utils';
2
2
  import { ConditionOperator, QualifierConditionValue, QualifierContextValue, QualifierMatchScore, QualifierTypeIndex, QualifierTypeName } from '../common';
3
+ import { JsonObject } from '@fgv/ts-json-base';
3
4
  /**
4
5
  * Interface for a qualifier type. A qualifier type implements the build and
5
6
  * runtime semantics for some class of related qualifiers (e.g. language,
@@ -11,6 +12,10 @@ export interface IQualifierType extends ICollectible<QualifierTypeName, Qualifie
11
12
  * The name of the qualifier type.
12
13
  */
13
14
  readonly name: QualifierTypeName;
15
+ /**
16
+ * Name of the underlying system type.
17
+ */
18
+ readonly systemTypeName: QualifierTypeName;
14
19
  /**
15
20
  * Unique key for this qualifier.
16
21
  */
@@ -73,6 +78,17 @@ export interface IQualifierType extends ICollectible<QualifierTypeName, Qualifie
73
78
  * Sets the index for this qualifier type. Once set, index is immutable.
74
79
  */
75
80
  setIndex(index: number): Result<QualifierTypeIndex>;
81
+ /**
82
+ * Gets the configuration for this qualifier type.
83
+ * @returns `Success` with the configuration if successful, `Failure` with an error message otherwise.
84
+ */
85
+ getConfigurationJson(): Result<JsonObject>;
86
+ /**
87
+ * Validates configuration JSON data for this qualifier type.
88
+ * @param from - The unknown data to validate as configuration JSON.
89
+ * @returns `Success` with validated JSON configuration if valid, `Failure` with an error message otherwise.
90
+ */
91
+ validateConfigurationJson(from: unknown): Result<JsonObject>;
76
92
  }
77
93
  /**
78
94
  * Parameters used to create a base {@link QualifierTypes.QualifierType | qualifier type}.
@@ -103,6 +119,10 @@ export declare abstract class QualifierType implements IQualifierType {
103
119
  * {@inheritdoc QualifierTypes.IQualifierType.name}
104
120
  */
105
121
  readonly name: QualifierTypeName;
122
+ /**
123
+ * {@inheritdoc QualifierTypes.IQualifierType.systemTypeName}
124
+ */
125
+ abstract readonly systemTypeName: QualifierTypeName;
106
126
  /**
107
127
  * {@inheritdoc QualifierTypes.IQualifierType.key}
108
128
  */
@@ -148,6 +168,14 @@ export declare abstract class QualifierType implements IQualifierType {
148
168
  * {@inheritdoc QualifierTypes.IQualifierType.matches}
149
169
  */
150
170
  matches(condition: QualifierConditionValue, context: QualifierContextValue, operator: ConditionOperator): QualifierMatchScore;
171
+ /**
172
+ * {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
173
+ */
174
+ abstract getConfigurationJson(): Result<JsonObject>;
175
+ /**
176
+ * {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
177
+ */
178
+ abstract validateConfigurationJson(from: unknown): Result<JsonObject>;
151
179
  /**
152
180
  * {@inheritdoc QualifierTypes.IQualifierType.setIndex}
153
181
  */
@@ -1,8 +1,9 @@
1
1
  import { Result } from '@fgv/ts-utils';
2
- import { QualifierConditionValue, QualifierContextValue, QualifierMatchScore, ConditionOperator } from '../common';
2
+ import { QualifierConditionValue, QualifierContextValue, QualifierMatchScore, ConditionOperator, QualifierTypeName } from '../common';
3
3
  import { QualifierType } from './qualifierType';
4
- import { LiteralValueHierarchy, LiteralValueHierarchyDecl } from './literalValueHierarchy';
4
+ import { LiteralValueHierarchy } from './literalValueHierarchy';
5
5
  import * as Config from './config';
6
+ import { JsonObject } from '@fgv/ts-json-base';
6
7
  /**
7
8
  * Parameters used to create a new {@link QualifierTypes.TerritoryQualifierType | TerritoryQualifierType} instance.
8
9
  * @public
@@ -30,10 +31,10 @@ export interface ITerritoryQualifierTypeCreateParams {
30
31
  */
31
32
  acceptLowercase?: boolean;
32
33
  /**
33
- * Optional {@link QualifierTypes.LiteralValueHierarchyDecl | hierarchy declaration}
34
+ * Optional {@link QualifierTypes.Config.LiteralValueHierarchyDecl | hierarchy declaration}
34
35
  * of territory values to use for matching. If not provided, no hierarchy will be used.
35
36
  */
36
- hierarchy?: LiteralValueHierarchyDecl<string>;
37
+ hierarchy?: Config.LiteralValueHierarchyDecl<string>;
37
38
  }
38
39
  /**
39
40
  * Qualifier type for territory values. Territories are two-letter ISO-3166-2
@@ -42,6 +43,10 @@ export interface ITerritoryQualifierTypeCreateParams {
42
43
  * @public
43
44
  */
44
45
  export declare class TerritoryQualifierType extends QualifierType {
46
+ /**
47
+ * {@inheritdoc QualifierTypes.IQualifierType.systemTypeName}
48
+ */
49
+ readonly systemTypeName: QualifierTypeName;
45
50
  /**
46
51
  * Optional array enumerating allowed territories to further constrain the type.
47
52
  */
@@ -83,6 +88,25 @@ export declare class TerritoryQualifierType extends QualifierType {
83
88
  * @public
84
89
  */
85
90
  static createFromConfig(config: Config.IQualifierTypeConfig<Config.ITerritoryQualifierTypeConfig>): Result<TerritoryQualifierType>;
91
+ /**
92
+ * {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
93
+ */
94
+ getConfiguration(): Result<Config.ISystemTerritoryQualifierTypeConfig>;
95
+ /**
96
+ * {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
97
+ */
98
+ getConfigurationJson(): Result<JsonObject>;
99
+ /**
100
+ * {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
101
+ */
102
+ validateConfigurationJson(from: unknown): Result<JsonObject>;
103
+ /**
104
+ * Validates a {@link QualifierTypes.Config.ISystemTerritoryQualifierTypeConfig | strongly typed configuration object}
105
+ * for this qualifier type.
106
+ * @param from - The unknown data to validate as a configuration object.
107
+ * @returns `Success` with the validated configuration if successful, `Failure` with an error message otherwise.
108
+ */
109
+ validateConfiguration(from: unknown): Result<Config.ISystemTerritoryQualifierTypeConfig>;
86
110
  /**
87
111
  * {@inheritdoc QualifierTypes.QualifierType._matchOne}
88
112
  */
@@ -20,12 +20,46 @@
20
20
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  * SOFTWARE.
22
22
  */
23
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ var desc = Object.getOwnPropertyDescriptor(m, k);
26
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
27
+ desc = { enumerable: true, get: function() { return m[k]; } };
28
+ }
29
+ Object.defineProperty(o, k2, desc);
30
+ }) : (function(o, m, k, k2) {
31
+ if (k2 === undefined) k2 = k;
32
+ o[k2] = m[k];
33
+ }));
34
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
35
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
36
+ }) : function(o, v) {
37
+ o["default"] = v;
38
+ });
39
+ var __importStar = (this && this.__importStar) || (function () {
40
+ var ownKeys = function(o) {
41
+ ownKeys = Object.getOwnPropertyNames || function (o) {
42
+ var ar = [];
43
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
44
+ return ar;
45
+ };
46
+ return ownKeys(o);
47
+ };
48
+ return function (mod) {
49
+ if (mod && mod.__esModule) return mod;
50
+ var result = {};
51
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
52
+ __setModuleDefault(result, mod);
53
+ return result;
54
+ };
55
+ })();
23
56
  Object.defineProperty(exports, "__esModule", { value: true });
24
57
  exports.TerritoryQualifierType = void 0;
25
58
  const ts_utils_1 = require("@fgv/ts-utils");
26
59
  const common_1 = require("../common");
27
60
  const qualifierType_1 = require("./qualifierType");
28
61
  const literalValueHierarchy_1 = require("./literalValueHierarchy");
62
+ const Config = __importStar(require("./config"));
29
63
  const ts_json_base_1 = require("@fgv/ts-json-base");
30
64
  /**
31
65
  * Qualifier type for territory values. Territories are two-letter ISO-3166-2
@@ -51,6 +85,12 @@ class TerritoryQualifierType extends qualifierType_1.QualifierType {
51
85
  allowContextList,
52
86
  index: validIndex
53
87
  });
88
+ /**
89
+ * {@inheritdoc QualifierTypes.IQualifierType.systemTypeName}
90
+ */
91
+ this.systemTypeName = common_1.Convert.qualifierTypeName
92
+ .convert('territory')
93
+ .orThrow();
54
94
  this.allowedTerritories = validTerritories;
55
95
  this.acceptLowercase = acceptLowercase === true;
56
96
  if (hierarchy) {
@@ -106,6 +146,43 @@ class TerritoryQualifierType extends qualifierType_1.QualifierType {
106
146
  hierarchy: territoryConfig.hierarchy
107
147
  }).onSuccess(TerritoryQualifierType.create);
108
148
  }
149
+ /**
150
+ * {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
151
+ */
152
+ getConfiguration() {
153
+ return this.getConfigurationJson().onSuccess((json) => Config.Convert.systemTerritoryQualifierTypeConfig.convert(json));
154
+ }
155
+ /**
156
+ * {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
157
+ */
158
+ getConfigurationJson() {
159
+ const hierarchy = this.hierarchy ? { hierarchy: this.hierarchy.asRecord() } : {};
160
+ const allowedTerritories = this.allowedTerritories
161
+ ? { allowedTerritories: [...this.allowedTerritories] }
162
+ : {};
163
+ return (0, ts_utils_1.succeed)({
164
+ name: this.name,
165
+ systemType: 'territory',
166
+ configuration: Object.assign(Object.assign({ allowContextList: this.allowContextList, acceptLowercase: this.acceptLowercase }, allowedTerritories), hierarchy)
167
+ });
168
+ }
169
+ /**
170
+ * {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
171
+ */
172
+ validateConfigurationJson(from) {
173
+ return Config.Convert.systemTerritoryQualifierTypeConfig
174
+ .convert(from)
175
+ .onSuccess((config) => (0, ts_utils_1.succeed)(config));
176
+ }
177
+ /**
178
+ * Validates a {@link QualifierTypes.Config.ISystemTerritoryQualifierTypeConfig | strongly typed configuration object}
179
+ * for this qualifier type.
180
+ * @param from - The unknown data to validate as a configuration object.
181
+ * @returns `Success` with the validated configuration if successful, `Failure` with an error message otherwise.
182
+ */
183
+ validateConfiguration(from) {
184
+ return this.validateConfigurationJson(from).onSuccess((json) => Config.Convert.systemTerritoryQualifierTypeConfig.convert(json));
185
+ }
109
186
  /**
110
187
  * {@inheritdoc QualifierTypes.QualifierType._matchOne}
111
188
  */
@@ -136,7 +136,7 @@ exports.compiledAbstractDecision = ts_utils_1.Converters.strictObject({
136
136
  * @public
137
137
  */
138
138
  exports.compiledCandidate = ts_utils_1.Converters.strictObject({
139
- json: ts_json_base_1.Converters.jsonValue,
139
+ valueIndex: Common.Convert.candidateValueIndex,
140
140
  isPartial: ts_utils_1.Converters.boolean,
141
141
  mergeMethod: Common.Convert.resourceValueMergeMethod
142
142
  });
@@ -162,6 +162,7 @@ exports.compiledResourceCollection = ts_utils_1.Converters.strictObject({
162
162
  conditions: ts_utils_1.Converters.arrayOf(exports.compiledCondition),
163
163
  conditionSets: ts_utils_1.Converters.arrayOf(exports.compiledConditionSet),
164
164
  decisions: ts_utils_1.Converters.arrayOf(exports.compiledAbstractDecision),
165
+ candidateValues: ts_utils_1.Converters.arrayOf(ts_json_base_1.Converters.jsonValue),
165
166
  resources: ts_utils_1.Converters.arrayOf(exports.compiledResource)
166
167
  });
167
168
  //# sourceMappingURL=convert.js.map
@@ -132,9 +132,9 @@ export interface ICompiledAbstractDecision {
132
132
  */
133
133
  export interface ICompiledCandidate {
134
134
  /**
135
- * The JSON value of the candidate.
135
+ * The global index of the JSON value of the candidate.
136
136
  */
137
- json: JsonValue;
137
+ valueIndex: Common.CandidateValueIndex;
138
138
  /**
139
139
  * Indicates if this is a partial resource that needs to be merged.
140
140
  */
@@ -196,6 +196,10 @@ export interface ICompiledResourceCollection {
196
196
  * Array of all decisions in the collection.
197
197
  */
198
198
  decisions: ReadonlyArray<ICompiledAbstractDecision>;
199
+ /**
200
+ * Array of all candidate values in the collection.
201
+ */
202
+ candidateValues: ReadonlyArray<JsonValue>;
199
203
  /**
200
204
  * Array of all resources in the collection.
201
205
  */
@@ -24,6 +24,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.resourceTypeConfig = void 0;
25
25
  /* eslint-disable @rushstack/typedef-var */
26
26
  const ts_utils_1 = require("@fgv/ts-utils");
27
+ const ts_json_base_1 = require("@fgv/ts-json-base");
27
28
  /**
28
29
  * A `Converter` for {@link ResourceTypes.Config.IResourceTypeConfig | ResourceTypeConfig} objects.
29
30
  * @returns A `Converter` for {@link ResourceTypes.Config.IResourceTypeConfig | ResourceTypeConfig} objects.
@@ -31,6 +32,7 @@ const ts_utils_1 = require("@fgv/ts-utils");
31
32
  */
32
33
  exports.resourceTypeConfig = ts_utils_1.Converters.strictObject({
33
34
  name: ts_utils_1.Converters.string,
34
- typeName: ts_utils_1.Converters.string
35
+ typeName: ts_utils_1.Converters.string,
36
+ template: ts_json_base_1.Converters.jsonObject.optional()
35
37
  });
36
38
  //# sourceMappingURL=convert.js.map
@@ -1,3 +1,4 @@
1
+ import { JsonObject } from '@fgv/ts-json-base';
1
2
  /**
2
3
  * Configuration for a {@link ResourceTypes.ResourceType | resource type}.
3
4
  * @public
@@ -5,5 +6,6 @@
5
6
  export interface IResourceTypeConfig {
6
7
  name: string;
7
8
  typeName: string;
9
+ template?: JsonObject;
8
10
  }
9
11
  //# sourceMappingURL=json.d.ts.map
@@ -17,19 +17,28 @@ export interface IJsonResourceTypeCreateParams {
17
17
  * instance.
18
18
  */
19
19
  index?: number;
20
+ /**
21
+ * Optional template for new instances of {@link ResourceTypes.JsonResourceType | JsonResourceType}
22
+ * resources.
23
+ */
24
+ template?: JsonObject;
20
25
  }
21
26
  /**
22
27
  * Implementation of a {@link ResourceTypes.ResourceType | ResourceType} for JSON values.
23
28
  * @public
24
29
  */
25
30
  export declare class JsonResourceType extends ResourceType<JsonObject> {
31
+ /**
32
+ * {@inheritdoc ResourceTypes.ResourceType.systemTypeName}
33
+ */
34
+ readonly systemTypeName: ResourceTypeName;
26
35
  /**
27
36
  * Protected {@link ResourceTypes.JsonResourceType | JsonResourceType} constructor for use by subclasses.
28
37
  * Use {@link ResourceTypes.JsonResourceType.create | JsonResourceType.create} to create a new instance.
29
38
  * @param key - The key for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.
30
39
  * @param index - Optional index for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.
31
40
  */
32
- protected constructor(key: ResourceTypeName, index?: number);
41
+ protected constructor(key: ResourceTypeName, index?: number, template?: JsonObject);
33
42
  /**
34
43
  * Factory method to create a new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.
35
44
  * @param params - {@link ResourceTypes.IJsonResourceTypeCreateParams | Parameters} to create the new instance.
@@ -53,10 +62,5 @@ export declare class JsonResourceType extends ResourceType<JsonObject> {
53
62
  * {@inheritdoc ResourceTypes.ResourceType.(validate:3)}
54
63
  */
55
64
  validate(json: JsonObject, completeness: 'partial'): Result<JsonObject>;
56
- /**
57
- * Gets the default template value for a JSON resource type.
58
- * @returns An empty object as the default JSON value
59
- */
60
- protected getDefaultTemplateValue(): JsonObject;
61
65
  }
62
66
  //# sourceMappingURL=jsonResourceType.d.ts.map
@@ -37,8 +37,12 @@ class JsonResourceType extends resourceType_1.ResourceType {
37
37
  * @param key - The key for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.
38
38
  * @param index - Optional index for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.
39
39
  */
40
- constructor(key, index) {
41
- super(key, index);
40
+ constructor(key, index, template) {
41
+ super(key, index, template);
42
+ /**
43
+ * {@inheritdoc ResourceTypes.ResourceType.systemTypeName}
44
+ */
45
+ this.systemTypeName = common_1.Convert.resourceTypeName.convert('json').orThrow();
42
46
  }
43
47
  /**
44
48
  * Factory method to create a new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.
@@ -49,7 +53,7 @@ class JsonResourceType extends resourceType_1.ResourceType {
49
53
  static create(params) {
50
54
  var _a;
51
55
  return common_1.Convert.resourceTypeName.convert((_a = params === null || params === void 0 ? void 0 : params.key) !== null && _a !== void 0 ? _a : 'json').onSuccess((key) => {
52
- return (0, ts_utils_1.captureResult)(() => new JsonResourceType(key, params === null || params === void 0 ? void 0 : params.index));
56
+ return (0, ts_utils_1.captureResult)(() => new JsonResourceType(key, params === null || params === void 0 ? void 0 : params.index, params === null || params === void 0 ? void 0 : params.template));
53
57
  });
54
58
  }
55
59
  /**
@@ -61,13 +65,6 @@ class JsonResourceType extends resourceType_1.ResourceType {
61
65
  validate(json, __completeness) {
62
66
  return ts_json_base_1.Converters.jsonObject.convert(json);
63
67
  }
64
- /**
65
- * Gets the default template value for a JSON resource type.
66
- * @returns An empty object as the default JSON value
67
- */
68
- getDefaultTemplateValue() {
69
- return {};
70
- }
71
68
  }
72
69
  exports.JsonResourceType = JsonResourceType;
73
70
  //# sourceMappingURL=jsonResourceType.js.map
@@ -1,6 +1,6 @@
1
- import { JsonValue, JsonObject } from '@fgv/ts-json-base';
1
+ import { JsonObject, JsonValue } from '@fgv/ts-json-base';
2
2
  import { ICollectible, Result } from '@fgv/ts-utils';
3
- import { CandidateCompleteness, ResourceTypeIndex, ResourceTypeName, ResourceValueMergeMethod, ResourceId } from '../common';
3
+ import { CandidateCompleteness, ResourceTypeIndex, ResourceTypeName, ResourceValueMergeMethod, ResourceId, IResourceResolver } from '../common';
4
4
  import * as ResourceJson from '../resource-json';
5
5
  /**
6
6
  * Parameters used to validate a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}.
@@ -86,11 +86,14 @@ export interface IResourceType<T = unknown> extends ICollectible<ResourceTypeNam
86
86
  /**
87
87
  * Creates a template for a new resource of this type.
88
88
  * The template provides a default structure for creating new resource instances.
89
- * @param resourceId - The id for the new resource
90
- * @returns A loose resource declaration with default values for this resource type
89
+ * @param resourceId - The id for the new resource.
90
+ * @param init - An optional initial value for the resource.
91
+ * @param resolver - An optional resource resolver that can be used to create the template.
92
+ * @param conditions - An optional set of conditions that must be met for the resource to be selected.
93
+ * @returns A loose resource declaration with default values for this resource type.
91
94
  * @public
92
95
  */
93
- createTemplate(resourceId: ResourceId): ResourceJson.Json.ILooseResourceDecl;
96
+ createTemplate(resourceId: ResourceId, init?: JsonValue, conditions?: ResourceJson.Json.ConditionSetDecl, resolver?: IResourceResolver): Result<ResourceJson.Json.ILooseResourceDecl>;
94
97
  }
95
98
  /**
96
99
  * Abstract base class for resource types which are responsible for
@@ -100,15 +103,20 @@ export interface IResourceType<T = unknown> extends ICollectible<ResourceTypeNam
100
103
  */
101
104
  export declare abstract class ResourceType<T = unknown> implements IResourceType<T> {
102
105
  private _collectible;
106
+ private _template;
103
107
  /**
104
108
  * {@inheritdoc ResourceTypes.IResourceType.key}
105
109
  */
106
110
  get key(): ResourceTypeName;
111
+ /**
112
+ * Name of the underlying system type.
113
+ */
114
+ abstract readonly systemTypeName: ResourceTypeName;
107
115
  /**
108
116
  * {@inheritdoc ResourceTypes.IResourceType.index}
109
117
  */
110
118
  get index(): ResourceTypeIndex | undefined;
111
- protected constructor(key: ResourceTypeName, index?: number);
119
+ protected constructor(key: ResourceTypeName, index?: number, template?: JsonObject);
112
120
  /**
113
121
  * Validates properties of a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration} for
114
122
  * a resource instance value.
@@ -163,15 +171,19 @@ export declare abstract class ResourceType<T = unknown> implements IResourceType
163
171
  * Default implementation provides a basic template.
164
172
  * Subclasses can override to provide type-specific templates.
165
173
  * @param resourceId - The id for the new resource
174
+ * @param init - An optional initial value for the resource.
175
+ * @param conditions - An optional set of conditions that must be met for the resource to be selected.
176
+ * @param resolver - An optional resource resolver that can be used to create the template.
166
177
  * @returns A loose resource declaration with default values for this resource type
167
178
  * @public
168
179
  */
169
- createTemplate(resourceId: ResourceId): ResourceJson.Json.ILooseResourceDecl;
180
+ createTemplate(resourceId: ResourceId, init?: JsonValue, conditions?: ResourceJson.Json.ConditionSetDecl, resolver?: IResourceResolver): Result<ResourceJson.Json.ILooseResourceDecl>;
170
181
  /**
171
182
  * Gets the default template value for this resource type.
172
183
  * Subclasses should override this to provide type-specific default values.
173
184
  * @returns The default JSON value for a new resource of this type
185
+ * @public
174
186
  */
175
- protected getDefaultTemplateValue(): JsonObject;
187
+ getDefaultTemplateCandidate(json?: JsonValue, conditions?: ResourceJson.Json.ConditionSetDecl, __resolver?: IResourceResolver): Result<ResourceJson.Json.IChildResourceCandidateDecl>;
176
188
  }
177
189
  //# sourceMappingURL=resourceType.d.ts.map