gemi 0.153.0 → 0.154.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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R;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,27 @@ 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 {
1727
1733
  scalars: ${schema.name}Scalars;
1728
1734
  relations: ${schema.name}Relations;
1729
1735
  unique: ${schema.name}Unique;
1730
- create: ${schema.name}CreateScalars;
1736
+ create: ${schema.name}CreateScalars;${jsonMember}
1731
1737
  }
1732
1738
  `;
1733
1739
  }
1740
+ function isTypedJson(field) {
1741
+ return field.type === "Json" && !field.isList;
1742
+ }
1743
+ function jsonInputTs(schema, field) {
1744
+ return `JsonColumnInput<${JSON.stringify(schema.name)}, ${JSON.stringify(field.name)}, ${field.nullable}>`;
1745
+ }
1734
1746
  var READ_OPERATIONS = [
1735
1747
  {
1736
1748
  name: "findMany",
@@ -1925,12 +1937,17 @@ var RUNTIME_IMPORTS = [
1925
1937
  function usesJson(schemas) {
1926
1938
  return schemas.some((schema) => Object.values(schema.fields).some((field) => field.type === "Json"));
1927
1939
  }
1940
+ function usesJsonList(schemas) {
1941
+ return schemas.some((schema) => Object.values(schema.fields).some((field) => field.type === "Json" && field.isList));
1942
+ }
1928
1943
  function emitModelsFile(schemas, enums = {}) {
1929
1944
  if (schemas.length === 0)
1930
1945
  return HEADER;
1931
1946
  const imports = [...RUNTIME_IMPORTS];
1932
1947
  if (usesJson(schemas)) {
1933
- imports.push("type JsonInput", "type JsonValue");
1948
+ imports.push("type JsonColumnInput", "type JsonColumnTypes", "type JsonValue");
1949
+ if (usesJsonList(schemas))
1950
+ imports.push("type JsonInput");
1934
1951
  }
1935
1952
  imports.sort((a, b) => {
1936
1953
  const aType = a.startsWith("type ");
@@ -2078,5 +2095,5 @@ import_generator_helper.generatorHandler({
2078
2095
  }
2079
2096
  });
2080
2097
 
2081
- //# debugId=049E59ABB41E57F464756E2164756E21
2098
+ //# debugId=1AF7D503EDBC01CE64756E2164756E21
2082
2099
  //# sourceMappingURL=orm-generator.js.map