Skip to content

Commit

Permalink
feat: update jsforce typings
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Bergman committed Dec 12, 2018
1 parent 2756784 commit 374b8fc
Show file tree
Hide file tree
Showing 4 changed files with 245 additions and 184 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"docs": "yarn sfdx-docs",
"format": "yarn sfdx-format",
"lint": "yarn sfdx-lint",
"lint-fix": "yarn sfdx-lint --fix",
"postcompile": "tsc -p test; tsc -p typedocExamples",
"prepack": "yarn sfdx-build",
"test": "yarn sfdx-test"
Expand Down Expand Up @@ -39,17 +40,17 @@
"@salesforce/kit": "0.13.3",
"@salesforce/ts-sinon": "0.2.7",
"@salesforce/ts-types": "0.19.3",
"@types/jsforce": "1.8.12",
"@types/jsforce": "1.9.2",
"bunyan-sfdx-no-dtrace": "1.8.2",
"debug": "^3.1.0",
"jsen": "0.6.6",
"jsforce": "1.8.4",
"jsforce": "1.9.1",
"jsonwebtoken": "7.0.0",
"mkdirp": "0.5.1",
"sfdx-faye": "^1.0.9"
},
"devDependencies": {
"@salesforce/dev-scripts": "0.3.7",
"@salesforce/dev-scripts": "0.3.9",
"@types/debug": "0.0.30",
"@types/jsen": "0.0.19",
"@types/jsonwebtoken": "7.2.8",
Expand Down
4 changes: 2 additions & 2 deletions src/keyChainImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,13 +503,13 @@ export class GenericKeychainAccess implements PasswordStore {
// file not found
if (fileAccessError.code === 'ENOENT') {
// create the file
_writeFile.call(this, opts, fn);
await _writeFile.call(this, opts, fn);
} else {
fn(fileAccessError);
}
} else {
// the existing file validated. we can write the updated key
_writeFile.call(this, opts, fn);
await _writeFile.call(this, opts, fn);
}
});
}
Expand Down
38 changes: 17 additions & 21 deletions src/permissionSetAssignment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

import { mapKeys, upperFirst } from '@salesforce/kit';
import { getString, Optional } from '@salesforce/ts-types';
import { ErrorResult, QueryResult, RecordResult, SuccessResult } from 'jsforce';
import { getString, hasArray, Optional } from '@salesforce/ts-types';
import { QueryResult, RecordResult } from 'jsforce';
import { EOL } from 'os';
import { Logger } from './logger';
import { Messages } from './messages';
Expand Down Expand Up @@ -95,33 +95,29 @@ export class PermissionSetAssignment {
permissionSetId
};

let createResponse: SuccessResult | ErrorResult | RecordResult[];
let createResponse: RecordResult;

createResponse = await this.org
.getConnection()
.sobject('PermissionSetAssignment')
.create(mapKeys(assignment, (value: unknown, key: string) => upperFirst(key)));

if ((createResponse as RecordResult[]).length) {
throw SfdxError.create('@salesforce/core', 'permissionSetAssignment', 'unexpectedType');
} else {
if ((createResponse as SuccessResult).success) {
return assignment;
if (hasArray(createResponse, 'errors')) {
const messages: Messages = Messages.loadMessages('@salesforce/core', 'permissionSetAssignment');
let message = messages.getMessage('errorsEncounteredCreatingAssignment');

const errors = createResponse.errors;
if (errors && errors.length > 0) {
message = `${message}:${EOL}`;
errors.forEach(_message => {
message = `${message}${_message}${EOL}`;
});
throw new SfdxError(message, 'errorsEncounteredCreatingAssignment');
} else {
const messages: Messages = Messages.loadMessages('@salesforce/core', 'permissionSetAssignment');
let message = messages.getMessage('errorsEncounteredCreatingAssignment');

const errors = (createResponse as ErrorResult).errors;
if (errors && errors.length > 0) {
message = `${message}:${EOL}`;
errors.forEach(_message => {
message = `${message}${_message}${EOL}`;
});
throw new SfdxError(message, 'errorsEncounteredCreatingAssignment');
} else {
throw SfdxError.create('@salesforce/core', 'permissionSetAssignment', 'notSuccessfulButNoErrorsReported');
}
throw SfdxError.create('@salesforce/core', 'permissionSetAssignment', 'notSuccessfulButNoErrorsReported');
}
} else {
return assignment;
}
}

Expand Down
Loading

0 comments on commit 374b8fc

Please sign in to comment.