@powerlines/plugin-alloy 0.26.226 → 0.26.228

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.
Files changed (52) hide show
  1. package/dist/core/components/infrastructure-file.cjs +1 -1
  2. package/dist/core/components/source-file.cjs +1 -1
  3. package/dist/helpers/capnp.cjs +141 -87
  4. package/dist/helpers/capnp.d.cts +20 -15
  5. package/dist/helpers/capnp.d.cts.map +1 -1
  6. package/dist/helpers/capnp.d.mts +20 -15
  7. package/dist/helpers/capnp.mjs +142 -87
  8. package/dist/helpers/index.cjs +0 -3
  9. package/dist/helpers/index.d.cts +2 -3
  10. package/dist/helpers/index.d.mts +2 -3
  11. package/dist/helpers/index.mjs +2 -3
  12. package/dist/index.cjs +1 -1
  13. package/dist/markdown/components/alert.cjs +74 -0
  14. package/dist/markdown/components/alert.d.cts +53 -0
  15. package/dist/markdown/components/alert.d.cts.map +1 -0
  16. package/dist/markdown/components/alert.d.mts +53 -0
  17. package/dist/markdown/components/alert.d.mts.map +1 -0
  18. package/dist/markdown/components/alert.mjs +69 -0
  19. package/dist/markdown/components/alert.mjs.map +1 -0
  20. package/dist/markdown/components/index.cjs +8 -1
  21. package/dist/markdown/components/index.d.cts +2 -1
  22. package/dist/markdown/components/index.d.mts +2 -1
  23. package/dist/markdown/components/index.mjs +2 -1
  24. package/dist/markdown/index.cjs +7 -0
  25. package/dist/markdown/index.d.cts +2 -1
  26. package/dist/markdown/index.d.mts +2 -1
  27. package/dist/markdown/index.mjs +2 -1
  28. package/dist/typescript/components/builtin-file.cjs +5 -3
  29. package/dist/typescript/components/builtin-file.d.cts +6 -0
  30. package/dist/typescript/components/builtin-file.d.cts.map +1 -1
  31. package/dist/typescript/components/builtin-file.d.mts +6 -0
  32. package/dist/typescript/components/builtin-file.mjs +5 -3
  33. package/dist/typescript/components/entry-file.cjs +1 -1
  34. package/dist/typescript/components/interface-declaration.cjs +1 -1
  35. package/dist/typescript/components/interface-declaration.d.mts +1 -1
  36. package/dist/typescript/components/interface-declaration.mjs +1 -1
  37. package/dist/typescript/components/object-declaration.cjs +2 -2
  38. package/dist/typescript/components/object-declaration.d.mts +1 -1
  39. package/dist/typescript/components/object-declaration.mjs +2 -2
  40. package/dist/typescript/components/tsdoc-schema.cjs +2 -2
  41. package/dist/typescript/components/tsdoc-schema.mjs +2 -2
  42. package/dist/typescript/components/tsdoc.cjs +1 -1
  43. package/dist/typescript/components/tsdoc.d.mts +1 -1
  44. package/dist/typescript/components/tsdoc.mjs +1 -1
  45. package/package.json +23 -22
  46. package/dist/helpers/typescript.cjs +0 -47
  47. package/dist/helpers/typescript.d.cts +0 -24
  48. package/dist/helpers/typescript.d.cts.map +0 -1
  49. package/dist/helpers/typescript.d.mts +0 -24
  50. package/dist/helpers/typescript.d.mts.map +0 -1
  51. package/dist/helpers/typescript.mjs +0 -47
  52. package/dist/helpers/typescript.mjs.map +0 -1
@@ -8,7 +8,7 @@ let _alloy_js_core = require("@alloy-js/core");
8
8
  let _stryke_path_replace = require("@stryke/path/replace");
9
9
  let _stryke_path_append = require("@stryke/path/append");
10
10
  let defu = require("defu");
11
- defu = require_runtime.__toESM(defu);
11
+ defu = require_runtime.__toESM(defu, 1);
12
12
 
13
13
  //#region src/core/components/infrastructure-file.tsx
14
14
  /**
@@ -5,7 +5,7 @@ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
5
5
  let _alloy_js_core = require("@alloy-js/core");
6
6
  let _stryke_path_append = require("@stryke/path/append");
7
7
  let defu = require("defu");
8
- defu = require_runtime.__toESM(defu);
8
+ defu = require_runtime.__toESM(defu, 1);
9
9
 
10
10
  //#region src/core/components/source-file.tsx
11
11
  /**
@@ -4,24 +4,19 @@ let defu = require("defu");
4
4
  defu = require_runtime.__toESM(defu, 1);
5
5
  let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
6
6
  let powerlines_utils = require("powerlines/utils");
7
- let _powerlines_deepkit_utilities = require("@powerlines/deepkit/utilities");
8
- let _stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
9
- let _stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
10
- let _powerlines_deepkit_vendor_core = require("@powerlines/deepkit/vendor/core");
11
- let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
7
+ let _powerlines_schema = require("@powerlines/schema");
12
8
  let _stryke_capnp_compile = require("@stryke/capnp/compile");
13
9
  let _stryke_capnp_helpers = require("@stryke/capnp/helpers");
14
10
  let _stryke_convert_to_array = require("@stryke/convert/to-array");
15
11
  let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
16
12
  let _stryke_json = require("@stryke/json");
17
13
  let _stryke_path_join = require("@stryke/path/join");
14
+ let _stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
18
15
  let _stryke_string_format_get_words = require("@stryke/string-format/get-words");
19
16
  let _stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
20
17
  let _stryke_type_checks_is_bigint = require("@stryke/type-checks/is-bigint");
21
- let _stryke_type_checks_is_null = require("@stryke/type-checks/is-null");
22
18
  let _stryke_type_checks_is_number = require("@stryke/type-checks/is-number");
23
19
  let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
24
- let node_buffer = require("node:buffer");
25
20
  let node_child_process = require("node:child_process");
26
21
  let node_util = require("node:util");
27
22
 
@@ -56,7 +51,7 @@ async function compile(context, options = {}) {
56
51
  * @returns A string representation of the value.
57
52
  */
58
53
  function stringifyCapnpDefaultValue(property, value) {
59
- return stringifyCapnpValue(property.type, value ?? property.getDefaultValue());
54
+ return stringifyCapnpValue(property, value ?? property.default);
60
55
  }
61
56
  /**
62
57
  * Converts any {@link Type}'s actual value to string representation.
@@ -65,8 +60,8 @@ function stringifyCapnpDefaultValue(property, value) {
65
60
  * @param value - The value to stringify.
66
61
  * @returns A string representation of the value.
67
62
  */
68
- function stringifyCapnpValue(type, value) {
69
- return type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.string || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal && (0, _stryke_type_checks_is_string.isString)(type.literal) ? `"${String(value)}"` : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.enum ? `${(0, _stryke_string_format_camel_case.camelCase)(String(value))}` : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.array ? _stryke_json.StormJSON.stringify(value) : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.object || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral ? _stryke_json.StormJSON.stringify(value).replaceAll("{", "(").replaceAll("}", ")") : String(value);
63
+ function stringifyCapnpValue(schema, value) {
64
+ return (0, _powerlines_schema.isJsonSchemaString)(schema) || (0, _powerlines_schema.isJsonSchemaLiteral)(schema) && (0, _stryke_type_checks_is_string.isString)(schema.const) ? `"${String(value)}"` : (0, _powerlines_schema.isJsonSchemaEnum)(schema) || (0, _powerlines_schema.isJsonSchemaNativeEnum)(schema) ? `${(0, _stryke_string_format_camel_case.camelCase)(String(value))}` : (0, _powerlines_schema.isJsonSchemaArray)(schema) && !(0, _powerlines_schema.isJsonSchemaMap)(schema) ? _stryke_json.StormJSON.stringify(value) : (0, _powerlines_schema.isJsonSchemaObject)(schema) || (0, _powerlines_schema.isJsonSchemaRecord)(schema) ? _stryke_json.StormJSON.stringify(value).replaceAll("{", "(").replaceAll("}", ")") : String(value);
70
65
  }
71
66
  /**
72
67
  * Converts a ReflectionProperty's default value to a Cap'n Proto schema string representation.
@@ -74,11 +69,13 @@ function stringifyCapnpValue(type, value) {
74
69
  * @param type - The TypeEnum to evaluate.
75
70
  * @returns A string representation of the property.
76
71
  */
77
- function getCapnpEnumTypes(type) {
78
- if (type.kind !== _powerlines_deepkit_vendor_type.ReflectionKind.enum) return null;
79
- const unique = (0, _stryke_helpers_get_unique.getUniqueBy)(type.values.filter((value) => !(0, _stryke_type_checks_is_undefined.isUndefined)(value) && !(0, _stryke_type_checks_is_null.isNull)(value)), (enumMember) => (0, _stryke_type_checks_is_string.isString)(enumMember) ? "Text" : "Float32");
80
- if (unique.length === 0) return null;
81
- return unique[0] && (0, _stryke_type_checks_is_string.isString)(unique[0]) ? "Text" : "Float32";
72
+ function getCapnpEnumTypes(schema) {
73
+ const s = schema;
74
+ if (!s.enum || !Array.isArray(s.enum)) return null;
75
+ const values = s.enum.filter((v) => v !== null && v !== void 0);
76
+ if (values.length === 0) return null;
77
+ const unique = (0, _stryke_helpers_get_unique.getUniqueBy)(values, (v) => (0, _stryke_type_checks_is_string.isString)(v) ? "Text" : "Float32");
78
+ return unique.length > 0 && (0, _stryke_type_checks_is_string.isString)(unique[0]) ? "Text" : "Float32";
82
79
  }
83
80
  /**
84
81
  * Determines if a Type is a `Void` type in a Cap'n Proto schema.
@@ -86,8 +83,8 @@ function getCapnpEnumTypes(type) {
86
83
  * @param type - The Type to check.
87
84
  * @returns True if the Type is a `Void` type, false otherwise.
88
85
  */
89
- function isVoidType(type) {
90
- return type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.void || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.never || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.null || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.undefined || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.symbol;
86
+ function isVoidType(schema) {
87
+ return (0, _powerlines_schema.isJsonSchemaNever)(schema) || (0, _powerlines_schema.isJsonSchemaNull)(schema) || (0, _powerlines_schema.isJsonSchemaUndefined)(schema);
91
88
  }
92
89
  /**
93
90
  * Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
@@ -95,8 +92,12 @@ function isVoidType(type) {
95
92
  * @param type - The {@link TypeUnion} to convert.
96
93
  * @returns A string representation of the Cap'n Proto primitive type.
97
94
  */
98
- function getCapnpUnionTypes(type) {
99
- return (0, _powerlines_deepkit_utilities.getUnionTypes)(type);
95
+ function getCapnpUnionTypes(schema) {
96
+ const s = schema;
97
+ if (Array.isArray(s.anyOf)) return s.anyOf;
98
+ if (Array.isArray(s.oneOf)) return s.oneOf;
99
+ if (Array.isArray(s.type)) return s.type.map((t) => ({ type: t }));
100
+ return [];
100
101
  }
101
102
  /**
102
103
  * Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
@@ -104,8 +105,8 @@ function getCapnpUnionTypes(type) {
104
105
  * @param type - The {@link TypeUnion} to convert.
105
106
  * @returns An array of Cap'n Proto primitive types.
106
107
  */
107
- function isCapnpStringUnion(type) {
108
- return getCapnpUnionTypes(type).some((member) => member.kind === _powerlines_deepkit_vendor_type.ReflectionKind.string);
108
+ function isCapnpStringUnion(schema) {
109
+ return getCapnpUnionTypes(schema).some((member) => (0, _powerlines_schema.isJsonSchemaString)(member) || (0, _powerlines_schema.isJsonSchemaLiteral)(member) && (0, _stryke_type_checks_is_string.isString)(member.const));
109
110
  }
110
111
  const LARGE_BUFFER = 1024 * 1e6;
111
112
  const execAsync = (0, node_util.promisify)(node_child_process.exec);
@@ -117,44 +118,48 @@ async function generateCapnpId() {
117
118
  });
118
119
  return stdout;
119
120
  }
120
- async function generateCapnp(context, reflection, options) {
121
+ async function generateCapnp(context, schema, options) {
121
122
  return `${(await generateCapnpId()).trim()};
122
123
  ${(0, powerlines_utils.getFileHeader)(context).replace(/^\r*\n*/g, "").replaceAll("//", "#")}
123
- ${reflection.getMethods().length === 0 ? generateCapnpStruct(reflection, options) : generateCapnpInterface(reflection, options)}
124
+ ${generateCapnpStruct(schema, options)}
124
125
  `.trim();
125
126
  }
126
- function generateCapnpStruct(reflection, options = {}) {
127
- const structName = options?.name || reflection.getTitle() || reflection.getClassName() || reflection.getName();
128
- return `${generateCapnpEnums(reflection)}struct ${(0, _stryke_string_format_pascal_case.pascalCase)(structName)} {
127
+ function generateCapnpStruct(schema, options = {}) {
128
+ const structName = options?.name || schema.title || schema.name || "Schema";
129
+ return `${generateCapnpEnums(schema)}struct ${(0, _stryke_string_format_pascal_case.pascalCase)(structName)} {
129
130
  # Struct definition for ${(0, _stryke_string_format_title_case.titleCase)(structName)}.
130
131
 
131
- ${generateCapnpSchema(reflection, options)}
132
+ ${generateCapnpSchema(schema, options)}
132
133
  }
133
134
  `;
134
135
  }
135
- function generateCapnpInterface(reflection, options = {}) {
136
- const interfaceName = options?.name || reflection.getTitle() || reflection.getClassName() || reflection.getName();
137
- return `${generateCapnpEnums(reflection)}interface ${(0, _stryke_string_format_pascal_case.pascalCase)(interfaceName)} {
136
+ function generateCapnpInterface(schema, options = {}) {
137
+ const interfaceName = options?.name || schema.title || schema.name || "Schema";
138
+ return `${generateCapnpEnums(schema)}interface ${(0, _stryke_string_format_pascal_case.pascalCase)(interfaceName)} {
138
139
  # Interface definition for ${(0, _stryke_string_format_title_case.titleCase)(interfaceName)}.
139
140
 
140
- ${generateCapnpSchema(reflection, options)}
141
+ ${generateCapnpSchema(schema, options)}
141
142
  }
142
143
  `;
143
144
  }
144
145
  function formatEnumName(name) {
145
146
  return (0, _stryke_string_format_pascal_case.pascalCase)(`${name}_Type`);
146
147
  }
147
- function generateCapnpEnums(reflection) {
148
- const enums = reflection.getProperties().filter((prop) => !prop.isIgnored() && (prop.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.enum || prop.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.union && getCapnpUnionTypes(prop.type).filter((type) => type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal && ((0, _stryke_type_checks_is_string.isString)(type.literal) || (0, _stryke_type_checks_is_number.isNumber)(type.literal))).length === 1)).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? b.getNameAsString().localeCompare(a.getNameAsString()) : a.isReadonly() ? 1 : -1);
148
+ function generateCapnpEnums(schema) {
149
+ const enums = (0, _powerlines_schema.getPropertiesList)(schema).filter((prop) => !prop.ignore && ((0, _powerlines_schema.isJsonSchemaEnum)(prop) || (0, _powerlines_schema.isJsonSchemaNativeEnum)(prop) || ((0, _powerlines_schema.isJsonSchemaUnion)(prop) || (0, _powerlines_schema.isJsonSchemaAnyOf)(prop)) && getCapnpUnionTypes(prop).filter((t) => (0, _powerlines_schema.isJsonSchemaLiteral)(t) && ((0, _stryke_type_checks_is_string.isString)(t.const) || (0, _stryke_type_checks_is_number.isNumber)(t.const))).length === 1)).sort((a, b) => a.readOnly && b.readOnly || !a.readOnly && !b.readOnly ? b.name.localeCompare(a.name) : a.readOnly ? 1 : -1);
149
150
  if (enums.length === 0) return "";
150
- return `${enums.map((enumeration) => generateCapnpEnumSchema(enumeration.type, formatEnumName(enumeration.getNameAsString()))).join("\n\n")}
151
+ return `${enums.map((prop) => generateCapnpEnumSchema(prop, formatEnumName(prop.name))).join("\n\n")}
151
152
 
152
153
  `;
153
154
  }
154
- function generateCapnpSchema(reflection, options = {}) {
155
+ function generateCapnpSchema(schema, options = {}) {
155
156
  let index = 0;
156
157
  const indexCounter = options?.indexCounter ?? (() => index++);
157
- return `${reflection.getProperties().filter((prop) => !prop.isIgnored()).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? b.getNameAsString().localeCompare(a.getNameAsString()) : a.isReadonly() ? 1 : -1).map((prop) => generateCapnpPropertySchema(prop, indexCounter)).join(" \n\n ")}${reflection.getMethods().filter((methods) => !methods.isIgnored()).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? String(b.getName()).localeCompare(String(a.getName())) : a.isReadonly() ? 1 : -1).map((methods) => generateCapnpMethodSchema(methods, indexCounter)).join(" \n\n ")}${reflection.getProperties().some((prop) => prop.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.class && prop.type.classType === Map) ? `
158
+ const props = (0, _powerlines_schema.getPropertiesList)(schema);
159
+ const filteredProps = props.filter((prop) => !prop.ignore).sort((a, b) => a.readOnly && b.readOnly || !a.readOnly && !b.readOnly ? b.name.localeCompare(a.name) : a.readOnly ? 1 : -1);
160
+ const hasMap = props.some((prop) => (0, _powerlines_schema.isJsonSchemaMap)(prop));
161
+ const hasDate = props.some((prop) => (0, _powerlines_schema.isJsonSchemaDate)(prop));
162
+ return `${filteredProps.map((prop) => generateCapnpPropertySchema(prop, indexCounter)).join(" \n\n ")}${hasMap ? `
158
163
  struct Map(Key, Value) {
159
164
  entries @0 :List(Entry);
160
165
 
@@ -162,7 +167,7 @@ function generateCapnpSchema(reflection, options = {}) {
162
167
  key @0 :Key;
163
168
  value @1 :Value;
164
169
  }
165
- }` : ""}${reflection.getProperties().some((prop) => prop.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.class && prop.type.classType === Date) ? `
170
+ }` : ""}${hasDate ? `
166
171
  struct Date {
167
172
  # A standard Gregorian calendar date.
168
173
 
@@ -183,15 +188,8 @@ function generateCapnpSchema(reflection, options = {}) {
183
188
  millisecond @6 :UInt16; # Milliseconds of the second, 0-999
184
189
  }` : ""}`;
185
190
  }
186
- function generateCapnpMethodSchema(reflection, indexCounter) {
187
- const methodName = reflection.getTitle() || typeof reflection.getName() === "string" ? String(reflection.getName()) : "";
188
- if (!methodName) throw new Error(`Cannot generate Cap'n Proto schema for method without a name - Parent interface: ${reflection.reflectionClass.getName()}`);
189
- return `${(0, _stryke_string_format_camel_case.camelCase)(methodName)} @${indexCounter()} (${reflection.getParameters().map((param) => {
190
- return `${(0, _stryke_string_format_camel_case.camelCase)(param.getName())} :${generateCapnpPrimitive(param.getType())}${param.hasDefault() ? ` = ${stringifyCapnpDefaultValue(param)}` : ""}`;
191
- }).join(", ")})${isVoidType(reflection.getReturnType()) ? "" : ` -> (${(0, _powerlines_deepkit_utilities.kindToName)(reflection.getReturnType().kind)}: ${generateCapnpPrimitive(reflection.getReturnType())})`}; # ${(reflection.getDescription() || `The ${(0, _stryke_string_format_title_case.titleCase)(reflection.reflectionClass.getTitle() || reflection.reflectionClass.getName())} interface ${(0, _stryke_string_format_title_case.titleCase)(methodName)} method.`).replaceAll("\n", ". ")}`;
192
- }
193
- function generateCapnpPropertyComment(reflection) {
194
- const result = (0, _stryke_string_format_get_words.getWords)(reflection.getDescription() || `A schema property for ${(0, _stryke_string_format_title_case.titleCase)(reflection.getTitle() || reflection.getNameAsString())} field.`, { relaxed: true }).reduce((ret, word) => {
191
+ function generateCapnpPropertyComment(prop) {
192
+ const result = (0, _stryke_string_format_get_words.getWords)(prop.description || `A schema property for ${(0, _stryke_string_format_title_case.titleCase)(prop.title || prop.name)} field.`, { relaxed: true }).reduce((ret, word) => {
195
193
  let length = ret.length;
196
194
  if (ret.includes("\n")) length = ret.substring(ret.lastIndexOf("\n") + 1).length;
197
195
  const current = word.trim();
@@ -202,50 +200,65 @@ function generateCapnpPropertyComment(reflection) {
202
200
  if (result.length > 0) return `\t# ${result}`;
203
201
  return "";
204
202
  }
205
- function generateCapnpPropertySchema(reflection, indexCounter) {
206
- if (reflection.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.union) if (getCapnpUnionTypes(reflection.type).length === 0) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Void;
207
- ${generateCapnpPropertyComment(reflection)}`;
208
- else if (getCapnpUnionTypes(reflection.type).filter((type) => type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal && ((0, _stryke_type_checks_is_string.isString)(type.literal) || (0, _stryke_type_checks_is_number.isNumber)(type.literal))).length === 1) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${formatEnumName(reflection.getNameAsString())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
209
- ${generateCapnpPropertyComment(reflection)}`;
210
- else return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} :union {
211
- ${getCapnpUnionTypes(reflection.type).map((type) => ` ${(0, _powerlines_deepkit_utilities.kindToName)(type.kind)} @${indexCounter()} :${generateCapnpPrimitive(type)};`).join("\n")}
203
+ function generateCapnpPropertySchema(prop, indexCounter) {
204
+ const propName = prop.name;
205
+ const defaultStr = prop.default !== void 0 ? ` = ${stringifyCapnpDefaultValue(prop)}` : "";
206
+ if ((0, _powerlines_schema.isJsonSchemaUnion)(prop) || (0, _powerlines_schema.isJsonSchemaAnyOf)(prop)) {
207
+ const unionTypes = getCapnpUnionTypes(prop);
208
+ if (unionTypes.length === 0) return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} @${indexCounter()} :Void;
209
+ ${generateCapnpPropertyComment(prop)}`;
210
+ else if (unionTypes.filter((t) => (0, _powerlines_schema.isJsonSchemaLiteral)(t) && ((0, _stryke_type_checks_is_string.isString)(t.const) || (0, _stryke_type_checks_is_number.isNumber)(t.const))).length === 1) return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} @${indexCounter()} :${formatEnumName(propName)}${defaultStr};
211
+ ${generateCapnpPropertyComment(prop)}`;
212
+ else return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} :union {
213
+ ${unionTypes.map((t) => {
214
+ return ` ${getJsonSchemaCapnpTypeName(t)} @${indexCounter()} :${generateCapnpPrimitive(t)};`;
215
+ }).join("\n")}
212
216
  }
213
- ${generateCapnpPropertyComment(reflection)}`;
214
- else if (reflection.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.array) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :List(${generateCapnpPrimitive(reflection.getSubType())})${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
215
- ${generateCapnpPropertyComment(reflection)}`;
216
- else if (reflection.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.class) if (reflection.type.classType === Map) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Map(${!reflection.type.typeArguments || reflection.type.typeArguments.length === 0 || !reflection.type.typeArguments[0] ? "Data" : generateCapnpPrimitive(reflection.type.typeArguments[0])}, ${!reflection.type.typeArguments || reflection.type.typeArguments.length < 2 || !reflection.type.typeArguments[1] ? "Data" : generateCapnpPrimitive(reflection.type.typeArguments[1])})${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
217
- ${generateCapnpPropertyComment(reflection)}`;
218
- else if (reflection.type.classType === Date) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
219
- ${generateCapnpPropertyComment(reflection)}`;
220
- else if (reflection.type.classType === node_buffer.Buffer) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
221
- ${generateCapnpPropertyComment(reflection)}`;
222
- else if (reflection.type.classType === ArrayBuffer) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
223
- ${generateCapnpPropertyComment(reflection)}`;
224
- else return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${(0, _stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || (0, _powerlines_deepkit_vendor_core.getClassName)(reflection.type.classType))}${generateCapnpStruct(reflection.reflectionClass, { name: (0, _stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || (0, _powerlines_deepkit_vendor_core.getClassName)(reflection.type.classType)) })}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
225
- ${generateCapnpPropertyComment(reflection)}`;
226
- else if (reflection.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${(0, _stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || (0, _powerlines_deepkit_vendor_type.memberNameToString)(reflection.getNameAsString()))}${generateCapnpStruct(reflection.reflectionClass, { name: (0, _stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || (0, _powerlines_deepkit_vendor_type.memberNameToString)(reflection.getNameAsString())) })}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
227
- ${generateCapnpPropertyComment(reflection)}`;
228
- else if (reflection.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.enum) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${(0, _stryke_string_format_pascal_case.pascalCase)(reflection.getNameAsString())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
229
- ${generateCapnpPropertyComment(reflection)}`;
230
- return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${generateCapnpPrimitive(reflection.getType())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
231
- ${generateCapnpPropertyComment(reflection)}`;
217
+ ${generateCapnpPropertyComment(prop)}`;
218
+ } else if ((0, _powerlines_schema.isJsonSchemaMap)(prop)) {
219
+ const keySchema = prop.items?.prefixItems?.[0];
220
+ const valueSchema = prop.items?.prefixItems?.[1];
221
+ return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} @${indexCounter()} :Map(${keySchema ? generateCapnpPrimitive(keySchema) : "Data"}, ${valueSchema ? generateCapnpPrimitive(valueSchema) : "Data"})${defaultStr};
222
+ ${generateCapnpPropertyComment(prop)}`;
223
+ } else if ((0, _powerlines_schema.isJsonSchemaDate)(prop)) return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} @${indexCounter()} :Data${defaultStr};
224
+ ${generateCapnpPropertyComment(prop)}`;
225
+ else if ((0, _powerlines_schema.isJsonSchemaSet)(prop) || (0, _powerlines_schema.isJsonSchemaTuple)(prop)) {
226
+ const itemSchema = prop.items;
227
+ return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} @${indexCounter()} :List(${itemSchema ? generateCapnpPrimitive(itemSchema) : "Data"})${defaultStr};
228
+ ${generateCapnpPropertyComment(prop)}`;
229
+ } else if ((0, _powerlines_schema.isJsonSchemaArray)(prop)) {
230
+ const itemSchema = prop.items;
231
+ return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} @${indexCounter()} :List(${itemSchema ? generateCapnpPrimitive(itemSchema) : "Data"})${defaultStr};
232
+ ${generateCapnpPropertyComment(prop)}`;
233
+ } else if ((0, _powerlines_schema.isJsonSchemaRef)(prop)) {
234
+ const refName = prop.$ref.split("/").pop() || prop.$ref;
235
+ return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} @${indexCounter()} :${(0, _stryke_string_format_pascal_case.pascalCase)(refName)}${defaultStr};
236
+ ${generateCapnpPropertyComment(prop)}`;
237
+ } else if ((0, _powerlines_schema.isJsonSchemaObject)(prop) || (0, _powerlines_schema.isJsonSchemaRecord)(prop)) {
238
+ const typeName = prop.title || propName;
239
+ return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} @${indexCounter()} :${(0, _stryke_string_format_pascal_case.pascalCase)(typeName)}${generateCapnpStruct(prop, { name: (0, _stryke_string_format_pascal_case.pascalCase)(typeName) })}${defaultStr};
240
+ ${generateCapnpPropertyComment(prop)}`;
241
+ } else if ((0, _powerlines_schema.isJsonSchemaEnum)(prop) || (0, _powerlines_schema.isJsonSchemaNativeEnum)(prop)) return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} @${indexCounter()} :${(0, _stryke_string_format_pascal_case.pascalCase)(propName)}${defaultStr};
242
+ ${generateCapnpPropertyComment(prop)}`;
243
+ return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} @${indexCounter()} :${generateCapnpPrimitive(prop)}${defaultStr};
244
+ ${generateCapnpPropertyComment(prop)}`;
232
245
  }
233
- function generateCapnpEnumSchema(type, name) {
234
- if (type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.union) return generateCapnpEnumSchema({
235
- kind: _powerlines_deepkit_vendor_type.ReflectionKind.enum,
236
- indexType: type,
237
- enum: type.types.reduce((ret, type) => {
238
- if ((0, _stryke_type_checks_is_string.isString)(type.literal) || (0, _stryke_type_checks_is_number.isNumber)(type.literal)) ret[(0, _stryke_string_format_camel_case.camelCase)(String(type.literal))] = type.literal;
239
- return ret;
240
- }, {}),
241
- values: getCapnpUnionTypes(type).filter((type) => type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal && ((0, _stryke_type_checks_is_string.isString)(type.literal) || (0, _stryke_type_checks_is_number.isNumber)(type.literal))).map((type) => type.literal)
242
- }, name);
246
+ function generateCapnpEnumSchema(schema, name) {
247
+ if ((0, _powerlines_schema.isJsonSchemaAnyOf)(schema)) {
248
+ const enumValues = (schema.anyOf || []).filter((t) => (0, _powerlines_schema.isJsonSchemaLiteral)(t) && ((0, _stryke_type_checks_is_string.isString)(t.const) || (0, _stryke_type_checks_is_number.isNumber)(t.const))).map((t) => t.const);
249
+ return generateCapnpEnumSchema({
250
+ type: enumValues.some((v) => (0, _stryke_type_checks_is_string.isString)(v)) ? "string" : "number",
251
+ enum: enumValues
252
+ }, name);
253
+ }
243
254
  let index = 0;
244
255
  const indexCounter = () => index++;
245
- const enumType = getCapnpEnumTypes(type);
256
+ const enumType = getCapnpEnumTypes(schema);
246
257
  if (!enumType) return "";
258
+ const values = (schema.enum || []).filter((v) => v !== null && v !== void 0);
259
+ const schemaTitle = schema.title;
247
260
  return `enum ${(0, _stryke_string_format_pascal_case.pascalCase)(name)} {
248
- ${type.enum && Object.entries(type.enum).length > 0 ? Object.entries(type.enum).filter(([, value]) => value !== null && value !== void 0).map(([key]) => ` ${(0, _stryke_string_format_camel_case.camelCase)(key)} @${indexCounter()};`).join("\n") : type.values.filter((value) => value !== null && value !== void 0).map((value) => `${enumType === "Text" && value ? (0, _stryke_string_format_camel_case.camelCase)(String(value)) : `${type.typeName ? `${(0, _stryke_string_format_camel_case.camelCase)(type.typeName)}_` : ""}${value || ""}`} @${indexCounter()};`).join("\n")}
261
+ ${values.map((value) => ` ${enumType === "Text" && value ? (0, _stryke_string_format_camel_case.camelCase)(String(value)) : `${schemaTitle ? `${(0, _stryke_string_format_camel_case.camelCase)(schemaTitle)}_` : ""}${value || ""}`} @${indexCounter()};`).join("\n")}
249
262
  }`;
250
263
  }
251
264
  /**
@@ -254,8 +267,50 @@ ${type.enum && Object.entries(type.enum).length > 0 ? Object.entries(type.enum).
254
267
  * @param type - The Deepkit Type to convert.
255
268
  * @returns A string representation of the Cap'n Proto primitive type.
256
269
  */
257
- function generateCapnpPrimitive(type) {
258
- return type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.never || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.void || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.null || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.undefined || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.symbol ? "Void" : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.class && type.classType === Date ? "Date" : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.class && type.classType === Set ? `List(${type.typeArguments && type.typeArguments[0] ? generateCapnpPrimitive(type.typeArguments[0]) : "Data"})` : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.bigint ? "UInt64" : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.number ? "Float64" : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.string || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.regexp ? "Text" : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.boolean ? "Bool" : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal ? (0, _stryke_type_checks_is_number.isNumber)(type.literal) ? "Float64" : (0, _stryke_type_checks_is_bigint.isBigInt)(type.literal) ? "UInt64" : (0, _stryke_type_checks_is_string.isString)(type.literal) ? "Text" : typeof type.literal === "boolean" ? "Bool" : "Data" : "Data";
270
+ /**
271
+ * Generates a string representation of Cap'n Proto primitive types from a JSON Schema.
272
+ *
273
+ * @param schema - The JSON Schema to convert.
274
+ * @returns A string representation of the Cap'n Proto primitive type.
275
+ */
276
+ function generateCapnpPrimitive(schema) {
277
+ if ((0, _powerlines_schema.isJsonSchemaNever)(schema) || (0, _powerlines_schema.isJsonSchemaNull)(schema) || (0, _powerlines_schema.isJsonSchemaUndefined)(schema)) return "Void";
278
+ if ((0, _powerlines_schema.isJsonSchemaDate)(schema)) return "Date";
279
+ if ((0, _powerlines_schema.isJsonSchemaSet)(schema)) {
280
+ const itemSchema = schema.items;
281
+ return `List(${itemSchema ? generateCapnpPrimitive(itemSchema) : "Data"})`;
282
+ }
283
+ if ((0, _powerlines_schema.isJsonSchemaBigint)(schema)) return "UInt64";
284
+ if ((0, _powerlines_schema.isJsonSchemaNumber)(schema) || (0, _powerlines_schema.isJsonSchemaInteger)(schema)) return "Float64";
285
+ if ((0, _powerlines_schema.isJsonSchemaString)(schema)) return "Text";
286
+ if ((0, _powerlines_schema.isJsonSchemaBoolean)(schema)) return "Bool";
287
+ if ((0, _powerlines_schema.isJsonSchemaLiteral)(schema)) {
288
+ const constVal = schema.const;
289
+ if ((0, _stryke_type_checks_is_number.isNumber)(constVal)) return "Float64";
290
+ if ((0, _stryke_type_checks_is_bigint.isBigInt)(constVal)) return "UInt64";
291
+ if ((0, _stryke_type_checks_is_string.isString)(constVal)) return "Text";
292
+ if (typeof constVal === "boolean") return "Bool";
293
+ }
294
+ return "Data";
295
+ }
296
+ /**
297
+ * Returns a descriptive Cap'n Proto field name for a JSON Schema member in a union.
298
+ *
299
+ * @param schema - The JSON Schema union member.
300
+ * @returns A camelCase name suitable for use as a Cap'n Proto union field label.
301
+ */
302
+ function getJsonSchemaCapnpTypeName(schema) {
303
+ const s = schema;
304
+ if (s.title || s.name) return (0, _stryke_string_format_camel_case.camelCase)(String(s.title || s.name));
305
+ if (s.type) return (0, _stryke_string_format_camel_case.camelCase)(Array.isArray(s.type) ? String(s.type[0]) : String(s.type));
306
+ if ("const" in s) {
307
+ if ((0, _stryke_type_checks_is_string.isString)(s.const)) return "string";
308
+ if ((0, _stryke_type_checks_is_number.isNumber)(s.const)) return "number";
309
+ if (typeof s.const === "boolean") return "bool";
310
+ if ((0, _stryke_type_checks_is_bigint.isBigInt)(s.const)) return "bigInt";
311
+ }
312
+ if (s.anyOf) return "union";
313
+ return "data";
259
314
  }
260
315
 
261
316
  //#endregion
@@ -265,7 +320,6 @@ exports.generateCapnp = generateCapnp;
265
320
  exports.generateCapnpEnumSchema = generateCapnpEnumSchema;
266
321
  exports.generateCapnpId = generateCapnpId;
267
322
  exports.generateCapnpInterface = generateCapnpInterface;
268
- exports.generateCapnpMethodSchema = generateCapnpMethodSchema;
269
323
  exports.generateCapnpPrimitive = generateCapnpPrimitive;
270
324
  exports.generateCapnpSchema = generateCapnpSchema;
271
325
  exports.generateCapnpStruct = generateCapnpStruct;
@@ -1,5 +1,5 @@
1
1
  import { Context, PluginContext } from "powerlines";
2
- import { ReflectionClass, ReflectionMethod, ReflectionParameter, ReflectionProperty, Type, TypeEnum, TypeUnion } from "@powerlines/deepkit/vendor/type";
2
+ import { GetPropertiesResult, JsonSchema, JsonSchemaAnyOf, JsonSchemaEnum, JsonSchemaNativeEnum, JsonSchemaObject } from "@powerlines/schema";
3
3
  import { CapnpcOptions, CapnpcResult } from "@stryke/capnp/types";
4
4
 
5
5
  //#region src/helpers/capnp.d.ts
@@ -18,7 +18,7 @@ declare function compile(context: Context, options?: Partial<CapnpcOptions>): Pr
18
18
  * @param value - The value to stringify.
19
19
  * @returns A string representation of the value.
20
20
  */
21
- declare function stringifyCapnpDefaultValue(property: ReflectionProperty | ReflectionParameter, value?: any): string;
21
+ declare function stringifyCapnpDefaultValue(property: GetPropertiesResult, value?: any): string;
22
22
  /**
23
23
  * Converts any {@link Type}'s actual value to string representation.
24
24
  *
@@ -26,35 +26,35 @@ declare function stringifyCapnpDefaultValue(property: ReflectionProperty | Refle
26
26
  * @param value - The value to stringify.
27
27
  * @returns A string representation of the value.
28
28
  */
29
- declare function stringifyCapnpValue(type: Type, value: any): string;
29
+ declare function stringifyCapnpValue(schema: JsonSchema, value: any): string;
30
30
  /**
31
31
  * Converts a ReflectionProperty's default value to a Cap'n Proto schema string representation.
32
32
  *
33
33
  * @param type - The TypeEnum to evaluate.
34
34
  * @returns A string representation of the property.
35
35
  */
36
- declare function getCapnpEnumTypes(type: Type): "Text" | "Float32" | null;
36
+ declare function getCapnpEnumTypes(schema: JsonSchema): "Text" | "Float32" | null;
37
37
  /**
38
38
  * Determines if a Type is a `Void` type in a Cap'n Proto schema.
39
39
  *
40
40
  * @param type - The Type to check.
41
41
  * @returns True if the Type is a `Void` type, false otherwise.
42
42
  */
43
- declare function isVoidType(type: Type): boolean;
43
+ declare function isVoidType(schema: JsonSchema): boolean;
44
44
  /**
45
45
  * Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
46
46
  *
47
47
  * @param type - The {@link TypeUnion} to convert.
48
48
  * @returns A string representation of the Cap'n Proto primitive type.
49
49
  */
50
- declare function getCapnpUnionTypes(type: Type): Type[];
50
+ declare function getCapnpUnionTypes(schema: JsonSchema): JsonSchema[];
51
51
  /**
52
52
  * Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
53
53
  *
54
54
  * @param type - The {@link TypeUnion} to convert.
55
55
  * @returns An array of Cap'n Proto primitive types.
56
56
  */
57
- declare function isCapnpStringUnion(type: Type): boolean;
57
+ declare function isCapnpStringUnion(schema: JsonSchema): boolean;
58
58
  declare const LARGE_BUFFER: number;
59
59
  type IOType = "overlapped" | "pipe" | "ignore" | "inherit";
60
60
  type StdioOptions = IOType | Array<IOType | "ipc" | number | null | undefined>;
@@ -62,22 +62,27 @@ declare function generateCapnpId(): Promise<string>;
62
62
  interface GenerateCapnpOptions {
63
63
  name?: string;
64
64
  }
65
- declare function generateCapnp(context: PluginContext, reflection: ReflectionClass<any>, options: GenerateCapnpOptions): Promise<string>;
65
+ declare function generateCapnp(context: PluginContext, schema: JsonSchemaObject, options: GenerateCapnpOptions): Promise<string>;
66
66
  interface GenerateCapnpStructOptions extends GenerateCapnpOptions {
67
67
  indexCounter?: () => number;
68
68
  }
69
- declare function generateCapnpStruct(reflection: ReflectionClass<any>, options?: GenerateCapnpStructOptions): string;
70
- declare function generateCapnpInterface(reflection: ReflectionClass<any>, options?: GenerateCapnpStructOptions): string;
71
- declare function generateCapnpSchema(reflection: ReflectionClass<any>, options?: GenerateCapnpStructOptions): string;
72
- declare function generateCapnpMethodSchema(reflection: ReflectionMethod, indexCounter: () => number): string;
73
- declare function generateCapnpEnumSchema(type: TypeEnum | TypeUnion, name: string): string;
69
+ declare function generateCapnpStruct(schema: JsonSchemaObject, options?: GenerateCapnpStructOptions): string;
70
+ declare function generateCapnpInterface(schema: JsonSchemaObject, options?: GenerateCapnpStructOptions): string;
71
+ declare function generateCapnpSchema(schema: JsonSchemaObject, options?: GenerateCapnpStructOptions): string;
72
+ declare function generateCapnpEnumSchema(schema: JsonSchemaEnum | JsonSchemaNativeEnum | JsonSchemaAnyOf, name: string): string;
74
73
  /**
75
74
  * Generates a string representation of Cap'n Proto primitive types from a Deepkit Type.
76
75
  *
77
76
  * @param type - The Deepkit Type to convert.
78
77
  * @returns A string representation of the Cap'n Proto primitive type.
79
78
  */
80
- declare function generateCapnpPrimitive(type: Type): string;
79
+ /**
80
+ * Generates a string representation of Cap'n Proto primitive types from a JSON Schema.
81
+ *
82
+ * @param schema - The JSON Schema to convert.
83
+ * @returns A string representation of the Cap'n Proto primitive type.
84
+ */
85
+ declare function generateCapnpPrimitive(schema: JsonSchema): string;
81
86
  //#endregion
82
- export { GenerateCapnpOptions, GenerateCapnpStructOptions, IOType, LARGE_BUFFER, StdioOptions, compile, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpMethodSchema, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, stringifyCapnpDefaultValue, stringifyCapnpValue };
87
+ export { GenerateCapnpOptions, GenerateCapnpStructOptions, IOType, LARGE_BUFFER, StdioOptions, compile, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, stringifyCapnpDefaultValue, stringifyCapnpValue };
83
88
  //# sourceMappingURL=capnp.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"capnp.d.cts","names":[],"sources":["../../src/helpers/capnp.ts"],"mappings":";;;;;;;AA8DA;;;;;iBAAsB,OAAA,CACpB,OAAA,EAAS,OAAA,EACT,OAAA,GAAS,OAAA,CAAQ,aAAA,IAChB,OAAA,CAAQ,YAAA;;;;;;;;iBA+BK,0BAAA,CACd,QAAA,EAAU,kBAAA,GAAqB,mBAAmB,EAClD,KAAA;;;;;AAjCqB;AA+BvB;;iBAiBgB,mBAAA,CAAoB,IAAA,EAAM,IAAI,EAAE,KAAA;;;;;;;iBAoBhC,iBAAA,CAAkB,IAAU,EAAJ,IAAI;AApB5C;;;;;;AAAA,iBA0CgB,UAAA,CAAW,IAAU,EAAJ,IAAI;;AA1CqB;AAoB1D;;;;iBAsCgB,kBAAA,CAAmB,IAAA,EAAM,IAAA,GAAO,IAAI;AAhBpD;;;;AAAqC;AAgBrC;AAhBA,iBA0BgB,kBAAA,CAAmB,IAAU,EAAJ,IAAI;AAAA,cAMhC,YAAA;AAAA,KACD,MAAA;AAAA,KACA,YAAA,GACR,MAAA,GACA,KAAA,CAAM,MAAA;AAAA,iBAIY,eAAA,IAAe,OAAA;AAAA,UAUpB,oBAAA;EACf,IAAI;AAAA;AAAA,iBAGgB,aAAA,CACpB,OAAA,EAAS,aAAA,EACT,UAAA,EAAY,eAAA,OACZ,OAAA,EAAS,oBAAA,GAAoB,OAAA;AAAA,UAgBd,0BAAA,SAAmC,oBAAoB;EACtE,YAAY;AAAA;AAAA,iBAGE,mBAAA,CACd,UAAA,EAAY,eAAA,OACZ,OAAA,GAAS,0BAA+B;AAAA,iBAgB1B,sBAAA,CACd,UAAA,EAAY,eAAA,OACZ,OAAA,GAAS,0BAA+B;AAAA,iBAyD1B,mBAAA,CACd,UAAA,EAAY,eAAA,OACZ,OAAA,GAAS,0BAA+B;AAAA,iBA4E1B,yBAAA,CACd,UAAA,EAAY,gBAAgB,EAC5B,YAAA;AAAA,iBA0Mc,uBAAA,CACd,IAAA,EAAM,QAAA,GAAW,SAAS,EAC1B,IAAA;AAtZwC;AAC1C;;;;AAAkB;AADwB,iBAwd1B,sBAAA,CAAuB,IAAU,EAAJ,IAAI"}
1
+ {"version":3,"file":"capnp.d.cts","names":[],"sources":["../../src/helpers/capnp.ts"],"mappings":";;;;;;;AA8EA;;;;;iBAAsB,OAAA,CACpB,OAAA,EAAS,OAAA,EACT,OAAA,GAAS,OAAA,CAAQ,aAAA,IAChB,OAAA,CAAQ,YAAA;;;;;;;;iBA+BK,0BAAA,CACd,QAAA,EAAU,mBAAmB,EAC7B,KAAA;;;;;AAjCqB;AA+BvB;;iBAcgB,mBAAA,CAAoB,MAAA,EAAQ,UAAU,EAAE,KAAA;;;;;;AAZ3C;iBA+BG,iBAAA,CACd,MAAkB,EAAV,UAAU;;;;;;;iBAuBJ,UAAA,CAAW,MAAkB,EAAV,UAAU;AA3CqB;AAmBlE;;;;AACoB;AApB8C,iBAyDlD,kBAAA,CAAmB,MAAA,EAAQ,UAAA,GAAa,UAAU;;;;AAdrB;AAc7C;;iBAoBgB,kBAAA,CAAmB,MAAkB,EAAV,UAAU;AAAA,cASxC,YAAA;AAAA,KACD,MAAA;AAAA,KACA,YAAA,GACR,MAAA,GACA,KAAA,CAAM,MAAA;AAAA,iBAIY,eAAA,IAAe,OAAA;AAAA,UAUpB,oBAAA;EACf,IAAI;AAAA;AAAA,iBAGgB,aAAA,CACpB,OAAA,EAAS,aAAA,EACT,MAAA,EAAQ,gBAAA,EACR,OAAA,EAAS,oBAAA,GAAoB,OAAA;AAAA,UAYd,0BAAA,SAAmC,oBAAoB;EACtE,YAAY;AAAA;AAAA,iBAGE,mBAAA,CACd,MAAA,EAAQ,gBAAA,EACR,OAAA,GAAS,0BAA+B;AAAA,iBAY1B,sBAAA,CACd,MAAA,EAAQ,gBAAA,EACR,OAAA,GAAS,0BAA+B;AAAA,iBA2D1B,mBAAA,CACd,MAAA,EAAQ,gBAAA,EACR,OAAA,GAAS,0BAA+B;AAAA,iBAiL1B,uBAAA,CACd,MAAA,EAAQ,cAAA,GAAiB,oBAAA,GAAuB,eAAA,EAChD,IAAA;AAzSwC;AAC1C;;;;AAAkB;AAClB;;;;;;AAAA,iBAmWgB,sBAAA,CAAuB,MAAkB,EAAV,UAAU"}
@@ -1,4 +1,4 @@
1
- import { ReflectionClass, ReflectionMethod, ReflectionParameter, ReflectionProperty, Type, TypeEnum, TypeUnion } from "@powerlines/deepkit/vendor/type";
1
+ import { GetPropertiesResult, JsonSchema, JsonSchemaAnyOf, JsonSchemaEnum, JsonSchemaNativeEnum, JsonSchemaObject } from "@powerlines/schema";
2
2
  import { Context, PluginContext } from "powerlines";
3
3
  import { CapnpcOptions, CapnpcResult } from "@stryke/capnp/types";
4
4
 
@@ -18,7 +18,7 @@ declare function compile(context: Context, options?: Partial<CapnpcOptions>): Pr
18
18
  * @param value - The value to stringify.
19
19
  * @returns A string representation of the value.
20
20
  */
21
- declare function stringifyCapnpDefaultValue(property: ReflectionProperty | ReflectionParameter, value?: any): string;
21
+ declare function stringifyCapnpDefaultValue(property: GetPropertiesResult, value?: any): string;
22
22
  /**
23
23
  * Converts any {@link Type}'s actual value to string representation.
24
24
  *
@@ -26,35 +26,35 @@ declare function stringifyCapnpDefaultValue(property: ReflectionProperty | Refle
26
26
  * @param value - The value to stringify.
27
27
  * @returns A string representation of the value.
28
28
  */
29
- declare function stringifyCapnpValue(type: Type, value: any): string;
29
+ declare function stringifyCapnpValue(schema: JsonSchema, value: any): string;
30
30
  /**
31
31
  * Converts a ReflectionProperty's default value to a Cap'n Proto schema string representation.
32
32
  *
33
33
  * @param type - The TypeEnum to evaluate.
34
34
  * @returns A string representation of the property.
35
35
  */
36
- declare function getCapnpEnumTypes(type: Type): "Text" | "Float32" | null;
36
+ declare function getCapnpEnumTypes(schema: JsonSchema): "Text" | "Float32" | null;
37
37
  /**
38
38
  * Determines if a Type is a `Void` type in a Cap'n Proto schema.
39
39
  *
40
40
  * @param type - The Type to check.
41
41
  * @returns True if the Type is a `Void` type, false otherwise.
42
42
  */
43
- declare function isVoidType(type: Type): boolean;
43
+ declare function isVoidType(schema: JsonSchema): boolean;
44
44
  /**
45
45
  * Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
46
46
  *
47
47
  * @param type - The {@link TypeUnion} to convert.
48
48
  * @returns A string representation of the Cap'n Proto primitive type.
49
49
  */
50
- declare function getCapnpUnionTypes(type: Type): Type[];
50
+ declare function getCapnpUnionTypes(schema: JsonSchema): JsonSchema[];
51
51
  /**
52
52
  * Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
53
53
  *
54
54
  * @param type - The {@link TypeUnion} to convert.
55
55
  * @returns An array of Cap'n Proto primitive types.
56
56
  */
57
- declare function isCapnpStringUnion(type: Type): boolean;
57
+ declare function isCapnpStringUnion(schema: JsonSchema): boolean;
58
58
  declare const LARGE_BUFFER: number;
59
59
  type IOType = "overlapped" | "pipe" | "ignore" | "inherit";
60
60
  type StdioOptions = IOType | Array<IOType | "ipc" | number | null | undefined>;
@@ -62,22 +62,27 @@ declare function generateCapnpId(): Promise<string>;
62
62
  interface GenerateCapnpOptions {
63
63
  name?: string;
64
64
  }
65
- declare function generateCapnp(context: PluginContext, reflection: ReflectionClass<any>, options: GenerateCapnpOptions): Promise<string>;
65
+ declare function generateCapnp(context: PluginContext, schema: JsonSchemaObject, options: GenerateCapnpOptions): Promise<string>;
66
66
  interface GenerateCapnpStructOptions extends GenerateCapnpOptions {
67
67
  indexCounter?: () => number;
68
68
  }
69
- declare function generateCapnpStruct(reflection: ReflectionClass<any>, options?: GenerateCapnpStructOptions): string;
70
- declare function generateCapnpInterface(reflection: ReflectionClass<any>, options?: GenerateCapnpStructOptions): string;
71
- declare function generateCapnpSchema(reflection: ReflectionClass<any>, options?: GenerateCapnpStructOptions): string;
72
- declare function generateCapnpMethodSchema(reflection: ReflectionMethod, indexCounter: () => number): string;
73
- declare function generateCapnpEnumSchema(type: TypeEnum | TypeUnion, name: string): string;
69
+ declare function generateCapnpStruct(schema: JsonSchemaObject, options?: GenerateCapnpStructOptions): string;
70
+ declare function generateCapnpInterface(schema: JsonSchemaObject, options?: GenerateCapnpStructOptions): string;
71
+ declare function generateCapnpSchema(schema: JsonSchemaObject, options?: GenerateCapnpStructOptions): string;
72
+ declare function generateCapnpEnumSchema(schema: JsonSchemaEnum | JsonSchemaNativeEnum | JsonSchemaAnyOf, name: string): string;
74
73
  /**
75
74
  * Generates a string representation of Cap'n Proto primitive types from a Deepkit Type.
76
75
  *
77
76
  * @param type - The Deepkit Type to convert.
78
77
  * @returns A string representation of the Cap'n Proto primitive type.
79
78
  */
80
- declare function generateCapnpPrimitive(type: Type): string;
79
+ /**
80
+ * Generates a string representation of Cap'n Proto primitive types from a JSON Schema.
81
+ *
82
+ * @param schema - The JSON Schema to convert.
83
+ * @returns A string representation of the Cap'n Proto primitive type.
84
+ */
85
+ declare function generateCapnpPrimitive(schema: JsonSchema): string;
81
86
  //#endregion
82
- export { GenerateCapnpOptions, GenerateCapnpStructOptions, IOType, LARGE_BUFFER, StdioOptions, compile, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpMethodSchema, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, stringifyCapnpDefaultValue, stringifyCapnpValue };
87
+ export { GenerateCapnpOptions, GenerateCapnpStructOptions, IOType, LARGE_BUFFER, StdioOptions, compile, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, stringifyCapnpDefaultValue, stringifyCapnpValue };
83
88
  //# sourceMappingURL=capnp.d.mts.map