quackage 1.0.45 → 1.0.47
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/.quackage-templates.json +3 -3
- package/README.md +6 -0
- package/debug/Harness.js +1 -1
- package/package.json +4 -3
- package/source/Default-Quackage-Configuration.json +4 -1
- package/source/Quackage-CLIProgram.js +12 -1
- package/source/commands/Quackage-Command-Build.js +0 -1
- package/source/commands/Quackage-Command-BuildTemplates.js +0 -1
- package/source/commands/Quackage-Command-CopyFilesFromTo.js +1 -0
- package/source/commands/Quackage-Command-DocuserveInject.js +90 -0
- package/source/commands/Quackage-Command-DocuserveServe.js +79 -0
- package/source/commands/Quackage-Command-GenerateDocumentation.js +136 -2
- package/source/commands/Quackage-Command-Indoctrinate.js +88 -0
- package/source/commands/Quackage-Command-IndoctrinateIndex.js +83 -0
- package/source/commands/Quackage-Command-ListTemplates.js +1 -0
- package/source/commands/Quackage-Command-PrepareDocs.js +156 -0
- package/source/commands/Quackage-Command-RunMochaTests.js +1 -3
- package/source/commands/Quackage-Command-UpdatePackage-Luxury.js +1 -1
- package/source/commands/Quackage-Command-UpdatePackage.js +1 -1
- package/source/commands/stricture/Quackage-Command-Stricture-Compile.js +37 -0
- package/source/commands/stricture/Quackage-Command-StrictureLegacy.js +37 -0
- package/source/commands/stricture/services/Fable-Service-Stricture-Compile.js +327 -0
- package/templates/fableservice/{Fable-Service.js → Fable-Service-QUACKAGESCOPE.js} +4 -5
- package/source/commands/Quackage-JSDoc-Wrapper.js +0 -147
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
const libCommandLineCommand = require('pict-service-commandlineutility').ServiceCommandLineCommand;
|
|
2
|
+
const libFS = require('fs');
|
|
3
|
+
const libPath = require('path');
|
|
4
|
+
|
|
5
|
+
class QuackageCommandPrepareDocs extends libCommandLineCommand
|
|
6
|
+
{
|
|
7
|
+
constructor(pFable, pManifest, pServiceHash)
|
|
8
|
+
{
|
|
9
|
+
super(pFable, pManifest, pServiceHash);
|
|
10
|
+
|
|
11
|
+
this.options.CommandKeyword = 'prepare-docs';
|
|
12
|
+
this.options.Description = 'Prepare documentation: generate catalog, build keyword index and inject pict-docuserve assets.';
|
|
13
|
+
|
|
14
|
+
this.options.CommandArguments.push({ Name: '<docs_folder>', Description: 'The documentation folder to prepare.' });
|
|
15
|
+
|
|
16
|
+
this.options.CommandOptions.push({ Name: '-d, --directory_root [directory_root]', Description: 'Root directory to scan for modules (defaults to CWD).', Default: '' });
|
|
17
|
+
this.options.CommandOptions.push({ Name: '-b, --branch [branch]', Description: 'Git branch for GitHub raw URLs (defaults to master).', Default: 'master' });
|
|
18
|
+
this.options.CommandOptions.push({ Name: '-g, --github_org [github_org]', Description: 'GitHub organization for raw URLs (defaults to stevenvelozo).', Default: 'stevenvelozo' });
|
|
19
|
+
|
|
20
|
+
this.options.Aliases.push('docs');
|
|
21
|
+
this.options.Aliases.push('prep-docs');
|
|
22
|
+
|
|
23
|
+
this.addCommand();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
onRunAsync(fCallback)
|
|
27
|
+
{
|
|
28
|
+
let tmpDocsFolder = libPath.resolve(this.ArgumentString || '.');
|
|
29
|
+
let tmpDirectoryRoot = this.CommandOptions.directory_root || this.fable.AppData.CWD;
|
|
30
|
+
let tmpBranch = this.CommandOptions.branch || 'master';
|
|
31
|
+
let tmpGitHubOrg = this.CommandOptions.github_org || 'stevenvelozo';
|
|
32
|
+
|
|
33
|
+
this.log.info(`Preparing documentation in [${tmpDocsFolder}]...`);
|
|
34
|
+
|
|
35
|
+
// Ensure the output folder exists
|
|
36
|
+
if (!libFS.existsSync(tmpDocsFolder))
|
|
37
|
+
{
|
|
38
|
+
this.log.info(`Creating documentation folder [${tmpDocsFolder}]...`);
|
|
39
|
+
libFS.mkdirSync(tmpDocsFolder, { recursive: true });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Find the executables we need
|
|
43
|
+
let tmpIndoctrinateLocation = this.resolveExecutable('indoctrinate');
|
|
44
|
+
if (!tmpIndoctrinateLocation)
|
|
45
|
+
{
|
|
46
|
+
return fCallback(new Error(`Could not find indoctrinate. Make sure it is installed (npm install indoctrinate).`));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let tmpDocuserveLocation = this.resolveExecutable('pict-docuserve');
|
|
50
|
+
if (!tmpDocuserveLocation)
|
|
51
|
+
{
|
|
52
|
+
return fCallback(new Error(`Could not find pict-docuserve. Make sure it is installed (npm install pict-docuserve).`));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let tmpCatalogFile = libPath.join(tmpDocsFolder, 'retold-catalog.json');
|
|
56
|
+
let tmpKeywordIndexFile = libPath.join(tmpDocsFolder, 'retold-keyword-index.json');
|
|
57
|
+
|
|
58
|
+
let tmpAnticipate = this.fable.newAnticipate();
|
|
59
|
+
|
|
60
|
+
// Step 1: Generate the documentation catalog
|
|
61
|
+
tmpAnticipate.anticipate(
|
|
62
|
+
function (fNext)
|
|
63
|
+
{
|
|
64
|
+
this.log.info(`###############################[ STEP 1: INDOCTRINATE CATALOG ]###############################`);
|
|
65
|
+
this.fable.QuackageProcess.execute(
|
|
66
|
+
tmpIndoctrinateLocation,
|
|
67
|
+
[
|
|
68
|
+
'generate_catalog',
|
|
69
|
+
'-d', tmpDirectoryRoot,
|
|
70
|
+
'-o', tmpCatalogFile,
|
|
71
|
+
'-b', tmpBranch,
|
|
72
|
+
'-g', tmpGitHubOrg
|
|
73
|
+
],
|
|
74
|
+
{ cwd: this.fable.AppData.CWD },
|
|
75
|
+
fNext
|
|
76
|
+
);
|
|
77
|
+
}.bind(this));
|
|
78
|
+
|
|
79
|
+
// Step 2: Generate the keyword search index
|
|
80
|
+
tmpAnticipate.anticipate(
|
|
81
|
+
function (fNext)
|
|
82
|
+
{
|
|
83
|
+
this.log.info(`###############################[ STEP 2: KEYWORD INDEX ]###############################`);
|
|
84
|
+
this.fable.QuackageProcess.execute(
|
|
85
|
+
tmpIndoctrinateLocation,
|
|
86
|
+
[
|
|
87
|
+
'generate_keyword_index',
|
|
88
|
+
'-d', tmpDirectoryRoot,
|
|
89
|
+
'-o', tmpKeywordIndexFile
|
|
90
|
+
],
|
|
91
|
+
{ cwd: this.fable.AppData.CWD },
|
|
92
|
+
fNext
|
|
93
|
+
);
|
|
94
|
+
}.bind(this));
|
|
95
|
+
|
|
96
|
+
// Step 3: Inject pict-docuserve assets
|
|
97
|
+
tmpAnticipate.anticipate(
|
|
98
|
+
function (fNext)
|
|
99
|
+
{
|
|
100
|
+
this.log.info(`###############################[ STEP 3: DOCUSERVE INJECT ]###############################`);
|
|
101
|
+
this.fable.QuackageProcess.execute(
|
|
102
|
+
tmpDocuserveLocation,
|
|
103
|
+
[
|
|
104
|
+
'inject',
|
|
105
|
+
tmpDocsFolder
|
|
106
|
+
],
|
|
107
|
+
{ cwd: this.fable.AppData.CWD },
|
|
108
|
+
fNext
|
|
109
|
+
);
|
|
110
|
+
}.bind(this));
|
|
111
|
+
|
|
112
|
+
return tmpAnticipate.wait(
|
|
113
|
+
function (pError)
|
|
114
|
+
{
|
|
115
|
+
if (pError)
|
|
116
|
+
{
|
|
117
|
+
this.log.error(`Documentation preparation failed: ${pError.message}`);
|
|
118
|
+
return fCallback(pError);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Ensure .nojekyll exists for GitHub Pages compatibility
|
|
122
|
+
let tmpNoJekyllPath = libPath.join(tmpDocsFolder, '.nojekyll');
|
|
123
|
+
libFS.writeFileSync(tmpNoJekyllPath, '');
|
|
124
|
+
this.log.info(`Wrote .nojekyll to [${tmpNoJekyllPath}]`);
|
|
125
|
+
|
|
126
|
+
this.log.info(`Documentation preparation complete!`);
|
|
127
|
+
this.log.info(` Catalog: ${tmpCatalogFile}`);
|
|
128
|
+
this.log.info(` Keyword Index: ${tmpKeywordIndexFile}`);
|
|
129
|
+
this.log.info(` Docuserve assets injected into: ${tmpDocsFolder}`);
|
|
130
|
+
|
|
131
|
+
return fCallback();
|
|
132
|
+
}.bind(this));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
resolveExecutable(pName)
|
|
136
|
+
{
|
|
137
|
+
let tmpLocations =
|
|
138
|
+
[
|
|
139
|
+
`${this.fable.AppData.CWD}/node_modules/.bin/${pName}`,
|
|
140
|
+
`${__dirname}/../../../.bin/${pName}`,
|
|
141
|
+
`${__dirname}/../../node_modules/.bin/${pName}`
|
|
142
|
+
];
|
|
143
|
+
|
|
144
|
+
for (let i = 0; i < tmpLocations.length; i++)
|
|
145
|
+
{
|
|
146
|
+
if (libFS.existsSync(tmpLocations[i]))
|
|
147
|
+
{
|
|
148
|
+
return tmpLocations[i];
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
module.exports = QuackageCommandPrepareDocs;
|
|
@@ -9,12 +9,10 @@ class QuackageCommandBuild extends libCommandLineCommand
|
|
|
9
9
|
|
|
10
10
|
this.options.CommandKeyword = 'run-mocha-tests';
|
|
11
11
|
this.options.Description = 'Run mocha tests in your tests/ folder.';
|
|
12
|
+
this.options.Aliases.push('test');
|
|
12
13
|
|
|
13
14
|
this.options.CommandOptions.push({ Name: '-g, --grep [search_expression]', Description: 'A grep search expression for the subset of tests you want to run.' });
|
|
14
15
|
|
|
15
|
-
this.options.Aliases.push('test');
|
|
16
|
-
|
|
17
|
-
// Auto add the command on initialization
|
|
18
16
|
this.addCommand();
|
|
19
17
|
}
|
|
20
18
|
|
|
@@ -9,6 +9,7 @@ class QuackageCommandUpdatePackage extends libCommandLineCommand
|
|
|
9
9
|
|
|
10
10
|
this.options.CommandKeyword = 'luxuryupdatepackage';
|
|
11
11
|
this.options.Description = 'Update your package.json to build and run luxury code containers';
|
|
12
|
+
this.options.Aliases.push('luxury_update_package');
|
|
12
13
|
|
|
13
14
|
this.fable.TemplateProvider.addTemplate('PrototypePackage', JSON.stringify(this.pict.ProgramConfiguration, null, 4));
|
|
14
15
|
|
|
@@ -16,7 +17,6 @@ class QuackageCommandUpdatePackage extends libCommandLineCommand
|
|
|
16
17
|
|
|
17
18
|
this.options.Aliases.push('lux');
|
|
18
19
|
|
|
19
|
-
// Auto add the command on initialization
|
|
20
20
|
this.addCommand();
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -9,12 +9,12 @@ class QuackageCommandUpdatePackage extends libCommandLineCommand
|
|
|
9
9
|
|
|
10
10
|
this.options.CommandKeyword = 'updatepackage';
|
|
11
11
|
this.options.Description = 'Update your package.json to support streamlined testing, building and coverage';
|
|
12
|
+
this.options.Aliases.push('update_package');
|
|
12
13
|
|
|
13
14
|
this.fable.TemplateProvider.addTemplate('PrototypePackage', JSON.stringify(this.pict.ProgramConfiguration, null, 4));
|
|
14
15
|
|
|
15
16
|
this.options.CommandOptions.push({ Name: '-f, --force', Description: 'Force overwrite anything in the package.json; use at your own quacking peril' });
|
|
16
17
|
|
|
17
|
-
// Auto add the command on initialization
|
|
18
18
|
this.addCommand();
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const libCommandLineCommand = require('pict-service-commandlineutility').ServiceCommandLineCommand;
|
|
2
|
+
|
|
3
|
+
const libFS = require('fs');
|
|
4
|
+
const libPath = require('path');
|
|
5
|
+
|
|
6
|
+
class QuackageCommandStrictureCompile extends libCommandLineCommand
|
|
7
|
+
{
|
|
8
|
+
constructor(pFable, pManifest, pServiceHash)
|
|
9
|
+
{
|
|
10
|
+
super(pFable, pManifest, pServiceHash);
|
|
11
|
+
|
|
12
|
+
this.options.CommandKeyword = 'stricture-compile';
|
|
13
|
+
this.options.Description = 'Compile stricture ddl into a meadow schema file.';
|
|
14
|
+
|
|
15
|
+
this.options.CommandArguments.push({ Name: '<output_folder>', Description: 'The folder in which to generate content' });
|
|
16
|
+
|
|
17
|
+
this.options.CommandOptions.push({ Name: '-m, --markdown [markdown_documentation_folder]', Description: 'Folder with markdwon documentation; subfolders are okay.', Default: '' });
|
|
18
|
+
|
|
19
|
+
this.options.Aliases.push('scomp');
|
|
20
|
+
|
|
21
|
+
this.addCommand();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
onRunAsync(fCallback)
|
|
25
|
+
{
|
|
26
|
+
const libFilePersistence = this.services.FilePersistence;
|
|
27
|
+
|
|
28
|
+
const tmpOperationState = {};
|
|
29
|
+
tmpOperationState.RawOutputFolderPath = this.ArgumentString;
|
|
30
|
+
|
|
31
|
+
tmpOperationState.RawSourceCodeFolder = this.CommandOptions.source;
|
|
32
|
+
|
|
33
|
+
return fCallback();
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = QuackageCommandStrictureCompile;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const libCommandLineCommand = require('pict-service-commandlineutility').ServiceCommandLineCommand;
|
|
2
|
+
|
|
3
|
+
const libFS = require('fs');
|
|
4
|
+
const libPath = require('path');
|
|
5
|
+
|
|
6
|
+
class QuackageCommandStrictureLegacy extends libCommandLineCommand
|
|
7
|
+
{
|
|
8
|
+
constructor(pFable, pManifest, pServiceHash)
|
|
9
|
+
{
|
|
10
|
+
super(pFable, pManifest, pServiceHash);
|
|
11
|
+
|
|
12
|
+
this.options.CommandKeyword = 'stricture-legaacy';
|
|
13
|
+
this.options.Description = 'Run a legacy stricture command.';
|
|
14
|
+
|
|
15
|
+
this.options.CommandArguments.push({ Name: '<output_folder>', Description: 'The folder in which to generate content' });
|
|
16
|
+
|
|
17
|
+
this.options.CommandOptions.push({ Name: '-m, --markdown [markdown_documentation_folder]', Description: 'Folder with markdwon documentation; subfolders are okay.', Default: '' });
|
|
18
|
+
|
|
19
|
+
this.options.Aliases.push('str');
|
|
20
|
+
|
|
21
|
+
this.addCommand();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
onRunAsync(fCallback)
|
|
25
|
+
{
|
|
26
|
+
const libFilePersistence = this.services.FilePersistence;
|
|
27
|
+
|
|
28
|
+
const tmpOperationState = {};
|
|
29
|
+
tmpOperationState.RawOutputFolderPath = this.ArgumentString;
|
|
30
|
+
|
|
31
|
+
tmpOperationState.RawSourceCodeFolder = this.CommandOptions.source;
|
|
32
|
+
|
|
33
|
+
return fCallback();
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = QuackageCommandStrictureLegacy;
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
// Eventually to be moved to the stricture package
|
|
2
|
+
|
|
3
|
+
const libFableServiceProviderBase = require('fable-serviceproviderbase');
|
|
4
|
+
|
|
5
|
+
var libFS = require('fs');
|
|
6
|
+
var libPath = require('path');
|
|
7
|
+
var libLineReader = require('line-by-line');
|
|
8
|
+
var libJSONFile = require('jsonfile');
|
|
9
|
+
var libUnderscore = require('underscore');
|
|
10
|
+
var libAsync = require('async');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Stricture MicroDDL Compiler
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
// ## Load the default state for meadow and pict configuration settings
|
|
17
|
+
var _DefaultAPIDefinitions = require(__dirname + '/Meadow-Endpoints-Definition-Defaults.js')
|
|
18
|
+
var _DefaultAPISecurity = require(__dirname + '/Meadow-Endpoints-Security-Defaults.js');
|
|
19
|
+
|
|
20
|
+
var _DefaultPict = require(__dirname + '/Pict-Configuration-Defaults.js');
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
const _DefaultOptions = (
|
|
24
|
+
{
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
class StrictureCompiler extends libFableServiceProviderBase
|
|
28
|
+
{
|
|
29
|
+
/**
|
|
30
|
+
* @param {import('fable')} pFable - The fable instance.
|
|
31
|
+
* @param {Object<String, any>} [pOptions] - The options for the client.
|
|
32
|
+
* @param {String} [pServiceHash] - A service hash for the fable service.
|
|
33
|
+
*/
|
|
34
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
35
|
+
{
|
|
36
|
+
let tmpOptions = Object.assign({}, _DefaultOptions, pOptions);
|
|
37
|
+
super(pFable, tmpOptions, pServiceHash);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
GenerateMeadowSchema(pModelData)
|
|
41
|
+
{
|
|
42
|
+
var tmpTable = pModelData;
|
|
43
|
+
|
|
44
|
+
console.log(' > Table: ' + tmpTable.TableName);
|
|
45
|
+
|
|
46
|
+
var tmpPrimaryKey = 'ID' + tmpTable.TableName;
|
|
47
|
+
|
|
48
|
+
// Get the primary key
|
|
49
|
+
for (var j = 0; j < tmpTable.Columns.length; j++)
|
|
50
|
+
if (tmpTable.Columns[j].DataType == 'ID')
|
|
51
|
+
tmpPrimaryKey = tmpTable.Columns[j].Column;
|
|
52
|
+
|
|
53
|
+
var tmpModel = ({
|
|
54
|
+
Scope: tmpTable.TableName,
|
|
55
|
+
DefaultIdentifier: tmpPrimaryKey,
|
|
56
|
+
|
|
57
|
+
Domain: (typeof (tmpTable.Domain) === 'undefined') ? 'Default' : tmpTable.Domain,
|
|
58
|
+
|
|
59
|
+
Schema: [],
|
|
60
|
+
|
|
61
|
+
DefaultObject: {},
|
|
62
|
+
|
|
63
|
+
JsonSchema: ({
|
|
64
|
+
title: tmpTable.TableName,
|
|
65
|
+
type: 'object',
|
|
66
|
+
properties: {},
|
|
67
|
+
required: []
|
|
68
|
+
}),
|
|
69
|
+
|
|
70
|
+
Authorization: {}
|
|
71
|
+
});
|
|
72
|
+
for (var j = 0; j < tmpTable.Columns.length; j++)
|
|
73
|
+
{
|
|
74
|
+
var tmpColumnName = tmpTable.Columns[j].Column;
|
|
75
|
+
var tmpColumnType = tmpTable.Columns[j].DataType;
|
|
76
|
+
var tmpColumnSize = tmpTable.Columns[j].hasOwnProperty('Size') ? tmpTable.Columns[j].Size : 'Default';
|
|
77
|
+
|
|
78
|
+
var tmpSchemaEntry = { Column: tmpColumnName, Type: 'Default' };
|
|
79
|
+
// Dump out each column......
|
|
80
|
+
switch (tmpColumnType)
|
|
81
|
+
{
|
|
82
|
+
case 'ID':
|
|
83
|
+
tmpSchemaEntry.Type = 'AutoIdentity';
|
|
84
|
+
tmpModel.DefaultObject[tmpColumnName] = 0;
|
|
85
|
+
tmpModel.JsonSchema.properties[tmpColumnName] = { type: 'integer', size: tmpColumnSize };
|
|
86
|
+
tmpModel.JsonSchema.required.push(tmpColumnName);
|
|
87
|
+
break;
|
|
88
|
+
case 'GUID':
|
|
89
|
+
tmpSchemaEntry.Type = 'AutoGUID';
|
|
90
|
+
tmpModel.DefaultObject[tmpColumnName] = '0x0000000000000000';
|
|
91
|
+
tmpModel.JsonSchema.properties[tmpColumnName] = { type: 'string', size: tmpColumnSize };
|
|
92
|
+
break;
|
|
93
|
+
case 'ForeignKey':
|
|
94
|
+
tmpSchemaEntry.Type = 'Integer';
|
|
95
|
+
tmpModel.DefaultObject[tmpColumnName] = 0;
|
|
96
|
+
tmpModel.JsonSchema.properties[tmpColumnName] = { type: 'integer', size: tmpColumnSize };
|
|
97
|
+
tmpModel.JsonSchema.required.push(tmpColumnName);
|
|
98
|
+
break;
|
|
99
|
+
case 'Numeric':
|
|
100
|
+
tmpSchemaEntry.Type = 'Integer';
|
|
101
|
+
tmpModel.DefaultObject[tmpColumnName] = 0;
|
|
102
|
+
tmpModel.JsonSchema.properties[tmpColumnName] = { type: 'integer', size: tmpColumnSize };
|
|
103
|
+
break;
|
|
104
|
+
case 'Decimal':
|
|
105
|
+
tmpSchemaEntry.Type = 'Decimal';
|
|
106
|
+
tmpModel.DefaultObject[tmpColumnName] = 0.0;
|
|
107
|
+
tmpModel.JsonSchema.properties[tmpColumnName] = { type: 'number', size: tmpColumnSize };
|
|
108
|
+
break;
|
|
109
|
+
case 'String':
|
|
110
|
+
case 'Text':
|
|
111
|
+
tmpSchemaEntry.Type = 'String';
|
|
112
|
+
tmpModel.DefaultObject[tmpColumnName] = '';
|
|
113
|
+
tmpModel.JsonSchema.properties[tmpColumnName] = { type: 'string', size: tmpColumnSize };
|
|
114
|
+
break;
|
|
115
|
+
case 'DateTime':
|
|
116
|
+
tmpSchemaEntry.Type = 'DateTime';
|
|
117
|
+
tmpModel.DefaultObject[tmpColumnName] = null;
|
|
118
|
+
tmpModel.JsonSchema.properties[tmpColumnName] = { type: 'string', size: tmpColumnSize };
|
|
119
|
+
break;
|
|
120
|
+
case 'Boolean':
|
|
121
|
+
tmpSchemaEntry.Type = 'Boolean';
|
|
122
|
+
tmpModel.DefaultObject[tmpColumnName] = false;
|
|
123
|
+
tmpModel.JsonSchema.properties[tmpColumnName] = { type: 'boolean', size: tmpColumnSize };
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
// Now mark up the magic columns that branch by name
|
|
127
|
+
switch (tmpColumnName)
|
|
128
|
+
{
|
|
129
|
+
case 'CreateDate':
|
|
130
|
+
tmpSchemaEntry.Type = 'CreateDate';
|
|
131
|
+
break;
|
|
132
|
+
case 'CreatingIDUser':
|
|
133
|
+
tmpSchemaEntry.Type = 'CreateIDUser';
|
|
134
|
+
break;
|
|
135
|
+
case 'UpdateDate':
|
|
136
|
+
tmpSchemaEntry.Type = 'UpdateDate';
|
|
137
|
+
break;
|
|
138
|
+
case 'UpdatingIDUser':
|
|
139
|
+
tmpSchemaEntry.Type = 'UpdateIDUser';
|
|
140
|
+
break;
|
|
141
|
+
case 'DeleteDate':
|
|
142
|
+
tmpSchemaEntry.Type = 'DeleteDate';
|
|
143
|
+
break;
|
|
144
|
+
case 'DeletingIDUser':
|
|
145
|
+
tmpSchemaEntry.Type = 'DeleteIDUser';
|
|
146
|
+
break;
|
|
147
|
+
case 'Deleted':
|
|
148
|
+
tmpSchemaEntry.Type = 'Deleted';
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
tmpSchemaEntry.Size = tmpColumnSize;
|
|
152
|
+
|
|
153
|
+
// Now add it to the array
|
|
154
|
+
tmpModel.Schema.push(tmpSchemaEntry);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return tmpModel
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/***********
|
|
161
|
+
* MicroDDL Compiler
|
|
162
|
+
*
|
|
163
|
+
*****/
|
|
164
|
+
compileMicroDDL(pFilePath, pFileName, fCallback)
|
|
165
|
+
{
|
|
166
|
+
pFable = this.fable;
|
|
167
|
+
|
|
168
|
+
var tmpStrictureModelFile = pFable.settings.OutputLocation + pFable.settings.OutputFileName + '.json';
|
|
169
|
+
var tmpStrictureModelExtendedFile = pFable.settings.OutputLocation + pFable.settings.OutputFileName + '-Extended.json';
|
|
170
|
+
var tmpStrictureModelPICTFile = pFable.settings.OutputLocation + pFable.settings.OutputFileName + '-PICT.json';
|
|
171
|
+
|
|
172
|
+
var tmpCallback = (typeof (fCallback) === 'function') ? fCallback : () => { };
|
|
173
|
+
|
|
174
|
+
pFable.Stricture = (
|
|
175
|
+
{
|
|
176
|
+
// This hash table will hold the model
|
|
177
|
+
Tables: {},
|
|
178
|
+
|
|
179
|
+
// This array will hold the order for the tables in the model, so they match the order they are first introduced to Stricture
|
|
180
|
+
TablesSequence: [],
|
|
181
|
+
|
|
182
|
+
// This hash table will hold the authenticator configuration for the entire model
|
|
183
|
+
Authorization: {},
|
|
184
|
+
|
|
185
|
+
// This hash table will hold the meadow endpoint configuration for the entire model
|
|
186
|
+
Endpoints: {},
|
|
187
|
+
|
|
188
|
+
Pict: {}
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
console.info('--> Compiling MicroDDL to JSON');
|
|
193
|
+
console.log(' > Input file: ' + pFable.settings.InputFileName);
|
|
194
|
+
console.log(' > Output file: ' + tmpStrictureModelFile);
|
|
195
|
+
console.log(' > Extended Output file: ' + tmpStrictureModelExtendedFile);
|
|
196
|
+
|
|
197
|
+
// Read in the file
|
|
198
|
+
console.info(' > Reading DDL File(s)');
|
|
199
|
+
ReadMicroDDLFile(pFable, pFable.settings.InputFileName,
|
|
200
|
+
function ()
|
|
201
|
+
{
|
|
202
|
+
libAsync.waterfall(
|
|
203
|
+
[
|
|
204
|
+
(fStageComplete) =>
|
|
205
|
+
{
|
|
206
|
+
// Generate the output
|
|
207
|
+
console.info(' > Metacompiling the Model');
|
|
208
|
+
libJSONFile.writeFile(tmpStrictureModelFile,
|
|
209
|
+
{ Tables: pFable.Stricture.Tables },
|
|
210
|
+
{ spaces: 4 },
|
|
211
|
+
function (pError)
|
|
212
|
+
{
|
|
213
|
+
if (pError)
|
|
214
|
+
{
|
|
215
|
+
console.error(' > Error writing out model JSON: ' + pError);
|
|
216
|
+
}
|
|
217
|
+
else
|
|
218
|
+
{
|
|
219
|
+
console.info(' > Model JSON Successfully Written');
|
|
220
|
+
}
|
|
221
|
+
return fStageComplete(pError);
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
},
|
|
225
|
+
(fStageComplete) =>
|
|
226
|
+
{
|
|
227
|
+
console.info(' Auto-generating inline meadow schemas');
|
|
228
|
+
for (var tmpTableKey in pFable.Stricture.Tables)
|
|
229
|
+
{
|
|
230
|
+
var tmpTable = pFable.Stricture.Tables[tmpTableKey];
|
|
231
|
+
var tmpSchema = GenerateMeadowSchema(tmpTable);
|
|
232
|
+
pFable.Stricture.Tables[tmpTableKey].MeadowSchema = tmpSchema;
|
|
233
|
+
}
|
|
234
|
+
return fStageComplete();
|
|
235
|
+
},
|
|
236
|
+
(fStageComplete) =>
|
|
237
|
+
{
|
|
238
|
+
// Generate the output
|
|
239
|
+
console.info(' > Compiling the Extended Model');
|
|
240
|
+
// Decorate the current model with the right output
|
|
241
|
+
if (typeof (pFable.Stricture) === 'object')
|
|
242
|
+
{
|
|
243
|
+
if (pFable.Stricture.hasOwnProperty('Tables') && (typeof (pFable.Stricture) === 'object'))
|
|
244
|
+
{
|
|
245
|
+
let tmpTableList = Object.keys(pFable.Stricture.Tables);
|
|
246
|
+
for (let i = 0; i < tmpTableList.length; i++)
|
|
247
|
+
{
|
|
248
|
+
const tmpTableName = tmpTableList[i];
|
|
249
|
+
const tmpTableObject = pFable.Stricture.Tables[tmpTableName];
|
|
250
|
+
// For now, have duplicate data in the schema.
|
|
251
|
+
let tmpJSONSchemaInsert;
|
|
252
|
+
try
|
|
253
|
+
{
|
|
254
|
+
tmpJSONSchemaInsert = JSON.parse(JSON.stringify(tmpTableObject));
|
|
255
|
+
}
|
|
256
|
+
catch (pError)
|
|
257
|
+
{
|
|
258
|
+
pFable.log.info(`Error parsing JSON for table: ${tmpTableName} -- ${pError}`)
|
|
259
|
+
}
|
|
260
|
+
// Remove the JSON Schema from the JSON Schema insert of the meadow model
|
|
261
|
+
delete tmpJSONSchemaInsert.JsonSchema;
|
|
262
|
+
// Add the JSON Schema to the model JSONSchema
|
|
263
|
+
tmpTableObject.MeadowSchema.JsonSchema.MeadowSchema = tmpJSONSchemaInsert;
|
|
264
|
+
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
libJSONFile.writeFile(tmpStrictureModelExtendedFile,
|
|
269
|
+
pFable.Stricture,
|
|
270
|
+
{ spaces: 4 },
|
|
271
|
+
function (pError)
|
|
272
|
+
{
|
|
273
|
+
if (pError)
|
|
274
|
+
{
|
|
275
|
+
console.error(' > Error writing out Extended model JSON: ' + pError);
|
|
276
|
+
}
|
|
277
|
+
else
|
|
278
|
+
{
|
|
279
|
+
console.info(' > Extended Model JSON Successfully Written');
|
|
280
|
+
}
|
|
281
|
+
return fStageComplete(pError);
|
|
282
|
+
}
|
|
283
|
+
);
|
|
284
|
+
},
|
|
285
|
+
(fStageComplete) =>
|
|
286
|
+
{
|
|
287
|
+
// Generate the output
|
|
288
|
+
console.info(' > Compiling the PICT Definition');
|
|
289
|
+
libJSONFile.writeFile(tmpStrictureModelPICTFile,
|
|
290
|
+
pFable.Stricture.Pict,
|
|
291
|
+
{ spaces: 4 },
|
|
292
|
+
function (pError)
|
|
293
|
+
{
|
|
294
|
+
if (pError)
|
|
295
|
+
{
|
|
296
|
+
console.error(' > Error writing out PICT model JSON: ' + pError);
|
|
297
|
+
}
|
|
298
|
+
else
|
|
299
|
+
{
|
|
300
|
+
console.info(' > PICT JSON Successfully Written');
|
|
301
|
+
}
|
|
302
|
+
return fStageComplete(pError);
|
|
303
|
+
}
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
],
|
|
307
|
+
(pError) =>
|
|
308
|
+
{
|
|
309
|
+
if (pError)
|
|
310
|
+
{
|
|
311
|
+
console.error(' > ERROR Compiling DDL: ' + pError);
|
|
312
|
+
}
|
|
313
|
+
else
|
|
314
|
+
{
|
|
315
|
+
console.info(' > DDL Compile Stages completed successfully.');
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
return tmpCallback(pError);
|
|
319
|
+
}
|
|
320
|
+
)
|
|
321
|
+
}
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
module.exports = StrictureCompiler;
|
|
327
|
+
module.exports.default_configuration = _DefaultOptions;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
const libFableServiceProviderBase = require('fable-serviceproviderbase');
|
|
2
2
|
|
|
3
3
|
const _DefaultOptions = (
|
|
4
4
|
{
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
class FableService extends
|
|
7
|
+
class FableService{~PascalCaseIdentifier:Record.Scope~} extends libFableServiceProviderBase
|
|
8
8
|
{
|
|
9
9
|
/**
|
|
10
10
|
* @param {import('fable')} pFable - The fable instance.
|
|
@@ -13,7 +13,7 @@ class FableService extends FableServiceProviderBase
|
|
|
13
13
|
*/
|
|
14
14
|
constructor(pFable, pOptions, pServiceHash)
|
|
15
15
|
{
|
|
16
|
-
|
|
16
|
+
const tmpOptions = Object.assign({}, _DefaultOptions, pOptions);
|
|
17
17
|
super(pFable, tmpOptions, pServiceHash);
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -23,6 +23,5 @@ class FableService extends FableServiceProviderBase
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
module.exports = FableService;
|
|
27
|
-
|
|
26
|
+
module.exports = FableService{~PascalCaseIdentifier:Record.Scope~};
|
|
28
27
|
module.exports.default_configuration = _DefaultOptions;
|