@fabricorg/gen-graphql 0.2.0 → 1.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - Require Platform 0.12 and Compiler 1.0 generated-artifact contracts.
8
+
9
+ ## 0.2.1
10
+
11
+ ### Patch Changes
12
+
13
+ - Close final uplift audit gaps: align Host 2.x documentation and migration evidence, surface every
14
+ compiler/generator API to LLM consumers, make memory outbox egress directly usable, sanitize relay
15
+ failures, validate complete archetype state maps, support recursive JSON Schema generation, reject
16
+ cross-platform path traversal, synchronize artifact version stamps, and include package licenses.
17
+ - Reject normalized property collisions and prevent schema properties from duplicating built-in
18
+ identity and tenant fields.
19
+ - Consume Platform as a peer dependency so applications keep a single copy of the public contracts.
20
+ - Updated dependencies
21
+ - @fabricorg/platform@0.11.1
22
+ - @fabricorg/compiler@0.2.1
23
+
3
24
  ## 0.2.0
4
25
 
5
26
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -34,12 +34,15 @@ var identifier = (value) => {
34
34
  };
35
35
  var graphqlGenerator = {
36
36
  name: "@fabricorg/gen-graphql",
37
- version: "0.1.0",
37
+ version: "1.0.0",
38
38
  generate(ir) {
39
39
  return ir.modules.flatMap((module2) => {
40
40
  const types = module2.objectTypes.map((objectType) => {
41
41
  const required = new Set(objectType.schema?.required ?? []);
42
- const fields = Object.entries(objectType.schema?.properties ?? {}).map(
42
+ const properties = Object.entries(objectType.schema?.properties ?? {}).filter(([name]) => !["id", "tenantId", "spaceId"].includes(name));
43
+ const fieldNames = properties.map(([name]) => identifier(name));
44
+ if (new Set(fieldNames).size !== fieldNames.length) throw new Error(`Object "${module2.namespace}.${objectType.type}" produces colliding GraphQL field names.`);
45
+ const fields = properties.map(
43
46
  ([name, schema]) => ` ${identifier(name)}: ${gql(schema)}${required.has(name) ? "!" : ""}`
44
47
  );
45
48
  return [`type ${pascal(module2.namespace)}${objectType.type} @key(fields: "id") {`, " id: ID!", " tenantId: ID!", " spaceId: ID!", ...fields, "}"].join("\n");
@@ -1 +1 @@
1
- {"version":3,"sources":["../index.ts"],"sourcesContent":["import type { GeneratorTarget } from \"@fabricorg/compiler\";\nimport type { PortableJsonSchema } from \"@fabricorg/platform\";\n\nconst pascal = (value: string): string =>\n\tvalue.split(/[-._/]/).filter(Boolean).map((part) => part[0]?.toUpperCase() + part.slice(1)).join(\"\");\nconst gql = (schema: PortableJsonSchema): string => {\n\tconst type = Array.isArray(schema.type) ? schema.type[0] : schema.type;\n\treturn type === \"integer\" ? \"Int\" : type === \"number\" ? \"Float\" : type === \"boolean\" ? \"Boolean\" : type === \"string\" ? \"String\" : \"JSON\";\n};\nconst identifier = (value: string): string => {\n\tconst normalized = value.replace(/[^_0-9A-Za-z]/g, \"_\");\n\treturn /^[_A-Za-z]/.test(normalized) ? normalized : `field_${normalized}`;\n};\n\nexport const graphqlGenerator: GeneratorTarget = {\n\tname: \"@fabricorg/gen-graphql\",\n\tversion: \"0.1.0\",\n\tgenerate(ir) {\n\t\treturn ir.modules.flatMap((module) => {\n\t\t\tconst types = module.objectTypes.map((objectType) => {\n\t\t\t\tconst required = new Set(objectType.schema?.required ?? []);\n\t\t\t\tconst fields = Object.entries(objectType.schema?.properties ?? {}).map(\n\t\t\t\t\t([name, schema]) => ` ${identifier(name)}: ${gql(schema)}${required.has(name) ? \"!\" : \"\"}`,\n\t\t\t\t);\n\t\t\t\treturn [`type ${pascal(module.namespace)}${objectType.type} @key(fields: \"id\") {`, \" id: ID!\", \" tenantId: ID!\", \" spaceId: ID!\", ...fields, \"}\"].join(\"\\n\");\n\t\t\t});\n\t\t\tconst fieldName = (value: string): string => {\n\t\t\t\tconst name = pascal(value);\n\t\t\t\treturn `${name[0]?.toLowerCase() ?? \"\"}${name.slice(1)}`;\n\t\t\t};\n\t\t\tconst queryFields = module.views.map((view) => ` ${fieldName(view.name)}: JSON!`);\n\t\t\tconst mutations = module.actions.map((action) => ` ${fieldName(action.actionId)}(parameters: JSON!): GovernedActionSubmission!`);\n\t\t\tconst operationNames = [...module.views.map((view) => fieldName(view.name)), ...module.actions.map((action) => fieldName(action.actionId))];\n\t\t\tif (new Set(operationNames).size !== operationNames.length) throw new Error(`Module \"${module.namespace}\" produces colliding GraphQL operation names.`);\n\t\t\tconst content = [\n\t\t\t\t`# Generated by ${graphqlGenerator.name}@${graphqlGenerator.version}`,\n\t\t\t\t`# Manifest digest: ${ir.manifestDigest}`,\n\t\t\t\t\"scalar JSON\",\n\t\t\t\t\"type GovernedActionSubmission { actionInvocationId: ID!, status: String! }\",\n\t\t\t\t...types,\n\t\t\t\t`type Query {\\n${queryFields.length ? queryFields.join(\"\\n\") : \" _fabric: Boolean!\"}\\n}`,\n\t\t\t\t`type Mutation {\\n${mutations.length ? mutations.join(\"\\n\") : \" _fabric: Boolean!\"}\\n}`,\n\t\t\t\t\"\",\n\t\t\t].join(\"\\n\\n\");\n\t\t\tconst resolvers = [\n\t\t\t\t\"// Generated resolver seam. Authenticate first; derive actor and tenant server-side.\",\n\t\t\t\t`export const actionIds = ${JSON.stringify(Object.fromEntries(module.actions.map((action) => [fieldName(action.actionId), action.actionId])), null, 2)} as const;`,\n\t\t\t\t\"// Each mutation resolver must call createGovernedActionHost().submitAction(); never call handlers directly.\",\n\t\t\t\t\"\",\n\t\t\t].join(\"\\n\");\n\t\t\treturn [{ path: `${module.namespace}/schema.graphql`, content }, { path: `${module.namespace}/resolver-contract.ts`, content: resolvers }];\n\t\t});\n\t},\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,IAAM,SAAS,CAAC,UACf,MAAM,MAAM,QAAQ,EAAE,OAAO,OAAO,EAAE,IAAI,CAAC,SAAS,KAAK,CAAC,GAAG,YAAY,IAAI,KAAK,MAAM,CAAC,CAAC,EAAE,KAAK,EA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,WAAW,KAAK,UAAU,OAAO,QAAQ,CAAC,gDAAgD;AAChI,YAAM,iBAAiB,CAAC,GAAGA,QAAO,MAAM,IAAI,CAAC,SAAS,UAAU,KAAK,IAAI,CAAC,GAAG,GAAGA,QAAO,QAAQ,IAAI,CAAC,WAAW,UAAU,OAAO,QAAQ,CAAC,CAAC;AAC1I,UAAI,IAAI,IAAI,cAAc,EAAE,SAAS,eAAe,OAAQ,OAAM,IAAI,MAAM,WAAWA,QAAO,SAAS,+CAA+C;AACtJ,YAAM,UAAU;AAAA,QACf,kBAAkB,iBAAiB,IAAI,IAAI,iBAAiB,OAAO;AAAA,QACnE,sBAAsB,GAAG,cAAc;AAAA,QACvC;AAAA,QACA;AAAA,QACA,GAAG;AAAA,QACH;AAAA,EAAiB,YAAY,SAAS,YAAY,KAAK,IAAI,IAAI,qBAAqB;AAAA;AAAA,QACpF;AAAA,EAAoB,UAAU,SAAS,UAAU,KAAK,IAAI,IAAI,qBAAqB;AAAA;AAAA,QACnF;AAAA,MACD,EAAE,KAAK,MAAM;AACb,YAAM,YAAY;AAAA,QACjB;AAAA,QACA,4BAA4B,KAAK,UAAU,OAAO,YAAYA,QAAO,QAAQ,IAAI,CAAC,WAAW,CAAC,UAAU,OAAO,QAAQ,GAAG,OAAO,QAAQ,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;AAAA,QACtJ;AAAA,QACA;AAAA,MACD,EAAE,KAAK,IAAI;AACX,aAAO,CAAC,EAAE,MAAM,GAAGA,QAAO,SAAS,mBAAmB,QAAQ,GAAG,EAAE,MAAM,GAAGA,QAAO,SAAS,yBAAyB,SAAS,UAAU,CAAC;AAAA,IAC1I,CAAC;AAAA,EACF;AACD;","names":["module"]}
1
+ {"version":3,"sources":["../index.ts"],"sourcesContent":["import type { GeneratorTarget } from \"@fabricorg/compiler\";\nimport type { PortableJsonSchema } from \"@fabricorg/platform\";\n\nconst pascal = (value: string): string =>\n\tvalue.split(/[-._/]/).filter(Boolean).map((part) => part[0]?.toUpperCase() + part.slice(1)).join(\"\");\nconst gql = (schema: PortableJsonSchema): string => {\n\tconst type = Array.isArray(schema.type) ? schema.type[0] : schema.type;\n\treturn type === \"integer\" ? \"Int\" : type === \"number\" ? \"Float\" : type === \"boolean\" ? \"Boolean\" : type === \"string\" ? \"String\" : \"JSON\";\n};\nconst identifier = (value: string): string => {\n\tconst normalized = value.replace(/[^_0-9A-Za-z]/g, \"_\");\n\treturn /^[_A-Za-z]/.test(normalized) ? normalized : `field_${normalized}`;\n};\n\nexport const graphqlGenerator: GeneratorTarget = {\n\tname: \"@fabricorg/gen-graphql\",\n\tversion: \"1.0.0\",\n\tgenerate(ir) {\n\t\treturn ir.modules.flatMap((module) => {\n\t\t\tconst types = module.objectTypes.map((objectType) => {\n\t\t\t\tconst required = new Set(objectType.schema?.required ?? []);\n\t\t\t\tconst properties = Object.entries(objectType.schema?.properties ?? {}).filter(([name]) => ![\"id\", \"tenantId\", \"spaceId\"].includes(name));\n\t\t\t\tconst fieldNames = properties.map(([name]) => identifier(name));\n\t\t\t\tif (new Set(fieldNames).size !== fieldNames.length) throw new Error(`Object \"${module.namespace}.${objectType.type}\" produces colliding GraphQL field names.`);\n\t\t\t\tconst fields = properties.map(\n\t\t\t\t\t([name, schema]) => ` ${identifier(name)}: ${gql(schema)}${required.has(name) ? \"!\" : \"\"}`,\n\t\t\t\t);\n\t\t\t\treturn [`type ${pascal(module.namespace)}${objectType.type} @key(fields: \"id\") {`, \" id: ID!\", \" tenantId: ID!\", \" spaceId: ID!\", ...fields, \"}\"].join(\"\\n\");\n\t\t\t});\n\t\t\tconst fieldName = (value: string): string => {\n\t\t\t\tconst name = pascal(value);\n\t\t\t\treturn `${name[0]?.toLowerCase() ?? \"\"}${name.slice(1)}`;\n\t\t\t};\n\t\t\tconst queryFields = module.views.map((view) => ` ${fieldName(view.name)}: JSON!`);\n\t\t\tconst mutations = module.actions.map((action) => ` ${fieldName(action.actionId)}(parameters: JSON!): GovernedActionSubmission!`);\n\t\t\tconst operationNames = [...module.views.map((view) => fieldName(view.name)), ...module.actions.map((action) => fieldName(action.actionId))];\n\t\t\tif (new Set(operationNames).size !== operationNames.length) throw new Error(`Module \"${module.namespace}\" produces colliding GraphQL operation names.`);\n\t\t\tconst content = [\n\t\t\t\t`# Generated by ${graphqlGenerator.name}@${graphqlGenerator.version}`,\n\t\t\t\t`# Manifest digest: ${ir.manifestDigest}`,\n\t\t\t\t\"scalar JSON\",\n\t\t\t\t\"type GovernedActionSubmission { actionInvocationId: ID!, status: String! }\",\n\t\t\t\t...types,\n\t\t\t\t`type Query {\\n${queryFields.length ? queryFields.join(\"\\n\") : \" _fabric: Boolean!\"}\\n}`,\n\t\t\t\t`type Mutation {\\n${mutations.length ? mutations.join(\"\\n\") : \" _fabric: Boolean!\"}\\n}`,\n\t\t\t\t\"\",\n\t\t\t].join(\"\\n\\n\");\n\t\t\tconst resolvers = [\n\t\t\t\t\"// Generated resolver seam. Authenticate first; derive actor and tenant server-side.\",\n\t\t\t\t`export const actionIds = ${JSON.stringify(Object.fromEntries(module.actions.map((action) => [fieldName(action.actionId), action.actionId])), null, 2)} as const;`,\n\t\t\t\t\"// Each mutation resolver must call createGovernedActionHost().submitAction(); never call handlers directly.\",\n\t\t\t\t\"\",\n\t\t\t].join(\"\\n\");\n\t\t\treturn [{ path: `${module.namespace}/schema.graphql`, content }, { path: `${module.namespace}/resolver-contract.ts`, content: resolvers }];\n\t\t});\n\t},\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,IAAM,SAAS,CAAC,UACf,MAAM,MAAM,QAAQ,EAAE,OAAO,OAAO,EAAE,IAAI,CAAC,SAAS,KAAK,CAAC,GAAG,YAAY,IAAI,KAAK,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE;AACpG,IAAM,MAAM,CAAC,WAAuC;AACnD,QAAM,OAAO,MAAM,QAAQ,OAAO,IAAI,IAAI,OAAO,KAAK,CAAC,IAAI,OAA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ACF;AACD;","names":["module"]}
package/dist/index.js CHANGED
@@ -10,12 +10,15 @@ var identifier = (value) => {
10
10
  };
11
11
  var graphqlGenerator = {
12
12
  name: "@fabricorg/gen-graphql",
13
- version: "0.1.0",
13
+ version: "1.0.0",
14
14
  generate(ir) {
15
15
  return ir.modules.flatMap((module) => {
16
16
  const types = module.objectTypes.map((objectType) => {
17
17
  const required = new Set(objectType.schema?.required ?? []);
18
- const fields = Object.entries(objectType.schema?.properties ?? {}).map(
18
+ const properties = Object.entries(objectType.schema?.properties ?? {}).filter(([name]) => !["id", "tenantId", "spaceId"].includes(name));
19
+ const fieldNames = properties.map(([name]) => identifier(name));
20
+ if (new Set(fieldNames).size !== fieldNames.length) throw new Error(`Object "${module.namespace}.${objectType.type}" produces colliding GraphQL field names.`);
21
+ const fields = properties.map(
19
22
  ([name, schema]) => ` ${identifier(name)}: ${gql(schema)}${required.has(name) ? "!" : ""}`
20
23
  );
21
24
  return [`type ${pascal(module.namespace)}${objectType.type} @key(fields: "id") {`, " id: ID!", " tenantId: ID!", " spaceId: ID!", ...fields, "}"].join("\n");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../index.ts"],"sourcesContent":["import type { GeneratorTarget } from \"@fabricorg/compiler\";\nimport type { PortableJsonSchema } from \"@fabricorg/platform\";\n\nconst pascal = (value: string): string =>\n\tvalue.split(/[-._/]/).filter(Boolean).map((part) => part[0]?.toUpperCase() + part.slice(1)).join(\"\");\nconst gql = (schema: PortableJsonSchema): string => {\n\tconst type = Array.isArray(schema.type) ? schema.type[0] : schema.type;\n\treturn type === \"integer\" ? \"Int\" : type === \"number\" ? \"Float\" : type === \"boolean\" ? \"Boolean\" : type === \"string\" ? \"String\" : \"JSON\";\n};\nconst identifier = (value: string): string => {\n\tconst normalized = value.replace(/[^_0-9A-Za-z]/g, \"_\");\n\treturn /^[_A-Za-z]/.test(normalized) ? normalized : `field_${normalized}`;\n};\n\nexport const graphqlGenerator: GeneratorTarget = {\n\tname: \"@fabricorg/gen-graphql\",\n\tversion: \"0.1.0\",\n\tgenerate(ir) {\n\t\treturn ir.modules.flatMap((module) => {\n\t\t\tconst types = module.objectTypes.map((objectType) => {\n\t\t\t\tconst required = new Set(objectType.schema?.required ?? []);\n\t\t\t\tconst fields = Object.entries(objectType.schema?.properties ?? {}).map(\n\t\t\t\t\t([name, schema]) => ` ${identifier(name)}: ${gql(schema)}${required.has(name) ? \"!\" : \"\"}`,\n\t\t\t\t);\n\t\t\t\treturn [`type ${pascal(module.namespace)}${objectType.type} @key(fields: \"id\") {`, \" id: ID!\", \" tenantId: ID!\", \" spaceId: ID!\", ...fields, \"}\"].join(\"\\n\");\n\t\t\t});\n\t\t\tconst fieldName = (value: string): string => {\n\t\t\t\tconst name = pascal(value);\n\t\t\t\treturn `${name[0]?.toLowerCase() ?? \"\"}${name.slice(1)}`;\n\t\t\t};\n\t\t\tconst queryFields = module.views.map((view) => ` ${fieldName(view.name)}: JSON!`);\n\t\t\tconst mutations = module.actions.map((action) => ` ${fieldName(action.actionId)}(parameters: JSON!): GovernedActionSubmission!`);\n\t\t\tconst operationNames = [...module.views.map((view) => fieldName(view.name)), ...module.actions.map((action) => fieldName(action.actionId))];\n\t\t\tif (new Set(operationNames).size !== operationNames.length) throw new Error(`Module \"${module.namespace}\" produces colliding GraphQL operation names.`);\n\t\t\tconst content = [\n\t\t\t\t`# Generated by ${graphqlGenerator.name}@${graphqlGenerator.version}`,\n\t\t\t\t`# Manifest digest: ${ir.manifestDigest}`,\n\t\t\t\t\"scalar JSON\",\n\t\t\t\t\"type GovernedActionSubmission { actionInvocationId: ID!, status: String! }\",\n\t\t\t\t...types,\n\t\t\t\t`type Query {\\n${queryFields.length ? queryFields.join(\"\\n\") : \" _fabric: Boolean!\"}\\n}`,\n\t\t\t\t`type Mutation {\\n${mutations.length ? mutations.join(\"\\n\") : \" _fabric: Boolean!\"}\\n}`,\n\t\t\t\t\"\",\n\t\t\t].join(\"\\n\\n\");\n\t\t\tconst resolvers = [\n\t\t\t\t\"// Generated resolver seam. Authenticate first; derive actor and tenant server-side.\",\n\t\t\t\t`export const actionIds = ${JSON.stringify(Object.fromEntries(module.actions.map((action) => [fieldName(action.actionId), action.actionId])), null, 2)} as const;`,\n\t\t\t\t\"// Each mutation resolver must call createGovernedActionHost().submitAction(); never call handlers directly.\",\n\t\t\t\t\"\",\n\t\t\t].join(\"\\n\");\n\t\t\treturn [{ path: `${module.namespace}/schema.graphql`, content }, { path: `${module.namespace}/resolver-contract.ts`, content: resolvers }];\n\t\t});\n\t},\n};\n"],"mappings":";AAGA,IAAM,SAAS,CAAC,UACf,MAAM,MAAM,QAAQ,EAAE,OAAO,OAAO,EAAE,IAAI,CAAC,SAAS,KAAK,CAAC,GAAG,YAAY,IAAI,KAAK,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE;AACpG,IAAM,MAAM,CAAC,WAAuC;AACnD,QAAM,OAAO,MAAM,QAAQ,OAAO,IAAI,IAAI,OAAO,KAAK,CAAC,IAAI,OAAO;AAClE,SAAO,SAAS,YAAY,QAAQ,SAAS,WAAW,UAAU,SAAS,YAAY,YAAY,SAAS,WAAW,WAAW;AACnI;AACA,IAAM,aAAa,CAAC,UAA0B;AAC7C,QAAM,aAAa,MAAM,QAAQ,kBAAkB,GAAG;AACtD,SAAO,aAAa,KAAK,UAAU,IAAI,aAAa,SAAS,UAAU;AACxE;AAEO,IAAM,mBAAoC;AAAA,EAChD,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS,IAAI;AACZ,WAAO,GAAG,QAAQ,QAAQ,CAAC,WAAW;AACrC,YAAM,QAAQ,OAAO,YAAY,IAAI,CAAC,eAAe;AACpD,cAAM,WAAW,IAAI,IAAI,WAAW,QAAQ,YAAY,CAAC,CAAC;AAC1D,cAAM,SAAS,OAAO,QAAQ,WAAW,QAAQ,cAAc,CAAC,CAAC,EAAE;AAAA,UAClE,CAAC,CAAC,MAAM,MAAM,MAAM,KAAK,WAAW,IAAI,CAAC,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Y,OAAO,QAAQ,IAAI,CAAC,WAAW,CAAC,UAAU,OAAO,QAAQ,GAAG,OAAO,QAAQ,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;AAAA,QACtJ;AAAA,QACA;AAAA,MACD,EAAE,KAAK,IAAI;AACX,aAAO,CAAC,EAAE,MAAM,GAAG,OAAO,SAAS,mBAAmB,QAAQ,GAAG,EAAE,MAAM,GAAG,OAAO,SAAS,yBAAyB,SAAS,UAAU,CAAC;AAAA,IAC1I,CAAC;AAAA,EACF;AACD;","names":[]}
1
+ {"version":3,"sources":["../index.ts"],"sourcesContent":["import type { GeneratorTarget } from \"@fabricorg/compiler\";\nimport type { PortableJsonSchema } from \"@fabricorg/platform\";\n\nconst pascal = (value: string): string =>\n\tvalue.split(/[-._/]/).filter(Boolean).map((part) => part[0]?.toUpperCase() + part.slice(1)).join(\"\");\nconst gql = (schema: PortableJsonSchema): string => {\n\tconst type = Array.isArray(schema.type) ? schema.type[0] : schema.type;\n\treturn type === \"integer\" ? \"Int\" : type === \"number\" ? \"Float\" : type === \"boolean\" ? \"Boolean\" : type === \"string\" ? \"String\" : \"JSON\";\n};\nconst identifier = (value: string): string => {\n\tconst normalized = value.replace(/[^_0-9A-Za-z]/g, \"_\");\n\treturn /^[_A-Za-z]/.test(normalized) ? normalized : `field_${normalized}`;\n};\n\nexport const graphqlGenerator: GeneratorTarget = {\n\tname: \"@fabricorg/gen-graphql\",\n\tversion: \"1.0.0\",\n\tgenerate(ir) {\n\t\treturn ir.modules.flatMap((module) => {\n\t\t\tconst types = module.objectTypes.map((objectType) => {\n\t\t\t\tconst required = new Set(objectType.schema?.required ?? []);\n\t\t\t\tconst properties = Object.entries(objectType.schema?.properties ?? {}).filter(([name]) => ![\"id\", \"tenantId\", \"spaceId\"].includes(name));\n\t\t\t\tconst fieldNames = properties.map(([name]) => identifier(name));\n\t\t\t\tif (new Set(fieldNames).size !== fieldNames.length) throw new Error(`Object \"${module.namespace}.${objectType.type}\" produces colliding GraphQL field names.`);\n\t\t\t\tconst fields = properties.map(\n\t\t\t\t\t([name, schema]) => ` ${identifier(name)}: ${gql(schema)}${required.has(name) ? \"!\" : \"\"}`,\n\t\t\t\t);\n\t\t\t\treturn [`type ${pascal(module.namespace)}${objectType.type} @key(fields: \"id\") {`, \" id: ID!\", \" tenantId: ID!\", \" spaceId: ID!\", ...fields, \"}\"].join(\"\\n\");\n\t\t\t});\n\t\t\tconst fieldName = (value: string): string => {\n\t\t\t\tconst name = pascal(value);\n\t\t\t\treturn `${name[0]?.toLowerCase() ?? \"\"}${name.slice(1)}`;\n\t\t\t};\n\t\t\tconst queryFields = module.views.map((view) => ` ${fieldName(view.name)}: JSON!`);\n\t\t\tconst mutations = module.actions.map((action) => ` ${fieldName(action.actionId)}(parameters: JSON!): GovernedActionSubmission!`);\n\t\t\tconst operationNames = [...module.views.map((view) => fieldName(view.name)), ...module.actions.map((action) => fieldName(action.actionId))];\n\t\t\tif (new Set(operationNames).size !== operationNames.length) throw new Error(`Module \"${module.namespace}\" produces colliding GraphQL operation names.`);\n\t\t\tconst content = [\n\t\t\t\t`# Generated by ${graphqlGenerator.name}@${graphqlGenerator.version}`,\n\t\t\t\t`# Manifest digest: ${ir.manifestDigest}`,\n\t\t\t\t\"scalar JSON\",\n\t\t\t\t\"type GovernedActionSubmission { actionInvocationId: ID!, status: String! }\",\n\t\t\t\t...types,\n\t\t\t\t`type Query {\\n${queryFields.length ? queryFields.join(\"\\n\") : \" _fabric: Boolean!\"}\\n}`,\n\t\t\t\t`type Mutation {\\n${mutations.length ? mutations.join(\"\\n\") : \" _fabric: Boolean!\"}\\n}`,\n\t\t\t\t\"\",\n\t\t\t].join(\"\\n\\n\");\n\t\t\tconst resolvers = [\n\t\t\t\t\"// Generated resolver seam. Authenticate first; derive actor and tenant server-side.\",\n\t\t\t\t`export const actionIds = ${JSON.stringify(Object.fromEntries(module.actions.map((action) => [fieldName(action.actionId), action.actionId])), null, 2)} as const;`,\n\t\t\t\t\"// Each mutation resolver must call createGovernedActionHost().submitAction(); never call handlers directly.\",\n\t\t\t\t\"\",\n\t\t\t].join(\"\\n\");\n\t\t\treturn [{ path: `${module.namespace}/schema.graphql`, content }, { path: `${module.namespace}/resolver-contract.ts`, content: resolvers }];\n\t\t});\n\t},\n};\n"],"mappings":";AAGA,IAAM,SAAS,CAAC,UACf,MAAM,MAAM,QAAQ,EAAE,OAAO,OAAO,EAAE,IAAI,CAAC,SAAS,KAAK,CAAC,GAAG,YAAY,IAAI,KAAK,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE;AACpG,IAAM,MAAM,CAAC,WAAuC;AACnD,QAAM,OAAO,MAAM,QAAQ,OAAO,IAAI,IAAI,OAAO,KAAK,CAAC,IAAI,OAAO;AAClE,SAAO,SAAS,YAAY,QAAQ,SAAS,WAAW,UAAU,SAAS,YAAY,YAAY,SAAS,WAAW,WAAW;AACnI;AACA,IAAM,aAAa,CAAC,UAA0B;AAC7C,QAAM,aAAa,MAAM,QAAQ,kBAAkB,GAAG;AACtD,SAAO,aAAa,KAAK,UAAU,IAAI,aAAa,SAAS,UAAU;AACxE;AAEO,IAAM,mBAAoC;AAAA,EAChD,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS,IAAI;AACZ,WAAO,GAAG,QAAQ,QAAQ,CAAC,WAAW;AACrC,YAAM,QAAQ,OAAO,YAAY,IAAI,CAAC,eAAe;AACpD,cAAM,WAAW,IAAI,IAAI,WAAW,QAAQ,YAAY,CAAC,CAAC;AAC1D,cAAM,aAAa,OAAO,QAAQ,WAAW,QAAQ,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,MAAM,YAAY,SAAS,EAAE,SAAS,IAAI,CAAC;AACvI,cAAM,aAAa,WAAW,IAAI,CAAC,CAAC,IAAI,MAAM,WAAW,IAAI,CAAC;AAC9D,YAAI,IAAI,IAAI,UAAU,EAAE,SAAS,WAAW,OAAQ,OAAM,IAAI,MAAM,WAAW,OAAO,S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AAqB;AAAA;AAAA,QACnF;AAAA,MACD,EAAE,KAAK,MAAM;AACb,YAAM,YAAY;AAAA,QACjB;AAAA,QACA,4BAA4B,KAAK,UAAU,OAAO,YAAY,OAAO,QAAQ,IAAI,CAAC,WAAW,CAAC,UAAU,OAAO,QAAQ,GAAG,OAAO,QAAQ,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;AAAA,QACtJ;AAAA,QACA;AAAA,MACD,EAAE,KAAK,IAAI;AACX,aAAO,CAAC,EAAE,MAAM,GAAG,OAAO,SAAS,mBAAmB,QAAQ,GAAG,EAAE,MAAM,GAAG,OAAO,SAAS,yBAAyB,SAAS,UAAU,CAAC;AAAA,IAC1I,CAAC;AAAA,EACF;AACD;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabricorg/gen-graphql",
3
- "version": "0.2.0",
3
+ "version": "1.0.0",
4
4
  "description": "Federation-ready GraphQL contract generator for Fabric compiler IR.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -25,14 +25,17 @@
25
25
  "CHANGELOG.md"
26
26
  ],
27
27
  "dependencies": {
28
- "@fabricorg/compiler": "^0.2.0",
29
- "@fabricorg/platform": "^0.11.0"
28
+ "@fabricorg/compiler": "^1.0.0"
29
+ },
30
+ "peerDependencies": {
31
+ "@fabricorg/platform": "^0.12.0"
30
32
  },
31
33
  "devDependencies": {
32
34
  "@types/node": "^22.10.0",
33
35
  "tsup": "^8.5.0",
34
36
  "typescript": "^5.7.3",
35
- "vitest": "^4.1.5"
37
+ "vitest": "^4.1.5",
38
+ "@fabricorg/platform": "^0.12.0"
36
39
  },
37
40
  "engines": {
38
41
  "node": ">=20"