-
Notifications
You must be signed in to change notification settings - Fork 393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: generate typings for sobjects #3018
Conversation
import { ChildRelationship, Field, SObject } from '../types'; | ||
|
||
export const MODIFIER = 'global'; | ||
export interface FieldDeclaration { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jag-sfdc The static representation could contain a list of these objects with some additional information. That's sufficient to generate apex and type files.
Codecov Report
@@ Coverage Diff @@
## develop #3018 +/- ##
========================================
Coverage 76.18% 76.18%
========================================
Files 276 276
Lines 10502 10502
Branches 1234 1234
========================================
Hits 8001 8001
Misses 2157 2157
Partials 344 344 Continue to review full report at Codecov.
|
|
||
const TYPING_PATH = ['typings', 'lwc', 'sobjects2']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't figured out how to do the transition yet. ALS will collide with this typing generation until it is disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can have a "local" variable/setting to gate this being enabled but still allow us to write tests, merge it, etc.
packages/salesforcedx-sobjects-faux-generator/src/generator/declarationGenerator.ts
Show resolved
Hide resolved
|
||
public generateTypingForObject(folderPath: string, sobject: SObject): string { | ||
const typingPath = path.join(folderPath, sobject.name + '.d.ts'); | ||
if (fs.existsSync(typingPath)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't needed as fs.writeFileSync
overwrites the file if it exists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was getting a permission error before I added this, probably since the perms were set to readonly when the previous contents were written?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, my definition files have permission 644
. Yeah it makes sense to remove first if we are writing with permission 444
.
fs.writeFileSync(fauxClassPath, this.generateFauxClassTextFromDecls(sobject.name, sobject.fields), { | ||
const fauxClassPath = path.join( | ||
standardSObjectsFolderPath, | ||
sobject.name + APEX_CLASS_EXTENSION |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sobject.name + APEX_CLASS_EXTENSION | |
`${sobject.name}${APEX_CLASS_EXTENSION}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did this change directly in GitHub so please check that it does work before merging
comment?: string; | ||
} | ||
|
||
export interface SObjectDefinition { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could move this and FieldDeclaration
to the types
folder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do,
@rcoringrato-sfdc if we merge these changes we'll be creating the lwc typings twice (here and from the Apex lang server). Are we going to add something to disable lwc typings from the faux module while we make the changes to the lang server or are we going to wait for the lang server changes before merging this PR ? |
@lcampos I added a class level flag to disable type declarations by default. As part of the story to add the updated ALS jar this flag should be removed. This should prevent the collision that you referred to. This PR could be committed separate from the ALS changes. |
Sounds good, I totally missed |
What does this PR do?
Added type generation to the sobject faux object flow.
What issues does this PR fix or reference?
@W-8912288@