@voxgig/create-sdkgen 0.0.1
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/LICENSE +22 -0
- package/README.md +2 -0
- package/bin/run-create-sdkgen.js +5 -0
- package/dist/create-sdkgen.d.ts +12 -0
- package/dist/create-sdkgen.js +50 -0
- package/dist/create-sdkgen.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utility.d.ts +2 -0
- package/dist/utility.js +5 -0
- package/dist/utility.js.map +1 -0
- package/package.json +51 -0
- package/src/create-sdkgen.ts +61 -0
- package/src/tsconfig.json +16 -0
- package/src/utility.ts +8 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Voxgig Ltd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type FullCreateSdkGenOptions = {
|
|
2
|
+
folder: string;
|
|
3
|
+
fs: any;
|
|
4
|
+
model: any;
|
|
5
|
+
meta: any;
|
|
6
|
+
};
|
|
7
|
+
type CreateSdkGenOptions = Partial<FullCreateSdkGenOptions>;
|
|
8
|
+
declare function CreateSdkGen(opts: CreateSdkGenOptions): {
|
|
9
|
+
generate: (spec: any) => Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
export type { CreateSdkGenOptions, };
|
|
12
|
+
export { CreateSdkGen, };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Copyright (c) 2024 Richard Rodger, MIT License */
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.CreateSdkGen = CreateSdkGen;
|
|
28
|
+
const Fs = __importStar(require("node:fs"));
|
|
29
|
+
const JostracaModule = __importStar(require("jostraca"));
|
|
30
|
+
const { Jostraca } = JostracaModule;
|
|
31
|
+
function CreateSdkGen(opts) {
|
|
32
|
+
const fs = opts.fs || Fs;
|
|
33
|
+
const folder = opts.folder || '.';
|
|
34
|
+
const jostraca = Jostraca();
|
|
35
|
+
async function generate(spec) {
|
|
36
|
+
const { model, root } = spec;
|
|
37
|
+
const ctx$ = { fs, folder, meta: { spec } };
|
|
38
|
+
try {
|
|
39
|
+
jostraca.generate(ctx$, () => root({ model }));
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
console.log('CREATE SDKGEN ERROR: ', err);
|
|
43
|
+
throw err;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
generate,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=create-sdkgen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-sdkgen.js","sourceRoot":"","sources":["../src/create-sdkgen.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;;;;;;;;;;;;;;;;;;;;;;;AA2DlD,oCAAY;AAzDd,4CAA6B;AAG7B,yDAA0C;AAc1C,MAAM,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAA;AAGnC,SAAS,YAAY,CAAC,IAAyB;IAC7C,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,IAAI,EAAE,CAAA;IACxB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,GAAG,CAAA;IACjC,MAAM,QAAQ,GAAG,QAAQ,EAAE,CAAA;IAG3B,KAAK,UAAU,QAAQ,CAAC,IAAS;QAC/B,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;QAE5B,MAAM,IAAI,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,CAAA;QAE3C,IAAI,CAAC;YACH,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;QAChD,CAAC;QACD,OAAO,GAAQ,EAAE,CAAC;YAChB,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAA;YACzC,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC;IAGD,OAAO;QACL,QAAQ;KACT,CAAA;AAEH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../src/create-sdkgen.ts","../src/utility.ts"],"version":"5.6.2"}
|
package/dist/utility.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utility.js","sourceRoot":"","sources":["../src/utility.ts"],"names":[],"mappings":";;AAME,kBAAG;AAJL,SAAS,GAAG,KAAK,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voxgig/create-sdkgen",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "dist/create-sdkgen.js",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"types": "dist/create-sdkgen.d.ts",
|
|
7
|
+
"description": "Create a Voxgig SDK Generator project",
|
|
8
|
+
"homepage": "https://github.com/voxgig/create-sdkgen",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"voxgig",
|
|
11
|
+
"sdkgen",
|
|
12
|
+
"create"
|
|
13
|
+
],
|
|
14
|
+
"author": "Richard Rodger (http://richardrodger.com)",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git://github.com/voxgig/create-sdkgen.git"
|
|
18
|
+
},
|
|
19
|
+
"bin": {
|
|
20
|
+
"create-sdkgen": "bin/run-create-sdkgen.js"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test": "node --enable-source-maps --test dist-test",
|
|
24
|
+
"test-some": "node --enable-source-maps --test-name-pattern=\"$npm_config_pattern\" --test dist-test",
|
|
25
|
+
"watch": "tsc --build src test -w",
|
|
26
|
+
"build": "tsc --build src test",
|
|
27
|
+
"clean": "rm -rf node_modules yarn.lock package-lock.json",
|
|
28
|
+
"reset": "npm run clean && npm i && npm run build && npm test",
|
|
29
|
+
"repo-tag": "REPO_VERSION=`node -e \"console.log(require('./package').version)\"` && echo TAG: v$REPO_VERSION && git commit -a -m v$REPO_VERSION && git push && git tag v$REPO_VERSION && git push --tags;",
|
|
30
|
+
"repo-publish": "npm run clean && npm i && npm run repo-publish-quick",
|
|
31
|
+
"repo-publish-quick": "npm run build && npm run test && npm run repo-tag && npm publish --registry https://registry.npmjs.org --access=public"
|
|
32
|
+
},
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"files": [
|
|
35
|
+
"src",
|
|
36
|
+
"dist",
|
|
37
|
+
"LICENSE"
|
|
38
|
+
],
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@hapi/code": "^9.0.3",
|
|
41
|
+
"@types/node": "22.5.4",
|
|
42
|
+
"esbuild": "^0.23.1",
|
|
43
|
+
"memfs": "^4.11.1",
|
|
44
|
+
"typescript": "^5.5.4"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"aontu": "^0.22.0",
|
|
48
|
+
"jostraca": "^0.4.0"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* Copyright (c) 2024 Richard Rodger, MIT License */
|
|
2
|
+
|
|
3
|
+
import * as Fs from 'node:fs'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import * as JostracaModule from 'jostraca'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
type FullCreateSdkGenOptions = {
|
|
11
|
+
folder: string
|
|
12
|
+
fs: any
|
|
13
|
+
model: any
|
|
14
|
+
meta: any
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type CreateSdkGenOptions = Partial<FullCreateSdkGenOptions>
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
const { Jostraca } = JostracaModule
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
function CreateSdkGen(opts: CreateSdkGenOptions) {
|
|
24
|
+
const fs = opts.fs || Fs
|
|
25
|
+
const folder = opts.folder || '.'
|
|
26
|
+
const jostraca = Jostraca()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
async function generate(spec: any) {
|
|
30
|
+
const { model, root } = spec
|
|
31
|
+
|
|
32
|
+
const ctx$ = { fs, folder, meta: { spec } }
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
jostraca.generate(ctx$, () => root({ model }))
|
|
36
|
+
}
|
|
37
|
+
catch (err: any) {
|
|
38
|
+
console.log('CREATE SDKGEN ERROR: ', err)
|
|
39
|
+
throw err
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
generate,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
export type {
|
|
54
|
+
CreateSdkGenOptions,
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
export {
|
|
60
|
+
CreateSdkGen,
|
|
61
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"esModuleInterop": true,
|
|
4
|
+
"module": "nodenext",
|
|
5
|
+
"noEmitOnError": true,
|
|
6
|
+
"outDir":"../dist",
|
|
7
|
+
"rootDir":".",
|
|
8
|
+
"resolveJsonModule": true,
|
|
9
|
+
"sourceMap": true,
|
|
10
|
+
"strict": true,
|
|
11
|
+
"target": "es2021",
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"declarationDir": "../dist"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|