@salesforce/lds-adapters-apex 0.1.0-dev1
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/LICENSE.txt +82 -0
- package/dist/es/es2018/apex-service.js +642 -0
- package/dist/es/es2018/types/src/generated/adapters/adapter-utils.d.ts +62 -0
- package/dist/es/es2018/types/src/generated/resources/getByApexMethodAndApexClass.d.ts +16 -0
- package/dist/es/es2018/types/src/generated/resources/postByApexMethodAndApexClass.d.ts +14 -0
- package/dist/es/es2018/types/src/generated/types/ApexMethodExecuteErrorResponse.d.ts +29 -0
- package/dist/es/es2018/types/src/generated/types/ApexMethodExecuteRequest.d.ts +25 -0
- package/dist/es/es2018/types/src/generated/types/type-utils.d.ts +32 -0
- package/dist/es/es2018/types/src/lds-apex-static-utils.d.ts +8 -0
- package/dist/es/es2018/types/src/main.d.ts +5 -0
- package/dist/es/es2018/types/src/predictive-loading/index.d.ts +1 -0
- package/dist/es/es2018/types/src/predictive-loading/registry.d.ts +8 -0
- package/dist/es/es2018/types/src/sfdc.d.ts +23 -0
- package/dist/es/es2018/types/src/types.d.ts +10 -0
- package/dist/es/es2018/types/src/util/language.d.ts +19 -0
- package/dist/es/es2018/types/src/util/shared.d.ts +39 -0
- package/dist/es/es2018/types/src/util/utils.d.ts +26 -0
- package/dist/es/es2018/types/src/wire/getApex/index.d.ts +14 -0
- package/dist/es/es2018/types/src/wire/postApex/index.d.ts +14 -0
- package/package.json +63 -0
- package/sfdc/index.d.ts +1 -0
- package/sfdc/index.js +689 -0
- package/sfdc/lds-apex-static-utils.js +63 -0
- package/src/raml/api.raml +139 -0
- package/src/raml/luvio.raml +7 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const { hasOwnProperty } = Object.prototype;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns the field API name, qualified with an object name if possible.
|
|
5
|
+
* @param value The value from which to get the qualified field API name.
|
|
6
|
+
* @return The qualified field API name.
|
|
7
|
+
*/
|
|
8
|
+
function getFieldApiName(value) {
|
|
9
|
+
if (typeof value === 'string') {
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
else if (value &&
|
|
13
|
+
typeof value.objectApiName === 'string' &&
|
|
14
|
+
typeof value.fieldApiName === 'string') {
|
|
15
|
+
return value.objectApiName + '.' + value.fieldApiName;
|
|
16
|
+
}
|
|
17
|
+
throw new TypeError('Value is not a string or FieldId.');
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Split the object API name and field API name from a qualified field name.
|
|
21
|
+
* Eg: Opportunity.Title returns ['Opportunity', 'Title']
|
|
22
|
+
* Eg: Opportunity.Account.Name returns ['Opportunity', 'Account.Name']
|
|
23
|
+
* @param fieldApiName The qualified field name.
|
|
24
|
+
* @return The object and field API names.
|
|
25
|
+
*/
|
|
26
|
+
function splitQualifiedFieldApiName(fieldApiName) {
|
|
27
|
+
const idx = fieldApiName.indexOf('.');
|
|
28
|
+
if (idx < 1) {
|
|
29
|
+
// object api name must non-empty
|
|
30
|
+
throw new TypeError('Value does not include an object API name.');
|
|
31
|
+
}
|
|
32
|
+
return [fieldApiName.substring(0, idx), fieldApiName.substring(idx + 1)];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const { isArray: ArrayIsArray } = Array;
|
|
36
|
+
function untrustedIsObject(untrusted) {
|
|
37
|
+
return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray(untrusted) === false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Gets a field value from an Apex sObject.
|
|
42
|
+
* @param sobject The sObject holding the field.
|
|
43
|
+
* @param field The qualified API name of the field to return.
|
|
44
|
+
* @returns The field's value. If it doesn't exist, undefined is returned.
|
|
45
|
+
*/
|
|
46
|
+
function getSObjectValue(sObject, field) {
|
|
47
|
+
if (untrustedIsObject(sObject) === false) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const unqualifiedField = splitQualifiedFieldApiName(getFieldApiName(field))[1];
|
|
51
|
+
const fields = unqualifiedField.split('.');
|
|
52
|
+
let ret = sObject;
|
|
53
|
+
for (let i = 0, fieldsLength = fields.length; i < fieldsLength; i++) {
|
|
54
|
+
const nextField = fields[i];
|
|
55
|
+
if (!hasOwnProperty.call(ret, nextField)) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
ret = ret[nextField];
|
|
59
|
+
}
|
|
60
|
+
return ret;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { getSObjectValue };
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
#%RAML 1.0
|
|
2
|
+
securitySchemes:
|
|
3
|
+
OAuth:
|
|
4
|
+
type: OAuth 2.0
|
|
5
|
+
settings:
|
|
6
|
+
authorizationUri: https://login.salesforce.com/services/oauth2/authorize
|
|
7
|
+
accessTokenUri: https://login.salesforce.com/services/oauth2/token
|
|
8
|
+
authorizationGrants:
|
|
9
|
+
- authorization_code
|
|
10
|
+
describedBy:
|
|
11
|
+
responses:
|
|
12
|
+
'401':
|
|
13
|
+
description: Bad or expired token.
|
|
14
|
+
'403':
|
|
15
|
+
description: Bad OAuth request.
|
|
16
|
+
headers:
|
|
17
|
+
Authorization:
|
|
18
|
+
description: Used to send a valid OAuth 2 access token.
|
|
19
|
+
example: 00Dxx0000001gEb!AQ4AQLlMunyjVCe5qEdoFJOtZG8fiypuvjsVZMqKHZFmKgv3SEfompm3_JBzYeAEdDbvV_o5q4oxo.Ese_5jI2E1lDjDDUZ
|
|
20
|
+
type: string
|
|
21
|
+
SID Cookie:
|
|
22
|
+
type: Basic Authentication
|
|
23
|
+
describedBy:
|
|
24
|
+
headers:
|
|
25
|
+
Cookie:
|
|
26
|
+
description: sid
|
|
27
|
+
example: 00DT0000000Dpvc!AQYAQG9Ut2qLrt7dV0Jh1z.nan7W04yLGUnBiKRxp6oaDQ4B988Wh24yhtnNHB3innkFy7Sd0HTAiBRh487mZ7p1.GT7td3r
|
|
28
|
+
type: string
|
|
29
|
+
settings: {}
|
|
30
|
+
title: Apex Adapter API
|
|
31
|
+
types:
|
|
32
|
+
ApexMethodExecuteRequest:
|
|
33
|
+
description: A JSON Object representing the parameters of an apex method as name-value pairs.
|
|
34
|
+
example:
|
|
35
|
+
strict: true
|
|
36
|
+
value:
|
|
37
|
+
paramName1: paramValue1
|
|
38
|
+
paramName2: paramValue2
|
|
39
|
+
type: object
|
|
40
|
+
ApexMethodExecuteErrorResponse:
|
|
41
|
+
description: Response in case of an error.
|
|
42
|
+
properties:
|
|
43
|
+
errorMessage:
|
|
44
|
+
example: User has insufficient permissions
|
|
45
|
+
type: string
|
|
46
|
+
debugInfo?:
|
|
47
|
+
example: "Cause: system.security.NoAccessException: Current user doesn't have access to entity. Check access before calling getApiName()"
|
|
48
|
+
type: string
|
|
49
|
+
ApexClassIdentifierWithoutNamespace:
|
|
50
|
+
description: Apex non-namespaced class identifier.
|
|
51
|
+
example: GreetingController
|
|
52
|
+
type: string
|
|
53
|
+
ApexClassIdentifierWithNamespace:
|
|
54
|
+
description: Apex namespaced class identifier.
|
|
55
|
+
example: myNS__GreetingController
|
|
56
|
+
type: string
|
|
57
|
+
baseUri: /lwr/apex/v66.0
|
|
58
|
+
description: |
|
|
59
|
+
Execute @AuraEnabled Apex Method.
|
|
60
|
+
mediaType:
|
|
61
|
+
- application/json
|
|
62
|
+
version: v1
|
|
63
|
+
protocols:
|
|
64
|
+
- HTTPS
|
|
65
|
+
securedBy:
|
|
66
|
+
- OAuth
|
|
67
|
+
- SID Cookie
|
|
68
|
+
/{apexClass}/{apexMethod}:
|
|
69
|
+
post:
|
|
70
|
+
description: Invoke @AuraEnabled method on Apex Class
|
|
71
|
+
displayName: Invoke Apex Class Method (using imperative call from LWC)
|
|
72
|
+
headers:
|
|
73
|
+
X-SFDC-Allow-Continuation?:
|
|
74
|
+
example: 'true'
|
|
75
|
+
type: string
|
|
76
|
+
body:
|
|
77
|
+
application/json:
|
|
78
|
+
type: ApexMethodExecuteRequest
|
|
79
|
+
securedBy:
|
|
80
|
+
- OAuth
|
|
81
|
+
- SID Cookie
|
|
82
|
+
responses:
|
|
83
|
+
'200':
|
|
84
|
+
headers:
|
|
85
|
+
Cache-Control:
|
|
86
|
+
example: 'no-cache'
|
|
87
|
+
description: Apex Method Response
|
|
88
|
+
# empty body because the body type is any
|
|
89
|
+
'400':
|
|
90
|
+
description: Returned when there is something wrong with the request like misnamed parameters.
|
|
91
|
+
body:
|
|
92
|
+
application/json:
|
|
93
|
+
type: ApexMethodExecuteErrorResponse
|
|
94
|
+
'404':
|
|
95
|
+
description: If the apex class or method cannot be found. This can also be returned if the user does not permission to access the apex class.
|
|
96
|
+
'500':
|
|
97
|
+
description: Returned when the apex method execution results in an error.
|
|
98
|
+
body:
|
|
99
|
+
application/json:
|
|
100
|
+
type: ApexMethodExecuteErrorResponse
|
|
101
|
+
get:
|
|
102
|
+
displayName: Invoke Cacheable Apex Class Method (using @wire call from LWC)
|
|
103
|
+
description: Invoke @AuraEnabled(cacheable = true) method on Apex Class
|
|
104
|
+
headers:
|
|
105
|
+
X-SFDC-Allow-Continuation?:
|
|
106
|
+
example: 'true'
|
|
107
|
+
type: string
|
|
108
|
+
securedBy:
|
|
109
|
+
- OAuth
|
|
110
|
+
- SID Cookie
|
|
111
|
+
responses:
|
|
112
|
+
'200':
|
|
113
|
+
headers:
|
|
114
|
+
Cache-Control:
|
|
115
|
+
example: 'private max-age=30'
|
|
116
|
+
# empty body because the body type is any
|
|
117
|
+
'400':
|
|
118
|
+
description: Returned if the apex method is not cacheable or if there is something else wrong with the request like misnamed parameters.
|
|
119
|
+
body:
|
|
120
|
+
application/json:
|
|
121
|
+
type: ApexMethodExecuteErrorResponse
|
|
122
|
+
'404':
|
|
123
|
+
description: If the apex class or method cannot be found. This can also be returned if the user does not permission to access the apex class.
|
|
124
|
+
'500':
|
|
125
|
+
description: Returned when the apex method execution results in an error.
|
|
126
|
+
body:
|
|
127
|
+
application/json:
|
|
128
|
+
type: ApexMethodExecuteErrorResponse
|
|
129
|
+
queryParameters:
|
|
130
|
+
methodParams?:
|
|
131
|
+
type: ApexMethodExecuteRequest
|
|
132
|
+
uriParameters:
|
|
133
|
+
apexMethod:
|
|
134
|
+
description: Name of the Apex Method
|
|
135
|
+
example: getGreeting
|
|
136
|
+
type: string
|
|
137
|
+
apexClass:
|
|
138
|
+
description: Apex Class Name (can include a namespace prefix separated by __)
|
|
139
|
+
type: ApexClassIdentifierWithNamespace | ApexClassIdentifierWithoutNamespace
|