@cparra/apexdocs 3.8.0 → 3.9.0

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/README.md CHANGED
@@ -115,7 +115,8 @@ apexdocs changelog --previousVersionDir force-app-previous --currentVersionDir f
115
115
  |----------------------------|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------|----------|
116
116
  | `--sourceDir` | `-s` | The directory where the source files are located. | N/A | Yes |
117
117
  | `--targetDir` | `-t` | The directory where the generated files will be placed. | `docs` | No |
118
- | `--scope` | `-p` | A list of scopes to document. Values should be separated by a space, e.g --scope global public namespaceaccessible. | `global` | No |
118
+ | `--scope` | `-p` | A list of scopes to document. Values should be separated by a space, e.g --scope global public namespaceaccessible. | `[global]` | No |
119
+ | `--customObjectVisibility` | `-v` | Controls which custom objects are documented. Values should be separated by a space. | `[public]` | No |
119
120
  | `--defaultGroupName` | N/A | The default group name to use when a group is not specified. | `Miscellaneous` | No |
120
121
  | `--namespace` | N/A | The package namespace, if any. If provided, it will be added to the generated files. | N/A | No |
121
122
  | `--sortAlphabetically` | N/A | Sorts files appearing in the Reference Guide alphabetically, as well as the members of a class, interface or enum alphabetically. If false, the members will be displayed in the same order as the code. | `false` | No |
@@ -184,14 +185,15 @@ apexdocs openapi -s force-app -t docs -n MyNamespace --title "My Custom OpenApi
184
185
 
185
186
  #### Flags
186
187
 
187
- | Flag | Alias | Description | Default | Required |
188
- |------------------------|-------|--------------------------------------------------------------------|-------------|----------|
189
- | `--previousVersionDir` | `-p` | The directory location of the previous version of the source code. | N/A | Yes |
190
- | `--currentVersionDir` | `-t` | The directory location of the current version of the source code. | N/A | Yes |
191
- | `--targetDir` | `-t` | The directory location where the changelog file will be generated. | `./docs/` | No |
192
- | `--fileName` | N/A | The name of the changelog file to be generated. | `changelog` | No |
193
- | `--scope` | N/A | The list of scope to respect when generating the changelog. | ['global'] | No |
194
- | `--skipIfNoChanges` | N/A | Whether to skip generating the changelog if there are no changes. | `true` | No |
188
+ | Flag | Alias | Description | Default | Required |
189
+ |----------------------------|-------|--------------------------------------------------------------------------------------|-------------|----------|
190
+ | `--previousVersionDir` | `-p` | The directory location of the previous version of the source code. | N/A | Yes |
191
+ | `--currentVersionDir` | `-t` | The directory location of the current version of the source code. | N/A | Yes |
192
+ | `--targetDir` | `-t` | The directory location where the changelog file will be generated. | `./docs/` | No |
193
+ | `--fileName` | N/A | The name of the changelog file to be generated. | `changelog` | No |
194
+ | `--scope` | N/A | The list of scope to respect when generating the changelog. | ['global'] | No |
195
+ | `--customObjectVisibility` | `-v` | Controls which custom objects are documented. Values should be separated by a space. | ['public'] | No |
196
+ | `--skipIfNoChanges` | N/A | Whether to skip generating the changelog if there are no changes. | `true` | No |
195
197
 
196
198
  #### Sample Usage
197
199
 
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- var logger$1 = require('../logger-B0wNVQij.js');
4
+ var logger$1 = require('../logger-Cr61RvjC.js');
5
5
  var module$1 = require('module');
6
6
  var cosmiconfig = require('cosmiconfig');
7
7
  var E = require('fp-ts/Either');
@@ -70,6 +70,14 @@ const markdownOptions = {
70
70
  default: logger$1.markdownDefaults.scope,
71
71
  describe: "A list of scopes to document. Values should be separated by a space, e.g --scope global public namespaceaccessible. Annotations are supported and should be passed lowercased and without the @ symbol, e.g. namespaceaccessible auraenabled."
72
72
  },
73
+ customObjectVisibility: {
74
+ type: "string",
75
+ array: true,
76
+ alias: "v",
77
+ default: logger$1.markdownDefaults.customObjectVisibility,
78
+ choices: ["public", "protected", "packageprotected"],
79
+ describe: "Controls which custom objects are documented. Values should be separated by a space."
80
+ },
73
81
  defaultGroupName: {
74
82
  type: "string",
75
83
  default: logger$1.markdownDefaults.defaultGroupName,
@@ -172,6 +180,14 @@ const changeLogOptions = {
172
180
  default: logger$1.changeLogDefaults.scope,
173
181
  describe: "The list of scope to respect when generating the changelog. Values should be separated by a space, e.g --scope global public namespaceaccessible. Annotations are supported and should be passed lowercased and without the @ symbol, e.g. namespaceaccessible auraenabled."
174
182
  },
183
+ customObjectVisibility: {
184
+ type: "string",
185
+ array: true,
186
+ alias: "v",
187
+ default: logger$1.changeLogDefaults.customObjectVisibility,
188
+ choices: ["public", "protected", "packageprotected"],
189
+ describe: "Controls which custom objects are documented. Values should be separated by a space."
190
+ },
175
191
  skipIfNoChanges: {
176
192
  type: "boolean",
177
193
  default: logger$1.changeLogDefaults.skipIfNoChanges,
package/dist/index.d.ts CHANGED
@@ -15,6 +15,7 @@ type CliConfigurableMarkdownConfig = {
15
15
  sourceDir: string;
16
16
  targetDir: string;
17
17
  scope: string[];
18
+ customObjectVisibility: string[];
18
19
  namespace?: string;
19
20
  defaultGroupName: string;
20
21
  customObjectsGroupName: string;
@@ -49,6 +50,7 @@ type UserDefinedChangelogConfig = {
49
50
  targetDir: string;
50
51
  fileName: string;
51
52
  scope: string[];
53
+ customObjectVisibility: string[];
52
54
  exclude: string[];
53
55
  skipIfNoChanges: boolean;
54
56
  } & Partial<ChangelogConfigurableHooks>;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var logger = require('./logger-B0wNVQij.js');
3
+ var logger = require('./logger-Cr61RvjC.js');
4
4
  var E = require('fp-ts/Either');
5
5
  require('fp-ts/function');
6
6
  require('fp-ts/TaskEither');
@@ -624,6 +624,16 @@ function singleGroup(headingLevel, groupName, adapter, members, linkGenerator) {
624
624
  }
625
625
  function objectMetadataToRenderable(objectMetadata, config) {
626
626
  var _a;
627
+ function toRenderablePublishBehavior(publishBehavior) {
628
+ switch (publishBehavior) {
629
+ case "PublishImmediately":
630
+ return "Publish Immediately";
631
+ case "PublishAfterCommit":
632
+ return "Publish After Commit";
633
+ default:
634
+ return null;
635
+ }
636
+ }
627
637
  return {
628
638
  type: "customobject",
629
639
  headingLevel: 1,
@@ -645,7 +655,8 @@ function objectMetadataToRenderable(objectMetadata, config) {
645
655
  headingLevel: 2,
646
656
  heading: "Records",
647
657
  value: objectMetadata.metadataRecords.map((metadata) => customMetadataToRenderable(metadata, 3))
648
- }
658
+ },
659
+ publishBehavior: toRenderablePublishBehavior(objectMetadata.publishBehavior)
649
660
  };
650
661
  }
651
662
  function fieldMetadataToRenderable(field, config, headingLevel) {
@@ -1458,16 +1469,19 @@ var __spreadProps$h = (a, b) => __defProps$h(a, __getOwnPropDescs$h(b));
1458
1469
  const commonDefaults = {
1459
1470
  targetDir: "./docs/"
1460
1471
  };
1461
- const markdownDefaults = __spreadProps$h(__spreadValues$h({}, commonDefaults), {
1472
+ const markdownAndChangelogDefaults = __spreadProps$h(__spreadValues$h({}, commonDefaults), {
1462
1473
  scope: ["global"],
1474
+ customObjectVisibility: ["public"],
1475
+ exclude: []
1476
+ });
1477
+ const markdownDefaults = __spreadProps$h(__spreadValues$h({}, markdownAndChangelogDefaults), {
1463
1478
  defaultGroupName: "Miscellaneous",
1464
1479
  customObjectsGroupName: "Custom Objects",
1465
1480
  includeMetadata: false,
1466
1481
  sortAlphabetically: false,
1467
1482
  linkingStrategy: "relative",
1468
1483
  referenceGuideTitle: "Reference Guide",
1469
- excludeTags: [],
1470
- exclude: []
1484
+ excludeTags: []
1471
1485
  });
1472
1486
  const openApiDefaults = __spreadProps$h(__spreadValues$h({}, commonDefaults), {
1473
1487
  fileName: "openapi",
@@ -1475,10 +1489,8 @@ const openApiDefaults = __spreadProps$h(__spreadValues$h({}, commonDefaults), {
1475
1489
  apiVersion: "1.0.0",
1476
1490
  exclude: []
1477
1491
  });
1478
- const changeLogDefaults = __spreadProps$h(__spreadValues$h({}, commonDefaults), {
1492
+ const changeLogDefaults = __spreadProps$h(__spreadValues$h({}, markdownAndChangelogDefaults), {
1479
1493
  fileName: "changelog",
1480
- scope: ["global"],
1481
- exclude: [],
1482
1494
  skipIfNoChanges: true
1483
1495
  });
1484
1496
 
@@ -1490,6 +1502,12 @@ const customObjectTemplate = `
1490
1502
  ## API Name
1491
1503
  \`{{apiName}}\`
1492
1504
 
1505
+ {{#if publishBehavior}}
1506
+ ## Publish Behavior
1507
+
1508
+ **{{publishBehavior}}**
1509
+ {{/if}}
1510
+
1493
1511
  {{#if hasFields}}
1494
1512
  {{ heading fields.headingLevel fields.heading }}
1495
1513
  {{#each fields.value}}
@@ -2265,12 +2283,17 @@ var __spreadValues$9 = (a, b) => {
2265
2283
  return a;
2266
2284
  };
2267
2285
  var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
2268
- function reflectCustomFieldsAndObjectsAndMetadataRecords(objectBundles) {
2286
+ function reflectCustomFieldsAndObjectsAndMetadataRecords(objectBundles, visibilitiesToDocument) {
2269
2287
  function filterNonPublished(parsedFiles) {
2270
2288
  return parsedFiles.filter((parsedFile) => parsedFile.type.deploymentStatus === "Deployed");
2271
2289
  }
2272
- function filterNonPublic(parsedFiles) {
2273
- return parsedFiles.filter((parsedFile) => parsedFile.type.visibility === "Public");
2290
+ function filter(parsedFiles) {
2291
+ function shouldBeDocumented(parsedFile) {
2292
+ return visibilitiesToDocument.includes(parsedFile.type.visibility.toLowerCase());
2293
+ }
2294
+ const objectsToDocument = parsedFiles.filter(shouldBeDocumented);
2295
+ const objectsToIgnore = parsedFiles.filter((parsedFile) => !shouldBeDocumented(parsedFile)).map((parsedFile) => parsedFile.type.name);
2296
+ return [objectsToDocument, objectsToIgnore];
2274
2297
  }
2275
2298
  const customObjects = objectBundles.filter(
2276
2299
  (object) => object.type === "customobject"
@@ -2291,12 +2314,12 @@ function reflectCustomFieldsAndObjectsAndMetadataRecords(objectBundles) {
2291
2314
  customObjects,
2292
2315
  reflectCustomObjectSources,
2293
2316
  TE__namespace.map(filterNonPublished),
2294
- TE__namespace.map(filterNonPublic),
2295
- TE__namespace.bindTo("objects"),
2317
+ TE__namespace.map(filter),
2318
+ TE__namespace.bindTo("filterResult"),
2296
2319
  TE__namespace.bind("fields", () => generateForFields(customFields)),
2297
2320
  TE__namespace.bind("metadata", () => generateForMetadata(customMetadata)),
2298
- TE__namespace.map(({ objects, fields, metadata }) => {
2299
- return [...mapFieldsAndMetadata(objects, fields, metadata), ...mapExtensionFields(objects, fields)];
2321
+ TE__namespace.map(({ filterResult, fields, metadata }) => {
2322
+ return [...mapFieldsAndMetadata(filterResult[0], fields, metadata), ...mapExtensionFields(filterResult, fields)];
2300
2323
  })
2301
2324
  );
2302
2325
  }
@@ -2312,9 +2335,11 @@ function mapFieldsAndMetadata(objects, fields, metadata) {
2312
2335
  });
2313
2336
  });
2314
2337
  }
2315
- function mapExtensionFields(objects, fields) {
2338
+ function mapExtensionFields(filterResult, fields) {
2339
+ const objects = filterResult[0];
2340
+ const ignoredObjectNames = filterResult[1];
2316
2341
  const extensionFields = fields.filter(
2317
- (field) => !objects.some((object) => object.type.name === field.type.parentName)
2342
+ (field) => !objects.some((object) => object.type.name.toLowerCase() === field.type.parentName.toLowerCase()) && !ignoredObjectNames.map((name) => name.toLowerCase()).includes(field.type.parentName.toLowerCase())
2318
2343
  );
2319
2344
  const extensionFieldsByParent = extensionFields.reduce(
2320
2345
  (acc, field) => {
@@ -2413,7 +2438,10 @@ function generateDocs(unparsedBundles, config) {
2413
2438
  generateForApex(filterApexSourceFiles(unparsedBundles), config),
2414
2439
  TE__namespace.chain((parsedApexFiles) => {
2415
2440
  return _function.pipe(
2416
- reflectCustomFieldsAndObjectsAndMetadataRecords(filterCustomObjectsFieldsAndMetadataRecords(unparsedBundles)),
2441
+ reflectCustomFieldsAndObjectsAndMetadataRecords(
2442
+ filterCustomObjectsFieldsAndMetadataRecords(unparsedBundles),
2443
+ config.customObjectVisibility
2444
+ ),
2417
2445
  TE__namespace.map((parsedObjectFiles) => [...parsedApexFiles, ...parsedObjectFiles])
2418
2446
  );
2419
2447
  }),
@@ -4234,7 +4262,10 @@ function reflect(bundles, config) {
4234
4262
  reflectApexFiles(filterApexSourceFiles(bundles)),
4235
4263
  TE__namespace.chain((parsedApexFiles) => {
4236
4264
  return _function.pipe(
4237
- reflectCustomFieldsAndObjectsAndMetadataRecords(filterCustomObjectsFieldsAndMetadataRecords(bundles)),
4265
+ reflectCustomFieldsAndObjectsAndMetadataRecords(
4266
+ filterCustomObjectsFieldsAndMetadataRecords(bundles),
4267
+ config.customObjectVisibility
4268
+ ),
4238
4269
  TE__namespace.map((parsedObjectFiles) => [...parsedApexFiles, ...parsedObjectFiles])
4239
4270
  );
4240
4271
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cparra/apexdocs",
3
- "version": "3.8.0",
3
+ "version": "3.9.0",
4
4
  "description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
5
5
  "keywords": [
6
6
  "apex",
@@ -19,14 +19,46 @@
19
19
  "apexdocs": "./dist/cli/generate.js"
20
20
  },
21
21
  "scripts": {
22
- "test": "npm run build && jest",
22
+ "test": "wireit",
23
23
  "test:cov": "npm run build && jest --coverage",
24
- "build": "rimraf ./dist && npm run lint && tsc --noEmit && pkgroll",
25
- "lint": "eslint \"./src/**/*.{js,ts}\" --quiet --fix",
24
+ "build": "wireit",
25
+ "lint": "wireit",
26
26
  "prepare": "npm run build",
27
27
  "version": "npm run format && git add -A src",
28
28
  "postversion": "git push && git push --tags"
29
29
  },
30
+ "wireit": {
31
+ "lint": {
32
+ "command": "eslint \"./src/**/*.{js,ts}\" --quiet --fix",
33
+ "files": [
34
+ "src/**/*.ts"
35
+ ],
36
+ "output": []
37
+ },
38
+ "build": {
39
+ "command": "tsc --noEmit --pretty && pkgroll",
40
+ "dependencies": [
41
+ "lint"
42
+ ],
43
+ "files": [
44
+ "src/**/*.ts",
45
+ "tsconfig.json"
46
+ ],
47
+ "output": [
48
+ "dist"
49
+ ]
50
+ },
51
+ "test": {
52
+ "command": "jest",
53
+ "dependencies": [
54
+ "build"
55
+ ],
56
+ "files": [
57
+ "src/**/*.ts"
58
+ ],
59
+ "output": []
60
+ }
61
+ },
30
62
  "author": "Cesar Parra",
31
63
  "license": "MIT",
32
64
  "repository": {
@@ -45,10 +77,10 @@
45
77
  "lint-staged": "^15.2.7",
46
78
  "pkgroll": "^2.4.2",
47
79
  "prettier": "^3.3.2",
48
- "rimraf": "^6.0.1",
49
80
  "ts-jest": "^29.2.0",
50
- "typescript": "^5.5.3",
51
- "typescript-eslint": "^7.16.0"
81
+ "typescript": "^5.7.3",
82
+ "typescript-eslint": "^7.16.0",
83
+ "wireit": "^0.14.10"
52
84
  },
53
85
  "husky": {
54
86
  "hooks": {