@snowtop/ent 0.1.0-alpha14 → 0.1.0-alpha15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowtop/ent",
3
- "version": "0.1.0-alpha14",
3
+ "version": "0.1.0-alpha15",
4
4
  "description": "snowtop ent framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -24,6 +24,7 @@ declare type ProcessedSchema = Omit<Schema, "edges" | "actions" | "edgeGroups" |
24
24
  assocEdgeGroups: ProcessedAssocEdgeGroup[];
25
25
  fields: ProcessedField[];
26
26
  schemaPath?: string;
27
+ patternNames?: string[];
27
28
  };
28
29
  declare type ProcessedAssocEdgeGroup = Omit<AssocEdgeGroup, "edgeAction"> & {
29
30
  edgeAction?: OutputAction;
@@ -38,6 +39,7 @@ interface ProcessedPattern {
38
39
  name: string;
39
40
  assocEdges: ProcessedAssocEdge[];
40
41
  fields: ProcessedField[];
42
+ disableMixin?: boolean;
41
43
  }
42
44
  declare type ProcessedType = Omit<Type, "subFields" | "listElemType" | "unionFields"> & {
43
45
  subFields?: ProcessedField[];
@@ -130,6 +130,7 @@ function processPattern(patterns, pattern, processedSchema) {
130
130
  name: pattern.name,
131
131
  assocEdges: edges,
132
132
  fields: fields,
133
+ disableMixin: pattern.disableMixin,
133
134
  };
134
135
  }
135
136
  else {
@@ -202,9 +203,11 @@ function parseSchema(potentialSchemas) {
202
203
  };
203
204
  // let's put patterns first just so we have id, created_at, updated_at first
204
205
  // ¯\_(ツ)_/¯
206
+ let patternNames = [];
205
207
  if (schema.patterns) {
206
208
  for (const pattern of schema.patterns) {
207
209
  const ret = processPattern(patterns, pattern, processedSchema);
210
+ patternNames.push(pattern.name);
208
211
  if (ret.transformsSelect) {
209
212
  if (processedSchema.transformsSelect) {
210
213
  throw new Error(`can only have one pattern which transforms default querying behavior`);
@@ -221,6 +224,7 @@ function parseSchema(potentialSchemas) {
221
224
  }
222
225
  const fields = processFields(schema.fields);
223
226
  processedSchema.fields.push(...fields);
227
+ processedSchema.patternNames = patternNames;
224
228
  if (schema.edges) {
225
229
  const edges = processEdges(schema.edges);
226
230
  processedSchema.assocEdges.push(...edges);
@@ -66,6 +66,7 @@ let nodeFieldsWithTZ = {
66
66
  exports.Node = {
67
67
  name: "node",
68
68
  fields: nodeFields,
69
+ disableMixin: true,
69
70
  };
70
71
  // Ent schema. has Node Pattern by default.
71
72
  // exists just to have less typing and easier for clients to implement
@@ -95,6 +96,7 @@ class EntSchemaWithTZ {
95
96
  // default schema added
96
97
  name: "nodeWithTZ",
97
98
  fields: nodeFieldsWithTZ,
99
+ disableMixin: true,
98
100
  },
99
101
  ];
100
102
  this.fields = cfg.fields;
@@ -131,6 +133,7 @@ class BaseEntSchemaWithTZ {
131
133
  // default schema added
132
134
  name: "nodeWithTZ",
133
135
  fields: nodeFieldsWithTZ,
136
+ disableMixin: true,
134
137
  },
135
138
  ];
136
139
  }
@@ -69,6 +69,7 @@ export declare type Edge = AssocEdge;
69
69
  export interface Pattern {
70
70
  name: string;
71
71
  fields: FieldMap | Field[];
72
+ disableMixin?: boolean;
72
73
  edges?: Edge[];
73
74
  transformRead?: () => Clause;
74
75
  transformWrite?: <T extends Ent>(stmt: UpdateOperation<T>) => TransformedUpdateOperation<T> | null;