@jd-data-limited/easy-fm 0.0.1
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/.idea/easy-fm.iml +8 -0
- package/.idea/jsLibraryMappings.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/LICENSE +21 -0
- package/README.md +64 -0
- package/decs.d.ts +4 -0
- package/fmErrors.json +1010 -0
- package/img.png +0 -0
- package/index.js +455 -0
- package/index.ts +533 -0
- package/package.json +34 -0
- package/tsconfig.json +8 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$" />
|
|
5
|
+
<orderEntry type="inheritedJdk" />
|
|
6
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
7
|
+
</component>
|
|
8
|
+
</module>
|
package/.idea/vcs.xml
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 JD-Data-Limited
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# easy-fm
|
|
2
|
+
|
|
3
|
+
easy-fm is a Node.js module that allows you to interact with
|
|
4
|
+
a [FileMaker database stored](https://www.claris.com/filemaker/) on
|
|
5
|
+
a [FileMaker server](https://www.claris.com/filemaker/server/). This module interacts with your server using the
|
|
6
|
+
[FileMaker Data API](https://help.claris.com/en/data-api-guide/content/index.html).
|
|
7
|
+
|
|
8
|
+
## FileMaker setup instructions
|
|
9
|
+
|
|
10
|
+
1. Enable the FileMaker Data API from the server's admin console. This setting is located
|
|
11
|
+
in `Connectors > FileMaker Data API`.
|
|
12
|
+
2. Create a FileMaker database account for easy-fm to use. This account must have the 'Access via FileMaker Data API (
|
|
13
|
+
fmrest)' extended privilege
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## Usage examples
|
|
17
|
+
|
|
18
|
+
1. Get the first record on the 'table1' layout
|
|
19
|
+
```javascript
|
|
20
|
+
import fm, {FMError} from "easy-fm"; // Import the module
|
|
21
|
+
const connection = new fm(); // This variable will be used for interacting with the server
|
|
22
|
+
|
|
23
|
+
connection.login(hostname, database, username, password).then(async token => { // Login
|
|
24
|
+
let layout = connection.getLayout("layout1")
|
|
25
|
+
let record = layout.getRecord(1)
|
|
26
|
+
await record.get() // Fetch the data for that record
|
|
27
|
+
console.log(record)
|
|
28
|
+
})
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
2. Get all related portal records
|
|
32
|
+
```javascript
|
|
33
|
+
await record.get() // Fetch the record's data
|
|
34
|
+
let portal = record.getPortal("portal1") // 'portal1' should be the name you assigned the portal object, when creating the layout
|
|
35
|
+
console.log(portal.records)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
3. Run a script
|
|
39
|
+
```javascript
|
|
40
|
+
let script = connection.script("script_name", "this is a parameter") // Create a new script object using the script name and parameter (optional)
|
|
41
|
+
|
|
42
|
+
// Get the layout we want to run the script on
|
|
43
|
+
let layout = connection.getLayout("layout1")
|
|
44
|
+
|
|
45
|
+
// Run the script on the layout
|
|
46
|
+
let result = await layout.runScript(script)
|
|
47
|
+
console.log(result)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
4. Perform a find
|
|
51
|
+
```javascript
|
|
52
|
+
let find = layout.newFind() // Create a new find operation
|
|
53
|
+
|
|
54
|
+
find.addRequests( // Specify the find criteria
|
|
55
|
+
{"PrimaryKey": "AAAAA", "ModifiedBy": "BBBB"},
|
|
56
|
+
{"CreatedBy": "BBBB"}
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
find.addSort("CratedBy", "ascend") // Sort the results in ascending order
|
|
60
|
+
let records = await find.find() // Perform the find
|
|
61
|
+
console.log(records)
|
|
62
|
+
```
|
|
63
|
+
This is the same as the following find request in FileMaker:
|
|
64
|
+

|
package/decs.d.ts
ADDED