@gen3/toolsff 0.12.41 → 0.12.42

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/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@gen3/toolsff",
3
- "version": "0.12.41",
3
+ "version": "0.12.42",
4
4
  "description": "tools for processing Gen3 commons content: color theme, icons, sharedFilters",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
7
  "engines": {
8
8
  "npm": ">=11.9.0",
9
- "node": ">=24.14.0"
9
+ "node": ">=24.15.0"
10
10
  },
11
11
  "scripts": {
12
12
  "lint": "eslint --ext .js,.ts src",
@@ -48,5 +48,5 @@
48
48
  "axios": "^1.8.2"
49
49
  }
50
50
  },
51
- "gitHead": "960fb78d55a692d81c9e7ebeb0e248e4f98f8fbf"
51
+ "gitHead": "99bb82f01ddae8d8df7b9e2b7950e4748d1c600c"
52
52
  }
@@ -1,148 +0,0 @@
1
- const getArgs = (defaults)=>{
2
- const args = {
3
- ...defaults
4
- };
5
- process.argv.slice(2, process.argv.length).forEach((arg)=>{
6
- // long arg
7
- if (arg.slice(0, 2) === '--') {
8
- const longArg = arg.split('=');
9
- const longArgFlag = longArg[0].slice(2, longArg[0].length);
10
- const longArgValue = longArg.length > 1 ? longArg[1] : true;
11
- args[longArgFlag] = longArgValue;
12
- } else if (arg[0] === '-') {
13
- const flags = arg.slice(1, arg.length).split('');
14
- flags.forEach((flag)=>{
15
- args[flag] = true;
16
- });
17
- }
18
- });
19
- return args;
20
- };
21
-
22
- const assertNever = (x)=>{
23
- throw Error(`Exhaustive comparison did not handle: ${x}`);
24
- };
25
- const handleGqlOperation = (handler, op)=>{
26
- switch(op.op){
27
- case '=':
28
- return handler.handleEquals(op);
29
- case '!=':
30
- return handler.handleNotEquals(op);
31
- case '<':
32
- return handler.handleLessThan(op);
33
- case '<=':
34
- return handler.handleLessThanOrEquals(op);
35
- case '>':
36
- return handler.handleGreaterThan(op);
37
- case '>=':
38
- return handler.handleGreaterThanOrEquals(op);
39
- // case "is":
40
- // return handler.handleMissing(op);
41
- // case "not":
42
- // return handler.handleExists(op);
43
- case 'in':
44
- return handler.handleIncludes(op);
45
- case 'exclude':
46
- return handler.handleExcludes(op);
47
- case 'excludeifany':
48
- return handler.handleExcludeIfAny(op);
49
- case 'and':
50
- return handler.handleIntersection(op);
51
- case 'or':
52
- return handler.handleUnion(op);
53
- default:
54
- return assertNever(op);
55
- }
56
- };
57
-
58
- // a handler to convert from gql to guppy gql
59
- class FromGDCToGen3 {
60
- constructor(){
61
- this.handleEquals = (op)=>({
62
- "=": {
63
- [op.content.field]: op.content.value
64
- }
65
- });
66
- this.handleNotEquals = (op)=>({
67
- "!=": {
68
- [op.content.field]: op.content.value
69
- }
70
- });
71
- this.handleLessThan = (op)=>({
72
- "<": {
73
- [op.content.field]: op.content.value
74
- }
75
- });
76
- this.handleLessThanOrEquals = (op)=>({
77
- "<=": {
78
- [op.content.field]: op.content.value
79
- }
80
- });
81
- this.handleGreaterThan = (op)=>({
82
- ">": {
83
- [op.content.field]: op.content.value
84
- }
85
- });
86
- this.handleGreaterThanOrEquals = (op)=>({
87
- ">=": {
88
- [op.content.field]: op.content.value
89
- }
90
- });
91
- // handleMissing = (op: GqlMissing): Missing => ({
92
- // operator: "missing",
93
- // field: op.content.field,
94
- // });
95
- // handleExists = (op: GqlExists): Exists => ({
96
- // operator: "exists",
97
- // field: op.content.field,
98
- // });
99
- this.handleIncludes = (op)=>({
100
- "in": {
101
- [op.content.field]: op.content.value
102
- }
103
- });
104
- this.handleExcludes = (op)=>({
105
- "exclude": {
106
- [op.content.field]: op.content.value
107
- }
108
- });
109
- this.handleExcludeIfAny = (op)=>({
110
- "excludeifany": {
111
- [op.content.field]: op.content.value instanceof Array ? op.content.value : [
112
- op.content.value
113
- ]
114
- }
115
- });
116
- this.handleIntersection = (op)=>({
117
- and: op.content.map(convertGDCFilterToGen3Filter)
118
- });
119
- this.handleUnion = (op)=>({
120
- or: op.content.map(convertGDCFilterToGen3Filter)
121
- });
122
- }
123
- }
124
- const convertGDCFilterToGen3Filter = (gqlFilter)=>{
125
- const handler = new FromGDCToGen3();
126
- return handleGqlOperation(handler, gqlFilter);
127
- };
128
-
129
- const main = async ()=>{
130
- console.log('Starting');
131
- try {
132
- const { query } = getArgs({
133
- query: ''
134
- });
135
- if (!query) {
136
- console.log('No query provided');
137
- return;
138
- }
139
- console.log('query', query);
140
- const gdcQuery = JSON.parse(query);
141
- console.log(gdcQuery);
142
- const gen3Query = convertGDCFilterToGen3Filter(gdcQuery);
143
- console.log(gen3Query);
144
- } catch (e) {
145
- console.log('Invalid query');
146
- }
147
- };
148
- main();