skyflow-js 1.21.3 → 1.22.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/CHANGELOG.md +4 -0
- package/README.md +125 -13
- package/dist/sdkNodeBuild/index.js +1 -1
- package/dist/sdkNodeBuild/index.js.gz +0 -0
- package/package.json +1 -1
- package/types/core/external/collect/collect-container.d.ts +2 -0
- package/types/core/external/collect/collect-element.d.ts +1 -0
- package/types/core/internal/iframe-form/index.d.ts +3 -1
- package/types/core/internal/index.d.ts +4 -1
- package/types/core-utils/collect.d.ts +5 -0
- package/types/utils/constants.d.ts +28 -0
- package/types/utils/logs.d.ts +9 -0
- package/types/utils/validators/index.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.22.0] - 2022-11-15
|
|
6
|
+
### Added
|
|
7
|
+
- `upsert` support while collecting data through skyflow elements.
|
|
8
|
+
- `upsert` support for pure js `insert` method.
|
|
5
9
|
## [1.21.3] - 2022-10-18
|
|
6
10
|
### Added
|
|
7
11
|
- `cardIcon` and `copyIcon` style objects for collect and reveal elements.
|
package/README.md
CHANGED
|
@@ -135,7 +135,7 @@ For `env` parameter, there are 2 accepted values in Skyflow.Env
|
|
|
135
135
|
- [**Using Skyflow File Element to upload a file**](#using-skyflow-file-element-to-upload-a-file)
|
|
136
136
|
## Inserting data into the vault
|
|
137
137
|
|
|
138
|
-
To insert data into the vault from the browser, use the `insert(records, options?)` method of the Skyflow client. The `records` parameter takes a JSON object of the records to be inserted in the below format. The `options` parameter takes a dictionary of optional parameters for the insertion. See below:
|
|
138
|
+
To insert data into the vault from the browser, use the `insert(records, options?)` method of the Skyflow client. The `records` parameter takes a JSON object of the records to be inserted in the below format. The `options` parameter takes a dictionary of optional parameters for the insertion. `insert` method also support upsert operations. See below:
|
|
139
139
|
|
|
140
140
|
```javascript
|
|
141
141
|
const records = {
|
|
@@ -152,15 +152,21 @@ const records = {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
const options = {
|
|
155
|
-
tokens: true //indicates whether or not tokens should be returned for the inserted data. Defaults to 'true'
|
|
155
|
+
tokens: true, //indicates whether or not tokens should be returned for the inserted data. Defaults to 'true'
|
|
156
|
+
upsert: [ // upsert operations support in the vault
|
|
157
|
+
{
|
|
158
|
+
table: "string", // table name
|
|
159
|
+
column: "value ", // unique column in the table
|
|
160
|
+
}
|
|
161
|
+
]
|
|
156
162
|
}
|
|
157
163
|
|
|
158
|
-
skyflowClient.insert(records, options
|
|
164
|
+
skyflowClient.insert(records, options)
|
|
159
165
|
```
|
|
160
166
|
|
|
161
167
|
|
|
162
168
|
|
|
163
|
-
An [example](https://github.com/skyflowapi/skyflow-js/blob/master/samples/
|
|
169
|
+
An [example](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/purejs.html) of an insert call:
|
|
164
170
|
```javascript
|
|
165
171
|
skyflowClient.insert({
|
|
166
172
|
"records": [
|
|
@@ -305,7 +311,7 @@ Finally, the `type` field takes a Skyflow ElementType. Each type applies the app
|
|
|
305
311
|
|
|
306
312
|
The `INPUT_FIELD` type is a custom UI element without any built-in validations. See the section on [validations](#validations) for more information on validations.
|
|
307
313
|
|
|
308
|
-
Along with CollectElement we can define other options which takes a
|
|
314
|
+
Along with CollectElement we can define other options which takes a object of optional parameters as described below:
|
|
309
315
|
|
|
310
316
|
```javascript
|
|
311
317
|
const options = {
|
|
@@ -391,10 +397,11 @@ element.unmount();
|
|
|
391
397
|
|
|
392
398
|
### Step 4: Collect data from Elements
|
|
393
399
|
|
|
394
|
-
When the form is ready to be submitted, call the `collect(options?)` method on the container object. The `options` parameter takes a
|
|
400
|
+
When the form is ready to be submitted, call the `collect(options?)` method on the container object. The `options` parameter takes a object of optional parameters as shown below:
|
|
395
401
|
|
|
396
402
|
- `tokens`: indicates whether tokens for the collected data should be returned or not. Defaults to 'true'
|
|
397
403
|
- `additionalFields`: Non-PCI elements data to be inserted into the vault which should be in the `records` object format as described in the above [Inserting data into vault](#inserting-data-into-the-vault) section.
|
|
404
|
+
- `upsert`: To support upsert operations while collecting the data from skyflow elements, pass the table and column that have been marked as unique in the table.
|
|
398
405
|
|
|
399
406
|
```javascript
|
|
400
407
|
const options = {
|
|
@@ -410,15 +417,21 @@ const options = {
|
|
|
410
417
|
}
|
|
411
418
|
//...additional records here
|
|
412
419
|
]
|
|
413
|
-
} //optional
|
|
420
|
+
}, //optional
|
|
421
|
+
upsert: [ //optional, upsert operations support in the vault
|
|
422
|
+
{
|
|
423
|
+
table: "string", // table name
|
|
424
|
+
column: "value ", // unique column in the table
|
|
425
|
+
}
|
|
426
|
+
]
|
|
414
427
|
}
|
|
415
428
|
|
|
416
|
-
container.collect(options
|
|
429
|
+
container.collect(options)
|
|
417
430
|
```
|
|
418
431
|
|
|
419
432
|
### End to end example of collecting data with Skyflow Elements
|
|
420
433
|
|
|
421
|
-
**[Sample Code:](https://github.com/skyflowapi/skyflow-js/blob/master/samples/
|
|
434
|
+
**[Sample Code:](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/skyflow-elements.html)**
|
|
422
435
|
|
|
423
436
|
```javascript
|
|
424
437
|
//Step 1
|
|
@@ -491,6 +504,105 @@ container.collect({
|
|
|
491
504
|
}
|
|
492
505
|
```
|
|
493
506
|
|
|
507
|
+
### End to end example of `upsert` support with Skyflow Elements
|
|
508
|
+
|
|
509
|
+
**[Sample Code:](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/upsert-support.html)**
|
|
510
|
+
|
|
511
|
+
```javascript
|
|
512
|
+
//Step 1
|
|
513
|
+
const container = skyflowClient.container(Skyflow.ContainerType.COLLECT)
|
|
514
|
+
|
|
515
|
+
//Step 2
|
|
516
|
+
const cardNumberElement = container.create({
|
|
517
|
+
table: "cards",
|
|
518
|
+
column: "card_number",
|
|
519
|
+
inputstyles: {
|
|
520
|
+
base: {
|
|
521
|
+
color: "#1d1d1d",
|
|
522
|
+
},
|
|
523
|
+
cardIcon:{
|
|
524
|
+
position: "absolute",
|
|
525
|
+
left:"8px",
|
|
526
|
+
bottom:"calc(50% - 12px)"
|
|
527
|
+
},
|
|
528
|
+
},
|
|
529
|
+
labelStyles: {
|
|
530
|
+
base: {
|
|
531
|
+
fontSize: "12px",
|
|
532
|
+
fontWeight: "bold"
|
|
533
|
+
}
|
|
534
|
+
},
|
|
535
|
+
errorTextStyles: {
|
|
536
|
+
base: {
|
|
537
|
+
color: "#f44336"
|
|
538
|
+
}
|
|
539
|
+
},
|
|
540
|
+
placeholder: "Card Number",
|
|
541
|
+
label: "card_number",
|
|
542
|
+
type: Skyflow.ElementType.CARD_NUMBER
|
|
543
|
+
})
|
|
544
|
+
|
|
545
|
+
const cvvElement = container.create({
|
|
546
|
+
table: "cards",
|
|
547
|
+
column: "cvv",
|
|
548
|
+
inputstyles: {
|
|
549
|
+
base: {
|
|
550
|
+
color: "#1d1d1d",
|
|
551
|
+
},
|
|
552
|
+
cardIcon:{
|
|
553
|
+
position: "absolute",
|
|
554
|
+
left:"8px",
|
|
555
|
+
bottom:"calc(50% - 12px)"
|
|
556
|
+
},
|
|
557
|
+
},
|
|
558
|
+
labelStyles: {
|
|
559
|
+
base: {
|
|
560
|
+
fontSize: "12px",
|
|
561
|
+
fontWeight: "bold"
|
|
562
|
+
}
|
|
563
|
+
},
|
|
564
|
+
errorTextStyles: {
|
|
565
|
+
base: {
|
|
566
|
+
color: "#f44336"
|
|
567
|
+
}
|
|
568
|
+
},
|
|
569
|
+
placeholder: "CVV",
|
|
570
|
+
label: "cvv",
|
|
571
|
+
type: Skyflow.ElementType.CVV
|
|
572
|
+
})
|
|
573
|
+
|
|
574
|
+
// Step 3
|
|
575
|
+
cardNumberElement.mount("#cardNumber") //assumes there is a div with id="#cardNumber" in the webpage
|
|
576
|
+
cvvElement.mount("#cvv"); //assumes there is a div with id="#cvv" in the webpage
|
|
577
|
+
|
|
578
|
+
// Step 4
|
|
579
|
+
|
|
580
|
+
container.collect({
|
|
581
|
+
tokens: true,
|
|
582
|
+
upsert: [
|
|
583
|
+
{
|
|
584
|
+
table: "cards",
|
|
585
|
+
column: "card_number",
|
|
586
|
+
}
|
|
587
|
+
]
|
|
588
|
+
})
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
**Sample Response :**
|
|
592
|
+
```javascript
|
|
593
|
+
{
|
|
594
|
+
"records": [
|
|
595
|
+
{
|
|
596
|
+
"table": "cards",
|
|
597
|
+
"fields": {
|
|
598
|
+
"card_number": "f3907186-e7e2-466f-91e5-48e12c2bcbc1",
|
|
599
|
+
"cvv": "12f670af-6c7d-4837-83fb-30365fbc0b1e"
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
]
|
|
603
|
+
}
|
|
604
|
+
```
|
|
605
|
+
|
|
494
606
|
### Validations
|
|
495
607
|
|
|
496
608
|
Skyflow-JS provides two types of validations on Collect Elements
|
|
@@ -544,7 +656,7 @@ const elementValueMatchRule = {
|
|
|
544
656
|
}
|
|
545
657
|
```
|
|
546
658
|
|
|
547
|
-
The Sample [code snippet](https://github.com/skyflowapi/skyflow-js/blob/master/samples/
|
|
659
|
+
The Sample [code snippet](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/CustomValidations.html) for using custom validations:
|
|
548
660
|
|
|
549
661
|
```javascript
|
|
550
662
|
/*
|
|
@@ -650,7 +762,7 @@ state : {
|
|
|
650
762
|
`Note:`
|
|
651
763
|
values of SkyflowElements will be returned in elementstate object only when `env` is `DEV`, else it is empty string i.e, ''
|
|
652
764
|
|
|
653
|
-
##### Sample [code snippet](https://github.com/skyflowapi/skyflow-js/blob/master/samples/
|
|
765
|
+
##### Sample [code snippet](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/CollectElementListeners.html) for using listeners
|
|
654
766
|
```javascript
|
|
655
767
|
//create skyflow client
|
|
656
768
|
const skyflowClient = Skyflow.init({
|
|
@@ -785,7 +897,7 @@ const records = {
|
|
|
785
897
|
|
|
786
898
|
skyflow.detokenize(records)
|
|
787
899
|
```
|
|
788
|
-
An [example](https://github.com/skyflowapi/skyflow-js/blob/master/samples/
|
|
900
|
+
An [example](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/purejs.html) of a detokenize call:
|
|
789
901
|
|
|
790
902
|
```javascript
|
|
791
903
|
skyflow.detokenize({
|
|
@@ -970,7 +1082,7 @@ container.reveal()
|
|
|
970
1082
|
|
|
971
1083
|
### End to end example of all steps
|
|
972
1084
|
|
|
973
|
-
**[Sample Code:](https://github.com/skyflowapi/skyflow-js/blob/master/samples/
|
|
1085
|
+
**[Sample Code:](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/skyflow-elements.html)**
|
|
974
1086
|
```javascript
|
|
975
1087
|
//Step 1
|
|
976
1088
|
const container = skyflowClient.container(Skyflow.ContainerType.REVEAL)
|