Giter Club home page Giter Club logo

generator's Introduction

Logo

Generator v2.1.1

Store, explore, share and create FileMaker code

Getting Started

FileMaker 19 should work now.

  • Download or clone or this repository.
  • The prepped and current version is in the "dist" folder

The development version is in the "source" directory.

Videos

JSON API and Field Maps https://vimeo.com/190242455 https://vimeo.com/190256809

Custom Generators http://youtu.be/EnycrdIHSBQ

Storing things on Disk http://youtu.be/8-bjvfMV_Jk

A Dev Tool Toolkit

Under the hood, you will find a collection of custom functions, and techniques that making building a Dev Toolkit like this one possible. Check them out and see what you can do. We hope to inspire people to build on top of Generator and the functions it includes.

Storing Data In Text Files

A core Generator ideal is that storing this stuff as text files is ultimately better for maintaining, and sharing this type of code. To that end, the "Custom Generators" feature saves everything to disk as soon as you save edits.

The JSON API Explorer doesn't store things automatically on disk but instead makes it easy to export and import Requests.

The Field Maps feature currently doesn't have import and export, nor does store things in text. Its all in the DB. Field Maps seem less shareable, and more transient, but perhaps they should be exportable as well.

We are convinced that anything that might be shared or checked into a Version Control (like GitHub) should be in text. But it's not clear yet which approach is best, Save everything on edit, or just allow export and import. Your feedback is appreciated.

Contributing

We welcome contributions from the community. That's what this is all about.

FileMaker files don't lend themselves well to Github since we can't do merges and pull requests. That's part of what this project is trying to change. But we can still use Github for issues, comments, and planning.

If you find a bug, please include a copy of the file with a Test that shows the bug in action if you can. Its the best way to get your issues addressed. Bugs that are clearly demonstrated are easily fixed.

If you have a bug fix, please include a copy of the file with the bug fixed. And instructions on where it is.

If you have ideas, please flesh them out in a copy of the file and include it on the issue. Nothing gets an idea across like semi-functional code.

Roadmap

Multi Clip Generators and Playback

We think that people will want to create a series of generators that should be "played back" in a certain order. That way you could send somebody a package which would include all the changes that need to be made to a system. Right now this is only supported by having an "order" property in the Generator that could be used to sort all the Generators in a folder in the correct order.

What we don't have yet is a great playback experience. But we think we could get there. Perhaps with a simpler Generator player file, that sucks up a folder full of generator packages and walks a user through those steps.

We hope to get there over time. Again your feedback or examples are appreciated.

XML Editor with Find and Replace

This will have to be a web viewer app, doable but hard. And you can use text editors now since everything is on disk.

Extending Field Maps

Right now field maps are sort of coupled to the JSON API explorer. They don't need to be. We should be able to Browse open files and tables and build JSON calcs and parsing script steps.

Credits

Todd Geist created and designed Generator
Chiyoko Yoshida of chiyoFM created the Theme
Nick Orr of Goya LT provides the amazing and free Base Elements Plugin

generator's People

Contributors

toddgeist avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

generator's Issues

MymeTypes Values List Is Incorrect

name should be MimeTypes, instead of MymeTypes

application/json is missing!!! - should be entry line #1
it is a very chaotic list - maybe sort it?

Create and Map fields not working in new file

I have tested the sample files from this link and they worked.
https://www.geistinteractive.com/2018/03/13/filemaker-json-parsing-generator/.

I then downloaded the file from github to try the latest version.
However, when I tried testing Create and Map fields with the json from a different api, the script would not create the fields in a brand new file. No errors displayed. The fields were not created.
The security settings in the new file are using the same as the Generator file, Admin with no password.
Here is the API I used.
https://www.bankofcanada.ca/valet/observations/FXUSDCAD/JSON?start_date=2021-10-01&end_date=2021-11-04&order_dir=desc

I am using FileMaker 19.3.2 on windows 10.

Does the SQL command "ALTER table" not work consistently in FMP 19?

I tried creating a simple script in the new file to use the same script steps from the script, Copy Over, in the generator file, which creates the fields. I imported the custom functions from Generator and made sure the latest version of the Base Elements plugin were installed.

However this did not work either.
Is the ALTER command broken in FMP 19.3.2 on Windows or am I missing something else?

image

'New Generator' error

When creating a new Generator, after first copying a section of script steps to the clipboard, I get a popover with the following text:- 'Sorry! We couldn't find any FileMaker Object XML'

I am using Windows 7 Pro 64 bit, and FMPA 16.0.2.205

Things I have observed....

  • In the script 'On Open New Clip', clip_GetFMObjectType returns "" ($clipType is empty)
  • In the custom function clip_GetFMObjectType, the case statement seems to just cater for MAC clipboard object types.

I'm sure you guys already have this information, but just in case you don't...

From https://www.briandunning.com/cf/2010, windows clipboard object types

//Windows Formats
format = "Mac-XMFD" ; "Field" ;
format = "Mac-XMSC" ; "Script" ;
format = "Mac-XMSS" ; "Script Step" ;
format = "Mac-XML2" ; "Layout Object" ;
format = "Mac-XMFN" ; "Custom Function" ;
format = "Mac-XMTB" ; "Table" ;
format = "CF_UNICODETEXT" ; "Plain Text" ;

My level of FM knowledge isn't up to fixing this - my apologies - I have tried to add the above and tinker around with the Let statement, but I have not been successful.....

Handle URL Encoded Form Data

@rwu2359 points out we don't handle form data very well in #11

We need to add another section for FormData, just like Params. We can't use params, since that maybe used as well in the same request. We probably can't do Multi-part here.

  • add new form-data table
  • change Data tab to accommodate a new UI for setting form data
  • add new section to Save and Export
  • add new section to Restore
  • make changes to HTTP Script

Error getting XML Script Steps on Windows

Unable to utilize either function:

  • Set Var JSON From Comments
  • Parse ScriptParameter

Actual Behavior:
No data/script steps are on the clipboard

Expected Behavior
Script steps are copied to the clipboard per the copied comments

Possible Resolution

The error stems from the custom function: clip_GetFMxml

It internally performs this calculation:

Let(
[
formats = BE_ClipboardFormats;
expression = "Left( item ; 4 ) = \"dyn.\"" ;
format = FilterValuesByExpression ( formats ; expression );

xml = BE_ClipboardText ( format );
...truncated...

Apparently this works on macOS for getting the copied script parameters; however, on windows the format dyn.ah62d4rv4gk8zuxnxnq does not work and needs to be Mac-XMSS

I believe changing to this should allow things to work on both Mac and Windows

xml = BE_ClipboardText ( If(Get(Device) = 2; "Mac-XMSS"; format) );

Feature request.

When generating Set Field Scripts Steps, would you consider adding an optional variable to
JSONGetElement( $json ; "[" & $index & "]description" ) to enable the creation of a loop to easily parse JSON data with multiple records?

Code to find last HTTP Headers not working

The http header response handling is not working for this API:
httpheader

I presume that there may be multiple http-headers (due to page forwarding?) and that we are only interested in the last one ... we thus need to find the last LINE starting with "http/":

I have changed the code to set $responseHeaders =

[
s = $responseHeaders;
tag = "http/" ;
 
p = Position( "¶" & s; "¶" & tag ; Length( s ) ; -1 )
] ;
Right ( s ; Length( s ) + 1 - p )
)

…which works (and using -1 in the pos function is also more efficient)

FogBugz JSON API not handled on return

result of getting a token as per image
screen shot 2016-11-06 at 12 39 04

using
{
"name": "Fogbugz token",
"notes": "",
"request": {
"method": "POST",
"url": "https://rwu.fogbugz.com/f/api/0/jsonapi",
"query": {},
"headers": {
"Content-Type": "application/json"
},
"data": {
"cmd": "logon",
"email": "myemail",
"password": "mypassword"
}
}
}

using API kitchen the results returned are
{"data":{"token":"k4i43mp1jljkmrajnjkkl1e76a3hsb"},"errors":[],"warnings":[],"meta":{"jsdbInvalidator":"XgTKsKzswka68vt6hyndjA2","clientVersionAllowed":{"min":4,"max":4}},"errorCode":null,"maxCacheAge":null}

and headers
Access-Control-Allow-Origin: *
Content-Type: text/javascript; charset=utf-8
Connection: close
Strict-Transport-Security: max-age=15552000
Date: Sun, 06 Nov 2016 12:27:39 GMT
X-Frame-Options: SAMEORIGIN
Content-Encoding: gzip
Content-Length: 185
Cache-Control: private, max-age=0
Vary: Accept-Encoding

This issue can be fixed by changing line #130 in the HTTP script in Generator to
IF ( $contentType = "application/json" or $contentType = "text/javascript" )

Why is this section (#125--136) in the Generator script not in the script that gets copied to user files??

Pasted HTTP (requestJSON) script needs manual attention

When I pasted the script to a new file, the ¶ characters which are in the stored XML get converted to
"
"

  • a literal carriage return,
    but then the script seem to not replace the CR in this line #74 -- Substitute( $responseHeader ; ":" ; ¶ ) (this is my edited version) and as a result Trim ( GetValue ( $responseHeader ; 2 ) ) then fails

Also line #60 has the calculation commented out which it needs otherwise line #65 fails.

Work Around for order dependent API

Some older APIs still use XML under the hood. They problem is that XML validators are sensitive to element order. JSON explicitly forbids this.

The problem is that Generators use of an intermediate JSON format causes the order of properties in the JSON to change, which will cause these validators to fail.

AuthorizeNet is an example of one such API

https://community.developer.authorize.net/t5/Integration-and-Testing/JSON-API-warning-properties-are-order-dependent/m-p/55519#M30389

Native Script still uses BE function

Not the generated script but the one used by generator itself

I've spotted a small discrepancy in the HTTP Native ( {request} ) script. On line 74 the generator still calls one of the CFs that used the BaseElements plugin to created the variable Set variable [ $headersList ; Value: jsonGetKeyList ( $headers) ]. Looking earlier in the script I assume that this should be Set variable [ $headersList ; Value: JSONListKeys ( $headers ; "" ) ] to keep then entire script native to FileMaker 16.

Unable to create New Generator on Windows

Repro steps:

  1. Copy script steps from another file
  2. Go to Generator, click on New Generator

Expected

  • New generator workflow as documented.

Actual

  • Error dialog, with report that Generator did not detect any FileMaker XML objects on the clipboard.

can't build on Windows

PathFMToOS CF fails, producing an OS path like:

C:\C:\generator-master\dist\

From the FM Path:

file:/C:/generator-master/dist/

Minor Documentation update for 18

Took me a second to realize why Generator wouldn't work with a file made in 18. FileAccess is turned on automatically in 18 so you have to authorize Generator to get a list of tables, etc or turn off the requirement. Might want to mention this to save others time.

Field value list in nested Field Map displays parent fields

Just downloaded 2.0.6, testing on FMPA 16.0.3 Mac

Mapping fields for top level response works as expected
Added a nested field map for a response array, but the field value list displays fields from the parent table, not the child table...

Steps to reproduce

  1. create a new request whose response will contain a nested array
  2. create a new field map
  3. select a field and table to map the parent fields
  4. click Nested Array in the list of response fields, to create a field map
  5. select file and table to map the parent fields
  6. go back and work with the parent fields
  7. choose the child field map
  8. try to map fields

Expected result:
Field value list displays field names from child table

Actual result:
Field value list displays field names from parent table

...I got it to work by reselecting the table for the nested field map:

  1. Choose table
  2. Refresh file list and select
  3. Refresh the table list and select

In conclusion, it is possible to operate Generator 2.0.6 in an way which does not offer the correct value list contents for a nested field map. I suspect it's a missing refresh when navigating back and forth between the two maps

Script needs altering to work with Google API

For the Google API (and maybe others) the parameters set in the Params tab need to become the data in the body, and not just part of the url string

Posting to https://accounts.google.com/o/oauth2/token?client_id=x&client_secret=y&refresh_token=z&grant_type=refresh_token , with the headers of Host: accounts.google.com and Content-Type: application/x-www-form-urlencoded (which is not in the dropdown list BTW) does not work - if you manually set the $data variable to the $queryString and do not add it to the url it works...

Otherwise you get a 405 Method Not Allowed

Improper handling of $responseBody

See script: HTTP BaseElements( {request} ).

The default handling of the response body for "other" content-types (see line 162) is:

Quote ( 
   Substitute ( 
     $responseBody ; 
     [ Char ( 8 ) ; "\b" ] ;
     [ Char ( 12 ) ; "\f" ] ; 
     [ "¶" ; "\n" ] ; 
     [ Char ( 13 ) ; "\r" ] ; 
     [ Char ( 9 ) ; "\t" ]
   ) 
)`

I'm not sure when there's a valid case to return the $responseBody quoted, but at least in this case it causes problems where the content-type is text/xml.

Sample $responseBody returned from API:

<?xml version="1.0" encoding="UTF-8"?><rsp stat="ok" version="1.0"> <api_key>asdfasdfasfda</api_key></rsp>

Note: there are multiple Char(10) characters that are not visible in the text (above).

Here's what it gets converted to:

"<?xml version=\"1.0\" encoding=\"UTF-8\"?><rsp stat=\"ok\" version=\"1.0\"> <api_key>kasjf;lskdfj;asldjk</api_key></rsp>"

When this gets added to the JSON object (line 177), the result is "?", and the custom function returns the following error: "SyntaxError: eof or line terminator while parsing string literal (line 3)."

I added another test at line 161 for a content-type of text/xml, with the following code:


Substitute ( $responseBody ; 
     [ Char ( 8 ) ; "\b" ] ;
     [ Char ( 12 ) ; "\f" ] ; 
     [ "¶" ; "\n" ] ; 
     [ Char ( 13 ) ; "\r" ] ; 
     [ Char ( 10 ) ; "\r" ] ; 
     [ Char ( 9 ) ; "\t" ]
 )

Note: this is almost the same as the code above, except it doesn't quote the result and also converts line feeds (i.e., Char ( 10 )).

Using token instead of authorization?

I try to make a get request using a token instead of a user/pw.
Token is put into request header but always getting an error "?".
In postman ther request works fine. is there any easy solution?

Multiple Response Status Headers Are Ignored

Wrong Status Code

There seems to be an issue parsing the multiple status response codes from the $responseHeader variable. Generator is only grabbing the first response code in the header. If a request contains a large amount of data (1024) the 100 continue response is recorded rather than the final status code.

Here are is an example of a large request that fails to show the final response code:

Generator-Bug.fmp12.zip

Here is a proposed patch:

Generator-Patch.fmp12.zip

The patch would apply lines 125- 140 of the "HTTP Native ( { request } )" script.

Credit to Eden Morris for helping me debug this issue and write the patch! (and general dev awesomeness)

Improvement idea

What about putting an auto enter TextFormatRemoveAll on the fields so if you paste in from web API documentation it doesn't look like angry fruit salad..??

Not defaulting to use legacy code

The field RESOURCES::UseLegacy is a stored calc with a value of 0. It does not reevaluate if the file is opened by a FileMaker version prior to 16.

Request Script Steps Problem

Good day When I hit generate request and request script steps nothing happens not sure if I am doing something wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.