@zenstackhq/sdk 3.0.0-beta.7 → 3.0.0-beta.8

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/dist/index.d.cts CHANGED
@@ -104,8 +104,7 @@ declare class PrismaSchemaGenerator {
104
104
  private getUnsupportedFieldType;
105
105
  private getStringLiteral;
106
106
  private generateModelField;
107
- private isDefaultWithPluginInvocation;
108
- private isFromPlugin;
107
+ private isDefaultWithAuthInvocation;
109
108
  private isInheritedFromDelegate;
110
109
  private makeFieldAttribute;
111
110
  private makeAttributeArg;
package/dist/index.d.ts CHANGED
@@ -104,8 +104,7 @@ declare class PrismaSchemaGenerator {
104
104
  private getUnsupportedFieldType;
105
105
  private getStringLiteral;
106
106
  private generateModelField;
107
- private isDefaultWithPluginInvocation;
108
- private isFromPlugin;
107
+ private isDefaultWithAuthInvocation;
109
108
  private isInheritedFromDelegate;
110
109
  private makeFieldAttribute;
111
110
  private makeAttributeArg;
package/dist/index.js CHANGED
@@ -103,8 +103,8 @@ var DELEGATE_AUX_RELATION_PREFIX = "delegate_aux";
103
103
 
104
104
  // src/prisma/prisma-schema-generator.ts
105
105
  import { lowerCaseFirst } from "@zenstackhq/common-helpers";
106
- import { BooleanLiteral, DataModel, DataSource as DataSource2, Enum as Enum2, GeneratorDecl, isArrayExpr, isDataModel as isDataModel2, isInvocationExpr, isLiteralExpr as isLiteralExpr2, isModel as isModel2, isNullExpr, isReferenceExpr, isStringLiteral, isTypeDef as isTypeDef2, NumberLiteral, StringLiteral } from "@zenstackhq/language/ast";
107
- import { getAllAttributes, getAllFields as getAllFields2, isDelegateModel as isDelegateModel2 } from "@zenstackhq/language/utils";
106
+ import { BooleanLiteral, DataModel, DataSource as DataSource2, Enum as Enum2, GeneratorDecl, isArrayExpr, isDataModel as isDataModel2, isInvocationExpr, isLiteralExpr as isLiteralExpr2, isNullExpr, isReferenceExpr, isStringLiteral, isTypeDef as isTypeDef2, NumberLiteral, StringLiteral } from "@zenstackhq/language/ast";
107
+ import { getAllAttributes, getAllFields as getAllFields2, isAuthInvocation, isDelegateModel as isDelegateModel2 } from "@zenstackhq/language/utils";
108
108
  import { AstUtils } from "langium";
109
109
  import { match } from "ts-pattern";
110
110
 
@@ -638,7 +638,7 @@ var PrismaSchemaGenerator = class {
638
638
  isTypeDef2(field.type.reference?.ref) ? false : field.type.array
639
639
  );
640
640
  const type = new ModelFieldType(fieldType, isArray, field.type.optional);
641
- const attributes = field.attributes.filter((attr) => this.isPrismaAttribute(attr)).filter((attr) => !this.isDefaultWithPluginInvocation(attr)).filter((attr) => (
641
+ const attributes = field.attributes.filter((attr) => this.isPrismaAttribute(attr)).filter((attr) => !this.isDefaultWithAuthInvocation(attr)).filter((attr) => (
642
642
  // when building physical schema, exclude `@default` for id fields inherited from delegate base
643
643
  !(model_utils_exports.isIdField(field, contextModel) && this.isInheritedFromDelegate(field, contextModel) && attr.decl.$refText === "@default")
644
644
  )).map((attr) => this.makeFieldAttribute(attr));
@@ -648,7 +648,7 @@ var PrismaSchemaGenerator = class {
648
648
  const result = model.addField(field.name, type, attributes, docs, addToFront);
649
649
  return result;
650
650
  }
651
- isDefaultWithPluginInvocation(attr) {
651
+ isDefaultWithAuthInvocation(attr) {
652
652
  if (attr.decl.ref?.name !== "@default") {
653
653
  return false;
654
654
  }
@@ -656,11 +656,7 @@ var PrismaSchemaGenerator = class {
656
656
  if (!expr) {
657
657
  return false;
658
658
  }
659
- return AstUtils.streamAst(expr).some((node) => isInvocationExpr(node) && this.isFromPlugin(node.function.ref));
660
- }
661
- isFromPlugin(node) {
662
- const model = AstUtils.getContainerOfType(node, isModel2);
663
- return !!model && !!model.$document && model.$document.uri.path.endsWith("plugin.zmodel");
659
+ return AstUtils.streamAst(expr).some(isAuthInvocation);
664
660
  }
665
661
  isInheritedFromDelegate(field, contextModel) {
666
662
  return field.$container !== contextModel && model_utils_exports.isDelegateModel(field.$container);