Skip to content
Open
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
32 changes: 12 additions & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@ executors:
TZ: "/usr/share/zoneinfo/America/Los_Angeles"

commands:
setup_auth:
description: Configure authentication for deployments
steps:
- add_ssh_keys:
fingerprints:
- "SHA256:hUAWVYdfSW5ml6ufbfyEHUcuPwUJ88xVhsZc21b2lA8"
- run: mkdir -p ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
- run: git config --global user.name "Intuit Service"
- run: git config --global user.email "opensource-svc@intuit.com"

auto_shipit:
description: Perform Auto shipit
steps:
- attach_workspace:
at: ~/tools

- restore_cache:
keys:
- v1-bazel-cache-core-{{ .Branch }}-{{ .Revision }}
- v1-bazel-cache-core-{{ .Branch }}
- v1-bazel-cache-core-main

- setup_auth
- run: echo "//registry.npmjs.com/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- run: echo -e $GPG_KEY | gpg --import --batch
- run: |
Expand Down Expand Up @@ -70,7 +74,7 @@ jobs:
executor: base
steps:
- attach_workspace:
at: ~/player
at: ~/tools
- run: |
echo "build --remote_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY}" >> .bazelrc.local
echo "test --remote_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY}" >> .bazelrc.local
Expand All @@ -87,12 +91,6 @@ jobs:
at: ~/tools
# Python files don't have a build step so we only need to actually build the JS files
- run: bazel build -- $(bazel query "kind(npm_package, //...)" --output label 2>/dev/null | tr '\n' ' ')

- save_cache:
paths:
- node_modules
key: v1-dependencies-{ { checksum "package.json" }}

- persist_to_workspace:
root: .
paths:
Expand All @@ -105,12 +103,6 @@ jobs:
- attach_workspace:
at: ~/tools

- restore_cache:
keys:
- v1-bazel-cache-core-{{ .Branch }}-{{ .Revision }}
- v1-bazel-cache-core-{{ .Branch }}
- v1-bazel-cache-core-main

- run: |
bazel coverage --config=ci -- $(bazel query "kind(js_test, //...) + kind(py_test, //...)" --output label 2>/dev/null | tr '\n' ' ')

Expand Down
8 changes: 5 additions & 3 deletions language/generators/fluent/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ vitest_config(name = "vitest_config")
js_pipeline(
package_name = "@player-tools/fluent-generator",
test_deps = [
"//:node_modules",
"//:vitest_config",
":node_modules/@player-tools/test-utils",
":node_modules/@player-tools/xlr-converters",
":node_modules/@player-tools/fluent",
],
deps = [
":node_modules/@player-tools/xlr",
":node_modules/@player-tools/xlr-utils",
":node_modules/ts-morph",
"//:node_modules/ts-morph",
"//:node_modules/typescript"
],
peer_deps = [
"//:node_modules/@player-ui/types"
]
)
6 changes: 1 addition & 5 deletions language/generators/fluent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@
},
"dependencies": {
"@player-tools/xlr": "workspace:*",
"@player-tools/xlr-utils": "workspace:*",
"ts-morph": "^24.0.0"
"@player-tools/xlr-utils": "workspace:*"
},
"devDependencies": {
"@player-tools/fluent": "workspace:*",
"@player-tools/test-utils": "workspace:*",
"@player-tools/xlr-converters": "workspace:*"
},
"peerDependencies": {
"@player-ui/types": ">=0.12.0"
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
"tiny-uid": "^1.1.2",
"ts-deepmerge": "^7.0.2",
"ts-loader": "^5.3.3",
"ts-morph": "^24.0.0",
"ts-node": "^10.4.0",
"tsconfig-to-swcconfig": "^2.7.0",
"tslib": "^2.6.2",
Expand Down
16 changes: 3 additions & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion xlr/converters/src/ts-to-xlr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,13 @@ export class TsConverter {
}

/** Converts all exported objects to a XLR representation */
public convertSourceFile(sourceFile: ts.SourceFile) {
public convertSourceFile(sourceFile: ts.SourceFile): {
data: {
version: number;
types: NonNullable<NamedType>[];
};
convertedTypes: string[];
} {
const declarations = sourceFile.statements.filter(isTopLevelNode);

const types = declarations
Expand Down
2 changes: 0 additions & 2 deletions xlr/sdk/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ js_pipeline(
"//:node_modules/typescript",
],
test_deps = [
":node_modules",
"//:vitest_config",
":node_modules/@player-tools/static-xlrs",
],
deps = [
Expand Down
23 changes: 23 additions & 0 deletions xlr/sdk/src/__tests__/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,29 @@ describe("Or Type Validation", () => {
"Expected: apple | banana | carrot | deli-meat",
);
});

test("Uses primitive type names over titles", () => {
const sdk = new XLRSDK();
sdk.loadDefinitionsFromModule(Types);
sdk.loadDefinitionsFromModule(ReferenceAssetsWebPluginManifest);
const validator = new XLRValidator(sdk.getType.bind(sdk));

const orType: OrType = {
type: "or",
or: [{ type: "string", title: "TextAsset.value" }, { type: "boolean" }],
};

const rootNode = parseTree(`1`);
if (!rootNode) {
throw new Error("Expected root node to be parsed");
}

const validationResult = validator.validateType(rootNode, orType);

expect(validationResult[0].message).toBe(
"Does not match any of the types: string | boolean",
);
});
});

describe("generateNestedTypesInfo Test", () => {
Expand Down
Empty file.
6 changes: 5 additions & 1 deletion xlr/sdk/src/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ export class XLRValidator {

let message: string;
const expectedTypes = xlrNode.or
.map((node) => node.name ?? node.title ?? node.type ?? "<unnamed type>")
.map((node) =>
isPrimitiveTypeNode(node)
? node.type
: (node.name ?? node.title ?? node.type ?? "<unnamed type>"),
)
.join(" | ");

if (xlrNode.name) {
Expand Down
2 changes: 0 additions & 2 deletions xlr/utils/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ js_pipeline(
"//:node_modules/jsonc-parser",
],
test_deps = [
"//:node_modules",
"//:vitest_config",
":node_modules/@player-tools/test-utils",
],
deps = [
Expand Down
7 changes: 6 additions & 1 deletion xlr/utils/src/ts-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ export function isNodeExported(node: ts.Node): boolean {
export function getReferencedType(
node: ts.TypeReferenceNode,
typeChecker: ts.TypeChecker,
) {
):
| {
declaration: ts.TypeAliasDeclaration | ts.InterfaceDeclaration;
exported: boolean;
}
| undefined {
let symbol = typeChecker.getSymbolAtLocation(node.typeName);

if (
Expand Down