@sprucelabs/spruce-templates 28.2.3 → 29.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.
@@ -21,3 +21,4 @@ import './schemaValuesPartial.addon';
21
21
  import './valueTypeGenerator.addon';
22
22
  import './valueTypeLiteral.addon';
23
23
  import './valueTypeMapper.addon';
24
+ import './schemaRenderer.addon';
@@ -23,3 +23,4 @@ require("./schemaValuesPartial.addon");
23
23
  require("./valueTypeGenerator.addon");
24
24
  require("./valueTypeLiteral.addon");
25
25
  require("./valueTypeMapper.addon");
26
+ require("./schemaRenderer.addon");
@@ -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: 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
+ }
@@ -0,0 +1,9 @@
1
+ package schemas
2
+
3
+ import SpruceSchema "github.com/sprucelabsai-community/spruce-schema/v32/pkg/fields"
4
+
5
+ {{#each schemaTemplateItems}}
6
+ {{{ schemaRenderer schema ../schemaTemplateItems }}}
7
+
8
+ {{/each}}
9
+
@@ -9,8 +9,9 @@ const {{nameCamel}}EventContract = buildEventContract({
9
9
  {{#each eventSignatures}}
10
10
  '{{@key}}': {
11
11
  {{#if isGlobal}}isGlobal: true,{{/if}}
12
- {{#if description}}description: `{{{description}}}`,{{/if}}
13
- {{#if aiInstructions}}aiInstructions: `{{{aiInstructions}}}`,{{/if}}
12
+ {{#if description}}description: {{{json description}}},{{/if}}
13
+ {{#if aiInstructions}}aiInstructions: {{{json aiInstructions}}},{{/if}}
14
+ {{#if feed}}feed: {{{json feed}}},{{/if}}
14
15
  {{#if emitPermissions}}emitPermissions: {{{json emitPermissions}}},{{/if}}
15
16
  {{#if listenPermissions}}listenPermissions: {{{json listenPermissions}}},{{/if}}
16
17
  {{#if emitPayloadSchema}}emitPayloadSchema: {{emitPayloadSchema.nameCamel}}Schema,{{/if}}
@@ -23,4 +24,4 @@ const {{nameCamel}}EventContract = buildEventContract({
23
24
  })
24
25
  export default {{nameCamel}}EventContract
25
26
 
26
- export type {{namePascal}}EventContract = typeof {{nameCamel}}EventContract
27
+ export type {{namePascal}}EventContract = typeof {{nameCamel}}EventContract
@@ -1,4 +1,4 @@
1
1
  declare const templateImportUtil: {
2
- getTemplate(filename: string): HandlebarsTemplateDelegate<any>;
2
+ getTemplate(filename: string, language?: string): HandlebarsTemplateDelegate<any>;
3
3
  };
4
4
  export default templateImportUtil;
@@ -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', 'typescript');
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": "28.2.3",
6
+ "version": "29.0.1",
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.112",
60
- "@sprucelabs/schema": "^32.1.59",
61
- "@sprucelabs/spruce-event-utils": "^41.0.126",
62
- "@sprucelabs/spruce-skill-utils": "^32.0.116",
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.6.2",
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": "7c00834ba1fe39633749edd2f1f878dd89bd4abf"
83
+ "gitHead": "356fd4d0649e4e5f6d5dbee4474ca6a1671ec740"
84
84
  }