@powerlines/plugin-alloy 0.26.126 → 0.26.127

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 (65) hide show
  1. package/dist/core/contexts/index.cjs +9 -10
  2. package/dist/core/contexts/index.d.cts +2 -2
  3. package/dist/core/contexts/index.d.mts +2 -2
  4. package/dist/core/contexts/index.mjs +2 -2
  5. package/dist/core/contexts/{reflection.cjs → schema.cjs} +18 -29
  6. package/dist/core/contexts/schema.d.cts +48 -0
  7. package/dist/core/contexts/schema.d.cts.map +1 -0
  8. package/dist/core/contexts/schema.d.mts +48 -0
  9. package/dist/core/contexts/schema.d.mts.map +1 -0
  10. package/dist/core/contexts/schema.mjs +61 -0
  11. package/dist/core/contexts/schema.mjs.map +1 -0
  12. package/dist/core/index.cjs +9 -10
  13. package/dist/core/index.d.cts +2 -2
  14. package/dist/core/index.d.mts +2 -2
  15. package/dist/core/index.mjs +2 -2
  16. package/dist/typescript/components/index.cjs +4 -7
  17. package/dist/typescript/components/index.d.cts +5 -5
  18. package/dist/typescript/components/index.d.mts +5 -5
  19. package/dist/typescript/components/index.mjs +3 -3
  20. package/dist/typescript/components/interface-declaration.cjs +52 -52
  21. package/dist/typescript/components/interface-declaration.d.cts +19 -21
  22. package/dist/typescript/components/interface-declaration.d.cts.map +1 -1
  23. package/dist/typescript/components/interface-declaration.d.mts +19 -21
  24. package/dist/typescript/components/interface-declaration.d.mts.map +1 -1
  25. package/dist/typescript/components/interface-declaration.mjs +52 -52
  26. package/dist/typescript/components/interface-declaration.mjs.map +1 -1
  27. package/dist/typescript/components/object-declaration.cjs +40 -56
  28. package/dist/typescript/components/object-declaration.d.cts +6 -11
  29. package/dist/typescript/components/object-declaration.d.cts.map +1 -1
  30. package/dist/typescript/components/object-declaration.d.mts +6 -11
  31. package/dist/typescript/components/object-declaration.d.mts.map +1 -1
  32. package/dist/typescript/components/object-declaration.mjs +41 -57
  33. package/dist/typescript/components/object-declaration.mjs.map +1 -1
  34. package/dist/typescript/components/tsdoc-schema.cjs +171 -0
  35. package/dist/typescript/components/tsdoc-schema.d.cts +21 -0
  36. package/dist/typescript/components/tsdoc-schema.d.cts.map +1 -0
  37. package/dist/typescript/components/tsdoc-schema.d.mts +21 -0
  38. package/dist/typescript/components/tsdoc-schema.d.mts.map +1 -0
  39. package/dist/typescript/components/tsdoc-schema.mjs +169 -0
  40. package/dist/typescript/components/tsdoc-schema.mjs.map +1 -0
  41. package/dist/typescript/components/tsdoc.cjs +30 -19
  42. package/dist/typescript/components/tsdoc.d.cts +16 -12
  43. package/dist/typescript/components/tsdoc.d.cts.map +1 -1
  44. package/dist/typescript/components/tsdoc.d.mts +16 -12
  45. package/dist/typescript/components/tsdoc.d.mts.map +1 -1
  46. package/dist/typescript/components/tsdoc.mjs +30 -20
  47. package/dist/typescript/components/tsdoc.mjs.map +1 -1
  48. package/dist/typescript/index.cjs +4 -7
  49. package/dist/typescript/index.d.cts +5 -5
  50. package/dist/typescript/index.d.mts +5 -5
  51. package/dist/typescript/index.mjs +3 -3
  52. package/package.json +12 -12
  53. package/dist/core/contexts/reflection.d.cts +0 -62
  54. package/dist/core/contexts/reflection.d.cts.map +0 -1
  55. package/dist/core/contexts/reflection.d.mts +0 -62
  56. package/dist/core/contexts/reflection.d.mts.map +0 -1
  57. package/dist/core/contexts/reflection.mjs +0 -71
  58. package/dist/core/contexts/reflection.mjs.map +0 -1
  59. package/dist/typescript/components/tsdoc-reflection.cjs +0 -331
  60. package/dist/typescript/components/tsdoc-reflection.d.cts +0 -41
  61. package/dist/typescript/components/tsdoc-reflection.d.cts.map +0 -1
  62. package/dist/typescript/components/tsdoc-reflection.d.mts +0 -41
  63. package/dist/typescript/components/tsdoc-reflection.d.mts.map +0 -1
  64. package/dist/typescript/components/tsdoc-reflection.mjs +0 -325
  65. package/dist/typescript/components/tsdoc-reflection.mjs.map +0 -1
@@ -1,17 +1,19 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
- const require_core_contexts_reflection = require('../../core/contexts/reflection.cjs');
3
+ const require_core_contexts_schema = require('../../core/contexts/schema.cjs');
4
4
  const require_typescript_components_tsdoc = require('./tsdoc.cjs');
5
5
  const require_typescript_contexts_member_scope = require('../contexts/member-scope.cjs');
6
6
  const require_typescript_components_property_name = require('./property-name.cjs');
7
7
  const require_typescript_components_type_parameters = require('./type-parameters.cjs');
8
- const require_typescript_components_tsdoc_reflection = require('./tsdoc-reflection.cjs');
8
+ const require_typescript_components_tsdoc_schema = require('./tsdoc-schema.cjs');
9
9
  let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
10
10
  let _alloy_js_core = require("@alloy-js/core");
11
- let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
11
+ let _stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
12
12
  let _stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
13
- let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
14
13
  let _alloy_js_typescript = require("@alloy-js/typescript");
14
+ let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
15
+ let _powerlines_schema = require("@powerlines/schema");
16
+ let _stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
15
17
 
16
18
  //#region src/typescript/components/interface-declaration.tsx
17
19
  const InterfaceExpression = (0, _alloy_js_typescript.ensureTypeRefContext)(function InterfaceExpression(props) {
@@ -41,8 +43,8 @@ const InterfaceExpression = (0, _alloy_js_typescript.ensureTypeRefContext)(funct
41
43
  * children of the component.
42
44
  */
43
45
  function InterfaceMember(props) {
44
- const type = props.type ?? props.children;
45
- const readonly = props.readonly ? "readonly " : "";
46
+ const type = props.schema ? (0, _powerlines_schema.stringifyType)(props.schema) : props.type ?? props.children;
47
+ const readonly = props.schema && props.schema?.metadata?.isReadonly || !props.schema && props.isReadonly ? "readonly " : "";
46
48
  if ("indexer" in props) return [
47
49
  (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
48
50
  get when() {
@@ -60,11 +62,11 @@ function InterfaceMember(props) {
60
62
  "]: ",
61
63
  type
62
64
  ];
63
- const optionality = props.optional ? "?" : "";
65
+ const optional = !!(props.schema && props.schema?.nullable) || !!(!props.schema && props.optional);
64
66
  const scope = (0, _alloy_js_typescript.useTSMemberScope)();
65
- const sym = (0, _alloy_js_core.createSymbol)(_alloy_js_typescript.TSOutputSymbol, props.name, scope.ownerSymbol.staticMembers, {
67
+ const sym = (0, _alloy_js_core.createSymbol)(_alloy_js_typescript.TSOutputSymbol, String((props.schema ? props.schema.metadata?.name || props.schema.metadata?.resourceId : (0, _stryke_type_checks_is_set_string.isSetString)(props.name) ? props.name : props.name.toString()) || (0, _stryke_unique_id_uuid.uuid)().replace(/-/g, "")), scope.ownerSymbol.staticMembers, {
66
68
  refkeys: props.refkey,
67
- tsFlags: _alloy_js_typescript.TSSymbolFlags.TypeSymbol | (props.nullish ?? props.optional ? _alloy_js_typescript.TSSymbolFlags.Nullish : _alloy_js_typescript.TSSymbolFlags.None),
69
+ tsFlags: _alloy_js_typescript.TSSymbolFlags.TypeSymbol | (optional ? _alloy_js_typescript.TSSymbolFlags.Nullish : _alloy_js_typescript.TSSymbolFlags.None),
68
70
  namePolicy: (0, _alloy_js_typescript.useTSNamePolicy)().for("interface-member"),
69
71
  binder: scope.binder
70
72
  });
@@ -90,7 +92,7 @@ function InterfaceMember(props) {
90
92
  }),
91
93
  readonly,
92
94
  (0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_property_name.PropertyName, {}),
93
- optionality,
95
+ optional ? "?" : "",
94
96
  ": ",
95
97
  type
96
98
  ];
@@ -104,7 +106,7 @@ const BaseInterfaceDeclaration = (0, _alloy_js_typescript.ensureTypeRefContext)(
104
106
  const filteredChildren = (0, _alloy_js_core.findUnkeyedChildren)(children);
105
107
  const currentScope = (0, _alloy_js_typescript.useTSLexicalScope)();
106
108
  const binder = currentScope?.binder;
107
- const sym = (0, _alloy_js_core.createSymbol)(_alloy_js_typescript.TSOutputSymbol, props.name, currentScope.types, {
109
+ const sym = (0, _alloy_js_core.createSymbol)(_alloy_js_typescript.TSOutputSymbol, ((0, _stryke_type_checks_is_set_string.isSetString)(props.name) ? props.name : props.name?.toString()) || (0, _stryke_unique_id_uuid.uuid)().replace(/-/g, ""), currentScope.types, {
108
110
  refkeys: props.refkey,
109
111
  default: props.default,
110
112
  export: props.export,
@@ -149,20 +151,19 @@ const BaseInterfaceDeclaration = (0, _alloy_js_typescript.ensureTypeRefContext)(
149
151
  }))];
150
152
  });
151
153
  /**
152
- * Generates a TypeScript interface for the given reflection class.
154
+ * Generates a TypeScript interface for the given schema.
153
155
  */
154
156
  function InterfaceDeclaration(props) {
155
- const [{ name, reflection, doc, defaultValue }, rest] = (0, _alloy_js_core.splitProps)(props, [
157
+ const [{ name, schema, doc }, rest] = (0, _alloy_js_core.splitProps)(props, [
156
158
  "name",
157
- "reflection",
158
- "doc",
159
- "defaultValue"
159
+ "schema",
160
+ "doc"
160
161
  ]);
161
- const interfaceName = (0, _alloy_js_core.computed)(() => (0, _stryke_string_format_pascal_case.pascalCase)(((0, _stryke_type_checks_is_string.isString)(name) ? name : name.toString()) || reflection?.getName()));
162
- const properties = (0, _alloy_js_core.computed)(() => reflection ? reflection.getProperties().filter((item) => !item.isIgnored()).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? a.getNameAsString().localeCompare(b.getNameAsString()) : a.isReadonly() ? 1 : -1) : []);
162
+ const interfaceName = (0, _alloy_js_core.computed)(() => (0, _stryke_string_format_pascal_case.pascalCase)((0, _stryke_type_checks_is_set_string.isSetString)(name) ? name : schema?.metadata?.name || schema?.metadata?.title || ""));
163
+ const properties = (0, _alloy_js_core.computed)(() => schema ? Object.values((0, _powerlines_schema.getProperties)(schema)).filter((property) => !property.metadata?.isIgnored).sort((a, b) => a.metadata?.isReadonly && b.metadata?.isReadonly || !a.metadata?.isReadonly && !b.metadata?.isReadonly ? a.name.localeCompare(b.name) : a.metadata?.isReadonly ? 1 : -1) : []);
163
164
  return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
164
165
  get when() {
165
- return reflection && properties.value.length > 0;
166
+ return schema && properties.value.length > 0;
166
167
  },
167
168
  get fallback() {
168
169
  return (0, _alloy_js_core_jsx_runtime.createComponent)(BaseInterfaceDeclaration, (0, _alloy_js_core_jsx_runtime.mergeProps)(props, { get name() {
@@ -170,29 +171,23 @@ function InterfaceDeclaration(props) {
170
171
  } }));
171
172
  },
172
173
  get children() {
173
- return (0, _alloy_js_core_jsx_runtime.createComponent)(require_core_contexts_reflection.ReflectionClassContext.Provider, {
174
- value: { reflection },
174
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(require_core_contexts_schema.SchemaContext.Provider, {
175
+ value: schema,
175
176
  get children() {
176
- return [(0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_tsdoc_reflection.TSDocReflectionClass, {
177
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_tsdoc_schema.TSDocObjectSchema, {
177
178
  heading: doc,
178
- reflection
179
+ schema
179
180
  }), (0, _alloy_js_core_jsx_runtime.createComponent)(BaseInterfaceDeclaration, (0, _alloy_js_core_jsx_runtime.mergeProps)({
180
181
  "export": true,
181
182
  get name() {
182
183
  return interfaceName.value;
183
- },
184
- defaultValue
184
+ }
185
185
  }, rest, { get children() {
186
186
  return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
187
187
  each: properties,
188
188
  doubleHardline: true,
189
189
  semicolon: true,
190
- children: (prop) => (0, _alloy_js_core_jsx_runtime.createComponent)(InterfaceDeclarationProperty, {
191
- property: prop,
192
- get defaultValue() {
193
- return defaultValue?.value?.[prop.getNameAsString()];
194
- }
195
- })
190
+ children: (property) => (0, _alloy_js_core_jsx_runtime.createComponent)(InterfaceDeclarationProperty, { schema: property })
196
191
  });
197
192
  } }))];
198
193
  }
@@ -204,30 +199,35 @@ function InterfaceDeclaration(props) {
204
199
  * Generates a TypeScript interface property for the given reflection class.
205
200
  */
206
201
  function InterfaceDeclarationProperty(props) {
207
- const [{ property, defaultValue }, rest] = (0, _alloy_js_core.splitProps)(props, ["property", "defaultValue"]);
208
- return (0, _alloy_js_core_jsx_runtime.createComponent)(require_core_contexts_reflection.ReflectionPropertyContext.Provider, {
209
- value: {
210
- property,
211
- defaultValue
202
+ const [{ schema }, rest] = (0, _alloy_js_core.splitProps)(props, ["schema"]);
203
+ const name = (0, _alloy_js_core.computed)(() => schema.metadata?.name || (0, _stryke_string_format_camel_case.camelCase)(schema.metadata?.title || schema.metadata?.resourceId));
204
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
205
+ get when() {
206
+ return (0, _stryke_type_checks_is_set_string.isSetString)(name.value);
212
207
  },
213
208
  get children() {
214
- return [(0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_tsdoc_reflection.TSDocContextProperty, {}), (0, _alloy_js_core_jsx_runtime.createComponent)(InterfaceMember, (0, _alloy_js_core_jsx_runtime.mergeProps)({
215
- get name() {
216
- return property.getNameAsString();
217
- },
218
- get readonly() {
219
- return property.isReadonly();
220
- },
221
- get optional() {
222
- return property.isOptional();
223
- },
224
- get nullish() {
225
- return property.isNullable();
226
- },
227
- get type() {
228
- return (0, _powerlines_deepkit_vendor_type.stringifyType)(property.getType());
209
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(require_core_contexts_schema.SchemaPropertyContext.Provider, {
210
+ value: schema,
211
+ get children() {
212
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_tsdoc_schema.TSDocSchemaProperty, { schema }), (0, _alloy_js_core_jsx_runtime.createComponent)(InterfaceMember, (0, _alloy_js_core_jsx_runtime.mergeProps)({
213
+ get name() {
214
+ return name.value;
215
+ },
216
+ get isReadonly() {
217
+ return schema.metadata?.isReadonly;
218
+ },
219
+ get optional() {
220
+ return !!schema.metadata?.isOptional;
221
+ },
222
+ get nullish() {
223
+ return !!schema?.nullable;
224
+ },
225
+ get type() {
226
+ return schema.type;
227
+ }
228
+ }, rest))];
229
229
  }
230
- }, rest))];
230
+ });
231
231
  }
232
232
  });
233
233
  }
@@ -1,10 +1,11 @@
1
1
  import { ComponentProps } from "../../types/components.cjs";
2
- import { Children, Namekey, Ref, Refkey } from "@alloy-js/core";
2
+ import { Children, Namekey, Refkey } from "@alloy-js/core";
3
3
  import { CommonDeclarationProps, TypeParameterDescriptor } from "@alloy-js/typescript";
4
- import { ReflectionClass, ReflectionProperty } from "@powerlines/deepkit/vendor/type";
4
+ import { JTDSchemaObjectType, JTDSchemaType, JTDType } from "@powerlines/schema";
5
+ import { PartialKeys } from "@stryke/types/base";
5
6
 
6
7
  //#region src/typescript/components/interface-declaration.d.ts
7
- interface InterfaceDeclarationProps<T extends Record<string, any> = Record<string, any>> extends CommonDeclarationProps, ComponentProps {
8
+ interface InterfaceDeclarationProps extends PartialKeys<CommonDeclarationProps, "name">, ComponentProps {
8
9
  /**
9
10
  * A base type that this interface extends. This can be used to represent inheritance
10
11
  */
@@ -14,48 +15,45 @@ interface InterfaceDeclarationProps<T extends Record<string, any> = Record<strin
14
15
  */
15
16
  typeParameters?: TypeParameterDescriptor[] | string[];
16
17
  /**
17
- * The reflection class that describes the properties of this interface.
18
+ * The JTD Schema that describes the properties of this interface.
18
19
  *
19
20
  * @remarks
20
- * This is used to generate the members of the interface based on the properties of the reflection class.
21
+ * This is used to generate the members of the interface based on the properties of the schema.
21
22
  */
22
- reflection?: ReflectionClass<T>;
23
- /**
24
- * A default value for this interface.
25
- *
26
- * @remarks
27
- * This is used when the interface is used as a type for a variable declaration, to provide an initial value for the variable.
28
- */
29
- defaultValue?: Ref<Partial<T>>;
23
+ schema?: JTDSchemaObjectType;
30
24
  /**
31
25
  * Documentation for the interface. This can be a string or any Alloy component that renders documentation content (such as `TSDoc`).
32
26
  */
33
27
  doc?: Children;
34
28
  }
35
29
  interface InterfaceDeclarationPropertyProps extends Omit<InterfaceMemberProps, "name">, ComponentProps {
36
- property: ReflectionProperty;
37
- defaultValue?: any;
30
+ schema: JTDSchemaType;
38
31
  }
39
32
  interface InterfaceExpressionProps {
40
33
  children?: Children;
41
34
  }
42
35
  declare const InterfaceExpression: import("@alloy-js/core").Component<InterfaceExpressionProps>;
43
36
  interface InterfaceMemberPropsBase {
44
- type?: Children;
45
37
  children?: Children;
46
- readonly?: boolean;
47
38
  doc?: Children;
48
39
  refkey?: Refkey | Refkey[];
49
40
  }
50
41
  interface InterfacePropertyMemberProps extends InterfaceMemberPropsBase {
51
42
  name: string | Namekey;
43
+ isReadonly?: boolean;
44
+ type?: Children | JTDType;
52
45
  optional?: boolean;
53
46
  nullish?: boolean;
54
47
  }
55
48
  interface InterfaceIndexerMemberProps extends InterfaceMemberPropsBase {
56
49
  indexer: Children;
50
+ isReadonly?: boolean;
51
+ type?: Children | JTDType;
52
+ }
53
+ interface InterfaceSchemaMemberProps extends InterfaceMemberPropsBase {
54
+ schema: JTDSchemaType;
57
55
  }
58
- type InterfaceMemberProps = InterfacePropertyMemberProps | InterfaceIndexerMemberProps;
56
+ type InterfaceMemberProps = InterfacePropertyMemberProps | InterfaceIndexerMemberProps | InterfaceSchemaMemberProps;
59
57
  /**
60
58
  * Create a TypeScript interface member.
61
59
  *
@@ -67,13 +65,13 @@ type InterfaceMemberProps = InterfacePropertyMemberProps | InterfaceIndexerMembe
67
65
  */
68
66
  declare function InterfaceMember(props: InterfaceMemberProps): Children;
69
67
  /**
70
- * Generates a TypeScript interface for the given reflection class.
68
+ * Generates a TypeScript interface for the given schema.
71
69
  */
72
- declare function InterfaceDeclaration<T extends Record<string, any> = Record<string, any>>(props: InterfaceDeclarationProps<T>): Children;
70
+ declare function InterfaceDeclaration(props: InterfaceDeclarationProps): Children;
73
71
  /**
74
72
  * Generates a TypeScript interface property for the given reflection class.
75
73
  */
76
74
  declare function InterfaceDeclarationProperty(props: InterfaceDeclarationPropertyProps): Children;
77
75
  //#endregion
78
- export { InterfaceDeclaration, InterfaceDeclarationProperty, InterfaceDeclarationPropertyProps, InterfaceDeclarationProps, InterfaceExpression, InterfaceExpressionProps, InterfaceIndexerMemberProps, InterfaceMember, InterfaceMemberProps, InterfaceMemberPropsBase, InterfacePropertyMemberProps };
76
+ export { InterfaceDeclaration, InterfaceDeclarationProperty, InterfaceDeclarationPropertyProps, InterfaceDeclarationProps, InterfaceExpression, InterfaceExpressionProps, InterfaceIndexerMemberProps, InterfaceMember, InterfaceMemberProps, InterfaceMemberPropsBase, InterfacePropertyMemberProps, InterfaceSchemaMemberProps };
79
77
  //# sourceMappingURL=interface-declaration.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interface-declaration.d.cts","names":[],"sources":["../../../src/typescript/components/interface-declaration.tsx"],"mappings":";;;;;;UAmEiB,yBAAA,WACL,MAAA,gBAAsB,MAAA,uBAExB,sBAAA,EAAwB,cAAA;;AAHlC;;EAOE,OAAA,GAAU,QAAA;EANA;;;EAWV,cAAA,GAAiB,uBAAA;EAQY;;;;;;EAA7B,UAAA,GAAa,eAAA,CAAgB,CAAA;EAjBG;;;;;;EAyBhC,YAAA,GAAe,GAAA,CAAI,OAAA,CAAQ,CAAA;EAzBK;;;EA8BhC,GAAA,GAAM,QAAA;AAAA;AAAA,UAGS,iCAAA,SACP,IAAA,CAAK,oBAAA,WAA+B,cAAA;EAC5C,QAAA,EAAU,kBAAA;EACV,YAAA;AAAA;AAAA,UAGe,wBAAA;EACf,QAAA,GAAW,QAAQ;AAAA;AAAA,cAGR,mBAAA,2BAAmB,SAAA,CAAA,wBAAA;AAAA,UAoBf,wBAAA;EACf,IAAA,GAAO,QAAA;EACP,QAAA,GAAW,QAAA;EACX,QAAA;EACA,GAAA,GAAM,QAAA;EACN,MAAA,GAAS,MAAA,GAAS,MAAA;AAAA;AAAA,UAEH,4BAAA,SAAqC,wBAAwB;EAC5E,IAAA,WAAe,OAAA;EACf,QAAA;EACA,OAAA;AAAA;AAAA,UAGe,2BAAA,SAAoC,wBAAwB;EAC3E,OAAA,EAAS,QAAA;AAAA;AAAA,KAGC,oBAAA,GACR,4BAAA,GACA,2BAA2B;;;;AA9CjB;AAGd;;;;AACqB;iBAqDL,eAAA,CAAgB,KAAA,EAAO,oBAAA,GAAoB,QAAA;;;;iBA+G3C,oBAAA,WACJ,MAAA,gBAAsB,MAAA,cAAA,CAChC,KAAA,EAAO,yBAAA,CAA0B,CAAA,IAAE,QAAA;AA/IrC;;;AAAA,iBA8MgB,4BAAA,CACd,KAAA,EAAO,iCAAA,GAAiC,QAAA"}
1
+ {"version":3,"file":"interface-declaration.d.cts","names":[],"sources":["../../../src/typescript/components/interface-declaration.tsx"],"mappings":";;;;;;;UAuEiB,yBAAA,SACP,WAAA,CAAY,sBAAA,WAAiC,cAAA;;AADvD;;EAKE,OAAA,GAAU,QAAA;EAJU;;;EASpB,cAAA,GAAiB,uBAAA;EAaX;;;;;;EALN,MAAA,GAAS,mBAAA;EAjB4C;;;EAsBrD,GAAA,GAAM,QAAA;AAAA;AAAA,UAGS,iCAAA,SACP,IAAA,CAAK,oBAAA,WAA+B,cAAA;EAC5C,MAAA,EAAQ,aAAA;AAAA;AAAA,UAGO,wBAAA;EACf,QAAA,GAAW,QAAQ;AAAA;AAAA,cAGR,mBAAA,2BAAmB,SAAA,CAAA,wBAAA;AAAA,UAoBf,wBAAA;EACf,QAAA,GAAW,QAAA;EACX,GAAA,GAAM,QAAA;EACN,MAAA,GAAS,MAAA,GAAS,MAAA;AAAA;AAAA,UAEH,4BAAA,SAAqC,wBAAA;EACpD,IAAA,WAAe,OAAA;EACf,UAAA;EACA,IAAA,GAAO,QAAA,GAAW,OAAA;EAClB,QAAA;EACA,OAAA;AAAA;AAAA,UAGe,2BAAA,SAAoC,wBAAA;EACnD,OAAA,EAAS,QAAA;EACT,UAAA;EACA,IAAA,GAAO,QAAA,GAAW,OAAA;AAAA;AAAA,UAGH,0BAAA,SAAmC,wBAAwB;EAC1E,MAAA,EAAQ,aAAA;AAAA;AAAA,KAGE,oBAAA,GACR,4BAAA,GACA,2BAAA,GACA,0BAAA;;;;AA9C4B;AAoBhC;;;;;iBAqCgB,eAAA,CAAgB,KAAA,EAAO,oBAAA,GAAoB,QAAA;;;;iBA+I3C,oBAAA,CAAqB,KAAA,EAAO,yBAAA,GAAyB,QAAA;;;;iBAqDrD,4BAAA,CACd,KAAA,EAAO,iCAAA,GAAiC,QAAA"}
@@ -1,10 +1,11 @@
1
1
  import { ComponentProps } from "../../types/components.mjs";
2
- import { Children, Namekey, Ref, Refkey } from "@alloy-js/core";
3
- import { ReflectionClass, ReflectionProperty } from "@powerlines/deepkit/vendor/type";
2
+ import { Children, Namekey, Refkey } from "@alloy-js/core";
4
3
  import { CommonDeclarationProps, TypeParameterDescriptor } from "@alloy-js/typescript";
4
+ import { JTDSchemaObjectType, JTDSchemaType, JTDType } from "@powerlines/schema";
5
+ import { PartialKeys } from "@stryke/types/base";
5
6
 
6
7
  //#region src/typescript/components/interface-declaration.d.ts
7
- interface InterfaceDeclarationProps<T extends Record<string, any> = Record<string, any>> extends CommonDeclarationProps, ComponentProps {
8
+ interface InterfaceDeclarationProps extends PartialKeys<CommonDeclarationProps, "name">, ComponentProps {
8
9
  /**
9
10
  * A base type that this interface extends. This can be used to represent inheritance
10
11
  */
@@ -14,48 +15,45 @@ interface InterfaceDeclarationProps<T extends Record<string, any> = Record<strin
14
15
  */
15
16
  typeParameters?: TypeParameterDescriptor[] | string[];
16
17
  /**
17
- * The reflection class that describes the properties of this interface.
18
+ * The JTD Schema that describes the properties of this interface.
18
19
  *
19
20
  * @remarks
20
- * This is used to generate the members of the interface based on the properties of the reflection class.
21
+ * This is used to generate the members of the interface based on the properties of the schema.
21
22
  */
22
- reflection?: ReflectionClass<T>;
23
- /**
24
- * A default value for this interface.
25
- *
26
- * @remarks
27
- * This is used when the interface is used as a type for a variable declaration, to provide an initial value for the variable.
28
- */
29
- defaultValue?: Ref<Partial<T>>;
23
+ schema?: JTDSchemaObjectType;
30
24
  /**
31
25
  * Documentation for the interface. This can be a string or any Alloy component that renders documentation content (such as `TSDoc`).
32
26
  */
33
27
  doc?: Children;
34
28
  }
35
29
  interface InterfaceDeclarationPropertyProps extends Omit<InterfaceMemberProps, "name">, ComponentProps {
36
- property: ReflectionProperty;
37
- defaultValue?: any;
30
+ schema: JTDSchemaType;
38
31
  }
39
32
  interface InterfaceExpressionProps {
40
33
  children?: Children;
41
34
  }
42
35
  declare const InterfaceExpression: import("@alloy-js/core").Component<InterfaceExpressionProps>;
43
36
  interface InterfaceMemberPropsBase {
44
- type?: Children;
45
37
  children?: Children;
46
- readonly?: boolean;
47
38
  doc?: Children;
48
39
  refkey?: Refkey | Refkey[];
49
40
  }
50
41
  interface InterfacePropertyMemberProps extends InterfaceMemberPropsBase {
51
42
  name: string | Namekey;
43
+ isReadonly?: boolean;
44
+ type?: Children | JTDType;
52
45
  optional?: boolean;
53
46
  nullish?: boolean;
54
47
  }
55
48
  interface InterfaceIndexerMemberProps extends InterfaceMemberPropsBase {
56
49
  indexer: Children;
50
+ isReadonly?: boolean;
51
+ type?: Children | JTDType;
52
+ }
53
+ interface InterfaceSchemaMemberProps extends InterfaceMemberPropsBase {
54
+ schema: JTDSchemaType;
57
55
  }
58
- type InterfaceMemberProps = InterfacePropertyMemberProps | InterfaceIndexerMemberProps;
56
+ type InterfaceMemberProps = InterfacePropertyMemberProps | InterfaceIndexerMemberProps | InterfaceSchemaMemberProps;
59
57
  /**
60
58
  * Create a TypeScript interface member.
61
59
  *
@@ -67,13 +65,13 @@ type InterfaceMemberProps = InterfacePropertyMemberProps | InterfaceIndexerMembe
67
65
  */
68
66
  declare function InterfaceMember(props: InterfaceMemberProps): Children;
69
67
  /**
70
- * Generates a TypeScript interface for the given reflection class.
68
+ * Generates a TypeScript interface for the given schema.
71
69
  */
72
- declare function InterfaceDeclaration<T extends Record<string, any> = Record<string, any>>(props: InterfaceDeclarationProps<T>): Children;
70
+ declare function InterfaceDeclaration(props: InterfaceDeclarationProps): Children;
73
71
  /**
74
72
  * Generates a TypeScript interface property for the given reflection class.
75
73
  */
76
74
  declare function InterfaceDeclarationProperty(props: InterfaceDeclarationPropertyProps): Children;
77
75
  //#endregion
78
- export { InterfaceDeclaration, InterfaceDeclarationProperty, InterfaceDeclarationPropertyProps, InterfaceDeclarationProps, InterfaceExpression, InterfaceExpressionProps, InterfaceIndexerMemberProps, InterfaceMember, InterfaceMemberProps, InterfaceMemberPropsBase, InterfacePropertyMemberProps };
76
+ export { InterfaceDeclaration, InterfaceDeclarationProperty, InterfaceDeclarationPropertyProps, InterfaceDeclarationProps, InterfaceExpression, InterfaceExpressionProps, InterfaceIndexerMemberProps, InterfaceMember, InterfaceMemberProps, InterfaceMemberPropsBase, InterfacePropertyMemberProps, InterfaceSchemaMemberProps };
79
77
  //# sourceMappingURL=interface-declaration.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interface-declaration.d.mts","names":[],"sources":["../../../src/typescript/components/interface-declaration.tsx"],"mappings":";;;;;;UAmEiB,yBAAA,WACL,MAAA,gBAAsB,MAAA,uBAExB,sBAAA,EAAwB,cAAA;;AAHlC;;EAOE,OAAA,GAAU,QAAA;EANA;;;EAWV,cAAA,GAAiB,uBAAA;EAQY;;;;;;EAA7B,UAAA,GAAa,eAAA,CAAgB,CAAA;EAjBG;;;;;;EAyBhC,YAAA,GAAe,GAAA,CAAI,OAAA,CAAQ,CAAA;EAzBK;;;EA8BhC,GAAA,GAAM,QAAA;AAAA;AAAA,UAGS,iCAAA,SACP,IAAA,CAAK,oBAAA,WAA+B,cAAA;EAC5C,QAAA,EAAU,kBAAA;EACV,YAAA;AAAA;AAAA,UAGe,wBAAA;EACf,QAAA,GAAW,QAAQ;AAAA;AAAA,cAGR,mBAAA,2BAAmB,SAAA,CAAA,wBAAA;AAAA,UAoBf,wBAAA;EACf,IAAA,GAAO,QAAA;EACP,QAAA,GAAW,QAAA;EACX,QAAA;EACA,GAAA,GAAM,QAAA;EACN,MAAA,GAAS,MAAA,GAAS,MAAA;AAAA;AAAA,UAEH,4BAAA,SAAqC,wBAAwB;EAC5E,IAAA,WAAe,OAAA;EACf,QAAA;EACA,OAAA;AAAA;AAAA,UAGe,2BAAA,SAAoC,wBAAwB;EAC3E,OAAA,EAAS,QAAA;AAAA;AAAA,KAGC,oBAAA,GACR,4BAAA,GACA,2BAA2B;;;;AA9CjB;AAGd;;;;AACqB;iBAqDL,eAAA,CAAgB,KAAA,EAAO,oBAAA,GAAoB,QAAA;;;;iBA+G3C,oBAAA,WACJ,MAAA,gBAAsB,MAAA,cAAA,CAChC,KAAA,EAAO,yBAAA,CAA0B,CAAA,IAAE,QAAA;AA/IrC;;;AAAA,iBA8MgB,4BAAA,CACd,KAAA,EAAO,iCAAA,GAAiC,QAAA"}
1
+ {"version":3,"file":"interface-declaration.d.mts","names":[],"sources":["../../../src/typescript/components/interface-declaration.tsx"],"mappings":";;;;;;;UAuEiB,yBAAA,SACP,WAAA,CAAY,sBAAA,WAAiC,cAAA;;AADvD;;EAKE,OAAA,GAAU,QAAA;EAJU;;;EASpB,cAAA,GAAiB,uBAAA;EAaX;;;;;;EALN,MAAA,GAAS,mBAAA;EAjB4C;;;EAsBrD,GAAA,GAAM,QAAA;AAAA;AAAA,UAGS,iCAAA,SACP,IAAA,CAAK,oBAAA,WAA+B,cAAA;EAC5C,MAAA,EAAQ,aAAA;AAAA;AAAA,UAGO,wBAAA;EACf,QAAA,GAAW,QAAQ;AAAA;AAAA,cAGR,mBAAA,2BAAmB,SAAA,CAAA,wBAAA;AAAA,UAoBf,wBAAA;EACf,QAAA,GAAW,QAAA;EACX,GAAA,GAAM,QAAA;EACN,MAAA,GAAS,MAAA,GAAS,MAAA;AAAA;AAAA,UAEH,4BAAA,SAAqC,wBAAA;EACpD,IAAA,WAAe,OAAA;EACf,UAAA;EACA,IAAA,GAAO,QAAA,GAAW,OAAA;EAClB,QAAA;EACA,OAAA;AAAA;AAAA,UAGe,2BAAA,SAAoC,wBAAA;EACnD,OAAA,EAAS,QAAA;EACT,UAAA;EACA,IAAA,GAAO,QAAA,GAAW,OAAA;AAAA;AAAA,UAGH,0BAAA,SAAmC,wBAAwB;EAC1E,MAAA,EAAQ,aAAA;AAAA;AAAA,KAGE,oBAAA,GACR,4BAAA,GACA,2BAAA,GACA,0BAAA;;;;AA9C4B;AAoBhC;;;;;iBAqCgB,eAAA,CAAgB,KAAA,EAAO,oBAAA,GAAoB,QAAA;;;;iBA+I3C,oBAAA,CAAqB,KAAA,EAAO,yBAAA,GAAyB,QAAA;;;;iBAqDrD,4BAAA,CACd,KAAA,EAAO,iCAAA,GAAiC,QAAA"}
@@ -1,15 +1,17 @@
1
- import { ReflectionClassContext, ReflectionPropertyContext } from "../../core/contexts/reflection.mjs";
1
+ import { SchemaContext, SchemaPropertyContext } from "../../core/contexts/schema.mjs";
2
2
  import { TSDoc } from "./tsdoc.mjs";
3
3
  import { MemberScope as MemberScope$1 } from "../contexts/member-scope.mjs";
4
4
  import { PropertyName } from "./property-name.mjs";
5
5
  import { TypeParameters } from "./type-parameters.mjs";
6
- import { TSDocContextProperty, TSDocReflectionClass } from "./tsdoc-reflection.mjs";
6
+ import { TSDocObjectSchema, TSDocSchemaProperty } from "./tsdoc-schema.mjs";
7
7
  import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
8
8
  import { Block, For, MemberDeclaration, Name, Show, childrenArray, computed, createSymbol, createSymbolSlot, effect, emitSymbol, findUnkeyedChildren, splitProps, takeSymbols } from "@alloy-js/core";
9
- import { stringifyType } from "@powerlines/deepkit/vendor/type";
9
+ import { camelCase } from "@stryke/string-format/camel-case";
10
10
  import { pascalCase } from "@stryke/string-format/pascal-case";
11
- import { isString } from "@stryke/type-checks/is-string";
12
11
  import { Declaration as Declaration$1, TSOutputSymbol, TSSymbolFlags, ensureTypeRefContext, useTSLexicalScope, useTSMemberScope, useTSNamePolicy } from "@alloy-js/typescript";
12
+ import { isSetString } from "@stryke/type-checks/is-set-string";
13
+ import { getProperties, stringifyType } from "@powerlines/schema";
14
+ import { uuid } from "@stryke/unique-id/uuid";
13
15
 
14
16
  //#region src/typescript/components/interface-declaration.tsx
15
17
  const InterfaceExpression = ensureTypeRefContext(function InterfaceExpression(props) {
@@ -39,8 +41,8 @@ const InterfaceExpression = ensureTypeRefContext(function InterfaceExpression(pr
39
41
  * children of the component.
40
42
  */
41
43
  function InterfaceMember(props) {
42
- const type = props.type ?? props.children;
43
- const readonly = props.readonly ? "readonly " : "";
44
+ const type = props.schema ? stringifyType(props.schema) : props.type ?? props.children;
45
+ const readonly = props.schema && props.schema?.metadata?.isReadonly || !props.schema && props.isReadonly ? "readonly " : "";
44
46
  if ("indexer" in props) return [
45
47
  createComponent(Show, {
46
48
  get when() {
@@ -58,11 +60,11 @@ function InterfaceMember(props) {
58
60
  "]: ",
59
61
  type
60
62
  ];
61
- const optionality = props.optional ? "?" : "";
63
+ const optional = !!(props.schema && props.schema?.nullable) || !!(!props.schema && props.optional);
62
64
  const scope = useTSMemberScope();
63
- const sym = createSymbol(TSOutputSymbol, props.name, scope.ownerSymbol.staticMembers, {
65
+ const sym = createSymbol(TSOutputSymbol, String((props.schema ? props.schema.metadata?.name || props.schema.metadata?.resourceId : isSetString(props.name) ? props.name : props.name.toString()) || uuid().replace(/-/g, "")), scope.ownerSymbol.staticMembers, {
64
66
  refkeys: props.refkey,
65
- tsFlags: TSSymbolFlags.TypeSymbol | (props.nullish ?? props.optional ? TSSymbolFlags.Nullish : TSSymbolFlags.None),
67
+ tsFlags: TSSymbolFlags.TypeSymbol | (optional ? TSSymbolFlags.Nullish : TSSymbolFlags.None),
66
68
  namePolicy: useTSNamePolicy().for("interface-member"),
67
69
  binder: scope.binder
68
70
  });
@@ -88,7 +90,7 @@ function InterfaceMember(props) {
88
90
  }),
89
91
  readonly,
90
92
  createComponent(PropertyName, {}),
91
- optionality,
93
+ optional ? "?" : "",
92
94
  ": ",
93
95
  type
94
96
  ];
@@ -102,7 +104,7 @@ const BaseInterfaceDeclaration = ensureTypeRefContext(function InterfaceDeclarat
102
104
  const filteredChildren = findUnkeyedChildren(children);
103
105
  const currentScope = useTSLexicalScope();
104
106
  const binder = currentScope?.binder;
105
- const sym = createSymbol(TSOutputSymbol, props.name, currentScope.types, {
107
+ const sym = createSymbol(TSOutputSymbol, (isSetString(props.name) ? props.name : props.name?.toString()) || uuid().replace(/-/g, ""), currentScope.types, {
106
108
  refkeys: props.refkey,
107
109
  default: props.default,
108
110
  export: props.export,
@@ -147,20 +149,19 @@ const BaseInterfaceDeclaration = ensureTypeRefContext(function InterfaceDeclarat
147
149
  }))];
148
150
  });
149
151
  /**
150
- * Generates a TypeScript interface for the given reflection class.
152
+ * Generates a TypeScript interface for the given schema.
151
153
  */
152
154
  function InterfaceDeclaration(props) {
153
- const [{ name, reflection, doc, defaultValue }, rest] = splitProps(props, [
155
+ const [{ name, schema, doc }, rest] = splitProps(props, [
154
156
  "name",
155
- "reflection",
156
- "doc",
157
- "defaultValue"
157
+ "schema",
158
+ "doc"
158
159
  ]);
159
- const interfaceName = computed(() => pascalCase((isString(name) ? name : name.toString()) || reflection?.getName()));
160
- const properties = computed(() => reflection ? reflection.getProperties().filter((item) => !item.isIgnored()).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? a.getNameAsString().localeCompare(b.getNameAsString()) : a.isReadonly() ? 1 : -1) : []);
160
+ const interfaceName = computed(() => pascalCase(isSetString(name) ? name : schema?.metadata?.name || schema?.metadata?.title || ""));
161
+ const properties = computed(() => schema ? Object.values(getProperties(schema)).filter((property) => !property.metadata?.isIgnored).sort((a, b) => a.metadata?.isReadonly && b.metadata?.isReadonly || !a.metadata?.isReadonly && !b.metadata?.isReadonly ? a.name.localeCompare(b.name) : a.metadata?.isReadonly ? 1 : -1) : []);
161
162
  return createComponent(Show, {
162
163
  get when() {
163
- return reflection && properties.value.length > 0;
164
+ return schema && properties.value.length > 0;
164
165
  },
165
166
  get fallback() {
166
167
  return createComponent(BaseInterfaceDeclaration, mergeProps(props, { get name() {
@@ -168,29 +169,23 @@ function InterfaceDeclaration(props) {
168
169
  } }));
169
170
  },
170
171
  get children() {
171
- return createComponent(ReflectionClassContext.Provider, {
172
- value: { reflection },
172
+ return createComponent(SchemaContext.Provider, {
173
+ value: schema,
173
174
  get children() {
174
- return [createComponent(TSDocReflectionClass, {
175
+ return [createComponent(TSDocObjectSchema, {
175
176
  heading: doc,
176
- reflection
177
+ schema
177
178
  }), createComponent(BaseInterfaceDeclaration, mergeProps({
178
179
  "export": true,
179
180
  get name() {
180
181
  return interfaceName.value;
181
- },
182
- defaultValue
182
+ }
183
183
  }, rest, { get children() {
184
184
  return createComponent(For, {
185
185
  each: properties,
186
186
  doubleHardline: true,
187
187
  semicolon: true,
188
- children: (prop) => createComponent(InterfaceDeclarationProperty, {
189
- property: prop,
190
- get defaultValue() {
191
- return defaultValue?.value?.[prop.getNameAsString()];
192
- }
193
- })
188
+ children: (property) => createComponent(InterfaceDeclarationProperty, { schema: property })
194
189
  });
195
190
  } }))];
196
191
  }
@@ -202,30 +197,35 @@ function InterfaceDeclaration(props) {
202
197
  * Generates a TypeScript interface property for the given reflection class.
203
198
  */
204
199
  function InterfaceDeclarationProperty(props) {
205
- const [{ property, defaultValue }, rest] = splitProps(props, ["property", "defaultValue"]);
206
- return createComponent(ReflectionPropertyContext.Provider, {
207
- value: {
208
- property,
209
- defaultValue
200
+ const [{ schema }, rest] = splitProps(props, ["schema"]);
201
+ const name = computed(() => schema.metadata?.name || camelCase(schema.metadata?.title || schema.metadata?.resourceId));
202
+ return createComponent(Show, {
203
+ get when() {
204
+ return isSetString(name.value);
210
205
  },
211
206
  get children() {
212
- return [createComponent(TSDocContextProperty, {}), createComponent(InterfaceMember, mergeProps({
213
- get name() {
214
- return property.getNameAsString();
215
- },
216
- get readonly() {
217
- return property.isReadonly();
218
- },
219
- get optional() {
220
- return property.isOptional();
221
- },
222
- get nullish() {
223
- return property.isNullable();
224
- },
225
- get type() {
226
- return stringifyType(property.getType());
207
+ return createComponent(SchemaPropertyContext.Provider, {
208
+ value: schema,
209
+ get children() {
210
+ return [createComponent(TSDocSchemaProperty, { schema }), createComponent(InterfaceMember, mergeProps({
211
+ get name() {
212
+ return name.value;
213
+ },
214
+ get isReadonly() {
215
+ return schema.metadata?.isReadonly;
216
+ },
217
+ get optional() {
218
+ return !!schema.metadata?.isOptional;
219
+ },
220
+ get nullish() {
221
+ return !!schema?.nullable;
222
+ },
223
+ get type() {
224
+ return schema.type;
225
+ }
226
+ }, rest))];
227
227
  }
228
- }, rest))];
228
+ });
229
229
  }
230
230
  });
231
231
  }