@fabricorg/gen-prisma 2.0.4 → 2.0.6

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,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - eac74a9: Republish packages that depend on `@fabricorg/platform` or `@fabricorg/platform-host` through workspace ranges, directly or through other republished packages, so their packed dependency minimums include the adapter circuit-breaker release. Runtime source is unchanged.
8
+ - e0f7ca7: Republish packages that depend on `@fabricorg/platform` or `@fabricorg/platform-host` through workspace ranges, directly or through other republished packages, so their packed dependency minimums include the evidence packet generator release. Runtime source is unchanged.
9
+ - Updated dependencies [eac74a9]
10
+ - Updated dependencies [e0f7ca7]
11
+ - @fabricorg/compiler@2.2.6
12
+
13
+ ## 2.0.5
14
+
15
+ ### Patch Changes
16
+
17
+ - 8c7d2a1: Republish packages that depend on `@fabricorg/platform` or `@fabricorg/platform-host` directly or through other republished packages via workspace ranges, so their packed dependency minimums include the invocation-aware policy resolution release. Runtime source is unchanged.
18
+ - Updated dependencies [8c7d2a1]
19
+ - @fabricorg/compiler@2.2.5
20
+
3
21
  ## 2.0.4
4
22
 
5
23
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -39,7 +39,7 @@ var identifier = (value) => {
39
39
  };
40
40
  var prismaGenerator = {
41
41
  name: "@fabricorg/gen-prisma",
42
- version: "2.0.4",
42
+ version: "2.0.6",
43
43
  generate(ir) {
44
44
  const modelNames = ir.modules.flatMap((module2) => module2.objectTypes.map((objectType) => `${pascal(module2.namespace)}${objectType.type}`));
45
45
  if (new Set(modelNames).size !== modelNames.length) throw new Error("Manifest produces colliding Prisma model names across modules.");
@@ -1 +1 @@
1
- {"version":3,"sources":["../index.ts"],"sourcesContent":["import type { GeneratorTarget } from \"@fabricorg/compiler\";\nimport type { PortableJsonSchema } from \"@fabricorg/platform\";\n\nconst scalar = (schema: PortableJsonSchema): string => {\n\tconst type = Array.isArray(schema.type) ? schema.type.find((item) => item !== \"null\") : schema.type;\n\tif (type === \"string\") return \"String\";\n\tif (type === \"integer\") return \"Int\";\n\tif (type === \"number\") return \"Float\";\n\tif (type === \"boolean\") return \"Boolean\";\n\tif (type === \"array\" || type === \"object\") return \"Json\";\n\treturn \"Json\";\n};\nconst pascal = (value: string): string => value.split(/[-._/]/).filter(Boolean).map((part) => part[0]?.toUpperCase() + part.slice(1)).join(\"\");\nconst identifier = (value: string): string => {\n\tconst normalized = value.replace(/[^a-zA-Z0-9_]/g, \"_\");\n\treturn /^[a-zA-Z]/.test(normalized) ? normalized : `field_${normalized}`;\n};\n\nexport const prismaGenerator: GeneratorTarget = {\n\tname: \"@fabricorg/gen-prisma\", version: \"2.0.4\",\n\tgenerate(ir) {\n\t\tconst modelNames = ir.modules.flatMap((module) => module.objectTypes.map((objectType) => `${pascal(module.namespace)}${objectType.type}`));\n\t\tif (new Set(modelNames).size !== modelNames.length) throw new Error(\"Manifest produces colliding Prisma model names across modules.\");\n\t\tconst models = ir.modules.flatMap((module) => module.objectTypes.map((objectType) => {\n\t\t\tconst required = new Set(objectType.schema?.required ?? []);\n\t\t\tconst properties = Object.entries(objectType.schema?.properties ?? {}).filter(([name]) => ![\"id\", \"tenantId\", \"spaceId\"].includes(name));\n\t\t\tconst identifiers = properties.map(([name]) => identifier(name));\n\t\t\tconst relationIdentifiers = (objectType.relations ?? []).map((relation) => `${relation.name}Ids`);\n\t\t\tif (new Set([...identifiers, ...relationIdentifiers]).size !== identifiers.length + relationIdentifiers.length) throw new Error(`Object \"${module.namespace}.${objectType.type}\" produces colliding Prisma field names.`);\n\t\t\tconst fields = properties.map(([name, schema]) => ` ${identifier(name)} ${scalar(schema)}${required.has(name) ? \"\" : \"?\"}${identifier(name) === name ? \"\" : ` @map(${JSON.stringify(name)})`}`);\n\t\t\tconst relations = (objectType.relations ?? []).map((relation) => ` ${relation.name}Ids String${relation.cardinality === \"many\" ? \"[]\" : relation.required ? \"\" : \"?\"} // ${relation.semantics} -> ${relation.target}`);\n\t\t\treturn [`model ${pascal(module.namespace)}${objectType.type} {`, \" id String @id\", \" tenantId String\", \" spaceId String\", ...fields, ...relations, \"\", \" @@index([tenantId, spaceId])\", ` @@map(\"${module.namespace}_${objectType.type}\")`, \"}\"].join(\"\\n\");\n\t\t}));\n\t\tconst content = [`// Generated by ${prismaGenerator.name}@${prismaGenerator.version}`, `// Manifest digest: ${ir.manifestDigest}`, \"generator client {\\n provider = \\\"prisma-client-js\\\"\\n}\", \"datasource db {\\n provider = \\\"postgresql\\\"\\n url = env(\\\"DATABASE_URL\\\")\\n}\", \"\", ...models, \"\"].join(\"\\n\\n\");\n\t\treturn [{ path: \"prisma/schema.prisma\", content }, { path: \"prisma/compatibility.json\", content: JSON.stringify({ manifestDigest: ir.manifestDigest, automaticMigration: false, reviewRequired: true }, null, 2) }];\n\t},\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,IAAM,SAAS,CAAC,WAAuC;AACtD,QAAM,OAAO,MAAM,QAAQ,OAAO,IAAI,IAAI,OAAO,KAAK,KAAK,CAAC,SAAS,SAAS,MAAM,IAAI,OAAO;AAC/F,MAAI,SAAS,SAAU,QAAO;AAC9B,MAAI,SAAS,UAAW,QAAO;AAC/B,MAAI,SAAS,SAAU,QAAO;AAC9B,MAAI,SAAS,UAAW,QAAO;AAC/B,MAAI,SAAS,WAAW,SAAS,SAAU,QAAO;AAClD,SAAO;AACR;AACA,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;AAC7I,IAAM,aAAa,CAAC,UAA0B;AAC7C,QAAM,aAAa,MAAM,QAAQ,kBAAkB,GAAG;AACtD,SAAO,YAAY,KAAK,UAAU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AG,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI,aAAa,SAAS,gBAAgB,SAAS,OAAO,SAAS,WAAW,KAAK,GAAG,OAAO,SAAS,SAAS,OAAO,SAAS,MAAM,EAAE;AACtN,aAAO,CAAC,SAAS,OAAOA,QAAO,SAAS,CAAC,GAAG,WAAW,IAAI,MAAM,mBAAmB,qBAAqB,oBAAoB,GAAG,QAAQ,GAAG,WAAW,IAAI,kCAAkC,YAAYA,QAAO,SAAS,IAAI,WAAW,IAAI,MAAM,GAAG,EAAE,KAAK,IAAI;AAAA,IAChQ,CAAC,CAAC;AACF,UAAM,UAAU,CAAC,mBAAmB,gBAAgB,IAAI,IAAI,gBAAgB,OAAO,IAAI,uBAAuB,GAAG,cAAc,IAAI,0DAA4D,mFAAuF,IAAI,GAAG,QAAQ,EAAE,EAAE,KAAK,MAAM;AACpT,WAAO,CAAC,EAAE,MAAM,wBAAwB,QAAQ,GAAG,EAAE,MAAM,6BAA6B,SAAS,KAAK,UAAU,EAAE,gBAAgB,GAAG,gBAAgB,oBAAoB,OAAO,gBAAgB,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC;AAAA,EACnN;AACD;","names":["module"]}
1
+ {"version":3,"sources":["../index.ts"],"sourcesContent":["import type { GeneratorTarget } from \"@fabricorg/compiler\";\nimport type { PortableJsonSchema } from \"@fabricorg/platform\";\n\nconst scalar = (schema: PortableJsonSchema): string => {\n\tconst type = Array.isArray(schema.type) ? schema.type.find((item) => item !== \"null\") : schema.type;\n\tif (type === \"string\") return \"String\";\n\tif (type === \"integer\") return \"Int\";\n\tif (type === \"number\") return \"Float\";\n\tif (type === \"boolean\") return \"Boolean\";\n\tif (type === \"array\" || type === \"object\") return \"Json\";\n\treturn \"Json\";\n};\nconst pascal = (value: string): string => value.split(/[-._/]/).filter(Boolean).map((part) => part[0]?.toUpperCase() + part.slice(1)).join(\"\");\nconst identifier = (value: string): string => {\n\tconst normalized = value.replace(/[^a-zA-Z0-9_]/g, \"_\");\n\treturn /^[a-zA-Z]/.test(normalized) ? normalized : `field_${normalized}`;\n};\n\nexport const prismaGenerator: GeneratorTarget = {\n\tname: \"@fabricorg/gen-prisma\", version: \"2.0.6\",\n\tgenerate(ir) {\n\t\tconst modelNames = ir.modules.flatMap((module) => module.objectTypes.map((objectType) => `${pascal(module.namespace)}${objectType.type}`));\n\t\tif (new Set(modelNames).size !== modelNames.length) throw new Error(\"Manifest produces colliding Prisma model names across modules.\");\n\t\tconst models = ir.modules.flatMap((module) => module.objectTypes.map((objectType) => {\n\t\t\tconst required = new Set(objectType.schema?.required ?? []);\n\t\t\tconst properties = Object.entries(objectType.schema?.properties ?? {}).filter(([name]) => ![\"id\", \"tenantId\", \"spaceId\"].includes(name));\n\t\t\tconst identifiers = properties.map(([name]) => identifier(name));\n\t\t\tconst relationIdentifiers = (objectType.relations ?? []).map((relation) => `${relation.name}Ids`);\n\t\t\tif (new Set([...identifiers, ...relationIdentifiers]).size !== identifiers.length + relationIdentifiers.length) throw new Error(`Object \"${module.namespace}.${objectType.type}\" produces colliding Prisma field names.`);\n\t\t\tconst fields = properties.map(([name, schema]) => ` ${identifier(name)} ${scalar(schema)}${required.has(name) ? \"\" : \"?\"}${identifier(name) === name ? \"\" : ` @map(${JSON.stringify(name)})`}`);\n\t\t\tconst relations = (objectType.relations ?? []).map((relation) => ` ${relation.name}Ids String${relation.cardinality === \"many\" ? \"[]\" : relation.required ? \"\" : \"?\"} // ${relation.semantics} -> ${relation.target}`);\n\t\t\treturn [`model ${pascal(module.namespace)}${objectType.type} {`, \" id String @id\", \" tenantId String\", \" spaceId String\", ...fields, ...relations, \"\", \" @@index([tenantId, spaceId])\", ` @@map(\"${module.namespace}_${objectType.type}\")`, \"}\"].join(\"\\n\");\n\t\t}));\n\t\tconst content = [`// Generated by ${prismaGenerator.name}@${prismaGenerator.version}`, `// Manifest digest: ${ir.manifestDigest}`, \"generator client {\\n provider = \\\"prisma-client-js\\\"\\n}\", \"datasource db {\\n provider = \\\"postgresql\\\"\\n url = env(\\\"DATABASE_URL\\\")\\n}\", \"\", ...models, \"\"].join(\"\\n\\n\");\n\t\treturn [{ path: \"prisma/schema.prisma\", content }, { path: \"prisma/compatibility.json\", content: JSON.stringify({ manifestDigest: ir.manifestDigest, automaticMigration: false, reviewRequired: true }, null, 2) }];\n\t},\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,IAAM,SAAS,CAAC,WAAuC;AACtD,QAAM,OAAO,MAAM,QAAQ,OAAO,IAAI,IAAI,OAAO,KAAK,KAAK,CAAC,SAAS,SAAS,MAAM,IAAI,OAAO;AAC/F,MAAI,SAAS,SAAU,QAAO;AAC9B,MAAI,SAAS,UAAW,QAAO;AAC/B,MAAI,SAAS,SAAU,QAAO;AAC9B,MAAI,SAAS,UAAW,QAAO;AAC/B,MAAI,SAAS,WAAW,SAAS,SAAU,QAAO;AAClD,SAAO;AACR;AACA,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;AAC7I,IAAM,aAAa,CAAC,UAA0B;AAC7C,QAAM,aAAa,MAAM,QAAQ,kBAAkB,GAAG;AACtD,SAAO,YAAY,KAAK,UAAU,IAAI,aAAa,SAAS,UAAU;AACvE;AAEO,IAAM,kBAAmC;AAAA,EAC/C,MAAM;AAAA,EAAyB,SAAS;AAAA,EACxC,SAAS,IAAI;AACZ,UAAM,aAAa,GAAG,QAAQ,QAAQ,CAACA,YAAWA,QAAO,YAAY,IAAI,CAAC,eAAe,GAAG,OAAOA,QAAO,SAAS,CAAC,GAAG,WAAW,IAAI,EAAE,CAAC;AACzI,QAAI,IAAI,IAAI,UAAU,EAAE,SAAS,WAAW,OAAQ,OAAM,IAAI,MAAM,gEAAgE;AACpI,UAAM,SAAS,GAAG,QAAQ,QAAQ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AM,UAAU,CAAC,mBAAmB,gBAAgB,IAAI,IAAI,gBAAgB,OAAO,IAAI,uBAAuB,GAAG,cAAc,IAAI,0DAA4D,mFAAuF,IAAI,GAAG,QAAQ,EAAE,EAAE,KAAK,MAAM;AACpT,WAAO,CAAC,EAAE,MAAM,wBAAwB,QAAQ,GAAG,EAAE,MAAM,6BAA6B,SAAS,KAAK,UAAU,EAAE,gBAAgB,GAAG,gBAAgB,oBAAoB,OAAO,gBAAgB,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC;AAAA,EACnN;AACD;","names":["module"]}
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ var identifier = (value) => {
15
15
  };
16
16
  var prismaGenerator = {
17
17
  name: "@fabricorg/gen-prisma",
18
- version: "2.0.4",
18
+ version: "2.0.6",
19
19
  generate(ir) {
20
20
  const modelNames = ir.modules.flatMap((module) => module.objectTypes.map((objectType) => `${pascal(module.namespace)}${objectType.type}`));
21
21
  if (new Set(modelNames).size !== modelNames.length) throw new Error("Manifest produces colliding Prisma model names across modules.");
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 scalar = (schema: PortableJsonSchema): string => {\n\tconst type = Array.isArray(schema.type) ? schema.type.find((item) => item !== \"null\") : schema.type;\n\tif (type === \"string\") return \"String\";\n\tif (type === \"integer\") return \"Int\";\n\tif (type === \"number\") return \"Float\";\n\tif (type === \"boolean\") return \"Boolean\";\n\tif (type === \"array\" || type === \"object\") return \"Json\";\n\treturn \"Json\";\n};\nconst pascal = (value: string): string => value.split(/[-._/]/).filter(Boolean).map((part) => part[0]?.toUpperCase() + part.slice(1)).join(\"\");\nconst identifier = (value: string): string => {\n\tconst normalized = value.replace(/[^a-zA-Z0-9_]/g, \"_\");\n\treturn /^[a-zA-Z]/.test(normalized) ? normalized : `field_${normalized}`;\n};\n\nexport const prismaGenerator: GeneratorTarget = {\n\tname: \"@fabricorg/gen-prisma\", version: \"2.0.4\",\n\tgenerate(ir) {\n\t\tconst modelNames = ir.modules.flatMap((module) => module.objectTypes.map((objectType) => `${pascal(module.namespace)}${objectType.type}`));\n\t\tif (new Set(modelNames).size !== modelNames.length) throw new Error(\"Manifest produces colliding Prisma model names across modules.\");\n\t\tconst models = ir.modules.flatMap((module) => module.objectTypes.map((objectType) => {\n\t\t\tconst required = new Set(objectType.schema?.required ?? []);\n\t\t\tconst properties = Object.entries(objectType.schema?.properties ?? {}).filter(([name]) => ![\"id\", \"tenantId\", \"spaceId\"].includes(name));\n\t\t\tconst identifiers = properties.map(([name]) => identifier(name));\n\t\t\tconst relationIdentifiers = (objectType.relations ?? []).map((relation) => `${relation.name}Ids`);\n\t\t\tif (new Set([...identifiers, ...relationIdentifiers]).size !== identifiers.length + relationIdentifiers.length) throw new Error(`Object \"${module.namespace}.${objectType.type}\" produces colliding Prisma field names.`);\n\t\t\tconst fields = properties.map(([name, schema]) => ` ${identifier(name)} ${scalar(schema)}${required.has(name) ? \"\" : \"?\"}${identifier(name) === name ? \"\" : ` @map(${JSON.stringify(name)})`}`);\n\t\t\tconst relations = (objectType.relations ?? []).map((relation) => ` ${relation.name}Ids String${relation.cardinality === \"many\" ? \"[]\" : relation.required ? \"\" : \"?\"} // ${relation.semantics} -> ${relation.target}`);\n\t\t\treturn [`model ${pascal(module.namespace)}${objectType.type} {`, \" id String @id\", \" tenantId String\", \" spaceId String\", ...fields, ...relations, \"\", \" @@index([tenantId, spaceId])\", ` @@map(\"${module.namespace}_${objectType.type}\")`, \"}\"].join(\"\\n\");\n\t\t}));\n\t\tconst content = [`// Generated by ${prismaGenerator.name}@${prismaGenerator.version}`, `// Manifest digest: ${ir.manifestDigest}`, \"generator client {\\n provider = \\\"prisma-client-js\\\"\\n}\", \"datasource db {\\n provider = \\\"postgresql\\\"\\n url = env(\\\"DATABASE_URL\\\")\\n}\", \"\", ...models, \"\"].join(\"\\n\\n\");\n\t\treturn [{ path: \"prisma/schema.prisma\", content }, { path: \"prisma/compatibility.json\", content: JSON.stringify({ manifestDigest: ir.manifestDigest, automaticMigration: false, reviewRequired: true }, null, 2) }];\n\t},\n};\n"],"mappings":";AAGA,IAAM,SAAS,CAAC,WAAuC;AACtD,QAAM,OAAO,MAAM,QAAQ,OAAO,IAAI,IAAI,OAAO,KAAK,KAAK,CAAC,SAAS,SAAS,MAAM,IAAI,OAAO;AAC/F,MAAI,SAAS,SAAU,QAAO;AAC9B,MAAI,SAAS,UAAW,QAAO;AAC/B,MAAI,SAAS,SAAU,QAAO;AAC9B,MAAI,SAAS,UAAW,QAAO;AAC/B,MAAI,SAAS,WAAW,SAAS,SAAU,QAAO;AAClD,SAAO;AACR;AACA,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;AAC7I,IAAM,aAAa,CAAC,UAA0B;AAC7C,QAAM,aAAa,MAAM,QAAQ,kBAAkB,GAAG;AACtD,SAAO,YAAY,KAAK,UAAU,IAAI,aAAa,SAAS,UAAU;AACvE;AAEO,IAAM,kBAAmC;AAAA,EAC/C,MAAM;AAAA,EAAyB,SAAS;AAAA,EACxC,SAAS,IAAI;AACZ,UAAM,aAAa,GAAG,QAAQ,QAAQ,CAAC,WAAW,OAAO,YAAY,IAAI,CAAC,eAAe,GAAG,OAAO,OAAO,SAAS,CAAC,GAAG,WAAW,IAAI,EAAE,CAAC;AACzI,QAAI,IAAI,IAAI,UAAU,EAAE,SAAS,WAAW,OAAQ,OAAM,IAAI,MAAM,gEAAgE;AACpI,UAAM,SAAS,GAAG,QAAQ,QAAQ,CAAC,WAAW,OAAO,YAAY,IAAI,CAAC,eAAe;AACpF,YAAM,WAAW,IAAI,IAAI,WAAW,QAAQ,YAAY,CAAC,CAAC;AA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I,GAAG,QAAQ,EAAE,EAAE,KAAK,MAAM;AACpT,WAAO,CAAC,EAAE,MAAM,wBAAwB,QAAQ,GAAG,EAAE,MAAM,6BAA6B,SAAS,KAAK,UAAU,EAAE,gBAAgB,GAAG,gBAAgB,oBAAoB,OAAO,gBAAgB,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC;AAAA,EACnN;AACD;","names":[]}
1
+ {"version":3,"sources":["../index.ts"],"sourcesContent":["import type { GeneratorTarget } from \"@fabricorg/compiler\";\nimport type { PortableJsonSchema } from \"@fabricorg/platform\";\n\nconst scalar = (schema: PortableJsonSchema): string => {\n\tconst type = Array.isArray(schema.type) ? schema.type.find((item) => item !== \"null\") : schema.type;\n\tif (type === \"string\") return \"String\";\n\tif (type === \"integer\") return \"Int\";\n\tif (type === \"number\") return \"Float\";\n\tif (type === \"boolean\") return \"Boolean\";\n\tif (type === \"array\" || type === \"object\") return \"Json\";\n\treturn \"Json\";\n};\nconst pascal = (value: string): string => value.split(/[-._/]/).filter(Boolean).map((part) => part[0]?.toUpperCase() + part.slice(1)).join(\"\");\nconst identifier = (value: string): string => {\n\tconst normalized = value.replace(/[^a-zA-Z0-9_]/g, \"_\");\n\treturn /^[a-zA-Z]/.test(normalized) ? normalized : `field_${normalized}`;\n};\n\nexport const prismaGenerator: GeneratorTarget = {\n\tname: \"@fabricorg/gen-prisma\", version: \"2.0.6\",\n\tgenerate(ir) {\n\t\tconst modelNames = ir.modules.flatMap((module) => module.objectTypes.map((objectType) => `${pascal(module.namespace)}${objectType.type}`));\n\t\tif (new Set(modelNames).size !== modelNames.length) throw new Error(\"Manifest produces colliding Prisma model names across modules.\");\n\t\tconst models = ir.modules.flatMap((module) => module.objectTypes.map((objectType) => {\n\t\t\tconst required = new Set(objectType.schema?.required ?? []);\n\t\t\tconst properties = Object.entries(objectType.schema?.properties ?? {}).filter(([name]) => ![\"id\", \"tenantId\", \"spaceId\"].includes(name));\n\t\t\tconst identifiers = properties.map(([name]) => identifier(name));\n\t\t\tconst relationIdentifiers = (objectType.relations ?? []).map((relation) => `${relation.name}Ids`);\n\t\t\tif (new Set([...identifiers, ...relationIdentifiers]).size !== identifiers.length + relationIdentifiers.length) throw new Error(`Object \"${module.namespace}.${objectType.type}\" produces colliding Prisma field names.`);\n\t\t\tconst fields = properties.map(([name, schema]) => ` ${identifier(name)} ${scalar(schema)}${required.has(name) ? \"\" : \"?\"}${identifier(name) === name ? \"\" : ` @map(${JSON.stringify(name)})`}`);\n\t\t\tconst relations = (objectType.relations ?? []).map((relation) => ` ${relation.name}Ids String${relation.cardinality === \"many\" ? \"[]\" : relation.required ? \"\" : \"?\"} // ${relation.semantics} -> ${relation.target}`);\n\t\t\treturn [`model ${pascal(module.namespace)}${objectType.type} {`, \" id String @id\", \" tenantId String\", \" spaceId String\", ...fields, ...relations, \"\", \" @@index([tenantId, spaceId])\", ` @@map(\"${module.namespace}_${objectType.type}\")`, \"}\"].join(\"\\n\");\n\t\t}));\n\t\tconst content = [`// Generated by ${prismaGenerator.name}@${prismaGenerator.version}`, `// Manifest digest: ${ir.manifestDigest}`, \"generator client {\\n provider = \\\"prisma-client-js\\\"\\n}\", \"datasource db {\\n provider = \\\"postgresql\\\"\\n url = env(\\\"DATABASE_URL\\\")\\n}\", \"\", ...models, \"\"].join(\"\\n\\n\");\n\t\treturn [{ path: \"prisma/schema.prisma\", content }, { path: \"prisma/compatibility.json\", content: JSON.stringify({ manifestDigest: ir.manifestDigest, automaticMigration: false, reviewRequired: true }, null, 2) }];\n\t},\n};\n"],"mappings":";AAGA,IAAM,SAAS,CAAC,WAAuC;AACtD,QAAM,OAAO,MAAM,QAAQ,OAAO,IAAI,IAAI,OAAO,KAAK,KAAK,CAAC,SAAS,SAAS,MAAM,IAAI,OAAO;AAC/F,MAAI,SAAS,SAAU,QAAO;AAC9B,MAAI,SAAS,UAAW,QAAO;AAC/B,MAAI,SAAS,SAAU,QAAO;AAC9B,MAAI,SAAS,UAAW,QAAO;AAC/B,MAAI,SAAS,W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OAAO,SAAS,IAAI,WAAW,IAAI,0CAA0C;AACxN,YAAM,SAAS,WAAW,IAAI,CAAC,CAAC,MAAM,MAAM,MAAM,KAAK,WAAW,IAAI,CAAC,IAAI,OAAO,MAAM,CAAC,GAAG,SAAS,IAAI,IAAI,IAAI,KAAK,GAAG,GAAG,WAAW,IAAI,MAAM,OAAO,KAAK,SAAS,KAAK,UAAU,IAAI,CAAC,GAAG,EAAE;AAC/L,YAAM,aAAa,WAAW,aAAa,CAAC,GAAG,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI,aAAa,SAAS,gBAAgB,SAAS,OAAO,SAAS,WAAW,KAAK,GAAG,OAAO,SAAS,SAAS,OAAO,SAAS,MAAM,EAAE;AACtN,aAAO,CAAC,SAAS,OAAO,OAAO,SAAS,CAAC,GAAG,WAAW,IAAI,MAAM,mBAAmB,qBAAqB,oBAAoB,GAAG,QAAQ,GAAG,WAAW,IAAI,kCAAkC,YAAY,OAAO,SAAS,IAAI,WAAW,IAAI,MAAM,GAAG,EAAE,KAAK,IAAI;AAAA,IAChQ,CAAC,CAAC;AACF,UAAM,UAAU,CAAC,mBAAmB,gBAAgB,IAAI,IAAI,gBAAgB,OAAO,IAAI,uBAAuB,GAAG,cAAc,IAAI,0DAA4D,mFAAuF,IAAI,GAAG,QAAQ,EAAE,EAAE,KAAK,MAAM;AACpT,WAAO,CAAC,EAAE,MAAM,wBAAwB,QAAQ,GAAG,EAAE,MAAM,6BAA6B,SAAS,KAAK,UAAU,EAAE,gBAAgB,GAAG,gBAAgB,oBAAoB,OAAO,gBAAgB,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC;AAAA,EACnN;AACD;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabricorg/gen-prisma",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": "Reference Prisma schema generator for Fabric compiler IR.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -32,17 +32,17 @@
32
32
  "CHANGELOG.md"
33
33
  ],
34
34
  "dependencies": {
35
- "@fabricorg/compiler": "^2.2.4"
35
+ "@fabricorg/compiler": "^2.2.6"
36
36
  },
37
37
  "peerDependencies": {
38
- "@fabricorg/platform": "^1.6.0"
38
+ "@fabricorg/platform": "^1.8.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/node": "^22.10.0",
42
42
  "tsup": "^8.5.0",
43
43
  "typescript": "^5.7.3",
44
44
  "vitest": "^4.1.5",
45
- "@fabricorg/platform": "^1.6.0"
45
+ "@fabricorg/platform": "^1.8.0"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=20"