@fgv/ts-res 5.0.0-6 → 5.0.0-8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ts-res.d.ts CHANGED
@@ -227,6 +227,15 @@ declare class Candidate<TVALUE extends JsonValue = JsonValue> implements ICandid
227
227
  */
228
228
  declare type CandidateAction = 'unchanged' | 'reduced' | 'suppressed';
229
229
 
230
+ /**
231
+ * The completeness of a resource candidate value. A full value is one that
232
+ * contains all of the required properties for the resource type. A partial
233
+ * value is one that contains some of the required properties for the resource
234
+ * type.
235
+ * @public
236
+ */
237
+ export declare type CandidateCompleteness = 'full' | 'partial';
238
+
230
239
  /**
231
240
  * Manages candidate reduction logic for filtering and qualifier reduction operations.
232
241
  * Encapsulates the state and logic needed to consistently process candidates for reduction.
@@ -402,7 +411,8 @@ declare namespace Common {
402
411
  ResourceTypeName,
403
412
  ResourceTypeIndex,
404
413
  ResourceValueMergeMethod,
405
- allResourceValueMergeMethods
414
+ allResourceValueMergeMethods,
415
+ CandidateCompleteness
406
416
  }
407
417
  }
408
418
 
@@ -685,7 +695,7 @@ declare class ConcreteDecision<TVALUE extends JsonValue = JsonValue> implements
685
695
  * Represents a single condition applied to some resource instance.
686
696
  * @public
687
697
  */
688
- declare class Condition implements IValidatedConditionDecl {
698
+ export declare class Condition implements IValidatedConditionDecl {
689
699
  /**
690
700
  * The {@link Qualifiers.Qualifier | qualifier} used in this condition.
691
701
  */
@@ -932,7 +942,7 @@ declare const conditionPriority: Converter<ConditionPriority, unknown>;
932
942
 
933
943
  declare namespace Conditions {
934
944
  export {
935
- Convert_2 as Convert,
945
+ Convert_5 as Convert,
936
946
  Condition,
937
947
  IConditionCollectorCreateParams,
938
948
  ConditionCollector,
@@ -956,7 +966,7 @@ export { Conditions }
956
966
  * context for a resource instance to be valid.
957
967
  * @public
958
968
  */
959
- declare class ConditionSet implements IValidatedConditionSetDecl {
969
+ export declare class ConditionSet implements IValidatedConditionSetDecl {
960
970
  protected readonly _collectible: Collections.Collectible<ConditionSetKey, ConditionSetIndex>;
961
971
  /**
962
972
  * The {@link Conditions.Condition | conditions} that make up this condition
@@ -1120,10 +1130,10 @@ declare class ConditionSetCollector extends ValidatingCollector<ConditionSet> {
1120
1130
  declare type ConditionSetDecl = ConditionSetDeclAsArray | ConditionSetDeclAsRecord;
1121
1131
 
1122
1132
  /**
1123
- * Converter which converts to a {@link Conditions.IConditionSetDecl | condition set declaration}.
1133
+ * `Converter` for a normalized {@link ResourceJson.Normalized.ConditionSetDecl | condition set declaration}.
1124
1134
  * @public
1125
1135
  */
1126
- declare const conditionSetDecl: ObjectConverter<IConditionSetDecl, unknown>;
1136
+ declare const conditionSetDecl: Converter<Normalized.ConditionSetDecl>;
1127
1137
 
1128
1138
  /**
1129
1139
  * Normalized non-validated declaration of a {@link Conditions.Condition | condition}.
@@ -1132,10 +1142,10 @@ declare const conditionSetDecl: ObjectConverter<IConditionSetDecl, unknown>;
1132
1142
  declare type ConditionSetDecl_2 = ReadonlyArray<ILooseConditionDecl>;
1133
1143
 
1134
1144
  /**
1135
- * `Converter` for a normalized {@link ResourceJson.Normalized.ConditionSetDecl | condition set declaration}.
1145
+ * Converter which converts to a {@link Conditions.IConditionSetDecl | condition set declaration}.
1136
1146
  * @public
1137
1147
  */
1138
- declare const conditionSetDecl_2: Converter<Normalized.ConditionSetDecl>;
1148
+ declare const conditionSetDecl_2: ObjectConverter<IConditionSetDecl, unknown>;
1139
1149
 
1140
1150
  /**
1141
1151
  * Non-validated declaration of a {@link Conditions.Condition | condition}.
@@ -1417,7 +1427,7 @@ declare const containerContextDecl: Converter<Normalized.IContainerContextDecl>;
1417
1427
 
1418
1428
  declare namespace Context {
1419
1429
  export {
1420
- Convert_5 as Convert,
1430
+ Convert_2 as Convert,
1421
1431
  IContextMatchOptions,
1422
1432
  IContextQualifierValueDecl,
1423
1433
  IContextDecl,
@@ -1767,12 +1777,11 @@ declare namespace Convert_10 {
1767
1777
 
1768
1778
  declare namespace Convert_2 {
1769
1779
  export {
1770
- conditionDecl,
1771
- IConditionDeclConvertContext,
1772
- validatedConditionDecl,
1773
- conditionSetDecl,
1774
- IConditionSetDeclConvertContext,
1775
- validatedConditionSetDecl
1780
+ contextQualifierValueDecl,
1781
+ contextDecl,
1782
+ IContextDeclConvertContext,
1783
+ validatedContextQualifierValueDecl,
1784
+ validatedContextDecl
1776
1785
  }
1777
1786
  }
1778
1787
 
@@ -1797,7 +1806,7 @@ declare namespace Convert_4 {
1797
1806
  export {
1798
1807
  looseConditionDecl,
1799
1808
  childConditionDecl,
1800
- conditionSetDecl_2 as conditionSetDecl,
1809
+ conditionSetDecl,
1801
1810
  looseResourceCandidateDecl,
1802
1811
  importerResourceCandidateDecl,
1803
1812
  childResourceCandidateDecl,
@@ -1813,11 +1822,12 @@ declare namespace Convert_4 {
1813
1822
 
1814
1823
  declare namespace Convert_5 {
1815
1824
  export {
1816
- contextQualifierValueDecl,
1817
- contextDecl,
1818
- IContextDeclConvertContext,
1819
- validatedContextQualifierValueDecl,
1820
- validatedContextDecl
1825
+ conditionDecl,
1826
+ IConditionDeclConvertContext,
1827
+ validatedConditionDecl,
1828
+ conditionSetDecl_2 as conditionSetDecl,
1829
+ IConditionSetDeclConvertContext,
1830
+ validatedConditionSetDecl
1821
1831
  }
1822
1832
  }
1823
1833
 
@@ -1895,7 +1905,7 @@ declare function createResourceTypeFromConfig(config: IResourceTypeConfig): Resu
1895
1905
  * Simple collectible implementation of {@link Decisions.IDecision | IDecision}.
1896
1906
  * @public
1897
1907
  */
1898
- declare class Decision<TVALUE extends JsonValue = JsonValue> implements IDecision<TVALUE> {
1908
+ export declare class Decision<TVALUE extends JsonValue = JsonValue> implements IDecision<TVALUE> {
1899
1909
  /**
1900
1910
  * The sorted {@link Conditions.ConditionSet | ConditionSets} that make up this decision.
1901
1911
  * @public
@@ -4281,7 +4291,7 @@ declare interface IResourceDeclContainer {
4281
4291
  * implementations without requiring the full ResourceManagerBuilder build mechanics.
4282
4292
  * @public
4283
4293
  */
4284
- declare interface IResourceManager {
4294
+ export declare interface IResourceManager {
4285
4295
  /**
4286
4296
  * A {@link Conditions.ReadOnlyConditionCollector | ReadOnlyConditionCollector} which
4287
4297
  * contains the {@link Conditions.Condition | conditions} used by resource candidates.
@@ -4405,6 +4415,24 @@ declare interface IResourceResolverCreateParams {
4405
4415
  * An optional listener for {@link Runtime.ResourceResolver | ResourceResolver} cache activity.
4406
4416
  */
4407
4417
  listener?: IResourceResolverCacheListener;
4418
+ /**
4419
+ * Optional configuration options for the {@link Runtime.ResourceResolver | ResourceResolver}.
4420
+ */
4421
+ options?: IResourceResolverOptions;
4422
+ }
4423
+
4424
+ /**
4425
+ * Options for configuring a {@link Runtime.ResourceResolver | ResourceResolver}.
4426
+ * @public
4427
+ */
4428
+ declare interface IResourceResolverOptions {
4429
+ /**
4430
+ * Controls whether null values in resource composition should suppress properties
4431
+ * instead of setting them to null. When true, properties with null values from
4432
+ * higher-priority partial candidates will be omitted from the final composed resource.
4433
+ * @defaultValue false
4434
+ */
4435
+ suppressNullAsDelete?: boolean;
4408
4436
  }
4409
4437
 
4410
4438
  /**
@@ -5083,15 +5111,15 @@ declare class JsonResourceType extends ResourceType<JsonObject> {
5083
5111
  /**
5084
5112
  * {@inheritdoc ResourceTypes.ResourceType.(validate:1)}
5085
5113
  */
5086
- validate(json: JsonObject, isPartial: true): Result<JsonObject>;
5114
+ validate(json: JsonObject, completeness: CandidateCompleteness): Result<JsonObject>;
5087
5115
  /**
5088
5116
  * {@inheritdoc ResourceTypes.ResourceType.(validate:2)}
5089
5117
  */
5090
- validate(json: JsonObject, isPartial: false): Result<JsonObject>;
5118
+ validate(json: JsonObject, completeness: 'full'): Result<JsonObject>;
5091
5119
  /**
5092
5120
  * {@inheritdoc ResourceTypes.ResourceType.(validate:3)}
5093
5121
  */
5094
- validate(json: JsonObject, isPartial: boolean): Result<JsonObject>;
5122
+ validate(json: JsonObject, completeness: 'partial'): Result<JsonObject>;
5095
5123
  }
5096
5124
 
5097
5125
  /**
@@ -5714,7 +5742,7 @@ declare const predefinedSystemConfiguration: Converter<PredefinedSystemConfigura
5714
5742
  * which a resource is used.
5715
5743
  * @public
5716
5744
  */
5717
- declare class Qualifier implements IValidatedQualifierDecl, ICollectible<QualifierName, QualifierIndex> {
5745
+ export declare class Qualifier implements IValidatedQualifierDecl, ICollectible<QualifierName, QualifierIndex> {
5718
5746
  /**
5719
5747
  * The name of the qualifier.
5720
5748
  */
@@ -6074,7 +6102,7 @@ export { Qualifiers }
6074
6102
  * the {@link QualifierTypes.IQualifierType | IQualifierType} interface.
6075
6103
  * @public
6076
6104
  */
6077
- declare abstract class QualifierType implements IQualifierType {
6105
+ export declare abstract class QualifierType implements IQualifierType {
6078
6106
  /**
6079
6107
  * {@inheritdoc QualifierTypes.IQualifierType.name}
6080
6108
  */
@@ -6427,7 +6455,7 @@ declare namespace RegularExpressions {
6427
6455
  * candidate instances.
6428
6456
  * @public
6429
6457
  */
6430
- declare class Resource implements IResource {
6458
+ export declare class Resource implements IResource {
6431
6459
  /**
6432
6460
  * The unique {@link ResourceId | id} of the resource.
6433
6461
  */
@@ -6643,7 +6671,7 @@ declare type ResourceBuilderResultDetail = Collections.ResultMapResultDetail | '
6643
6671
  * and instructions on how to merge it with other instances.
6644
6672
  * @public
6645
6673
  */
6646
- declare class ResourceCandidate implements IResourceCandidate {
6674
+ export declare class ResourceCandidate implements IResourceCandidate {
6647
6675
  /**
6648
6676
  * The unique identifier of the resource for which this candidate
6649
6677
  * is a possible instance.
@@ -6888,7 +6916,7 @@ export { ResourceJson }
6888
6916
  * and builds a collection of {@link Resources.Resource | resources} once all candidates are collected.
6889
6917
  * @public
6890
6918
  */
6891
- declare class ResourceManagerBuilder implements IResourceManager {
6919
+ export declare class ResourceManagerBuilder implements IResourceManager {
6892
6920
  readonly qualifiers: IReadOnlyQualifierCollector;
6893
6921
  readonly resourceTypes: ReadOnlyResourceTypeCollector;
6894
6922
  protected readonly _conditions: ConditionCollector;
@@ -6953,6 +6981,15 @@ declare class ResourceManagerBuilder implements IResourceManager {
6953
6981
  * @public
6954
6982
  */
6955
6983
  static create(params: IResourceManagerBuilderCreateParams): Result<ResourceManagerBuilder>;
6984
+ /**
6985
+ * Creates a new {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder} object from a predefined system configuration.
6986
+ * @param name - The name of the predefined system configuration to use.
6987
+ * @param qualifierDefaultValues - Optional default values for qualifiers.
6988
+ * @returns `Success` with the new {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder} object if successful,
6989
+ * or `Failure` with an error message if not.
6990
+ * @public
6991
+ */
6992
+ static createPredefined(name: Config.PredefinedSystemConfiguration, qualifierDefaultValues?: Config.ISystemConfigurationInitParams['qualifierDefaultValues']): Result<ResourceManagerBuilder>;
6956
6993
  /**
6957
6994
  * Given a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}, builds and adds
6958
6995
  * a {@link Resources.ResourceCandidate | candidate} to the manager.
@@ -7136,7 +7173,7 @@ declare const resourceName: Converter<ResourceName, unknown>;
7136
7173
  * and caching results for optimal performance.
7137
7174
  * @public
7138
7175
  */
7139
- declare class ResourceResolver {
7176
+ export declare class ResourceResolver {
7140
7177
  /**
7141
7178
  * The resource manager that defines available resources and provides condition access.
7142
7179
  */
@@ -7149,6 +7186,10 @@ declare class ResourceResolver {
7149
7186
  * The context qualifier provider that resolves qualifier values.
7150
7187
  */
7151
7188
  readonly contextQualifierProvider: IContextQualifierProvider;
7189
+ /**
7190
+ * The configuration options for this resource resolver.
7191
+ */
7192
+ readonly options: IResourceResolverOptions;
7152
7193
  /**
7153
7194
  * The cache array for resolved conditions, indexed by condition index for O(1) lookup.
7154
7195
  * Each entry stores the resolved {@link Runtime.IConditionMatchResult | condition match result} for
@@ -7500,7 +7541,7 @@ declare const resourceTreeRootDecl: Converter<Normalized.IResourceTreeRootDecl>;
7500
7541
  * resource value.
7501
7542
  * @public
7502
7543
  */
7503
- declare abstract class ResourceType<T = unknown> implements ICollectible<ResourceTypeName, ResourceTypeIndex> {
7544
+ export declare abstract class ResourceType<T = unknown> implements ICollectible<ResourceTypeName, ResourceTypeIndex> {
7504
7545
  private _collectible;
7505
7546
  /**
7506
7547
  * The key for this resource type.
@@ -7523,30 +7564,39 @@ declare abstract class ResourceType<T = unknown> implements ICollectible<Resourc
7523
7564
  /**
7524
7565
  * Validates a JSON value for use as a partial resource instance value.
7525
7566
  * @param json - The JSON value to validate.
7526
- * @param isPartial - `true` indicates that the value is expected to be partial.
7567
+ * @param completeness - Describes {@link CandidateCompleteness | how complete} the candidate value is.
7527
7568
  * @returns `Success` with the strongly-typed partial resource value if the JSON is valid,
7528
7569
  * `Failure` with an error message otherwise.
7529
7570
  * @public
7530
7571
  */
7531
- abstract validate(json: JsonValue, isPartial: true): Result<Partial<T>>;
7572
+ abstract validate(json: JsonValue, completeness: CandidateCompleteness): Result<Partial<T>>;
7532
7573
  /**
7533
7574
  * Validates a JSON value for use as a complete resource instance value.
7534
7575
  * @param json - The JSON value to validate.
7535
- * @param isPartial - `false` indicates that the value is expected to be complete.
7576
+ * @param completeness - Describes {@link CandidateCompleteness | how complete} the candidate value is.
7536
7577
  * @returns `Success` with the strongly-typed resource value if the JSON is valid,
7537
7578
  * `Failure` with an error message otherwise.
7538
7579
  * @public
7539
7580
  */
7540
- abstract validate(json: JsonValue, isPartial: false): Result<T>;
7581
+ abstract validate(json: JsonValue, completeness: 'full'): Result<T>;
7582
+ /**
7583
+ * Validates a JSON value for use as a partial resource instance value.
7584
+ * @param json - The JSON value to validate.
7585
+ * @param completeness - Describes {@link CandidateCompleteness | how complete} the candidate value is.
7586
+ * @returns `Success` with the strongly-typed partial resource value if the JSON is valid,
7587
+ * `Failure` with an error message otherwise.
7588
+ * @public
7589
+ */
7590
+ abstract validate(json: JsonValue, completeness: 'partial'): Result<Partial<T>>;
7541
7591
  /**
7542
7592
  * Validates a JSON value for use as a full or partial resource instance value.
7543
7593
  * @param json - The JSON value to validate.
7544
- * @param isPartial - Indicates whether the value is expected to be partial.
7594
+ * @param completeness - Describes {@link CandidateCompleteness | how complete} the candidate value is.
7545
7595
  * @returns `Success` with the strongly-typed full or partial resource value if
7546
7596
  * the JSON is valid, `Failure` with an error message otherwise.
7547
7597
  * @public
7548
7598
  */
7549
- abstract validate(json: JsonValue, isPartial?: boolean): Result<T | Partial<T>>;
7599
+ abstract validate(json: JsonValue, completeness?: CandidateCompleteness): Result<T | Partial<T>>;
7550
7600
  /**
7551
7601
  * Sets the index for this resource type. Once set, the index cannot be changed.
7552
7602
  */
@@ -7644,6 +7694,7 @@ declare namespace Runtime {
7644
7694
  IValidatingSimpleContextQualifierProviderCreateParams,
7645
7695
  ValidatingSimpleContextQualifierProvider,
7646
7696
  DecisionResolutionResult,
7697
+ IResourceResolverOptions,
7647
7698
  IResourceResolverCreateParams,
7648
7699
  ResourceResolver,
7649
7700
  ConditionMatchType,
package/lib/index.d.ts CHANGED
@@ -10,6 +10,12 @@ import * as ResourceTypes from './packlets/resource-types';
10
10
  import * as Import from './packlets/import';
11
11
  import * as Runtime from './packlets/runtime';
12
12
  export * from './packlets/common';
13
- export * from './packlets/common';
14
- export { Conditions, Config, Context, Decisions, Import, QualifierTypes, Qualifiers, ResourceJson, Resources, ResourceTypes, Runtime };
13
+ import { Condition, ConditionSet } from './packlets/conditions';
14
+ import { Decision } from './packlets/decisions';
15
+ import { QualifierType } from './packlets/qualifier-types';
16
+ import { Qualifier } from './packlets/qualifiers';
17
+ import { ResourceType } from './packlets/resource-types';
18
+ import { Resource, ResourceCandidate, ResourceManagerBuilder } from './packlets/resources';
19
+ import { IResourceManager, ResourceResolver } from './packlets/runtime';
20
+ export { Condition, Conditions, ConditionSet, Config, Context, Decision, Decisions, Import, IResourceManager, Qualifier, QualifierType, QualifierTypes, Qualifiers, Resource, ResourceCandidate, ResourceJson, ResourceResolver, ResourceManagerBuilder, ResourceType, ResourceTypes, Resources, Runtime };
15
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,cAAc,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,YAAY,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,aAAa,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAE9C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAElC,OAAO,EACL,UAAU,EACV,MAAM,EACN,OAAO,EACP,SAAS,EACT,MAAM,EACN,cAAc,EACd,UAAU,EACV,YAAY,EACZ,SAAS,EACT,aAAa,EACb,OAAO,EACR,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,cAAc,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,YAAY,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,aAAa,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAE9C,cAAc,mBAAmB,CAAC;AAElC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,EACL,SAAS,EACT,UAAU,EACV,YAAY,EACZ,MAAM,EACN,OAAO,EACP,QAAQ,EACR,SAAS,EACT,MAAM,EACN,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,cAAc,EACd,UAAU,EACV,QAAQ,EACR,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,SAAS,EACT,OAAO,EACR,CAAC"}
package/lib/index.js CHANGED
@@ -57,7 +57,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
57
57
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
58
58
  };
59
59
  Object.defineProperty(exports, "__esModule", { value: true });
60
- exports.Runtime = exports.ResourceTypes = exports.Resources = exports.ResourceJson = exports.Qualifiers = exports.QualifierTypes = exports.Import = exports.Decisions = exports.Context = exports.Config = exports.Conditions = void 0;
60
+ exports.Runtime = exports.Resources = exports.ResourceTypes = exports.ResourceType = exports.ResourceManagerBuilder = exports.ResourceResolver = exports.ResourceJson = exports.ResourceCandidate = exports.Resource = exports.Qualifiers = exports.QualifierTypes = exports.QualifierType = exports.Qualifier = exports.Import = exports.Decisions = exports.Decision = exports.Context = exports.Config = exports.ConditionSet = exports.Conditions = exports.Condition = void 0;
61
61
  const QualifierTypes = __importStar(require("./packlets/qualifier-types"));
62
62
  exports.QualifierTypes = QualifierTypes;
63
63
  const Qualifiers = __importStar(require("./packlets/qualifiers"));
@@ -81,5 +81,21 @@ exports.Import = Import;
81
81
  const Runtime = __importStar(require("./packlets/runtime"));
82
82
  exports.Runtime = Runtime;
83
83
  __exportStar(require("./packlets/common"), exports);
84
- __exportStar(require("./packlets/common"), exports);
84
+ const conditions_1 = require("./packlets/conditions");
85
+ Object.defineProperty(exports, "Condition", { enumerable: true, get: function () { return conditions_1.Condition; } });
86
+ Object.defineProperty(exports, "ConditionSet", { enumerable: true, get: function () { return conditions_1.ConditionSet; } });
87
+ const decisions_1 = require("./packlets/decisions");
88
+ Object.defineProperty(exports, "Decision", { enumerable: true, get: function () { return decisions_1.Decision; } });
89
+ const qualifier_types_1 = require("./packlets/qualifier-types");
90
+ Object.defineProperty(exports, "QualifierType", { enumerable: true, get: function () { return qualifier_types_1.QualifierType; } });
91
+ const qualifiers_1 = require("./packlets/qualifiers");
92
+ Object.defineProperty(exports, "Qualifier", { enumerable: true, get: function () { return qualifiers_1.Qualifier; } });
93
+ const resource_types_1 = require("./packlets/resource-types");
94
+ Object.defineProperty(exports, "ResourceType", { enumerable: true, get: function () { return resource_types_1.ResourceType; } });
95
+ const resources_1 = require("./packlets/resources");
96
+ Object.defineProperty(exports, "Resource", { enumerable: true, get: function () { return resources_1.Resource; } });
97
+ Object.defineProperty(exports, "ResourceCandidate", { enumerable: true, get: function () { return resources_1.ResourceCandidate; } });
98
+ Object.defineProperty(exports, "ResourceManagerBuilder", { enumerable: true, get: function () { return resources_1.ResourceManagerBuilder; } });
99
+ const runtime_1 = require("./packlets/runtime");
100
+ Object.defineProperty(exports, "ResourceResolver", { enumerable: true, get: function () { return runtime_1.ResourceResolver; } });
85
101
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2EAA6D;AAqB3D,wCAAc;AApBhB,kEAAoD;AAqBlD,gCAAU;AApBZ,kEAAoD;AAclD,gCAAU;AAbZ,0DAA4C;AAc1C,wBAAM;AAbR,4DAA8C;AAc5C,0BAAO;AAbT,gEAAkD;AAchD,8BAAS;AAbX,uEAAyD;AAiBvD,oCAAY;AAhBd,gEAAkD;AAiBhD,8BAAS;AAhBX,yEAA2D;AAiBzD,sCAAa;AAhBf,0DAA4C;AAW1C,wBAAM;AAVR,4DAA8C;AAgB5C,0BAAO;AAdT,oDAAkC;AAClC,oDAAkC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as QualifierTypes from './packlets/qualifier-types';\nimport * as Qualifiers from './packlets/qualifiers';\nimport * as Conditions from './packlets/conditions';\nimport * as Config from './packlets/config';\nimport * as Context from './packlets/context';\nimport * as Decisions from './packlets/decisions';\nimport * as ResourceJson from './packlets/resource-json';\nimport * as Resources from './packlets/resources';\nimport * as ResourceTypes from './packlets/resource-types';\nimport * as Import from './packlets/import';\nimport * as Runtime from './packlets/runtime';\n\nexport * from './packlets/common';\nexport * from './packlets/common';\n\nexport {\n Conditions,\n Config,\n Context,\n Decisions,\n Import,\n QualifierTypes,\n Qualifiers,\n ResourceJson,\n Resources,\n ResourceTypes,\n Runtime\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2EAA6D;AAkC3D,wCAAc;AAjChB,kEAAoD;AAkClD,gCAAU;AAjCZ,kEAAoD;AAsBlD,gCAAU;AArBZ,0DAA4C;AAuB1C,wBAAM;AAtBR,4DAA8C;AAuB5C,0BAAO;AAtBT,gEAAkD;AAwBhD,8BAAS;AAvBX,uEAAyD;AAgCvD,oCAAY;AA/Bd,gEAAkD;AAoChD,8BAAS;AAnCX,yEAA2D;AAkCzD,sCAAa;AAjCf,0DAA4C;AAqB1C,wBAAM;AApBR,4DAA8C;AAkC5C,0BAAO;AAhCT,oDAAkC;AAElC,sDAAgE;AAS9D,0FATO,sBAAS,OASP;AAET,6FAXkB,yBAAY,OAWlB;AAVd,oDAAgD;AAa9C,yFAbO,oBAAQ,OAaP;AAZV,gEAA2D;AAiBzD,8FAjBO,+BAAa,OAiBP;AAhBf,sDAAkD;AAehD,0FAfO,sBAAS,OAeP;AAdX,8DAAyD;AAuBvD,6FAvBO,6BAAY,OAuBP;AAtBd,oDAA2F;AAiBzF,yFAjBO,oBAAQ,OAiBP;AACR,kGAlBiB,6BAAiB,OAkBjB;AAGjB,uGArBoC,kCAAsB,OAqBpC;AApBxB,gDAAwE;AAmBtE,iGAnByB,0BAAgB,OAmBzB","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as QualifierTypes from './packlets/qualifier-types';\nimport * as Qualifiers from './packlets/qualifiers';\nimport * as Conditions from './packlets/conditions';\nimport * as Config from './packlets/config';\nimport * as Context from './packlets/context';\nimport * as Decisions from './packlets/decisions';\nimport * as ResourceJson from './packlets/resource-json';\nimport * as Resources from './packlets/resources';\nimport * as ResourceTypes from './packlets/resource-types';\nimport * as Import from './packlets/import';\nimport * as Runtime from './packlets/runtime';\n\nexport * from './packlets/common';\n\nimport { Condition, ConditionSet } from './packlets/conditions';\nimport { Decision } from './packlets/decisions';\nimport { QualifierType } from './packlets/qualifier-types';\nimport { Qualifier } from './packlets/qualifiers';\nimport { ResourceType } from './packlets/resource-types';\nimport { Resource, ResourceCandidate, ResourceManagerBuilder } from './packlets/resources';\nimport { IResourceManager, ResourceResolver } from './packlets/runtime';\n\nexport {\n Condition,\n Conditions,\n ConditionSet,\n Config,\n Context,\n Decision,\n Decisions,\n Import,\n IResourceManager,\n Qualifier,\n QualifierType,\n QualifierTypes,\n Qualifiers,\n Resource,\n ResourceCandidate,\n ResourceJson,\n ResourceResolver,\n ResourceManagerBuilder,\n ResourceType,\n ResourceTypes,\n Resources,\n Runtime\n};\n"]}
@@ -38,4 +38,12 @@ export type ResourceValueMergeMethod = 'augment' | 'delete' | 'replace';
38
38
  * @public
39
39
  */
40
40
  export declare const allResourceValueMergeMethods: ResourceValueMergeMethod[];
41
+ /**
42
+ * The completeness of a resource candidate value. A full value is one that
43
+ * contains all of the required properties for the resource type. A partial
44
+ * value is one that contains some of the required properties for the resource
45
+ * type.
46
+ * @public
47
+ */
48
+ export type CandidateCompleteness = 'full' | 'partial';
41
49
  //# sourceMappingURL=resources.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/packlets/common/resources.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAErD;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAEzD;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAE3D;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AAEjE;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;AAEnE;;;;;;GAMG;AACH,MAAM,MAAM,wBAAwB,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,4BAA4B,EAAE,wBAAwB,EAAqC,CAAC"}
1
+ {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/packlets/common/resources.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAErD;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAEzD;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAE3D;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AAEjE;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;AAEnE;;;;;;GAMG;AACH,MAAM,MAAM,wBAAwB,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,4BAA4B,EAAE,wBAAwB,EAAqC,CAAC;AAEzG;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,SAAS,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"resources.js","sourceRoot":"","sources":["../../../src/packlets/common/resources.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AA4CH;;;GAGG;AACU,QAAA,4BAA4B,GAA+B,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Brand } from '@fgv/ts-utils';\n\n/**\n * Branded string representing a validated resource id. A resource ID\n * is a dot-separated sequence of resource names.\n * @public\n */\nexport type ResourceId = Brand<string, 'ResourceId'>;\n\n/**\n * Branded string representing a validated resource name.\n * @public\n */\nexport type ResourceName = Brand<string, 'ResourceName'>;\n\n/**\n * Branded number representing a validated resource index.\n * @public\n */\nexport type ResourceIndex = Brand<number, 'ResourceIndex'>;\n\n/**\n * Branded string representing a validated resource type name.\n * @public\n */\nexport type ResourceTypeName = Brand<string, 'ResourceTypeName'>;\n\n/**\n * Branded number representing a validated resource type index.\n * @public\n */\nexport type ResourceTypeIndex = Brand<number, 'ResourceTypeIndex'>;\n\n/**\n * Type representing the possible ways that a resource value can be merged into an existing resource.\n * - 'augment' means that the new value should be merged into the existing value, with new properties added and existing properties updated.\n * - 'delete' means that the existing values should be deleted.\n * - 'replace' means that the new value should replace the existing value.\n * @public\n */\nexport type ResourceValueMergeMethod = 'augment' | 'delete' | 'replace';\n\n/**\n * Array of all possible {@link ResourceValueMergeMethod | resource merge type} values.\n * @public\n */\nexport const allResourceValueMergeMethods: ResourceValueMergeMethod[] = ['augment', 'delete', 'replace'];\n"]}
1
+ {"version":3,"file":"resources.js","sourceRoot":"","sources":["../../../src/packlets/common/resources.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AA4CH;;;GAGG;AACU,QAAA,4BAA4B,GAA+B,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Brand } from '@fgv/ts-utils';\n\n/**\n * Branded string representing a validated resource id. A resource ID\n * is a dot-separated sequence of resource names.\n * @public\n */\nexport type ResourceId = Brand<string, 'ResourceId'>;\n\n/**\n * Branded string representing a validated resource name.\n * @public\n */\nexport type ResourceName = Brand<string, 'ResourceName'>;\n\n/**\n * Branded number representing a validated resource index.\n * @public\n */\nexport type ResourceIndex = Brand<number, 'ResourceIndex'>;\n\n/**\n * Branded string representing a validated resource type name.\n * @public\n */\nexport type ResourceTypeName = Brand<string, 'ResourceTypeName'>;\n\n/**\n * Branded number representing a validated resource type index.\n * @public\n */\nexport type ResourceTypeIndex = Brand<number, 'ResourceTypeIndex'>;\n\n/**\n * Type representing the possible ways that a resource value can be merged into an existing resource.\n * - 'augment' means that the new value should be merged into the existing value, with new properties added and existing properties updated.\n * - 'delete' means that the existing values should be deleted.\n * - 'replace' means that the new value should replace the existing value.\n * @public\n */\nexport type ResourceValueMergeMethod = 'augment' | 'delete' | 'replace';\n\n/**\n * Array of all possible {@link ResourceValueMergeMethod | resource merge type} values.\n * @public\n */\nexport const allResourceValueMergeMethods: ResourceValueMergeMethod[] = ['augment', 'delete', 'replace'];\n\n/**\n * The completeness of a resource candidate value. A full value is one that\n * contains all of the required properties for the resource type. A partial\n * value is one that contains some of the required properties for the resource\n * type.\n * @public\n */\nexport type CandidateCompleteness = 'full' | 'partial';\n"]}
@@ -1,6 +1,6 @@
1
1
  import { JsonObject } from '@fgv/ts-json-base';
2
2
  import { IResourceCandidateValidationProperties, ResourceType } from './resourceType';
3
- import { ResourceTypeName } from '../common';
3
+ import { CandidateCompleteness, ResourceTypeName } from '../common';
4
4
  import { Result } from '@fgv/ts-utils';
5
5
  /**
6
6
  * Parameters to create a {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.
@@ -44,14 +44,14 @@ export declare class JsonResourceType extends ResourceType<JsonObject> {
44
44
  /**
45
45
  * {@inheritdoc ResourceTypes.ResourceType.(validate:1)}
46
46
  */
47
- validate(json: JsonObject, isPartial: true): Result<JsonObject>;
47
+ validate(json: JsonObject, completeness: CandidateCompleteness): Result<JsonObject>;
48
48
  /**
49
49
  * {@inheritdoc ResourceTypes.ResourceType.(validate:2)}
50
50
  */
51
- validate(json: JsonObject, isPartial: false): Result<JsonObject>;
51
+ validate(json: JsonObject, completeness: 'full'): Result<JsonObject>;
52
52
  /**
53
53
  * {@inheritdoc ResourceTypes.ResourceType.(validate:3)}
54
54
  */
55
- validate(json: JsonObject, isPartial: boolean): Result<JsonObject>;
55
+ validate(json: JsonObject, completeness: 'partial'): Result<JsonObject>;
56
56
  }
57
57
  //# sourceMappingURL=jsonResourceType.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsonResourceType.d.ts","sourceRoot":"","sources":["../../../src/packlets/resource-types/jsonResourceType.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAgC,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,sCAAsC,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAW,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAiB,MAAM,EAAE,MAAM,eAAe,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,6BAA6B;IAC5C;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,YAAY,CAAC,UAAU,CAAC;IAC5D;;;;;OAKG;IACH,SAAS,aAAa,GAAG,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,MAAM;IAI3D;;;;;OAKG;WACW,MAAM,CAAC,MAAM,CAAC,EAAE,6BAA6B,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAMtF;;OAEG;IAEI,mBAAmB,CAAC,KAAK,EAAE,sCAAsC,GAAG,MAAM,CAAC,UAAU,CAAC;IAI7F;;OAEG;IACI,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC;IACtE;;OAEG;IACI,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC;IACvE;;OAEG;IACI,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC;CAI1E"}
1
+ {"version":3,"file":"jsonResourceType.d.ts","sourceRoot":"","sources":["../../../src/packlets/resource-types/jsonResourceType.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAgC,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,sCAAsC,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAW,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7E,OAAO,EAAiB,MAAM,EAAE,MAAM,eAAe,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,6BAA6B;IAC5C;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,YAAY,CAAC,UAAU,CAAC;IAC5D;;;;;OAKG;IACH,SAAS,aAAa,GAAG,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,MAAM;IAI3D;;;;;OAKG;WACW,MAAM,CAAC,MAAM,CAAC,EAAE,6BAA6B,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAMtF;;OAEG;IAEI,mBAAmB,CAAC,KAAK,EAAE,sCAAsC,GAAG,MAAM,CAAC,UAAU,CAAC;IAI7F;;OAEG;IACI,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,qBAAqB,GAAG,MAAM,CAAC,UAAU,CAAC;IAC1F;;OAEG;IACI,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC;IAC3E;;OAEG;IACI,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC;CAI/E"}
@@ -58,7 +58,7 @@ class JsonResourceType extends resourceType_1.ResourceType {
58
58
  validateDeclaration(props) {
59
59
  return ts_json_base_1.Converters.jsonObject.convert(props.json);
60
60
  }
61
- validate(json, __isPartial) {
61
+ validate(json, __completeness) {
62
62
  return ts_json_base_1.Converters.jsonObject.convert(json);
63
63
  }
64
64
  }
@@ -1 +1 @@
1
- {"version":3,"file":"jsonResourceType.js","sourceRoot":"","sources":["../../../src/packlets/resource-types/jsonResourceType.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,oDAA6E;AAC7E,iDAAsF;AACtF,sCAAsD;AACtD,4CAAsD;AAoBtD;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,2BAAwB;IAC5D;;;;;OAKG;IACH,YAAsB,GAAqB,EAAE,KAAc;QACzD,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACpB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,MAAsC;;QACzD,OAAO,gBAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,mCAAI,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/E,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,gBAAgB,CAAC,GAAG,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IAEI,mBAAmB,CAAC,KAA6C;QACtE,OAAO,yBAAc,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IAcM,QAAQ,CAAC,IAAgB,EAAE,WAAqB;QACrD,OAAO,yBAAc,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;CACF;AA9CD,4CA8CC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Converters as JsonConverters, JsonObject } from '@fgv/ts-json-base';\nimport { IResourceCandidateValidationProperties, ResourceType } from './resourceType';\nimport { Convert, ResourceTypeName } from '../common';\nimport { captureResult, Result } from '@fgv/ts-utils';\n\n/**\n * Parameters to create a {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n * @public\n */\nexport interface IJsonResourceTypeCreateParams {\n /**\n * Optional key for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n * Defaults to 'json'.\n */\n key?: string;\n\n /**\n * Optional index for the new {@link ResourceTypes.JsonResourceType | JsonResourceType}\n * instance.\n */\n index?: number;\n}\n\n/**\n * Implementation of a {@link ResourceTypes.ResourceType | ResourceType} for JSON values.\n * @public\n */\nexport class JsonResourceType extends ResourceType<JsonObject> {\n /**\n * Protected {@link ResourceTypes.JsonResourceType | JsonResourceType} constructor for use by subclasses.\n * Use {@link ResourceTypes.JsonResourceType.create | JsonResourceType.create} to create a new instance.\n * @param key - The key for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n * @param index - Optional index for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n */\n protected constructor(key: ResourceTypeName, index?: number) {\n super(key, index);\n }\n\n /**\n * Factory method to create a new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n * @param params - {@link ResourceTypes.IJsonResourceTypeCreateParams | Parameters} to create the new instance.\n * @returns `Success` with the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance if successful\n * or `Failure` with an error message if not.\n */\n public static create(params?: IJsonResourceTypeCreateParams): Result<JsonResourceType> {\n return Convert.resourceTypeName.convert(params?.key ?? 'json').onSuccess((key) => {\n return captureResult(() => new JsonResourceType(key, params?.index));\n });\n }\n\n /**\n * {@inheritdoc ResourceTypes.ResourceType.validateDeclaration}\n */\n\n public validateDeclaration(props: IResourceCandidateValidationProperties): Result<JsonObject> {\n return JsonConverters.jsonObject.convert(props.json);\n }\n\n /**\n * {@inheritdoc ResourceTypes.ResourceType.(validate:1)}\n */\n public validate(json: JsonObject, isPartial: true): Result<JsonObject>;\n /**\n * {@inheritdoc ResourceTypes.ResourceType.(validate:2)}\n */\n public validate(json: JsonObject, isPartial: false): Result<JsonObject>;\n /**\n * {@inheritdoc ResourceTypes.ResourceType.(validate:3)}\n */\n public validate(json: JsonObject, isPartial: boolean): Result<JsonObject>;\n public validate(json: JsonObject, __isPartial?: boolean): Result<JsonObject> {\n return JsonConverters.jsonObject.convert(json);\n }\n}\n"]}
1
+ {"version":3,"file":"jsonResourceType.js","sourceRoot":"","sources":["../../../src/packlets/resource-types/jsonResourceType.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,oDAA6E;AAC7E,iDAAsF;AACtF,sCAA6E;AAC7E,4CAAsD;AAoBtD;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,2BAAwB;IAC5D;;;;;OAKG;IACH,YAAsB,GAAqB,EAAE,KAAc;QACzD,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACpB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,MAAsC;;QACzD,OAAO,gBAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,mCAAI,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/E,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,gBAAgB,CAAC,GAAG,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IAEI,mBAAmB,CAAC,KAA6C;QACtE,OAAO,yBAAc,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IAcM,QAAQ,CAAC,IAAgB,EAAE,cAAsC;QACtE,OAAO,yBAAc,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;CACF;AA9CD,4CA8CC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Converters as JsonConverters, JsonObject } from '@fgv/ts-json-base';\nimport { IResourceCandidateValidationProperties, ResourceType } from './resourceType';\nimport { CandidateCompleteness, Convert, ResourceTypeName } from '../common';\nimport { captureResult, Result } from '@fgv/ts-utils';\n\n/**\n * Parameters to create a {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n * @public\n */\nexport interface IJsonResourceTypeCreateParams {\n /**\n * Optional key for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n * Defaults to 'json'.\n */\n key?: string;\n\n /**\n * Optional index for the new {@link ResourceTypes.JsonResourceType | JsonResourceType}\n * instance.\n */\n index?: number;\n}\n\n/**\n * Implementation of a {@link ResourceTypes.ResourceType | ResourceType} for JSON values.\n * @public\n */\nexport class JsonResourceType extends ResourceType<JsonObject> {\n /**\n * Protected {@link ResourceTypes.JsonResourceType | JsonResourceType} constructor for use by subclasses.\n * Use {@link ResourceTypes.JsonResourceType.create | JsonResourceType.create} to create a new instance.\n * @param key - The key for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n * @param index - Optional index for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n */\n protected constructor(key: ResourceTypeName, index?: number) {\n super(key, index);\n }\n\n /**\n * Factory method to create a new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n * @param params - {@link ResourceTypes.IJsonResourceTypeCreateParams | Parameters} to create the new instance.\n * @returns `Success` with the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance if successful\n * or `Failure` with an error message if not.\n */\n public static create(params?: IJsonResourceTypeCreateParams): Result<JsonResourceType> {\n return Convert.resourceTypeName.convert(params?.key ?? 'json').onSuccess((key) => {\n return captureResult(() => new JsonResourceType(key, params?.index));\n });\n }\n\n /**\n * {@inheritdoc ResourceTypes.ResourceType.validateDeclaration}\n */\n\n public validateDeclaration(props: IResourceCandidateValidationProperties): Result<JsonObject> {\n return JsonConverters.jsonObject.convert(props.json);\n }\n\n /**\n * {@inheritdoc ResourceTypes.ResourceType.(validate:1)}\n */\n public validate(json: JsonObject, completeness: CandidateCompleteness): Result<JsonObject>;\n /**\n * {@inheritdoc ResourceTypes.ResourceType.(validate:2)}\n */\n public validate(json: JsonObject, completeness: 'full'): Result<JsonObject>;\n /**\n * {@inheritdoc ResourceTypes.ResourceType.(validate:3)}\n */\n public validate(json: JsonObject, completeness: 'partial'): Result<JsonObject>;\n public validate(json: JsonObject, __completeness?: CandidateCompleteness): Result<JsonObject> {\n return JsonConverters.jsonObject.convert(json);\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { JsonValue } from '@fgv/ts-json-base';
2
2
  import { ICollectible, Result } from '@fgv/ts-utils';
3
- import { ResourceTypeIndex, ResourceTypeName, ResourceValueMergeMethod, ResourceId } from '../common';
3
+ import { CandidateCompleteness, ResourceTypeIndex, ResourceTypeName, ResourceValueMergeMethod, ResourceId } from '../common';
4
4
  /**
5
5
  * Parameters used to validate a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}.
6
6
  * @public
@@ -56,30 +56,39 @@ export declare abstract class ResourceType<T = unknown> implements ICollectible<
56
56
  /**
57
57
  * Validates a JSON value for use as a partial resource instance value.
58
58
  * @param json - The JSON value to validate.
59
- * @param isPartial - `true` indicates that the value is expected to be partial.
59
+ * @param completeness - Describes {@link CandidateCompleteness | how complete} the candidate value is.
60
60
  * @returns `Success` with the strongly-typed partial resource value if the JSON is valid,
61
61
  * `Failure` with an error message otherwise.
62
62
  * @public
63
63
  */
64
- abstract validate(json: JsonValue, isPartial: true): Result<Partial<T>>;
64
+ abstract validate(json: JsonValue, completeness: CandidateCompleteness): Result<Partial<T>>;
65
65
  /**
66
66
  * Validates a JSON value for use as a complete resource instance value.
67
67
  * @param json - The JSON value to validate.
68
- * @param isPartial - `false` indicates that the value is expected to be complete.
68
+ * @param completeness - Describes {@link CandidateCompleteness | how complete} the candidate value is.
69
69
  * @returns `Success` with the strongly-typed resource value if the JSON is valid,
70
70
  * `Failure` with an error message otherwise.
71
71
  * @public
72
72
  */
73
- abstract validate(json: JsonValue, isPartial: false): Result<T>;
73
+ abstract validate(json: JsonValue, completeness: 'full'): Result<T>;
74
+ /**
75
+ * Validates a JSON value for use as a partial resource instance value.
76
+ * @param json - The JSON value to validate.
77
+ * @param completeness - Describes {@link CandidateCompleteness | how complete} the candidate value is.
78
+ * @returns `Success` with the strongly-typed partial resource value if the JSON is valid,
79
+ * `Failure` with an error message otherwise.
80
+ * @public
81
+ */
82
+ abstract validate(json: JsonValue, completeness: 'partial'): Result<Partial<T>>;
74
83
  /**
75
84
  * Validates a JSON value for use as a full or partial resource instance value.
76
85
  * @param json - The JSON value to validate.
77
- * @param isPartial - Indicates whether the value is expected to be partial.
86
+ * @param completeness - Describes {@link CandidateCompleteness | how complete} the candidate value is.
78
87
  * @returns `Success` with the strongly-typed full or partial resource value if
79
88
  * the JSON is valid, `Failure` with an error message otherwise.
80
89
  * @public
81
90
  */
82
- abstract validate(json: JsonValue, isPartial?: boolean): Result<T | Partial<T>>;
91
+ abstract validate(json: JsonValue, completeness?: CandidateCompleteness): Result<T | Partial<T>>;
83
92
  /**
84
93
  * Sets the index for this resource type. Once set, the index cannot be changed.
85
94
  */
@@ -1 +1 @@
1
- {"version":3,"file":"resourceType.d.ts","sourceRoot":"","sources":["../../../src/packlets/resource-types/resourceType.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAe,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAGL,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACxB,UAAU,EACX,MAAM,WAAW,CAAC;AAEnB;;;GAGG;AACH,MAAM,WAAW,sCAAsC;IACrD;;;OAGG;IACH,EAAE,EAAE,UAAU,CAAC;IAEf;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,IAAI,EAAE,SAAS,CAAC;IAEhB;;;OAGG;IACH,WAAW,EAAE,wBAAwB,CAAC;CACvC;AAED;;;;;GAKG;AACH,8BAAsB,YAAY,CAAC,CAAC,GAAG,OAAO,CAAE,YAAW,YAAY,CAAC,gBAAgB,EAAE,iBAAiB,CAAC;IAC1G,OAAO,CAAC,YAAY,CAA+D;IACnF;;OAEG;IACH,IAAW,GAAG,IAAI,gBAAgB,CAEjC;IAED;;OAEG;IACH,IAAW,KAAK,IAAI,iBAAiB,GAAG,SAAS,CAEhD;IAED,SAAS,aAAa,GAAG,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,MAAM;IAS3D;;;;;;;OAOG;aACa,mBAAmB,CAAC,KAAK,EAAE,sCAAsC,GAAG,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAE1G;;;;;;;OAOG;aACa,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAE9E;;;;;;;OAOG;aACa,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC;IAEtE;;;;;;;OAOG;aACa,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAEtF;;OAEG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC;CAG1D"}
1
+ {"version":3,"file":"resourceType.d.ts","sourceRoot":"","sources":["../../../src/packlets/resource-types/resourceType.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAe,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EACL,qBAAqB,EAGrB,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACxB,UAAU,EACX,MAAM,WAAW,CAAC;AAEnB;;;GAGG;AACH,MAAM,WAAW,sCAAsC;IACrD;;;OAGG;IACH,EAAE,EAAE,UAAU,CAAC;IAEf;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,IAAI,EAAE,SAAS,CAAC;IAEhB;;;OAGG;IACH,WAAW,EAAE,wBAAwB,CAAC;CACvC;AAED;;;;;GAKG;AACH,8BAAsB,YAAY,CAAC,CAAC,GAAG,OAAO,CAAE,YAAW,YAAY,CAAC,gBAAgB,EAAE,iBAAiB,CAAC;IAC1G,OAAO,CAAC,YAAY,CAA+D;IACnF;;OAEG;IACH,IAAW,GAAG,IAAI,gBAAgB,CAEjC;IAED;;OAEG;IACH,IAAW,KAAK,IAAI,iBAAiB,GAAG,SAAS,CAEhD;IAED,SAAS,aAAa,GAAG,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,MAAM;IAS3D;;;;;;;OAOG;aACa,mBAAmB,CAAC,KAAK,EAAE,sCAAsC,GAAG,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAE1G;;;;;;;OAOG;aACa,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,qBAAqB,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAElG;;;;;;;OAOG;aACa,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;IAE1E;;;;;;;OAOG;aACa,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAEtF;;;;;;;OAOG;aACa,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,YAAY,CAAC,EAAE,qBAAqB,GAAG,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAEvG;;OAEG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC;CAG1D"}
@@ -1 +1 @@
1
- {"version":3,"file":"resourceType.js","sourceRoot":"","sources":["../../../src/packlets/resource-types/resourceType.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAGH,4CAAkE;AAClE,sCAOmB;AAgCnB;;;;;GAKG;AACH,MAAsB,YAAY;IAEhC;;OAEG;IACH,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;IACjC,CAAC;IAED,YAAsB,GAAqB,EAAE,KAAc;QACzD,IAAI,CAAC,YAAY,GAAG,IAAI,sBAAW,CAAC,WAAW,CAAsC;YACnF,GAAG;YACH,qDAAqD;YACrD,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,iBAAQ,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS;YACtF,cAAc,EAAE,gBAAa,CAAC,iBAAiB;SAChD,CAAC,CAAC;IACL,CAAC;IA0CD;;OAEG;IACI,QAAQ,CAAC,KAAa;QAC3B,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF;AAvED,oCAuEC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { JsonValue } from '@fgv/ts-json-base';\nimport { Collections, ICollectible, Result } from '@fgv/ts-utils';\nimport {\n Convert as CommonConvert,\n Validate,\n ResourceTypeIndex,\n ResourceTypeName,\n ResourceValueMergeMethod,\n ResourceId\n} from '../common';\n\n/**\n * Parameters used to validate a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}.\n * @public\n */\nexport interface IResourceCandidateValidationProperties {\n /**\n * {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.id}\n * @public\n */\n id: ResourceId;\n\n /**\n * {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.isPartial}\n * @public\n */\n isPartial: boolean;\n\n /**\n * {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.json}\n * @public\n */\n json: JsonValue;\n\n /**\n * {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.mergeMethod}\n * @public\n */\n mergeMethod: ResourceValueMergeMethod;\n}\n\n/**\n * Abstract base class for resource types which are responsible for\n * validating and converting JSON values into the appropriate strongly-typed\n * resource value.\n * @public\n */\nexport abstract class ResourceType<T = unknown> implements ICollectible<ResourceTypeName, ResourceTypeIndex> {\n private _collectible: Collections.Collectible<ResourceTypeName, ResourceTypeIndex>;\n /**\n * The key for this resource type.\n */\n public get key(): ResourceTypeName {\n return this._collectible.key;\n }\n\n /**\n * The index for this resource type.\n */\n public get index(): ResourceTypeIndex | undefined {\n return this._collectible.index;\n }\n\n protected constructor(key: ResourceTypeName, index?: number) {\n this._collectible = new Collections.Collectible<ResourceTypeName, ResourceTypeIndex>({\n key,\n /* c8 ignore next 1 - coverage having a rough time */\n index: index !== undefined ? Validate.toResourceTypeIndex(index).orThrow() : undefined,\n indexConverter: CommonConvert.resourceTypeIndex\n });\n }\n\n /**\n * Validates properties of a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration} for\n * a resource instance value.\n * @param props - The {@link ResourceTypes.IResourceCandidateValidationProperties | properties } to validate.\n * @returns `Success` with the strongly-typed resource value if the JSON and merge method\n * are valid, `Failure` with an error message otherwise.\n * @public\n */\n public abstract validateDeclaration(props: IResourceCandidateValidationProperties): Result<T | Partial<T>>;\n\n /**\n * Validates a JSON value for use as a partial resource instance value.\n * @param json - The JSON value to validate.\n * @param isPartial - `true` indicates that the value is expected to be partial.\n * @returns `Success` with the strongly-typed partial resource value if the JSON is valid,\n * `Failure` with an error message otherwise.\n * @public\n */\n public abstract validate(json: JsonValue, isPartial: true): Result<Partial<T>>;\n\n /**\n * Validates a JSON value for use as a complete resource instance value.\n * @param json - The JSON value to validate.\n * @param isPartial - `false` indicates that the value is expected to be complete.\n * @returns `Success` with the strongly-typed resource value if the JSON is valid,\n * `Failure` with an error message otherwise.\n * @public\n */\n public abstract validate(json: JsonValue, isPartial: false): Result<T>;\n\n /**\n * Validates a JSON value for use as a full or partial resource instance value.\n * @param json - The JSON value to validate.\n * @param isPartial - Indicates whether the value is expected to be partial.\n * @returns `Success` with the strongly-typed full or partial resource value if\n * the JSON is valid, `Failure` with an error message otherwise.\n * @public\n */\n public abstract validate(json: JsonValue, isPartial?: boolean): Result<T | Partial<T>>;\n\n /**\n * Sets the index for this resource type. Once set, the index cannot be changed.\n */\n public setIndex(index: number): Result<ResourceTypeIndex> {\n return this._collectible.setIndex(index);\n }\n}\n"]}
1
+ {"version":3,"file":"resourceType.js","sourceRoot":"","sources":["../../../src/packlets/resource-types/resourceType.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAGH,4CAAkE;AAClE,sCAQmB;AAgCnB;;;;;GAKG;AACH,MAAsB,YAAY;IAEhC;;OAEG;IACH,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;IACjC,CAAC;IAED,YAAsB,GAAqB,EAAE,KAAc;QACzD,IAAI,CAAC,YAAY,GAAG,IAAI,sBAAW,CAAC,WAAW,CAAsC;YACnF,GAAG;YACH,qDAAqD;YACrD,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,iBAAQ,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS;YACtF,cAAc,EAAE,gBAAa,CAAC,iBAAiB;SAChD,CAAC,CAAC;IACL,CAAC;IAoDD;;OAEG;IACI,QAAQ,CAAC,KAAa;QAC3B,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF;AAjFD,oCAiFC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { JsonValue } from '@fgv/ts-json-base';\nimport { Collections, ICollectible, Result } from '@fgv/ts-utils';\nimport {\n CandidateCompleteness,\n Convert as CommonConvert,\n Validate,\n ResourceTypeIndex,\n ResourceTypeName,\n ResourceValueMergeMethod,\n ResourceId\n} from '../common';\n\n/**\n * Parameters used to validate a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}.\n * @public\n */\nexport interface IResourceCandidateValidationProperties {\n /**\n * {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.id}\n * @public\n */\n id: ResourceId;\n\n /**\n * {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.isPartial}\n * @public\n */\n isPartial: boolean;\n\n /**\n * {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.json}\n * @public\n */\n json: JsonValue;\n\n /**\n * {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.mergeMethod}\n * @public\n */\n mergeMethod: ResourceValueMergeMethod;\n}\n\n/**\n * Abstract base class for resource types which are responsible for\n * validating and converting JSON values into the appropriate strongly-typed\n * resource value.\n * @public\n */\nexport abstract class ResourceType<T = unknown> implements ICollectible<ResourceTypeName, ResourceTypeIndex> {\n private _collectible: Collections.Collectible<ResourceTypeName, ResourceTypeIndex>;\n /**\n * The key for this resource type.\n */\n public get key(): ResourceTypeName {\n return this._collectible.key;\n }\n\n /**\n * The index for this resource type.\n */\n public get index(): ResourceTypeIndex | undefined {\n return this._collectible.index;\n }\n\n protected constructor(key: ResourceTypeName, index?: number) {\n this._collectible = new Collections.Collectible<ResourceTypeName, ResourceTypeIndex>({\n key,\n /* c8 ignore next 1 - coverage having a rough time */\n index: index !== undefined ? Validate.toResourceTypeIndex(index).orThrow() : undefined,\n indexConverter: CommonConvert.resourceTypeIndex\n });\n }\n\n /**\n * Validates properties of a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration} for\n * a resource instance value.\n * @param props - The {@link ResourceTypes.IResourceCandidateValidationProperties | properties } to validate.\n * @returns `Success` with the strongly-typed resource value if the JSON and merge method\n * are valid, `Failure` with an error message otherwise.\n * @public\n */\n public abstract validateDeclaration(props: IResourceCandidateValidationProperties): Result<T | Partial<T>>;\n\n /**\n * Validates a JSON value for use as a partial resource instance value.\n * @param json - The JSON value to validate.\n * @param completeness - Describes {@link CandidateCompleteness | how complete} the candidate value is.\n * @returns `Success` with the strongly-typed partial resource value if the JSON is valid,\n * `Failure` with an error message otherwise.\n * @public\n */\n public abstract validate(json: JsonValue, completeness: CandidateCompleteness): Result<Partial<T>>;\n\n /**\n * Validates a JSON value for use as a complete resource instance value.\n * @param json - The JSON value to validate.\n * @param completeness - Describes {@link CandidateCompleteness | how complete} the candidate value is.\n * @returns `Success` with the strongly-typed resource value if the JSON is valid,\n * `Failure` with an error message otherwise.\n * @public\n */\n public abstract validate(json: JsonValue, completeness: 'full'): Result<T>;\n\n /**\n * Validates a JSON value for use as a partial resource instance value.\n * @param json - The JSON value to validate.\n * @param completeness - Describes {@link CandidateCompleteness | how complete} the candidate value is.\n * @returns `Success` with the strongly-typed partial resource value if the JSON is valid,\n * `Failure` with an error message otherwise.\n * @public\n */\n public abstract validate(json: JsonValue, completeness: 'partial'): Result<Partial<T>>;\n\n /**\n * Validates a JSON value for use as a full or partial resource instance value.\n * @param json - The JSON value to validate.\n * @param completeness - Describes {@link CandidateCompleteness | how complete} the candidate value is.\n * @returns `Success` with the strongly-typed full or partial resource value if\n * the JSON is valid, `Failure` with an error message otherwise.\n * @public\n */\n public abstract validate(json: JsonValue, completeness?: CandidateCompleteness): Result<T | Partial<T>>;\n\n /**\n * Sets the index for this resource type. Once set, the index cannot be changed.\n */\n public setIndex(index: number): Result<ResourceTypeIndex> {\n return this._collectible.setIndex(index);\n }\n}\n"]}