@sprucelabs/spruce-templates 28.2.2 → 29.0.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/build/addons/index.d.ts +1 -0
- package/build/addons/index.js +1 -0
- package/build/addons/schemaRenderer.addon.d.ts +1 -0
- package/build/addons/schemaRenderer.addon.js +15 -0
- package/build/index.d.ts +4 -1
- package/build/index.js +2 -2
- package/build/templates/go/schema/schema.go.hbs +24 -0
- package/build/templates/go/schema/schemas.go.hbs +9 -0
- package/build/utilities/templateImporter.utility.d.ts +1 -1
- package/build/utilities/templateImporter.utility.js +3 -3
- package/package.json +7 -7
package/build/addons/index.d.ts
CHANGED
package/build/addons/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const schema_1 = require("@sprucelabs/schema");
|
|
7
|
+
const handlebars_1 = __importDefault(require("handlebars"));
|
|
8
|
+
handlebars_1.default.registerHelper('schemaRenderer', function (schema, schemaTemplateItems) {
|
|
9
|
+
const renderer = schema_1.SchemaTypesRenderer.Renderer();
|
|
10
|
+
const rendered = renderer.render(schema, {
|
|
11
|
+
language: 'go',
|
|
12
|
+
schemaTemplateItems,
|
|
13
|
+
});
|
|
14
|
+
return rendered;
|
|
15
|
+
});
|
package/build/index.d.ts
CHANGED
|
@@ -9,9 +9,10 @@ export declare const templates: {
|
|
|
9
9
|
schemasTypes(options: {
|
|
10
10
|
schemaTemplateItems: SchemaTemplateItem[];
|
|
11
11
|
fieldTemplateItems: FieldTemplateItem[];
|
|
12
|
-
valueTypes
|
|
12
|
+
valueTypes?: ValueTypes;
|
|
13
13
|
globalSchemaNamespace?: string;
|
|
14
14
|
typesTemplate?: string;
|
|
15
|
+
language: "typescript" | "go";
|
|
15
16
|
}): string;
|
|
16
17
|
valueTypes(options: {
|
|
17
18
|
schemaTemplateItems: SchemaTemplateItem[];
|
|
@@ -25,7 +26,9 @@ export declare const templates: {
|
|
|
25
26
|
globalSchemaNamespace?: string;
|
|
26
27
|
registerBuiltSchemas: boolean;
|
|
27
28
|
schemaFile?: string;
|
|
29
|
+
goModuleNameAndPath?: string;
|
|
28
30
|
typesFile?: string;
|
|
31
|
+
language: "typescript" | "go";
|
|
29
32
|
}): string;
|
|
30
33
|
schemaBuilder(options: SchemaBuilderTemplateItem): string;
|
|
31
34
|
error(options: ErrorOptions): string;
|
package/build/index.js
CHANGED
|
@@ -35,7 +35,7 @@ exports.templates = {
|
|
|
35
35
|
schemasTypes(options) {
|
|
36
36
|
var _a, _b;
|
|
37
37
|
const imports = importExtractor_utility_1.default.extractFieldImports(options.fieldTemplateItems);
|
|
38
|
-
const template = templateImporter_utility_1.default.getTemplate((_a = options.typesTemplate) !== null && _a !== void 0 ? _a : 'schema/schemas.types.ts.hbs');
|
|
38
|
+
const template = templateImporter_utility_1.default.getTemplate((_a = options.typesTemplate) !== null && _a !== void 0 ? _a : 'schema/schemas.types.ts.hbs', options.language);
|
|
39
39
|
const schemaImports = importExtractor_utility_1.default.extractSchemaImports(options.schemaTemplateItems);
|
|
40
40
|
return template({
|
|
41
41
|
...options,
|
|
@@ -64,7 +64,7 @@ exports.templates = {
|
|
|
64
64
|
schema(options) {
|
|
65
65
|
var _a, _b, _c;
|
|
66
66
|
const imports = importExtractor_utility_1.default.extractFieldImports(options.fieldTemplateItems);
|
|
67
|
-
const template = templateImporter_utility_1.default.getTemplate((_a = options.schemaFile) !== null && _a !== void 0 ? _a : 'schema/schema.ts.hbs');
|
|
67
|
+
const template = templateImporter_utility_1.default.getTemplate((_a = options.schemaFile) !== null && _a !== void 0 ? _a : 'schema/schema.ts.hbs', options.language);
|
|
68
68
|
return template({
|
|
69
69
|
...options,
|
|
70
70
|
imports,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package {{schema.version}}
|
|
2
|
+
|
|
3
|
+
// THIS FILE IS AUTO-GENERATED. DO NOT EDIT.
|
|
4
|
+
|
|
5
|
+
import (
|
|
6
|
+
"encoding/json"
|
|
7
|
+
"{{goModuleNameAndPath}}/schemas"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
func Make{{namePascal}}(data map[string]any) (*schemas.{{namePascal}}, error) {
|
|
11
|
+
var {{nameCamel}} schemas.{{namePascal}}
|
|
12
|
+
|
|
13
|
+
jsonData, err := json.Marshal(data)
|
|
14
|
+
if err != nil {
|
|
15
|
+
return nil, err
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
err = json.Unmarshal(jsonData, &{{nameCamel}})
|
|
19
|
+
if err != nil {
|
|
20
|
+
return nil, err
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return &{{nameCamel}}, nil
|
|
24
|
+
}
|
|
@@ -7,12 +7,12 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const handlebars_1 = __importDefault(require("handlebars"));
|
|
9
9
|
const templateCache = {};
|
|
10
|
-
const templatePath = path_1.default.join(__dirname, '..', 'templates'
|
|
10
|
+
const templatePath = path_1.default.join(__dirname, '..', 'templates');
|
|
11
11
|
const templateImportUtil = {
|
|
12
|
-
getTemplate(filename) {
|
|
12
|
+
getTemplate(filename, language = 'typescript') {
|
|
13
13
|
if (!templateCache[filename]) {
|
|
14
14
|
const contents = fs_1.default
|
|
15
|
-
.readFileSync(path_1.default.join(templatePath, filename))
|
|
15
|
+
.readFileSync(path_1.default.join(templatePath, language, filename))
|
|
16
16
|
.toString();
|
|
17
17
|
const template = handlebars_1.default.compile(contents);
|
|
18
18
|
templateCache[filename] = template;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "29.0.0",
|
|
7
7
|
"files": [
|
|
8
8
|
"build/**/*",
|
|
9
9
|
"tsconfig.json",
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
"watch.tsc": "tsc -w"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@sprucelabs/mercury-types": "^48.0.
|
|
60
|
-
"@sprucelabs/schema": "^32.
|
|
61
|
-
"@sprucelabs/spruce-event-utils": "^41.0.
|
|
62
|
-
"@sprucelabs/spruce-skill-utils": "^32.
|
|
59
|
+
"@sprucelabs/mercury-types": "^48.0.141",
|
|
60
|
+
"@sprucelabs/schema": "^32.3.12",
|
|
61
|
+
"@sprucelabs/spruce-event-utils": "^41.0.160",
|
|
62
|
+
"@sprucelabs/spruce-skill-utils": "^32.1.16",
|
|
63
63
|
"fs-extra": "^11.3.2",
|
|
64
64
|
"handlebars": "^4.7.8",
|
|
65
65
|
"lodash": "^4.17.21",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@types/fs-extra": "^11.0.4",
|
|
70
70
|
"@types/lodash": "^4.17.20",
|
|
71
|
-
"@types/node": "^24.
|
|
71
|
+
"@types/node": "^24.9.1",
|
|
72
72
|
"chokidar-cli": "^3.0.0",
|
|
73
73
|
"concurrently": "^9.2.1",
|
|
74
74
|
"conventional-changelog-sprucelabs": "2.0.1",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"conventional-changelog-sprucelabs"
|
|
81
81
|
]
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "408c01bb3de7ec5fdb89bd3f3bd0103b7792a921"
|
|
84
84
|
}
|