Skip to content

Commit 1fa746d

Browse files
committed
Initial commit.
1 parent 7ae3a1b commit 1fa746d

File tree

9 files changed

+292
-4
lines changed

9 files changed

+292
-4
lines changed

examples/vitepress/docs/.vitepress/sidebar.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@
7070
"text": "Product__c",
7171
"link": "custom-objects/Product__c.md"
7272
},
73+
{
74+
"text": "Product_Inline_Fields__c",
75+
"link": "custom-objects/Product_Inline_Fields__c.md"
76+
},
7377
{
7478
"text": "Product_Price_Component__c",
7579
"link": "custom-objects/Product_Price_Component__c.md"

examples/vitepress/docs/changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ These custom objects are new.
5151
Represents an event that people can register for.
5252
### Price_Component__c
5353

54+
### Product_Inline_Fields__c
55+
56+
Products
5457
### Product_Price_Component__c
5558

5659
### Product__c
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
title: Product_Inline_Fields__c
3+
---
4+
5+
# Products
6+
7+
Products
8+
9+
## API Name
10+
`apexdocs__Product_Inline_Fields__c`
11+
12+
## Fields
13+
### DiscontinuedDate
14+
15+
The date the product got discontinued
16+
17+
**API Name**
18+
19+
`apexdocs__DiscontinuedDate__c`
20+
21+
**Type**
22+
23+
*DateTime*
24+
25+
---
26+
### ID
27+
28+
**API Name**
29+
30+
`apexdocs__ID__c`
31+
32+
**Type**
33+
34+
*Number*
35+
36+
---
37+
### Name
38+
39+
Product name
40+
41+
**API Name**
42+
43+
`apexdocs__Name__c`
44+
45+
**Type**
46+
47+
*Text*
48+
49+
---
50+
### Price
51+
52+
Product price in the default currency
53+
54+
**API Name**
55+
56+
`apexdocs__Price__c`
57+
58+
**Type**
59+
60+
*Number*
61+
62+
---
63+
### Products
64+
65+
**API Name**
66+
67+
`apexdocs__Products__c`
68+
69+
**Type**
70+
71+
*ExternalLookup*
72+
73+
---
74+
### Rating
75+
76+
Rating
77+
78+
**API Name**
79+
80+
`apexdocs__Rating__c`
81+
82+
**Type**
83+
84+
*Number*
85+
86+
---
87+
### ReleaseDate
88+
89+
ReleaseDate
90+
91+
**API Name**
92+
93+
`apexdocs__ReleaseDate__c`
94+
95+
**Type**
96+
97+
*DateTime*

examples/vitepress/docs/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ Represents an event that people can register for.
2929

3030
Product that is sold or available for sale.
3131

32+
### [Product_Inline_Fields__c](custom-objects/Product_Inline_Fields__c)
33+
34+
Products
35+
3236
### [Product_Price_Component__c](custom-objects/Product_Price_Component__c)
3337

3438
### [Sales_Order__c](custom-objects/Sales_Order__c)
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<actionOverrides>
4+
<actionName>CancelEdit</actionName>
5+
<type>Default</type>
6+
</actionOverrides>
7+
<actionOverrides>
8+
<actionName>Delete</actionName>
9+
<type>Default</type>
10+
</actionOverrides>
11+
<actionOverrides>
12+
<actionName>Edit</actionName>
13+
<type>Default</type>
14+
</actionOverrides>
15+
<actionOverrides>
16+
<actionName>Follow</actionName>
17+
<type>Default</type>
18+
</actionOverrides>
19+
<actionOverrides>
20+
<actionName>List</actionName>
21+
<type>Default</type>
22+
</actionOverrides>
23+
<actionOverrides>
24+
<actionName>New</actionName>
25+
<type>Default</type>
26+
</actionOverrides>
27+
<actionOverrides>
28+
<actionName>SaveEdit</actionName>
29+
<type>Default</type>
30+
</actionOverrides>
31+
<actionOverrides>
32+
<actionName>Tab</actionName>
33+
<type>Default</type>
34+
</actionOverrides>
35+
<actionOverrides>
36+
<actionName>View</actionName>
37+
<type>Default</type>
38+
</actionOverrides>
39+
<deploymentStatus>Deployed</deploymentStatus>
40+
<description>Products</description>
41+
<enableFeeds>false</enableFeeds>
42+
<externalDataSource>OData</externalDataSource>
43+
<externalIndexAvailable>false</externalIndexAvailable>
44+
<externalName>Products</externalName>
45+
<fields>
46+
<fullName>DiscontinuedDate__c</fullName>
47+
<description>The date the product got discontinued</description>
48+
<externalDeveloperName>DiscontinuedDate</externalDeveloperName>
49+
<externalId>false</externalId>
50+
<isFilteringDisabled>false</isFilteringDisabled>
51+
<isNameField>false</isNameField>
52+
<isSortingDisabled>false</isSortingDisabled>
53+
<label>DiscontinuedDate</label>
54+
<required>false</required>
55+
<type>DateTime</type>
56+
</fields>
57+
<fields>
58+
<fullName>ID__c</fullName>
59+
<externalDeveloperName>ID</externalDeveloperName>
60+
<externalId>false</externalId>
61+
<isFilteringDisabled>false</isFilteringDisabled>
62+
<isNameField>false</isNameField>
63+
<isSortingDisabled>false</isSortingDisabled>
64+
<label>ID</label>
65+
<precision>18</precision>
66+
<required>false</required>
67+
<scale>0</scale>
68+
<type>Number</type>
69+
<unique>false</unique>
70+
</fields>
71+
<fields>
72+
<fullName>Name__c</fullName>
73+
<description>Product name</description>
74+
<externalDeveloperName>Name</externalDeveloperName>
75+
<externalId>false</externalId>
76+
<isFilteringDisabled>false</isFilteringDisabled>
77+
<isNameField>false</isNameField>
78+
<isSortingDisabled>false</isSortingDisabled>
79+
<label>Name</label>
80+
<length>128</length>
81+
<required>false</required>
82+
<type>Text</type>
83+
<unique>false</unique>
84+
</fields>
85+
<fields>
86+
<fullName>Price__c</fullName>
87+
<description>Product price in the default currency</description>
88+
<externalDeveloperName>Price</externalDeveloperName>
89+
<externalId>false</externalId>
90+
<isFilteringDisabled>false</isFilteringDisabled>
91+
<isNameField>false</isNameField>
92+
<isSortingDisabled>false</isSortingDisabled>
93+
<label>Price</label>
94+
<precision>16</precision>
95+
<required>false</required>
96+
<scale>2</scale>
97+
<type>Number</type>
98+
<unique>false</unique>
99+
</fields>
100+
<fields>
101+
<fullName>Products__c</fullName>
102+
<externalDeveloperName>Products</externalDeveloperName>
103+
<externalId>false</externalId>
104+
<isFilteringDisabled>false</isFilteringDisabled>
105+
<isNameField>false</isNameField>
106+
<isSortingDisabled>false</isSortingDisabled>
107+
<label>Products</label>
108+
<length>20</length>
109+
<referenceTo>Products__x</referenceTo>
110+
<relationshipLabel>Products</relationshipLabel>
111+
<relationshipName>Products</relationshipName>
112+
<type>ExternalLookup</type>
113+
</fields>
114+
<fields>
115+
<fullName>Rating__c</fullName>
116+
<description>Rating</description>
117+
<externalDeveloperName>Rating</externalDeveloperName>
118+
<externalId>false</externalId>
119+
<isFilteringDisabled>false</isFilteringDisabled>
120+
<isNameField>false</isNameField>
121+
<isSortingDisabled>false</isSortingDisabled>
122+
<label>Rating</label>
123+
<precision>18</precision>
124+
<required>false</required>
125+
<scale>0</scale>
126+
<type>Number</type>
127+
<unique>false</unique>
128+
</fields>
129+
<fields>
130+
<fullName>ReleaseDate__c</fullName>
131+
<description>ReleaseDate</description>
132+
<externalDeveloperName>ReleaseDate</externalDeveloperName>
133+
<externalId>false</externalId>
134+
<isFilteringDisabled>false</isFilteringDisabled>
135+
<isNameField>false</isNameField>
136+
<isSortingDisabled>false</isSortingDisabled>
137+
<label>ReleaseDate</label>
138+
<required>false</required>
139+
<type>DateTime</type>
140+
</fields>
141+
<label>Products</label>
142+
<pluralLabel>Products</pluralLabel>
143+
<searchLayouts>
144+
<customTabListAdditionalFields>ExternalId</customTabListAdditionalFields>
145+
<lookupDialogsAdditionalFields>ExternalId</lookupDialogsAdditionalFields>
146+
<lookupPhoneDialogsAdditionalFields>ExternalId</lookupPhoneDialogsAdditionalFields>
147+
<searchResultsAdditionalFields>ExternalId</searchResultsAdditionalFields>
148+
<searchResultsAdditionalFields>DisplayUrl</searchResultsAdditionalFields>
149+
<searchResultsAdditionalFields>ID__c</searchResultsAdditionalFields>
150+
</searchLayouts>
151+
</CustomObject>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cparra/apexdocs",
3-
"version": "3.5.0",
3+
"version": "3.5.1",
44
"description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
55
"keywords": [
66
"apex",

src/core/reflection/sobject/reflect-custom-field-source.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function toCustomFieldMetadata(parserResult: { CustomField: unknown }): CustomFi
6666
};
6767

6868
const pickListValues =
69-
hasType(customField) && customField.type?.toLowerCase() === 'picklist' ? toPickListValues(customField) : undefined;
69+
hasType(customField) && customField.type.toLowerCase() === 'picklist' ? toPickListValues(customField) : undefined;
7070
return { ...defaultValues, ...customField, type_name: 'customfield', pickListValues } as CustomFieldMetadata;
7171
}
7272

@@ -85,7 +85,7 @@ function toPickListValues(customField: object): string[] {
8585
return [];
8686
}
8787

88-
function hasType(customField: object): customField is CustomFieldMetadata {
88+
function hasType(customField: object): customField is { type: string } {
8989
return !!(customField as CustomFieldMetadata).type;
9090
}
9191

src/core/reflection/sobject/reflect-custom-object-sources.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function reflectCustomObjectSource(
3838
E.flatMap(validate),
3939
E.map(toObjectMetadata),
4040
E.map((metadata) => addName(metadata, objectSource.name)),
41+
E.map(parseInlineFields),
4142
E.map(addTypeName),
4243
E.map((metadata) => toParsedFile(objectSource.filePath, metadata)),
4344
E.mapLeft((error) => new ReflectionErrors([new ReflectionError(objectSource.filePath, error.message)])),
@@ -78,6 +79,34 @@ function addName(objectMetadata: CustomObjectMetadata, name: string): CustomObje
7879
};
7980
}
8081

82+
function parseInlineFields(metadata: CustomObjectMetadata): CustomObjectMetadata {
83+
return {
84+
...metadata,
85+
fields: metadata.fields.map((field) => convertInlineFieldsToCustomFieldMetadata(field, metadata.name)),
86+
};
87+
}
88+
89+
function convertInlineFieldsToCustomFieldMetadata(
90+
inlineField: Record<string, unknown>,
91+
parentName: string,
92+
): CustomFieldMetadata {
93+
// Based on Salesforce's documentation, the only required field is "fullName"
94+
const name = inlineField.fullName as string;
95+
const description = inlineField.description ? (inlineField.description as string) : null;
96+
const label = inlineField.label ? (inlineField.label as string) : name;
97+
const type = inlineField.type ? (inlineField.type as string) : null;
98+
99+
return {
100+
type_name: 'customfield',
101+
description,
102+
label,
103+
name,
104+
parentName,
105+
type,
106+
// TODO: Parse picklist values
107+
};
108+
}
109+
81110
function addTypeName(objectMetadata: CustomObjectMetadata): CustomObjectMetadata {
82111
return {
83112
...objectMetadata,

src/core/reflection/sobject/reflectCustomFieldsAndObjects.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function reflectCustomFieldsAndObjects(
4646
...object,
4747
type: {
4848
...object.type,
49-
fields: objectFields.map((field) => field.type),
49+
fields: [...object.type.fields, ...objectFields.map((field) => field.type)],
5050
},
5151
};
5252
});

0 commit comments

Comments
 (0)