@graffy/pg 0.19.1-alpha.2 → 0.19.1-alpha.3

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/filter/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- export { default as filterObject } from './filterObject.js';
2
1
  export { default as getFilterSql } from './getSql.js';
package/filter/index.js CHANGED
@@ -1,2 +1 @@
1
- export { default as filterObject } from "./filterObject.js";
2
1
  export { default as getFilterSql } from "./getSql.js";
package/package.json CHANGED
@@ -2,18 +2,9 @@
2
2
  "name": "@graffy/pg",
3
3
  "description": "The standard Postgres module for Graffy. Each instance this module mounts a Postgres table as a Graffy subtree.",
4
4
  "author": "aravind (https://github.com/aravindet)",
5
- "version": "0.19.1-alpha.2",
6
- "main": "./cjs/index.js",
7
- "exports": {
8
- ".": {
9
- "import": "./index.js",
10
- "types": "./index.d.ts"
11
- },
12
- "./*": {
13
- "import": "./*.js",
14
- "types": "./*.d.ts"
15
- }
16
- },
5
+ "version": "0.19.1-alpha.3",
6
+ "type": "module",
7
+ "main": "./index.js",
17
8
  "types": "./index.d.ts",
18
9
  "repository": {
19
10
  "type": "git",
@@ -22,7 +13,7 @@
22
13
  "license": "Apache-2.0",
23
14
  "dependencies": {
24
15
  "sql-formatter": "^15.7.4",
25
- "@graffy/common": "0.19.1-alpha.2",
16
+ "@graffy/common": "0.19.1-alpha.3",
26
17
  "sql-template-tag": "^5.2.1",
27
18
  "debug": "^4.4.3"
28
19
  },
package/sql/clauses.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { Sql } from 'sql-template-tag';
2
2
  export declare const getJsonBuildTrusted: (variadic: any) => Sql;
3
3
  export declare const lookup: (prop: any, options: any) => Sql;
4
- export declare const lookupNumeric: (prop: any) => Sql;
5
4
  export declare const getSelectCols: (options: any, projection?: any) => Sql;
6
5
  export declare function cubeLiteralSql(value: any): Sql;
7
6
  export declare const getInsert: (rows: any, options: any) => {
package/sql/clauses.js CHANGED
@@ -35,7 +35,7 @@ export const lookup = (prop, options) => {
35
35
  }
36
36
  throw Error(`pg.cannot_lookup ${prop}`);
37
37
  };
38
- export const lookupNumeric = (prop) => {
38
+ const lookupNumeric = (prop) => {
39
39
  const [prefix, ...suffix] = prop.split('.');
40
40
  return suffix.length
41
41
  ? sql `CASE WHEN "${raw(prefix)}" #> ${suffix} = 'null'::jsonb
@@ -1 +0,0 @@
1
- export default function filterObject(filter: any, object: any): boolean;
@@ -1,39 +0,0 @@
1
- import { encodePath, unwrapObject } from '@graffy/common';
2
- import getAst from "./getAst.js";
3
- export default function filterObject(filter, object) {
4
- function lookup(path) {
5
- return unwrapObject(object, encodePath(path));
6
- }
7
- function checkNode(ast) {
8
- switch (ast[0]) {
9
- case '$eq':
10
- return lookup(ast[1]) === ast[2];
11
- case '$ne':
12
- return lookup(ast[1]) !== ast[2];
13
- case '$lt':
14
- return lookup(ast[1]) < ast[2];
15
- case '$lte':
16
- return lookup(ast[1]) <= ast[2];
17
- case '$gt':
18
- return lookup(ast[1]) > ast[2];
19
- case '$gte':
20
- return lookup(ast[1]) >= ast[2];
21
- case '$in':
22
- return Array.isArray(ast[2]) && ast[2].includes(lookup(ast[1]));
23
- case '$nin':
24
- return !(Array.isArray(ast[2]) && ast[2].includes(lookup(ast[1])));
25
- case '$cts':
26
- case '$ctd':
27
- case '$ovp':
28
- case '$and':
29
- case '$or':
30
- case '$not':
31
- case '$any':
32
- case '$all':
33
- case '$has':
34
- throw Error('pgfilter.unimplemented');
35
- }
36
- }
37
- const rootAst = getAst(filter);
38
- return checkNode(rootAst);
39
- }