@salesforce/plugin-bre-to-cml 1.0.2
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/LICENSE.txt +206 -0
- package/README.md +158 -0
- package/lib/commands/cml/convert/prod-cfg-rules.d.ts +29 -0
- package/lib/commands/cml/convert/prod-cfg-rules.js +226 -0
- package/lib/commands/cml/convert/prod-cfg-rules.js.map +1 -0
- package/lib/commands/cml/import/as-expression-set.d.ts +18 -0
- package/lib/commands/cml/import/as-expression-set.js +184 -0
- package/lib/commands/cml/import/as-expression-set.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +17 -0
- package/lib/index.js.map +1 -0
- package/lib/shared/bre-rules-generator.d.ts +20 -0
- package/lib/shared/bre-rules-generator.js +497 -0
- package/lib/shared/bre-rules-generator.js.map +1 -0
- package/lib/shared/cml.d.ts +2 -0
- package/lib/shared/cml.js +13 -0
- package/lib/shared/cml.js.map +1 -0
- package/lib/shared/constants/constants.d.ts +94 -0
- package/lib/shared/constants/constants.js +109 -0
- package/lib/shared/constants/constants.js.map +1 -0
- package/lib/shared/grouping.d.ts +4 -0
- package/lib/shared/grouping.js +88 -0
- package/lib/shared/grouping.js.map +1 -0
- package/lib/shared/models.d.ts +65 -0
- package/lib/shared/models.js +2 -0
- package/lib/shared/models.js.map +1 -0
- package/lib/shared/pcm-generator.d.ts +57 -0
- package/lib/shared/pcm-generator.js +418 -0
- package/lib/shared/pcm-generator.js.map +1 -0
- package/lib/shared/pcm-products.d.ts +14 -0
- package/lib/shared/pcm-products.js +125 -0
- package/lib/shared/pcm-products.js.map +1 -0
- package/lib/shared/pcm-products.types.d.ts +99 -0
- package/lib/shared/pcm-products.types.js +2 -0
- package/lib/shared/pcm-products.types.js.map +1 -0
- package/lib/shared/types/association.d.ts +15 -0
- package/lib/shared/types/association.js +64 -0
- package/lib/shared/types/association.js.map +1 -0
- package/lib/shared/types/base/annotated-cml-element-w-attributes.d.ts +10 -0
- package/lib/shared/types/base/annotated-cml-element-w-attributes.js +36 -0
- package/lib/shared/types/base/annotated-cml-element-w-attributes.js.map +1 -0
- package/lib/shared/types/base/annotated-cml-element.d.ts +9 -0
- package/lib/shared/types/base/annotated-cml-element.js +39 -0
- package/lib/shared/types/base/annotated-cml-element.js.map +1 -0
- package/lib/shared/types/base/types.d.ts +2 -0
- package/lib/shared/types/base/types.js +18 -0
- package/lib/shared/types/base/types.js.map +1 -0
- package/lib/shared/types/cml-attribute.d.ts +17 -0
- package/lib/shared/types/cml-attribute.js +84 -0
- package/lib/shared/types/cml-attribute.js.map +1 -0
- package/lib/shared/types/cml-constraint.d.ts +50 -0
- package/lib/shared/types/cml-constraint.js +277 -0
- package/lib/shared/types/cml-constraint.js.map +1 -0
- package/lib/shared/types/cml-domain.d.ts +25 -0
- package/lib/shared/types/cml-domain.js +132 -0
- package/lib/shared/types/cml-domain.js.map +1 -0
- package/lib/shared/types/cml-model.d.ts +39 -0
- package/lib/shared/types/cml-model.js +153 -0
- package/lib/shared/types/cml-model.js.map +1 -0
- package/lib/shared/types/cml-relation.d.ts +31 -0
- package/lib/shared/types/cml-relation.js +118 -0
- package/lib/shared/types/cml-relation.js.map +1 -0
- package/lib/shared/types/cml-type.d.ts +22 -0
- package/lib/shared/types/cml-type.js +111 -0
- package/lib/shared/types/cml-type.js.map +1 -0
- package/lib/shared/types/sobject.d.ts +13 -0
- package/lib/shared/types/sobject.js +2 -0
- package/lib/shared/types/sobject.js.map +1 -0
- package/lib/shared/types/types.d.ts +8 -0
- package/lib/shared/types/types.js +24 -0
- package/lib/shared/types/types.js.map +1 -0
- package/lib/shared/utils/association.utils.d.ts +61 -0
- package/lib/shared/utils/association.utils.js +175 -0
- package/lib/shared/utils/association.utils.js.map +1 -0
- package/lib/shared/utils/common.utils.d.ts +191 -0
- package/lib/shared/utils/common.utils.js +338 -0
- package/lib/shared/utils/common.utils.js.map +1 -0
- package/messages/call.external.service.md +20 -0
- package/messages/cml.convert.prod-cfg-rules.md +59 -0
- package/messages/cml.import.as-expression-set.md +32 -0
- package/messages/connect.org.md +19 -0
- package/messages/hello.world.md +29 -0
- package/oclif.lock +8313 -0
- package/oclif.manifest.json +209 -0
- package/package.json +227 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export type PCMProduct = {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
productCode: string;
|
|
5
|
+
nodeType: 'simpleProduct' | 'bundleProduct' | 'productClass';
|
|
6
|
+
description: string;
|
|
7
|
+
displayUrl: string;
|
|
8
|
+
isActive: boolean;
|
|
9
|
+
isAssetizable: boolean;
|
|
10
|
+
isSoldOnlyWithOtherProds: boolean;
|
|
11
|
+
additionalFields: Record<string, unknown>;
|
|
12
|
+
attributeCategory: PCMAttributeCategory[];
|
|
13
|
+
attributes: PCMProductAttribute[];
|
|
14
|
+
catalogs: unknown[];
|
|
15
|
+
categories: unknown[];
|
|
16
|
+
childProducts: PCMProduct[];
|
|
17
|
+
configureDuringSale: 'Allowed' | 'NotAllowed';
|
|
18
|
+
productClassification: PCMProductClassification;
|
|
19
|
+
productRelatedComponent: PCMProductRelatedComponent;
|
|
20
|
+
productComponentGroups: PCMProductComponentGroup[];
|
|
21
|
+
productSellingModelOptions: PCMProductSellingModelOption[];
|
|
22
|
+
sequence: number;
|
|
23
|
+
};
|
|
24
|
+
export type PCMProductSellingModelOption = {
|
|
25
|
+
id: string;
|
|
26
|
+
isDefault: boolean;
|
|
27
|
+
productId: string;
|
|
28
|
+
productSellingModel: PCMProductSellingModel;
|
|
29
|
+
};
|
|
30
|
+
export type PCMProductSellingModel = {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
sellingModelType: string;
|
|
34
|
+
status: string;
|
|
35
|
+
};
|
|
36
|
+
export type PCMProductComponentGroup = {
|
|
37
|
+
id: string;
|
|
38
|
+
code: string;
|
|
39
|
+
name: string;
|
|
40
|
+
parentProductId: string;
|
|
41
|
+
isExcluded: boolean;
|
|
42
|
+
components: PCMProduct[];
|
|
43
|
+
childGroups: PCMProductComponentGroup[];
|
|
44
|
+
};
|
|
45
|
+
export type PCMProductClassification = {
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
};
|
|
49
|
+
export type PCMAttributeCategory = {
|
|
50
|
+
id: string;
|
|
51
|
+
name: string;
|
|
52
|
+
code: string;
|
|
53
|
+
attributes: PCMProductAttribute[];
|
|
54
|
+
};
|
|
55
|
+
export type PCMProductAttribute = {
|
|
56
|
+
id: string;
|
|
57
|
+
name: string;
|
|
58
|
+
label: string;
|
|
59
|
+
attributeNameOverride: string;
|
|
60
|
+
developerName: string;
|
|
61
|
+
dataType: string;
|
|
62
|
+
additionalFields: Record<string, unknown>;
|
|
63
|
+
defaultValue: string | number | boolean | undefined;
|
|
64
|
+
isHidden: boolean;
|
|
65
|
+
isPriceImpacting: boolean;
|
|
66
|
+
isReadOnly: boolean;
|
|
67
|
+
isRequired: boolean;
|
|
68
|
+
picklist: PCMAttributePicklist;
|
|
69
|
+
status: string;
|
|
70
|
+
};
|
|
71
|
+
export type PCMAttributePicklist = {
|
|
72
|
+
id: string;
|
|
73
|
+
name: string;
|
|
74
|
+
dataType: string;
|
|
75
|
+
values: PCMAttributePickListValue[];
|
|
76
|
+
};
|
|
77
|
+
export type PCMAttributePickListValue = {
|
|
78
|
+
id: string;
|
|
79
|
+
name: string;
|
|
80
|
+
code: string;
|
|
81
|
+
sequence: number;
|
|
82
|
+
displayValue: string;
|
|
83
|
+
value: string;
|
|
84
|
+
};
|
|
85
|
+
export type PCMProductRelatedComponent = {
|
|
86
|
+
id: string;
|
|
87
|
+
parentProductId: string;
|
|
88
|
+
childProductId: string;
|
|
89
|
+
productRelationshipTypeId: string;
|
|
90
|
+
quantity: number;
|
|
91
|
+
quantityScaleMethod?: 'Constant' | 'Proportional';
|
|
92
|
+
doesBundlePriceIncludeChild: boolean;
|
|
93
|
+
isComponentRequired: boolean;
|
|
94
|
+
isDefaultComponent: boolean;
|
|
95
|
+
isExcluded: boolean;
|
|
96
|
+
isQuantityEditable: boolean;
|
|
97
|
+
minQuantity: number | undefined;
|
|
98
|
+
maxQuantity: number | undefined;
|
|
99
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pcm-products.types.js","sourceRoot":"","sources":["../../src/shared/pcm-products.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AssociationType } from '../constants/constants.js';
|
|
2
|
+
export type ReferenceObjectType = 'Product2' | 'ProductClassification' | 'ProductRelatedComponent';
|
|
3
|
+
export declare class Association {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(id: string | null, tag: string, type: AssociationType, referenceObjectId: string, referenceObjectType: ReferenceObjectType, referenceObjectReferenceValue: string);
|
|
6
|
+
get id(): string;
|
|
7
|
+
get tag(): string;
|
|
8
|
+
get type(): AssociationType;
|
|
9
|
+
get referenceObjectId(): string;
|
|
10
|
+
get referenceObjectType(): ReferenceObjectType;
|
|
11
|
+
get referenceObjectReferenceValue(): string;
|
|
12
|
+
setReferenceObjectId(referenceObjectId: string): void;
|
|
13
|
+
setType(type: AssociationType): void;
|
|
14
|
+
setTag(tag: string): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { ASSOCIATION_TYPES } from '../constants/constants.js';
|
|
17
|
+
import { uuid } from '../utils/common.utils.js';
|
|
18
|
+
export class Association {
|
|
19
|
+
#id;
|
|
20
|
+
#tag; // ConstraintModelTag
|
|
21
|
+
#type; // ConstraintModelTagType
|
|
22
|
+
#referenceObjectId; // ReferenceObjectId
|
|
23
|
+
#referenceObjectType;
|
|
24
|
+
#referenceObjectReferenceValue;
|
|
25
|
+
constructor(id, tag, type, referenceObjectId, referenceObjectType, referenceObjectReferenceValue) {
|
|
26
|
+
this.#id = id ?? uuid();
|
|
27
|
+
this.#tag = tag;
|
|
28
|
+
this.#referenceObjectId = referenceObjectId;
|
|
29
|
+
this.#type = type;
|
|
30
|
+
this.#referenceObjectType = referenceObjectType;
|
|
31
|
+
this.#referenceObjectReferenceValue = referenceObjectReferenceValue;
|
|
32
|
+
}
|
|
33
|
+
get id() {
|
|
34
|
+
return this.#id;
|
|
35
|
+
}
|
|
36
|
+
get tag() {
|
|
37
|
+
return this.#tag;
|
|
38
|
+
}
|
|
39
|
+
get type() {
|
|
40
|
+
return this.#type;
|
|
41
|
+
}
|
|
42
|
+
get referenceObjectId() {
|
|
43
|
+
return this.#referenceObjectId;
|
|
44
|
+
}
|
|
45
|
+
get referenceObjectType() {
|
|
46
|
+
return this.#referenceObjectType;
|
|
47
|
+
}
|
|
48
|
+
get referenceObjectReferenceValue() {
|
|
49
|
+
return this.#referenceObjectReferenceValue;
|
|
50
|
+
}
|
|
51
|
+
setReferenceObjectId(referenceObjectId) {
|
|
52
|
+
this.#referenceObjectId = referenceObjectId;
|
|
53
|
+
}
|
|
54
|
+
setType(type) {
|
|
55
|
+
if (!Object.values(ASSOCIATION_TYPES).includes(type)) {
|
|
56
|
+
throw new Error('InvalidAssociationType'.replace('{0}', type));
|
|
57
|
+
}
|
|
58
|
+
this.#type = type;
|
|
59
|
+
}
|
|
60
|
+
setTag(tag) {
|
|
61
|
+
this.#tag = tag;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=association.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"association.js","sourceRoot":"","sources":["../../../src/shared/types/association.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,iBAAiB,EAAmB,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAIhD,MAAM,OAAO,WAAW;IACb,GAAG,CAAS;IACrB,IAAI,CAAS,CAAC,qBAAqB;IACnC,KAAK,CAAkB,CAAC,yBAAyB;IACjD,kBAAkB,CAAS,CAAC,oBAAoB;IAEvC,oBAAoB,CAAsB;IAC1C,8BAA8B,CAAS;IAEhD,YACE,EAAiB,EACjB,GAAW,EACX,IAAqB,EACrB,iBAAyB,EACzB,mBAAwC,EACxC,6BAAqC;QAErC,IAAI,CAAC,GAAG,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,kBAAkB,GAAG,iBAAiB,CAAC;QAC5C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,oBAAoB,GAAG,mBAAmB,CAAC;QAChD,IAAI,CAAC,8BAA8B,GAAG,6BAA6B,CAAC;IACtE,CAAC;IAED,IAAW,EAAE;QACX,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAW,iBAAiB;QAC1B,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;IAED,IAAW,mBAAmB;QAC5B,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;IAED,IAAW,6BAA6B;QACtC,OAAO,IAAI,CAAC,8BAA8B,CAAC;IAC7C,CAAC;IAEM,oBAAoB,CAAC,iBAAyB;QACnD,IAAI,CAAC,kBAAkB,GAAG,iBAAiB,CAAC;IAC9C,CAAC;IAEM,OAAO,CAAC,IAAqB;QAClC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACrD,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAEM,MAAM,CAAC,GAAW;QACvB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CmlAttribute } from '../cml-attribute.js';
|
|
2
|
+
import { AnnotatedCmlElement } from './types.js';
|
|
3
|
+
export declare class AnnotatedCmlElementWAttributes extends AnnotatedCmlElement {
|
|
4
|
+
#private;
|
|
5
|
+
get attributes(): CmlAttribute[];
|
|
6
|
+
getAttribute(name: string): CmlAttribute | undefined;
|
|
7
|
+
findAttributeById(attributeId: string): CmlAttribute | null;
|
|
8
|
+
addAttribute(a: CmlAttribute): void;
|
|
9
|
+
hasAttributes(): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { findInMap, isSameIds } from '../../utils/common.utils.js';
|
|
17
|
+
import { AnnotatedCmlElement } from './types.js';
|
|
18
|
+
export class AnnotatedCmlElementWAttributes extends AnnotatedCmlElement {
|
|
19
|
+
#attributes = new Map();
|
|
20
|
+
get attributes() {
|
|
21
|
+
return Array.from(this.#attributes.values());
|
|
22
|
+
}
|
|
23
|
+
getAttribute(name) {
|
|
24
|
+
return findInMap(this.#attributes, 'name', name);
|
|
25
|
+
}
|
|
26
|
+
findAttributeById(attributeId) {
|
|
27
|
+
return Array.from(this.#attributes.values()).find((a) => isSameIds(a.attributeId, attributeId)) ?? null;
|
|
28
|
+
}
|
|
29
|
+
addAttribute(a) {
|
|
30
|
+
this.#attributes.set(a.name, a);
|
|
31
|
+
}
|
|
32
|
+
hasAttributes() {
|
|
33
|
+
return this.attributes.length > 0;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=annotated-cml-element-w-attributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotated-cml-element-w-attributes.js","sourceRoot":"","sources":["../../../../src/shared/types/base/annotated-cml-element-w-attributes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,OAAO,8BAA+B,SAAQ,mBAAmB;IACrE,WAAW,GAA8B,IAAI,GAAG,EAAE,CAAC;IAEnD,IAAW,UAAU;QACnB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/C,CAAC;IAEM,YAAY,CAAC,IAAY;QAC9B,OAAO,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;IAEM,iBAAiB,CAAC,WAAmB;QAC1C,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,IAAI,IAAI,CAAC;IAC1G,CAAC;IAEM,YAAY,CAAC,CAAe;QACjC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAClC,CAAC;IAEM,aAAa;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;IACpC,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class AnnotatedCmlElement {
|
|
2
|
+
#private;
|
|
3
|
+
get properties(): Record<string, string | number | boolean>;
|
|
4
|
+
setProperties(properties: {
|
|
5
|
+
[k: string]: string | number | boolean;
|
|
6
|
+
}): void;
|
|
7
|
+
hasProperties(): boolean;
|
|
8
|
+
generateAnnotation(): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export class AnnotatedCmlElement {
|
|
17
|
+
#properties = {};
|
|
18
|
+
get properties() {
|
|
19
|
+
return this.#properties;
|
|
20
|
+
}
|
|
21
|
+
setProperties(properties) {
|
|
22
|
+
Object.assign(this.#properties, properties);
|
|
23
|
+
}
|
|
24
|
+
hasProperties() {
|
|
25
|
+
return Object.entries(this.properties).length > 0;
|
|
26
|
+
}
|
|
27
|
+
generateAnnotation() {
|
|
28
|
+
if (!this.hasProperties()) {
|
|
29
|
+
return ''; // Return an empty string if no properties are set
|
|
30
|
+
}
|
|
31
|
+
const entries = Object.entries(this.properties);
|
|
32
|
+
const formattedEntries = entries.map(([key, value]) => {
|
|
33
|
+
const formattedValue = typeof value === 'string' ? `"${value}"` : value;
|
|
34
|
+
return `${key} = ${formattedValue}`;
|
|
35
|
+
});
|
|
36
|
+
return `@(${formattedEntries.join(', ')})`;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=annotated-cml-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotated-cml-element.js","sourceRoot":"","sources":["../../../../src/shared/types/base/annotated-cml-element.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,mBAAmB;IAC9B,WAAW,GAA8C,EAAE,CAAC;IAE5D,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAEM,aAAa,CAAC,UAAsD;QACzE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAC9C,CAAC;IAEM,aAAa;QAClB,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IACpD,CAAC;IAEM,kBAAkB;QACvB,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC;YAC1B,OAAO,EAAE,CAAC,CAAC,kDAAkD;QAC/D,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAEhD,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YACpD,MAAM,cAAc,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;YACxE,OAAO,GAAG,GAAG,MAAM,cAAc,EAAE,CAAC;QACtC,CAAC,CAAC,CAAC;QAEH,OAAO,KAAK,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;IAC7C,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export * from './annotated-cml-element.js';
|
|
17
|
+
export * from './annotated-cml-element-w-attributes.js';
|
|
18
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/shared/types/base/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yCAAyC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AnnotatedCmlElement } from './base/types.js';
|
|
2
|
+
import { CmlDomain } from './types.js';
|
|
3
|
+
export declare class CmlAttribute extends AnnotatedCmlElement {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(attributeId: string | null, name: string, type: string);
|
|
6
|
+
get attributeId(): string | null;
|
|
7
|
+
get name(): string;
|
|
8
|
+
get type(): string;
|
|
9
|
+
get typeScale(): number | undefined;
|
|
10
|
+
get valueType(): string | undefined;
|
|
11
|
+
get value(): CmlDomain | undefined;
|
|
12
|
+
set name(name: string);
|
|
13
|
+
set type(type: string);
|
|
14
|
+
setTypeScale(scale: number | undefined): void;
|
|
15
|
+
setValue(valueType: string, value: CmlDomain): void;
|
|
16
|
+
generateCml(): string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { AnnotatedCmlElement } from './base/types.js';
|
|
17
|
+
export class CmlAttribute extends AnnotatedCmlElement {
|
|
18
|
+
#attributeId;
|
|
19
|
+
#name;
|
|
20
|
+
#type;
|
|
21
|
+
#typeScale; // decimal and double attribute types have scale values
|
|
22
|
+
#valueType;
|
|
23
|
+
#value;
|
|
24
|
+
constructor(attributeId, name, type) {
|
|
25
|
+
super();
|
|
26
|
+
this.#attributeId = attributeId;
|
|
27
|
+
this.#name = name;
|
|
28
|
+
this.#type = type;
|
|
29
|
+
}
|
|
30
|
+
get attributeId() {
|
|
31
|
+
return this.#attributeId;
|
|
32
|
+
}
|
|
33
|
+
get name() {
|
|
34
|
+
return this.#name;
|
|
35
|
+
}
|
|
36
|
+
get type() {
|
|
37
|
+
return this.#type;
|
|
38
|
+
}
|
|
39
|
+
get typeScale() {
|
|
40
|
+
return this.#typeScale;
|
|
41
|
+
}
|
|
42
|
+
get valueType() {
|
|
43
|
+
return this.#valueType;
|
|
44
|
+
}
|
|
45
|
+
get value() {
|
|
46
|
+
return this.#value;
|
|
47
|
+
}
|
|
48
|
+
set name(name) {
|
|
49
|
+
this.#name = name;
|
|
50
|
+
}
|
|
51
|
+
set type(type) {
|
|
52
|
+
this.#type = type;
|
|
53
|
+
}
|
|
54
|
+
setTypeScale(scale) {
|
|
55
|
+
this.#typeScale = scale;
|
|
56
|
+
}
|
|
57
|
+
setValue(valueType, value) {
|
|
58
|
+
this.#valueType = valueType;
|
|
59
|
+
this.#value = value;
|
|
60
|
+
}
|
|
61
|
+
generateCml() {
|
|
62
|
+
let output = '';
|
|
63
|
+
if (this.hasProperties()) {
|
|
64
|
+
output += this.generateAnnotation() + '\n';
|
|
65
|
+
}
|
|
66
|
+
if (this.#type) {
|
|
67
|
+
if (this.#typeScale !== undefined && this.#typeScale !== null) {
|
|
68
|
+
output += `${this.#type}(${this.#typeScale}) ${this.#name}`;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
output += `${this.#type} ${this.#name}`;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
// relation and component attributes do not have a defined data type
|
|
76
|
+
output += `${this.#name}`;
|
|
77
|
+
}
|
|
78
|
+
if (this.value) {
|
|
79
|
+
output += ` = ${this.value.generateCml()}`;
|
|
80
|
+
}
|
|
81
|
+
return output;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=cml-attribute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cml-attribute.js","sourceRoot":"","sources":["../../../src/shared/types/cml-attribute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGtD,MAAM,OAAO,YAAa,SAAQ,mBAAmB;IAC1C,YAAY,CAAgB;IACrC,KAAK,CAAS;IACd,KAAK,CAAS;IACd,UAAU,CAAU,CAAC,uDAAuD;IAC5E,UAAU,CAAU;IACpB,MAAM,CAAa;IAEnB,YAAmB,WAA0B,EAAE,IAAY,EAAE,IAAY;QACvE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAW,IAAI,CAAC,IAAY;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,IAAW,IAAI,CAAC,IAAY;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAEM,YAAY,CAAC,KAAyB;QAC3C,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC1B,CAAC;IAEM,QAAQ,CAAC,SAAiB,EAAE,KAAgB;QACjD,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAEM,WAAW;QAChB,IAAI,MAAM,GAAG,EAAE,CAAC;QAEhB,IAAI,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC;YACzB,MAAM,IAAI,IAAI,CAAC,kBAAkB,EAAE,GAAG,IAAI,CAAC;QAC7C,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,EAAE,CAAC;gBAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9D,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC1C,CAAC;QACH,CAAC;aAAM,CAAC;YACN,oEAAoE;YACpE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QAC5B,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;QAC7C,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { AnnotatedCmlElement } from './base/types.js';
|
|
2
|
+
export type CmlConstraintAttribute = {
|
|
3
|
+
attributeName: string;
|
|
4
|
+
attributeValue: string;
|
|
5
|
+
};
|
|
6
|
+
export declare class CmlConstraint extends AnnotatedCmlElement {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(type: string, declaration: string, explanation?: string, explanationType?: string);
|
|
9
|
+
get type(): string;
|
|
10
|
+
get name(): string;
|
|
11
|
+
get explanation(): string | undefined;
|
|
12
|
+
get explanationType(): string | undefined;
|
|
13
|
+
get declaration(): string;
|
|
14
|
+
get targetType(): string | undefined;
|
|
15
|
+
get targetRelation(): string | undefined;
|
|
16
|
+
get targetAttributes(): CmlConstraintAttribute[];
|
|
17
|
+
get targetQuantity(): number | undefined;
|
|
18
|
+
get action(): string | undefined;
|
|
19
|
+
get actionScope(): string | undefined;
|
|
20
|
+
get actionTarget(): string | undefined;
|
|
21
|
+
get actionClassification(): string | undefined;
|
|
22
|
+
get actionTargetValues(): string[];
|
|
23
|
+
get additiveExpressions(): string[] | undefined;
|
|
24
|
+
get sequence(): number;
|
|
25
|
+
set name(name: string);
|
|
26
|
+
static createRequireConstraint(type: string, // 'exclude' | 'require'
|
|
27
|
+
declaration: string, targetRelation: string, targetType: string, explanation?: string, targetAttributes?: CmlConstraintAttribute[], targetQuantity?: number): CmlConstraint;
|
|
28
|
+
static createRuleConstraint(declaration: string, action: string, actionScope: string, actionTarget: string, actionClassification?: string, actionTargetValues?: string[]): CmlConstraint;
|
|
29
|
+
static createMessageConstraint(declaration: string, explanation?: string, explanationType?: string, additiveExpressions?: string[]): CmlConstraint;
|
|
30
|
+
setType(type: string): void;
|
|
31
|
+
setExplanation(explanation: string): void;
|
|
32
|
+
setExplanationType(explanationType: string): void;
|
|
33
|
+
setSequence(value: number): void;
|
|
34
|
+
setTargetType(value: string): void;
|
|
35
|
+
setDeclaration(declaration: string): void;
|
|
36
|
+
setTargetRelation(value: string): void;
|
|
37
|
+
setTargetAttributes(attributesArray: CmlConstraintAttribute[]): void;
|
|
38
|
+
setTargetQuantity(value: number): void;
|
|
39
|
+
setAction(action: string): void;
|
|
40
|
+
setActionScope(actionScope: string): void;
|
|
41
|
+
setActionTarget(actionTarget: string): void;
|
|
42
|
+
setActionClassification(actionClassification?: string): void;
|
|
43
|
+
setActionTargetValues(actionTargetValues: string[]): void;
|
|
44
|
+
addTargetAttribute(attribute: string, value: string): void;
|
|
45
|
+
removeTargetAttribute(attribute: string): void;
|
|
46
|
+
updateTargetAttribute(index: number, attribute: string, value: string): void;
|
|
47
|
+
generateCml(): string;
|
|
48
|
+
private generateRequireCml;
|
|
49
|
+
private generateRuleCml;
|
|
50
|
+
}
|