@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,109 @@
|
|
|
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 const CML_METHODS = {
|
|
17
|
+
GET_PROPERTY: 'getProperty',
|
|
18
|
+
GET_ID: 'getId',
|
|
19
|
+
GET_TYPE_NAME: 'getTypeName',
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* CML has a set of predefined functions that can be invoked.
|
|
23
|
+
*/
|
|
24
|
+
export const CML_RELATION_ATTRIBUTE_FUNCTIONS = {
|
|
25
|
+
SUM: 'sum',
|
|
26
|
+
TOTAL: 'total',
|
|
27
|
+
MAX: 'max',
|
|
28
|
+
MIN: 'min',
|
|
29
|
+
COUNT: 'count',
|
|
30
|
+
JOIN: 'join',
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* CML has a set of proxy variables.
|
|
34
|
+
*/
|
|
35
|
+
export const CML_PROXY_VARIABLES = {
|
|
36
|
+
PARENT: 'parent',
|
|
37
|
+
ROOT: 'root',
|
|
38
|
+
SIBLING: 'sibling',
|
|
39
|
+
CARDINALITY: 'cardinality',
|
|
40
|
+
THIS_QUANTITY: 'this.quantity',
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* CML variable value types.
|
|
44
|
+
*/
|
|
45
|
+
export const CML_VARIABLE_VALUE_TYPES = {
|
|
46
|
+
DOMAIN: 'Domain',
|
|
47
|
+
FUNCTION: 'Function',
|
|
48
|
+
EXPRESSION: 'Expression',
|
|
49
|
+
PROXY_VARIABLE: 'Proxy Variable',
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* All primitive data types for CML.
|
|
53
|
+
*/
|
|
54
|
+
export const CML_DATA_TYPES = {
|
|
55
|
+
BOOLEAN: 'boolean',
|
|
56
|
+
DATE: 'date',
|
|
57
|
+
DECIMAL: 'decimal',
|
|
58
|
+
DOUBLE: 'double',
|
|
59
|
+
INTEGER: 'int',
|
|
60
|
+
STRING: 'string',
|
|
61
|
+
STRING_ARRAY: 'string[]',
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Display names of primitive data types for CML.
|
|
65
|
+
*/
|
|
66
|
+
export const CML_DATA_TYPE_DISPLAY_NAMES = {
|
|
67
|
+
int: 'Integer',
|
|
68
|
+
boolean: 'Boolean',
|
|
69
|
+
date: 'Date',
|
|
70
|
+
decimal: 'Decimal',
|
|
71
|
+
double: 'Double',
|
|
72
|
+
string: 'String',
|
|
73
|
+
'string[]': 'String Array',
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Subset of data types that are numbers.
|
|
77
|
+
*/
|
|
78
|
+
export const CML_NUMBER_DATA_TYPES = {
|
|
79
|
+
DECIMAL: 'decimal',
|
|
80
|
+
DOUBLE: 'double',
|
|
81
|
+
INTEGER: 'int',
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* All the constraint types.
|
|
85
|
+
*
|
|
86
|
+
* @type {Set<string>}
|
|
87
|
+
*/
|
|
88
|
+
export const CONSTRAINT_TYPES = {
|
|
89
|
+
BELONG: 'belong',
|
|
90
|
+
CONSTRAINT: 'constraint',
|
|
91
|
+
DISTINCT: 'distinct',
|
|
92
|
+
EQUAL: 'equal',
|
|
93
|
+
EXCLUDE: 'exclude',
|
|
94
|
+
INCLUDE: 'include',
|
|
95
|
+
MESSAGE: 'message',
|
|
96
|
+
PREFERENCE: 'preference',
|
|
97
|
+
REQUIRE: 'require',
|
|
98
|
+
RULE: 'rule',
|
|
99
|
+
SEQUENTIAL: 'sequential',
|
|
100
|
+
ACTION: 'action',
|
|
101
|
+
SET: 'set',
|
|
102
|
+
CONSTRUCTOR: 'constructor',
|
|
103
|
+
UNKNOWN: 'unknown',
|
|
104
|
+
};
|
|
105
|
+
export const ASSOCIATION_TYPES = {
|
|
106
|
+
TYPE: 'Type',
|
|
107
|
+
RELATION: 'Port',
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/shared/constants/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,YAAY,EAAE,aAAa;IAC3B,MAAM,EAAE,OAAO;IACf,aAAa,EAAE,aAAa;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG;IAC9C,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;CACb,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;IAC1B,aAAa,EAAE,eAAe;CAC/B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,MAAM,EAAE,QAAQ;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,0 +1,4 @@
|
|
|
1
|
+
import { ConfiguratorRuleInput, RuleCriteria } from './models.js';
|
|
2
|
+
export declare function extractProductIdsFromRuleCriteria(criterion: RuleCriteria): Set<string>;
|
|
3
|
+
export declare function extractProductIds(rule: ConfiguratorRuleInput): Set<string>;
|
|
4
|
+
export declare function groupByNonIntersectingProduct2(rules: ConfiguratorRuleInput[]): Map<string, ConfiguratorRuleInput[]>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
function isProduct2Id(id) {
|
|
2
|
+
return id?.startsWith('01t') ?? false;
|
|
3
|
+
}
|
|
4
|
+
export function extractProductIdsFromRuleCriteria(criterion) {
|
|
5
|
+
const ids = new Set();
|
|
6
|
+
if (isProduct2Id(criterion.rootObjectId)) {
|
|
7
|
+
ids.add(criterion.rootObjectId);
|
|
8
|
+
}
|
|
9
|
+
criterion.sourceValues?.forEach((v) => {
|
|
10
|
+
if (isProduct2Id(v)) {
|
|
11
|
+
ids.add(v);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
criterion.sourceInformation
|
|
15
|
+
?.filter((info) => info.name === 'Product')
|
|
16
|
+
.flatMap((info) => info.values?.values ?? [])
|
|
17
|
+
.filter(isProduct2Id)
|
|
18
|
+
.forEach((v) => ids.add(v));
|
|
19
|
+
return ids;
|
|
20
|
+
}
|
|
21
|
+
export function extractProductIds(rule) {
|
|
22
|
+
const ids = new Set();
|
|
23
|
+
for (const criterion of rule.criteria) {
|
|
24
|
+
Array.from(extractProductIdsFromRuleCriteria(criterion)).forEach((p) => ids.add(p));
|
|
25
|
+
}
|
|
26
|
+
for (const action of rule.actions) {
|
|
27
|
+
action.targetValues?.filter(isProduct2Id).forEach((v) => ids.add(v));
|
|
28
|
+
action.targetInformation
|
|
29
|
+
?.filter((info) => info.name === 'Product')
|
|
30
|
+
.flatMap((info) => info.values?.values ?? [])
|
|
31
|
+
.filter(isProduct2Id)
|
|
32
|
+
.forEach((v) => ids.add(v));
|
|
33
|
+
}
|
|
34
|
+
return ids;
|
|
35
|
+
}
|
|
36
|
+
export function groupByNonIntersectingProduct2(rules) {
|
|
37
|
+
const ruleToProducts = new Map();
|
|
38
|
+
const productToRules = new Map();
|
|
39
|
+
for (const rule of rules) {
|
|
40
|
+
const ids = extractProductIds(rule);
|
|
41
|
+
ruleToProducts.set(rule, ids);
|
|
42
|
+
for (const id of ids) {
|
|
43
|
+
if (!productToRules.has(id)) {
|
|
44
|
+
productToRules.set(id, new Set());
|
|
45
|
+
}
|
|
46
|
+
productToRules.get(id).add(rule);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const parent = new Map();
|
|
50
|
+
const find = (x) => {
|
|
51
|
+
if (parent.get(x) !== x) {
|
|
52
|
+
parent.set(x, find(parent.get(x)));
|
|
53
|
+
}
|
|
54
|
+
return parent.get(x);
|
|
55
|
+
};
|
|
56
|
+
const union = (x, y) => {
|
|
57
|
+
const rootX = find(x);
|
|
58
|
+
const rootY = find(y);
|
|
59
|
+
if (rootX !== rootY) {
|
|
60
|
+
parent.set(rootY, rootX);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
for (const rule of rules) {
|
|
64
|
+
parent.set(rule, rule);
|
|
65
|
+
}
|
|
66
|
+
for (const linkedRules of productToRules.values()) {
|
|
67
|
+
const [first, ...rest] = [...linkedRules];
|
|
68
|
+
for (const rule of rest) {
|
|
69
|
+
union(first, rule);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const rootToGroup = new Map();
|
|
73
|
+
for (const rule of rules) {
|
|
74
|
+
const root = find(rule);
|
|
75
|
+
if (!rootToGroup.has(root)) {
|
|
76
|
+
rootToGroup.set(root, []);
|
|
77
|
+
}
|
|
78
|
+
rootToGroup.get(root).push(rule);
|
|
79
|
+
}
|
|
80
|
+
const result = new Map();
|
|
81
|
+
for (const group of rootToGroup.values()) {
|
|
82
|
+
const ids = [...(ruleToProducts.get(group[0]) ?? [])];
|
|
83
|
+
const key = ids.join(',');
|
|
84
|
+
result.set(key, group);
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=grouping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grouping.js","sourceRoot":"","sources":["../../src/shared/grouping.ts"],"names":[],"mappings":"AAiBA,SAAS,YAAY,CAAC,EAA6B;IACjD,OAAO,EAAE,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,iCAAiC,CAAC,SAAuB;IACvE,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,IAAI,YAAY,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC;QACzC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IAClC,CAAC;IACD,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACpC,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;YACpB,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACb,CAAC;IACH,CAAC,CAAC,CAAC;IACH,SAAS,CAAC,iBAAiB;QACzB,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC;SAC1C,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,IAAI,EAAE,CAAC;SAC5C,MAAM,CAAC,YAAY,CAAC;SACpB,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAE,CAAC,CAAC,CAAC;IAE/B,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAA2B;IAC3D,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAE9B,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,QAAQ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AAG,IAAI,GAAG,EAAkD,CAAC;IAC9E,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;QACxB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC5B,CAAC;QACD,WAAW,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,GAAG,EAAmC,CAAC;IAE1D,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC;QACzC,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACtD,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export type RuleScope = 'Product' | 'Bundle' | 'Transaction';
|
|
2
|
+
export type RuleConditionType = 'Tag' | 'Enum' | 'Attribute';
|
|
3
|
+
export type RuleConditionOperator = 'Equals' | 'NotEquals' | 'LessThan' | 'LessThanOrEquals' | 'GreaterThan' | 'GreaterThanOrEquals' | 'IsNotNull' | 'IsNull' | 'Contains' | 'DoesNotContain' | 'In' | 'NotIn';
|
|
4
|
+
export type RuleActionType = 'AutoAdd' | 'AutoRemove' | 'SetAttribute' | 'SetQuantity' | 'SetDefaultProduct' | 'SetDefaultAttributeValue' | 'HideAttribute' | 'HideAttributeValue' | 'HideProduct' | 'DisableProduct' | 'DisableAttributeValue' | 'Requires' | 'Excludes' | 'Validate';
|
|
5
|
+
export type QuantityScaleMethod = 'Proportional' | 'Constant';
|
|
6
|
+
export type RuleConditionDataType = 'Text' | 'String' | 'Number' | 'Integer' | 'Percent' | 'Picklist' | 'Boolean' | 'MultiPicklist' | 'Date' | 'DateTime' | 'Currency' | 'Lookup';
|
|
7
|
+
export type UpdateCartAction = 'Validate' | 'Price';
|
|
8
|
+
export type ResourceValues = {
|
|
9
|
+
values: Array<string | null>;
|
|
10
|
+
};
|
|
11
|
+
export type ConditionInformation = {
|
|
12
|
+
type: string;
|
|
13
|
+
name: string;
|
|
14
|
+
values: ResourceValues;
|
|
15
|
+
};
|
|
16
|
+
export type Condition = {
|
|
17
|
+
contextTagName?: string;
|
|
18
|
+
dataType?: RuleConditionDataType;
|
|
19
|
+
values: string[];
|
|
20
|
+
attributeId?: string;
|
|
21
|
+
attributeName?: string;
|
|
22
|
+
conditionIndex?: number;
|
|
23
|
+
operator: RuleConditionOperator;
|
|
24
|
+
type: RuleConditionType;
|
|
25
|
+
};
|
|
26
|
+
export type RuleCriteria = {
|
|
27
|
+
rootObjectId: string;
|
|
28
|
+
sourceDataType?: string;
|
|
29
|
+
sourceContextTagName?: string;
|
|
30
|
+
sourceOperator?: RuleConditionOperator;
|
|
31
|
+
sourceValues: string[];
|
|
32
|
+
sourceInformation: ConditionInformation[];
|
|
33
|
+
conditionExpression?: string;
|
|
34
|
+
criteriaIndex?: number;
|
|
35
|
+
conditions?: Condition[];
|
|
36
|
+
};
|
|
37
|
+
export type RuleAction = {
|
|
38
|
+
name: string;
|
|
39
|
+
message?: string;
|
|
40
|
+
actionType: RuleActionType;
|
|
41
|
+
behaviorTypeLock?: boolean;
|
|
42
|
+
messageType?: string;
|
|
43
|
+
sequence?: number;
|
|
44
|
+
targetValues: string[];
|
|
45
|
+
targetInformation: ConditionInformation[];
|
|
46
|
+
targetContextTagName?: string;
|
|
47
|
+
targetDataType?: RuleConditionDataType;
|
|
48
|
+
targetOperator?: RuleConditionOperator;
|
|
49
|
+
actionParameters?: Condition[];
|
|
50
|
+
actionParametersExpression?: string;
|
|
51
|
+
};
|
|
52
|
+
export type ConfiguratorRuleInput = {
|
|
53
|
+
name: string;
|
|
54
|
+
apiName: string;
|
|
55
|
+
description?: string;
|
|
56
|
+
sequence?: number;
|
|
57
|
+
usageSubType: string;
|
|
58
|
+
criteriaExpressionType: string;
|
|
59
|
+
startDate?: string;
|
|
60
|
+
endDate?: string;
|
|
61
|
+
scope: RuleScope;
|
|
62
|
+
criteria: RuleCriteria[];
|
|
63
|
+
actions: RuleAction[];
|
|
64
|
+
productConfigurationRuleId?: string;
|
|
65
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/shared/models.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { PCMProduct, PCMProductAttribute, PCMProductRelatedComponent } from './pcm-products.types.js';
|
|
2
|
+
import { Association, CmlAttribute, CmlDomain, CmlModel, CmlRelation, CmlType } from './types/types.js';
|
|
3
|
+
export declare class PcmGenerator {
|
|
4
|
+
static generateType(model: CmlModel, product: PCMProduct, existingProductIdsToTypes: Map<string, CmlType>): {
|
|
5
|
+
type: CmlType;
|
|
6
|
+
association?: Association;
|
|
7
|
+
};
|
|
8
|
+
static setParentTypesToBaseType(model: CmlModel): void;
|
|
9
|
+
static generateRelationsAndChildTypes(model: CmlModel, type: CmlType, rootProduct: PCMProduct, childProducts: PCMProduct[]): {
|
|
10
|
+
associations: Association[];
|
|
11
|
+
relations: CmlRelation[];
|
|
12
|
+
types: CmlType[];
|
|
13
|
+
};
|
|
14
|
+
static generateViewModels(model: CmlModel, productsToAdd: PCMProduct[]): {
|
|
15
|
+
types: CmlType[];
|
|
16
|
+
associations: Association[];
|
|
17
|
+
attributes: Map<string, CmlAttribute[]>;
|
|
18
|
+
relations: Map<string, CmlRelation[]>;
|
|
19
|
+
};
|
|
20
|
+
static generateRelationsAttributesAndChildTypesRecursively(model: CmlModel, type: CmlType, parentProduct: PCMProduct, childProducts: PCMProduct[], existingProductIdsToTypes: Map<string, CmlType>, existingPrcIdsToRelations: Map<string, CmlRelation>, types?: CmlType[], associations?: Association[], relations?: Map<string, CmlRelation[]>, attributes?: Map<string, CmlAttribute[]>): {
|
|
21
|
+
associations: Association[];
|
|
22
|
+
relations: Map<string, CmlRelation[]>;
|
|
23
|
+
attributes: Map<string, CmlAttribute[]>;
|
|
24
|
+
types: CmlType[];
|
|
25
|
+
};
|
|
26
|
+
static generateRelation(model: CmlModel, parentProductType: CmlType, childProductType: CmlType, childProductComponent: PCMProduct, parentProduct: PCMProduct, prc: PCMProductRelatedComponent, existingPrcIdsToRelations: Map<string, CmlRelation>): {
|
|
27
|
+
association?: Association;
|
|
28
|
+
relation: CmlRelation;
|
|
29
|
+
};
|
|
30
|
+
static getProductComponents(product: PCMProduct): PCMProduct[];
|
|
31
|
+
static generateAttributes(productAttributes: PCMProductAttribute[]): CmlAttribute[];
|
|
32
|
+
static generateAttribute(productAttribute: PCMProductAttribute): CmlAttribute;
|
|
33
|
+
static getProductAttributes(product: PCMProduct): PCMProductAttribute[];
|
|
34
|
+
static dataTypeToCmlDataType(attribute: PCMProductAttribute): string;
|
|
35
|
+
static dataTypeNameToCmlDataType(dataType: string): string;
|
|
36
|
+
}
|
|
37
|
+
export declare function generateDomain(attribute: PCMProductAttribute): CmlDomain | null;
|
|
38
|
+
/**
|
|
39
|
+
* Generates a unique type name for a product within the given model.
|
|
40
|
+
* Ensures the name has only alphanumeric characters and underscores, starts with a letter,
|
|
41
|
+
* and is no longer than 80 characters.
|
|
42
|
+
*
|
|
43
|
+
* @param {Object} model - The model containing existing type names.
|
|
44
|
+
* @param {string} productName - The base name of the product.
|
|
45
|
+
* @param {Map} existingProductIdsToTypes - A map of existing type names to types that have been created but not yet saved to the model.
|
|
46
|
+
* @returns {string} - A valid, unique type name.
|
|
47
|
+
*/
|
|
48
|
+
export declare function generateUniqueTypeName(model: CmlModel, productName: string, existingProductIdsToTypes: Map<string, CmlType>): string;
|
|
49
|
+
/**
|
|
50
|
+
* Generates a unique relation name for a parent product type based on a child product type name.
|
|
51
|
+
*
|
|
52
|
+
* @param {Object} parentProductType - The parent product type object containing existing relations.
|
|
53
|
+
* @param {string} childProductTypeName - The base name for the relation.
|
|
54
|
+
* @param {Map} existingPrcIdsToRelations - A map of existing relation names to relations that have been created but not yet saved to the model.
|
|
55
|
+
* @returns {string} - A unique, lowercased relation name.
|
|
56
|
+
*/
|
|
57
|
+
export declare function generateUniqueRelationName(parentProductType: CmlType, childProductTypeName: string, existingPrcIdsToRelations: Map<string, CmlRelation>): string;
|