@salesforce/afv-skills 1.12.0 → 1.14.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/package.json +3 -3
- package/skills/building-mobile-apps/SKILL.md +70 -0
- package/skills/building-ui-bundle-app/SKILL.md +33 -8
- package/skills/generating-custom-application/SKILL.md +1 -1
- package/skills/generating-ui-bundle-custom-app/SKILL.md +93 -0
- package/skills/generating-ui-bundle-custom-app/docs/configure-metadata-custom-application.md +70 -0
- package/skills/generating-ui-bundle-metadata/SKILL.md +39 -1
- package/skills/reviewing-lwc-mobile-offline/SKILL.md +168 -0
- package/skills/reviewing-lwc-mobile-offline/references/grounding.md +7 -0
- package/skills/reviewing-lwc-mobile-offline/references/inline-graphql.md +43 -0
- package/skills/reviewing-lwc-mobile-offline/references/komaci-eslint.md +125 -0
- package/skills/reviewing-lwc-mobile-offline/references/lwc-if.md +78 -0
- package/skills/reviewing-lwc-mobile-offline/scripts/komaci.config.mjs +18 -0
- package/skills/reviewing-lwc-mobile-offline/scripts/package.json +10 -0
- package/skills/reviewing-lwc-mobile-offline/scripts/run-komaci.sh +69 -0
- package/skills/using-mobile-native-capabilities/SKILL.md +182 -0
- package/skills/using-mobile-native-capabilities/references/app-review.md +68 -0
- package/skills/using-mobile-native-capabilities/references/ar-space-capture.md +125 -0
- package/skills/using-mobile-native-capabilities/references/barcode-scanner.md +219 -0
- package/skills/using-mobile-native-capabilities/references/base-capability.md +22 -0
- package/skills/using-mobile-native-capabilities/references/biometrics.md +90 -0
- package/skills/using-mobile-native-capabilities/references/calendar.md +213 -0
- package/skills/using-mobile-native-capabilities/references/contacts.md +232 -0
- package/skills/using-mobile-native-capabilities/references/document-scanner.md +342 -0
- package/skills/using-mobile-native-capabilities/references/geofencing.md +123 -0
- package/skills/using-mobile-native-capabilities/references/location.md +158 -0
- package/skills/using-mobile-native-capabilities/references/mobile-capabilities.md +30 -0
- package/skills/using-mobile-native-capabilities/references/nfc.md +181 -0
- package/skills/using-mobile-native-capabilities/references/payments.md +95 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# Contacts Service Grounding Context
|
|
2
|
+
|
|
3
|
+
The following content provides grounding information for generating a Salesforce LWC that leverages contacts facilities on mobile devices. Specifically, this context will cover the API types and methods available to leverage the contacts API of the mobile device, within the LWC.
|
|
4
|
+
|
|
5
|
+
## Contacts Service API
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
/*
|
|
9
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
10
|
+
* All rights reserved.
|
|
11
|
+
* For full license text, see the LICENSE.txt file
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { BaseCapability } from '../BaseCapability.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Use this factory function to get an instance of {@linkcode ContactsService}.
|
|
18
|
+
* @returns An instance of {@linkcode ContactsService}.
|
|
19
|
+
*/
|
|
20
|
+
export function getContactsService(): ContactsService;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Access contacts from a Lightning web component.
|
|
24
|
+
* @see {@link https://developer.salesforce.com/docs/platform/lwc/guide/reference-lightning-contactsservice.html|ContactsService API}
|
|
25
|
+
*/
|
|
26
|
+
export interface ContactsService extends BaseCapability {
|
|
27
|
+
/**
|
|
28
|
+
* Allows the user to pick one or more contacts from the device’s Contacts app. If needed, presents a
|
|
29
|
+
* permissions pop-up to the user to request access to contacts first, and then presents the user with the contacts selector.
|
|
30
|
+
* @param options A {@linkcode ContactsServiceOptions} object to configure the {@linkcode ContactsService} request.
|
|
31
|
+
* @returns A Promise object that resolves as an array of {@linkcode Contacts} objects. If an error is encountered, the array is empty.
|
|
32
|
+
*/
|
|
33
|
+
getContacts(options?: ContactsServiceOptions): Promise<Contact[]>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Save a contact record into the mobile device address book.
|
|
37
|
+
* @param contact A {@linkcode Contacts} object.
|
|
38
|
+
* @param options A {@linkcode ContactsServiceOptions} object to configure the {@linkcode ContactsService} request. Currently
|
|
39
|
+
* used to override the device's permission UX sequence text.
|
|
40
|
+
* @returns A resolved promise returns a {@linkcode Contacts} object.
|
|
41
|
+
*/
|
|
42
|
+
putContact(contact: Contact, options?: ContactsServiceOptions): Promise<Contact>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* An object representing a contact.
|
|
47
|
+
*/
|
|
48
|
+
export interface Contact {
|
|
49
|
+
/**
|
|
50
|
+
* A stringified number unique to each contact. Generated by the native device at the time of contact creation.
|
|
51
|
+
*/
|
|
52
|
+
id: string;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* An object representing a contact's name.
|
|
56
|
+
*/
|
|
57
|
+
name: ContactName;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* An array of objects containing phone numbers for the contact.
|
|
61
|
+
*/
|
|
62
|
+
phoneNumbers: ContactLabeledValue[];
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* An array of objects containing email addresses for the contact.
|
|
66
|
+
*/
|
|
67
|
+
emails: ContactLabeledValue[];
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* An array of objects representing contact's addresses.
|
|
71
|
+
*/
|
|
72
|
+
addresses: ContactAddress[];
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* An array of objects containing instant messaging (IM) usernames for the contact.
|
|
76
|
+
*/
|
|
77
|
+
ims: ContactLabeledValue[];
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* An object representing a contact's organization.
|
|
81
|
+
*/
|
|
82
|
+
organizations: ContactOrganization[];
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* A text field for any extra information about the contact.
|
|
86
|
+
*/
|
|
87
|
+
note: string;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* An array of objects containing URLs for the contact.
|
|
91
|
+
*/
|
|
92
|
+
urls: ContactLabeledValue[];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* An object representing a contact’s address.
|
|
97
|
+
*/
|
|
98
|
+
export interface ContactAddress {
|
|
99
|
+
/**
|
|
100
|
+
* A string representing the type of address for a contact’s address.
|
|
101
|
+
*/
|
|
102
|
+
type: string;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* A string representing the street address for a contact’s address.
|
|
106
|
+
*/
|
|
107
|
+
streetAddress: string;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* A string representing the locality (also known as the “city”) for a contact’s address.
|
|
111
|
+
*/
|
|
112
|
+
locality: string;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* A string representing the region (also known as the “state” or “province”) for a contact’s address.
|
|
116
|
+
*/
|
|
117
|
+
region: string;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* A string representing the postal code for a contact’s address.
|
|
121
|
+
*/
|
|
122
|
+
postalCode: string;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* A string representing the country for a contact’s address.
|
|
126
|
+
*/
|
|
127
|
+
country: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* An object representing a contact’s organization.
|
|
132
|
+
*/
|
|
133
|
+
export interface ContactOrganization {
|
|
134
|
+
/**
|
|
135
|
+
* A string representing the name of a contact’s organization.
|
|
136
|
+
*/
|
|
137
|
+
name: string;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* A string representing the department of a contact’s organization.
|
|
141
|
+
*/
|
|
142
|
+
department: string;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* A string representing the title the contact holds in the organization.
|
|
146
|
+
*/
|
|
147
|
+
title: string;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* An object representing a contact’s name.
|
|
152
|
+
*/
|
|
153
|
+
export interface ContactName {
|
|
154
|
+
/**
|
|
155
|
+
* A string representing the contact’s family name (also known as “surname” or “last name”).
|
|
156
|
+
*/
|
|
157
|
+
familyName: string;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* A string representing the contact’s given name (also known as “first name”).
|
|
161
|
+
*/
|
|
162
|
+
givenName: string;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* A string representing the contact’s middle name.
|
|
166
|
+
*/
|
|
167
|
+
middleName: string;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* A string representing the contact’s name prefix.
|
|
171
|
+
*/
|
|
172
|
+
namePrefix: string;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* A string representing the contact’s name suffix.
|
|
176
|
+
*/
|
|
177
|
+
nameSuffix: string;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* An object containing a label and a value for a miscellaneous piece of contact information.
|
|
182
|
+
*/
|
|
183
|
+
export interface ContactLabeledValue {
|
|
184
|
+
/**
|
|
185
|
+
* The display name that categorizes the data in value. In the following examples, home, homepage, and work are label properties.
|
|
186
|
+
*/
|
|
187
|
+
label: string;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* The value of the data specified in label.
|
|
191
|
+
*/
|
|
192
|
+
value: string;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* An object representing an error that occurred when accessing {@linkcode ContactsService} features.
|
|
197
|
+
*/
|
|
198
|
+
export interface ContactsServiceFailure {
|
|
199
|
+
/**
|
|
200
|
+
* A value representing the reason for a contacts error.
|
|
201
|
+
*/
|
|
202
|
+
code: ContactsServiceFailureCode;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* A string value describing the reason for the failure. This value is suitable for use in user interface messages. The message is provided in English, and isn’t localized.
|
|
206
|
+
*/
|
|
207
|
+
message: string;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* An object representing configuration details for a {@linkcode ContactsService} session.
|
|
212
|
+
*/
|
|
213
|
+
export interface ContactsServiceOptions {
|
|
214
|
+
/**
|
|
215
|
+
* Optional parameter, used by Android only. This only appears after an initial denial by the user. To use the default permission message, pass in an empty object.
|
|
216
|
+
* The default permission message is “To import Contacts, permission is needed to access Contacts. Tap Allow in the following permissions dialog.”
|
|
217
|
+
*/
|
|
218
|
+
permissionRationaleText?: string;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Possible failure codes.
|
|
223
|
+
*/
|
|
224
|
+
export type ContactsServiceFailureCode =
|
|
225
|
+
| 'USER_DISMISSED' // The user clicked the cancel button.
|
|
226
|
+
| 'USER_DENIED_PERMISSION' // Permission was denied to access contacts (older versions of Android only).
|
|
227
|
+
| 'USER_DISABLED_PERMISSION' // Android Only - Permission was denied. User will need to go to app setting to turn on.
|
|
228
|
+
| 'USER_RESTRICTED_PERMISSION' // The application is restricted (perhaps by parental controls) from accessing Contacts (iOS only).
|
|
229
|
+
| 'SERVICE_NOT_ENABLED' // The service is not enabled and therefore cannot be used.
|
|
230
|
+
| 'SAVE_OPERATION_FAILED' // The service couldn't save the contact record into the address book.
|
|
231
|
+
| 'UNKNOWN_REASON'; // Generic error that is not captured by any of the above categories
|
|
232
|
+
```
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
# Document Scanner Service Grounding Context
|
|
2
|
+
|
|
3
|
+
The following content provides grounding information for generating a Salesforce LWC that leverages document scanning facilities on mobile devices. Specifically, this context will cover the API types and methods available to leverage the document scanner API of the mobile device, within the LWC.
|
|
4
|
+
|
|
5
|
+
## Document Scanner Service API
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
/*
|
|
9
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
10
|
+
* All rights reserved.
|
|
11
|
+
* For full license text, see the LICENSE.txt file
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { BaseCapability } from '../BaseCapability.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Use this factory function to get an instance of {@linkcode DocumentScanner}.
|
|
18
|
+
* @returns An instance of {@linkcode DocumentScanner}.
|
|
19
|
+
*/
|
|
20
|
+
export function getDocumentScanner(): DocumentScanner;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Scan documents from a Lightning web component.
|
|
24
|
+
* @see {@link https://developer.salesforce.com/docs/platform/lwc/guide/reference-lightning-documentscanner.html|DocumentScanner API}
|
|
25
|
+
*/
|
|
26
|
+
export interface DocumentScanner extends BaseCapability {
|
|
27
|
+
/**
|
|
28
|
+
* Use this function to start scanning a document.
|
|
29
|
+
* @param options A {@linkcode DocumentScannerOptions} object to configure the scanning session.
|
|
30
|
+
* @returns A Promise object that resolves to an array containing one or more {@linkcode Document} objects.
|
|
31
|
+
*/
|
|
32
|
+
scan(options?: DocumentScannerOptions): Promise<Document[]>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* An object representing a scanned document. Returned as the result of a successful scan operation.
|
|
37
|
+
*/
|
|
38
|
+
export interface Document {
|
|
39
|
+
/**
|
|
40
|
+
* A string containing the base64 image data of the scanned document. Only provided when returnImageBytes is set to true in your {@linkcode DocumentScannerOptions} configuration object.
|
|
41
|
+
*/
|
|
42
|
+
imageBytes?: string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A string value providing the recognized text from the scanned document.
|
|
46
|
+
*/
|
|
47
|
+
text: string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* An array of {@linkcode TextBlock} objects that represent a structured text result that is visually aligned with the corresponding image. See {@linkcode TextBlock} for details of this structured text data.
|
|
51
|
+
*/
|
|
52
|
+
blocks: TextBlock[];
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* An array of {@linkcode Entity} objects.
|
|
56
|
+
*/
|
|
57
|
+
entities: Entity[];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* An object representing a contiguous section of the scanned text. Text that is visually close together is grouped into a block of text.
|
|
62
|
+
* A document is made up of one to many blocks, and each block can be further broken down into smaller text elements: {@linkcode TextLine} (a single line of text in
|
|
63
|
+
* a visually aligned run of text) and {@linkcode TextElement} (an individual word or glyph).
|
|
64
|
+
*/
|
|
65
|
+
export interface TextBlock {
|
|
66
|
+
/**
|
|
67
|
+
* A string containing the text content of the block.
|
|
68
|
+
*/
|
|
69
|
+
text: string;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* An object containing the coordinates — position and size — that represent the bounding rectangle in the scanned image that contains the {@linkcode TextBlock}.
|
|
73
|
+
*/
|
|
74
|
+
frame: Frame;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* An array of Point objects that define a closed shape within the scanned image that contains the {@linkcode TextBlock}.
|
|
78
|
+
*/
|
|
79
|
+
cornerPoints: Point[];
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The BCP-47 language code values for the languages detected in the recognized text.
|
|
83
|
+
*/
|
|
84
|
+
recognizedLangCodes: string[];
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* An array of {@linkcode TextLine} objects, each of which represents a visually aligned line of text within the {@linkcode TextBlock}.
|
|
88
|
+
*/
|
|
89
|
+
lines: TextLine[];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* An object representing a single line of scanned text.
|
|
94
|
+
*/
|
|
95
|
+
export interface TextLine {
|
|
96
|
+
/**
|
|
97
|
+
* A string containing the text content of the line.
|
|
98
|
+
*/
|
|
99
|
+
text: string;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* An object containing the coordinates — position and size — that represent the bounding rectangle in the scanned image that contains the {@linkcode TextLine}.
|
|
103
|
+
*/
|
|
104
|
+
frame: Frame;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* An array of {@linkcode Point} objects that define a closed shape within the scanned image that contains the {@linkcode TextLine}.
|
|
108
|
+
*/
|
|
109
|
+
cornerPoints: Point[];
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The BCP-47 language code values for the languages detected in the recognized text.
|
|
113
|
+
*/
|
|
114
|
+
recognizedLangCodes: string[];
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* An array of {@linkcode TextElement} objects, each of which represents a word or glyph within the {@linkcode TextLine}.
|
|
118
|
+
*/
|
|
119
|
+
elements: TextElement[];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* An object representing a single word, individual character, or glyph.
|
|
124
|
+
*/
|
|
125
|
+
export interface TextElement {
|
|
126
|
+
/**
|
|
127
|
+
* A string containing the text content of the word or character.
|
|
128
|
+
*/
|
|
129
|
+
text: string;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* An object containing the coordinates — position and size — that represent the bounding rectangle in the scanned image that contains the {@linkcode TextElement}.
|
|
133
|
+
*/
|
|
134
|
+
frame: Frame;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* An array of {@linkcode Point} objects that define a closed shape within the scanned image that contains the {@linkcode TextElement}.
|
|
138
|
+
*/
|
|
139
|
+
cornerPoints: Point[];
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The BCP-47 language code values for the languages detected in the recognized text.
|
|
143
|
+
*/
|
|
144
|
+
recognizedLangCodes: string[];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* An object representing a bounding rectangle. When used in {@linkcode DocumentScanner}, the Frame is the smallest that fully encloses a region of scanned text for a {@linkcode TextBlock}, {@linkcode TextLine}, or {@linkcode TextElement}.
|
|
149
|
+
*/
|
|
150
|
+
export interface Frame {
|
|
151
|
+
/**
|
|
152
|
+
* The X coordinate of the top-left of the rectangle, in pixels, within the coordinate system of the scanned image.
|
|
153
|
+
*/
|
|
154
|
+
x: number;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The Y coordinate of the top-left of the rectangle, in pixels, within the coordinate system of the scanned image.
|
|
158
|
+
*/
|
|
159
|
+
y: number;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* The width of the rectangle, in pixels.
|
|
163
|
+
*/
|
|
164
|
+
width: number;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The height of the rectangle, in pixels.
|
|
168
|
+
*/
|
|
169
|
+
height: number;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* An object representing a point in a coordinate system.
|
|
174
|
+
*/
|
|
175
|
+
export interface Point {
|
|
176
|
+
/**
|
|
177
|
+
* The X coordinate of the point.
|
|
178
|
+
*/
|
|
179
|
+
x: number;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* The Y coordinate of the point.
|
|
183
|
+
*/
|
|
184
|
+
y: number;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Entity interface.
|
|
189
|
+
*/
|
|
190
|
+
export interface Entity {
|
|
191
|
+
type: EntityType;
|
|
192
|
+
value: string;
|
|
193
|
+
dateTimeEntity?: DateTimeEntity;
|
|
194
|
+
flightNumberEntity?: FlightNumberEntity;
|
|
195
|
+
ibanEntity?: IBANEntity;
|
|
196
|
+
moneyEntity?: MoneyEntity;
|
|
197
|
+
paymentCardEntity?: PaymentCardEntity;
|
|
198
|
+
trackingNumberEntity?: TrackingNumberEntity;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* EntityType values.
|
|
203
|
+
*/
|
|
204
|
+
export type EntityType =
|
|
205
|
+
| 'ADDRESS'
|
|
206
|
+
| 'DATETIME'
|
|
207
|
+
| 'EMAIL'
|
|
208
|
+
| 'FLIGHTNUMBER'
|
|
209
|
+
| 'IBAN'
|
|
210
|
+
| 'ISBN'
|
|
211
|
+
| 'MONEY'
|
|
212
|
+
| 'PAYMENTCARD'
|
|
213
|
+
| 'PHONE'
|
|
214
|
+
| 'TRACKINGNUMBER'
|
|
215
|
+
| 'URL';
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* DateTimeEntity interface.
|
|
219
|
+
*/
|
|
220
|
+
export interface DateTimeEntity {
|
|
221
|
+
secondsUTC: number;
|
|
222
|
+
granularity: string;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* FlightNumberEntity interface.
|
|
227
|
+
*/
|
|
228
|
+
export interface FlightNumberEntity {
|
|
229
|
+
airlineCode: string;
|
|
230
|
+
flightNumber: string;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* IBANEntity interface.
|
|
235
|
+
*/
|
|
236
|
+
export interface IBANEntity {
|
|
237
|
+
countryCode: string;
|
|
238
|
+
iban: string;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* MoneyEntity interface.
|
|
243
|
+
*/
|
|
244
|
+
export interface MoneyEntity {
|
|
245
|
+
unnormalizedCurrency: string;
|
|
246
|
+
integerPart: number;
|
|
247
|
+
fractionalPart: number;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* PaymentCardEntity interface.
|
|
252
|
+
*/
|
|
253
|
+
export interface PaymentCardEntity {
|
|
254
|
+
network: string;
|
|
255
|
+
cardNumber: string;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* TrackingNumberEntity interface.
|
|
260
|
+
*/
|
|
261
|
+
export interface TrackingNumberEntity {
|
|
262
|
+
carrier: string;
|
|
263
|
+
trackingNumber: string;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* DocumentScannerSource values.
|
|
268
|
+
*/
|
|
269
|
+
export type DocumentScannerSource = 'INPUT_IMAGE' | 'PHOTO_LIBRARY' | 'DEVICE_CAMERA';
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Script values.
|
|
273
|
+
*/
|
|
274
|
+
export type Script = 'CHINESE' | 'DEVANAGARI' | 'JAPANESE' | 'KOREAN' | 'LATIN';
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* An object containing configuration details for a document scanning session.
|
|
278
|
+
*/
|
|
279
|
+
export interface DocumentScannerOptions {
|
|
280
|
+
/**
|
|
281
|
+
* Optional, and only for Android implementations. The text shown in the UI when the device prompts the user to grant permission for your app to use the camera.
|
|
282
|
+
*/
|
|
283
|
+
permissionRationaleText?: string;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Optional. Specifies the source of the document to be scanned. Defaults to "DEVICE_CAMERA".
|
|
287
|
+
*/
|
|
288
|
+
imageSource?: DocumentScannerSource;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Optional. Specifies the language writing system of the text to be scanned. Defaults to "LATIN".
|
|
292
|
+
*/
|
|
293
|
+
scriptHint?: Script;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Defaults to FALSE when omitted.
|
|
297
|
+
*/
|
|
298
|
+
extractEntities?: boolean;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Defaults to EN when omitted.
|
|
302
|
+
*/
|
|
303
|
+
entityExtractionLanguageCode?: string;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Optional. Specifies whether the image data should (true) or should not (false) be returned by the plugin. Defaults to false. This setting is overridden and set to false when imageSource is set to “INPUT_IMAGE”.
|
|
307
|
+
*/
|
|
308
|
+
returnImageBytes?: boolean;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Optional. A stringified array of base64 image data to be scanned. Used when imageSource is set to "INPUT_IMAGE".
|
|
312
|
+
*/
|
|
313
|
+
inputImageBytes?: string[];
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* An object representing an error that occurred when accessing {@linkcode DocumentScanner} features.
|
|
318
|
+
*/
|
|
319
|
+
export interface DocumentScannerFailure {
|
|
320
|
+
/**
|
|
321
|
+
* A value representing the reason for a document scanner error. See {@linkcode DocumentScannerFailureCode} for the list of possible values.
|
|
322
|
+
*/
|
|
323
|
+
code: DocumentScannerFailureCode;
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* A string value describing the reason for the failure. This value is suitable for use in user interface messages. The message is provided in English and isn’t localized.
|
|
327
|
+
*/
|
|
328
|
+
message: string;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Correlates with the code property on the {@linkcode DocumentScannerFailure} object.
|
|
333
|
+
*/
|
|
334
|
+
export type DocumentScannerFailureCode =
|
|
335
|
+
| 'USER_DISMISSED' // User dismissed the scanner.
|
|
336
|
+
| 'USER_DENIED_CAMERA_PERMISSION' // A user denied permission to access the device camera when prompted.
|
|
337
|
+
| 'USER_DENIED_PHOTO_LIBRARY_PERMISSION' // A user denied permission to access the device photo library when prompted.
|
|
338
|
+
| 'NO_SUPPORTED_CAMERA' // The device doesn’t have a supported camera.
|
|
339
|
+
| 'INVALID_INPUT_IMAGE' // The input image data can’t be read as an image.
|
|
340
|
+
| 'SERVICE_NOT_ENABLED' // DocumentScanner is not enabled and cannot be used.
|
|
341
|
+
| 'UNKNOWN_REASON'; // An error occurred in the native code that isn’t related to permissions or hardware issues. More information is provided in the DocumentScannerFailure message.
|
|
342
|
+
```
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Geofencing Service Grounding Context
|
|
2
|
+
|
|
3
|
+
The following content provides grounding information for generating a Salesforce LWC that leverages geofencing facilities on mobile devices. Specifically, this context will cover the API types and methods available to leverage the geofencing API of the mobile device, within the LWC.
|
|
4
|
+
|
|
5
|
+
## Geofencing Service API
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
/*
|
|
9
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
10
|
+
* All rights reserved.
|
|
11
|
+
* For full license text, see the LICENSE.txt file
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { BaseCapability } from '../BaseCapability.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Use this factory function to get an instance of {@linkcode GeofencingService}.
|
|
18
|
+
* @returns An instance of {@linkcode GeofencingService}.
|
|
19
|
+
*/
|
|
20
|
+
export function getGeofencingService(): GeofencingService;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Create and monitor geofences in a Lightning web component.
|
|
24
|
+
* @see {@link https://developer.salesforce.com/docs/platform/lwc/guide/reference-lightning-geofencingservice.html|GeofencingService API}
|
|
25
|
+
*/
|
|
26
|
+
export interface GeofencingService extends BaseCapability {
|
|
27
|
+
/**
|
|
28
|
+
* Starts geofence monitoring.
|
|
29
|
+
* @param geofence A {@linkcode Geofencing} object to monitor.
|
|
30
|
+
* @returns A Promise object that resolves as a string value. The value is a unique ID that’s assigned to the monitored geofence.
|
|
31
|
+
*/
|
|
32
|
+
startMonitoringGeofence(geofence: Geofence): Promise<string>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Stop monitoring a specific geofence.
|
|
36
|
+
* @param id Unique ID assigned to a specific geofence.
|
|
37
|
+
* @returns A Promise object that resolves as null.
|
|
38
|
+
*/
|
|
39
|
+
stopMonitoringGeofence(id: string): Promise<null>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Stop monitoring all geofences.
|
|
43
|
+
* @returns A Promise object that resolves as null.
|
|
44
|
+
*/
|
|
45
|
+
stopMonitoringAllGeofences(): Promise<null>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Get all IDs of monitored geofences.
|
|
49
|
+
* @returns A Promise object that resolves as an array of string values. The values are unique IDs assigned to monitored geofences.
|
|
50
|
+
*/
|
|
51
|
+
getMonitoredGeofences(): Promise<string[]>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* An object representing an error that occurred when accessing {@linkcode GeofencingService} features.
|
|
56
|
+
*/
|
|
57
|
+
export interface GeofencingServiceFailure {
|
|
58
|
+
/**
|
|
59
|
+
* A value representing the reason for a location error.
|
|
60
|
+
*/
|
|
61
|
+
code: GeofencingServiceFailureCode;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A string value explaining the reason for the failure. This value is
|
|
65
|
+
* suitable for use in user interface messages. The message is provided in English and isn’t localized.
|
|
66
|
+
*/
|
|
67
|
+
message: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Possible failure codes.
|
|
72
|
+
*/
|
|
73
|
+
export type GeofencingServiceFailureCode =
|
|
74
|
+
| 'LOCATION_SERVICE_DISABLED' // Android Only: The location service is disabled on the device, not just for this app.
|
|
75
|
+
| 'USER_DENIED_PERMISSION' // Permission was denied by user when prompt, could ask again
|
|
76
|
+
| 'USER_DISABLED_PERMISSION' // Android: permission was denied along "don't ask again" when prompt, will need to go app setting to turn on. iOS: permission was disabled by the user and will need to be turned on in settings
|
|
77
|
+
| 'UNAVAILABLE_ON_HARDWARE' // Geofence monitoring not available on the hardware.
|
|
78
|
+
| 'MAX_GEOFENCE_MONITORED_REACHED' // The maximum number of geofences that can be monitored by the OS has been reached.
|
|
79
|
+
| 'INVALID_LATITUDE' // The range of latitude for a geofence is -90...90
|
|
80
|
+
| 'INVALID_LONGITUDE' // The range of longitude for a geofence is -180...180
|
|
81
|
+
| 'SERVICE_NOT_ENABLED' // The service is not enabled and therefore cannot be used.
|
|
82
|
+
| 'UNKNOWN_REASON'; // An error happened in the Native Code that is not permission based. Will give more information in the GeofencingServiceFailure message.
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* An object representing the coordinates and radius of the geofence region.
|
|
86
|
+
*/
|
|
87
|
+
export interface Geofence {
|
|
88
|
+
/**
|
|
89
|
+
* The latitude, in degrees. Ranges from -90 to 90.
|
|
90
|
+
*/
|
|
91
|
+
latitude: number;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The longitude, in degrees. Ranges from -180 to 180.
|
|
95
|
+
*/
|
|
96
|
+
longitude: number;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The radius of the geofence in meters.
|
|
100
|
+
*/
|
|
101
|
+
radius: number;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Monitors the entry into the geofence radius. Defaults to true.
|
|
105
|
+
*/
|
|
106
|
+
notifyOnEntry: boolean;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Monitors the exit out of the geofence radius. Defaults to true.
|
|
110
|
+
*/
|
|
111
|
+
notifyOnExit: boolean;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Notification triggered by a geofence event.
|
|
115
|
+
*/
|
|
116
|
+
message: string;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Removes geofence after it’s triggered. Defaults to true.
|
|
120
|
+
*/
|
|
121
|
+
triggerOnce: boolean;
|
|
122
|
+
}
|
|
123
|
+
```
|