vsam.js 3.1.4 → 3.1.6
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/README.md +17 -2
- package/WrappedVsam.cpp +13 -11
- package/package.json +2 -2
- package/test/async.js +7 -24
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This [Node.js](https://nodejs.org/en/) module is available through the [npm regi
|
|
|
8
8
|
-->
|
|
9
9
|
|
|
10
10
|
Before installing, [download and install IBM Open Enterprise SDK for Node.js](https://www.ibm.com/docs/en/sdk-nodejs-zos)
|
|
11
|
-
|
|
11
|
+
20 or higher. vsam.js v3.1.6 or higher is required for Node.js 26 or higher.
|
|
12
12
|
|
|
13
13
|
## Simple to use
|
|
14
14
|
|
|
@@ -79,8 +79,9 @@ See [test/schema.json](https://github.com/ibmruntimes/vsam.js/blob/master/test/s
|
|
|
79
79
|
|
|
80
80
|
- [Supported Data Types](#supported-data-types)
|
|
81
81
|
- [Dataset Schema JSON File](#dataset-schema-json-file)
|
|
82
|
-
- [Open a VSAM dataset](#open-a-vsam-dataset)
|
|
83
82
|
- [Allocate a VSAM dataset](#allocate-a-vsam-dataset)
|
|
83
|
+
- [Open a VSAM dataset](#open-a-vsam-dataset)
|
|
84
|
+
- [VSAM record-level sharing (RLS)](#rls-support)
|
|
84
85
|
- [Check if a VSAM dataset exists](#check-if-a-vsam-dataset-exists)
|
|
85
86
|
- [Close a VSAM dataset](#close-a-vsam-dataset)
|
|
86
87
|
- [Read a record from a VSAM dataset](#read-a-record-from-a-vsam-dataset)
|
|
@@ -150,6 +151,20 @@ var vsamObj = vsam.openSync("VSAM.DATASET.NAME", JSON.parse(fs.readFileSync("sch
|
|
|
150
151
|
* To open a non-empty dataset in read-only mode, specify "rb,type=record" as the third argument.
|
|
151
152
|
* If the dataset doesn't exist, or on error, this function will throw an exception.
|
|
152
153
|
|
|
154
|
+
## VSAM record-level sharing (RLS)
|
|
155
|
+
|
|
156
|
+
To use RLS, the VSAM dataset must have been allocated using IDCAMS utility commands via JCL, ISPF panels, etc., where certain parameters for RLS support must be specified.
|
|
157
|
+
|
|
158
|
+
To open a VSAM dataset in RLS mode in vsam.js, specify, using the "rls=" keyword, the read integrity file access mode in the optional "mode" argument of `openSync`. For example:
|
|
159
|
+
```js
|
|
160
|
+
const vsam = require("vsam");
|
|
161
|
+
const fs = require("fs");
|
|
162
|
+
var vsamObj = vsam.openSync(dsname,
|
|
163
|
+
JSON.parse(fs.readFileSync('path-to-schema.json')),
|
|
164
|
+
"rb,type=record,rls=cr");
|
|
165
|
+
```
|
|
166
|
+
For a list of RLS access modes, see https://www.ibm.com/docs/en/zos/3.2.0?topic=pvio-vsam-record-level-sharing-transactional-vsam.
|
|
167
|
+
|
|
153
168
|
## Check if a VSAM dataset exists
|
|
154
169
|
|
|
155
170
|
```js
|
package/WrappedVsam.cpp
CHANGED
|
@@ -78,10 +78,11 @@ void WrappedVsam::DefaultComplete(uv_work_t *req, int status) {
|
|
|
78
78
|
Napi::HandleScope scope(pdata->env_);
|
|
79
79
|
DCHECK(pdata->cb_ != nullptr && pdata->env_ != nullptr);
|
|
80
80
|
if (pdata->rc_ != 0)
|
|
81
|
-
pdata->cb_.
|
|
82
|
-
|
|
81
|
+
pdata->cb_.MakeCallback(
|
|
82
|
+
pdata->env_.Global(),
|
|
83
|
+
{Napi::String::New(pdata->env_, pdata->errmsg_)});
|
|
83
84
|
else
|
|
84
|
-
pdata->cb_.
|
|
85
|
+
pdata->cb_.MakeCallback(pdata->env_.Global(), {pdata->env_.Null()});
|
|
85
86
|
delete pdata;
|
|
86
87
|
}
|
|
87
88
|
|
|
@@ -97,11 +98,11 @@ void WrappedVsam::FindUpdateComplete(uv_work_t *req, int status) {
|
|
|
97
98
|
DCHECK(pdata->cb_ != nullptr && pdata->env_ != nullptr);
|
|
98
99
|
if (pdata->rc_ != 0)
|
|
99
100
|
// even on error, 1 or more records may have been updated before the error
|
|
100
|
-
pdata->cb_.
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
pdata->cb_.MakeCallback(pdata->env_.Global(),
|
|
102
|
+
{Napi::Number::New(pdata->env_, pdata->count_),
|
|
103
|
+
Napi::String::New(pdata->env_, pdata->errmsg_)});
|
|
103
104
|
else
|
|
104
|
-
pdata->cb_.
|
|
105
|
+
pdata->cb_.MakeCallback(
|
|
105
106
|
pdata->env_.Global(),
|
|
106
107
|
{Napi::Number::New(pdata->env_, pdata->count_), pdata->env_.Null()});
|
|
107
108
|
|
|
@@ -164,21 +165,22 @@ void WrappedVsam::ReadComplete(uv_work_t *req, int status) {
|
|
|
164
165
|
Napi::HandleScope scope(pdata->env_);
|
|
165
166
|
DCHECK(pdata->cb_ != nullptr && pdata->env_ != nullptr);
|
|
166
167
|
if (pdata->rc_ != 0) {
|
|
167
|
-
pdata->cb_.
|
|
168
|
+
pdata->cb_.MakeCallback(
|
|
168
169
|
pdata->env_.Global(),
|
|
169
170
|
{pdata->env_.Null(), Napi::String::New(pdata->env_, pdata->errmsg_)});
|
|
170
171
|
delete pdata;
|
|
171
172
|
return;
|
|
172
173
|
}
|
|
173
174
|
if (pdata->recbuf_ == nullptr) {
|
|
174
|
-
pdata->cb_.
|
|
175
|
-
|
|
175
|
+
pdata->cb_.MakeCallback(pdata->env_.Global(),
|
|
176
|
+
{pdata->env_.Null(), pdata->env_.Null()});
|
|
176
177
|
delete pdata;
|
|
177
178
|
return;
|
|
178
179
|
}
|
|
179
180
|
|
|
180
181
|
Napi::Value record = createRecordObject(pdata);
|
|
181
|
-
pdata->cb_.
|
|
182
|
+
pdata->cb_.MakeCallback(pdata->env_.Global(),
|
|
183
|
+
{record, pdata->env_.Null()});
|
|
182
184
|
delete pdata;
|
|
183
185
|
}
|
|
184
186
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vsam.js",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.6",
|
|
4
4
|
"description": "Interact with VSAM Data Sets on z/OS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "ibmruntimes/vsam.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"async": "^1.5.0",
|
|
19
19
|
"chai": "^4.1.2",
|
|
20
|
-
"mocha": "^
|
|
20
|
+
"mocha": "^12.0.3"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "node-gyp build",
|
package/test/async.js
CHANGED
|
@@ -15,8 +15,7 @@ const { execSync } = require('child_process');
|
|
|
15
15
|
// Set IBM_VSAM_UID environment variable for customer uid
|
|
16
16
|
const uid = process.env.IBM_VSAM_UID || execSync('whoami').slice(0, -1);
|
|
17
17
|
const testSet = `${uid}.TEST2.VSAM.KSDS2`;
|
|
18
|
-
const
|
|
19
|
-
const title = `VSAM Key Sequenced Dataset - async APIs${lmt}`
|
|
18
|
+
const title = 'VSAM Key Sequenced Dataset - async APIs';
|
|
20
19
|
|
|
21
20
|
function readUntilEnd(file, done) {
|
|
22
21
|
var end = false;
|
|
@@ -423,14 +422,7 @@ describe(title, function() {
|
|
|
423
422
|
});
|
|
424
423
|
});
|
|
425
424
|
|
|
426
|
-
|
|
427
|
-
// FIXME(gabylb): even though all 4 promises resolve/reject in the expected time
|
|
428
|
-
// (and DONE-* displayed), it may take too long (~30 seconds) for Promise.all() to return.
|
|
429
|
-
// This happens only when the block below is run in mocha and Node version v12.
|
|
430
|
-
// With Node v8, those test time out, but pass when run outside of mocha.
|
|
431
|
-
|
|
432
|
-
if (process.version.split('.')[0] !== 'v8') {
|
|
433
|
-
it("run multiple read-only transactions async", function() {
|
|
425
|
+
it("run multiple read-only transactions async", function() {
|
|
434
426
|
var file = vsam.openSync(testSet,
|
|
435
427
|
JSON.parse(fs.readFileSync('test/schema.json')),
|
|
436
428
|
"rb,type=record");
|
|
@@ -490,8 +482,7 @@ describe(title, function() {
|
|
|
490
482
|
assert.ifError(err);
|
|
491
483
|
expect(file.close()).to.not.throw;
|
|
492
484
|
})
|
|
493
|
-
|
|
494
|
-
}
|
|
485
|
+
});
|
|
495
486
|
|
|
496
487
|
it("delete existing record, then find it and verify error, then delete it and verify error", function(done) {
|
|
497
488
|
var file = vsam.openSync(testSet,
|
|
@@ -915,14 +906,7 @@ describe(title, function() {
|
|
|
915
906
|
readUntilEnd(file, done);
|
|
916
907
|
});
|
|
917
908
|
|
|
918
|
-
|
|
919
|
-
// (and DONE-* displayed), it may take too long (~30 seconds) for Promise.all() to return.
|
|
920
|
-
// This happens only when the block below is run in mocha and Node version v12.
|
|
921
|
-
// With Node v8, those test time out, but pass when run outside of mocha.
|
|
922
|
-
//
|
|
923
|
-
|
|
924
|
-
if (process.version.split('.')[0] !== 'v8') {
|
|
925
|
-
it("run multiple find-update transactions async", function() {
|
|
909
|
+
it("run multiple find-update transactions async", function() {
|
|
926
910
|
var file = vsam.openSync(testSet,
|
|
927
911
|
JSON.parse(fs.readFileSync('test/schema.json')));
|
|
928
912
|
|
|
@@ -966,9 +950,9 @@ describe(title, function() {
|
|
|
966
950
|
assert.ifError(err);
|
|
967
951
|
expect(file.close()).to.not.throw;
|
|
968
952
|
})
|
|
969
|
-
|
|
953
|
+
});
|
|
970
954
|
|
|
971
|
-
|
|
955
|
+
it("write back a records to enable above test run in a loop if needed", function(done) {
|
|
972
956
|
var file = vsam.openSync(testSet,
|
|
973
957
|
JSON.parse(fs.readFileSync('test/schema.json')));
|
|
974
958
|
record = { key: "a3", name: "NAME 72347", amount: "f1a2a3f4c5" };
|
|
@@ -977,8 +961,7 @@ describe(title, function() {
|
|
|
977
961
|
expect(file.close()).to.not.throw;
|
|
978
962
|
done();
|
|
979
963
|
});
|
|
980
|
-
|
|
981
|
-
}
|
|
964
|
+
});
|
|
982
965
|
|
|
983
966
|
it("reads all records until the end", function(done) {
|
|
984
967
|
var file = vsam.openSync(testSet,
|