wrekenfile-converter 2.0.6 → 2.1.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.
Files changed (52) hide show
  1. package/README.md +45 -26
  2. package/dist/example-usage.d.ts +1 -1
  3. package/dist/index.d.ts +6 -5
  4. package/dist/index.js +53 -20
  5. package/dist/v1/index.d.ts +3 -0
  6. package/dist/v1/index.js +21 -0
  7. package/dist/{postman-to-wrekenfile.js → v1/postman-to-wrekenfile.js} +7 -19
  8. package/dist/{wrekenfile-validator.js → v1/wrekenfile-validator.js} +30 -8
  9. package/dist/v2/cli/cli-mini-wrekenfile-generator.d.ts +2 -0
  10. package/dist/v2/cli/cli-mini-wrekenfile-generator.js +107 -0
  11. package/dist/v2/cli/cli-openapi-to-wrekenfile.d.ts +2 -0
  12. package/dist/v2/cli/cli-openapi-to-wrekenfile.js +115 -0
  13. package/dist/v2/cli/cli-openapi-v2-to-wrekenfile.d.ts +2 -0
  14. package/dist/v2/cli/cli-openapi-v2-to-wrekenfile.js +115 -0
  15. package/dist/v2/cli/cli-postman-to-wrekenfile.d.ts +2 -0
  16. package/dist/v2/cli/cli-postman-to-wrekenfile.js +54 -0
  17. package/dist/v2/index.d.ts +4 -0
  18. package/dist/v2/index.js +25 -0
  19. package/dist/v2/mini-wrekenfile-generator.d.ts +13 -0
  20. package/dist/v2/mini-wrekenfile-generator.js +289 -0
  21. package/dist/v2/openapi-to-wreken.d.ts +2 -0
  22. package/dist/v2/openapi-to-wreken.js +829 -0
  23. package/dist/v2/openapi-v2-to-wrekenfile.d.ts +2 -0
  24. package/dist/v2/openapi-v2-to-wrekenfile.js +806 -0
  25. package/dist/v2/postman-to-wrekenfile.d.ts +11 -0
  26. package/dist/v2/postman-to-wrekenfile.js +742 -0
  27. package/dist/v2/utils/constants.d.ts +80 -0
  28. package/dist/v2/utils/constants.js +104 -0
  29. package/dist/v2/utils/response-utils.d.ts +11 -0
  30. package/dist/v2/utils/response-utils.js +39 -0
  31. package/dist/v2/utils/yaml-utils.d.ts +4 -0
  32. package/dist/v2/utils/yaml-utils.js +96 -0
  33. package/dist/versions.d.ts +9 -0
  34. package/dist/versions.js +12 -0
  35. package/package.json +12 -14
  36. package/dist/openapi-to-wrekenfile.d.ts +0 -0
  37. package/dist/openapi-to-wrekenfile.js +0 -10
  38. package/wrekenfile.md +0 -726
  39. /package/dist/{cli → v1/cli}/cli-mini-wrekenfile-generator.d.ts +0 -0
  40. /package/dist/{cli → v1/cli}/cli-mini-wrekenfile-generator.js +0 -0
  41. /package/dist/{cli → v1/cli}/cli-openapi-to-wrekenfile.d.ts +0 -0
  42. /package/dist/{cli → v1/cli}/cli-openapi-to-wrekenfile.js +0 -0
  43. /package/dist/{cli → v1/cli}/cli-postman-to-wrekenfile.d.ts +0 -0
  44. /package/dist/{cli → v1/cli}/cli-postman-to-wrekenfile.js +0 -0
  45. /package/dist/{mini-wrekenfile-generator.d.ts → v1/mini-wrekenfile-generator.d.ts} +0 -0
  46. /package/dist/{mini-wrekenfile-generator.js → v1/mini-wrekenfile-generator.js} +0 -0
  47. /package/dist/{openapi-to-wreken.d.ts → v1/openapi-to-wreken.d.ts} +0 -0
  48. /package/dist/{openapi-to-wreken.js → v1/openapi-to-wreken.js} +0 -0
  49. /package/dist/{openapi-v2-to-wrekenfile.d.ts → v1/openapi-v2-to-wrekenfile.d.ts} +0 -0
  50. /package/dist/{openapi-v2-to-wrekenfile.js → v1/openapi-v2-to-wrekenfile.js} +0 -0
  51. /package/dist/{postman-to-wrekenfile.d.ts → v1/postman-to-wrekenfile.d.ts} +0 -0
  52. /package/dist/{wrekenfile-validator.d.ts → v1/wrekenfile-validator.d.ts} +0 -0
package/wrekenfile.md DELETED
@@ -1,726 +0,0 @@
1
- # Wrekenfile v1.2
2
-
3
- ## Wrekenfile
4
-
5
- 1. The accepted names for the file are `Wrekenfile.yaml` or `Wrekenfile.yml` .
6
-
7
-
8
-
9
-
10
- ```yaml
11
- # =========================================================
12
- #
13
- # Wrekenfile
14
- # Metadata file for the given library to be fed to Wreken
15
- #
16
- # =========================================================
17
-
18
- # Wrekenfile version
19
- #
20
- # Putting version information helps generate and verify the correct schema of the
21
- # Wrekenfile
22
-
23
- VERSION: "1.2"
24
-
25
-
26
-
27
- # ==========================================================
28
- #
29
- # List of available programming interfaces for the library
30
- # This can include `INTERFACES` and `INIT`
31
- #
32
- # ==========================================================
33
-
34
-
35
- # INIT functions
36
-
37
- # These functions are called at the top to initialize the library or
38
- # functions which are required as a dependency for the library initialization
39
- # and functions which are out of scope for the library e.g `current date` required as
40
- # a param in library initialization
41
- #
42
- # `INIT` functions are called in order of their declarations
43
- #
44
- # If no `INIT` functions are provided, `INTERFACES` can be called directly
45
- # without `lib` object. e.g
46
- # With `INIT`: `lib.method_name(...params)`
47
- # Without `INIT`: `function_name(...params)`
48
-
49
- INIT:
50
-
51
- # `DEFAULTS` is a special block in `INIT`. Here, you define defaults for function
52
- # calls. These are global variables. You can also define `DEFAULTS` inside the
53
- # `INTERFACES`
54
- #
55
- # The `DEFAULTS` inside `INTERFACES` take precedence over global `DEFAULTS`
56
- # `DEFAULT` values can be overwritten anytime during code generation
57
-
58
- DEFAULTS:
59
- - userid: 1
60
- - cartid: 1
61
- - amount: 100.00
62
- - bearer_token: "BEARER abcd"
63
- - some_val: "SOME VALUE"
64
-
65
-
66
- current-date:
67
- DESC: "Generate a timestamp"
68
- INTERFACE: Date()
69
- ASYNC: false
70
- TYPE: sdk
71
- RETURNS:
72
- - RETURNTYPE: TIMESTAMP
73
- RETURNNAME: currentDate
74
-
75
-
76
- initiate-library:
77
- DESC: "Initiate the library"
78
- INTERFACE: Library(currentDate)
79
- ASYNC: false
80
- TYPE: sdk
81
- RETURNS:
82
- - RETURNTYPE: STRUCT(ABC)
83
- RETURNNAME: lib
84
-
85
-
86
-
87
- # INTERFACES
88
-
89
- # Available programming interfaces
90
- # Order agnostic
91
-
92
- INTERFACES:
93
-
94
- # General internal function
95
-
96
- nonce:
97
- DESC: "Generate one unique key for the transactions"
98
- INTERFACE: nonce()
99
- ASYNC: false
100
- RETURNS:
101
- - RETURNTYPE: STRING, REQUIRED
102
- RETURNNAME: nonceVal
103
-
104
-
105
- make-payment:
106
- DESC: "Make a payment for a product"
107
- INTERFACE: make_payment(userid, cartid, amount, nonce, cardtype)
108
- ASYNC: true
109
- INPUTS:
110
- - name: userid
111
- type: INT
112
- required: TRUE
113
- - name: cardid
114
- tye: INT
115
- required: TRUE
116
- - name: amount
117
- type: FLOAT
118
- required: TRUE
119
- - name: nonce
120
- type: STRING
121
- required: TRUE
122
- - name: cardtype
123
- type: STRING
124
- required: FALSE
125
- DEFAULTS:
126
- - cardtype: "Master"
127
- - amount: 100.00
128
- - nonce: nonceVal
129
- RETURNS:
130
- - RETURNTYPE: STRUCT(ABC)
131
- RETURNNAME: payment_status
132
-
133
-
134
- payment-details-by-id:
135
- DESC: "Get payment details by ID"
136
- INTERFACE: get_paymentDetails_by_id(userid, paymentid)
137
- ASYNC: false
138
- INPUTS:
139
- - name: userid
140
- type: INT
141
- required: TRUE
142
- - name: paymentid
143
- type: STRING
144
- required: FALSE
145
- DEFAULTS:
146
- - paymentid: payment_status.uid
147
- RETURNS:
148
- - RETURNTYPE: []STRUCT(ABC)
149
-
150
- # POST requests
151
-
152
- user-payment-details:
153
- DESC: "Get details of user's specific payment"
154
- ENDPOINT: http://library.api/payment-details
155
- HTTP:
156
- METHOD: "POST"
157
- HEADERS:
158
- - Authorization: bearer_token
159
- - CustomHeader: some_val
160
-
161
- # `BODYTYPE` can be raw, form-data, x-www-form-urlencoded, graphql
162
-
163
- BODYTYPE: "RAW"
164
- INPUTS:
165
- - name: userid
166
- type: INT
167
- required: TRUE
168
- RETURNS:
169
- - RETURNTYPE: []STRUCT(ABC)
170
-
171
- # GET Requests
172
-
173
- payment-methods:
174
- DESC: "Get all available payment methods"
175
- ENDPOINT: http://library.api/payment-methods
176
- HTTP:
177
- METHOD: "GET"
178
- HEADERS:
179
- - Authorization: bearer_token
180
- - CustomHeader: some_val
181
- RETURNS:
182
- - RETURNTYPE: []STRUCT(ABC)
183
-
184
-
185
-
186
- # ==========================================================
187
- #
188
- # Basic test cases for the library with Wrekenfile
189
- # Any specific input and output value should be enclosed within ticks(``)
190
- #
191
- # ==========================================================
192
-
193
- TESTS:
194
- NLP:
195
- - Generate code to make a payment using `Visa` card and get the payment details for the generated `paymentid`
196
- - Get all payment methods
197
- ```
198
-
199
-
200
-
201
- ## Expected output for the Tests
202
-
203
- The output from the tests are sent as an API response
204
-
205
-
206
-
207
- #### Test 1
208
-
209
- ```javascript
210
- /*
211
- * ==================================================================================
212
- * Generate code to make a payment using `Visa` card and get the payment details for
213
- * the generated `paymentid`
214
- * ==================================================================================
215
- */
216
-
217
-
218
- // Initiate Library
219
-
220
- const currentDate = new Date()
221
- const lib = new Library(currentDate)
222
-
223
- // Process NLP
224
- const nonceVal = lib.nonce()
225
-
226
- // Note:
227
- // 1. The values picked from `DEFAULTS`
228
- // 2. Also, note how `Visa` was assigned instead of Default `Master`
229
- // 3. Lastly, see how the required `nonceVal` value was interpreted and the function
230
- // call was made above
231
-
232
- const payment_status = await lib.make_payment(1, 1, 100.00, nonceVal, "Visa")
233
-
234
- // If no `RETURNNAME` is specified in the Wrekenfile, just `console.log` the output
235
- console.log(lib.get_paymentDetails_by_id(1, payment_status.uid))
236
- ```
237
-
238
-
239
-
240
- #### Test 2
241
-
242
- ```javascript
243
- /*
244
- * ===================================
245
- * Get all payment methods
246
- * ===================================
247
- */
248
-
249
- // Initiate Library
250
- // Note: Irrespective of the fact that we don't need the values in an API, but since
251
- // `INIT` was defined, we initialize the library
252
-
253
- const currentDate = new Date()
254
- const lib = new Library(currentDate)
255
-
256
- // Process NLP
257
- const response = await fetch("http://library.api/payment-methods");
258
- const payments = await response.json();
259
- console.log(payments);
260
- ```
261
-
262
- # Wrekenfile Documentation
263
-
264
- # About Wrekenfile
265
-
266
-
267
-
268
- Wrekenfile is a universal configuration specification for APIs and SDKs that helps generate one shot code workflow for the library. The configuration specification is programming language agnostic and it's a `yaml` file that contains the `input`, `output`, `method descriptions`, `http methods`, `default values` and `custom variable` definitions of a library.
269
-
270
-
271
-
272
- The intention is to use the Wrekenfile to generate a code workflow for the library by using a combination of available functions/APIs available in the specification. Users should be able to write their requirements as a LLM prompt, and the AI should understand the components in a Wrekenfile and generate a working code workflow for them.
273
-
274
-
275
-
276
- ## Main Blocks
277
-
278
-
279
-
280
- Wrekenfile is divided into 4 important blocks, namely
281
-
282
-
283
-
284
- ### 1\. VERSION
285
-
286
-
287
-
288
- It describes the current version of the Wrekenfile. Putting version information together helps generate and verify the correct schema of the specification. This should be included in the top, like
289
-
290
-
291
-
292
- ```plain
293
- VERSION: "1.2"
294
- ```
295
-
296
-
297
-
298
- ### 2\. INIT
299
-
300
-
301
-
302
- Contains the default values for constants and environment variables. Also includes definitions for external dependent functions and a call to the entry function of the library. Here is an example of INIT block
303
-
304
-
305
-
306
- ```plain
307
- INIT:
308
- DEFAULTS:
309
- - userid: 1
310
- - cartid: 1
311
- - amount: 100.00
312
- - bearer_token: "BEARER abcd"
313
- - some_val: "SOME VALUE"
314
-
315
- EXT:
316
- DESC: "Generate a timestamp"
317
- INTERFACE: Date()
318
- ASYNC: false
319
- RETURNS:
320
- - RETURNTYPE: TIMESTAMP
321
- RETURNVAR: currentDate
322
-
323
- ENTRY:
324
- DESC: "Initiate the library"
325
- INTERFACE: Library(currentDate)
326
- ASYNC: false
327
- INPUTS:
328
- - name: currentDate
329
- type: INT
330
- required: TRUE
331
- RETURNS:
332
- - RETURNTYPE: STRUCT(LIBRARY)
333
- RETURNVAR: library
334
- ```
335
-
336
-
337
-
338
- Section description for the block above
339
-
340
-
341
-
342
- ##### DEFAULTS
343
-
344
-
345
-
346
- Defaults contain the values for environment variables or constants to be used later in the Wrekenfile. These values can be overridden by values mentioned inside the Methods (to be explained later)
347
-
348
-
349
-
350
- ##### EXT
351
-
352
-
353
-
354
- This section defines any external function and its return types. These functions should be independent of any other dependencies. If there is a dependency on a variable or value, it should be defined in _DEFAULTS_ rather than writing a different function for the same. In the example above, the _EXT_ contain the following [Sections (defined here in detail)](http://#sections)
355
-
356
-
357
-
358
- 1. `SUMMARY` provides a summary of external function description
359
- 2. `DESC` provides a detailed description of the method
360
- 3. `INTERFACE` defines how you can call the external function. Remember, this function shouldn't have an input dependency from another function. If so, the values should be defined in _DEFAULTS_ and passed as function arguments.
361
- 4. `ASYNC` is false and tells the interface returns immediately.
362
- 5. `RETURNTYPE` defines the return data type. It can be a [Primitive value](http://#primitive-types), a [Struct (object)](http://#4-structs) or an Array (primitives or structs)
363
- 6. `RETRURNVAR` is the variable name that contains the value of the return from the function.
364
-
365
-
366
-
367
- ##### ENTRY
368
-
369
-
370
-
371
- This defines the starting function, method, or API for the library. e.g., if a library needs an authentication or authorization call before each API, function, or method call, then that should be defined here. Many libraries may not contain the _ENTRY_ block. Also, _ENTRY_ block can be an [Endpoint](http://#endpoint-optional) or an [Interface](http://#interface-optional)
372
-
373
-
374
-
375
- The structure of this block is similar to _EXT_ with two distinctions. One being the`INPUTS` section and the other being the `RETURNTYPE`.
376
-
377
-
378
-
379
- 1. Inputs are _variable-type maps_ that are passed as arguments to the Interface/Endpoint function.
380
- 2. The ReturnType above is a Struct (which is a user-defined data type) and its definition **(LIBRARY)** can be found inside the [STRUCTS](http://#4-structs) block
381
-
382
-
383
-
384
- ### 3\. METHODS
385
-
386
-
387
-
388
- These are the functions or methods available for the library. They can be either API definitions or function declarations for the SDKs. Methods also contain _SECTIONS_ that define the input and output values and their types. These returns can also serve as input for other methods in the case of designing an API workflow.
389
-
390
-
391
-
392
- #### Sections
393
-
394
-
395
-
396
- The building blocks of a Method.
397
-
398
-
399
-
400
- ##### ALIAS (Mandatory)
401
-
402
-
403
-
404
- Alias or Section headers, are just names to identify a method. It should be a programmatic name (similar to variable naming conventions) and can contain only alphanumeric characters, an underscore, and a hyphen. e.g
405
-
406
-
407
-
408
- ```plain
409
- get-last-4-payment-by-user_id:
410
- ```
411
-
412
-
413
-
414
- ##### SUMMARY (Mandatory)
415
-
416
-
417
-
418
- A summary is an important section of a method. Every Method block item should have a summary which the LLM can read to find out what the API or method does. Without a summary, the LLM doesn't get the proper context of the underlying API or method. It's recommended that the summary contain one line on what the function does in a direct commanding tone. e.g
419
-
420
-
421
-
422
- ```plain
423
- SUMMARY: "Fetch a list of payments for a user_id"
424
- ```
425
-
426
-
427
-
428
-
429
- ##### DESC (Optional)
430
-
431
-
432
-
433
- A description is an optional field for the method and provides more context to the LLM. Description augments what the summary does but provides a lot of other details while considering code generation. e.g
434
-
435
-
436
-
437
- ```plain
438
- DESC: "Fetch a list of payments for a user_id also displays the payment id and date of their creations. Method can be POST only"
439
- ```
440
-
441
-
442
-
443
- ##### INTERFACE (Optional)
444
-
445
-
446
-
447
- A library can be one of an SDK type or an API type. The interface defines the function calls for an SDK. For API types, instead of an Interface, an [_ENDPOINT_](http://#endpoint-optional) is provided
448
-
449
-
450
-
451
- These functions can be standalone or have arguments. e.g
452
-
453
-
454
-
455
- ```plain
456
- INTERFACE: get_paymentDetails_by_id(userid, paymentid)
457
- ```
458
-
459
- In the above example
460
-
461
-
462
-
463
- 1. `get_paymentDetails_by_id` should be the name of the actual function/method in the SDK
464
- 2. The arguments, `userid` and `paymentid` types are defined later in the _INPUTS_ section. But it should be passed in the same order as expected in the actual SDK function/method
465
- 3. Function returns are defined later
466
-
467
- ##### ASYNC (Optional)
468
- Async accepts a boolean (true/false). When combined with interface, it tells the function returns asynchronous output. By default, if not present, it can be assumed to be false.
469
-
470
- ##### ENDPOINT (Optional)
471
-
472
-
473
-
474
- For the API type of a library, Endpoint is mandatory. Endpoint defines a URL that is called to execute results for an API. To define a BASE URL for all the APIs, please read [w\_base\_url in Keywords section](http://#keywords). `w_base_url` shortens the time needed to switch between various environments and also makes the Endpoints look cleaner.
475
-
476
-
477
-
478
- Endpoints can be of the following three types:
479
-
480
-
481
-
482
- ```plain
483
- #E.g-1 with w_base_url
484
- ENDPOINT: "/payment-details"
485
-
486
- #E.g-2 for get/post/put/delete requests with parameters
487
- ENDPOINT: "http://library.api/payment-details?key1=value1&key2=value2"
488
- ENDPOINT: "http://library.api/payment-details/value1/value2"
489
- ```
490
-
491
-
492
-
493
- In E.g-2 above, if the values are dynamic, they can be defined as described in the [Inputs](http://#inputs) section. However, to make them dynamic, the value parameters need to be wrapped with `{}` and the whole Endpoint needs to be wrapped in a tick `(``)` rather than double quotes `("")`. e.g
494
-
495
-
496
-
497
- ```plain
498
- ENDPOINT: `http://library.api/payment-details?key1={dynamicValue1}&key2={dynamicValue2}`
499
-
500
- ENDPOINT: `http://library.api/payment-details/{dynamicValue1}/{dynamicValue2}`
501
- ```
502
-
503
-
504
-
505
- ##### HTTP (Optional)
506
-
507
-
508
-
509
- This section only comes into play when making HTTP requests to an API endpoint. The Http can contain three parameters
510
-
511
-
512
-
513
- 1. METHOD: The HTTP method to use. e.g, `GET/POST/PUT/DELETE`
514
- 2. HEADERS: The HTTP headers to send along with the request. All the HTTP headers are supported here
515
- 3. BODYTYPE: Body Type be `raw`, `form-data`, `x-www-form-urlencoded`
516
-
517
-
518
-
519
- ```plain
520
- HTTP:
521
- METHOD: "POST"
522
- HEADERS:
523
- - Authorization: bearer_token
524
- - CustomHeader: some_val
525
- - Content-Type: "application/json"
526
- BODYTYPE: "raw"
527
- ```
528
-
529
-
530
-
531
- ##### INPUTS (Optional)
532
-
533
-
534
-
535
- If any of the interfaces or endpoints require input parameters/arguments, then it is mandatory to define Inputs. Inputs contain the data types that need to be passed along with a function call or HTTP request.
536
-
537
- e.g
538
-
539
-
540
-
541
- For Interface calls
542
-
543
-
544
-
545
- ```plain
546
- INPUTS:
547
- - name: userid
548
- type: INT
549
- required: TRUE
550
- - name: payment
551
- type: INT
552
- required: FALSE
553
- ```
554
-
555
-
556
-
557
- For URL parameters
558
-
559
-
560
-
561
- ```plain
562
- INPUTS:
563
- - name: dynamicValue1
564
- type: INT
565
- required: TRUE
566
- - name: dynamicValue2
567
- type: STRING
568
- required: TRUE
569
- ```
570
-
571
-
572
-
573
- For POST HTTP method request with `BODYTYPE:"raw"`
574
-
575
-
576
-
577
- ```plain
578
- INPUTS:
579
- - name: body
580
- type: STRUCT(WATCHES)
581
- required: TRUE
582
- ```
583
-
584
-
585
-
586
- **Note**: For the POST HTTP example, there is a special variable `body` that needs to be defined, and the `Content-Type` header needs to be checked. If `Content-Type: "application/json"`, the body needs to be passed as JSON, if `Content-Type:"text/plain"`, then plain text needs to be passed in the body
587
-
588
-
589
-
590
- ##### DEFAULTS (Optional)
591
-
592
-
593
-
594
- When there is a need to pass a default constant only to a specific Function/API, _DEFAULTS_ inside METHODS can be used. If a Default Constant with the same name is defined in the [INIT](http://#init) block, then the current one will supersede the later one.
595
-
596
-
597
-
598
- ##### RETURNS (Optional)
599
-
600
-
601
-
602
- Returns section defines the return data type and value(s) from the library. It can be one of a [Primitive value](http://#primitive-types), a [Struct (object)](http://#4-structs) or an Array (primitives or structs). Returns contain two sub-sections, namely
603
-
604
-
605
-
606
- 1. `RETURNTYPE`: Defines the type of data returned.
607
- 2. `RETURNVAR`: User defined name of the variable that holds the return from the API/Method. _ReturnVar_ holds significance when being used as an input for another API/Function call while executing a workflow
608
-
609
-
610
-
611
- To define an array as a return data type, use a `[]` followed by a Primitive or Struct(name). e.g
612
-
613
-
614
-
615
- ```plain
616
- # Return type: Primitive
617
- - RETURNTYPE: TIMESTAMP
618
- - RETURNTYPE: STRING
619
-
620
- # Return type: Struct
621
- - RETURNTYPE: STRUCT(LIBRARY)
622
-
623
- # Return type: Array
624
- - RETURNTYPE: []STRUCT(LIBRARY)
625
- - RETURNTYPE: []STRING
626
- ```
627
-
628
-
629
-
630
- Simple examples using `Returns`
631
-
632
-
633
-
634
- ```plain
635
- # E.g-1
636
- RETURNS:
637
- - RETURNTYPE: STRUCT(LIBRARY)
638
- RETURNVAR: lib
639
- # E.g-2
640
- RETURNS:
641
- - RETURNTYPE: []STRING
642
- RETURNVAR: names
643
- ```
644
-
645
-
646
-
647
- For _E.g-1_, the return values can be accessed via `lib.surname`, `lib.age` in any other subsequent functions in the workflow. Look for `LIBRARY` struct defined later in the Structs block
648
-
649
-
650
-
651
- For _E.g-2_, the return values can be accessed via `names[0]`, `names[1]` in any other subsequent functions in the workflow. They can even be used in a loop
652
-
653
-
654
-
655
- ### 4\. STRUCTS
656
-
657
-
658
-
659
- Structs contain the definition of user-defined objects, or structs. Here, any kind of variable can be defined, which cannot be defined directly by programming language primitive variables. A struct can also refer to another struct internally, which needs to be defined within this block. The order of defining structs doesn't matter
660
-
661
-
662
-
663
- ```plain
664
- STRUCTS:
665
- LIBRARY:
666
- - name: STRING, REQUIRED
667
- - surname: STRING, REQUIRED
668
- - age: INT, REQUIRED
669
- - pets: []STRING, REQUIRED
670
- - watches: []STRUCT(WATCHES), OPTIONAL
671
-
672
- WATCHES:
673
- - make: STRING, REQUIRED
674
- - price: FLOAT, REQUIRED
675
- - year: INT, OPTIONAL
676
- ```
677
-
678
-
679
-
680
- ## PRIMITIVE TYPES
681
-
682
-
683
-
684
- Listed below are the generalized Primitive types for all programming languages.
685
-
686
-
687
-
688
- 1. `STRING`: can cover VARCHAR, TEXT, STRING, etc
689
- 2. `INT`: covers INT, INTEGER, INT32, INT64, BIGINT, NUMBER, etc
690
- 3. `FLOAT`: covers FLOAT, FLOAT32, FLOAT64, DOUBLE, DECIMAL, etc
691
- 4. `TIMESTAMP`: covers all TIMESTAMP cases
692
- 5. `DATE`: covers DATE types
693
- 6. `TIME`: covers TIME
694
- 7. `BOOL`: also covers BOOLEAN
695
- 8. `UNDEFINED`: for static programming languages where user data type is unknown
696
- 9. `NULL`: returns/holds nothing
697
- 10. `BYTES`: For byte types
698
- 11. `ANY`: can take any value
699
- 12. `UUID`: Unique string for uuid
700
-
701
-
702
-
703
- ## KEYWORDS
704
-
705
- 1. `w_base_url`: can be defined in the [DEFAULTS](http://#defaults). Once defined, it will be prepended to the [ENDPOINT](http://#endpoint-optional). e.g
706
-
707
-
708
-
709
- ```plain
710
- INIT:
711
- DEFAULTS:
712
- - w_base_url: "https://library.api"
713
-
714
- METHODS:
715
- make-payment:
716
- DESC: "Make a payment for a product"
717
- ENDPOINT: "/payment-details"
718
- ```
719
-
720
-
721
-
722
- In the example above, the `w_base_url` variable is defined, and the Endpoint only needs to point to the remaining part of the URL. However, when the API Endpoint is called, the full URL is passed like ([https://library.api/payment-details](https://library.api/payment-details)).
723
-
724
-
725
-
726
- **Note**: `w_base_url` shouldn't contain the trailing forward slash (`/`)