Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cli/src/commands/xlr/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default class XLRCompile extends BaseCommand {
const tsManifestFile = `${[...(capabilities.capabilities?.values() ?? [])]
.flat(2)
.map((capability) => {
return `const ${capability} = require("./${capability}.json")`;
return `const ${capability.replace(".", "_")} = require("./${capability}.json")`;
})
.join("\n")}

Expand All @@ -164,7 +164,7 @@ export default class XLRCompile extends BaseCommand {
"capabilities": {
${[...(capabilities.capabilities?.entries() ?? [])]
.map(([capabilityName, provides]) => {
return `"${capabilityName}":[${provides.join(",")}],`;
return `"${capabilityName}":[${provides.join(",").replaceAll(".", "_")}],`;
})
.join("\n\t\t")}
},
Expand Down
2 changes: 2 additions & 0 deletions cli/src/utils/xlr/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export const customPrimitives = [
"AssetWrapper",
"Schema.DataType",
"ExpressionHandler",
"FormatType",
"ValidatorFunction",
];

export enum Mode {
Expand Down
12 changes: 10 additions & 2 deletions cli/src/utils/xlr/visitors/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ function runPlayerPostProcessing(
*/
function generateXLR(
node: ts.Node,
capabilityType: string,
checker: ts.TypeChecker,
converter: TsConverter,
outputDirectory: string,
Expand All @@ -126,7 +127,7 @@ function generateXLR(
capabilityDescription,
checker,
);
const capabilityName = capabilityDescription?.name ?? "error";
const capabilityName = `${capabilityType}.${capabilityDescription?.name ?? "error"}`;
fs.writeFileSync(
path.join(outputDirectory, `${capabilityName}.json`),
JSON.stringify(capabilityDescription, undefined, 4),
Expand Down Expand Up @@ -194,7 +195,13 @@ export function pluginVisitor(args: VisitorProps): Manifest | undefined {
if (ts.isTupleTypeNode(exportedCapabilities)) {
const capabilityNames = exportedCapabilities.elements.map(
(element) =>
generateXLR(element, checker, converter, outputDirectory),
generateXLR(
element,
capabilityType,
checker,
converter,
outputDirectory,
),
);

provides.set(capabilityType, capabilityNames);
Expand All @@ -204,6 +211,7 @@ export function pluginVisitor(args: VisitorProps): Manifest | undefined {
) {
const capabilityName = generateXLR(
exportedCapabilities,
capabilityType,
checker,
converter,
outputDirectory,
Expand Down
2 changes: 1 addition & 1 deletion common/static-xlrs/src/core/xlr/Asset.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"source": "src/index.ts",
"name": "Asset",
"type": "object",
"source": "src/index.ts",
"properties": {
"id": {
"required": true,
Expand Down
2 changes: 1 addition & 1 deletion common/static-xlrs/src/core/xlr/AssetBinding.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"source": "src/index.ts",
"name": "AssetBinding",
"type": "object",
"source": "src/index.ts",
"properties": {
"binding": {
"required": true,
Expand Down
28 changes: 13 additions & 15 deletions common/static-xlrs/src/core/xlr/AssetSwitch.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"name": "AssetSwitch",
"source": "src/index.ts",
"name": "AssetSwitch",
"type": "or",
"or": [
{
"name": "StaticSwitch",
"type": "object",
"source": "src/index.ts",
"name": "StaticSwitch<T>",
"type": "object",
"properties": {
"staticSwitch": {
"required": true,
"node": {
"name": "Switch",
"source": "src/index.ts",
"name": "Switch<T>",
"type": "array",
"elementType": {
"name": "SwitchCase",
"type": "object",
"source": "src/index.ts",
"name": "SwitchCase<T>",
"type": "object",
"properties": {
"asset": {
"required": true,
Expand All @@ -40,8 +40,7 @@
},
{
"type": "boolean",
"const": true,
"title": "SwitchCase.case"
"const": true
}
],
"title": "SwitchCase.case",
Expand Down Expand Up @@ -101,20 +100,20 @@
]
},
{
"name": "DynamicSwitch",
"type": "object",
"source": "src/index.ts",
"name": "DynamicSwitch<T>",
"type": "object",
"properties": {
"dynamicSwitch": {
"required": true,
"node": {
"name": "Switch",
"source": "src/index.ts",
"name": "Switch<T>",
"type": "array",
"elementType": {
"name": "SwitchCase",
"type": "object",
"source": "src/index.ts",
"name": "SwitchCase<T>",
"type": "object",
"properties": {
"asset": {
"required": true,
Expand All @@ -137,8 +136,7 @@
},
{
"type": "boolean",
"const": true,
"title": "SwitchCase.case"
"const": true
}
],
"title": "SwitchCase.case",
Expand Down
2 changes: 1 addition & 1 deletion common/static-xlrs/src/core/xlr/AssetWrapper.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "AssetWrapper",
"source": "src/index.ts",
"name": "AssetWrapper",
"type": "object",
"properties": {
"asset": {
Expand Down
28 changes: 13 additions & 15 deletions common/static-xlrs/src/core/xlr/AssetWrapperOrSwitch.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "AssetWrapperOrSwitch",
"source": "src/index.ts",
"name": "AssetWrapperOrSwitch",
"type": "or",
"or": [
{
Expand Down Expand Up @@ -44,20 +44,20 @@
"type": "and",
"and": [
{
"name": "StaticSwitch",
"type": "object",
"source": "src/index.ts",
"name": "StaticSwitch<T>",
"type": "object",
"properties": {
"staticSwitch": {
"required": true,
"node": {
"name": "Switch",
"source": "src/index.ts",
"name": "Switch<T>",
"type": "array",
"elementType": {
"name": "SwitchCase",
"type": "object",
"source": "src/index.ts",
"name": "SwitchCase<T>",
"type": "object",
"properties": {
"asset": {
"required": true,
Expand All @@ -80,8 +80,7 @@
},
{
"type": "boolean",
"const": true,
"title": "SwitchCase.case"
"const": true
}
],
"title": "SwitchCase.case",
Expand Down Expand Up @@ -168,20 +167,20 @@
"type": "and",
"and": [
{
"name": "DynamicSwitch",
"type": "object",
"source": "src/index.ts",
"name": "DynamicSwitch<T>",
"type": "object",
"properties": {
"dynamicSwitch": {
"required": true,
"node": {
"name": "Switch",
"source": "src/index.ts",
"name": "Switch<T>",
"type": "array",
"elementType": {
"name": "SwitchCase",
"type": "object",
"source": "src/index.ts",
"name": "SwitchCase<T>",
"type": "object",
"properties": {
"asset": {
"required": true,
Expand All @@ -204,8 +203,7 @@
},
{
"type": "boolean",
"const": true,
"title": "SwitchCase.case"
"const": true
}
],
"title": "SwitchCase.case",
Expand Down
2 changes: 1 addition & 1 deletion common/static-xlrs/src/core/xlr/Binding.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Binding",
"source": "src/index.ts",
"name": "Binding",
"type": "string",
"title": "Binding",
"description": "Bindings describe locations in the data model."
Expand Down
2 changes: 1 addition & 1 deletion common/static-xlrs/src/core/xlr/BindingRef.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "BindingRef",
"source": "src/index.ts",
"name": "BindingRef",
"type": "template",
"format": "{{.*}}",
"title": "BindingRef"
Expand Down
2 changes: 1 addition & 1 deletion common/static-xlrs/src/core/xlr/DataModel.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "DataModel",
"source": "src/index.ts",
"name": "DataModel",
"type": "record",
"keyType": {
"type": "any"
Expand Down
11 changes: 5 additions & 6 deletions common/static-xlrs/src/core/xlr/DynamicSwitch.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"source": "src/index.ts",
"name": "DynamicSwitch",
"type": "object",
"source": "src/index.ts",
"properties": {
"dynamicSwitch": {
"required": true,
"node": {
"name": "Switch",
"source": "src/index.ts",
"name": "Switch<T>",
"type": "array",
"elementType": {
"name": "SwitchCase",
"type": "object",
"source": "src/index.ts",
"name": "SwitchCase<T>",
"type": "object",
"properties": {
"asset": {
"required": true,
Expand All @@ -35,8 +35,7 @@
},
{
"type": "boolean",
"const": true,
"title": "SwitchCase.case"
"const": true
}
],
"title": "SwitchCase.case",
Expand Down
2 changes: 1 addition & 1 deletion common/static-xlrs/src/core/xlr/Expression.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Expression",
"source": "src/index.ts",
"name": "Expression",
"type": "or",
"or": [
{
Expand Down
2 changes: 1 addition & 1 deletion common/static-xlrs/src/core/xlr/ExpressionObject.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"source": "src/index.ts",
"name": "ExpressionObject",
"type": "object",
"source": "src/index.ts",
"properties": {
"exp": {
"required": false,
Expand Down
2 changes: 1 addition & 1 deletion common/static-xlrs/src/core/xlr/ExpressionRef.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ExpressionRef",
"source": "src/index.ts",
"name": "ExpressionRef",
"type": "template",
"format": "@[.*]@",
"title": "ExpressionRef"
Expand Down
Loading