gemi 0.153.0 → 0.155.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.
@@ -1 +1 @@
1
- {"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../../bin/orm/emit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAErD,OAAO,EAKL,KAAK,WAAW,EAGjB,MAAM,kBAAkB,CAAC;AAU1B,eAAO,MAAM,eAAe,iDAAkD,CAAC;AAC/E,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAiD7D,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAwXD,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAA;CAAE,EAAE,CAAC,EACnE,QAAQ,GAAE,MAAM,EAAO,GACtB,WAAW,CAmCb;AA+BD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE,EAC7B,QAAQ,GAAE,MAAM,EAAO,GACtB,WAAW,EAAE,CAmBf;AAUD,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CA2B7D;AA2CD,6CAA6C;AAC7C,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;AAonBxD,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,EAAE,EACtB,KAAK,GAAE,OAAY,GAClB,MAAM,CA8ER;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAwB5D;AA+BD;;;;;;;;;;;;;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FR;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAwB5D;AA+BD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE,EAC7B,KAAK,GAAE,SAAS,IAAI,CAAC,aAAa,EAAO,EACzC,QAAQ,GAAE,MAAM,EAAO,GACtB,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAO/B"}
@@ -1666,7 +1666,7 @@ ${fields.join(`
1666
1666
  }
1667
1667
  function createType(schema, enums) {
1668
1668
  const relationBacked = relationBackedColumns(schema);
1669
- const fields = Object.values(schema.fields).map((field) => ` ${propertyName(field.name)}` + `${optionalOnCreate(field, relationBacked) ? "?" : ""}: ` + `${fieldTs(field, enums, "write")};`);
1669
+ const fields = Object.values(schema.fields).map((field) => ` ${propertyName(field.name)}` + `${optionalOnCreate(field, relationBacked) ? "?" : ""}: ` + `${isTypedJson(field) ? jsonInputTs(schema, field) : fieldTs(field, enums, "write")};`);
1670
1670
  return `
1671
1671
  export type ${schema.name}CreateScalars = {
1672
1672
  ${fields.join(`
@@ -1722,15 +1722,28 @@ export type ${schema.name}Unique = ${union};
1722
1722
  `;
1723
1723
  }
1724
1724
  function typesInterface(schema) {
1725
+ const json = Object.values(schema.fields).filter(isTypedJson).map((field) => ` ${propertyName(field.name)}: JsonColumnTypes<` + `${JSON.stringify(schema.name)}, ${JSON.stringify(field.name)}, ${field.nullable}>;`);
1726
+ const jsonMember = json.length > 0 ? `
1727
+ json: {
1728
+ ${json.join(`
1729
+ `)}
1730
+ };` : "";
1725
1731
  return `
1726
1732
  export interface ${schema.name}Types extends ModelTypeInfo {
1733
+ name: ${JSON.stringify(schema.name)};
1727
1734
  scalars: ${schema.name}Scalars;
1728
1735
  relations: ${schema.name}Relations;
1729
1736
  unique: ${schema.name}Unique;
1730
- create: ${schema.name}CreateScalars;
1737
+ create: ${schema.name}CreateScalars;${jsonMember}
1731
1738
  }
1732
1739
  `;
1733
1740
  }
1741
+ function isTypedJson(field) {
1742
+ return field.type === "Json" && !field.isList;
1743
+ }
1744
+ function jsonInputTs(schema, field) {
1745
+ return `JsonColumnInput<${JSON.stringify(schema.name)}, ${JSON.stringify(field.name)}, ${field.nullable}>`;
1746
+ }
1734
1747
  var READ_OPERATIONS = [
1735
1748
  {
1736
1749
  name: "findMany",
@@ -1925,12 +1938,17 @@ var RUNTIME_IMPORTS = [
1925
1938
  function usesJson(schemas) {
1926
1939
  return schemas.some((schema) => Object.values(schema.fields).some((field) => field.type === "Json"));
1927
1940
  }
1941
+ function usesJsonList(schemas) {
1942
+ return schemas.some((schema) => Object.values(schema.fields).some((field) => field.type === "Json" && field.isList));
1943
+ }
1928
1944
  function emitModelsFile(schemas, enums = {}) {
1929
1945
  if (schemas.length === 0)
1930
1946
  return HEADER;
1931
1947
  const imports = [...RUNTIME_IMPORTS];
1932
1948
  if (usesJson(schemas)) {
1933
- imports.push("type JsonInput", "type JsonValue");
1949
+ imports.push("type JsonColumnInput", "type JsonColumnTypes", "type JsonValue");
1950
+ if (usesJsonList(schemas))
1951
+ imports.push("type JsonInput");
1934
1952
  }
1935
1953
  imports.sort((a, b) => {
1936
1954
  const aType = a.startsWith("type ");
@@ -2078,5 +2096,5 @@ import_generator_helper.generatorHandler({
2078
2096
  }
2079
2097
  });
2080
2098
 
2081
- //# debugId=049E59ABB41E57F464756E2164756E21
2099
+ //# debugId=A00BE29DEB09066A64756E2164756E21
2082
2100
  //# sourceMappingURL=orm-generator.js.map