@snowtop/ent 0.1.0-alpha143 → 0.1.0-alpha144

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.
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.executeOperations = exports.ComplexExecutor = exports.ListBasedExecutor = void 0;
7
- const graph_data_structure_1 = __importDefault(require("graph-data-structure"));
7
+ const graph_data_structure_1 = require("graph-data-structure");
8
8
  const ent_1 = require("../core/ent");
9
9
  const db_1 = __importDefault(require("../core/db"));
10
10
  const logger_1 = require("../core/logger");
@@ -123,7 +123,7 @@ class ComplexExecutor {
123
123
  this.executors = [];
124
124
  this.updatedOps = new Map();
125
125
  this.builder = options?.builder;
126
- let graph = (0, graph_data_structure_1.default)();
126
+ let graph = (0, graph_data_structure_1.Graph)();
127
127
  const changesetMap = new Map();
128
128
  const impl = (c) => {
129
129
  changesetMap.set(c.placeholderID.toString(), c);
@@ -1,7 +1,7 @@
1
1
  export interface Options {
2
2
  filter?: (file: string, index: number, array: string[]) => boolean;
3
3
  justCurrentDir?: boolean;
4
- ignore?: string | Readonly<string[]> | undefined;
4
+ ignore?: string | string[] | undefined;
5
5
  }
6
6
  export interface PathResult {
7
7
  m: Map<string, file[]>;
package/imports/index.js CHANGED
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.parseCustomImports = void 0;
30
- const glob_1 = __importDefault(require("glob"));
30
+ const glob = __importStar(require("glob"));
31
31
  const typescript_1 = __importDefault(require("typescript"));
32
32
  const fs = __importStar(require("fs"));
33
33
  const path = __importStar(require("path"));
@@ -42,7 +42,7 @@ function getFiles(filePath, opts) {
42
42
  if (opts?.justCurrentDir) {
43
43
  pattern = `${filePath}/**.ts`;
44
44
  }
45
- let files = glob_1.default.sync(pattern, {
45
+ let files = glob.sync(pattern, {
46
46
  ignore: opts?.ignore,
47
47
  });
48
48
  if (opts?.filter) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowtop/ent",
3
- "version": "0.1.0-alpha143",
3
+ "version": "0.1.0-alpha144",
4
4
  "description": "snowtop ent framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -9,24 +9,24 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "@swc-node/register": "^1.6.5",
12
- "@types/node": "^18.11.18",
12
+ "@types/node": "^20.2.5",
13
13
  "camel-case": "^4.1.2",
14
- "cosmiconfig": "^8.0.0",
15
- "dataloader": "^2.1.0",
16
- "glob": "^8.0.3",
17
- "graph-data-structure": "^2.0.0",
14
+ "cosmiconfig": "^8.1.3",
15
+ "dataloader": "^2.2.2",
16
+ "glob": "^10.2.6",
17
+ "graph-data-structure": "^3.3.0",
18
18
  "js-yaml": "^4.1.0",
19
- "json5": "^2.2.2",
20
- "luxon": "^3.1.1",
19
+ "json5": "^2.2.3",
20
+ "luxon": "^3.3.0",
21
21
  "memoizee": "^0.4.15",
22
- "minimist": "^1.2.7",
22
+ "minimist": "^1.2.8",
23
23
  "pascal-case": "^3.1.2",
24
24
  "pg": "^8.11.0",
25
- "prettier": "^2.8.1",
25
+ "prettier": "^2.8.8",
26
26
  "snake-case": "^3.0.4",
27
27
  "ts-node": "^10.9.1",
28
28
  "tsconfig-paths": "^4.2.0",
29
- "tslib": "^2.5.0",
29
+ "tslib": "^2.5.2",
30
30
  "typescript": "^5.0.4",
31
31
  "uuid": "^9.0.0"
32
32
  },
@@ -269,6 +269,7 @@ async function parseSchema(potentialSchemas, globalSchema) {
269
269
  assocEdgeGroups: [],
270
270
  customGraphQLInterfaces: schema.customGraphQLInterfaces,
271
271
  supportUpsert: schema.supportUpsert,
272
+ supportCanViewerSee: schema.supportCanViewerSee,
272
273
  };
273
274
  // let's put patterns first just so we have id, created_at, updated_at first
274
275
  // ¯\_(ツ)_/¯
@@ -21,6 +21,7 @@ export declare class EntSchema implements Schema {
21
21
  hideFromGraphQL?: boolean;
22
22
  customGraphQLInterfaces?: string[] | undefined;
23
23
  supportUpsert?: boolean | undefined;
24
+ supportCanViewerSee?: boolean | undefined;
24
25
  constructor(cfg: SchemaConfig);
25
26
  }
26
27
  export declare class EntSchemaWithTZ implements Schema {
@@ -40,6 +41,7 @@ export declare class EntSchemaWithTZ implements Schema {
40
41
  hideFromGraphQL?: boolean;
41
42
  customGraphQLInterfaces?: string[] | undefined;
42
43
  supportUpsert?: boolean | undefined;
44
+ supportCanViewerSee?: boolean | undefined;
43
45
  constructor(cfg: SchemaConfig);
44
46
  }
45
47
  export declare abstract class BaseEntSchema {
@@ -91,6 +91,7 @@ class EntSchema {
91
91
  // TODO annoying that have to list these...
92
92
  this.customGraphQLInterfaces = cfg.customGraphQLInterfaces;
93
93
  this.supportUpsert = cfg.supportUpsert;
94
+ this.supportCanViewerSee = cfg.supportCanViewerSee;
94
95
  }
95
96
  }
96
97
  exports.EntSchema = EntSchema;
@@ -121,6 +122,7 @@ class EntSchemaWithTZ {
121
122
  // TODO annoying that have to list these...
122
123
  this.customGraphQLInterfaces = cfg.customGraphQLInterfaces;
123
124
  this.supportUpsert = cfg.supportUpsert;
125
+ this.supportCanViewerSee = cfg.supportCanViewerSee;
124
126
  }
125
127
  }
126
128
  exports.EntSchemaWithTZ = EntSchemaWithTZ;
@@ -40,6 +40,7 @@ export default interface Schema {
40
40
  hideFromGraphQL?: boolean;
41
41
  customGraphQLInterfaces?: string[];
42
42
  supportUpsert?: boolean;
43
+ supportCanViewerSee?: boolean;
43
44
  }
44
45
  export interface AssocEdge {
45
46
  name: string;
@@ -29,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
30
  const typescript_1 = __importDefault(require("typescript"));
31
31
  const path = __importStar(require("path"));
32
- const glob_1 = __importDefault(require("glob"));
32
+ const glob = __importStar(require("glob"));
33
33
  const compilerOptions_1 = require("../tsc/compilerOptions");
34
34
  // TODO this should probably be its own package but for now it's here
35
35
  class Compiler {
@@ -265,6 +265,6 @@ class Compiler {
265
265
  // todo this should be configurable
266
266
  // TODO this should be broken into its own repo and npm module
267
267
  // TODO use includes and exclude in tsconfig.json if it exists
268
- new Compiler(glob_1.default.sync("**/*.ts", {
268
+ new Compiler(glob.sync("**/*.ts", {
269
269
  ignore: ["node_modules/**", "tests/**", "**/*.test.ts"],
270
270
  }), ["node_modules/@types/node"]).compile();
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  return (mod && mod.__esModule) ? mod : { "default": mod };
28
28
  };
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
- const glob_1 = __importDefault(require("glob"));
30
+ const glob = __importStar(require("glob"));
31
31
  const json5_1 = __importDefault(require("json5"));
32
32
  const minimist_1 = __importDefault(require("minimist"));
33
33
  const path = __importStar(require("path"));
@@ -256,12 +256,12 @@ async function captureCustom(filePath, filesCsv, jsonPath, gqlCapture) {
256
256
  // ignore test files.
257
257
  "**/*.test.ts",
258
258
  ];
259
- const customGQLResolvers = glob_1.default.sync(path.join(filePath, "/graphql/resolvers/**/*.ts"), {
259
+ const customGQLResolvers = glob.sync(path.join(filePath, "/graphql/resolvers/**/*.ts"), {
260
260
  // no actions for now to speed things up
261
261
  // no index.ts or internal file.
262
262
  ignore: ignore,
263
263
  });
264
- const customGQLMutations = glob_1.default.sync(path.join(filePath, "/graphql/mutations/**/*.ts"), {
264
+ const customGQLMutations = glob.sync(path.join(filePath, "/graphql/mutations/**/*.ts"), {
265
265
  // no actions for now to speed things up
266
266
  // no index.ts or internal file.
267
267
  ignore: ignore,
@@ -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
- const glob_1 = __importDefault(require("glob"));
29
+ const glob = __importStar(require("glob"));
30
30
  const path = __importStar(require("path"));
31
31
  const pascal_case_1 = require("pascal-case");
32
32
  const minimist_1 = __importDefault(require("minimist"));
@@ -42,7 +42,7 @@ function main() {
42
42
  let globalSchema;
43
43
  const r = /(\w+).ts/;
44
44
  // do we still even need this...
45
- const paths = glob_1.default.sync(path.join(options.path, "*.ts"), {
45
+ const paths = glob.sync(path.join(options.path, "*.ts"), {
46
46
  ignore: [`\d+_read_schema.ts`],
47
47
  });
48
48
  let potentialSchemas = {};
@@ -73,6 +73,11 @@ export declare function dateList(name: string, opts?: options): Column;
73
73
  export declare function boolList(name: string, opts?: options): Column;
74
74
  export declare function table(name: string, ...items: SchemaItem[]): Table;
75
75
  export declare function enumType(name: string, values: string[]): CoreConcept;
76
+ interface TempDBOptions {
77
+ dialect: Dialect;
78
+ sqliteConnString?: string;
79
+ tables?: CoreConcept[] | (() => CoreConcept[]);
80
+ }
76
81
  export declare class TempDB {
77
82
  private db;
78
83
  private client;
@@ -81,7 +86,9 @@ export declare class TempDB {
81
86
  private dialect;
82
87
  private sqlite;
83
88
  private setTables;
89
+ private sqliteConnString;
84
90
  constructor(dialect: Dialect, tables?: CoreConcept[] | (() => CoreConcept[]));
91
+ constructor(opts: TempDBOptions);
85
92
  getDialect(): Dialect;
86
93
  __getTables(): Map<string, CoreConcept>;
87
94
  beforeAll(setupConnString?: boolean): Promise<void>;
@@ -381,8 +381,15 @@ function randomDB() {
381
381
  class TempDB {
382
382
  constructor(dialect, tables) {
383
383
  this.tables = new Map();
384
- this.dialect = dialect;
385
- this.setTables = tables;
384
+ if (typeof dialect === "string") {
385
+ this.dialect = dialect;
386
+ this.setTables = tables;
387
+ }
388
+ else {
389
+ this.dialect = dialect.dialect;
390
+ this.setTables = dialect.tables;
391
+ this.sqliteConnString = dialect.sqliteConnString;
392
+ }
386
393
  }
387
394
  getDialect() {
388
395
  return this.dialect;
@@ -434,10 +441,17 @@ class TempDB {
434
441
  await this.dbClient.connect();
435
442
  }
436
443
  else {
437
- if (process.env.DB_CONNECTION_STRING === undefined) {
438
- throw new Error(`DB_CONNECTION_STRING required for sqlite `);
444
+ let connString;
445
+ if (this.sqliteConnString) {
446
+ connString = this.sqliteConnString;
439
447
  }
440
- const filePath = process.env.DB_CONNECTION_STRING.substr(10);
448
+ else {
449
+ if (process.env.DB_CONNECTION_STRING === undefined) {
450
+ throw new Error(`DB_CONNECTION_STRING required for sqlite if sqliteConnString is not set`);
451
+ }
452
+ connString = process.env.DB_CONNECTION_STRING;
453
+ }
454
+ const filePath = connString.substr(10);
441
455
  this.sqlite = (0, better_sqlite3_1.default)(filePath);
442
456
  }
443
457
  if (this.setTables) {
@@ -563,10 +577,15 @@ function assoc_edge_table(name, global, unique_edge) {
563
577
  }
564
578
  exports.assoc_edge_table = assoc_edge_table;
565
579
  function setupSqlite(connString, tables, opts) {
566
- let tdb = new TempDB(db_1.Dialect.SQLite, tables);
580
+ let tdb = new TempDB({
581
+ dialect: db_1.Dialect.SQLite,
582
+ tables,
583
+ sqliteConnString: connString,
584
+ });
567
585
  beforeAll(async () => {
568
- process.env.DB_CONNECTION_STRING = connString;
569
- (0, config_1.loadConfig)();
586
+ (0, config_1.loadConfig)({
587
+ dbConnectionString: connString,
588
+ });
570
589
  await tdb.beforeAll();
571
590
  const conn = db_1.default.getInstance().getConnection();
572
591
  expect(conn.db.memory).toBe(false);
@@ -268,5 +268,3 @@ QueryRecorder.ids = [];
268
268
  // we need pkeys when storing...
269
269
  QueryRecorder.data = new Map();
270
270
  exports.QueryRecorder = QueryRecorder;
271
- // TODO
272
- process.env.DB_CONNECTION_STRING = "INVALID DATABASE";
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.moveGenerated = void 0;
30
- const glob_1 = require("glob");
30
+ const glob = __importStar(require("glob"));
31
31
  const path = __importStar(require("path"));
32
32
  const fs = __importStar(require("fs"));
33
33
  const typescript_1 = __importDefault(require("typescript"));
@@ -38,7 +38,7 @@ class MoveFiles {
38
38
  this.globPath = globPath;
39
39
  }
40
40
  move() {
41
- const files = glob_1.glob.sync(this.globPath);
41
+ const files = glob.sync(this.globPath);
42
42
  moveFiles(files);
43
43
  }
44
44
  }
@@ -1,4 +1,4 @@
1
- import { IOptions } from "glob";
1
+ import * as glob from "glob";
2
2
  import ts from "typescript";
3
3
  interface TraverseChildResponse {
4
4
  node?: ts.Node;
@@ -10,7 +10,7 @@ interface TraverseChildResponse {
10
10
  }
11
11
  export interface TransformFile {
12
12
  glob: string;
13
- globOptions?: IOptions;
13
+ globOptions?: glob.GlobOptions;
14
14
  preprocessFile?: (contents: string, file: string, sourceFile: ts.SourceFile) => boolean;
15
15
  traverseChild(sourceFile: ts.SourceFile, contents: string, file: string, node: ts.Node): TraverseChildResponse | undefined;
16
16
  filter?(files: string[]): string[];
package/tsc/transform.js CHANGED
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.transform = void 0;
30
- const glob_1 = require("glob");
30
+ const glob = __importStar(require("glob"));
31
31
  const typescript_1 = __importDefault(require("typescript"));
32
32
  const child_process_1 = require("child_process");
33
33
  const fs = __importStar(require("fs"));
@@ -40,10 +40,11 @@ function normalizePath(p) {
40
40
  return p;
41
41
  }
42
42
  function transform(transform) {
43
- let files = glob_1.glob.sync(transform.glob, transform.globOptions);
43
+ let files = glob.sync(transform.glob, transform.globOptions ?? {});
44
44
  const target = (0, compilerOptions_1.getTargetFromCurrentDir)();
45
45
  if (transform.filter) {
46
- files = transform.filter(files);
46
+ const f2 = files.map((f) => (typeof f === "string" ? f : f.path));
47
+ files = transform.filter(f2);
47
48
  }
48
49
  files.forEach((file) => {
49
50
  let { contents, sourceFile } = (0, compilerOptions_1.createSourceFile)(target, file);