@snowtop/ent 0.1.14 → 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/action.d.ts +1 -1
- package/action/executor.d.ts +2 -2
- package/action/operations.d.ts +38 -38
- package/action/orchestrator.d.ts +14 -14
- package/action/transaction.d.ts +7 -4
- 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 +2 -2
- package/testutils/db/temp_db.d.ts +1 -0
- package/testutils/db/temp_db.js +15 -1
package/action/action.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export interface Builder<TEnt extends Ent<TViewer>, TViewer extends Viewer = Vie
|
|
|
24
24
|
getInput(): Data;
|
|
25
25
|
orchestrator: BuilderOrchestrator;
|
|
26
26
|
}
|
|
27
|
-
export interface Executor extends Iterable<DataOperation
|
|
27
|
+
export interface Executor extends Iterable<DataOperation<Ent>>, Iterator<DataOperation<Ent>> {
|
|
28
28
|
placeholderID: ID;
|
|
29
29
|
resolveValue(val: any): Ent | null;
|
|
30
30
|
builderOpChanged(builder: Builder<any>): boolean;
|
package/action/executor.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export declare class ComplexExecutor<T extends Ent> implements Executor {
|
|
|
40
40
|
private executors;
|
|
41
41
|
private changedOps;
|
|
42
42
|
builder?: Builder<Ent> | undefined;
|
|
43
|
-
constructor(viewer: Viewer, placeholderID: ID, operations: DataOperation[], dependencies: Map<ID, Builder<T>>, changesets: Changeset[], options?: OrchestratorOptions<T, Data, Viewer>, complexOptions?: ComplexExecutorOptions | undefined);
|
|
43
|
+
constructor(viewer: Viewer, placeholderID: ID, operations: DataOperation<T>[], dependencies: Map<ID, Builder<T>>, changesets: Changeset[], options?: OrchestratorOptions<T, Data, Viewer>, complexOptions?: ComplexExecutorOptions | undefined);
|
|
44
44
|
[Symbol.iterator](): this;
|
|
45
45
|
private handleCreatedEnt;
|
|
46
46
|
next(): IteratorResult<DataOperation<Ent>>;
|
|
@@ -51,5 +51,5 @@ export declare class ComplexExecutor<T extends Ent> implements Executor {
|
|
|
51
51
|
preFetch?(queryer: Queryer, context: Context): Promise<void>;
|
|
52
52
|
postFetch?(queryer: Queryer, context: Context): Promise<void>;
|
|
53
53
|
}
|
|
54
|
-
export declare function executeOperations(executor: Executor, context?: Context, trackOps?: true): Promise<DataOperation<Ent<Viewer<Ent<any> | null, ID | null
|
|
54
|
+
export declare function executeOperations(executor: Executor, context?: Context, trackOps?: true): Promise<DataOperation<Ent<Viewer<Ent<any> | null, ID | null>>, Viewer<Ent<any> | null, ID | null>>[]>;
|
|
55
55
|
export {};
|
package/action/operations.d.ts
CHANGED
|
@@ -3,62 +3,62 @@ import { Viewer, Ent, ID, Data, DataOptions, EditRowOptions, LoadEntOptions, Con
|
|
|
3
3
|
import { Executor } from "../action/action";
|
|
4
4
|
import { WriteOperation, Builder } from "../action";
|
|
5
5
|
import { AssocEdgeData, parameterizedQueryOptions } from "../core/ent";
|
|
6
|
-
export interface UpdatedOperation {
|
|
6
|
+
export interface UpdatedOperation<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer> {
|
|
7
7
|
operation: WriteOperation;
|
|
8
|
-
builder: Builder<
|
|
8
|
+
builder: Builder<TEnt, TViewer>;
|
|
9
9
|
}
|
|
10
|
-
export interface DataOperation<
|
|
11
|
-
builder: Builder<
|
|
10
|
+
export interface DataOperation<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer> {
|
|
11
|
+
builder: Builder<TEnt, TViewer>;
|
|
12
12
|
preFetch?(queryer: Queryer, context?: Context): Promise<void>;
|
|
13
13
|
performWriteSync(queryer: SyncQueryer, context?: Context): void;
|
|
14
14
|
performWrite(queryer: Queryer, context?: Context): Promise<void>;
|
|
15
15
|
placeholderID?: ID;
|
|
16
16
|
returnedRow?(): Data | null;
|
|
17
|
-
createdEnt?(viewer: Viewer):
|
|
17
|
+
createdEnt?(viewer: Viewer): TEnt | null;
|
|
18
18
|
shortCircuit?(executor: Executor): boolean;
|
|
19
|
-
updatedOperation?(): UpdatedOperation | null;
|
|
19
|
+
updatedOperation?(): UpdatedOperation<TEnt, TViewer> | null;
|
|
20
20
|
resolve?(executor: Executor): void;
|
|
21
21
|
postFetch?(queryer: Queryer, context?: Context): Promise<void>;
|
|
22
22
|
}
|
|
23
|
-
export declare class DeleteNodeOperation implements DataOperation {
|
|
23
|
+
export declare class DeleteNodeOperation<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer> implements DataOperation<TEnt, TViewer> {
|
|
24
24
|
private id;
|
|
25
|
-
readonly builder: Builder<
|
|
25
|
+
readonly builder: Builder<TEnt, TViewer>;
|
|
26
26
|
private options;
|
|
27
|
-
constructor(id: ID, builder: Builder<
|
|
27
|
+
constructor(id: ID, builder: Builder<TEnt, TViewer>, options: DataOptions);
|
|
28
28
|
performWrite(queryer: Queryer, context?: Context): Promise<void>;
|
|
29
29
|
performWriteSync(queryer: SyncQueryer, context?: Context): void;
|
|
30
30
|
}
|
|
31
|
-
export declare class RawQueryOperation<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer> implements DataOperation<TEnt> {
|
|
31
|
+
export declare class RawQueryOperation<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer> implements DataOperation<TEnt, TViewer> {
|
|
32
32
|
builder: Builder<TEnt, TViewer>;
|
|
33
33
|
private queries;
|
|
34
34
|
constructor(builder: Builder<TEnt, TViewer>, queries: (string | parameterizedQueryOptions)[]);
|
|
35
35
|
performWrite(queryer: Queryer, context?: Context): Promise<void>;
|
|
36
36
|
performWriteSync(queryer: SyncQueryer, context?: Context): void;
|
|
37
37
|
}
|
|
38
|
-
export interface EditNodeOptions<
|
|
38
|
+
export interface EditNodeOptions<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer> extends EditRowOptions {
|
|
39
39
|
fieldsToResolve: string[];
|
|
40
|
-
loadEntOptions: LoadEntOptions<
|
|
40
|
+
loadEntOptions: LoadEntOptions<TEnt>;
|
|
41
41
|
key: string;
|
|
42
42
|
onConflict?: CreateRowOptions["onConflict"];
|
|
43
|
-
builder: Builder<
|
|
43
|
+
builder: Builder<TEnt, TViewer>;
|
|
44
44
|
}
|
|
45
|
-
export declare class NoOperation<
|
|
46
|
-
builder: Builder<
|
|
45
|
+
export declare class NoOperation<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer> implements DataOperation<TEnt, TViewer> {
|
|
46
|
+
builder: Builder<TEnt, TViewer>;
|
|
47
47
|
private row;
|
|
48
|
-
constructor(builder: Builder<
|
|
48
|
+
constructor(builder: Builder<TEnt, TViewer>, existingEnt?: Ent | null);
|
|
49
49
|
performWrite(queryer: Queryer, context?: Context): Promise<void>;
|
|
50
50
|
performWriteSync(queryer: SyncQueryer, context?: Context): void;
|
|
51
51
|
returnedRow(): Data | null;
|
|
52
52
|
}
|
|
53
|
-
export declare class EditNodeOperation<
|
|
54
|
-
options: EditNodeOptions<
|
|
53
|
+
export declare class EditNodeOperation<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer> implements DataOperation<TEnt, TViewer> {
|
|
54
|
+
options: EditNodeOptions<TEnt, TViewer>;
|
|
55
55
|
private existingEnt;
|
|
56
56
|
private row;
|
|
57
57
|
placeholderID?: ID | undefined;
|
|
58
58
|
private updatedOp;
|
|
59
|
-
builder: Builder<
|
|
59
|
+
builder: Builder<TEnt, TViewer>;
|
|
60
60
|
private resolved;
|
|
61
|
-
constructor(options: EditNodeOptions<
|
|
61
|
+
constructor(options: EditNodeOptions<TEnt, TViewer>, existingEnt?: Ent | null);
|
|
62
62
|
resolve<T extends Ent>(executor: Executor): void;
|
|
63
63
|
private hasData;
|
|
64
64
|
private buildOnConflictQuery;
|
|
@@ -67,8 +67,8 @@ export declare class EditNodeOperation<T extends Ent> implements DataOperation {
|
|
|
67
67
|
private reloadRow;
|
|
68
68
|
performWriteSync(queryer: SyncQueryer, context?: Context): void;
|
|
69
69
|
returnedRow(): Data | null;
|
|
70
|
-
createdEnt(viewer: Viewer):
|
|
71
|
-
updatedOperation(): UpdatedOperation | null;
|
|
70
|
+
createdEnt(viewer: Viewer): TEnt | null;
|
|
71
|
+
updatedOperation(): UpdatedOperation<TEnt, TViewer> | null;
|
|
72
72
|
}
|
|
73
73
|
export interface AssocEdgeInputOptions extends AssocEdgeOptions {
|
|
74
74
|
time?: Date;
|
|
@@ -85,8 +85,8 @@ export interface AssocEdgeInput extends AssocEdgeInputOptions {
|
|
|
85
85
|
id2: ID;
|
|
86
86
|
id2Type: string;
|
|
87
87
|
}
|
|
88
|
-
export declare class EdgeOperation implements DataOperation {
|
|
89
|
-
builder: Builder<any>;
|
|
88
|
+
export declare class EdgeOperation<TViewer extends Viewer = Viewer> implements DataOperation<any, TViewer> {
|
|
89
|
+
builder: Builder<any, TViewer>;
|
|
90
90
|
edgeInput: AssocEdgeInput;
|
|
91
91
|
private options;
|
|
92
92
|
private edgeData;
|
|
@@ -102,33 +102,33 @@ export declare class EdgeOperation implements DataOperation {
|
|
|
102
102
|
private performInsertWriteSync;
|
|
103
103
|
private resolveImpl;
|
|
104
104
|
resolve(executor: Executor): void;
|
|
105
|
-
symmetricEdge(): EdgeOperation
|
|
106
|
-
inverseEdge(edgeData: AssocEdgeData): EdgeOperation
|
|
105
|
+
symmetricEdge(): EdgeOperation<TViewer>;
|
|
106
|
+
inverseEdge(edgeData: AssocEdgeData): EdgeOperation<TViewer>;
|
|
107
107
|
private static resolveIDs;
|
|
108
108
|
private static isBuilder;
|
|
109
109
|
private static resolveData;
|
|
110
|
-
static inboundEdge<T extends Ent
|
|
111
|
-
static outboundEdge<T extends Ent
|
|
112
|
-
static removeInboundEdge<T extends Ent>(builder: Builder<T>, edgeType: string, id1: ID, options?: AssocEdgeInputOptions): EdgeOperation
|
|
113
|
-
static removeOutboundEdge<T extends Ent>(builder: Builder<T>, edgeType: string, id2: ID, options?: AssocEdgeInputOptions): EdgeOperation
|
|
110
|
+
static inboundEdge<T extends Ent<TViewer>, T2 extends Ent<TViewer>, TViewer extends Viewer = Viewer>(builder: Builder<T, TViewer>, edgeType: string, id1: Builder<T2, TViewer> | ID, nodeType: string, options?: AssocEdgeInputOptions): EdgeOperation<TViewer>;
|
|
111
|
+
static outboundEdge<T extends Ent<TViewer>, T2 extends Ent<TViewer>, TViewer extends Viewer = Viewer>(builder: Builder<T, TViewer>, edgeType: string, id2: Builder<T2, TViewer> | ID, nodeType: string, options?: AssocEdgeInputOptions): EdgeOperation<TViewer>;
|
|
112
|
+
static removeInboundEdge<T extends Ent<TViewer>, TViewer extends Viewer = Viewer>(builder: Builder<T, TViewer>, edgeType: string, id1: ID, options?: AssocEdgeInputOptions): EdgeOperation<TViewer>;
|
|
113
|
+
static removeOutboundEdge<T extends Ent<TViewer>, TViewer extends Viewer = Viewer>(builder: Builder<T, TViewer>, edgeType: string, id2: ID, options?: AssocEdgeInputOptions): EdgeOperation<TViewer>;
|
|
114
114
|
}
|
|
115
|
-
export declare class ConditionalOperation<
|
|
116
|
-
protected op: DataOperation<
|
|
115
|
+
export declare class ConditionalOperation<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer> implements DataOperation<TEnt, TViewer> {
|
|
116
|
+
protected op: DataOperation<TEnt, TViewer>;
|
|
117
117
|
private conditionalBuilder;
|
|
118
118
|
placeholderID?: ID | undefined;
|
|
119
119
|
protected shortCircuited: boolean;
|
|
120
|
-
readonly builder: Builder<
|
|
121
|
-
constructor(op: DataOperation<
|
|
120
|
+
readonly builder: Builder<TEnt, TViewer>;
|
|
121
|
+
constructor(op: DataOperation<TEnt, TViewer>, conditionalBuilder: Builder<TEnt, TViewer>);
|
|
122
122
|
shortCircuit(executor: Executor): boolean;
|
|
123
123
|
preFetch(queryer: Queryer, context?: Context<Viewer<Ent<any> | null, ID | null>> | undefined): Promise<void>;
|
|
124
124
|
performWriteSync(queryer: SyncQueryer, context?: Context<Viewer<Ent<any> | null, ID | null>> | undefined): void;
|
|
125
125
|
performWrite(queryer: Queryer, context?: Context<Viewer<Ent<any> | null, ID | null>> | undefined): Promise<void>;
|
|
126
126
|
returnedRow(): Data | null;
|
|
127
|
-
updatedOperation(): UpdatedOperation | null;
|
|
127
|
+
updatedOperation(): UpdatedOperation<TEnt, TViewer> | null;
|
|
128
128
|
resolve(executor: Executor): void;
|
|
129
129
|
postFetch(queryer: Queryer, context?: Context<Viewer<Ent<any> | null, ID | null>> | undefined): Promise<void>;
|
|
130
130
|
}
|
|
131
|
-
export declare class ConditionalNodeOperation<
|
|
132
|
-
createdEnt(viewer: Viewer):
|
|
133
|
-
updatedOperation(): UpdatedOperation | null;
|
|
131
|
+
export declare class ConditionalNodeOperation<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer> extends ConditionalOperation<TEnt, TViewer> {
|
|
132
|
+
createdEnt(viewer: Viewer): TEnt | null;
|
|
133
|
+
updatedOperation(): UpdatedOperation<TEnt, TViewer> | null;
|
|
134
134
|
}
|
package/action/orchestrator.d.ts
CHANGED
|
@@ -21,14 +21,14 @@ export interface OrchestratorOptions<TEnt extends Ent<TViewer>, TInput extends D
|
|
|
21
21
|
expressions?: Map<string, clause.Clause>;
|
|
22
22
|
fieldInfo: FieldInfoMap;
|
|
23
23
|
}
|
|
24
|
-
interface edgeInputDataOpts {
|
|
24
|
+
interface edgeInputDataOpts<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer> {
|
|
25
25
|
edgeType: string;
|
|
26
|
-
id: Builder<
|
|
26
|
+
id: Builder<TEnt, TViewer> | ID;
|
|
27
27
|
nodeType?: string;
|
|
28
28
|
options?: AssocEdgeInputOptions;
|
|
29
29
|
}
|
|
30
|
-
export interface EdgeInputData extends edgeInputDataOpts {
|
|
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;
|
|
@@ -108,24 +108,24 @@ export declare class Orchestrator<TEnt extends Ent<TViewer>, TInput extends Data
|
|
|
108
108
|
editedEnt(): Promise<TEnt | null>;
|
|
109
109
|
editedEntX(): Promise<TEnt>;
|
|
110
110
|
}
|
|
111
|
-
export declare class EntChangeset<
|
|
111
|
+
export declare class EntChangeset<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer> implements Changeset {
|
|
112
112
|
viewer: Viewer;
|
|
113
113
|
private builder;
|
|
114
114
|
readonly placeholderID: ID;
|
|
115
115
|
private conditionalOverride;
|
|
116
|
-
operations: DataOperation[];
|
|
116
|
+
operations: DataOperation<any, TViewer>[];
|
|
117
117
|
dependencies?: Map<ID, Builder<Ent<Viewer<Ent<any> | null, ID | null>>, Viewer<Ent<any> | null, ID | null>, Ent<Viewer<Ent<any> | null, ID | null>> | null>> | undefined;
|
|
118
118
|
changesets?: Changeset[] | undefined;
|
|
119
119
|
private options?;
|
|
120
120
|
private _executor;
|
|
121
|
-
constructor(viewer: Viewer, builder: Builder<
|
|
122
|
-
static changesetFrom(builder: Builder<
|
|
123
|
-
static changesetFromQueries(builder: Builder<
|
|
121
|
+
constructor(viewer: Viewer, builder: Builder<TEnt, TViewer>, placeholderID: ID, conditionalOverride: boolean, operations: DataOperation<any, TViewer>[], dependencies?: Map<ID, Builder<Ent<Viewer<Ent<any> | null, ID | null>>, Viewer<Ent<any> | null, ID | null>, Ent<Viewer<Ent<any> | null, ID | null>> | null>> | undefined, changesets?: Changeset[] | undefined, options?: OrchestratorOptions<TEnt, Data, TViewer, MaybeNull<TEnt>> | undefined);
|
|
122
|
+
static changesetFrom<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer>(builder: Builder<TEnt, TViewer, any>, ops: DataOperation<any, TViewer>[]): EntChangeset<any, TViewer>;
|
|
123
|
+
static changesetFromQueries<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer>(builder: Builder<TEnt, TViewer, any>, queries: Array<string | parameterizedQueryOptions>): EntChangeset<any, TViewer>;
|
|
124
124
|
private static changesetFromEdgeOp;
|
|
125
|
-
static changesetFromOutboundEdge(builder: Builder<
|
|
126
|
-
static changesetFromInboundEdge(builder: Builder<
|
|
127
|
-
static changesetRemoveFromOutboundEdge(builder: Builder<
|
|
128
|
-
static changesetRemoveFromInboundEdge(builder: Builder<
|
|
125
|
+
static changesetFromOutboundEdge<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer>(builder: Builder<TEnt, TViewer, any>, edgeType: string, id2: Builder<any, TViewer> | ID, nodeType: string, options?: AssocEdgeInputOptions): Promise<EntChangeset<any, TViewer>>;
|
|
126
|
+
static changesetFromInboundEdge<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer>(builder: Builder<TEnt, TViewer, any>, edgeType: string, id1: Builder<any, TViewer> | ID, nodeType: string, options?: AssocEdgeInputOptions): Promise<EntChangeset<any, TViewer>>;
|
|
127
|
+
static changesetRemoveFromOutboundEdge<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer>(builder: Builder<TEnt, TViewer, any>, edgeType: string, id2: ID, options?: AssocEdgeInputOptions): Promise<EntChangeset<any, TViewer>>;
|
|
128
|
+
static changesetRemoveFromInboundEdge<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer>(builder: Builder<TEnt, TViewer, any>, edgeType: string, id1: ID, options?: AssocEdgeInputOptions): Promise<EntChangeset<any, TViewer>>;
|
|
129
129
|
executor(): Executor;
|
|
130
130
|
}
|
|
131
131
|
export {};
|
package/action/transaction.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { Ent, Viewer } from "../core/base";
|
|
2
|
-
import { Action
|
|
3
|
-
|
|
1
|
+
import { Ent, Viewer, Data } from "../core/base";
|
|
2
|
+
import { Action } from "./action";
|
|
3
|
+
import { EntBuilder } from "./experimental_action";
|
|
4
|
+
type MaybeNull<T extends Ent> = T | null;
|
|
5
|
+
type TMaybleNullableEnt<T extends Ent> = T | MaybeNull<T>;
|
|
6
|
+
type ActionAny<TEnt extends Ent<TViewer>, TViewer extends Viewer, TInput extends Data, TExistingEnt extends TMaybleNullableEnt<TEnt> = MaybeNull<TEnt>> = Action<TEnt, EntBuilder<TEnt, TViewer, TInput, TExistingEnt>, TViewer, TInput, TExistingEnt>;
|
|
4
7
|
export declare class Transaction<TViewer extends Viewer = Viewer> {
|
|
5
8
|
private viewer;
|
|
6
9
|
private actions;
|
|
7
|
-
constructor(viewer: TViewer, actions: ActionAny<TViewer>[]);
|
|
10
|
+
constructor(viewer: TViewer, actions: ActionAny<any, TViewer, Data>[]);
|
|
8
11
|
run(): Promise<void>;
|
|
9
12
|
}
|
|
10
13
|
export {};
|
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),
|
|
@@ -7,7 +7,7 @@ import { MockLogs } from "../../testutils/mock_log";
|
|
|
7
7
|
import { Table } from "../db/temp_db";
|
|
8
8
|
export declare function setupTest(): void;
|
|
9
9
|
export declare function getML(): MockLogs;
|
|
10
|
-
export declare function getOperations(): DataOperation<
|
|
10
|
+
export declare function getOperations(): DataOperation<any, Viewer<Ent<any> | null, ID | null>>[];
|
|
11
11
|
export declare const UserSchema: BuilderSchema<User>;
|
|
12
12
|
export declare class UserWithBalance extends User {
|
|
13
13
|
}
|
|
@@ -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) => SimpleAction<Ent>;
|
|
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
|
}
|