@snowtop/ent 0.1.0-alpha13 → 0.1.0-alpha16
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 +19 -19
- package/action/executor.d.ts +3 -3
- package/action/executor.js +2 -2
- package/action/experimental_action.d.ts +21 -20
- package/action/experimental_action.js +10 -4
- package/action/orchestrator.d.ts +13 -13
- package/action/orchestrator.js +6 -4
- package/action/privacy.d.ts +2 -2
- package/core/base.d.ts +20 -20
- package/core/config.d.ts +5 -0
- package/core/context.d.ts +2 -2
- package/core/ent.d.ts +13 -13
- package/core/loaders/assoc_count_loader.d.ts +2 -2
- package/core/loaders/assoc_edge_loader.d.ts +2 -2
- package/core/loaders/object_loader.d.ts +3 -3
- package/core/loaders/query_loader.d.ts +2 -2
- package/core/loaders/raw_count_loader.d.ts +2 -2
- package/core/privacy.d.ts +24 -24
- package/core/query/assoc_query.d.ts +6 -6
- package/core/query/custom_query.d.ts +5 -5
- package/core/query/query.d.ts +1 -1
- package/core/viewer.d.ts +3 -3
- package/graphql/query/edge_connection.d.ts +9 -9
- package/graphql/query/page_info.d.ts +1 -1
- package/package.json +1 -1
- package/parse_schema/parse.d.ts +2 -0
- package/parse_schema/parse.js +4 -0
- package/schema/base_schema.js +3 -0
- package/schema/schema.d.ts +1 -0
- package/scripts/move_generated.js +2 -3
- package/scripts/transform_actions.d.ts +1 -0
- package/scripts/transform_actions.js +266 -0
- package/scripts/transform_code.js +1 -3
- package/testutils/builder.d.ts +10 -9
- package/testutils/builder.js +16 -3
- package/testutils/fake_data/user_query.d.ts +2 -2
- package/testutils/fake_log.d.ts +3 -3
- package/tsc/ast.d.ts +11 -0
- package/tsc/ast.js +46 -13
package/testutils/builder.js
CHANGED
|
@@ -207,6 +207,13 @@ class SimpleBuilder {
|
|
|
207
207
|
updateInput: this.updateInput.bind(this),
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
|
+
getInput() {
|
|
211
|
+
let ret = {};
|
|
212
|
+
for (const [k, v] of this.fields) {
|
|
213
|
+
ret[k] = v;
|
|
214
|
+
}
|
|
215
|
+
return ret;
|
|
216
|
+
}
|
|
210
217
|
updateInput(input) {
|
|
211
218
|
const knownFields = (0, schema_1.getFields)(this.schema);
|
|
212
219
|
for (const k in input) {
|
|
@@ -250,11 +257,17 @@ class SimpleAction {
|
|
|
250
257
|
constructor(viewer, schema, fields, operation = action_1.WriteOperation.Insert, existingEnt) {
|
|
251
258
|
this.viewer = viewer;
|
|
252
259
|
this.fields = fields;
|
|
253
|
-
this.validators = [];
|
|
254
|
-
this.triggers = [];
|
|
255
|
-
this.observers = [];
|
|
256
260
|
this.builder = new SimpleBuilder(this.viewer, schema, fields, operation, existingEnt, this);
|
|
257
261
|
}
|
|
262
|
+
getTriggers() {
|
|
263
|
+
return [];
|
|
264
|
+
}
|
|
265
|
+
getValidators() {
|
|
266
|
+
return [];
|
|
267
|
+
}
|
|
268
|
+
getObservers() {
|
|
269
|
+
return [];
|
|
270
|
+
}
|
|
258
271
|
getPrivacyPolicy() {
|
|
259
272
|
return privacy_1.AlwaysAllowPrivacyPolicy;
|
|
260
273
|
}
|
|
@@ -53,7 +53,7 @@ export declare class UserToFriendRequestsQuery extends AssocEdgeQueryBase<FakeUs
|
|
|
53
53
|
}
|
|
54
54
|
export declare class UserToIncomingFriendRequestsQuery extends AssocEdgeQueryBase<FakeUser, FakeUser, AssocEdge> {
|
|
55
55
|
constructor(viewer: Viewer, src: EdgeQuerySource<FakeUser, FakeUser>);
|
|
56
|
-
getPrivacyPolicy(): import("../../core/base").PrivacyPolicy<Ent
|
|
56
|
+
getPrivacyPolicy(): import("../../core/base").PrivacyPolicy<Ent<Viewer<Ent<any> | null, ID | null>>, Viewer<Ent<any> | null, ID | null>>;
|
|
57
57
|
sourceEnt(id: ID): Promise<FakeUser | null>;
|
|
58
58
|
static query(viewer: Viewer, src: EdgeQuerySource<FakeUser, FakeUser>): UserToIncomingFriendRequestsQuery;
|
|
59
59
|
queryContacts(): UserToContactsQuery;
|
|
@@ -90,7 +90,7 @@ export declare class UserToEventsInNextWeekQuery extends CustomEdgeQueryBase<Fak
|
|
|
90
90
|
constructor(viewer: Viewer, src: ID | FakeUser);
|
|
91
91
|
static query(viewer: Viewer, src: FakeUser | ID): UserToEventsInNextWeekQuery;
|
|
92
92
|
sourceEnt(id: ID): Promise<FakeUser | null>;
|
|
93
|
-
getPrivacyPolicy(): import("../../core/base").PrivacyPolicy<Ent
|
|
93
|
+
getPrivacyPolicy(): import("../../core/base").PrivacyPolicy<Ent<Viewer<Ent<any> | null, ID | null>>, Viewer<Ent<any> | null, ID | null>>;
|
|
94
94
|
}
|
|
95
95
|
export declare class UserToFollowingQuery extends AssocEdgeQueryBase<FakeUser, Ent, AssocEdge> {
|
|
96
96
|
constructor(viewer: Viewer, src: EdgeQuerySource<FakeUser, FakeUser>);
|
package/testutils/fake_log.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ent } from "../core/base";
|
|
1
|
+
import { Ent, Viewer } from "../core/base";
|
|
2
2
|
import { Builder } from "./../action";
|
|
3
3
|
export declare class FakeLogger {
|
|
4
4
|
private static logs;
|
|
@@ -8,6 +8,6 @@ export declare class FakeLogger {
|
|
|
8
8
|
static contains(line: string): boolean;
|
|
9
9
|
static clear(): void;
|
|
10
10
|
}
|
|
11
|
-
export declare class EntCreationObserver<
|
|
12
|
-
observe(builder: Builder<
|
|
11
|
+
export declare class EntCreationObserver<TEnt extends Ent<TViewer>, TViewer extends Viewer = Viewer> {
|
|
12
|
+
observe(builder: Builder<TEnt, TViewer>): Promise<void>;
|
|
13
13
|
}
|
package/tsc/ast.d.ts
CHANGED
|
@@ -15,7 +15,18 @@ interface transformOpts {
|
|
|
15
15
|
removeImports?: string[];
|
|
16
16
|
newImports?: string[];
|
|
17
17
|
transform?: transformImportFn;
|
|
18
|
+
transformPath?: string;
|
|
18
19
|
}
|
|
19
20
|
export declare function transformImport(fileContents: string, importNode: ts.ImportDeclaration, sourceFile: ts.SourceFile, opts?: transformOpts): string | undefined;
|
|
20
21
|
export declare function updateImportPath(fileContents: string, importNode: ts.ImportDeclaration, sourceFile: ts.SourceFile, newPath: string): string | undefined;
|
|
22
|
+
export declare function isRelativeImport(node: ts.ImportDeclaration, sourceFile: ts.SourceFile): boolean;
|
|
23
|
+
export declare function isRelativeGeneratedImport(node: ts.ImportDeclaration, sourceFile: ts.SourceFile): boolean;
|
|
24
|
+
interface importInfo {
|
|
25
|
+
imports: string[];
|
|
26
|
+
start: number;
|
|
27
|
+
end: number;
|
|
28
|
+
importText: string;
|
|
29
|
+
importPath: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function getImportInfo(imp: ts.ImportDeclaration, sourceFile: ts.SourceFile): importInfo | undefined;
|
|
21
32
|
export {};
|
package/tsc/ast.js
CHANGED
|
@@ -3,7 +3,7 @@ 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
|
-
exports.updateImportPath = exports.transformImport = exports.getClassInfo = exports.getPreText = void 0;
|
|
6
|
+
exports.getImportInfo = exports.isRelativeGeneratedImport = exports.isRelativeImport = exports.updateImportPath = exports.transformImport = exports.getClassInfo = exports.getPreText = void 0;
|
|
7
7
|
const typescript_1 = __importDefault(require("typescript"));
|
|
8
8
|
function getPreText(fileContents, node, sourceFile) {
|
|
9
9
|
return fileContents.substring(node.getFullStart(), node.getStart(sourceFile));
|
|
@@ -82,21 +82,23 @@ exports.getClassInfo = getClassInfo;
|
|
|
82
82
|
function transformImport(fileContents, importNode, sourceFile, opts) {
|
|
83
83
|
// remove quotes too
|
|
84
84
|
const text = importNode.moduleSpecifier.getText(sourceFile).slice(1, -1);
|
|
85
|
-
if (
|
|
86
|
-
text !==
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
if (opts?.transformPath) {
|
|
86
|
+
if (text !== opts.transformPath) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
else {
|
|
91
|
+
if (text !== "@snowtop/ent" &&
|
|
92
|
+
text !== "@snowtop/ent/schema" &&
|
|
93
|
+
text !== "@snowtop/ent/schema/") {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const impInfo = getImportInfo(importNode, sourceFile);
|
|
98
|
+
if (!impInfo) {
|
|
94
99
|
return;
|
|
95
100
|
}
|
|
96
|
-
const imports =
|
|
97
|
-
.substring(start + 1, end)
|
|
98
|
-
// .trim()
|
|
99
|
-
.split(",");
|
|
101
|
+
const { imports, start, end, importText } = impInfo;
|
|
100
102
|
let removeImportsMap = {};
|
|
101
103
|
if (opts?.removeImports) {
|
|
102
104
|
opts.removeImports.forEach((imp) => (removeImportsMap[imp] = true));
|
|
@@ -152,3 +154,34 @@ function updateImportPath(fileContents, importNode, sourceFile, newPath) {
|
|
|
152
154
|
'";');
|
|
153
155
|
}
|
|
154
156
|
exports.updateImportPath = updateImportPath;
|
|
157
|
+
function isRelativeImport(node, sourceFile) {
|
|
158
|
+
const text = node.moduleSpecifier.getText(sourceFile).slice(1, -1);
|
|
159
|
+
return text.startsWith("..") || text.startsWith("./");
|
|
160
|
+
}
|
|
161
|
+
exports.isRelativeImport = isRelativeImport;
|
|
162
|
+
function isRelativeGeneratedImport(node, sourceFile) {
|
|
163
|
+
const text = node.moduleSpecifier.getText(sourceFile).slice(1, -1);
|
|
164
|
+
return ((text.startsWith("..") || text.startsWith("./")) &&
|
|
165
|
+
text.indexOf("/generated") !== -1);
|
|
166
|
+
}
|
|
167
|
+
exports.isRelativeGeneratedImport = isRelativeGeneratedImport;
|
|
168
|
+
function getImportInfo(imp, sourceFile) {
|
|
169
|
+
const importText = imp.importClause?.getText(sourceFile) || "";
|
|
170
|
+
const start = importText.indexOf("{");
|
|
171
|
+
const end = importText.lastIndexOf("}");
|
|
172
|
+
const text = imp.moduleSpecifier.getText(sourceFile).slice(1, -1);
|
|
173
|
+
if (start === -1 || end === -1) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
importPath: text,
|
|
178
|
+
importText,
|
|
179
|
+
start,
|
|
180
|
+
end,
|
|
181
|
+
imports: importText
|
|
182
|
+
.substring(start + 1, end)
|
|
183
|
+
//.trim()
|
|
184
|
+
.split(","),
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
exports.getImportInfo = getImportInfo;
|