@snowtop/ent 0.1.0-alpha146 → 0.1.0-alpha148
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 +1 -1
- package/parse_schema/parse.d.ts +3 -2
- package/parse_schema/parse.js +31 -25
- package/schema/base_schema.d.ts +4 -2
- package/schema/base_schema.js +4 -2
- package/schema/schema.d.ts +9 -1
- package/testutils/ent-graphql-tests/index.d.ts +1 -1
- package/testutils/ent-graphql-tests/index.js +4 -3
package/package.json
CHANGED
package/parse_schema/parse.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema, Field, AssocEdge, AssocEdgeGroup, Action } from "../schema";
|
|
2
|
-
import { ActionField, Type, GlobalSchema, TransformReadBetaResult } from "../schema/schema";
|
|
2
|
+
import { ActionField, Type, GlobalSchema, TransformReadBetaResult, CanViewerDo } from "../schema/schema";
|
|
3
3
|
declare enum NullableResult {
|
|
4
4
|
CONTENTS = "contents",
|
|
5
5
|
CONTENTS_AND_LIST = "contentsAndList",
|
|
@@ -30,8 +30,9 @@ type ProcessedSchema = Omit<Schema, "edges" | "actions" | "edgeGroups" | "fields
|
|
|
30
30
|
type ProcessedAssocEdgeGroup = Omit<AssocEdgeGroup, "edgeAction"> & {
|
|
31
31
|
edgeAction?: OutputAction;
|
|
32
32
|
};
|
|
33
|
-
type OutputAction = Omit<Action, "actionOnlyFields"> & {
|
|
33
|
+
type OutputAction = Omit<Action, "actionOnlyFields" | "canViewerDo"> & {
|
|
34
34
|
actionOnlyFields?: ProcessedActionField[];
|
|
35
|
+
canViewerDo?: CanViewerDo;
|
|
35
36
|
};
|
|
36
37
|
interface schemasDict {
|
|
37
38
|
[key: string]: ProcessedSchema;
|
package/parse_schema/parse.js
CHANGED
|
@@ -202,34 +202,39 @@ var NullableResult;
|
|
|
202
202
|
NullableResult["ITEM"] = "true";
|
|
203
203
|
})(NullableResult || (NullableResult = {}));
|
|
204
204
|
function processAction(action) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
delete f2.nullable;
|
|
213
|
-
return f2;
|
|
214
|
-
}
|
|
215
|
-
if (typeof f.nullable === "boolean") {
|
|
216
|
-
f2.nullable = NullableResult.ITEM;
|
|
217
|
-
}
|
|
218
|
-
else {
|
|
219
|
-
if (f.nullable === "contentsAndList") {
|
|
220
|
-
f2.nullable = NullableResult.CONTENTS_AND_LIST;
|
|
221
|
-
}
|
|
222
|
-
else if (f.nullable === "contents") {
|
|
223
|
-
f2.nullable = NullableResult.CONTENTS;
|
|
205
|
+
const ret = { ...action };
|
|
206
|
+
if (action.actionOnlyFields !== undefined) {
|
|
207
|
+
let actionOnlyFields = action.actionOnlyFields.map((f) => {
|
|
208
|
+
let f2 = f;
|
|
209
|
+
if (!f.nullable) {
|
|
210
|
+
delete f2.nullable;
|
|
211
|
+
return f2;
|
|
224
212
|
}
|
|
225
|
-
|
|
226
|
-
// shouldn't happen but ran into weirdness where it did...
|
|
213
|
+
if (typeof f.nullable === "boolean") {
|
|
227
214
|
f2.nullable = NullableResult.ITEM;
|
|
228
215
|
}
|
|
216
|
+
else {
|
|
217
|
+
if (f.nullable === "contentsAndList") {
|
|
218
|
+
f2.nullable = NullableResult.CONTENTS_AND_LIST;
|
|
219
|
+
}
|
|
220
|
+
else if (f.nullable === "contents") {
|
|
221
|
+
f2.nullable = NullableResult.CONTENTS;
|
|
222
|
+
}
|
|
223
|
+
else if (f.nullable === "true") {
|
|
224
|
+
// shouldn't happen but ran into weirdness where it did...
|
|
225
|
+
f2.nullable = NullableResult.ITEM;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return f2;
|
|
229
|
+
});
|
|
230
|
+
ret.actionOnlyFields = actionOnlyFields;
|
|
231
|
+
}
|
|
232
|
+
if (action.canViewerDo !== undefined) {
|
|
233
|
+
if (typeof action.canViewerDo !== "object") {
|
|
234
|
+
delete ret.canViewerDo;
|
|
235
|
+
ret.canViewerDo = {};
|
|
229
236
|
}
|
|
230
|
-
|
|
231
|
-
});
|
|
232
|
-
ret.actionOnlyFields = actionOnlyFields;
|
|
237
|
+
}
|
|
233
238
|
return ret;
|
|
234
239
|
}
|
|
235
240
|
async function parseSchema(potentialSchemas, globalSchema) {
|
|
@@ -270,7 +275,8 @@ async function parseSchema(potentialSchemas, globalSchema) {
|
|
|
270
275
|
assocEdgeGroups: [],
|
|
271
276
|
customGraphQLInterfaces: schema.customGraphQLInterfaces,
|
|
272
277
|
supportUpsert: schema.supportUpsert,
|
|
273
|
-
|
|
278
|
+
showCanViewerSee: schema.showCanViewerSee,
|
|
279
|
+
showCanViewerEdit: schema.showCanViewerEdit,
|
|
274
280
|
};
|
|
275
281
|
// let's put patterns first just so we have id, created_at, updated_at first
|
|
276
282
|
// ¯\_(ツ)_/¯
|
package/schema/base_schema.d.ts
CHANGED
|
@@ -21,7 +21,8 @@ export declare class EntSchema implements Schema {
|
|
|
21
21
|
hideFromGraphQL?: boolean;
|
|
22
22
|
customGraphQLInterfaces?: string[] | undefined;
|
|
23
23
|
supportUpsert?: boolean | undefined;
|
|
24
|
-
|
|
24
|
+
showCanViewerSee?: boolean | undefined;
|
|
25
|
+
showCanViewerEdit?: boolean | undefined;
|
|
25
26
|
constructor(cfg: SchemaConfig);
|
|
26
27
|
}
|
|
27
28
|
export declare class EntSchemaWithTZ implements Schema {
|
|
@@ -41,7 +42,8 @@ export declare class EntSchemaWithTZ implements Schema {
|
|
|
41
42
|
hideFromGraphQL?: boolean;
|
|
42
43
|
customGraphQLInterfaces?: string[] | undefined;
|
|
43
44
|
supportUpsert?: boolean | undefined;
|
|
44
|
-
|
|
45
|
+
showCanViewerSee?: boolean | undefined;
|
|
46
|
+
showCanViewerEdit?: boolean | undefined;
|
|
45
47
|
constructor(cfg: SchemaConfig);
|
|
46
48
|
}
|
|
47
49
|
export declare abstract class BaseEntSchema {
|
package/schema/base_schema.js
CHANGED
|
@@ -91,7 +91,8 @@ class EntSchema {
|
|
|
91
91
|
// TODO annoying that have to list these...
|
|
92
92
|
this.customGraphQLInterfaces = cfg.customGraphQLInterfaces;
|
|
93
93
|
this.supportUpsert = cfg.supportUpsert;
|
|
94
|
-
this.
|
|
94
|
+
this.showCanViewerSee = cfg.showCanViewerSee;
|
|
95
|
+
this.showCanViewerEdit = cfg.showCanViewerEdit;
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
exports.EntSchema = EntSchema;
|
|
@@ -122,7 +123,8 @@ class EntSchemaWithTZ {
|
|
|
122
123
|
// TODO annoying that have to list these...
|
|
123
124
|
this.customGraphQLInterfaces = cfg.customGraphQLInterfaces;
|
|
124
125
|
this.supportUpsert = cfg.supportUpsert;
|
|
125
|
-
this.
|
|
126
|
+
this.showCanViewerSee = cfg.showCanViewerSee;
|
|
127
|
+
this.showCanViewerEdit = cfg.showCanViewerEdit;
|
|
126
128
|
}
|
|
127
129
|
}
|
|
128
130
|
exports.EntSchemaWithTZ = EntSchemaWithTZ;
|
package/schema/schema.d.ts
CHANGED
|
@@ -40,7 +40,8 @@ export default interface Schema {
|
|
|
40
40
|
hideFromGraphQL?: boolean;
|
|
41
41
|
customGraphQLInterfaces?: string[];
|
|
42
42
|
supportUpsert?: boolean;
|
|
43
|
-
|
|
43
|
+
showCanViewerSee?: boolean;
|
|
44
|
+
showCanViewerEdit?: boolean;
|
|
44
45
|
}
|
|
45
46
|
export interface AssocEdge {
|
|
46
47
|
name: string;
|
|
@@ -59,6 +60,7 @@ export interface EdgeAction {
|
|
|
59
60
|
hideFromGraphQL?: boolean;
|
|
60
61
|
graphQLName?: string;
|
|
61
62
|
actionOnlyFields?: ActionField[];
|
|
63
|
+
canViewerDo?: boolean | CanViewerDo;
|
|
62
64
|
}
|
|
63
65
|
export interface InverseAssocEdge {
|
|
64
66
|
name: string;
|
|
@@ -70,6 +72,7 @@ export interface EdgeGroupAction {
|
|
|
70
72
|
hideFromGraphQL?: boolean;
|
|
71
73
|
graphQLName?: string;
|
|
72
74
|
actionOnlyFields?: ActionField[];
|
|
75
|
+
canViewerDo?: boolean | CanViewerDo;
|
|
73
76
|
}
|
|
74
77
|
export interface AssocEdgeGroup {
|
|
75
78
|
name: string;
|
|
@@ -309,8 +312,13 @@ export interface Action {
|
|
|
309
312
|
optionalFields?: string[];
|
|
310
313
|
requiredFields?: string[];
|
|
311
314
|
noFields?: boolean;
|
|
315
|
+
canViewerDo?: boolean | CanViewerDo;
|
|
312
316
|
[x: string]: any;
|
|
313
317
|
}
|
|
318
|
+
export interface CanViewerDo {
|
|
319
|
+
addAllFields?: boolean;
|
|
320
|
+
inputFields?: string[];
|
|
321
|
+
}
|
|
314
322
|
export declare const NoFields = "__NO_FIELDS__";
|
|
315
323
|
export declare function requiredField(field: string): string;
|
|
316
324
|
export declare function optionalField(field: string): string;
|
|
@@ -2,7 +2,7 @@ import { Express, RequestHandler } from "express";
|
|
|
2
2
|
import { Viewer } from "../../core/base";
|
|
3
3
|
import { GraphQLSchema } from "graphql";
|
|
4
4
|
import supertest from "supertest";
|
|
5
|
-
export type Option = [string, any];
|
|
5
|
+
export type Option = [string, any] | [string, any, string];
|
|
6
6
|
interface queryConfig {
|
|
7
7
|
viewer?: Viewer;
|
|
8
8
|
init?: (app: Express) => void;
|
|
@@ -418,8 +418,9 @@ async function expectFromRoot(config, ...options) {
|
|
|
418
418
|
}
|
|
419
419
|
}
|
|
420
420
|
await Promise.all(options.map(async (option) => {
|
|
421
|
-
|
|
422
|
-
|
|
421
|
+
const path = option[0];
|
|
422
|
+
const expected = option[1];
|
|
423
|
+
const alias = option[2];
|
|
423
424
|
let nullPath;
|
|
424
425
|
let nullParts = [];
|
|
425
426
|
let undefinedPath;
|
|
@@ -442,7 +443,7 @@ async function expectFromRoot(config, ...options) {
|
|
|
442
443
|
}
|
|
443
444
|
}
|
|
444
445
|
}
|
|
445
|
-
let parts = splitPath(path);
|
|
446
|
+
let parts = splitPath(alias ?? path);
|
|
446
447
|
let current = result;
|
|
447
448
|
// possible to make this smarter and better
|
|
448
449
|
// e.g. when building up the tree above
|