fable 3.0.50 → 3.0.51
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/.config/configstore/update-notifier-npm.json +1 -1
- package/dist/fable.compatible.js +49 -39
- package/dist/fable.compatible.min.js +10 -18
- package/dist/fable.compatible.min.js.map +1 -1
- package/dist/fable.js +23 -13
- package/dist/fable.min.js +10 -18
- package/dist/fable.min.js.map +1 -1
- package/gulpfile.js +1 -164
- package/package.json +65 -78
- package/source/Fable.js +2 -0
- package/source/services/Fable-Service-Anticipate.js +87 -0
- package/source/services/Fable-Service-DataGeneration-DefaultValues.json +55 -0
- package/source/services/Fable-Service-DataGeneration.js +66 -0
- package/source/services/Fable-Service-FilePersistence-Web.js +1 -0
- package/source/services/Fable-Service-FilePersistence.js +66 -1
- package/test/Anticipate_tests.js +91 -0
- package/test/DataGeneration_tests.js +109 -0
- package/gulpfile-config.json +0 -11
- package/gulpfile-config_compatible.json +0 -11
- package/gulpfile-config_default.json +0 -11
package/gulpfile.js
CHANGED
|
@@ -1,164 +1 @@
|
|
|
1
|
-
'
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
After hours of reading and trying various ways of using gulp-env, environment variables
|
|
5
|
-
and babel browesrslistrc / package.json environments it is clear that the state of using
|
|
6
|
-
these tools is a mess. There are ways of getting it to work but none of them feel like
|
|
7
|
-
they will work well in the long term (all of the examples seem to be in bands of about
|
|
8
|
-
a year or two of working before the pattern changes entirely).
|
|
9
|
-
|
|
10
|
-
WHY did we need such a crazy compatible version? wkhtmltopdf is why. It uses a very
|
|
11
|
-
old incompatible version of the QT browser.
|
|
12
|
-
|
|
13
|
-
Therefore, we will use a very old and simple method.
|
|
14
|
-
|
|
15
|
-
1) There is a config file (gulpfile-config.json), documented here, describing the inputs and outputs for the build operation.
|
|
16
|
-
|
|
17
|
-
const _CONFIG = (
|
|
18
|
-
{
|
|
19
|
-
// The input source file that should be passed to browserify:
|
|
20
|
-
// (if you need to auto-instantiate an object, for instance)
|
|
21
|
-
EntrypointInputSourceFile: `${__dirname}/source/Fable-Browser-Shim.js`,
|
|
22
|
-
|
|
23
|
-
// The name of the packaged object to be passed to browserify:
|
|
24
|
-
// (browserify sets this to global scope and window.SOMEOBJECTNAMEHERE where SOMEOBJECTNAMEHERE is the string below)
|
|
25
|
-
LibraryObjectName: `Fable`,
|
|
26
|
-
|
|
27
|
-
// The folder to write the library files and maps out to:
|
|
28
|
-
LibraryOutputFolder: `${__dirname}/dist/`,
|
|
29
|
-
|
|
30
|
-
// The name of the unminified version of the packaged library, for easy debugging:
|
|
31
|
-
LibraryUniminifiedFileName: `fable.js`,
|
|
32
|
-
|
|
33
|
-
// The name of the minified version of the packaged library, for production release:
|
|
34
|
-
LibraryMinifiedFileName: `fable.min.js`
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
2) We are using a .browserslistrc file... this is what tells gulp-babel, through the
|
|
38
|
-
magic of the @babel/preset-env library, how to transpile the library into a compatible
|
|
39
|
-
enough format for our targets.
|
|
40
|
-
|
|
41
|
-
For example as of writing this, there are two targets we want:
|
|
42
|
-
|
|
43
|
-
* Modern browsers in the last five years, expressed as a .browserslistrc with the string "since 2018"
|
|
44
|
-
* Very old janky browsers expressed as a .browserslistrc with the string "> 0.01%"
|
|
45
|
-
... which is interpreted as anything more than 0.01% of browsers in existence or something like that
|
|
46
|
-
|
|
47
|
-
3) Because we want multiple outputs, and, the tools do fine if we want one output but some of
|
|
48
|
-
the toolchain doesn't like making different targets well, we're just going to have multiple
|
|
49
|
-
configurations and .browserslistrc files. So if our spec above says we need a ".browserslistrc"
|
|
50
|
-
file and a "gulpfile-config.json", we're going to make the following two sets of configuration:
|
|
51
|
-
|
|
52
|
-
* .browserslistrc_default, .gulpfile-config_default.json
|
|
53
|
-
* .browserslistrc_compatible, .gulpfile-config_compatible.json
|
|
54
|
-
|
|
55
|
-
4) We will copy, synchronously, these files to where the rest of our toolchain expects
|
|
56
|
-
them, before we begin the build. This will be done by looking at the GULP_CUSTOM_BUILD_TARGET
|
|
57
|
-
environment variable. This allows us to create new targets to experiment by copying a couple files,
|
|
58
|
-
jimmying the settings and setting an environment variable before running the pipeline.
|
|
59
|
-
|
|
60
|
-
5) We will run the toolchain and it will happily think it's just doing a single build and kinda work.
|
|
61
|
-
|
|
62
|
-
*/
|
|
63
|
-
// BEGINNING OF STEP 3 and STEP 4 ABOVE
|
|
64
|
-
const libFS = require('fs');
|
|
65
|
-
const _GULP_CUSTOM_BUILD_TARGET = (typeof(process.env.GULP_CUSTOM_BUILD_TARGET) == 'undefined') ? 'default' : process.env.GULP_CUSTOM_BUILD_TARGET;
|
|
66
|
-
console.log(`--> Gulp custom build target set to: [${_GULP_CUSTOM_BUILD_TARGET}]`);
|
|
67
|
-
const _GULP_CONFIG = `./gulpfile-config_${_GULP_CUSTOM_BUILD_TARGET}.json`;
|
|
68
|
-
const _GULP_CONFIG_TARGET = `./gulpfile-config.json`;
|
|
69
|
-
console.log(` : Environment set gulp config [${_GULP_CONFIG}] will be copied to [${_GULP_CONFIG_TARGET}]`);
|
|
70
|
-
if (!libFS.existsSync(`./${_GULP_CONFIG}`))
|
|
71
|
-
{
|
|
72
|
-
console.log(`!!!> Enviromnent set gulp config doesn't exist!`);
|
|
73
|
-
process.exit(1);
|
|
74
|
-
}
|
|
75
|
-
else
|
|
76
|
-
{
|
|
77
|
-
libFS.copyFileSync(_GULP_CONFIG, _GULP_CONFIG_TARGET);
|
|
78
|
-
console.log(` > Environment Gulp Config copied`);
|
|
79
|
-
}
|
|
80
|
-
const _BROWSERSLISTRC = `./.browserslistrc_${_GULP_CUSTOM_BUILD_TARGET}`;
|
|
81
|
-
const _BROWSERSLISTRC_TARGET = `./.browserslistrc`;
|
|
82
|
-
console.log(` : Environment set browserslistrc [${_BROWSERSLISTRC}] will be copied to [${_BROWSERSLISTRC_TARGET}]`);
|
|
83
|
-
if (!libFS.existsSync(`./${_GULP_CONFIG}`))
|
|
84
|
-
{
|
|
85
|
-
console.log(`!!!> Enviromnent set browserslistrc doesn't exist!`);
|
|
86
|
-
process.exit(1);
|
|
87
|
-
}
|
|
88
|
-
else
|
|
89
|
-
{
|
|
90
|
-
libFS.copyFileSync(_BROWSERSLISTRC, _BROWSERSLISTRC_TARGET);
|
|
91
|
-
console.log(` > Environment Gulp Config copied`);
|
|
92
|
-
}
|
|
93
|
-
console.log(`---> The browserslistrc compatibility set is: ${libFS.readFileSync(_BROWSERSLISTRC_TARGET, 'utf8')}`);
|
|
94
|
-
// END OF STEP 3 and STEP 4 ABOVE
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
// ---> Now load the config and get on with building <--- \\
|
|
98
|
-
console.log(``);
|
|
99
|
-
console.log(`---> Loading the gulp config...`);
|
|
100
|
-
const _CONFIG = require('./gulpfile-config.json');
|
|
101
|
-
console.log(` > Building to [${_CONFIG.LibraryUniminifiedFileName}] and [${_CONFIG.LibraryMinifiedFileName}]`)
|
|
102
|
-
|
|
103
|
-
// ---> Boilerplate Browser Uglification and Packaging <--- \\
|
|
104
|
-
console.log(``);
|
|
105
|
-
console.log(`--> Gulp is taking over!`);
|
|
106
|
-
|
|
107
|
-
const libBrowserify = require('browserify');
|
|
108
|
-
const libGulp = require('gulp');
|
|
109
|
-
|
|
110
|
-
const libVinylSourceStream = require('vinyl-source-stream');
|
|
111
|
-
const libVinylBuffer = require('vinyl-buffer');
|
|
112
|
-
|
|
113
|
-
const libSourcemaps = require('gulp-sourcemaps');
|
|
114
|
-
const libGulpUtil = require('gulp-util');
|
|
115
|
-
const libBabel = require('gulp-babel');
|
|
116
|
-
const libTerser = require('gulp-terser');
|
|
117
|
-
|
|
118
|
-
// Build the module for the browser
|
|
119
|
-
libGulp.task('minified',
|
|
120
|
-
() => {
|
|
121
|
-
// set up the custom browserify instance for this task
|
|
122
|
-
var tmpBrowserify = libBrowserify(
|
|
123
|
-
{
|
|
124
|
-
entries: _CONFIG.EntrypointInputSourceFile,
|
|
125
|
-
standalone: _CONFIG.LibraryObjectName,
|
|
126
|
-
debug: true
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
return tmpBrowserify.bundle()
|
|
130
|
-
.pipe(libVinylSourceStream(_CONFIG.LibraryMinifiedFileName))
|
|
131
|
-
.pipe(libVinylBuffer())
|
|
132
|
-
.pipe(libSourcemaps.init({loadMaps: true}))
|
|
133
|
-
// Add transformation tasks to the pipeline here.
|
|
134
|
-
.pipe(libBabel({"presets": ["@babel/preset-env"]}))
|
|
135
|
-
.pipe(libTerser())
|
|
136
|
-
.on('error', libGulpUtil.log)
|
|
137
|
-
.pipe(libSourcemaps.write('./'))
|
|
138
|
-
.pipe(libGulp.dest(_CONFIG.LibraryOutputFolder));
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
// Build the module for the browser
|
|
142
|
-
libGulp.task('debug',
|
|
143
|
-
() => {
|
|
144
|
-
// set up the custom browserify instance for this task
|
|
145
|
-
var tmpBrowserify = libBrowserify(
|
|
146
|
-
{
|
|
147
|
-
entries: _CONFIG.EntrypointInputSourceFile,
|
|
148
|
-
standalone: _CONFIG.LibraryObjectName,
|
|
149
|
-
debug: true
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
return tmpBrowserify.bundle()
|
|
153
|
-
.pipe(libVinylSourceStream(_CONFIG.LibraryUniminifiedFileName))
|
|
154
|
-
.pipe(libVinylBuffer())
|
|
155
|
-
.pipe(libBabel({"presets": ["@babel/preset-env"]}))
|
|
156
|
-
.on('error', libGulpUtil.log)
|
|
157
|
-
.pipe(libGulp.dest(_CONFIG.LibraryOutputFolder));
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
libGulp.task
|
|
161
|
-
(
|
|
162
|
-
'build',
|
|
163
|
-
libGulp.series('debug', 'minified')
|
|
164
|
-
);
|
|
1
|
+
require('/Users/steven/Code/retold/modules/fable/fable/node_modules/quackage/gulp/Quackage-Gulpfile.js');
|
package/package.json
CHANGED
|
@@ -1,81 +1,68 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
2
|
+
"name": "fable",
|
|
3
|
+
"version": "3.0.51",
|
|
4
|
+
"description": "An entity behavior management and API bundling library.",
|
|
5
|
+
"main": "source/Fable.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "node source/Fable.js",
|
|
8
|
+
"coverage": "./node_modules/.bin/nyc --reporter=lcov --reporter=text-lcov ./node_modules/mocha/bin/_mocha -- -u tdd -R spec",
|
|
9
|
+
"test": "./node_modules/.bin/mocha -u tdd -R spec",
|
|
10
|
+
"build": "./node_modules/.bin/gulp build",
|
|
11
|
+
"build-compatible": "GULP_CUSTOM_BUILD_TARGET=compatible ./node_modules/.bin/gulp build",
|
|
12
|
+
"docker-dev-build": "docker build ./ -f Dockerfile_LUXURYCode -t fable-image:local",
|
|
13
|
+
"docker-dev-run": "docker run -it -d --name fable-dev -p 30001:8080 -p 38086:8086 -v \"$PWD/.config:/home/coder/.config\" -v \"$PWD:/home/coder/fable\" -u \"$(id -u):$(id -g)\" -e \"DOCKER_USER=$USER\" fable-image:local",
|
|
14
|
+
"docker-dev-shell": "docker exec -it fable-dev /bin/bash"
|
|
15
|
+
},
|
|
16
|
+
"mocha": {
|
|
17
|
+
"diff": true,
|
|
18
|
+
"extension": [
|
|
19
|
+
"js"
|
|
20
|
+
],
|
|
21
|
+
"package": "./package.json",
|
|
22
|
+
"reporter": "spec",
|
|
23
|
+
"slow": "75",
|
|
24
|
+
"timeout": "5000",
|
|
25
|
+
"ui": "tdd",
|
|
26
|
+
"watch-files": [
|
|
27
|
+
"source/**/*.js",
|
|
28
|
+
"test/**/*.js"
|
|
29
|
+
],
|
|
30
|
+
"watch-ignore": [
|
|
31
|
+
"lib/vendor"
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
"browser": {
|
|
35
|
+
"./source/service/Fable-Service-EnvironmentData.js": "./source/service/Fable-Service-EnvironmentData-Web.js",
|
|
36
|
+
"./source/service/Fable-Service-FilePersistence.js": "./source/service/Fable-Service-FilePersistence-Web.js"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "https://github.com/stevenvelozo/fable.git"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"entity",
|
|
44
|
+
"behavior"
|
|
20
45
|
],
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"entity",
|
|
44
|
-
"behavior"
|
|
45
|
-
],
|
|
46
|
-
"author": "Steven Velozo <steven@velozo.com> (http://velozo.com/)",
|
|
47
|
-
"license": "MIT",
|
|
48
|
-
"bugs": {
|
|
49
|
-
"url": "https://github.com/stevenvelozo/fable/issues"
|
|
50
|
-
},
|
|
51
|
-
"homepage": "https://github.com/stevenvelozo/fable",
|
|
52
|
-
"devDependencies": {
|
|
53
|
-
"@babel/core": "^7.21.8",
|
|
54
|
-
"@babel/preset-env": "^7.21.5",
|
|
55
|
-
"browserify": "^17.0.0",
|
|
56
|
-
"chai": "4.3.7",
|
|
57
|
-
"gulp": "^4.0.2",
|
|
58
|
-
"gulp-babel": "^8.0.0",
|
|
59
|
-
"gulp-env": "^0.4.0",
|
|
60
|
-
"gulp-sourcemaps": "^3.0.0",
|
|
61
|
-
"gulp-terser": "^2.1.0",
|
|
62
|
-
"gulp-util": "^3.0.8",
|
|
63
|
-
"mocha": "10.2.0",
|
|
64
|
-
"nyc": "^15.1.0",
|
|
65
|
-
"retold-data-service": "^1.0.3",
|
|
66
|
-
"vinyl-buffer": "^1.0.1",
|
|
67
|
-
"vinyl-source-stream": "^2.0.0"
|
|
68
|
-
},
|
|
69
|
-
"dependencies": {
|
|
70
|
-
"async.eachlimit": "^0.5.2",
|
|
71
|
-
"async.waterfall": "^0.5.2",
|
|
72
|
-
"cachetrax": "^1.0.3",
|
|
73
|
-
"data-arithmatic": "^1.0.7",
|
|
74
|
-
"fable-log": "^3.0.10",
|
|
75
|
-
"fable-serviceproviderbase": "^3.0.5",
|
|
76
|
-
"fable-settings": "^3.0.6",
|
|
77
|
-
"fable-uuid": "^3.0.5",
|
|
78
|
-
"manyfest": "^1.0.24",
|
|
79
|
-
"simple-get": "^4.0.1"
|
|
80
|
-
}
|
|
46
|
+
"author": "Steven Velozo <steven@velozo.com> (http://velozo.com/)",
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/stevenvelozo/fable/issues"
|
|
50
|
+
},
|
|
51
|
+
"homepage": "https://github.com/stevenvelozo/fable",
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"retold-data-service": "^1.0.3"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"async.eachlimit": "^0.5.2",
|
|
57
|
+
"async.waterfall": "^0.5.2",
|
|
58
|
+
"cachetrax": "^1.0.3",
|
|
59
|
+
"data-arithmatic": "^1.0.7",
|
|
60
|
+
"fable-log": "^3.0.10",
|
|
61
|
+
"fable-serviceproviderbase": "^3.0.5",
|
|
62
|
+
"fable-settings": "^3.0.6",
|
|
63
|
+
"fable-uuid": "^3.0.5",
|
|
64
|
+
"manyfest": "^1.0.24",
|
|
65
|
+
"quackage": "^1.0.6",
|
|
66
|
+
"simple-get": "^4.0.1"
|
|
67
|
+
}
|
|
81
68
|
}
|
package/source/Fable.js
CHANGED
|
@@ -45,7 +45,9 @@ class Fable
|
|
|
45
45
|
this.serviceManager.addAndInstantiateServiceType('EnvironmentData', require('./services/Fable-Service-EnvironmentData.js'));
|
|
46
46
|
this.serviceManager.addServiceType('Template', require('./services/Fable-Service-Template.js'));
|
|
47
47
|
this.serviceManager.addServiceType('MetaTemplate', require('./services/Fable-Service-MetaTemplate.js'));
|
|
48
|
+
this.serviceManager.addServiceType('Anticipate', require('./services/Fable-Service-Anticipate.js'));
|
|
48
49
|
this.serviceManager.addAndInstantiateServiceType('DataFormat', require('./services/Fable-Service-DataFormat.js'));
|
|
50
|
+
this.serviceManager.addAndInstantiateServiceType('DataGeneration', require('./services/Fable-Service-DataGeneration.js'));
|
|
49
51
|
this.serviceManager.addAndInstantiateServiceType('Utility', require('./services/Fable-Service-Utility.js'));
|
|
50
52
|
this.serviceManager.addServiceType('Operation', require('./services/Fable-Service-Operation.js'));
|
|
51
53
|
this.serviceManager.addServiceType('RestClient', require('./services/Fable-Service-RestClient.js'));
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const libFableServiceBase = require('../Fable-ServiceManager.js').ServiceProviderBase;
|
|
2
|
+
|
|
3
|
+
class FableServiceAnticipate extends libFableServiceBase
|
|
4
|
+
{
|
|
5
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
6
|
+
{
|
|
7
|
+
super(pFable, pOptions, pServiceHash);
|
|
8
|
+
|
|
9
|
+
this.serviceType = 'AsyncAnticipate';
|
|
10
|
+
|
|
11
|
+
// The queue of operations waiting to run.
|
|
12
|
+
this.operationQueue = [];
|
|
13
|
+
this.erroredOperations = [];
|
|
14
|
+
|
|
15
|
+
this.executingOperationCount = 0;
|
|
16
|
+
this.completedOperationCount = 0;
|
|
17
|
+
|
|
18
|
+
this.maxOperations = 1;
|
|
19
|
+
|
|
20
|
+
this.lastError = undefined;
|
|
21
|
+
|
|
22
|
+
this.waitingFunctions = [];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
checkQueue()
|
|
26
|
+
{
|
|
27
|
+
// This checks to see if we need to start any operations.
|
|
28
|
+
if (this.operationQueue.length > 0 && this.executingOperationCount < this.maxOperations)
|
|
29
|
+
{
|
|
30
|
+
let tmpOperation = this.operationQueue.shift();
|
|
31
|
+
this.executingOperationCount += 1;
|
|
32
|
+
tmpOperation(this.buildAnticipatorCallback());
|
|
33
|
+
}
|
|
34
|
+
else if (this.waitingFunctions.length > 0 && this.executingOperationCount < 1)
|
|
35
|
+
{
|
|
36
|
+
// If there are no operations left, and we have waiting functions, call them.
|
|
37
|
+
for (let i = 0; i < this.waitingFunctions.length; i++)
|
|
38
|
+
{
|
|
39
|
+
this.waitingFunctions[i](this.lastError);
|
|
40
|
+
}
|
|
41
|
+
// Reset our state
|
|
42
|
+
this.lastError = undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Expects a function fAsynchronousFunction(fCallback)
|
|
47
|
+
anticipate(fAsynchronousFunction)
|
|
48
|
+
{
|
|
49
|
+
this.operationQueue.push(fAsynchronousFunction);
|
|
50
|
+
this.checkQueue();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
buildAnticipatorCallback()
|
|
54
|
+
{
|
|
55
|
+
// This uses closure-scoped state to track the callback state
|
|
56
|
+
let tmpCallbackState = (
|
|
57
|
+
{
|
|
58
|
+
Called: false,
|
|
59
|
+
Error: undefined,
|
|
60
|
+
OperationSet: this
|
|
61
|
+
});
|
|
62
|
+
return hoistedCallback;
|
|
63
|
+
function hoistedCallback(pError)
|
|
64
|
+
{
|
|
65
|
+
if (tmpCallbackState.Called)
|
|
66
|
+
{
|
|
67
|
+
// If they call the callback twice, throw an error
|
|
68
|
+
throw new Error("Anticipation async callback called twice...");
|
|
69
|
+
}
|
|
70
|
+
tmpCallbackState.Called = true;
|
|
71
|
+
tmpCallbackState.error = pError;
|
|
72
|
+
|
|
73
|
+
tmpCallbackState.OperationSet.executingOperationCount -= 1;
|
|
74
|
+
tmpCallbackState.OperationSet.completedOperationCount += 1;
|
|
75
|
+
|
|
76
|
+
tmpCallbackState.OperationSet.checkQueue();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
wait(fCallback)
|
|
81
|
+
{
|
|
82
|
+
this.waitingFunctions.push(fCallback);
|
|
83
|
+
this.checkQueue();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
module.exports = FableServiceAnticipate;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"DefaultIntegerMinimum": 0,
|
|
3
|
+
"DefaultIntegerMaximum": 9999999,
|
|
4
|
+
|
|
5
|
+
"DefaultNumericStringLength": 10,
|
|
6
|
+
|
|
7
|
+
"MonthSet": ["January","February","March","April","May","June","July","August","September","October","November","December"],
|
|
8
|
+
|
|
9
|
+
"WeekDaySet":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],
|
|
10
|
+
|
|
11
|
+
"ColorSet":
|
|
12
|
+
[
|
|
13
|
+
"Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet", "Pink", "Purple", "Turquoise", "Gold",
|
|
14
|
+
"Lime", "Maroon", "Navy", "Coral", "Teal", "Brown", "White", "Black", "Sky", "Berry",
|
|
15
|
+
"Grey", "Straw", "Silver", "Sapphire"
|
|
16
|
+
],
|
|
17
|
+
|
|
18
|
+
"SurNameSet":
|
|
19
|
+
[
|
|
20
|
+
"Smith", "Johnson", "Williams", "Brown", "Jones", "Miller", "Davis", "Garcia", "Rodriguez", "Wilson",
|
|
21
|
+
"Martinez", "Anderson", "Taylor", "Thomas", "Hernandez", "Moore", "Martin", "Jackson", "Thompson", "White",
|
|
22
|
+
"Lopez", "Lee", "Gonzalez", "Harris", "Clark", "Lewis", "Robinson", "Walker", "Perez", "Hall",
|
|
23
|
+
"Young", "Allen", "Sanchez", "Wright", "King", "Scott", "Green", "Baker", "Adams", "Nelson",
|
|
24
|
+
"Hill", "Ramirez", "Campbell", "Mitchell", "Roberts", "Carter", "Phillips", "Evans", "Turner", "Torres",
|
|
25
|
+
"Parker", "Collins", "Edwards", "Stewart", "Flores", "Morris", "Nguyen", "Murphy", "Rivera", "Cook",
|
|
26
|
+
"Rogers", "Morgan", "Peterson", "Cooper", "Reed", "Bailey", "Bell", "Gomez", "Kelly", "Howard",
|
|
27
|
+
"Ward", "Cox", "Diaz", "Richardson", "Wood", "Watson", "Brooks", "Bennett", "Gray", "James",
|
|
28
|
+
"Reyes", "Cruz", "Hughes", "Price", "Myers", "Long", "Foster", "Sanders", "Ross", "Morales",
|
|
29
|
+
"Powell", "Sullivan", "Russell", "Ortiz", "Jenkins", "Gutierrez", "Perry", "Butler", "Barnes", "Fisher"
|
|
30
|
+
],
|
|
31
|
+
|
|
32
|
+
"NameSet":
|
|
33
|
+
[
|
|
34
|
+
"Mary", "Patricia", "Jennifer", "Linda", "Elizabeth", "Barbara", "Susan", "Jessica", "Sarah", "Karen",
|
|
35
|
+
"Lisa", "Nancy", "Betty", "Sandra", "Margaret", "Ashley", "Kimberly", "Emily", "Donna", "Michelle",
|
|
36
|
+
"Carol", "Amanda", "Melissa", "Deborah", "Stephanie", "Dorothy", "Rebecca", "Sharon", "Laura", "Cynthia",
|
|
37
|
+
"Amy", "Kathleen", "Angela", "Shirley", "Brenda", "Emma", "Anna", "Pamela", "Nicole", "Samantha",
|
|
38
|
+
"Katherine", "Christine", "Helen", "Debra", "Rachel", "Carolyn", "Janet", "Maria", "Catherine", "Heather",
|
|
39
|
+
"Diane", "Olivia", "Julie", "Joyce", "Victoria", "Ruth", "Virginia", "Lauren", "Kelly", "Christina",
|
|
40
|
+
"Joan", "Evelyn", "Judith", "Andrea", "Hannah", "Megan", "Cheryl", "Jacqueline", "Martha", "Madison",
|
|
41
|
+
"Teresa", "Gloria", "Sara", "Janice", "Ann", "Kathryn", "Abigail", "Sophia", "Frances", "Jean",
|
|
42
|
+
"Alice", "Judy", "Isabella", "Julia", "Grace", "Amber", "Denise", "Danielle", "Marilyn", "Beverly",
|
|
43
|
+
"Charlotte", "Natalie", "Theresa", "Diana", "Brittany", "Doris", "Kayla", "Alexis", "Lori", "Marie",
|
|
44
|
+
"James", "Robert", "John", "Michael", "David", "William", "Richard", "Joseph", "Thomas", "Christopher",
|
|
45
|
+
"Charles", "Daniel", "Matthew", "Anthony", "Mark", "Donald", "Steven", "Andrew", "Paul", "Joshua",
|
|
46
|
+
"Kenneth", "Kevin", "Brian", "George", "Timothy", "Ronald", "Jason", "Edward", "Jeffrey", "Ryan",
|
|
47
|
+
"Jacob", "Gary", "Nicholas", "Eric", "Jonathan", "Stephen", "Larry", "Justin", "Scott", "Brandon",
|
|
48
|
+
"Benjamin", "Samuel", "Gregory", "Alexander", "Patrick", "Frank", "Raymond", "Jack", "Dennis", "Jerry",
|
|
49
|
+
"Tyler", "Aaron", "Jose", "Adam", "Nathan", "Henry", "Zachary", "Douglas", "Peter", "Kyle",
|
|
50
|
+
"Noah", "Ethan", "Jeremy", "Walter", "Christian", "Keith", "Roger", "Terry", "Austin", "Sean",
|
|
51
|
+
"Gerald", "Carl", "Harold", "Dylan", "Arthur", "Lawrence", "Jordan", "Jesse", "Bryan", "Billy",
|
|
52
|
+
"Bruce", "Gabriel", "Joe", "Logan", "Alan", "Juan", "Albert", "Willie", "Elijah", "Wayne",
|
|
53
|
+
"Randy", "Vincent", "Mason", "Roy", "Ralph", "Bobby", "Russell", "Bradley", "Philip", "Eugene"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const libFableServiceBase = require('../Fable-ServiceManager.js').ServiceProviderBase;
|
|
2
|
+
|
|
3
|
+
class FableServiceDataGeneration extends libFableServiceBase
|
|
4
|
+
{
|
|
5
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
6
|
+
{
|
|
7
|
+
super(pFable, pOptions, pServiceHash);
|
|
8
|
+
|
|
9
|
+
this.serviceType = 'DataGeneration';
|
|
10
|
+
|
|
11
|
+
this.defaultData = require('./Fable-Service-DataGeneration-DefaultValues.json');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Return a random integer between pMinimum and pMaximum
|
|
15
|
+
randomIntegerBetween(pMinimum, pMaximum)
|
|
16
|
+
{
|
|
17
|
+
return Math.floor(Math.random() * (pMaximum - pMinimum + 1)) + pMinimum;
|
|
18
|
+
}
|
|
19
|
+
// Return a random integer up to the passed-in maximum
|
|
20
|
+
randomIntegerUpTo(pMaximum)
|
|
21
|
+
{
|
|
22
|
+
return this.randomIntegerBetween(0, pMaximum);
|
|
23
|
+
}
|
|
24
|
+
// Return a random integer between 0 and 9999999
|
|
25
|
+
randomInteger()
|
|
26
|
+
{
|
|
27
|
+
return Math.floor(Math.random()*this.defaultData.DefaultIntegerMaximum);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
randomNumericString(pLength, pMaxNumber)
|
|
32
|
+
{
|
|
33
|
+
let tmpLength = (typeof(pLength) === 'undefined') ? 10 : pLength;
|
|
34
|
+
let tmpMaxNumber = (typeof(pMaxNumber) === 'undefined') ? ((10 ** tmpLength) - 1) : pMaxNumber;
|
|
35
|
+
|
|
36
|
+
return this.defaultServices.DataFormat.stringPadStart(this.randomIntegerUpTo(tmpMaxNumber), pLength, '0');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
randomMonth()
|
|
41
|
+
{
|
|
42
|
+
return this.defaultData.MonthSet[this.randomIntegerUpTo(this.defaultData.MonthSet.length-1)];
|
|
43
|
+
}
|
|
44
|
+
randomDayOfWeek()
|
|
45
|
+
{
|
|
46
|
+
return this.defaultData.WeekDaySet[this.randomIntegerUpTo(this.defaultData.WeekDaySet.length-1)];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
randomColor()
|
|
51
|
+
{
|
|
52
|
+
return this.defaultData.ColorSet[this.randomIntegerUpTo(this.defaultData.ColorSet.length-1)];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
randomName()
|
|
57
|
+
{
|
|
58
|
+
return this.defaultData.NameSet[this.randomIntegerUpTo(this.defaultData.NameSet.length-1)];
|
|
59
|
+
}
|
|
60
|
+
randomSurname()
|
|
61
|
+
{
|
|
62
|
+
return this.defaultData.SurNameSet[this.randomIntegerUpTo(this.defaultData.SurNameSet.length-1)];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
module.exports = FableServiceDataGeneration;
|
|
@@ -16,8 +16,16 @@ class FableServiceFilePersistence extends libFableServiceBase
|
|
|
16
16
|
{
|
|
17
17
|
this.options.Mode = parseInt('0777', 8) & ~process.umask();
|
|
18
18
|
}
|
|
19
|
+
|
|
20
|
+
this.currentInputFolder = `/tmp`;
|
|
21
|
+
this.currentOutputFolder = `/tmp`;
|
|
19
22
|
}
|
|
20
23
|
|
|
24
|
+
joinPath(pPathArray)
|
|
25
|
+
{
|
|
26
|
+
return libPath.resolve(...pPathArray);
|
|
27
|
+
}
|
|
28
|
+
|
|
21
29
|
existsSync(pPath)
|
|
22
30
|
{
|
|
23
31
|
return libFS.existsSync(pPath);
|
|
@@ -30,6 +38,63 @@ class FableServiceFilePersistence extends libFableServiceBase
|
|
|
30
38
|
return fCallback(null, tmpFileExists);
|
|
31
39
|
}
|
|
32
40
|
|
|
41
|
+
writeFileSync(pFileName, pFileContent, pOptions)
|
|
42
|
+
{
|
|
43
|
+
let tmpOptions = (typeof(pOptions) === 'undefined') ? 'utf8' : pOptions;
|
|
44
|
+
libFS.writeFileSync(pFileName, pFileContent, tmpOptions);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
appendFileSync(pFileName, pAppendContent, pOptions)
|
|
48
|
+
{
|
|
49
|
+
let tmpOptions = (typeof(pOptions) === 'undefined') ? 'utf8' : pOptions;
|
|
50
|
+
libFS.appendFileSync(pFileName, pAppendContent, tmpOptions);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
writeFileSyncFromObject(pFileName, pObject)
|
|
54
|
+
{
|
|
55
|
+
this.writeFileSync(pFileName, JSON.stringify(pObject, null, 4));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
writeFileSyncFromArray(pFileName, pFileArray)
|
|
59
|
+
{
|
|
60
|
+
if (!Array.isArray(pFileArray))
|
|
61
|
+
{
|
|
62
|
+
this.log.error(`File Persistence Service attempted to write ${pFileName} from array but the expected array was not an array (it was a ${typeof(pFileArray)}).`);
|
|
63
|
+
return Error('Attempted to write ${pFileName} from array but the expected array was not an array (it was a ${typeof(pFileArray)}).');
|
|
64
|
+
}
|
|
65
|
+
else
|
|
66
|
+
{
|
|
67
|
+
for (let i = 0; i < pFileArray.length; i++)
|
|
68
|
+
{
|
|
69
|
+
this.appendFileSync(pFileName, `${pFileArray[i]}\n`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Default folder behaviors
|
|
75
|
+
|
|
76
|
+
getDefaultOutputPath(pFileName)
|
|
77
|
+
{
|
|
78
|
+
return libPath.join(this.currentOutputFolder, pFileName);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
dataFolderWriteSync(pFileName, pFileContent)
|
|
82
|
+
{
|
|
83
|
+
return this.writeFileSync(this.getDefaultOutputPath(pFileName), pFileContent);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
dataFolderWriteSyncFromObject(pFileName, pObject)
|
|
87
|
+
{
|
|
88
|
+
return this.writeFileSyncFromObject(this.getDefaultOutputPath(pFileName), pObject);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
dataFolderWriteSyncFromArray(pFileName, pFileArray)
|
|
92
|
+
{
|
|
93
|
+
return this.writeFileSyncFromArray(this.getDefaultOutputPath(pFileName), pFileArray);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Folder management
|
|
97
|
+
|
|
33
98
|
makeFolderRecursive (pParameters, fCallback)
|
|
34
99
|
{
|
|
35
100
|
let tmpParameters = pParameters;
|
|
@@ -88,7 +153,7 @@ class FableServiceFilePersistence extends libFableServiceBase
|
|
|
88
153
|
return true;
|
|
89
154
|
}
|
|
90
155
|
|
|
91
|
-
// Check if the path exists
|
|
156
|
+
// Check if the path exists (and is a folder)
|
|
92
157
|
libFS.open(tmpParameters.CurrentPath + libPath.sep + tmpParameters.ActualPathParts[tmpParameters.CurrentPathIndex], 'r',
|
|
93
158
|
function(pError, pFileDescriptor)
|
|
94
159
|
{
|