@fabricorg/gen-types 1.0.0 → 2.0.1
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/CHANGELOG.md +15 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Republish package manifests with dependency and peer ranges synchronized to Platform 1.2. The
|
|
8
|
+
runtime and generated contracts are unchanged.
|
|
9
|
+
|
|
10
|
+
## 2.0.0
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
- @fabricorg/platform@1.0.0
|
|
16
|
+
- @fabricorg/compiler@2.0.0
|
|
17
|
+
|
|
3
18
|
## 1.0.0
|
|
4
19
|
|
|
5
20
|
### Major Changes
|
package/dist/index.cjs
CHANGED
|
@@ -63,7 +63,7 @@ function jsonSchemaToTypeScript(schema, root = schema, resolving = /* @__PURE__
|
|
|
63
63
|
}
|
|
64
64
|
var typesGenerator = {
|
|
65
65
|
name: "@fabricorg/gen-types",
|
|
66
|
-
version: "
|
|
66
|
+
version: "2.0.1",
|
|
67
67
|
generate(ir) {
|
|
68
68
|
return ir.modules.map((module2) => {
|
|
69
69
|
const declarations = module2.objectTypes.map((objectType) => `export type ${objectType.type} = ${jsonSchemaToTypeScript(objectType.schema, objectType.schema, /* @__PURE__ */ new Set(), objectType.type)};`);
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts"],"sourcesContent":["import type { FabricCompilerIr, GeneratorTarget } from \"@fabricorg/compiler\";\nimport type { PortableJsonSchema } from \"@fabricorg/platform\";\n\nexport function jsonSchemaToTypeScript(\n\tschema: PortableJsonSchema | undefined,\n\troot = schema,\n\tresolving = new Set<string>(),\n\trecursiveTypeName?: string,\n): string {\n\tif (!schema) return \"unknown\";\n\tif (schema.$ref) {\n\t\tconst match = schema.$ref.match(/^#\\/\\$defs\\/([^/]+)$/);\n\t\tconst resolved = match ? root?.$defs?.[decodeURIComponent(match[1]!)] : undefined;\n\t\tif (!resolved) throw new Error(`Unsupported or unresolved JSON Schema reference \"${schema.$ref}\".`);\n\t\tif (resolving.has(schema.$ref)) {\n\t\t\tif (recursiveTypeName) return recursiveTypeName;\n\t\t\tthrow new Error(`Recursive JSON Schema reference \"${schema.$ref}\" requires a named generated type.`);\n\t\t}\n\t\tconst next = new Set(resolving).add(schema.$ref);\n\t\treturn jsonSchemaToTypeScript(resolved, root, next, recursiveTypeName);\n\t}\n\tif (schema.allOf) return schema.allOf.map((item) => jsonSchemaToTypeScript(item, root, resolving, recursiveTypeName)).join(\" & \");\n\tif (schema.enum) return schema.enum.map((value) => JSON.stringify(value)).join(\" | \") || \"never\";\n\tif (schema.const !== undefined) return JSON.stringify(schema.const);\n\tif (schema.oneOf) return schema.oneOf.map((item) => jsonSchemaToTypeScript(item, root, resolving, recursiveTypeName)).join(\" | \");\n\tif (schema.anyOf) return schema.anyOf.map((item) => jsonSchemaToTypeScript(item, root, resolving, recursiveTypeName)).join(\" | \");\n\tconst type = Array.isArray(schema.type) ? schema.type : schema.type ? [schema.type] : [];\n\tconst variants = type.map((item) => {\n\t\tif (item === \"string\") return \"string\";\n\t\tif (item === \"number\" || item === \"integer\") return \"number\";\n\t\tif (item === \"boolean\") return \"boolean\";\n\t\tif (item === \"null\") return \"null\";\n\t\tif (item === \"array\") {\n\t\t\tif (schema.prefixItems) return `[${schema.prefixItems.map((child) => jsonSchemaToTypeScript(child, root, resolving, recursiveTypeName)).join(\", \")}]`;\n\t\t\treturn `Array<${Array.isArray(schema.items) ? schema.items.map((child) => jsonSchemaToTypeScript(child, root, resolving, recursiveTypeName)).join(\" | \") : jsonSchemaToTypeScript(schema.items, root, resolving, recursiveTypeName)}>`;\n\t\t}\n\t\tif (item === \"object\") {\n\t\t\tconst required = new Set(schema.required ?? []);\n\t\t\tconst properties = Object.entries(schema.properties ?? {}).map(([name, child]) => `${JSON.stringify(name)}${required.has(name) ? \"\" : \"?\"}: ${jsonSchemaToTypeScript(child, root, resolving, recursiveTypeName)};`);\n\t\t\treturn `{ ${properties.join(\" \")} }`;\n\t\t}\n\t\treturn \"unknown\";\n\t});\n\treturn variants.length ? variants.join(\" | \") : schema.properties ? jsonSchemaToTypeScript({ ...schema, type: \"object\" }, root, resolving, recursiveTypeName) : \"unknown\";\n}\n\nexport const typesGenerator: GeneratorTarget = {\n\tname: \"@fabricorg/gen-types\",\n\tversion: \"
|
|
1
|
+
{"version":3,"sources":["../index.ts"],"sourcesContent":["import type { FabricCompilerIr, GeneratorTarget } from \"@fabricorg/compiler\";\nimport type { PortableJsonSchema } from \"@fabricorg/platform\";\n\nexport function jsonSchemaToTypeScript(\n\tschema: PortableJsonSchema | undefined,\n\troot = schema,\n\tresolving = new Set<string>(),\n\trecursiveTypeName?: string,\n): string {\n\tif (!schema) return \"unknown\";\n\tif (schema.$ref) {\n\t\tconst match = schema.$ref.match(/^#\\/\\$defs\\/([^/]+)$/);\n\t\tconst resolved = match ? root?.$defs?.[decodeURIComponent(match[1]!)] : undefined;\n\t\tif (!resolved) throw new Error(`Unsupported or unresolved JSON Schema reference \"${schema.$ref}\".`);\n\t\tif (resolving.has(schema.$ref)) {\n\t\t\tif (recursiveTypeName) return recursiveTypeName;\n\t\t\tthrow new Error(`Recursive JSON Schema reference \"${schema.$ref}\" requires a named generated type.`);\n\t\t}\n\t\tconst next = new Set(resolving).add(schema.$ref);\n\t\treturn jsonSchemaToTypeScript(resolved, root, next, recursiveTypeName);\n\t}\n\tif (schema.allOf) return schema.allOf.map((item) => jsonSchemaToTypeScript(item, root, resolving, recursiveTypeName)).join(\" & \");\n\tif (schema.enum) return schema.enum.map((value) => JSON.stringify(value)).join(\" | \") || \"never\";\n\tif (schema.const !== undefined) return JSON.stringify(schema.const);\n\tif (schema.oneOf) return schema.oneOf.map((item) => jsonSchemaToTypeScript(item, root, resolving, recursiveTypeName)).join(\" | \");\n\tif (schema.anyOf) return schema.anyOf.map((item) => jsonSchemaToTypeScript(item, root, resolving, recursiveTypeName)).join(\" | \");\n\tconst type = Array.isArray(schema.type) ? schema.type : schema.type ? [schema.type] : [];\n\tconst variants = type.map((item) => {\n\t\tif (item === \"string\") return \"string\";\n\t\tif (item === \"number\" || item === \"integer\") return \"number\";\n\t\tif (item === \"boolean\") return \"boolean\";\n\t\tif (item === \"null\") return \"null\";\n\t\tif (item === \"array\") {\n\t\t\tif (schema.prefixItems) return `[${schema.prefixItems.map((child) => jsonSchemaToTypeScript(child, root, resolving, recursiveTypeName)).join(\", \")}]`;\n\t\t\treturn `Array<${Array.isArray(schema.items) ? schema.items.map((child) => jsonSchemaToTypeScript(child, root, resolving, recursiveTypeName)).join(\" | \") : jsonSchemaToTypeScript(schema.items, root, resolving, recursiveTypeName)}>`;\n\t\t}\n\t\tif (item === \"object\") {\n\t\t\tconst required = new Set(schema.required ?? []);\n\t\t\tconst properties = Object.entries(schema.properties ?? {}).map(([name, child]) => `${JSON.stringify(name)}${required.has(name) ? \"\" : \"?\"}: ${jsonSchemaToTypeScript(child, root, resolving, recursiveTypeName)};`);\n\t\t\treturn `{ ${properties.join(\" \")} }`;\n\t\t}\n\t\treturn \"unknown\";\n\t});\n\treturn variants.length ? variants.join(\" | \") : schema.properties ? jsonSchemaToTypeScript({ ...schema, type: \"object\" }, root, resolving, recursiveTypeName) : \"unknown\";\n}\n\nexport const typesGenerator: GeneratorTarget = {\n\tname: \"@fabricorg/gen-types\",\n\tversion: \"2.0.1\",\n\tgenerate(ir: FabricCompilerIr) {\n\t\treturn ir.modules.map((module) => {\n\t\t\tconst declarations = module.objectTypes.map((objectType) => `export type ${objectType.type} = ${jsonSchemaToTypeScript(objectType.schema, objectType.schema, new Set(), objectType.type)};`);\n\t\t\tconst actionTypes = module.actions.flatMap((action) => [\n\t\t\t\t`export type ${pascal(action.actionId)}Parameters = ${jsonSchemaToTypeScript(action.parameterSchema as PortableJsonSchema | undefined, action.parameterSchema as PortableJsonSchema | undefined, new Set(), `${pascal(action.actionId)}Parameters`)};`,\n\t\t\t\t`export type ${pascal(action.actionId)}Result = ${jsonSchemaToTypeScript(action.resultSchema as PortableJsonSchema | undefined, action.resultSchema as PortableJsonSchema | undefined, new Set(), `${pascal(action.actionId)}Result`)};`,\n\t\t\t]);\n\t\t\treturn { path: `${module.namespace}/index.ts`, content: `// Generated by ${typesGenerator.name}@${typesGenerator.version}\\n// Manifest digest: ${ir.manifestDigest}\\n\\n${[...declarations, ...actionTypes].join(\"\\n\\n\")}\\n` };\n\t\t});\n\t},\n};\n\nconst pascal = (value: string): string => value.split(/[._/-]/).filter(Boolean).map((part) => part[0]?.toUpperCase() + part.slice(1)).join(\"\");\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,SAAS,uBACf,QACA,OAAO,QACP,YAAY,oBAAI,IAAY,GAC5B,mBACS;AACT,MAAI,CAAC,OAAQ,QAAO;AACpB,MAAI,OAAO,MAAM;AAChB,UAAM,QAAQ,OAAO,KAAK,MAAM,sBAAsB;AACtD,UAAM,WAAW,QAAQ,MAAM,QAAQ,mBAAmB,MAAM,CAAC,CAAE,CAAC,IAAI;AACxE,QAAI,CAAC,SAAU,OAAM,IAAI,MAAM,oDAAoD,OAAO,IAAI,IAAI;AAClG,QAAI,UAAU,IAAI,OAAO,IAAI,GAAG;AAC/B,UAAI,kBAAmB,QAAO;AAC9B,YAAM,IAAI,MAAM,oCAAoC,OAAO,IAAI,oCAAoC;AAAA,IACpG;AACA,UAAM,OAAO,IAAI,IAAI,SAAS,EAAE,IAAI,OAAO,IAAI;AAC/C,WAAO,uBAAuB,UAAU,M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sBAAyB,GAAG,cAAc;AAAA;AAAA,EAAO,CAAC,GAAG,cAAc,GAAG,WAAW,EAAE,KAAK,MAAM,CAAC;AAAA,EAAK;AAAA,IAC7N,CAAC;AAAA,EACF;AACD;AAEA,IAAM,SAAS,CAAC,UAA0B,MAAM,MAAM,QAAQ,EAAE,OAAO,OAAO,EAAE,IAAI,CAAC,SAAS,KAAK,CAAC,GAAG,YAAY,IAAI,KAAK,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE;","names":["module"]}
|
package/dist/index.js
CHANGED
|
@@ -38,7 +38,7 @@ function jsonSchemaToTypeScript(schema, root = schema, resolving = /* @__PURE__
|
|
|
38
38
|
}
|
|
39
39
|
var typesGenerator = {
|
|
40
40
|
name: "@fabricorg/gen-types",
|
|
41
|
-
version: "
|
|
41
|
+
version: "2.0.1",
|
|
42
42
|
generate(ir) {
|
|
43
43
|
return ir.modules.map((module) => {
|
|
44
44
|
const declarations = module.objectTypes.map((objectType) => `export type ${objectType.type} = ${jsonSchemaToTypeScript(objectType.schema, objectType.schema, /* @__PURE__ */ new Set(), objectType.type)};`);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts"],"sourcesContent":["import type { FabricCompilerIr, GeneratorTarget } from \"@fabricorg/compiler\";\nimport type { PortableJsonSchema } from \"@fabricorg/platform\";\n\nexport function jsonSchemaToTypeScript(\n\tschema: PortableJsonSchema | undefined,\n\troot = schema,\n\tresolving = new Set<string>(),\n\trecursiveTypeName?: string,\n): string {\n\tif (!schema) return \"unknown\";\n\tif (schema.$ref) {\n\t\tconst match = schema.$ref.match(/^#\\/\\$defs\\/([^/]+)$/);\n\t\tconst resolved = match ? root?.$defs?.[decodeURIComponent(match[1]!)] : undefined;\n\t\tif (!resolved) throw new Error(`Unsupported or unresolved JSON Schema reference \"${schema.$ref}\".`);\n\t\tif (resolving.has(schema.$ref)) {\n\t\t\tif (recursiveTypeName) return recursiveTypeName;\n\t\t\tthrow new Error(`Recursive JSON Schema reference \"${schema.$ref}\" requires a named generated type.`);\n\t\t}\n\t\tconst next = new Set(resolving).add(schema.$ref);\n\t\treturn jsonSchemaToTypeScript(resolved, root, next, recursiveTypeName);\n\t}\n\tif (schema.allOf) return schema.allOf.map((item) => jsonSchemaToTypeScript(item, root, resolving, recursiveTypeName)).join(\" & \");\n\tif (schema.enum) return schema.enum.map((value) => JSON.stringify(value)).join(\" | \") || \"never\";\n\tif (schema.const !== undefined) return JSON.stringify(schema.const);\n\tif (schema.oneOf) return schema.oneOf.map((item) => jsonSchemaToTypeScript(item, root, resolving, recursiveTypeName)).join(\" | \");\n\tif (schema.anyOf) return schema.anyOf.map((item) => jsonSchemaToTypeScript(item, root, resolving, recursiveTypeName)).join(\" | \");\n\tconst type = Array.isArray(schema.type) ? schema.type : schema.type ? [schema.type] : [];\n\tconst variants = type.map((item) => {\n\t\tif (item === \"string\") return \"string\";\n\t\tif (item === \"number\" || item === \"integer\") return \"number\";\n\t\tif (item === \"boolean\") return \"boolean\";\n\t\tif (item === \"null\") return \"null\";\n\t\tif (item === \"array\") {\n\t\t\tif (schema.prefixItems) return `[${schema.prefixItems.map((child) => jsonSchemaToTypeScript(child, root, resolving, recursiveTypeName)).join(\", \")}]`;\n\t\t\treturn `Array<${Array.isArray(schema.items) ? schema.items.map((child) => jsonSchemaToTypeScript(child, root, resolving, recursiveTypeName)).join(\" | \") : jsonSchemaToTypeScript(schema.items, root, resolving, recursiveTypeName)}>`;\n\t\t}\n\t\tif (item === \"object\") {\n\t\t\tconst required = new Set(schema.required ?? []);\n\t\t\tconst properties = Object.entries(schema.properties ?? {}).map(([name, child]) => `${JSON.stringify(name)}${required.has(name) ? \"\" : \"?\"}: ${jsonSchemaToTypeScript(child, root, resolving, recursiveTypeName)};`);\n\t\t\treturn `{ ${properties.join(\" \")} }`;\n\t\t}\n\t\treturn \"unknown\";\n\t});\n\treturn variants.length ? variants.join(\" | \") : schema.properties ? jsonSchemaToTypeScript({ ...schema, type: \"object\" }, root, resolving, recursiveTypeName) : \"unknown\";\n}\n\nexport const typesGenerator: GeneratorTarget = {\n\tname: \"@fabricorg/gen-types\",\n\tversion: \"
|
|
1
|
+
{"version":3,"sources":["../index.ts"],"sourcesContent":["import type { FabricCompilerIr, GeneratorTarget } from \"@fabricorg/compiler\";\nimport type { PortableJsonSchema } from \"@fabricorg/platform\";\n\nexport function jsonSchemaToTypeScript(\n\tschema: PortableJsonSchema | undefined,\n\troot = schema,\n\tresolving = new Set<string>(),\n\trecursiveTypeName?: string,\n): string {\n\tif (!schema) return \"unknown\";\n\tif (schema.$ref) {\n\t\tconst match = schema.$ref.match(/^#\\/\\$defs\\/([^/]+)$/);\n\t\tconst resolved = match ? root?.$defs?.[decodeURIComponent(match[1]!)] : undefined;\n\t\tif (!resolved) throw new Error(`Unsupported or unresolved JSON Schema reference \"${schema.$ref}\".`);\n\t\tif (resolving.has(schema.$ref)) {\n\t\t\tif (recursiveTypeName) return recursiveTypeName;\n\t\t\tthrow new Error(`Recursive JSON Schema reference \"${schema.$ref}\" requires a named generated type.`);\n\t\t}\n\t\tconst next = new Set(resolving).add(schema.$ref);\n\t\treturn jsonSchemaToTypeScript(resolved, root, next, recursiveTypeName);\n\t}\n\tif (schema.allOf) return schema.allOf.map((item) => jsonSchemaToTypeScript(item, root, resolving, recursiveTypeName)).join(\" & \");\n\tif (schema.enum) return schema.enum.map((value) => JSON.stringify(value)).join(\" | \") || \"never\";\n\tif (schema.const !== undefined) return JSON.stringify(schema.const);\n\tif (schema.oneOf) return schema.oneOf.map((item) => jsonSchemaToTypeScript(item, root, resolving, recursiveTypeName)).join(\" | \");\n\tif (schema.anyOf) return schema.anyOf.map((item) => jsonSchemaToTypeScript(item, root, resolving, recursiveTypeName)).join(\" | \");\n\tconst type = Array.isArray(schema.type) ? schema.type : schema.type ? [schema.type] : [];\n\tconst variants = type.map((item) => {\n\t\tif (item === \"string\") return \"string\";\n\t\tif (item === \"number\" || item === \"integer\") return \"number\";\n\t\tif (item === \"boolean\") return \"boolean\";\n\t\tif (item === \"null\") return \"null\";\n\t\tif (item === \"array\") {\n\t\t\tif (schema.prefixItems) return `[${schema.prefixItems.map((child) => jsonSchemaToTypeScript(child, root, resolving, recursiveTypeName)).join(\", \")}]`;\n\t\t\treturn `Array<${Array.isArray(schema.items) ? schema.items.map((child) => jsonSchemaToTypeScript(child, root, resolving, recursiveTypeName)).join(\" | \") : jsonSchemaToTypeScript(schema.items, root, resolving, recursiveTypeName)}>`;\n\t\t}\n\t\tif (item === \"object\") {\n\t\t\tconst required = new Set(schema.required ?? []);\n\t\t\tconst properties = Object.entries(schema.properties ?? {}).map(([name, child]) => `${JSON.stringify(name)}${required.has(name) ? \"\" : \"?\"}: ${jsonSchemaToTypeScript(child, root, resolving, recursiveTypeName)};`);\n\t\t\treturn `{ ${properties.join(\" \")} }`;\n\t\t}\n\t\treturn \"unknown\";\n\t});\n\treturn variants.length ? variants.join(\" | \") : schema.properties ? jsonSchemaToTypeScript({ ...schema, type: \"object\" }, root, resolving, recursiveTypeName) : \"unknown\";\n}\n\nexport const typesGenerator: GeneratorTarget = {\n\tname: \"@fabricorg/gen-types\",\n\tversion: \"2.0.1\",\n\tgenerate(ir: FabricCompilerIr) {\n\t\treturn ir.modules.map((module) => {\n\t\t\tconst declarations = module.objectTypes.map((objectType) => `export type ${objectType.type} = ${jsonSchemaToTypeScript(objectType.schema, objectType.schema, new Set(), objectType.type)};`);\n\t\t\tconst actionTypes = module.actions.flatMap((action) => [\n\t\t\t\t`export type ${pascal(action.actionId)}Parameters = ${jsonSchemaToTypeScript(action.parameterSchema as PortableJsonSchema | undefined, action.parameterSchema as PortableJsonSchema | undefined, new Set(), `${pascal(action.actionId)}Parameters`)};`,\n\t\t\t\t`export type ${pascal(action.actionId)}Result = ${jsonSchemaToTypeScript(action.resultSchema as PortableJsonSchema | undefined, action.resultSchema as PortableJsonSchema | undefined, new Set(), `${pascal(action.actionId)}Result`)};`,\n\t\t\t]);\n\t\t\treturn { path: `${module.namespace}/index.ts`, content: `// Generated by ${typesGenerator.name}@${typesGenerator.version}\\n// Manifest digest: ${ir.manifestDigest}\\n\\n${[...declarations, ...actionTypes].join(\"\\n\\n\")}\\n` };\n\t\t});\n\t},\n};\n\nconst pascal = (value: string): string => value.split(/[._/-]/).filter(Boolean).map((part) => part[0]?.toUpperCase() + part.slice(1)).join(\"\");\n"],"mappings":";AAGO,SAAS,uBACf,QACA,OAAO,QACP,YAAY,oBAAI,IAAY,GAC5B,mBACS;AACT,MAAI,CAAC,OAAQ,QAAO;AACpB,MAAI,OAAO,MAAM;AAChB,UAAM,QAAQ,OAAO,KAAK,MAAM,sBAAsB;AACtD,UAAM,WAAW,QAAQ,MAAM,QAAQ,mBAAmB,MAAM,CAAC,CAAE,CAAC,IAAI;AACxE,QAAI,CAAC,SAAU,OAAM,IAAI,MAAM,oDAAoD,OAAO,IAAI,IAAI;AAClG,QAAI,UAAU,IAAI,OAAO,IAAI,GAAG;AAC/B,UAAI,kBAAmB,QAAO;AAC9B,YAAM,IAAI,MAAM,oCAAoC,OAAO,IAAI,oCAAoC;AAAA,IACpG;AACA,UAAM,OAAO,IAAI,IAAI,SAAS,EAAE,IAAI,OAAO,IAAI;AAC/C,WAAO,uBAAuB,UAAU,MAAM,MAAM,iBAAiB;AAAA,EACtE;AACA,MAAI,OAAO,MAAO,QAAO,OAAO,MAAM,IAAI,CAAC,SAAS,uBAAuB,MAAM,MAAM,WAAW,iBAAiB,CAAC,EAAE,KAAK,KAAK;AAChI,MAAI,OAAO,KAAM,QAAO,OAAO,KAAK,IAAI,CAAC,UAAU,KAAK,UAAU,KAAK,CAAC,EAAE,KAAK,KAAK,KAAK;AACzF,MAAI,OAAO,UAAU,OAAW,QAAO,KAAK,UAAU,OAAO,KAAK;AAClE,MAAI,OAAO,MAAO,QAAO,OAAO,MAAM,IAAI,CAAC,SAAS,uBAAuB,MAAM,MAAM,WAAW,iBAAiB,CAAC,EAAE,KAAK,KAAK;AAChI,MA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4
4
|
"description": "TypeScript type generator for Fabric compiler IR.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
"CHANGELOG.md"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@fabricorg/compiler": "^
|
|
28
|
+
"@fabricorg/compiler": "^2.2.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@fabricorg/platform": "^
|
|
31
|
+
"@fabricorg/platform": "^1.2.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "^22.10.0",
|
|
35
35
|
"tsup": "^8.5.0",
|
|
36
36
|
"typescript": "^5.7.3",
|
|
37
37
|
"vitest": "^4.1.5",
|
|
38
|
-
"@fabricorg/platform": "^
|
|
38
|
+
"@fabricorg/platform": "^1.2.0"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">=20"
|