@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.
- package/dist/core/contexts/index.cjs +9 -10
- package/dist/core/contexts/index.d.cts +2 -2
- package/dist/core/contexts/index.d.mts +2 -2
- package/dist/core/contexts/index.mjs +2 -2
- package/dist/core/contexts/{reflection.cjs → schema.cjs} +18 -29
- package/dist/core/contexts/schema.d.cts +48 -0
- package/dist/core/contexts/schema.d.cts.map +1 -0
- package/dist/core/contexts/schema.d.mts +48 -0
- package/dist/core/contexts/schema.d.mts.map +1 -0
- package/dist/core/contexts/schema.mjs +61 -0
- package/dist/core/contexts/schema.mjs.map +1 -0
- package/dist/core/index.cjs +9 -10
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.mts +2 -2
- package/dist/core/index.mjs +2 -2
- package/dist/typescript/components/index.cjs +4 -7
- package/dist/typescript/components/index.d.cts +5 -5
- package/dist/typescript/components/index.d.mts +5 -5
- package/dist/typescript/components/index.mjs +3 -3
- package/dist/typescript/components/interface-declaration.cjs +52 -52
- package/dist/typescript/components/interface-declaration.d.cts +19 -21
- package/dist/typescript/components/interface-declaration.d.cts.map +1 -1
- package/dist/typescript/components/interface-declaration.d.mts +19 -21
- package/dist/typescript/components/interface-declaration.d.mts.map +1 -1
- package/dist/typescript/components/interface-declaration.mjs +52 -52
- package/dist/typescript/components/interface-declaration.mjs.map +1 -1
- package/dist/typescript/components/object-declaration.cjs +40 -56
- package/dist/typescript/components/object-declaration.d.cts +6 -11
- package/dist/typescript/components/object-declaration.d.cts.map +1 -1
- package/dist/typescript/components/object-declaration.d.mts +6 -11
- package/dist/typescript/components/object-declaration.d.mts.map +1 -1
- package/dist/typescript/components/object-declaration.mjs +41 -57
- package/dist/typescript/components/object-declaration.mjs.map +1 -1
- package/dist/typescript/components/tsdoc-schema.cjs +171 -0
- package/dist/typescript/components/tsdoc-schema.d.cts +21 -0
- package/dist/typescript/components/tsdoc-schema.d.cts.map +1 -0
- package/dist/typescript/components/tsdoc-schema.d.mts +21 -0
- package/dist/typescript/components/tsdoc-schema.d.mts.map +1 -0
- package/dist/typescript/components/tsdoc-schema.mjs +169 -0
- package/dist/typescript/components/tsdoc-schema.mjs.map +1 -0
- package/dist/typescript/components/tsdoc.cjs +30 -19
- package/dist/typescript/components/tsdoc.d.cts +16 -12
- package/dist/typescript/components/tsdoc.d.cts.map +1 -1
- package/dist/typescript/components/tsdoc.d.mts +16 -12
- package/dist/typescript/components/tsdoc.d.mts.map +1 -1
- package/dist/typescript/components/tsdoc.mjs +30 -20
- package/dist/typescript/components/tsdoc.mjs.map +1 -1
- package/dist/typescript/index.cjs +4 -7
- package/dist/typescript/index.d.cts +5 -5
- package/dist/typescript/index.d.mts +5 -5
- package/dist/typescript/index.mjs +3 -3
- package/package.json +12 -12
- package/dist/core/contexts/reflection.d.cts +0 -62
- package/dist/core/contexts/reflection.d.cts.map +0 -1
- package/dist/core/contexts/reflection.d.mts +0 -62
- package/dist/core/contexts/reflection.d.mts.map +0 -1
- package/dist/core/contexts/reflection.mjs +0 -71
- package/dist/core/contexts/reflection.mjs.map +0 -1
- package/dist/typescript/components/tsdoc-reflection.cjs +0 -331
- package/dist/typescript/components/tsdoc-reflection.d.cts +0 -41
- package/dist/typescript/components/tsdoc-reflection.d.cts.map +0 -1
- package/dist/typescript/components/tsdoc-reflection.d.mts +0 -41
- package/dist/typescript/components/tsdoc-reflection.d.mts.map +0 -1
- package/dist/typescript/components/tsdoc-reflection.mjs +0 -325
- package/dist/typescript/components/tsdoc-reflection.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface-declaration.mjs","names":[],"sources":["../../../src/typescript/components/interface-declaration.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n Block,\n Children,\n childrenArray,\n computed,\n createSymbol,\n createSymbolSlot,\n effect,\n emitSymbol,\n findUnkeyedChildren,\n For,\n MemberDeclaration,\n Name,\n Namekey,\n Ref,\n Refkey,\n Show,\n splitProps,\n takeSymbols\n} from \"@alloy-js/core\";\nimport {\n CommonDeclarationProps,\n Declaration,\n ensureTypeRefContext,\n TSOutputSymbol,\n TSSymbolFlags,\n TypeParameterDescriptor,\n useTSLexicalScope,\n useTSMemberScope,\n useTSNamePolicy\n} from \"@alloy-js/typescript\";\nimport {\n ReflectionClass,\n ReflectionProperty,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport {\n ReflectionClassContext,\n ReflectionPropertyContext\n} from \"../../core/contexts/reflection\";\nimport { ComponentProps } from \"../../types/components\";\nimport { MemberScope } from \"../contexts/member-scope\";\nimport { PropertyName } from \"./property-name\";\nimport { TSDoc } from \"./tsdoc\";\nimport { TSDocContextProperty, TSDocReflectionClass } from \"./tsdoc-reflection\";\nimport { TypeParameters } from \"./type-parameters\";\n\nexport interface InterfaceDeclarationProps<\n T extends Record<string, any> = Record<string, any>\n>\n extends CommonDeclarationProps, ComponentProps {\n /**\n * A base type that this interface extends. This can be used to represent inheritance\n */\n extends?: Children;\n\n /**\n * The generic type parameters of the interface.\n */\n typeParameters?: TypeParameterDescriptor[] | string[];\n\n /**\n * The reflection class that describes the properties of this interface.\n *\n * @remarks\n * This is used to generate the members of the interface based on the properties of the reflection class.\n */\n reflection?: ReflectionClass<T>;\n\n /**\n * A default value for this interface.\n *\n * @remarks\n * This is used when the interface is used as a type for a variable declaration, to provide an initial value for the variable.\n */\n defaultValue?: Ref<Partial<T>>;\n\n /**\n * Documentation for the interface. This can be a string or any Alloy component that renders documentation content (such as `TSDoc`).\n */\n doc?: Children;\n}\n\nexport interface InterfaceDeclarationPropertyProps\n extends Omit<InterfaceMemberProps, \"name\">, ComponentProps {\n property: ReflectionProperty;\n defaultValue?: any;\n}\n\nexport interface InterfaceExpressionProps {\n children?: Children;\n}\n\nexport const InterfaceExpression = ensureTypeRefContext(\n function InterfaceExpression(props: InterfaceExpressionProps) {\n const scope = useTSLexicalScope();\n const symbol = createSymbol(TSOutputSymbol, \"\", undefined, {\n transient: true,\n binder: scope?.binder\n });\n\n emitSymbol(symbol);\n\n return (\n <group>\n <MemberScope ownerSymbol={symbol}>\n <Block>{props.children}</Block>\n </MemberScope>\n </group>\n );\n }\n);\n\nexport interface InterfaceMemberPropsBase {\n type?: Children;\n children?: Children;\n readonly?: boolean;\n doc?: Children;\n refkey?: Refkey | Refkey[];\n}\nexport interface InterfacePropertyMemberProps extends InterfaceMemberPropsBase {\n name: string | Namekey;\n optional?: boolean;\n nullish?: boolean;\n}\n\nexport interface InterfaceIndexerMemberProps extends InterfaceMemberPropsBase {\n indexer: Children;\n}\n\nexport type InterfaceMemberProps =\n | InterfacePropertyMemberProps\n | InterfaceIndexerMemberProps;\n\n/**\n * Create a TypeScript interface member.\n *\n * An interface member can either provide a `name` prop to create a named\n * property, or an `indexer` prop to define an indexer for the interface.\n *\n * The type of the member can be provided either as the `type` prop or as the\n * children of the component.\n */\nexport function InterfaceMember(props: InterfaceMemberProps) {\n const type = props.type ?? props.children;\n const readonly = props.readonly ? \"readonly \" : \"\";\n\n if (\"indexer\" in props) {\n return (\n <>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc} />\n </Show>\n {readonly}[{props.indexer}]: {type}\n </>\n );\n }\n\n const optionality = props.optional ? \"?\" : \"\";\n const scope = useTSMemberScope();\n const sym = createSymbol(\n TSOutputSymbol,\n props.name,\n scope.ownerSymbol.staticMembers,\n {\n refkeys: props.refkey,\n tsFlags:\n TSSymbolFlags.TypeSymbol |\n ((props.nullish ?? props.optional)\n ? TSSymbolFlags.Nullish\n : TSSymbolFlags.None),\n namePolicy: useTSNamePolicy().for(\"interface-member\"),\n binder: scope.binder\n }\n );\n\n const taken = takeSymbols();\n\n effect(() => {\n if (taken.size > 1) return;\n const symbol = Array.from(taken)[0];\n if (symbol?.isTransient) {\n symbol.moveMembersTo(sym);\n }\n });\n\n return (\n <MemberDeclaration symbol={sym}>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc} />\n </Show>\n {readonly}\n <PropertyName />\n {optionality}: {type}\n </MemberDeclaration>\n );\n}\n\nconst BaseInterfaceDeclaration = ensureTypeRefContext(\n function InterfaceDeclaration(props: InterfaceDeclarationProps) {\n const ExprSlot = createSymbolSlot();\n\n const children = childrenArray(() => props.children);\n\n const extendsPart = props.extends ? <> extends {props.extends}</> : \"\";\n const filteredChildren = findUnkeyedChildren(children);\n const currentScope = useTSLexicalScope();\n\n const binder = currentScope?.binder;\n const sym = createSymbol(TSOutputSymbol, props.name, currentScope.types, {\n refkeys: props.refkey,\n default: props.default,\n export: props.export,\n metadata: props.metadata,\n tsFlags: TSSymbolFlags.TypeSymbol,\n namePolicy: useTSNamePolicy().for(\"interface\"),\n binder\n });\n\n effect(() => {\n if (ExprSlot.ref.value) {\n const takenSymbols = ExprSlot.ref.value;\n for (const symbol of takenSymbols) {\n // ignore non-transient symbols (likely not the result of an expression).\n if (symbol.isTransient) {\n symbol.moveMembersTo(sym);\n }\n }\n }\n });\n\n return (\n <>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc} />\n </Show>\n <Declaration {...props} nameKind=\"interface\" kind=\"type\" symbol={sym}>\n interface <Name />\n {props.typeParameters && (\n <TypeParameters parameters={props.typeParameters} />\n )}\n {extendsPart}{\" \"}\n <ExprSlot>\n <InterfaceExpression>{filteredChildren}</InterfaceExpression>\n </ExprSlot>\n </Declaration>\n </>\n );\n }\n);\n\n/**\n * Generates a TypeScript interface for the given reflection class.\n */\nexport function InterfaceDeclaration<\n T extends Record<string, any> = Record<string, any>\n>(props: InterfaceDeclarationProps<T>) {\n const [{ name, reflection, doc, defaultValue }, rest] = splitProps(props, [\n \"name\",\n \"reflection\",\n \"doc\",\n \"defaultValue\"\n ]);\n\n const interfaceName = computed(() =>\n pascalCase(\n (isString(name) ? name : name.toString()) || reflection?.getName()\n )\n );\n\n const properties = computed(() =>\n reflection\n ? reflection\n .getProperties()\n .filter(item => !item.isIgnored())\n .sort((a, b) =>\n (a.isReadonly() && b.isReadonly()) ||\n (!a.isReadonly() && !b.isReadonly())\n ? a.getNameAsString().localeCompare(b.getNameAsString())\n : a.isReadonly()\n ? 1\n : -1\n )\n : []\n );\n\n return (\n <Show\n when={reflection && properties.value.length > 0}\n fallback={\n <BaseInterfaceDeclaration {...props} name={interfaceName.value} />\n }>\n <ReflectionClassContext.Provider\n value={{\n reflection: reflection!\n }}>\n <TSDocReflectionClass<T> heading={doc} reflection={reflection!} />\n <BaseInterfaceDeclaration\n export={true}\n name={interfaceName.value}\n defaultValue={defaultValue}\n {...rest}>\n <For each={properties} doubleHardline={true} semicolon={true}>\n {prop => (\n <InterfaceDeclarationProperty\n property={prop}\n defaultValue={defaultValue?.value?.[prop.getNameAsString()]}\n />\n )}\n </For>\n </BaseInterfaceDeclaration>\n </ReflectionClassContext.Provider>\n </Show>\n );\n}\n\n/**\n * Generates a TypeScript interface property for the given reflection class.\n */\nexport function InterfaceDeclarationProperty(\n props: InterfaceDeclarationPropertyProps\n) {\n const [{ property, defaultValue }, rest] = splitProps(props, [\n \"property\",\n \"defaultValue\"\n ]);\n\n return (\n <ReflectionPropertyContext.Provider value={{ property, defaultValue }}>\n <TSDocContextProperty />\n <InterfaceMember\n name={property.getNameAsString()}\n readonly={property.isReadonly()}\n optional={property.isOptional()}\n nullish={property.isNullable()}\n type={stringifyType(property.getType())}\n {...rest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AEJ;;;;AAKA,SAAgB,6BAAc,OAAA;CAC5B,MAAI,CAAA,EACF,UACA,gBACC,QAAC,WAAA,OAAA,CAAA,YAAA,cAAA,CAAA;;EAEF,OAAO;GACL;GACA;EACF;EACA,IAAI,WAAW;GACb,OAAO,CAAC,gBAAkB,sBAAE,CAAA,CAAA,GAAA,gBAAA,iBAAA,WAAA;IAC1B,IAAI,OAAO;KACT,OAAA,SAAA,gBAAA;IACF;IACF,IAAA,WAAA;KACA,OAAA,SAAA,WAAA;;IAEF,IAAO,WAAA;KACJ,OAAA,SAAA,WAAA;IACC;IACA,IAAG,UAAM;KACP,OAAI,SAAA,WAAA;IACN;IACA,IAAE,OAAS;KACT,OAAO,cAAc,SAAI,QAAA,CAAA;IAC3B;GACF,GAAG,IAAE,CAAA,CAAA;EACP;CACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"interface-declaration.mjs","names":[],"sources":["../../../src/typescript/components/interface-declaration.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n Block,\n Children,\n childrenArray,\n computed,\n createSymbol,\n createSymbolSlot,\n effect,\n emitSymbol,\n findUnkeyedChildren,\n For,\n MemberDeclaration,\n Name,\n Namekey,\n Refkey,\n Show,\n splitProps,\n takeSymbols\n} from \"@alloy-js/core\";\nimport {\n CommonDeclarationProps,\n Declaration,\n ensureTypeRefContext,\n TSOutputSymbol,\n TSSymbolFlags,\n TypeParameterDescriptor,\n useTSLexicalScope,\n useTSMemberScope,\n useTSNamePolicy\n} from \"@alloy-js/typescript\";\nimport {\n getProperties,\n JTDSchemaObjectType,\n JTDSchemaType,\n JTDType,\n stringifyType\n} from \"@powerlines/schema\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { PartialKeys } from \"@stryke/types/base\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport {\n SchemaContext,\n SchemaPropertyContext\n} from \"../../core/contexts/schema\";\nimport { ComponentProps } from \"../../types/components\";\nimport { MemberScope } from \"../contexts/member-scope\";\nimport { PropertyName } from \"./property-name\";\nimport { TSDoc } from \"./tsdoc\";\nimport { TSDocObjectSchema, TSDocSchemaProperty } from \"./tsdoc-schema\";\nimport { TypeParameters } from \"./type-parameters\";\n\nexport interface InterfaceDeclarationProps\n extends PartialKeys<CommonDeclarationProps, \"name\">, ComponentProps {\n /**\n * A base type that this interface extends. This can be used to represent inheritance\n */\n extends?: Children;\n\n /**\n * The generic type parameters of the interface.\n */\n typeParameters?: TypeParameterDescriptor[] | string[];\n\n /**\n * The JTD Schema that describes the properties of this interface.\n *\n * @remarks\n * This is used to generate the members of the interface based on the properties of the schema.\n */\n schema?: JTDSchemaObjectType;\n\n /**\n * Documentation for the interface. This can be a string or any Alloy component that renders documentation content (such as `TSDoc`).\n */\n doc?: Children;\n}\n\nexport interface InterfaceDeclarationPropertyProps\n extends Omit<InterfaceMemberProps, \"name\">, ComponentProps {\n schema: JTDSchemaType;\n}\n\nexport interface InterfaceExpressionProps {\n children?: Children;\n}\n\nexport const InterfaceExpression = ensureTypeRefContext(\n function InterfaceExpression(props: InterfaceExpressionProps) {\n const scope = useTSLexicalScope();\n const symbol = createSymbol(TSOutputSymbol, \"\", undefined, {\n transient: true,\n binder: scope?.binder\n });\n\n emitSymbol(symbol);\n\n return (\n <group>\n <MemberScope ownerSymbol={symbol}>\n <Block>{props.children}</Block>\n </MemberScope>\n </group>\n );\n }\n);\n\nexport interface InterfaceMemberPropsBase {\n children?: Children;\n doc?: Children;\n refkey?: Refkey | Refkey[];\n}\nexport interface InterfacePropertyMemberProps extends InterfaceMemberPropsBase {\n name: string | Namekey;\n isReadonly?: boolean;\n type?: Children | JTDType;\n optional?: boolean;\n nullish?: boolean;\n}\n\nexport interface InterfaceIndexerMemberProps extends InterfaceMemberPropsBase {\n indexer: Children;\n isReadonly?: boolean;\n type?: Children | JTDType;\n}\n\nexport interface InterfaceSchemaMemberProps extends InterfaceMemberPropsBase {\n schema: JTDSchemaType;\n}\n\nexport type InterfaceMemberProps =\n | InterfacePropertyMemberProps\n | InterfaceIndexerMemberProps\n | InterfaceSchemaMemberProps;\n\n/**\n * Create a TypeScript interface member.\n *\n * An interface member can either provide a `name` prop to create a named\n * property, or an `indexer` prop to define an indexer for the interface.\n *\n * The type of the member can be provided either as the `type` prop or as the\n * children of the component.\n */\nexport function InterfaceMember(props: InterfaceMemberProps) {\n const type = (props as InterfaceSchemaMemberProps).schema\n ? stringifyType((props as InterfaceSchemaMemberProps).schema)\n : ((props as InterfacePropertyMemberProps | InterfaceIndexerMemberProps)\n .type ?? props.children);\n\n const readonly =\n ((props as InterfaceSchemaMemberProps).schema &&\n (props as InterfaceSchemaMemberProps).schema?.metadata?.isReadonly) ||\n (!(props as InterfaceSchemaMemberProps).schema &&\n (props as InterfacePropertyMemberProps | InterfaceIndexerMemberProps)\n .isReadonly)\n ? \"readonly \"\n : \"\";\n\n if (\"indexer\" in props) {\n return (\n <>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc} />\n </Show>\n {readonly}[{props.indexer}]: {type}\n </>\n );\n }\n\n const optional =\n !!(\n (props as InterfaceSchemaMemberProps).schema &&\n (props as InterfaceSchemaMemberProps).schema?.nullable\n ) ||\n !!(\n !(props as InterfaceSchemaMemberProps).schema &&\n (props as InterfacePropertyMemberProps).optional\n );\n\n const scope = useTSMemberScope();\n const sym = createSymbol(\n TSOutputSymbol,\n String(\n ((props as InterfaceSchemaMemberProps).schema\n ? (props as InterfaceSchemaMemberProps).schema.metadata?.name ||\n (props as InterfaceSchemaMemberProps).schema.metadata?.resourceId\n : isSetString((props as InterfacePropertyMemberProps).name)\n ? (props as InterfacePropertyMemberProps).name\n : (props as InterfacePropertyMemberProps).name.toString()) ||\n uuid().replace(/-/g, \"\")\n ),\n scope.ownerSymbol.staticMembers,\n {\n refkeys: props.refkey,\n tsFlags:\n TSSymbolFlags.TypeSymbol |\n (optional ? TSSymbolFlags.Nullish : TSSymbolFlags.None),\n namePolicy: useTSNamePolicy().for(\"interface-member\"),\n binder: scope.binder\n }\n );\n\n const taken = takeSymbols();\n\n effect(() => {\n if (taken.size > 1) return;\n const symbol = Array.from(taken)[0];\n if (symbol?.isTransient) {\n symbol.moveMembersTo(sym);\n }\n });\n\n return (\n <MemberDeclaration symbol={sym}>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc} />\n </Show>\n {readonly}\n <PropertyName />\n {optional ? \"?\" : \"\"}: {type}\n </MemberDeclaration>\n );\n}\n\nconst BaseInterfaceDeclaration = ensureTypeRefContext(\n function InterfaceDeclaration(props: InterfaceDeclarationProps) {\n const ExprSlot = createSymbolSlot();\n\n const children = childrenArray(() => props.children);\n\n const extendsPart = props.extends ? <> extends {props.extends}</> : \"\";\n const filteredChildren = findUnkeyedChildren(children);\n const currentScope = useTSLexicalScope();\n\n const binder = currentScope?.binder;\n const sym = createSymbol(\n TSOutputSymbol,\n (isSetString(props.name) ? props.name : props.name?.toString()) ||\n uuid().replace(/-/g, \"\"),\n currentScope.types,\n {\n refkeys: props.refkey,\n default: props.default,\n export: props.export,\n metadata: props.metadata,\n tsFlags: TSSymbolFlags.TypeSymbol,\n namePolicy: useTSNamePolicy().for(\"interface\"),\n binder\n }\n );\n\n effect(() => {\n if (ExprSlot.ref.value) {\n const takenSymbols = ExprSlot.ref.value;\n for (const symbol of takenSymbols) {\n // ignore non-transient symbols (likely not the result of an expression).\n if (symbol.isTransient) {\n symbol.moveMembersTo(sym);\n }\n }\n }\n });\n\n return (\n <>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc} />\n </Show>\n <Declaration {...props} nameKind=\"interface\" kind=\"type\" symbol={sym}>\n interface <Name />\n {props.typeParameters && (\n <TypeParameters parameters={props.typeParameters} />\n )}\n {extendsPart}{\" \"}\n <ExprSlot>\n <InterfaceExpression>{filteredChildren}</InterfaceExpression>\n </ExprSlot>\n </Declaration>\n </>\n );\n }\n);\n\n/**\n * Generates a TypeScript interface for the given schema.\n */\nexport function InterfaceDeclaration(props: InterfaceDeclarationProps) {\n const [{ name, schema, doc }, rest] = splitProps(props, [\n \"name\",\n \"schema\",\n \"doc\"\n ]);\n\n const interfaceName = computed(() =>\n pascalCase(\n isSetString(name)\n ? name\n : schema?.metadata?.name || schema?.metadata?.title || \"\"\n )\n );\n const properties = computed(() =>\n schema\n ? Object.values(getProperties(schema))\n .filter(property => !property.metadata?.isIgnored)\n .sort((a, b) =>\n (a.metadata?.isReadonly && b.metadata?.isReadonly) ||\n (!a.metadata?.isReadonly && !b.metadata?.isReadonly)\n ? a.name.localeCompare(b.name)\n : a.metadata?.isReadonly\n ? 1\n : -1\n )\n : []\n );\n\n return (\n <Show\n when={schema && properties.value.length > 0}\n fallback={\n <BaseInterfaceDeclaration {...props} name={interfaceName.value} />\n }>\n <SchemaContext.Provider value={schema}>\n <TSDocObjectSchema heading={doc} schema={schema!} />\n <BaseInterfaceDeclaration\n export={true}\n name={interfaceName.value}\n {...rest}>\n <For each={properties} doubleHardline={true} semicolon={true}>\n {property => <InterfaceDeclarationProperty schema={property} />}\n </For>\n </BaseInterfaceDeclaration>\n </SchemaContext.Provider>\n </Show>\n );\n}\n\n/**\n * Generates a TypeScript interface property for the given reflection class.\n */\nexport function InterfaceDeclarationProperty(\n props: InterfaceDeclarationPropertyProps\n) {\n const [{ schema }, rest] = splitProps(props, [\"schema\"]);\n\n const name = computed(\n () =>\n schema.metadata?.name ||\n camelCase(schema.metadata?.title || schema.metadata?.resourceId)\n );\n\n return (\n <Show when={isSetString(name.value)}>\n <SchemaPropertyContext.Provider value={schema}>\n <TSDocSchemaProperty schema={schema} />\n <InterfaceMember\n name={name.value!}\n isReadonly={schema.metadata?.isReadonly}\n optional={!!schema.metadata?.isOptional}\n nullish={!!schema?.nullable}\n type={(schema as { type?: JTDType }).type}\n {...rest}\n />\n </SchemaPropertyContext.Provider>\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkCA,MAAY,sBAAA,qBAAA,SAAA,oBAAA,OAAA;CAEV,MAAM,SAAS,aAAM,gBAAA,IAAA,QAAA;EACvB,WAAO;EACL,QAHA,kBAGA,GAAA;CACA,CAAA;CACA,WAAA,MAAA;CACA,OAAA,gBAAc,SAAA,EACd,IAAA,WAAa;EACb,OAAA,gBAAuB,eAAA;GACvB,aAAiB;GACjB,IAAA,WAAgB;IAChB,OAAA,gBAAA,OAAA,EACO,IAAM,WAAG;KACX,OAAA,MAAA;IACL,EACA,CAAA;GACA;EACA,CAAA;CACA,EACA,CAAA;AACF,CAAA;;;;;;;;;;AAUA,SAAS,gBAAuB,OAAA;CAChC,MAAQ,OAAC,MAAY,SAAS,cAAW,MAAK,MAAA,IAAA,MAAA,QAAA,MAAA;CAC9C,MAAQ,WAAS,MAAQ,UAAM,MAAA,QAAA,UAAA,cAAA,CAAA,MAAA,UAAA,MAAA,aAAA,cAAA;CAC/B,IAAM,aAAG,OACT,OAAS;EAAA,gBAAqB,MAAI;;IAE3B,OAAA,QAAU,MAAA,GAAA;GACf;GACE,IAAA,WAAA;IACG,OAAK,gBAAe,OAAU,EACjC,IAAA,UAAA;KACQ,OAAA,MAAQ;MAEhB,CAAA;GACC;EACD,CAAA;EAAA;EAAA;EAAA,WAAA,MAAA,OAAA;EAAA;EAAA;CAAA;;CAGF,MAAE,QAAA,iBAAA;CACF,MAAM,MAAK,aAAY,gBAAc,QAAW,MAAO,SAAC,MAAS,OAAA,UAAA,QAAA,MAAA,OAAA,U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AC;AACH"}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const require_core_contexts_schema = require('../../core/contexts/schema.cjs');
|
|
4
|
+
const require_typescript_components_tsdoc_schema = require('./tsdoc-schema.cjs');
|
|
5
5
|
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
6
6
|
let _alloy_js_core = require("@alloy-js/core");
|
|
7
|
-
let _powerlines_deepkit_utilities = require("@powerlines/deepkit/utilities");
|
|
8
7
|
let _stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
|
|
9
8
|
let _stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
|
|
10
|
-
let _stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
|
|
11
|
-
let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
12
9
|
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
10
|
+
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
11
|
+
let _powerlines_schema = require("@powerlines/schema");
|
|
13
12
|
|
|
14
13
|
//#region src/typescript/components/object-declaration.tsx
|
|
15
14
|
/**
|
|
16
15
|
* Generates a TypeScript object for the given reflection class.
|
|
17
16
|
*/
|
|
18
17
|
function ObjectDeclaration(props) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
18
|
+
const { schema } = props;
|
|
19
|
+
if (!schema) return null;
|
|
20
|
+
const name = (0, _alloy_js_core.computed)(() => (0, _stryke_string_format_camel_case.camelCase)((0, _stryke_type_checks_is_set_string.isSetString)(props.name) ? props.name : schema.metadata?.name));
|
|
21
|
+
const defaultValues = (0, _alloy_js_core.computed)(() => schema.metadata?.default || {});
|
|
22
|
+
const properties = (0, _alloy_js_core.computed)(() => Object.values((0, _powerlines_schema.getProperties)(schema)).filter((property) => !property.metadata?.isIgnored && !property.metadata?.isRuntime && !(0, _stryke_type_checks_is_undefined.isUndefined)(defaultValues.value[property.name] ?? property.metadata?.alias?.reduce((ret, alias) => {
|
|
23
|
+
if ((0, _stryke_type_checks_is_undefined.isUndefined)(ret) && !(0, _stryke_type_checks_is_undefined.isUndefined)(defaultValues.value[alias])) return defaultValues.value[alias];
|
|
24
24
|
return ret;
|
|
25
|
-
}, void 0) ??
|
|
25
|
+
}, void 0) ?? property.metadata?.default)).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));
|
|
26
26
|
const TypeSymbolSlot = (0, _alloy_js_core.createSymbolSlot)();
|
|
27
27
|
const ValueTypeSymbolSlot = (0, _alloy_js_core.createSymbolSlot)();
|
|
28
|
-
const sym = (0, _alloy_js_typescript.createValueSymbol)(
|
|
28
|
+
const sym = (0, _alloy_js_typescript.createValueSymbol)(name.value || "schema", {
|
|
29
29
|
refkeys: props.refkey,
|
|
30
30
|
default: props.default,
|
|
31
31
|
export: props.export,
|
|
@@ -42,30 +42,17 @@ function ObjectDeclaration(props) {
|
|
|
42
42
|
} })];
|
|
43
43
|
} }) : void 0;
|
|
44
44
|
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
45
|
-
|
|
46
|
-
return !!props.reflection.value;
|
|
47
|
-
},
|
|
45
|
+
when: !!schema,
|
|
48
46
|
get children() {
|
|
49
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
reflection: props.reflection.value,
|
|
53
|
-
override: {
|
|
54
|
-
name: objectName.value,
|
|
55
|
-
type: objectType.value,
|
|
56
|
-
defaultValue: props.defaultValue?.value
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
},
|
|
47
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_core_contexts_schema.SchemaContext.Provider, {
|
|
48
|
+
value: schema,
|
|
60
49
|
get children() {
|
|
61
50
|
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
62
51
|
get when() {
|
|
63
|
-
return !!
|
|
52
|
+
return !!name.value && !!type;
|
|
64
53
|
},
|
|
65
54
|
get children() {
|
|
66
|
-
return [(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
67
|
-
return props.reflection.value;
|
|
68
|
-
} }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Declaration, {
|
|
55
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_tsdoc_schema.TSDocObjectSchema, { schema }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Declaration, {
|
|
69
56
|
symbol: sym,
|
|
70
57
|
get children() {
|
|
71
58
|
return [
|
|
@@ -85,12 +72,7 @@ function ObjectDeclaration(props) {
|
|
|
85
72
|
},
|
|
86
73
|
comma: true,
|
|
87
74
|
doubleHardline: true,
|
|
88
|
-
children: (
|
|
89
|
-
property: prop,
|
|
90
|
-
get defaultValue() {
|
|
91
|
-
return props.defaultValue?.value?.[prop.getNameAsString()];
|
|
92
|
-
}
|
|
93
|
-
})
|
|
75
|
+
children: (property) => (0, _alloy_js_core_jsx_runtime.createComponent)(ObjectDeclarationProperty, { schema: property })
|
|
94
76
|
});
|
|
95
77
|
} });
|
|
96
78
|
} })
|
|
@@ -108,28 +90,30 @@ function ObjectDeclaration(props) {
|
|
|
108
90
|
* Generates a TypeScript object property for the given reflection class.
|
|
109
91
|
*/
|
|
110
92
|
function ObjectDeclarationProperty(props) {
|
|
111
|
-
const [{
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
93
|
+
const [{ schema }, rest] = (0, _alloy_js_core.splitProps)(props, ["schema"]);
|
|
94
|
+
const name = (0, _alloy_js_core.computed)(() => schema.metadata?.name || (0, _stryke_string_format_camel_case.camelCase)(schema.metadata?.title || schema.metadata?.resourceId));
|
|
95
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
96
|
+
get when() {
|
|
97
|
+
return (0, _stryke_type_checks_is_set_string.isSetString)(name.value);
|
|
116
98
|
},
|
|
117
99
|
get children() {
|
|
118
|
-
return
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
100
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_core_contexts_schema.SchemaPropertyContext.Provider, {
|
|
101
|
+
value: schema,
|
|
102
|
+
get children() {
|
|
103
|
+
return [
|
|
104
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_tsdoc_schema.TSDocSchemaProperty, { schema }),
|
|
105
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ObjectProperty, (0, _alloy_js_core_jsx_runtime.mergeProps)({
|
|
106
|
+
get name() {
|
|
107
|
+
return name.value;
|
|
108
|
+
},
|
|
109
|
+
get value() {
|
|
110
|
+
return (0, _alloy_js_core_jsx_runtime.memo)(() => !!!(0, _stryke_type_checks_is_undefined.isUndefined)(schema.metadata?.default))() ? JSON.stringify(schema.metadata?.default) : void 0;
|
|
111
|
+
}
|
|
112
|
+
}, rest)),
|
|
113
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
});
|
|
133
117
|
}
|
|
134
118
|
});
|
|
135
119
|
}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { ComponentProps } from "../../types/components.cjs";
|
|
2
2
|
import { VarDeclarationProps } from "@alloy-js/typescript";
|
|
3
|
-
import {
|
|
3
|
+
import { JTDSchemaObjectType, JTDSchemaType } from "@powerlines/schema";
|
|
4
4
|
|
|
5
5
|
//#region src/typescript/components/object-declaration.d.ts
|
|
6
|
-
interface
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
interface ObjectDeclarationProps<T extends Record<string, any> = Record<string, any>> extends VarDeclarationProps {
|
|
10
|
-
reflection?: ComputedRef<ReflectionClass<T>>;
|
|
11
|
-
defaultValue?: ComputedRef<Partial<T> | undefined>;
|
|
6
|
+
interface ObjectDeclarationProps extends VarDeclarationProps {
|
|
7
|
+
schema?: JTDSchemaObjectType;
|
|
12
8
|
}
|
|
13
9
|
/**
|
|
14
10
|
* Generates a TypeScript object for the given reflection class.
|
|
15
11
|
*/
|
|
16
|
-
declare function ObjectDeclaration
|
|
12
|
+
declare function ObjectDeclaration(props: ObjectDeclarationProps): import("@alloy-js/core").Children;
|
|
17
13
|
interface ObjectDeclarationPropertyProps extends ComponentProps {
|
|
18
|
-
|
|
19
|
-
defaultValue?: any;
|
|
14
|
+
schema: JTDSchemaType;
|
|
20
15
|
}
|
|
21
16
|
/**
|
|
22
17
|
* Generates a TypeScript object property for the given reflection class.
|
|
23
18
|
*/
|
|
24
19
|
declare function ObjectDeclarationProperty(props: ObjectDeclarationPropertyProps): import("@alloy-js/core").Children;
|
|
25
20
|
//#endregion
|
|
26
|
-
export {
|
|
21
|
+
export { ObjectDeclaration, ObjectDeclarationProperty, ObjectDeclarationPropertyProps, ObjectDeclarationProps };
|
|
27
22
|
//# sourceMappingURL=object-declaration.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-declaration.d.cts","names":[],"sources":["../../../src/typescript/components/object-declaration.tsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"object-declaration.d.cts","names":[],"sources":["../../../src/typescript/components/object-declaration.tsx"],"mappings":";;;;;UAmDiB,sBAAA,SAA+B,mBAAmB;EACjE,MAAA,GAAS,mBAAA;AAAA;;;;iBAMK,iBAAA,CAAkB,KAAA,EAAO,sBAAsB,4BAAA,QAAA;AAAA,UAmG9C,8BAAA,SAAuC,cAAc;EACpE,MAAA,EAAQ,aAAA;AAAA;AA1GoB;AAM9B;;AAN8B,iBAgHd,yBAAA,CACd,KAAA,EAAO,8BAA8B,4BAAA,QAAA"}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { ComponentProps } from "../../types/components.mjs";
|
|
2
|
-
import { ReflectionClass, ReflectionProperty } from "@powerlines/deepkit/vendor/type";
|
|
3
2
|
import { VarDeclarationProps } from "@alloy-js/typescript";
|
|
3
|
+
import { JTDSchemaObjectType, JTDSchemaType } from "@powerlines/schema";
|
|
4
4
|
|
|
5
5
|
//#region src/typescript/components/object-declaration.d.ts
|
|
6
|
-
interface
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
interface ObjectDeclarationProps<T extends Record<string, any> = Record<string, any>> extends VarDeclarationProps {
|
|
10
|
-
reflection?: ComputedRef<ReflectionClass<T>>;
|
|
11
|
-
defaultValue?: ComputedRef<Partial<T> | undefined>;
|
|
6
|
+
interface ObjectDeclarationProps extends VarDeclarationProps {
|
|
7
|
+
schema?: JTDSchemaObjectType;
|
|
12
8
|
}
|
|
13
9
|
/**
|
|
14
10
|
* Generates a TypeScript object for the given reflection class.
|
|
15
11
|
*/
|
|
16
|
-
declare function ObjectDeclaration
|
|
12
|
+
declare function ObjectDeclaration(props: ObjectDeclarationProps): import("@alloy-js/core").Children;
|
|
17
13
|
interface ObjectDeclarationPropertyProps extends ComponentProps {
|
|
18
|
-
|
|
19
|
-
defaultValue?: any;
|
|
14
|
+
schema: JTDSchemaType;
|
|
20
15
|
}
|
|
21
16
|
/**
|
|
22
17
|
* Generates a TypeScript object property for the given reflection class.
|
|
23
18
|
*/
|
|
24
19
|
declare function ObjectDeclarationProperty(props: ObjectDeclarationPropertyProps): import("@alloy-js/core").Children;
|
|
25
20
|
//#endregion
|
|
26
|
-
export {
|
|
21
|
+
export { ObjectDeclaration, ObjectDeclarationProperty, ObjectDeclarationPropertyProps, ObjectDeclarationProps };
|
|
27
22
|
//# sourceMappingURL=object-declaration.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-declaration.d.mts","names":[],"sources":["../../../src/typescript/components/object-declaration.tsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"object-declaration.d.mts","names":[],"sources":["../../../src/typescript/components/object-declaration.tsx"],"mappings":";;;;;UAmDiB,sBAAA,SAA+B,mBAAmB;EACjE,MAAA,GAAS,mBAAA;AAAA;;;;iBAMK,iBAAA,CAAkB,KAAA,EAAO,sBAAsB,4BAAA,QAAA;AAAA,UAmG9C,8BAAA,SAAuC,cAAc;EACpE,MAAA,EAAQ,aAAA;AAAA;AA1GoB;AAM9B;;AAN8B,iBAgHd,yBAAA,CACd,KAAA,EAAO,8BAA8B,4BAAA,QAAA"}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { createComponent, createIntrinsic, memo } from "@alloy-js/core/jsx-runtime";
|
|
1
|
+
import { SchemaContext, SchemaPropertyContext } from "../../core/contexts/schema.mjs";
|
|
2
|
+
import { TSDocObjectSchema, TSDocSchemaProperty } from "./tsdoc-schema.mjs";
|
|
3
|
+
import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
4
4
|
import { Declaration, For, Name, Show, computed, createSymbolSlot, splitProps } from "@alloy-js/core";
|
|
5
|
-
import { stringifyDefaultValue } from "@powerlines/deepkit/utilities";
|
|
6
5
|
import { camelCase } from "@stryke/string-format/camel-case";
|
|
7
6
|
import { isUndefined } from "@stryke/type-checks/is-undefined";
|
|
8
|
-
import { pascalCase } from "@stryke/string-format/pascal-case";
|
|
9
|
-
import { isString } from "@stryke/type-checks/is-string";
|
|
10
7
|
import { ObjectExpression, ObjectProperty, TSSymbolFlags, TypeRefContext, createValueSymbol, useTSNamePolicy } from "@alloy-js/typescript";
|
|
8
|
+
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
9
|
+
import { getProperties } from "@powerlines/schema";
|
|
11
10
|
|
|
12
11
|
//#region src/typescript/components/object-declaration.tsx
|
|
13
12
|
/**
|
|
14
13
|
* Generates a TypeScript object for the given reflection class.
|
|
15
14
|
*/
|
|
16
15
|
function ObjectDeclaration(props) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
16
|
+
const { schema } = props;
|
|
17
|
+
if (!schema) return null;
|
|
18
|
+
const name = computed(() => camelCase(isSetString(props.name) ? props.name : schema.metadata?.name));
|
|
19
|
+
const defaultValues = computed(() => schema.metadata?.default || {});
|
|
20
|
+
const properties = computed(() => Object.values(getProperties(schema)).filter((property) => !property.metadata?.isIgnored && !property.metadata?.isRuntime && !isUndefined(defaultValues.value[property.name] ?? property.metadata?.alias?.reduce((ret, alias) => {
|
|
21
|
+
if (isUndefined(ret) && !isUndefined(defaultValues.value[alias])) return defaultValues.value[alias];
|
|
22
22
|
return ret;
|
|
23
|
-
}, void 0) ??
|
|
23
|
+
}, void 0) ?? property.metadata?.default)).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));
|
|
24
24
|
const TypeSymbolSlot = createSymbolSlot();
|
|
25
25
|
const ValueTypeSymbolSlot = createSymbolSlot();
|
|
26
|
-
const sym = createValueSymbol(
|
|
26
|
+
const sym = createValueSymbol(name.value || "schema", {
|
|
27
27
|
refkeys: props.refkey,
|
|
28
28
|
default: props.default,
|
|
29
29
|
export: props.export,
|
|
@@ -40,30 +40,17 @@ function ObjectDeclaration(props) {
|
|
|
40
40
|
} })];
|
|
41
41
|
} }) : void 0;
|
|
42
42
|
return createComponent(Show, {
|
|
43
|
-
|
|
44
|
-
return !!props.reflection.value;
|
|
45
|
-
},
|
|
43
|
+
when: !!schema,
|
|
46
44
|
get children() {
|
|
47
|
-
return createComponent(
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
reflection: props.reflection.value,
|
|
51
|
-
override: {
|
|
52
|
-
name: objectName.value,
|
|
53
|
-
type: objectType.value,
|
|
54
|
-
defaultValue: props.defaultValue?.value
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
},
|
|
45
|
+
return createComponent(SchemaContext.Provider, {
|
|
46
|
+
value: schema,
|
|
58
47
|
get children() {
|
|
59
48
|
return [createComponent(Show, {
|
|
60
49
|
get when() {
|
|
61
|
-
return !!
|
|
50
|
+
return !!name.value && !!type;
|
|
62
51
|
},
|
|
63
52
|
get children() {
|
|
64
|
-
return [createComponent(
|
|
65
|
-
return props.reflection.value;
|
|
66
|
-
} }), createComponent(Declaration, {
|
|
53
|
+
return [createComponent(TSDocObjectSchema, { schema }), createComponent(Declaration, {
|
|
67
54
|
symbol: sym,
|
|
68
55
|
get children() {
|
|
69
56
|
return [
|
|
@@ -83,12 +70,7 @@ function ObjectDeclaration(props) {
|
|
|
83
70
|
},
|
|
84
71
|
comma: true,
|
|
85
72
|
doubleHardline: true,
|
|
86
|
-
children: (
|
|
87
|
-
property: prop,
|
|
88
|
-
get defaultValue() {
|
|
89
|
-
return props.defaultValue?.value?.[prop.getNameAsString()];
|
|
90
|
-
}
|
|
91
|
-
})
|
|
73
|
+
children: (property) => createComponent(ObjectDeclarationProperty, { schema: property })
|
|
92
74
|
});
|
|
93
75
|
} });
|
|
94
76
|
} })
|
|
@@ -106,28 +88,30 @@ function ObjectDeclaration(props) {
|
|
|
106
88
|
* Generates a TypeScript object property for the given reflection class.
|
|
107
89
|
*/
|
|
108
90
|
function ObjectDeclarationProperty(props) {
|
|
109
|
-
const [{
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
91
|
+
const [{ schema }, rest] = splitProps(props, ["schema"]);
|
|
92
|
+
const name = computed(() => schema.metadata?.name || camelCase(schema.metadata?.title || schema.metadata?.resourceId));
|
|
93
|
+
return createComponent(Show, {
|
|
94
|
+
get when() {
|
|
95
|
+
return isSetString(name.value);
|
|
114
96
|
},
|
|
115
97
|
get children() {
|
|
116
|
-
return
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
98
|
+
return createComponent(SchemaPropertyContext.Provider, {
|
|
99
|
+
value: schema,
|
|
100
|
+
get children() {
|
|
101
|
+
return [
|
|
102
|
+
createComponent(TSDocSchemaProperty, { schema }),
|
|
103
|
+
createComponent(ObjectProperty, mergeProps({
|
|
104
|
+
get name() {
|
|
105
|
+
return name.value;
|
|
106
|
+
},
|
|
107
|
+
get value() {
|
|
108
|
+
return memo(() => !!!isUndefined(schema.metadata?.default))() ? JSON.stringify(schema.metadata?.default) : void 0;
|
|
109
|
+
}
|
|
110
|
+
}, rest)),
|
|
111
|
+
createIntrinsic("hbr", {})
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
131
115
|
}
|
|
132
116
|
});
|
|
133
117
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-declaration.mjs","names":[],"sources":["../../../src/typescript/components/object-declaration.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n computed,\n Declaration as CoreDeclaration,\n createSymbolSlot,\n For,\n Name,\n Show,\n splitProps\n} from \"@alloy-js/core\";\nimport {\n createValueSymbol,\n ObjectExpression,\n ObjectProperty,\n TSSymbolFlags,\n TypeRefContext,\n useTSNamePolicy,\n VarDeclarationProps\n} from \"@alloy-js/typescript\";\nimport {
|
|
1
|
+
{"version":3,"file":"object-declaration.mjs","names":[],"sources":["../../../src/typescript/components/object-declaration.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n computed,\n Declaration as CoreDeclaration,\n createSymbolSlot,\n For,\n Name,\n Show,\n splitProps\n} from \"@alloy-js/core\";\nimport {\n createValueSymbol,\n ObjectExpression,\n ObjectProperty,\n TSSymbolFlags,\n TypeRefContext,\n useTSNamePolicy,\n VarDeclarationProps\n} from \"@alloy-js/typescript\";\nimport {\n getProperties,\n JTDSchemaObjectType,\n JTDSchemaType\n} from \"@powerlines/schema\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport {\n SchemaContext,\n SchemaPropertyContext\n} from \"../../core/contexts/schema\";\nimport { ComponentProps } from \"../../types/components\";\nimport { TSDocObjectSchema, TSDocSchemaProperty } from \"./tsdoc-schema\";\n\nexport interface ObjectDeclarationProps extends VarDeclarationProps {\n schema?: JTDSchemaObjectType;\n}\n\n/**\n * Generates a TypeScript object for the given reflection class.\n */\nexport function ObjectDeclaration(props: ObjectDeclarationProps) {\n const { schema } = props;\n if (!schema) {\n return null;\n }\n\n const name = computed(() =>\n camelCase(isSetString(props.name) ? props.name : schema.metadata?.name)\n );\n\n const defaultValues = computed(\n () => (schema.metadata?.default || {}) as Record<string, any>\n );\n const properties = computed(() =>\n Object.values(getProperties(schema))\n .filter(\n property =>\n !property.metadata?.isIgnored &&\n !property.metadata?.isRuntime &&\n !isUndefined(\n defaultValues.value[property.name] ??\n property.metadata?.alias?.reduce((ret, alias) => {\n if (\n isUndefined(ret) &&\n !isUndefined(defaultValues.value[alias])\n ) {\n return defaultValues.value[alias];\n }\n\n return ret;\n }, undefined) ??\n property.metadata?.default\n )\n )\n .sort((a, b) =>\n (a.metadata?.isReadonly && b.metadata?.isReadonly) ||\n (!a.metadata?.isReadonly && !b.metadata?.isReadonly)\n ? a.name.localeCompare(b.name)\n : a.metadata?.isReadonly\n ? 1\n : -1\n )\n );\n\n const TypeSymbolSlot = createSymbolSlot();\n const ValueTypeSymbolSlot = createSymbolSlot();\n const sym = createValueSymbol(name.value || \"schema\", {\n refkeys: props.refkey,\n default: props.default,\n export: props.export,\n metadata: props.metadata,\n tsFlags: props.nullish ? TSSymbolFlags.Nullish : TSSymbolFlags.None,\n type: props.type ? TypeSymbolSlot.firstSymbol : undefined,\n namePolicy: useTSNamePolicy().for(\"variable\")\n });\n\n if (!props.type) {\n ValueTypeSymbolSlot.moveMembersTo(sym);\n }\n\n const keyword = props.var ? \"var\" : props.let ? \"let\" : \"const\";\n const type = props.type ? (\n <TypeRefContext>\n : <TypeSymbolSlot>{props.type}</TypeSymbolSlot>\n </TypeRefContext>\n ) : undefined;\n\n return (\n <Show when={!!schema}>\n <SchemaContext.Provider value={schema}>\n <Show when={!!name.value && !!type}>\n <TSDocObjectSchema schema={schema} />\n <CoreDeclaration symbol={sym}>\n {props.export ? \"export \" : \"\"}\n {props.default ? \"default \" : \"\"}\n {keyword} <Name />\n {type} ={\" \"}\n <ValueTypeSymbolSlot>\n {props.initializer ?? props.children ?? (\n <ObjectExpression>\n <For\n each={properties.value ?? []}\n comma={true}\n doubleHardline={true}>\n {property => (\n <ObjectDeclarationProperty schema={property} />\n )}\n </For>\n </ObjectExpression>\n )}\n </ValueTypeSymbolSlot>\n </CoreDeclaration>\n </Show>\n <hbr />\n </SchemaContext.Provider>\n </Show>\n );\n}\n\nexport interface ObjectDeclarationPropertyProps extends ComponentProps {\n schema: JTDSchemaType;\n}\n\n/**\n * Generates a TypeScript object property for the given reflection class.\n */\nexport function ObjectDeclarationProperty(\n props: ObjectDeclarationPropertyProps\n) {\n const [{ schema }, rest] = splitProps(props, [\"schema\"]);\n\n const name = computed(\n () =>\n schema.metadata?.name ||\n camelCase(schema.metadata?.title || schema.metadata?.resourceId)\n );\n\n return (\n <Show when={isSetString(name.value)}>\n <SchemaPropertyContext.Provider value={schema}>\n <TSDocSchemaProperty schema={schema} />\n <ObjectProperty\n name={name.value}\n value={\n !isUndefined(schema.metadata?.default)\n ? JSON.stringify(schema.metadata?.default)\n : undefined\n }\n {...rest}\n />\n <hbr />\n </SchemaPropertyContext.Provider>\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA+BA,SAAe,kBAAA,OAAA;CACb,MAAA,EACA,WACA;CACA,IAAI,CAAC,QACP,OAAO;CAEL,MAAA,OAAA,eAAmB,UAAA,YAAA,MAAA,IAAA,IAAA,MAAA,OAAA,OAAA,UAAA,IAAA,CAAA;CACnB,MAAA,gBAAA,eAAA,OAAA,UAAA,WAAA,CAAA,CAAA;CACA,MAAM,aAAY,eAAO,OAAA,OAAA,cAAA,MAAA,CAAA,EAAA,QAAA,aAAA,CAAA,SAAA,UAAA,aAAA,CAAA,SAAA,UAAA,aAAA,CAAA,YAAA,cAAA,MAAA,SAAA,SAAA,SAAA,UAAA,OAAA,QAAA,KAAA,UAAA;EAC3B,IAAQ,YAAY,GAAC,KAAO,CAAA,YAAa,cAAc,MAAK,MAAA,GACtD,OAAG,cAAkB,MAAG;EAE9B,OAAO;CACL,GAAA,MAAA,KAAa,SAAA,UAAA,OAAA,CA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