@snowtop/ent 0.1.0-alpha123 → 0.1.0-alpha125

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,54 +1,135 @@
1
1
  "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.push(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.push(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
7
28
  };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
10
35
  };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
36
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
37
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
38
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
13
39
  };
14
40
  Object.defineProperty(exports, "__esModule", { value: true });
15
41
  const graphql_1 = require("../../../graphql/graphql");
16
42
  const graphql_2 = require("graphql");
17
- let UserAuthInput = class UserAuthInput {
18
- };
19
- __decorate([
20
- (0, graphql_1.gqlField)(),
21
- __metadata("design:type", String)
22
- ], UserAuthInput.prototype, "emailAddress", void 0);
23
- __decorate([
24
- (0, graphql_1.gqlField)(),
25
- __metadata("design:type", String)
26
- ], UserAuthInput.prototype, "password", void 0);
27
- UserAuthInput = __decorate([
28
- (0, graphql_1.gqlInputObjectType)()
29
- ], UserAuthInput);
30
- let UserAuthResponse = class UserAuthResponse {
31
- };
32
- __decorate([
33
- (0, graphql_1.gqlField)(),
34
- __metadata("design:type", String)
35
- ], UserAuthResponse.prototype, "token", void 0);
36
- __decorate([
37
- (0, graphql_1.gqlField)({ type: graphql_2.GraphQLID }),
38
- __metadata("design:type", Object)
39
- ], UserAuthResponse.prototype, "viewerID", void 0);
40
- UserAuthResponse = __decorate([
41
- (0, graphql_1.gqlObjectType)()
42
- ], UserAuthResponse);
43
- class AuthResolver {
44
- async userAuth(input) {
45
- throw new Error("not implemented");
46
- }
47
- }
48
- __decorate([
49
- (0, graphql_1.gqlMutation)({ name: "userAuth", type: UserAuthResponse }),
50
- __param(0, (0, graphql_1.gqlArg)("input")),
51
- __metadata("design:type", Function),
52
- __metadata("design:paramtypes", [UserAuthInput]),
53
- __metadata("design:returntype", Promise)
54
- ], AuthResolver.prototype, "userAuth", null);
43
+ let UserAuthInput = (() => {
44
+ let _classDecorators = [(0, graphql_1.gqlInputObjectType)()];
45
+ let _classDescriptor;
46
+ let _classExtraInitializers = [];
47
+ let _classThis;
48
+ let _instanceExtraInitializers = [];
49
+ let _emailAddress_decorators;
50
+ let _emailAddress_initializers = [];
51
+ let _password_decorators;
52
+ let _password_initializers = [];
53
+ var UserAuthInput = _classThis = class {
54
+ constructor() {
55
+ this.emailAddress = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _emailAddress_initializers, void 0));
56
+ this.password = __runInitializers(this, _password_initializers, void 0);
57
+ }
58
+ };
59
+ __setFunctionName(_classThis, "UserAuthInput");
60
+ (() => {
61
+ _emailAddress_decorators = [(0, graphql_1.gqlField)({
62
+ nodeName: "UserAuthInput",
63
+ type: graphql_2.GraphQLString,
64
+ })];
65
+ _password_decorators = [(0, graphql_1.gqlField)({
66
+ nodeName: "UserAuthInput",
67
+ type: graphql_2.GraphQLString,
68
+ })];
69
+ __esDecorate(null, null, _emailAddress_decorators, { kind: "field", name: "emailAddress", static: false, private: false, access: { has: obj => "emailAddress" in obj, get: obj => obj.emailAddress, set: (obj, value) => { obj.emailAddress = value; } } }, _emailAddress_initializers, _instanceExtraInitializers);
70
+ __esDecorate(null, null, _password_decorators, { kind: "field", name: "password", static: false, private: false, access: { has: obj => "password" in obj, get: obj => obj.password, set: (obj, value) => { obj.password = value; } } }, _password_initializers, _instanceExtraInitializers);
71
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers);
72
+ UserAuthInput = _classThis = _classDescriptor.value;
73
+ __runInitializers(_classThis, _classExtraInitializers);
74
+ })();
75
+ return UserAuthInput = _classThis;
76
+ })();
77
+ let UserAuthResponse = (() => {
78
+ let _classDecorators_1 = [(0, graphql_1.gqlObjectType)()];
79
+ let _classDescriptor_1;
80
+ let _classExtraInitializers_1 = [];
81
+ let _classThis_1;
82
+ let _instanceExtraInitializers_1 = [];
83
+ let _token_decorators;
84
+ let _token_initializers = [];
85
+ let _viewerID_decorators;
86
+ let _viewerID_initializers = [];
87
+ var UserAuthResponse = _classThis_1 = class {
88
+ constructor() {
89
+ this.token = (__runInitializers(this, _instanceExtraInitializers_1), __runInitializers(this, _token_initializers, void 0));
90
+ this.viewerID = __runInitializers(this, _viewerID_initializers, void 0);
91
+ }
92
+ };
93
+ __setFunctionName(_classThis_1, "UserAuthResponse");
94
+ (() => {
95
+ _token_decorators = [(0, graphql_1.gqlField)({
96
+ nodeName: "UserAuthResponse",
97
+ type: graphql_2.GraphQLString,
98
+ })];
99
+ _viewerID_decorators = [(0, graphql_1.gqlField)({ nodeName: "UserAuthResponses", type: graphql_2.GraphQLID })];
100
+ __esDecorate(null, null, _token_decorators, { kind: "field", name: "token", static: false, private: false, access: { has: obj => "token" in obj, get: obj => obj.token, set: (obj, value) => { obj.token = value; } } }, _token_initializers, _instanceExtraInitializers_1);
101
+ __esDecorate(null, null, _viewerID_decorators, { kind: "field", name: "viewerID", static: false, private: false, access: { has: obj => "viewerID" in obj, get: obj => obj.viewerID, set: (obj, value) => { obj.viewerID = value; } } }, _viewerID_initializers, _instanceExtraInitializers_1);
102
+ __esDecorate(null, _classDescriptor_1 = { value: _classThis_1 }, _classDecorators_1, { kind: "class", name: _classThis_1.name }, null, _classExtraInitializers_1);
103
+ UserAuthResponse = _classThis_1 = _classDescriptor_1.value;
104
+ __runInitializers(_classThis_1, _classExtraInitializers_1);
105
+ })();
106
+ return UserAuthResponse = _classThis_1;
107
+ })();
108
+ let AuthResolver = (() => {
109
+ var _a;
110
+ let _instanceExtraInitializers_2 = [];
111
+ let _userAuth_decorators;
112
+ return _a = class AuthResolver {
113
+ async userAuth(input) {
114
+ throw new Error("not implemented");
115
+ }
116
+ constructor() {
117
+ __runInitializers(this, _instanceExtraInitializers_2);
118
+ }
119
+ },
120
+ (() => {
121
+ _userAuth_decorators = [(0, graphql_1.gqlMutation)({
122
+ nodeName: "AuthResolver",
123
+ name: "userAuth",
124
+ type: UserAuthResponse,
125
+ args: [
126
+ {
127
+ name: "input",
128
+ type: UserAuthInput,
129
+ },
130
+ ],
131
+ })];
132
+ __esDecorate(_a, null, _userAuth_decorators, { kind: "method", name: "userAuth", static: false, private: false, access: { has: obj => "userAuth" in obj, get: obj => obj.userAuth } }, null, _instanceExtraInitializers_2);
133
+ })(),
134
+ _a;
135
+ })();
@@ -1,46 +1,94 @@
1
1
  "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
2
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
3
+ var useValue = arguments.length > 2;
4
+ for (var i = 0; i < initializers.length; i++) {
5
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
6
+ }
7
+ return useValue ? value : void 0;
7
8
  };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
10
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
11
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
12
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
13
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
14
+ var _, done = false;
15
+ for (var i = decorators.length - 1; i >= 0; i--) {
16
+ var context = {};
17
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
18
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
19
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
20
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
21
+ if (kind === "accessor") {
22
+ if (result === void 0) continue;
23
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
24
+ if (_ = accept(result.get)) descriptor.get = _;
25
+ if (_ = accept(result.set)) descriptor.set = _;
26
+ if (_ = accept(result.init)) initializers.push(_);
27
+ }
28
+ else if (_ = accept(result)) {
29
+ if (kind === "field") initializers.push(_);
30
+ else descriptor[key] = _;
31
+ }
32
+ }
33
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
34
+ done = true;
10
35
  };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
36
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
37
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
38
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
13
39
  };
14
40
  Object.defineProperty(exports, "__esModule", { value: true });
15
41
  const graphql_1 = require("../../../graphql/graphql");
16
42
  const graphql_2 = require("graphql");
17
- let ViewerType = class ViewerType {
18
- constructor(viewer) {
19
- this.viewer = viewer;
20
- }
21
- get viewerID() {
22
- return this.viewer.viewerID;
23
- }
24
- };
25
- __decorate([
26
- (0, graphql_1.gqlField)({ type: graphql_2.GraphQLID, nullable: true }),
27
- __metadata("design:type", Object),
28
- __metadata("design:paramtypes", [])
29
- ], ViewerType.prototype, "viewerID", null);
30
- ViewerType = __decorate([
31
- (0, graphql_1.gqlObjectType)({ name: "Viewer" }),
32
- __metadata("design:paramtypes", [Object])
33
- ], ViewerType);
34
- class ViewerResolver {
35
- viewer(context) {
36
- return new ViewerType(context.getViewer());
37
- }
38
- }
39
- __decorate([
40
- (0, graphql_1.gqlQuery)({ name: "viewer", type: ViewerType }),
41
- __param(0, (0, graphql_1.gqlContextType)()),
42
- __metadata("design:type", Function),
43
- __metadata("design:paramtypes", [Object]),
44
- __metadata("design:returntype", ViewerType)
45
- ], ViewerResolver.prototype, "viewer", null);
46
- exports.default = ViewerResolver;
43
+ let ViewerType = (() => {
44
+ let _classDecorators = [(0, graphql_1.gqlObjectType)({ name: "Viewer" })];
45
+ let _classDescriptor;
46
+ let _classExtraInitializers = [];
47
+ let _classThis;
48
+ let _instanceExtraInitializers = [];
49
+ let _get_viewerID_decorators;
50
+ var ViewerType = _classThis = class {
51
+ constructor(viewer) {
52
+ this.viewer = (__runInitializers(this, _instanceExtraInitializers), viewer);
53
+ }
54
+ get viewerID() {
55
+ return this.viewer.viewerID;
56
+ }
57
+ };
58
+ __setFunctionName(_classThis, "ViewerType");
59
+ (() => {
60
+ _get_viewerID_decorators = [(0, graphql_1.gqlField)({
61
+ nodeName: "ViewerType",
62
+ type: graphql_2.GraphQLID,
63
+ nullable: true,
64
+ })];
65
+ __esDecorate(_classThis, null, _get_viewerID_decorators, { kind: "getter", name: "viewerID", static: false, private: false, access: { has: obj => "viewerID" in obj, get: obj => obj.viewerID } }, null, _instanceExtraInitializers);
66
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers);
67
+ ViewerType = _classThis = _classDescriptor.value;
68
+ __runInitializers(_classThis, _classExtraInitializers);
69
+ })();
70
+ return ViewerType = _classThis;
71
+ })();
72
+ exports.default = (() => {
73
+ var _a;
74
+ let _instanceExtraInitializers_1 = [];
75
+ let _viewer_decorators;
76
+ return _a = class ViewerResolver {
77
+ viewer(context) {
78
+ return new ViewerType(context.getViewer());
79
+ }
80
+ constructor() {
81
+ __runInitializers(this, _instanceExtraInitializers_1);
82
+ }
83
+ },
84
+ (() => {
85
+ _viewer_decorators = [(0, graphql_1.gqlQuery)({
86
+ nodeName: "ViewerResolver",
87
+ name: "viewer",
88
+ type: ViewerType,
89
+ args: [(0, graphql_1.gqlContextType)()],
90
+ })];
91
+ __esDecorate(_a, null, _viewer_decorators, { kind: "method", name: "viewer", static: false, private: false, access: { has: obj => "viewer" in obj, get: obj => obj.viewer } }, null, _instanceExtraInitializers_1);
92
+ })(),
93
+ _a;
94
+ })();
package/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  export * from "./core/base";
2
- export { loadEnt, loadCustomData, loadCustomEnts, loadCustomCount, loadEntX, loadEnts, CustomQuery, loadDerivedEnt, loadDerivedEntX, loadEntViaKey, loadEntXViaKey, performRawQuery, loadRowX, loadRow, loadRows, DataOperation, EditNodeOptions, EditNodeOperation, RawQueryOperation, EdgeOperation, DeleteNodeOperation, AssocEdge, AssocEdgeInputOptions, AssocEdgeInput, AssocEdgeData, loadEdgeData, loadEdgeDatas, loadEdges, loadUniqueEdge, loadUniqueNode, loadRawEdgeCountX, loadEdgeForID2, loadNodesByEdge, getEdgeTypeInGroup, } from "./core/ent";
3
- export { setGlobalSchema } from "./core/global_schema";
2
+ export { loadEnt, loadCustomData, loadCustomEnts, loadCustomCount, loadEntX, loadEnts, CustomQuery, loadDerivedEnt, loadDerivedEntX, loadEntViaKey, loadEntXViaKey, performRawQuery, loadRowX, loadRow, loadRows, DataOperation, EditNodeOptions, EditNodeOperation, RawQueryOperation, EdgeOperation, DeleteNodeOperation, AssocEdge, AssocEdgeInputOptions, AssocEdgeInput, AssocEdgeData, loadEdgeData, loadEdgeDatas, loadEdges, loadUniqueEdge, loadUniqueNode, loadRawEdgeCountX, loadEdgeForID2, loadNodesByEdge, getEdgeTypeInGroup, setGlobalSchema, } from "./core/ent";
4
3
  import DB from "./core/db";
5
4
  export * from "./core/loaders";
6
5
  export { DB };
package/index.js CHANGED
@@ -63,8 +63,7 @@ Object.defineProperty(exports, "loadRawEdgeCountX", { enumerable: true, get: fun
63
63
  Object.defineProperty(exports, "loadEdgeForID2", { enumerable: true, get: function () { return ent_1.loadEdgeForID2; } });
64
64
  Object.defineProperty(exports, "loadNodesByEdge", { enumerable: true, get: function () { return ent_1.loadNodesByEdge; } });
65
65
  Object.defineProperty(exports, "getEdgeTypeInGroup", { enumerable: true, get: function () { return ent_1.getEdgeTypeInGroup; } });
66
- var global_schema_1 = require("./core/global_schema");
67
- Object.defineProperty(exports, "setGlobalSchema", { enumerable: true, get: function () { return global_schema_1.setGlobalSchema; } });
66
+ Object.defineProperty(exports, "setGlobalSchema", { enumerable: true, get: function () { return ent_1.setGlobalSchema; } });
68
67
  const db_1 = __importDefault(require("./core/db"));
69
68
  exports.DB = db_1.default;
70
69
  __exportStar(require("./core/loaders"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowtop/ent",
3
- "version": "0.1.0-alpha123",
3
+ "version": "0.1.0-alpha125",
4
4
  "description": "snowtop ent framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -22,12 +22,11 @@
22
22
  "pascal-case": "^3.1.2",
23
23
  "pg": "^8.8.0",
24
24
  "prettier": "^2.8.1",
25
- "reflect-metadata": "^0.1.13",
26
25
  "snake-case": "^3.0.4",
27
26
  "ts-node": "^10.9.1",
28
- "tsconfig-paths": "^4.1.1",
29
- "tslib": "^2.4.1",
30
- "typescript": "^4.9.4",
27
+ "tsconfig-paths": "^4.2.0",
28
+ "tslib": "^2.5.0",
29
+ "typescript": "^5.0.4",
31
30
  "uuid": "^9.0.0"
32
31
  },
33
32
  "peerDependencies": {
@@ -83,7 +83,6 @@ interface RomeConfig {
83
83
  interface ProcessedGlobalSchema {
84
84
  globalEdges: ProcessedAssocEdge[];
85
85
  extraEdgeFields: ProcessedField[];
86
- init?: boolean;
87
- globalFields?: ProcessedField[];
86
+ initForEdges?: boolean;
88
87
  }
89
88
  export {};
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseSchema = void 0;
4
4
  const cosmiconfig_1 = require("cosmiconfig");
5
5
  const const_1 = require("../core/const");
6
- const global_schema_1 = require("../core/global_schema");
7
6
  async function processFields(src, patternName) {
8
7
  const ret = [];
9
8
  let m = {};
@@ -237,9 +236,6 @@ async function parseSchema(potentialSchemas, globalSchema) {
237
236
  let parsedGlobalSchema;
238
237
  if (globalSchema) {
239
238
  parsedGlobalSchema = await parseGlobalSchema(globalSchema);
240
- // set this so that we can use it, if we're trying to process server default or anything
241
- // that ends up parsing,validating and formatting fields
242
- (0, global_schema_1.setGlobalSchema)(globalSchema);
243
239
  }
244
240
  for (const key in potentialSchemas) {
245
241
  const value = potentialSchemas[key];
@@ -358,10 +354,9 @@ async function parseGlobalSchema(s) {
358
354
  const ret = {
359
355
  globalEdges: [],
360
356
  extraEdgeFields: [],
361
- init: !!s.extraEdgeFields ||
357
+ initForEdges: !!s.extraEdgeFields ||
362
358
  s.transformEdgeRead !== undefined ||
363
- s.transformEdgeWrite !== undefined ||
364
- s.fields !== undefined,
359
+ s.transformEdgeWrite !== undefined,
365
360
  };
366
361
  if (s.extraEdgeFields) {
367
362
  ret.extraEdgeFields = await processFields(s.extraEdgeFields);
@@ -369,8 +364,5 @@ async function parseGlobalSchema(s) {
369
364
  if (s.edges) {
370
365
  ret.globalEdges = processEdges(s.edges);
371
366
  }
372
- if (s.fields) {
373
- ret.globalFields = await processFields(s.fields);
374
- }
375
367
  return ret;
376
368
  }
package/schema/field.d.ts CHANGED
@@ -149,7 +149,6 @@ export interface EnumOptions extends FieldOptions {
149
149
  graphQLType?: string;
150
150
  createEnumType?: boolean;
151
151
  disableUnknownType?: boolean;
152
- globalType?: string;
153
152
  }
154
153
  /**
155
154
  * @deprecated Use StringEnumField
@@ -159,7 +158,7 @@ export declare class EnumField extends BaseField implements Field {
159
158
  private values?;
160
159
  private map?;
161
160
  constructor(options: StringEnumOptions);
162
- valid(val: any): Promise<boolean>;
161
+ valid(val: any): boolean;
163
162
  format(val: any): any;
164
163
  }
165
164
  export declare class StringEnumField extends EnumField {
@@ -174,18 +173,17 @@ declare type IntEnumMap = {
174
173
  [key: string]: number;
175
174
  };
176
175
  export interface IntegerEnumOptions extends FieldOptions {
177
- map?: IntEnumMap;
176
+ map: IntEnumMap;
178
177
  deprecated?: IntEnumMap;
179
178
  tsType?: string;
180
179
  graphQLType?: string;
181
180
  disableUnknownType?: boolean;
182
- globalType?: string;
183
181
  }
184
182
  export declare class IntegerEnumField extends BaseField implements Field {
185
183
  type: Type;
186
184
  private map;
187
185
  constructor(options: IntegerEnumOptions);
188
- valid(val: any): Promise<boolean>;
186
+ valid(val: any): boolean;
189
187
  format(val: any): any;
190
188
  }
191
189
  export declare function IntegerEnumType(options: IntegerEnumOptions): IntegerEnumField;
package/schema/field.js CHANGED
@@ -31,8 +31,6 @@ const uuid_1 = require("uuid");
31
31
  const base_1 = require("../core/base");
32
32
  const db_1 = __importStar(require("../core/db"));
33
33
  const schema_1 = require("./schema");
34
- const global_schema_1 = require("../core/global_schema");
35
- const logger_1 = require("../core/logger");
36
34
  class BaseField {
37
35
  logValue(val) {
38
36
  if (this.sensitive) {
@@ -527,11 +525,10 @@ class EnumField extends BaseField {
527
525
  type: options.tsType,
528
526
  graphQLType: options.graphQLType,
529
527
  disableUnknownType: options.disableUnknownType,
530
- globalType: options.globalType,
531
528
  };
532
529
  if (!options.foreignKey) {
533
- if (!options.values && !options.map && !options.globalType) {
534
- throw new Error("values, map or globalType required if not look up table enum. Look-up table enum indicated by foreignKey field");
530
+ if (!options.values && !options.map) {
531
+ throw new Error("values or map required if not look up table enum. Look-up table enum indicated by foreignKey field");
535
532
  }
536
533
  if (options.values) {
537
534
  if (!options.values.length) {
@@ -550,8 +547,8 @@ class EnumField extends BaseField {
550
547
  }
551
548
  }
552
549
  else {
553
- if (options.values || options.map || options.globalType) {
554
- throw new Error("cannot specify values, map or globalType and foreign key for lookup table enum type");
550
+ if (options.values || options.map) {
551
+ throw new Error("cannot specify values or map and foreign key for lookup table enum type");
555
552
  }
556
553
  if (options.createEnumType) {
557
554
  throw new Error("cannot specify createEnumType without specifying values");
@@ -566,20 +563,7 @@ class EnumField extends BaseField {
566
563
  this.values = options.values;
567
564
  this.map = options.map;
568
565
  }
569
- async valid(val) {
570
- if (this.type.globalType) {
571
- const f = (0, global_schema_1.__getGlobalSchemaField)(this.type.globalType);
572
- if (f) {
573
- if (f.valid) {
574
- return f.valid(val);
575
- }
576
- return true;
577
- }
578
- else {
579
- (0, logger_1.log)("error", `globalType ${this.type.globalType} not found in global schema`);
580
- return false;
581
- }
582
- }
566
+ valid(val) {
583
567
  // lookup table enum and indicated via presence of foreignKey
584
568
  if (!this.values && !this.map) {
585
569
  return true;
@@ -597,13 +581,6 @@ class EnumField extends BaseField {
597
581
  return false;
598
582
  }
599
583
  format(val) {
600
- if (this.type.globalType) {
601
- const f = (0, global_schema_1.__getGlobalSchemaField)(this.type.globalType);
602
- if (f && f.format) {
603
- return f.format(val);
604
- }
605
- return val;
606
- }
607
584
  return val;
608
585
  }
609
586
  }
@@ -626,46 +603,21 @@ class IntegerEnumField extends BaseField {
626
603
  graphQLType: options.graphQLType,
627
604
  deprecatedIntEnumMap: options.deprecated,
628
605
  disableUnknownType: options.disableUnknownType,
629
- globalType: options.globalType,
630
606
  };
631
- if (options.foreignKey) {
632
- throw new Error(`foreignKey on intEnum not supported`);
607
+ let count = 0;
608
+ for (const _ in options.map) {
609
+ count++;
610
+ break;
633
611
  }
634
- if (options.globalType) {
635
- if (options.map) {
636
- throw new Error(`cannot specify map and globalType`);
637
- }
638
- this.map = {};
612
+ if (!count) {
613
+ throw new Error("need at least one entry in enum map");
639
614
  }
640
- else {
641
- let count = 0;
642
- for (const _ in options.map) {
643
- count++;
644
- break;
645
- }
646
- if (!count) {
647
- throw new Error("need at least one entry in enum map");
648
- }
649
- if (!options.map) {
650
- throw new Error("map required if not globalType");
651
- }
652
- this.map = options.map;
615
+ if (options.foreignKey) {
616
+ throw new Error(`foreignKey on intEnum not supported`);
653
617
  }
618
+ this.map = options.map;
654
619
  }
655
- async valid(val) {
656
- if (this.type?.globalType) {
657
- const f = (0, global_schema_1.__getGlobalSchemaField)(this.type.globalType);
658
- if (f) {
659
- if (f.valid) {
660
- return f.valid(val);
661
- }
662
- return true;
663
- }
664
- else {
665
- (0, logger_1.log)("error", `globalType ${this.type.globalType} not found in global schema`);
666
- return false;
667
- }
668
- }
620
+ valid(val) {
669
621
  // lookup table enum and indicated via presence of foreignKey
670
622
  for (const k in this.map) {
671
623
  const v = this.map[k];
@@ -676,12 +628,6 @@ class IntegerEnumField extends BaseField {
676
628
  return false;
677
629
  }
678
630
  format(val) {
679
- if (this.type.globalType) {
680
- const f = (0, global_schema_1.__getGlobalSchemaField)(this.type.globalType);
681
- if (f && f.format) {
682
- return f.format(val);
683
- }
684
- }
685
631
  return parseInt(val);
686
632
  }
687
633
  }
@@ -17,7 +17,6 @@ export interface GlobalSchema {
17
17
  extraEdgeFields?: FieldMap;
18
18
  transformEdgeRead?: () => Clause;
19
19
  transformEdgeWrite?: (stmt: EdgeUpdateOperation) => TransformedEdgeUpdateOperation | null;
20
- fields?: FieldMap;
21
20
  }
22
21
  type FieldOverride = Pick<FieldOptions, "nullable" | "storageKey" | "serverDefault" | "unique" | "hideFromGraphQL" | "graphqlName" | "index">;
23
22
  export type FieldOverrideMap = {
@@ -172,7 +171,6 @@ export interface Type {
172
171
  intEnumMap?: IntEnumMap;
173
172
  deprecatedIntEnumMap?: IntEnumMap;
174
173
  disableUnknownType?: boolean;
175
- globalType?: string;
176
174
  importType?: DeprecatedImportType;
177
175
  subFields?: FieldMap;
178
176
  unionFields?: FieldMap;
@@ -1,22 +1,20 @@
1
1
  import { BaseField, ListField } from "./field";
2
2
  import { FieldOptions, Field, Type, FieldMap } from "./schema";
3
- interface structFieldOptions extends FieldOptions {
3
+ export interface StructOptions extends FieldOptions {
4
4
  tsType: string;
5
5
  fields: FieldMap;
6
6
  graphQLType?: string;
7
7
  jsonNotJSONB?: boolean;
8
8
  }
9
- interface GlobalStructOptions extends FieldOptions {
10
- globalType: string;
9
+ interface allStructOptions extends StructOptions {
10
+ jsonAsList?: boolean;
11
11
  }
12
- export type StructOptions = structFieldOptions | GlobalStructOptions;
13
12
  export declare class StructField extends BaseField implements Field {
14
13
  private options;
15
- private jsonAsList?;
16
14
  type: Type;
17
- constructor(options: StructOptions, jsonAsList?: boolean | undefined);
15
+ constructor(options: allStructOptions);
18
16
  formatImpl(obj: any, nested?: boolean): string | Object;
19
- format(obj: any, nested?: boolean): any;
17
+ format(obj: any, nested?: boolean): string | Object;
20
18
  private validImpl;
21
19
  valid(obj: any): Promise<boolean>;
22
20
  }
@@ -25,5 +23,5 @@ export declare function StructType(options: StructOptions): StructField & Struct
25
23
  * @deprecated use StructTypeAsList
26
24
  */
27
25
  export declare function StructListType(options: StructOptions): ListField;
28
- export declare function StructTypeAsList(options: StructOptions): StructField & StructOptions;
26
+ export declare function StructTypeAsList(options: allStructOptions): StructField & allStructOptions;
29
27
  export {};