@apollo-deploy/tesseract 2.0.0 → 2.2.0
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/adapters/go/index.d.ts.map +1 -1
- package/dist/adapters/go/index.js +11 -8
- package/dist/adapters/go/index.js.map +1 -1
- package/dist/adapters/kotlin/index.d.ts.map +1 -1
- package/dist/adapters/kotlin/index.js +25 -12
- package/dist/adapters/kotlin/index.js.map +1 -1
- package/dist/adapters/typescript/emitter/emitSchema.d.ts +6 -7
- package/dist/adapters/typescript/emitter/emitSchema.d.ts.map +1 -1
- package/dist/adapters/typescript/emitter/emitSchema.js +101 -86
- package/dist/adapters/typescript/emitter/emitSchema.js.map +1 -1
- package/dist/adapters/typescript/emitter/emitTypeScriptModels.d.ts.map +1 -1
- package/dist/adapters/typescript/emitter/emitTypeScriptModels.js +42 -6
- package/dist/adapters/typescript/emitter/emitTypeScriptModels.js.map +1 -1
- package/dist/adapters/typescript/emitter/importCollector.d.ts +2 -2
- package/dist/adapters/typescript/emitter/importCollector.d.ts.map +1 -1
- package/dist/adapters/typescript/emitter/importCollector.js +16 -5
- package/dist/adapters/typescript/emitter/importCollector.js.map +1 -1
- package/dist/adapters/typescript/emitter/zodType.d.ts +7 -0
- package/dist/adapters/typescript/emitter/zodType.d.ts.map +1 -0
- package/dist/adapters/typescript/emitter/zodType.js +199 -0
- package/dist/adapters/typescript/emitter/zodType.js.map +1 -0
- package/dist/adapters/typescript/index.js +1 -15
- package/dist/adapters/typescript/index.js.map +1 -1
- package/dist/adapters/typescript/shared.d.ts +2 -0
- package/dist/adapters/typescript/shared.d.ts.map +1 -1
- package/dist/adapters/typescript/shared.js +22 -1
- package/dist/adapters/typescript/shared.js.map +1 -1
- package/dist/collector.d.ts +12 -4
- package/dist/collector.d.ts.map +1 -1
- package/dist/collector.js +40 -20
- package/dist/collector.js.map +1 -1
- package/dist/fastify.d.ts +2 -2
- package/dist/fastify.d.ts.map +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fastify.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/pipeline/intake.d.ts.map +1 -1
- package/dist/pipeline/intake.js +116 -65
- package/dist/pipeline/intake.js.map +1 -1
- package/dist/pipeline/validate.d.ts +11 -0
- package/dist/pipeline/validate.d.ts.map +1 -0
- package/dist/pipeline/validate.js +67 -0
- package/dist/pipeline/validate.js.map +1 -0
- package/package.json +8 -4
- package/templates/kotlin/types.hbs +1 -11
- package/templates/typescript/package-json.hbs +2 -1
- package/templates/typescript/types.hbs +2 -2
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EnrichedSDKIR } from '../types/ir.js';
|
|
2
|
+
/**
|
|
3
|
+
* Rejects SDK contracts whose shape has already been erased.
|
|
4
|
+
*
|
|
5
|
+
* Tesseract can translate concrete schemas between languages. It cannot recover
|
|
6
|
+
* fields from `unknown`, `Any`, `JsonElement`, or an untyped JSON map. Failing
|
|
7
|
+
* here keeps every generated target honest instead of quietly emitting catch-all
|
|
8
|
+
* types such as JsonElement, Any, mixed, or interface{}.
|
|
9
|
+
*/
|
|
10
|
+
export declare function validateConcreteContract(enriched: EnrichedSDKIR): void;
|
|
11
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/pipeline/validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAId,MAAM,gBAAgB,CAAC;AAKxB;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,CAGtE"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const DYNAMIC_TYPE_PATTERN = /\b(?:unknown|any|JsonElement|JsonObject|JsonArray|JsonPrimitive|JsonNull|Any)\b|serde_json::Value|interface\s*\{\s*\}/;
|
|
2
|
+
/**
|
|
3
|
+
* Rejects SDK contracts whose shape has already been erased.
|
|
4
|
+
*
|
|
5
|
+
* Tesseract can translate concrete schemas between languages. It cannot recover
|
|
6
|
+
* fields from `unknown`, `Any`, `JsonElement`, or an untyped JSON map. Failing
|
|
7
|
+
* here keeps every generated target honest instead of quietly emitting catch-all
|
|
8
|
+
* types such as JsonElement, Any, mixed, or interface{}.
|
|
9
|
+
*/
|
|
10
|
+
export function validateConcreteContract(enriched) {
|
|
11
|
+
for (const schema of enriched.schemas)
|
|
12
|
+
validateSchema(schema);
|
|
13
|
+
for (const group of enriched.groups)
|
|
14
|
+
validateGroup(group);
|
|
15
|
+
}
|
|
16
|
+
function validateSchema(schema) {
|
|
17
|
+
if (schema.ownership?.kind === 'external')
|
|
18
|
+
return;
|
|
19
|
+
if (DYNAMIC_TYPE_PATTERN.test(schema.name)) {
|
|
20
|
+
fail(`schema ${schema.name}`, schema.name);
|
|
21
|
+
}
|
|
22
|
+
checkType(`schema ${schema.name} alias`, schema.aliasType);
|
|
23
|
+
checkType(`schema ${schema.name} additionalProperties`, schema.additionalPropertiesType);
|
|
24
|
+
for (const [index, member] of (schema.unionMembers ?? []).entries()) {
|
|
25
|
+
checkType(`schema ${schema.name} union member ${index + 1}`, member);
|
|
26
|
+
}
|
|
27
|
+
for (const [index, member] of (schema.intersectionMembers ?? []).entries()) {
|
|
28
|
+
checkType(`schema ${schema.name} intersection member ${index + 1}`, member);
|
|
29
|
+
}
|
|
30
|
+
for (const property of schema.properties) {
|
|
31
|
+
checkType(`schema ${schema.name}.${property.name}`, property.type);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function validateGroup(group) {
|
|
35
|
+
for (const operation of group.operations)
|
|
36
|
+
validateOperation(group, operation);
|
|
37
|
+
}
|
|
38
|
+
function validateOperation(group, operation) {
|
|
39
|
+
const location = `${operation.httpMethod} ${operation.path} (${group.name}.${operation.name})`;
|
|
40
|
+
checkType(`${location} response`, operation.responseType);
|
|
41
|
+
checkType(`${location} request body`, operation.requestBody?.type);
|
|
42
|
+
checkType(`${location} query`, operation.queryType);
|
|
43
|
+
checkType(`${location} headers`, operation.headerType);
|
|
44
|
+
checkType(`${location} cookies`, operation.cookieType);
|
|
45
|
+
checkType(`${location} event`, operation.eventSchema);
|
|
46
|
+
checkType(`${location} SSE envelope`, operation.sseReturnType);
|
|
47
|
+
for (const parameter of [
|
|
48
|
+
...operation.pathParams,
|
|
49
|
+
...operation.queryParams,
|
|
50
|
+
...operation.headerParams,
|
|
51
|
+
...operation.cookieParams,
|
|
52
|
+
]) {
|
|
53
|
+
checkType(`${location} parameter ${parameter.originalName}`, parameter.type);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function checkType(location, type) {
|
|
57
|
+
if (!type || type === 'void' || type === 'never')
|
|
58
|
+
return;
|
|
59
|
+
if (DYNAMIC_TYPE_PATTERN.test(type))
|
|
60
|
+
fail(location, type);
|
|
61
|
+
}
|
|
62
|
+
function fail(location, type) {
|
|
63
|
+
throw new Error(`Tesseract cannot generate a complete SDK model for ${location}: ${type}. ` +
|
|
64
|
+
'Replace dynamic JSON/Any/unknown fields with a concrete serializable model. ' +
|
|
65
|
+
'For example, use Map<String, PaymentMethod> instead of Map<String, JsonElement>.');
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/pipeline/validate.ts"],"names":[],"mappings":"AAOA,MAAM,oBAAoB,GACxB,uHAAuH,CAAC;AAE1H;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CAAC,QAAuB;IAC9D,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,OAAO;QAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IAC9D,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,MAAM;QAAE,aAAa,CAAC,KAAK,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,cAAc,CAAC,MA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C5D,CAAC;AAED,SAAS,IAAI,CAAC,QAAgB,EAAE,IAAY;IAC1C,MAAM,IAAI,KAAK,CACb,sDAAsD,QAAQ,KAAK,IAAI,IAAI;QACzE,8EAA8E;QAC9E,kFAAkF,CACrF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apollo-deploy/tesseract",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Manifest-first SDK generator for TypeScript, Python, Ruby, PHP, Go, Rust, Kotlin, and C#",
|
|
6
6
|
"bin": {
|
|
@@ -59,8 +59,10 @@
|
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build": "tsc",
|
|
61
61
|
"dev": "bun src/cli.ts",
|
|
62
|
-
"
|
|
63
|
-
"test": "
|
|
62
|
+
"test": "vitest run",
|
|
63
|
+
"test:coverage": "vitest run --coverage",
|
|
64
|
+
"test:watch": "vitest",
|
|
65
|
+
"test:ui": "vitest --ui"
|
|
64
66
|
},
|
|
65
67
|
"dependencies": {
|
|
66
68
|
"change-case": "^5.4.4",
|
|
@@ -109,6 +111,8 @@
|
|
|
109
111
|
"devDependencies": {
|
|
110
112
|
"@types/node": "^20.14.0",
|
|
111
113
|
"fastify": "^5.8.5",
|
|
112
|
-
"typescript": "^5.5.0"
|
|
114
|
+
"typescript": "^5.5.0",
|
|
115
|
+
"vitest": "^3.2.4",
|
|
116
|
+
"@vitest/coverage-v8": "^3.2.4"
|
|
113
117
|
}
|
|
114
118
|
}
|
|
@@ -2,13 +2,9 @@ package {{packageName}}.models
|
|
|
2
2
|
|
|
3
3
|
import kotlinx.serialization.SerialName
|
|
4
4
|
import kotlinx.serialization.Serializable
|
|
5
|
-
import kotlinx.serialization.json.JsonElement
|
|
6
5
|
|
|
7
6
|
{{#each schemas}}
|
|
8
|
-
{{#if
|
|
9
|
-
typealias {{name}} = JsonElement
|
|
10
|
-
|
|
11
|
-
{{else if isEnum}}
|
|
7
|
+
{{#if isEnum}}
|
|
12
8
|
{{#if stringEnum}}
|
|
13
9
|
@Serializable
|
|
14
10
|
enum class {{name}} {
|
|
@@ -20,12 +16,6 @@ enum class {{name}} {
|
|
|
20
16
|
typealias {{name}} = Double
|
|
21
17
|
{{/if}}
|
|
22
18
|
|
|
23
|
-
{{else if isUnionType}}
|
|
24
|
-
typealias {{name}} = JsonElement
|
|
25
|
-
|
|
26
|
-
{{else if isIntersectionType}}
|
|
27
|
-
typealias {{name}} = JsonElement
|
|
28
|
-
|
|
29
19
|
{{else if isTypeAlias}}
|
|
30
20
|
typealias {{name}} = {{{aliasType}}}
|
|
31
21
|
|
|
@@ -17,11 +17,11 @@ export { SDKError } from './errors.js';
|
|
|
17
17
|
|
|
18
18
|
// ── Per-domain type files ────────────────────────────
|
|
19
19
|
{{#each domainTypeFiles}}
|
|
20
|
-
export
|
|
20
|
+
export * from './{{this}}.js';
|
|
21
21
|
{{/each}}
|
|
22
22
|
{{/if}}
|
|
23
23
|
{{#if includeModels}}
|
|
24
|
-
export
|
|
24
|
+
export * from './models.js';
|
|
25
25
|
{{/if}}
|
|
26
26
|
{{#if externalImports.length}}
|
|
27
27
|
|