@snowtop/ent 0.1.14-test3 → 0.1.15
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/action/orchestrator.d.ts +3 -3
- package/core/convert.d.ts +3 -0
- package/core/convert.js +15 -1
- package/package.json +1 -1
- package/schema/binary_field.d.ts +14 -0
- package/schema/binary_field.js +53 -0
- package/schema/index.d.ts +1 -0
- package/schema/index.js +1 -0
- package/schema/schema.d.ts +2 -0
- package/schema/schema.js +2 -0
- package/scripts/custom_graphql.js +4 -0
- package/testutils/action/complex_schemas.d.ts +1 -1
- package/testutils/db/temp_db.d.ts +1 -0
- package/testutils/db/temp_db.js +15 -1
package/action/orchestrator.d.ts
CHANGED
|
@@ -27,8 +27,8 @@ interface edgeInputDataOpts<TEnt extends Ent<TViewer>, TViewer extends Viewer =
|
|
|
27
27
|
nodeType?: string;
|
|
28
28
|
options?: AssocEdgeInputOptions;
|
|
29
29
|
}
|
|
30
|
-
export interface EdgeInputData<
|
|
31
|
-
isBuilder(id: Builder<
|
|
30
|
+
export interface EdgeInputData<TViewer extends Viewer = Viewer> extends edgeInputDataOpts<any, TViewer> {
|
|
31
|
+
isBuilder(id: Builder<any, TViewer> | ID): id is Builder<any, TViewer>;
|
|
32
32
|
}
|
|
33
33
|
export declare enum edgeDirection {
|
|
34
34
|
inboundEdge = 0,
|
|
@@ -62,7 +62,7 @@ export declare class Orchestrator<TEnt extends Ent<TViewer>, TInput extends Data
|
|
|
62
62
|
addOutboundEdge<T2 extends Ent>(id2: ID | Builder<T2, any>, edgeType: string, nodeType: string, options?: AssocEdgeInputOptions): void;
|
|
63
63
|
removeInboundEdge(id1: ID, edgeType: string, options?: AssocEdgeOptions): void;
|
|
64
64
|
removeOutboundEdge(id2: ID, edgeType: string, options?: AssocEdgeOptions): void;
|
|
65
|
-
getInputEdges(edgeType: string, op: WriteOperation): EdgeInputData<
|
|
65
|
+
getInputEdges(edgeType: string, op: WriteOperation): EdgeInputData<TViewer>[];
|
|
66
66
|
clearInputEdges(edgeType: string, op: WriteOperation, id?: ID): void;
|
|
67
67
|
private buildMainOp;
|
|
68
68
|
private getEdgeOperation;
|
package/core/convert.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
export declare function convertDate(val: any): Date;
|
|
2
3
|
export declare function convertNullableDate(val: any): Date | null;
|
|
3
4
|
export declare function convertBool(val: any): boolean;
|
|
@@ -12,3 +13,5 @@ export declare function convertJSON(val: any): any;
|
|
|
12
13
|
export declare function convertNullableJSON(val: any): any | null;
|
|
13
14
|
export declare function convertJSONList(val: any): any[];
|
|
14
15
|
export declare function convertNullableJSONList(val: any): any[] | null;
|
|
16
|
+
export declare function convertTextToBuffer(val: any): Buffer;
|
|
17
|
+
export declare function convertNullableTextToBuffer(val: any): Buffer;
|
package/core/convert.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertNullableJSONList = exports.convertJSONList = exports.convertNullableJSON = exports.convertJSON = exports.convertNullableBoolList = exports.convertBoolList = exports.convertNullableDateList = exports.convertDateList = exports.convertNullableList = exports.convertList = exports.convertNullableBool = exports.convertBool = exports.convertNullableDate = exports.convertDate = void 0;
|
|
3
|
+
exports.convertNullableTextToBuffer = exports.convertTextToBuffer = exports.convertNullableJSONList = exports.convertJSONList = exports.convertNullableJSON = exports.convertJSON = exports.convertNullableBoolList = exports.convertBoolList = exports.convertNullableDateList = exports.convertDateList = exports.convertNullableList = exports.convertList = exports.convertNullableBool = exports.convertBool = exports.convertNullableDate = exports.convertDate = void 0;
|
|
4
4
|
const luxon_1 = require("luxon");
|
|
5
5
|
// these are needed to deal with SQLite having different types stored in the db vs the representation
|
|
6
6
|
// gotten back from the db/needed in ent land
|
|
@@ -104,3 +104,17 @@ function convertNullableJSONList(val) {
|
|
|
104
104
|
return convertNullableList(val, convertJSON);
|
|
105
105
|
}
|
|
106
106
|
exports.convertNullableJSONList = convertNullableJSONList;
|
|
107
|
+
function convertTextToBuffer(val) {
|
|
108
|
+
if (typeof val === "string") {
|
|
109
|
+
return Buffer.from(val, "base64");
|
|
110
|
+
}
|
|
111
|
+
return val;
|
|
112
|
+
}
|
|
113
|
+
exports.convertTextToBuffer = convertTextToBuffer;
|
|
114
|
+
function convertNullableTextToBuffer(val) {
|
|
115
|
+
if (val == null) {
|
|
116
|
+
return val;
|
|
117
|
+
}
|
|
118
|
+
return convertTextToBuffer(val);
|
|
119
|
+
}
|
|
120
|
+
exports.convertNullableTextToBuffer = convertNullableTextToBuffer;
|
package/package.json
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseField } from "./field";
|
|
2
|
+
import { Type, Field, FieldOptions } from "./schema";
|
|
3
|
+
export declare class ByteaField extends BaseField implements Field {
|
|
4
|
+
type: Type;
|
|
5
|
+
format(val: any): any;
|
|
6
|
+
valid(val: any): boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function ByteaType(options?: FieldOptions): ByteaField & FieldOptions;
|
|
9
|
+
export declare class BinaryTextField extends BaseField implements Field {
|
|
10
|
+
type: Type;
|
|
11
|
+
format(val: any): any;
|
|
12
|
+
valid(val: any): boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function BinaryTextType(options?: FieldOptions): BinaryTextField & FieldOptions;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BinaryTextType = exports.BinaryTextField = exports.ByteaType = exports.ByteaField = void 0;
|
|
4
|
+
const field_1 = require("./field");
|
|
5
|
+
const schema_1 = require("./schema");
|
|
6
|
+
class ByteaField extends field_1.BaseField {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.type = {
|
|
10
|
+
dbType: schema_1.DBType.Bytea,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
format(val) {
|
|
14
|
+
return val;
|
|
15
|
+
}
|
|
16
|
+
valid(val) {
|
|
17
|
+
return val instanceof Buffer;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.ByteaField = ByteaField;
|
|
21
|
+
/*
|
|
22
|
+
* NB: using this field requires the developer to run `npm i graphql-scalars` for the correct
|
|
23
|
+
* graphql types to be available.
|
|
24
|
+
*/
|
|
25
|
+
function ByteaType(options) {
|
|
26
|
+
const result = new ByteaField();
|
|
27
|
+
return Object.assign(result, options);
|
|
28
|
+
}
|
|
29
|
+
exports.ByteaType = ByteaType;
|
|
30
|
+
class BinaryTextField extends field_1.BaseField {
|
|
31
|
+
constructor() {
|
|
32
|
+
super(...arguments);
|
|
33
|
+
this.type = {
|
|
34
|
+
dbType: schema_1.DBType.StringByte,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
format(val) {
|
|
38
|
+
return val.toString("base64");
|
|
39
|
+
}
|
|
40
|
+
valid(val) {
|
|
41
|
+
return val instanceof Buffer;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.BinaryTextField = BinaryTextField;
|
|
45
|
+
/*
|
|
46
|
+
* NB: using this field requires the developer to run `npm i graphql-scalars` for the correct
|
|
47
|
+
* graphql types to be available.
|
|
48
|
+
*/
|
|
49
|
+
function BinaryTextType(options) {
|
|
50
|
+
const result = new BinaryTextField();
|
|
51
|
+
return Object.assign(result, options);
|
|
52
|
+
}
|
|
53
|
+
exports.BinaryTextType = BinaryTextType;
|
package/schema/index.d.ts
CHANGED
package/schema/index.js
CHANGED
package/schema/schema.d.ts
CHANGED
package/schema/schema.js
CHANGED
|
@@ -39,6 +39,8 @@ var DBType;
|
|
|
39
39
|
DBType["Date"] = "Date";
|
|
40
40
|
DBType["Time"] = "Time";
|
|
41
41
|
DBType["Timetz"] = "Timetz";
|
|
42
|
+
DBType["Bytea"] = "Bytea";
|
|
43
|
+
DBType["StringByte"] = "StringByte";
|
|
42
44
|
DBType["List"] = "List";
|
|
43
45
|
})(DBType = exports.DBType || (exports.DBType = {}));
|
|
44
46
|
function isSchema(value) {
|
|
@@ -363,6 +363,10 @@ async function main() {
|
|
|
363
363
|
importPath: "graphql-type-json",
|
|
364
364
|
type: "GraphQLJSON",
|
|
365
365
|
}, gqlCapture);
|
|
366
|
+
(0, graphql_1.addCustomType)({
|
|
367
|
+
importPath: "graphql-scalars",
|
|
368
|
+
type: "GraphQLByte",
|
|
369
|
+
}, gqlCapture);
|
|
366
370
|
const [inputsRead, _, __, imports] = await Promise.all([
|
|
367
371
|
readInputs(),
|
|
368
372
|
captureCustom(options.path, options.files, options.json_path, gqlCapture),
|
|
@@ -45,7 +45,7 @@ export declare class UserAction extends SimpleAction<User> {
|
|
|
45
45
|
getTriggers(): Trigger<User, SimpleBuilder<User>>[];
|
|
46
46
|
getObservers(): Observer<User, SimpleBuilder<User>>[];
|
|
47
47
|
}
|
|
48
|
-
type getMembershipFunction = (viewer: Viewer, edge: EdgeInputData<
|
|
48
|
+
type getMembershipFunction = (viewer: Viewer, edge: EdgeInputData<Viewer>) => SimpleAction<Ent>;
|
|
49
49
|
export declare class GroupMembershipTrigger implements Trigger<Group, SimpleBuilder<Group>> {
|
|
50
50
|
private getter;
|
|
51
51
|
constructor(getter: getMembershipFunction);
|
|
@@ -62,6 +62,7 @@ export declare function integer(name: string, opts?: options): Column;
|
|
|
62
62
|
export declare function float(name: string, opts?: options): Column;
|
|
63
63
|
export declare function json(name: string, opts?: options): Column;
|
|
64
64
|
export declare function jsonb(name: string, opts?: options): Column;
|
|
65
|
+
export declare function bytea(name: string, opts?: options): Column;
|
|
65
66
|
export declare function textList(name: string, opts?: options): Column;
|
|
66
67
|
export declare function integerList(name: string, opts?: options): Column;
|
|
67
68
|
export declare function uuidList(name: string, opts?: options): Column;
|
package/testutils/db/temp_db.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.getColumnFromField = exports.getSchemaTable = exports.doSQLiteTestFromSchemas = exports.setupPostgres = exports.setupSqlite = exports.assoc_edge_table = exports.assoc_edge_config_table = exports.TempDB = exports.enumType = exports.table = exports.boolList = exports.dateList = exports.timetzList = exports.timeList = exports.timestamptzList = exports.timestampList = exports.uuidList = exports.integerList = exports.textList = exports.jsonb = exports.json = exports.float = exports.integer = exports.bool = exports.date = exports.timetz = exports.time = exports.timestamptz = exports.timestamp = exports.enumCol = exports.text = exports.uuid = exports.index = exports.check = exports.foreignKey = exports.primaryKey = void 0;
|
|
29
|
+
exports.getColumnFromField = exports.getSchemaTable = exports.doSQLiteTestFromSchemas = exports.setupPostgres = exports.setupSqlite = exports.assoc_edge_table = exports.assoc_edge_config_table = exports.TempDB = exports.enumType = exports.table = exports.boolList = exports.dateList = exports.timetzList = exports.timeList = exports.timestamptzList = exports.timestampList = exports.uuidList = exports.integerList = exports.textList = exports.bytea = exports.jsonb = exports.json = exports.float = exports.integer = exports.bool = exports.date = exports.timetz = exports.time = exports.timestamptz = exports.timestamp = exports.enumCol = exports.text = exports.uuid = exports.index = exports.check = exports.foreignKey = exports.primaryKey = void 0;
|
|
30
30
|
const pg_1 = require("pg");
|
|
31
31
|
const db_1 = __importStar(require("../../core/db"));
|
|
32
32
|
// this should only be used in tests so we expect to be able to import without shenanigans
|
|
@@ -239,6 +239,16 @@ function jsonb(name, opts) {
|
|
|
239
239
|
};
|
|
240
240
|
}
|
|
241
241
|
exports.jsonb = jsonb;
|
|
242
|
+
function bytea(name, opts) {
|
|
243
|
+
return {
|
|
244
|
+
name,
|
|
245
|
+
datatype() {
|
|
246
|
+
return "BYTEA";
|
|
247
|
+
},
|
|
248
|
+
...opts,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
exports.bytea = bytea;
|
|
242
252
|
function list(name, col, opts) {
|
|
243
253
|
return {
|
|
244
254
|
name,
|
|
@@ -724,6 +734,10 @@ function getColumnForDbType(t, dialect) {
|
|
|
724
734
|
return jsonb;
|
|
725
735
|
case schema_1.DBType.JSON:
|
|
726
736
|
return json;
|
|
737
|
+
case schema_1.DBType.StringByte:
|
|
738
|
+
return text;
|
|
739
|
+
case schema_1.DBType.Bytea:
|
|
740
|
+
return bytea;
|
|
727
741
|
default:
|
|
728
742
|
return undefined;
|
|
729
743
|
}
|