@snowtop/ent 0.1.0-alpha80 → 0.1.0-alpha81
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/schema/field.d.ts +5 -1
- package/schema/field.js +12 -7
- package/schema/struct_field.js +1 -1
- package/scripts/custom_graphql.js +2 -2
- package/scripts/migrate_v0.1.js +1 -1
package/package.json
CHANGED
package/schema/field.d.ts
CHANGED
|
@@ -165,11 +165,15 @@ export declare class IntegerEnumField extends BaseField implements Field {
|
|
|
165
165
|
format(val: any): any;
|
|
166
166
|
}
|
|
167
167
|
export declare function IntegerEnumType(options: IntegerEnumOptions): IntegerEnumField;
|
|
168
|
+
interface ListOptions extends FieldOptions {
|
|
169
|
+
disableJSONStringify?: boolean;
|
|
170
|
+
}
|
|
168
171
|
export declare class ListField extends BaseField {
|
|
169
172
|
private field;
|
|
173
|
+
private options?;
|
|
170
174
|
type: Type;
|
|
171
175
|
private validators;
|
|
172
|
-
constructor(field: Field, options?:
|
|
176
|
+
constructor(field: Field, options?: ListOptions | undefined);
|
|
173
177
|
__getElemField(): Field;
|
|
174
178
|
validate(validator: (val: any[]) => boolean): this;
|
|
175
179
|
valid(val: any): Promise<boolean>;
|
package/schema/field.js
CHANGED
|
@@ -22,10 +22,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
22
22
|
exports.UUIDListType = exports.IntegerEnumListType = exports.EnumListType = exports.DateListType = exports.TimetzListType = exports.TimeListType = exports.TimestamptzListType = exports.TimestampListType = exports.BooleanListType = exports.BigIntegerListType = exports.FloatListType = exports.IntegerListType = exports.IntListType = exports.StringListType = exports.ListField = exports.IntegerEnumType = exports.IntegerEnumField = exports.EnumType = exports.StringEnumField = exports.EnumField = exports.DateType = exports.DateField = exports.TimetzType = exports.TimeType = exports.TimeField = exports.leftPad = exports.TimestamptzType = exports.TimestampType = exports.TimestampField = exports.StringType = exports.StringField = exports.BooleanType = exports.BooleanField = exports.FloatType = exports.FloatField = exports.BigIntegerType = exports.BigIntegerField = exports.IntegerType = exports.IntegerField = exports.UUIDType = exports.UUIDField = exports.BaseField = void 0;
|
|
23
23
|
const luxon_1 = require("luxon");
|
|
24
24
|
const snake_case_1 = require("snake-case");
|
|
25
|
-
const db_1 = __importStar(require("../core/db"));
|
|
26
|
-
const schema_1 = require("./schema");
|
|
27
25
|
const util_1 = require("util");
|
|
28
26
|
const uuid_1 = require("uuid");
|
|
27
|
+
const db_1 = __importStar(require("../core/db"));
|
|
28
|
+
const schema_1 = require("./schema");
|
|
29
29
|
class BaseField {
|
|
30
30
|
logValue(val) {
|
|
31
31
|
if (this.sensitive) {
|
|
@@ -608,6 +608,7 @@ class ListField extends BaseField {
|
|
|
608
608
|
constructor(field, options) {
|
|
609
609
|
super();
|
|
610
610
|
this.field = field;
|
|
611
|
+
this.options = options;
|
|
611
612
|
this.validators = [];
|
|
612
613
|
if (field.type.dbType === schema_1.DBType.List) {
|
|
613
614
|
throw new Error(`nested lists not currently supported`);
|
|
@@ -648,11 +649,12 @@ class ListField extends BaseField {
|
|
|
648
649
|
return result;
|
|
649
650
|
}
|
|
650
651
|
postgresVal(val, jsonType) {
|
|
651
|
-
if (!jsonType) {
|
|
652
|
+
if (!jsonType && val === "") {
|
|
652
653
|
// support empty strings in list
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
654
|
+
val = '"' + val + '"';
|
|
655
|
+
return val;
|
|
656
|
+
}
|
|
657
|
+
if (this.options?.disableJSONStringify) {
|
|
656
658
|
return val;
|
|
657
659
|
}
|
|
658
660
|
return JSON.stringify(val);
|
|
@@ -789,6 +791,9 @@ function IntegerEnumListType(options) {
|
|
|
789
791
|
}
|
|
790
792
|
exports.IntegerEnumListType = IntegerEnumListType;
|
|
791
793
|
function UUIDListType(options) {
|
|
792
|
-
return new ListField(UUIDType(options),
|
|
794
|
+
return new ListField(UUIDType(options), {
|
|
795
|
+
...options,
|
|
796
|
+
disableJSONStringify: true,
|
|
797
|
+
});
|
|
793
798
|
}
|
|
794
799
|
exports.UUIDListType = UUIDListType;
|
package/schema/struct_field.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StructTypeAsList = exports.StructListType = exports.StructType = exports.StructField = void 0;
|
|
4
|
+
const camel_case_1 = require("camel-case");
|
|
4
5
|
const field_1 = require("./field");
|
|
5
6
|
const schema_1 = require("./schema");
|
|
6
|
-
const camel_case_1 = require("camel-case");
|
|
7
7
|
class StructField extends field_1.BaseField {
|
|
8
8
|
constructor(options) {
|
|
9
9
|
super();
|
|
@@ -26,10 +26,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
const glob_1 = __importDefault(require("glob"));
|
|
27
27
|
const json5_1 = __importDefault(require("json5"));
|
|
28
28
|
const minimist_1 = __importDefault(require("minimist"));
|
|
29
|
-
const graphql_1 = require("../graphql/graphql");
|
|
30
|
-
const readline = __importStar(require("readline"));
|
|
31
29
|
const path = __importStar(require("path"));
|
|
32
30
|
const fs = __importStar(require("fs"));
|
|
31
|
+
const graphql_1 = require("../graphql/graphql");
|
|
32
|
+
const readline = __importStar(require("readline"));
|
|
33
33
|
const imports_1 = require("../imports");
|
|
34
34
|
const process_1 = require("process");
|
|
35
35
|
// need to use the GQLCapture from the package so that when we call GQLCapture.enable()
|
package/scripts/migrate_v0.1.js
CHANGED
|
@@ -3,12 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const minimist_1 = __importDefault(require("minimist"));
|
|
6
7
|
const transform_1 = require("../tsc/transform");
|
|
7
8
|
const transform_schema_1 = require("../tsc/transform_schema");
|
|
8
9
|
const transform_ent_1 = require("../tsc/transform_ent");
|
|
9
10
|
const move_generated_1 = require("../tsc/move_generated");
|
|
10
11
|
const transform_action_1 = require("../tsc/transform_action");
|
|
11
|
-
const minimist_1 = __importDefault(require("minimist"));
|
|
12
12
|
const ast_1 = require("../tsc/ast");
|
|
13
13
|
// todo-sqlite
|
|
14
14
|
// ts-node-script --swc --project ./tsconfig.json -r tsconfig-paths/register ../../ts/src/scripts/migrate_v0.1.ts --transform_schema --old_base_class BaseEntTodoSchema --new_schema_class TodoEntSchema --transform_path src/schema/patterns/base
|