@snowtop/ent 0.1.10 → 0.1.12
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
package/parse_schema/parse.d.ts
CHANGED
|
@@ -20,13 +20,14 @@ interface TransformFlags {
|
|
|
20
20
|
transformsInsert?: boolean;
|
|
21
21
|
transformsUpdate?: boolean;
|
|
22
22
|
}
|
|
23
|
-
type ProcessedSchema = Omit<Schema, "edges" | "actions" | "edgeGroups" | "fields"> & TransformFlags & {
|
|
23
|
+
type ProcessedSchema = Omit<Schema, "edges" | "actions" | "edgeGroups" | "fields" | "defaultActionPrivacy"> & TransformFlags & {
|
|
24
24
|
actions: OutputAction[];
|
|
25
25
|
assocEdges: ProcessedAssocEdge[];
|
|
26
26
|
assocEdgeGroups: ProcessedAssocEdgeGroup[];
|
|
27
27
|
fields: ProcessedField[];
|
|
28
28
|
schemaPath?: string;
|
|
29
29
|
patternNames?: string[];
|
|
30
|
+
hasDefaultActionPrivacy?: boolean;
|
|
30
31
|
};
|
|
31
32
|
type ProcessedAssocEdgeGroup = Omit<AssocEdgeGroup, "edgeAction"> & {
|
|
32
33
|
edgeAction?: OutputAction;
|
package/parse_schema/parse.js
CHANGED
|
@@ -278,6 +278,7 @@ async function parseSchema(potentialSchemas, globalSchema) {
|
|
|
278
278
|
supportUpsert: schema.supportUpsert,
|
|
279
279
|
showCanViewerSee: schema.showCanViewerSee,
|
|
280
280
|
showCanViewerEdit: schema.showCanViewerEdit,
|
|
281
|
+
hasDefaultActionPrivacy: schema.defaultActionPrivacy !== undefined,
|
|
281
282
|
};
|
|
282
283
|
// let's put patterns first just so we have id, created_at, updated_at first
|
|
283
284
|
// ¯\_(ツ)_/¯
|
package/schema/base_schema.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FieldMap, Pattern, FieldOverrideMap } from "./schema";
|
|
2
2
|
import { Action, AssocEdgeGroup, Constraint, Edge, Index, Schema } from ".";
|
|
3
|
+
import { PrivacyPolicy } from "../core/base";
|
|
3
4
|
export declare const Timestamps: Pattern;
|
|
4
5
|
export declare const Node: Pattern;
|
|
5
6
|
export interface SchemaConfig extends Schema {
|
|
@@ -23,6 +24,7 @@ export declare class EntSchema implements Schema {
|
|
|
23
24
|
supportUpsert?: boolean | undefined;
|
|
24
25
|
showCanViewerSee?: boolean | undefined;
|
|
25
26
|
showCanViewerEdit?: boolean | undefined;
|
|
27
|
+
defaultActionPrivacy?: PrivacyPolicy | (() => PrivacyPolicy);
|
|
26
28
|
constructor(cfg: SchemaConfig);
|
|
27
29
|
}
|
|
28
30
|
export declare class EntSchemaWithTZ implements Schema {
|
|
@@ -44,6 +46,7 @@ export declare class EntSchemaWithTZ implements Schema {
|
|
|
44
46
|
supportUpsert?: boolean | undefined;
|
|
45
47
|
showCanViewerSee?: boolean | undefined;
|
|
46
48
|
showCanViewerEdit?: boolean | undefined;
|
|
49
|
+
defaultActionPrivacy?: PrivacyPolicy | (() => PrivacyPolicy);
|
|
47
50
|
constructor(cfg: SchemaConfig);
|
|
48
51
|
}
|
|
49
52
|
export declare abstract class BaseEntSchema {
|
package/schema/base_schema.js
CHANGED
|
@@ -93,6 +93,7 @@ class EntSchema {
|
|
|
93
93
|
this.supportUpsert = cfg.supportUpsert;
|
|
94
94
|
this.showCanViewerSee = cfg.showCanViewerSee;
|
|
95
95
|
this.showCanViewerEdit = cfg.showCanViewerEdit;
|
|
96
|
+
this.defaultActionPrivacy = cfg.defaultActionPrivacy;
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
exports.EntSchema = EntSchema;
|
|
@@ -125,6 +126,7 @@ class EntSchemaWithTZ {
|
|
|
125
126
|
this.supportUpsert = cfg.supportUpsert;
|
|
126
127
|
this.showCanViewerSee = cfg.showCanViewerSee;
|
|
127
128
|
this.showCanViewerEdit = cfg.showCanViewerEdit;
|
|
129
|
+
this.defaultActionPrivacy = cfg.defaultActionPrivacy;
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
132
|
exports.EntSchemaWithTZ = EntSchemaWithTZ;
|
package/schema/schema.d.ts
CHANGED
package/schema/struct_field.d.ts
CHANGED
|
@@ -6,10 +6,13 @@ interface structFieldOptions extends FieldOptions {
|
|
|
6
6
|
graphQLType?: string;
|
|
7
7
|
jsonNotJSONB?: boolean;
|
|
8
8
|
}
|
|
9
|
+
interface structFieldListOptions extends structFieldOptions {
|
|
10
|
+
validateUniqueKey?: string;
|
|
11
|
+
}
|
|
9
12
|
interface GlobalStructOptions extends FieldOptions {
|
|
10
13
|
globalType: string;
|
|
11
14
|
}
|
|
12
|
-
export type StructOptions = structFieldOptions | GlobalStructOptions;
|
|
15
|
+
export type StructOptions = structFieldOptions | GlobalStructOptions | structFieldListOptions;
|
|
13
16
|
export declare class StructField extends BaseField implements Field {
|
|
14
17
|
private options;
|
|
15
18
|
private jsonAsList?;
|
package/schema/struct_field.js
CHANGED
|
@@ -168,7 +168,17 @@ class StructField extends field_1.BaseField {
|
|
|
168
168
|
if (!Array.isArray(obj)) {
|
|
169
169
|
return false;
|
|
170
170
|
}
|
|
171
|
-
const
|
|
171
|
+
const unique = new Set();
|
|
172
|
+
const valid = await Promise.all(obj.map((v) => {
|
|
173
|
+
if (this.options.validateUniqueKey) {
|
|
174
|
+
const value = v[this.options.validateUniqueKey];
|
|
175
|
+
if (unique.has(value)) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
unique.add(value);
|
|
179
|
+
}
|
|
180
|
+
return this.validImpl(v);
|
|
181
|
+
}));
|
|
172
182
|
return valid.every((b) => b);
|
|
173
183
|
}
|
|
174
184
|
if (!(obj instanceof Object)) {
|