tangled
alpha
login
or
join now
tylur.dev
/
prototypey
prototypey.org - atproto lexicon typescript toolkit - mirror https://github.com/tylersayshi/prototypey
1
fork
atom
overview
issues
pulls
pipelines
some fixes
Tyler
3 months ago
db9b7aff
15c93be1
+16
-7
4 changed files
expand all
collapse all
unified
split
.github
workflows
ci.yml
packages
cli
tests
commands
gen-inferred.test.ts
prototypey
tests
infer.bench.ts
pnpm-workspace.yaml
+1
-1
.github/workflows/ci.yml
···
41
41
steps:
42
42
- uses: actions/checkout@v4
43
43
- uses: ./.github/actions/prepare
44
44
-
- run: pnpm test:bench
44
44
+
- run: pnpm -F prototypey test:bench
45
45
46
46
name: CI
47
47
+13
-4
packages/cli/tests/commands/gen-inferred.test.ts
···
74
74
expect(content).toContain('with { type: "json" }');
75
75
expect(content).toContain("export type Profile = Infer<typeof schema>");
76
76
expect(content).toContain("export const ProfileSchema = schema");
77
77
-
expect(content).toContain("export function isProfile(v: unknown): v is Profile");
77
77
+
expect(content).toContain(
78
78
+
"export function isProfile(v: unknown): v is Profile",
79
79
+
);
78
80
expect(content).toContain('v.$type === "app.bsky.actor.profile"');
79
81
});
80
82
···
275
277
);
276
278
277
279
// Run with array of patterns
278
278
-
await genInferred(outDir, [`${schemasDir1}/*.json`, `${schemasDir2}/*.json`]);
280
280
+
await genInferred(outDir, [
281
281
+
`${schemasDir1}/*.json`,
282
282
+
`${schemasDir2}/*.json`,
283
283
+
]);
279
284
280
285
// Verify both were generated
281
286
const oneContent = await readFile(join(outDir, "app/one.ts"), "utf-8");
···
319
324
expect(content).toContain('import type { Infer } from "prototypey"');
320
325
expect(content).toContain("export type Complete = Infer<typeof schema>");
321
326
expect(content).toContain("export const CompleteSchema = schema");
322
322
-
expect(content).toContain("export function isComplete(v: unknown): v is Complete");
327
327
+
expect(content).toContain(
328
328
+
"export function isComplete(v: unknown): v is Complete",
329
329
+
);
323
330
324
331
// Check type guard implementation
325
332
expect(content).toContain('typeof v === "object"');
···
330
337
// Check comments
331
338
expect(content).toContain("// Generated by prototypey - DO NOT EDIT");
332
339
expect(content).toContain("// Source: app.test.complete");
333
333
-
expect(content).toContain("* Type-inferred from lexicon schema: app.test.complete");
340
340
+
expect(content).toContain(
341
341
+
"* Type-inferred from lexicon schema: app.test.complete",
342
342
+
);
334
343
expect(content).toContain("* The lexicon schema object");
335
344
expect(content).toContain("* Type guard to check if a value is a Complete");
336
345
});
+1
-1
packages/prototypey/tests/infer.bench.ts
···
9
9
}),
10
10
});
11
11
return schema.infer;
12
12
-
}).types([899, "instantiations"]);
12
12
+
}).types([741, "instantiations"]);
13
13
14
14
bench("infer with complex nested structure", () => {
15
15
const schema = lx.namespace("test.complex", {
+1
-1
pnpm-workspace.yaml
···
1
1
packages:
2
2
-
- 'packages/*'
2
2
+
- "packages/*"