@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.
Files changed (85) hide show
  1. package/LICENSE.txt +206 -0
  2. package/README.md +158 -0
  3. package/lib/commands/cml/convert/prod-cfg-rules.d.ts +29 -0
  4. package/lib/commands/cml/convert/prod-cfg-rules.js +226 -0
  5. package/lib/commands/cml/convert/prod-cfg-rules.js.map +1 -0
  6. package/lib/commands/cml/import/as-expression-set.d.ts +18 -0
  7. package/lib/commands/cml/import/as-expression-set.js +184 -0
  8. package/lib/commands/cml/import/as-expression-set.js.map +1 -0
  9. package/lib/index.d.ts +2 -0
  10. package/lib/index.js +17 -0
  11. package/lib/index.js.map +1 -0
  12. package/lib/shared/bre-rules-generator.d.ts +20 -0
  13. package/lib/shared/bre-rules-generator.js +497 -0
  14. package/lib/shared/bre-rules-generator.js.map +1 -0
  15. package/lib/shared/cml.d.ts +2 -0
  16. package/lib/shared/cml.js +13 -0
  17. package/lib/shared/cml.js.map +1 -0
  18. package/lib/shared/constants/constants.d.ts +94 -0
  19. package/lib/shared/constants/constants.js +109 -0
  20. package/lib/shared/constants/constants.js.map +1 -0
  21. package/lib/shared/grouping.d.ts +4 -0
  22. package/lib/shared/grouping.js +88 -0
  23. package/lib/shared/grouping.js.map +1 -0
  24. package/lib/shared/models.d.ts +65 -0
  25. package/lib/shared/models.js +2 -0
  26. package/lib/shared/models.js.map +1 -0
  27. package/lib/shared/pcm-generator.d.ts +57 -0
  28. package/lib/shared/pcm-generator.js +418 -0
  29. package/lib/shared/pcm-generator.js.map +1 -0
  30. package/lib/shared/pcm-products.d.ts +14 -0
  31. package/lib/shared/pcm-products.js +125 -0
  32. package/lib/shared/pcm-products.js.map +1 -0
  33. package/lib/shared/pcm-products.types.d.ts +99 -0
  34. package/lib/shared/pcm-products.types.js +2 -0
  35. package/lib/shared/pcm-products.types.js.map +1 -0
  36. package/lib/shared/types/association.d.ts +15 -0
  37. package/lib/shared/types/association.js +64 -0
  38. package/lib/shared/types/association.js.map +1 -0
  39. package/lib/shared/types/base/annotated-cml-element-w-attributes.d.ts +10 -0
  40. package/lib/shared/types/base/annotated-cml-element-w-attributes.js +36 -0
  41. package/lib/shared/types/base/annotated-cml-element-w-attributes.js.map +1 -0
  42. package/lib/shared/types/base/annotated-cml-element.d.ts +9 -0
  43. package/lib/shared/types/base/annotated-cml-element.js +39 -0
  44. package/lib/shared/types/base/annotated-cml-element.js.map +1 -0
  45. package/lib/shared/types/base/types.d.ts +2 -0
  46. package/lib/shared/types/base/types.js +18 -0
  47. package/lib/shared/types/base/types.js.map +1 -0
  48. package/lib/shared/types/cml-attribute.d.ts +17 -0
  49. package/lib/shared/types/cml-attribute.js +84 -0
  50. package/lib/shared/types/cml-attribute.js.map +1 -0
  51. package/lib/shared/types/cml-constraint.d.ts +50 -0
  52. package/lib/shared/types/cml-constraint.js +277 -0
  53. package/lib/shared/types/cml-constraint.js.map +1 -0
  54. package/lib/shared/types/cml-domain.d.ts +25 -0
  55. package/lib/shared/types/cml-domain.js +132 -0
  56. package/lib/shared/types/cml-domain.js.map +1 -0
  57. package/lib/shared/types/cml-model.d.ts +39 -0
  58. package/lib/shared/types/cml-model.js +153 -0
  59. package/lib/shared/types/cml-model.js.map +1 -0
  60. package/lib/shared/types/cml-relation.d.ts +31 -0
  61. package/lib/shared/types/cml-relation.js +118 -0
  62. package/lib/shared/types/cml-relation.js.map +1 -0
  63. package/lib/shared/types/cml-type.d.ts +22 -0
  64. package/lib/shared/types/cml-type.js +111 -0
  65. package/lib/shared/types/cml-type.js.map +1 -0
  66. package/lib/shared/types/sobject.d.ts +13 -0
  67. package/lib/shared/types/sobject.js +2 -0
  68. package/lib/shared/types/sobject.js.map +1 -0
  69. package/lib/shared/types/types.d.ts +8 -0
  70. package/lib/shared/types/types.js +24 -0
  71. package/lib/shared/types/types.js.map +1 -0
  72. package/lib/shared/utils/association.utils.d.ts +61 -0
  73. package/lib/shared/utils/association.utils.js +175 -0
  74. package/lib/shared/utils/association.utils.js.map +1 -0
  75. package/lib/shared/utils/common.utils.d.ts +191 -0
  76. package/lib/shared/utils/common.utils.js +338 -0
  77. package/lib/shared/utils/common.utils.js.map +1 -0
  78. package/messages/call.external.service.md +20 -0
  79. package/messages/cml.convert.prod-cfg-rules.md +59 -0
  80. package/messages/cml.import.as-expression-set.md +32 -0
  81. package/messages/connect.org.md +19 -0
  82. package/messages/hello.world.md +29 -0
  83. package/oclif.lock +8313 -0
  84. package/oclif.manifest.json +209 -0
  85. package/package.json +227 -0
@@ -0,0 +1,209 @@
1
+ {
2
+ "commands": {
3
+ "cml:convert:prod-cfg-rules": {
4
+ "aliases": [],
5
+ "args": {},
6
+ "description": "Before you execute this command make sure to migrate you PCM or perform migration of rules within the same org.\n\nExport BRE based Standard Configurator rules using sf data export bulk plugin and save results in a JSON file:\nsf data export bulk -o breMigOrg --query \"SELECT ApiName, ConfigurationRuleDefinition,Description, EffectiveFromDate, EffectiveToDate, Id, IsDeleted, Name, ProcessScope, RuleSubType, RuleType, Sequence, Status FROM ProductConfigurationRule WHERE RuleType = 'Configurator' AND ApiName = 'myTestBundle'\" --output-file ./data/ProductConfigurationRules.json --result-format json --wait 10 --all-rows\n\nThis command executes following logic:\n\n- Read SC Rules from the json file and build a list of `ConfiguratorRuleInput` to mimic the JSON structure of `ConfigurationRuleDefinition`\n- Group rules by non-intersecting `Product2` IDs (CMLs can’t share products)\n- For each group:\n - Query PCM for related products (for bundle rules) or root definitions (for others)\n - Build an in-memory representation of the CML\n - Apply logic to build constraints\n- Serialize the in-memory CML to a blob for import as an Expression Set, save it in a cml-api.cml file. \n- Create `ExpressionSetConstraintObj` association records pointing to the `cml-api` name and write them to `cml-api_associations.csv` file.\n- If multiple CML and association files are produced 1-N number will be appended to the names of files.",
7
+ "examples": [
8
+ "<%= config.bin %> <%= command.id %> --pcr-file data/ProductConfigurationRules.json --cml-api MY_TEST --workspace-dir data --target-org breMigOrg"
9
+ ],
10
+ "flags": {
11
+ "json": {
12
+ "description": "Format output as json.",
13
+ "helpGroup": "GLOBAL",
14
+ "name": "json",
15
+ "allowNo": false,
16
+ "type": "boolean"
17
+ },
18
+ "flags-dir": {
19
+ "helpGroup": "GLOBAL",
20
+ "name": "flags-dir",
21
+ "summary": "Import flag values from a directory.",
22
+ "hasDynamicHelp": false,
23
+ "multiple": false,
24
+ "type": "option"
25
+ },
26
+ "target-org": {
27
+ "char": "o",
28
+ "name": "target-org",
29
+ "noCacheDefault": true,
30
+ "required": true,
31
+ "summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
32
+ "hasDynamicHelp": true,
33
+ "multiple": false,
34
+ "type": "option"
35
+ },
36
+ "api-version": {
37
+ "description": "Override the api version used for api requests made by this command",
38
+ "name": "api-version",
39
+ "hasDynamicHelp": false,
40
+ "multiple": false,
41
+ "type": "option"
42
+ },
43
+ "pcr-file": {
44
+ "char": "r",
45
+ "name": "pcr-file",
46
+ "required": true,
47
+ "summary": "Name of the JSON file that contain exported standard Product Configuration Rules.",
48
+ "hasDynamicHelp": false,
49
+ "multiple": false,
50
+ "type": "option"
51
+ },
52
+ "cml-api": {
53
+ "char": "c",
54
+ "name": "cml-api",
55
+ "required": true,
56
+ "summary": "Unique CML API Name to be created.",
57
+ "hasDynamicHelp": false,
58
+ "multiple": false,
59
+ "type": "option"
60
+ },
61
+ "workspace-dir": {
62
+ "char": "d",
63
+ "name": "workspace-dir",
64
+ "summary": "Directory where working files are located, exported rules JSON and where CMLs will be created.",
65
+ "hasDynamicHelp": false,
66
+ "multiple": false,
67
+ "type": "option"
68
+ },
69
+ "additional-products": {
70
+ "char": "x",
71
+ "name": "additional-products",
72
+ "summary": "Comma-separated list of additional product IDs for which CML types should be generated.",
73
+ "hasDynamicHelp": false,
74
+ "multiple": false,
75
+ "type": "option"
76
+ },
77
+ "products-file": {
78
+ "char": "v",
79
+ "name": "products-file",
80
+ "summary": "Name of the JSON file that contain exported Products from PCM (if not present products will be fetched automatically).",
81
+ "hasDynamicHelp": false,
82
+ "multiple": false,
83
+ "type": "option"
84
+ }
85
+ },
86
+ "hasDynamicHelp": true,
87
+ "hiddenAliases": [],
88
+ "id": "cml:convert:prod-cfg-rules",
89
+ "pluginAlias": "@salesforce/plugin-bre-to-cml",
90
+ "pluginName": "@salesforce/plugin-bre-to-cml",
91
+ "pluginType": "core",
92
+ "strict": true,
93
+ "summary": "Converts BRE based Standard Configurator rules represented as JSON to CML and saves it as a pair of CML and association files.",
94
+ "enableJsonFlag": true,
95
+ "isESM": true,
96
+ "relativePath": [
97
+ "lib",
98
+ "commands",
99
+ "cml",
100
+ "convert",
101
+ "prod-cfg-rules.js"
102
+ ],
103
+ "aliasPermutations": [],
104
+ "permutations": [
105
+ "cml:convert:prod-cfg-rules",
106
+ "convert:cml:prod-cfg-rules",
107
+ "convert:prod-cfg-rules:cml",
108
+ "cml:prod-cfg-rules:convert",
109
+ "prod-cfg-rules:cml:convert",
110
+ "prod-cfg-rules:convert:cml"
111
+ ]
112
+ },
113
+ "cml:import:as-expression-set": {
114
+ "aliases": [],
115
+ "args": {},
116
+ "description": "Review CM created by conversion command before doing import. \nThis command executes following logic:\n- Import one CML at a time\n- Upsert the Expression Set using the `cml-api` name\n- Read and upsert `ExpressionSetConstraintObj` rows from the `cml-api_associations.csv` file (resolving FKs)\n- Upload the CML blob",
117
+ "examples": [
118
+ "<%= config.bin %> <%= command.id %> --cml-api MY_TEST --context-definition PricingTransactionCD2 --workspace-dir data --target-org tgtOrg"
119
+ ],
120
+ "flags": {
121
+ "json": {
122
+ "description": "Format output as json.",
123
+ "helpGroup": "GLOBAL",
124
+ "name": "json",
125
+ "allowNo": false,
126
+ "type": "boolean"
127
+ },
128
+ "flags-dir": {
129
+ "helpGroup": "GLOBAL",
130
+ "name": "flags-dir",
131
+ "summary": "Import flag values from a directory.",
132
+ "hasDynamicHelp": false,
133
+ "multiple": false,
134
+ "type": "option"
135
+ },
136
+ "target-org": {
137
+ "char": "o",
138
+ "name": "target-org",
139
+ "noCacheDefault": true,
140
+ "required": true,
141
+ "summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
142
+ "hasDynamicHelp": true,
143
+ "multiple": false,
144
+ "type": "option"
145
+ },
146
+ "api-version": {
147
+ "description": "Override the api version used for api requests made by this command",
148
+ "name": "api-version",
149
+ "hasDynamicHelp": false,
150
+ "multiple": false,
151
+ "type": "option"
152
+ },
153
+ "context-definition": {
154
+ "char": "x",
155
+ "name": "context-definition",
156
+ "required": true,
157
+ "summary": "Context Definition name to be assocciated with the CML.",
158
+ "hasDynamicHelp": false,
159
+ "multiple": false,
160
+ "type": "option"
161
+ },
162
+ "cml-api": {
163
+ "char": "c",
164
+ "name": "cml-api",
165
+ "required": true,
166
+ "summary": "Unique CML API Name to be created.",
167
+ "hasDynamicHelp": false,
168
+ "multiple": false,
169
+ "type": "option"
170
+ },
171
+ "workspace-dir": {
172
+ "char": "d",
173
+ "name": "workspace-dir",
174
+ "summary": "Directory where converted CML and assocciations csv files are located.",
175
+ "hasDynamicHelp": false,
176
+ "multiple": false,
177
+ "type": "option"
178
+ }
179
+ },
180
+ "hasDynamicHelp": true,
181
+ "hiddenAliases": [],
182
+ "id": "cml:import:as-expression-set",
183
+ "pluginAlias": "@salesforce/plugin-bre-to-cml",
184
+ "pluginName": "@salesforce/plugin-bre-to-cml",
185
+ "pluginType": "core",
186
+ "strict": true,
187
+ "summary": "Imports CML and associations to the target org",
188
+ "enableJsonFlag": true,
189
+ "isESM": true,
190
+ "relativePath": [
191
+ "lib",
192
+ "commands",
193
+ "cml",
194
+ "import",
195
+ "as-expression-set.js"
196
+ ],
197
+ "aliasPermutations": [],
198
+ "permutations": [
199
+ "cml:import:as-expression-set",
200
+ "import:cml:as-expression-set",
201
+ "import:as-expression-set:cml",
202
+ "cml:as-expression-set:import",
203
+ "as-expression-set:cml:import",
204
+ "as-expression-set:import:cml"
205
+ ]
206
+ }
207
+ },
208
+ "version": "1.0.2"
209
+ }
package/package.json ADDED
@@ -0,0 +1,227 @@
1
+ {
2
+ "name": "@salesforce/plugin-bre-to-cml",
3
+ "description": "Plugin for migrating BRE based configurator rules to CML.",
4
+ "version": "1.0.2",
5
+ "salesforceRelease": "256.11",
6
+ "dependencies": {
7
+ "@oclif/core": "^4",
8
+ "@salesforce/core": "^8.2.7",
9
+ "@salesforce/sf-plugins-core": "^12",
10
+ "csv-parse": "^5.6.0",
11
+ "got": "12"
12
+ },
13
+ "devDependencies": {
14
+ "@oclif/plugin-command-snapshot": "^5.3.5",
15
+ "@salesforce/plugin-command-reference": "^3.1.61",
16
+ "@oclif/test": "^4.1.0",
17
+ "@salesforce/cli-plugins-testkit": "^5.3.20",
18
+ "@salesforce/dev-scripts": "^11.0.2",
19
+ "@types/node": "^22.17.0",
20
+ "eslint-config-salesforce-license": "^1.0.1",
21
+ "eslint-plugin-sf-plugin": "^1.18.8",
22
+ "oclif": "^4.14.0",
23
+ "ts-node": "^10.9.2",
24
+ "typescript": "^5.9.2"
25
+ },
26
+ "engines": {
27
+ "node": ">=18.0.0"
28
+ },
29
+ "files": [
30
+ "lib",
31
+ "messages",
32
+ "oclif.manifest.json",
33
+ "oclif.lock"
34
+ ],
35
+ "keywords": [
36
+ "force",
37
+ "salesforce",
38
+ "salesforcedx",
39
+ "sf",
40
+ "sf-plugin",
41
+ "sfdx",
42
+ "sfdx-plugin"
43
+ ],
44
+ "license": "Apache-2.0",
45
+ "oclif": {
46
+ "commands": "./lib/commands",
47
+ "bin": "sf",
48
+ "topicSeparator": " ",
49
+ "devPlugins": [
50
+ "@oclif/plugin-help",
51
+ "@oclif/plugin-command-snapshot",
52
+ "@salesforce/plugin-command-reference"
53
+ ],
54
+ "topics": {
55
+ "cml": {
56
+ "description": "description for cml",
57
+ "subtopics": {
58
+ "convert": {
59
+ "description": "description for cml.convert"
60
+ },
61
+ "import": {
62
+ "description": "description for cml.import"
63
+ }
64
+ }
65
+ }
66
+ },
67
+ "flexibleTaxonomy": true
68
+ },
69
+ "scripts": {
70
+ "build": "wireit",
71
+ "clean": "sf-clean",
72
+ "clean-all": "sf-clean all",
73
+ "compile": "wireit",
74
+ "dev.js": "./bin/dev.js cml convert prod-cfg-rules -o prism-dev -r ./data/ProductConfigurationRules3.json -v ./data/Products.json -c TestModel3 -d ./data/output",
75
+ "docs": "sf-docs",
76
+ "fix-license": "eslint src test --fix --rule \"header/header: [2]\"",
77
+ "format": "wireit",
78
+ "link-check": "wireit",
79
+ "lint": "wireit",
80
+ "postinstall": "test -d .git && yarn husky install || echo 'Skipping husky install'",
81
+ "postpack": "sf-clean --ignore-signing-artifacts",
82
+ "prepack": "sf-prepack",
83
+ "prepare": "sf-install",
84
+ "test": "wireit",
85
+ "test:nuts": "nyc mocha \"**/*.nut.ts\" --slow 4500 --timeout 600000 --parallel",
86
+ "test:only": "wireit",
87
+ "version": "oclif readme"
88
+ },
89
+ "publishConfig": {
90
+ "access": "public"
91
+ },
92
+ "wireit": {
93
+ "build": {
94
+ "dependencies": [
95
+ "compile",
96
+ "lint",
97
+ "gen-manifest"
98
+ ]
99
+ },
100
+ "compile": {
101
+ "command": "tsc -p . --pretty --incremental",
102
+ "files": [
103
+ "src/**/*.ts",
104
+ "**/tsconfig.json",
105
+ "messages/**"
106
+ ],
107
+ "output": [
108
+ "lib/**",
109
+ "*.tsbuildinfo"
110
+ ],
111
+ "clean": "if-file-deleted"
112
+ },
113
+ "format": {
114
+ "command": "prettier --write \"+(src|test|schemas)/**/*.+(ts|js|json)|command-snapshot.json\"",
115
+ "files": [
116
+ "src/**/*.ts",
117
+ "test/**/*.ts",
118
+ "schemas/**/*.json",
119
+ "command-snapshot.json",
120
+ ".prettier*"
121
+ ],
122
+ "output": []
123
+ },
124
+ "lint": {
125
+ "command": "eslint src test --color --cache --cache-location .eslintcache",
126
+ "files": [
127
+ "src/**/*.ts",
128
+ "test/**/*.ts",
129
+ "messages/**",
130
+ "**/.eslint*",
131
+ "**/tsconfig.json"
132
+ ],
133
+ "output": []
134
+ },
135
+ "gen-manifest": {
136
+ "command": "yarn oclif manifest .",
137
+ "dependencies": [
138
+ "compile"
139
+ ],
140
+ "files": [
141
+ "lib/commands/**/*.js"
142
+ ],
143
+ "output": [
144
+ "oclif.manifest.json"
145
+ ]
146
+ },
147
+ "test:compile": {
148
+ "command": "tsc -p \"./test\" --pretty",
149
+ "files": [
150
+ "test/**/*.ts",
151
+ "**/tsconfig.json"
152
+ ],
153
+ "output": []
154
+ },
155
+ "test": {
156
+ "dependencies": [
157
+ "test:compile",
158
+ "test:only",
159
+ "test:command-reference",
160
+ "test:deprecation-policy",
161
+ "lint",
162
+ "test:json-schema",
163
+ "link-check"
164
+ ]
165
+ },
166
+ "test:only": {
167
+ "command": "nyc mocha \"test/**/*.test.ts\"",
168
+ "env": {
169
+ "FORCE_COLOR": "2"
170
+ },
171
+ "files": [
172
+ "test/**/*.ts",
173
+ "src/**/*.ts",
174
+ "**/tsconfig.json",
175
+ ".mocha*",
176
+ "!*.nut.ts",
177
+ ".nycrc"
178
+ ],
179
+ "output": []
180
+ },
181
+ "test:command-reference": {
182
+ "command": "node --loader ts-node/esm --no-warnings=ExperimentalWarning \"./bin/dev.js\" commandreference:generate --erroronwarnings",
183
+ "files": [
184
+ "src/**/*.ts",
185
+ "messages/**",
186
+ "package.json"
187
+ ],
188
+ "output": [
189
+ "tmp/root"
190
+ ]
191
+ },
192
+ "test:deprecation-policy": {
193
+ "command": "node --loader ts-node/esm --no-warnings=ExperimentalWarning \"./bin/dev.js\" snapshot:compare",
194
+ "files": [
195
+ "src/**/*.ts"
196
+ ],
197
+ "output": [],
198
+ "dependencies": [
199
+ "compile"
200
+ ]
201
+ },
202
+ "test:json-schema": {
203
+ "command": "node --loader ts-node/esm --no-warnings=ExperimentalWarning \"./bin/dev.js\" schema:compare",
204
+ "files": [
205
+ "src/**/*.ts",
206
+ "schemas"
207
+ ],
208
+ "output": []
209
+ },
210
+ "link-check": {
211
+ "command": "node -e \"process.exit(process.env.CI ? 0 : 1)\" || linkinator \"**/*.md\" --skip \"CHANGELOG.md|node_modules|test/|confluence.internal.salesforce.com|my.salesforce.com|localhost|%s\" --markdown --retry --directory-listing --verbosity error",
212
+ "files": [
213
+ "./*.md",
214
+ "./!(CHANGELOG).md",
215
+ "messages/**/*.md"
216
+ ],
217
+ "output": []
218
+ }
219
+ },
220
+ "exports": "./lib/index.js",
221
+ "type": "module",
222
+ "author": "George Kibilov",
223
+ "sfdx": {
224
+ "publicKeyUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-bre-to-cml/1.0.2.crt",
225
+ "signatureUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-bre-to-cml/1.0.2.sig"
226
+ }
227
+ }