postgrest-parser 0.1.0 → 0.1.2

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.
Binary file
@@ -0,0 +1,27 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_wasmqueryresult_free: (a: number, b: number) => void;
5
+ export const buildFilterClause: (a: number, b: number) => void;
6
+ export const initSchemaFromDb: (a: number) => number;
7
+ export const parseDelete: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
8
+ export const parseInsert: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
9
+ export const parseOnly: (a: number, b: number, c: number) => void;
10
+ export const parseQueryString: (a: number, b: number, c: number, d: number, e: number) => void;
11
+ export const parseRequest: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
12
+ export const parseRpc: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
13
+ export const parseUpdate: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
14
+ export const wasmqueryresult_params: (a: number) => number;
15
+ export const wasmqueryresult_query: (a: number, b: number) => void;
16
+ export const wasmqueryresult_tables: (a: number) => number;
17
+ export const wasmqueryresult_toJSON: (a: number) => number;
18
+ export const init_panic_hook: () => void;
19
+ export const __wasm_bindgen_func_elem_344: (a: number, b: number) => void;
20
+ export const __wasm_bindgen_func_elem_345: (a: number, b: number, c: number, d: number) => void;
21
+ export const __wasm_bindgen_func_elem_416: (a: number, b: number, c: number, d: number) => void;
22
+ export const __wbindgen_export: (a: number, b: number) => number;
23
+ export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
24
+ export const __wbindgen_export3: (a: number) => void;
25
+ export const __wbindgen_export4: (a: number, b: number, c: number) => void;
26
+ export const __wbindgen_add_to_stack_pointer: (a: number) => number;
27
+ export const __wbindgen_start: () => void;
@@ -0,0 +1,33 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ESNext",
5
+ "lib": ["ES2020", "DOM"],
6
+ "moduleResolution": "bundler",
7
+ "strict": true,
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "declaration": true,
12
+ "declarationMap": false,
13
+ "sourceMap": false,
14
+ "outDir": ".",
15
+ "rootDir": ".",
16
+ "noEmit": false,
17
+ "allowSyntheticDefaultImports": true,
18
+ "resolveJsonModule": true,
19
+ "isolatedModules": true,
20
+ "noUnusedLocals": false,
21
+ "noUnusedParameters": false,
22
+ "noImplicitReturns": true,
23
+ "noFallthroughCasesInSwitch": true
24
+ },
25
+ "include": [
26
+ "types.ts",
27
+ "client.ts"
28
+ ],
29
+ "exclude": [
30
+ "node_modules",
31
+ "dist"
32
+ ]
33
+ }
package/pkg/types.d.ts ADDED
@@ -0,0 +1,174 @@
1
+ /**
2
+ * Type-safe TypeScript definitions for PostgREST Parser
3
+ *
4
+ * This file provides strongly-typed interfaces that replace the `any` types
5
+ * in the auto-generated wasm bindings, improving TypeScript developer experience.
6
+ */
7
+ /**
8
+ * Supported HTTP methods for PostgREST operations
9
+ */
10
+ export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
11
+ /**
12
+ * SQL parameter value types
13
+ */
14
+ export type SqlValue = string | number | boolean | null;
15
+ /**
16
+ * Array of SQL parameter values (can include arrays for IN operator)
17
+ */
18
+ export type SqlParam = SqlValue | string[];
19
+ /**
20
+ * Query result containing SQL query, parameters, and affected tables
21
+ */
22
+ export interface QueryResult {
23
+ /** The generated SQL query string */
24
+ query: string;
25
+ /** Parameterized values for the query ($1, $2, etc.) */
26
+ params: SqlParam[];
27
+ /** List of tables referenced in the query */
28
+ tables: string[];
29
+ }
30
+ /**
31
+ * PostgREST filter operators
32
+ */
33
+ export type FilterOperator = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "like" | "ilike" | "match" | "imatch" | "in" | "is" | "fts" | "plfts" | "phfts" | "wfts" | "cs" | "cd" | "ov" | "sl" | "sr" | "nxr" | "nxl" | "adj";
34
+ /**
35
+ * Single filter condition
36
+ */
37
+ export interface Filter {
38
+ column: string;
39
+ operator: FilterOperator;
40
+ value: string | string[];
41
+ negate?: boolean;
42
+ }
43
+ /**
44
+ * Logic tree for complex filters (AND/OR/NOT)
45
+ */
46
+ export interface LogicCondition {
47
+ operator: "and" | "or" | "not";
48
+ conditions: (Filter | LogicCondition)[];
49
+ }
50
+ /**
51
+ * Order direction
52
+ */
53
+ export type OrderDirection = "asc" | "desc";
54
+ /**
55
+ * Nulls position in ordering
56
+ */
57
+ export type NullsPosition = "first" | "last";
58
+ /**
59
+ * Single order clause
60
+ */
61
+ export interface OrderBy {
62
+ column: string;
63
+ direction: OrderDirection;
64
+ nulls?: NullsPosition;
65
+ }
66
+ /**
67
+ * Parsed query parameters
68
+ */
69
+ export interface ParsedQuery {
70
+ select?: string[];
71
+ filters?: (Filter | LogicCondition)[];
72
+ order?: OrderBy[];
73
+ limit?: number;
74
+ offset?: number;
75
+ on_conflict?: string[];
76
+ returning?: string[];
77
+ }
78
+ /**
79
+ * PostgREST Prefer header options
80
+ */
81
+ export interface PreferOptions {
82
+ /** Return representation: "minimal" | "representation" | "headers-only" */
83
+ return?: "minimal" | "representation" | "headers-only";
84
+ /** Resolution for conflicts: "merge-duplicates" | "ignore-duplicates" */
85
+ resolution?: "merge-duplicates" | "ignore-duplicates";
86
+ /** Missing columns behavior: "default" | "null" */
87
+ missing?: "default" | "null";
88
+ /** Count algorithm: "exact" | "planned" | "estimated" */
89
+ count?: "exact" | "planned" | "estimated";
90
+ }
91
+ /**
92
+ * Request headers (type-safe alternative to JSON string)
93
+ */
94
+ export interface RequestHeaders {
95
+ Prefer?: string;
96
+ [key: string]: string | undefined;
97
+ }
98
+ /**
99
+ * Query options for SELECT operations
100
+ */
101
+ export interface SelectOptions {
102
+ /** Columns to select (comma-separated or array) */
103
+ select?: string | string[];
104
+ /** Filter conditions */
105
+ filters?: Record<string, string>;
106
+ /** Order by clauses */
107
+ order?: string | string[];
108
+ /** Limit number of results */
109
+ limit?: number;
110
+ /** Offset for pagination */
111
+ offset?: number;
112
+ /** Count total rows */
113
+ count?: "exact" | "planned" | "estimated";
114
+ }
115
+ /**
116
+ * Insert options
117
+ */
118
+ export interface InsertOptions {
119
+ /** Columns to return (default: "*") */
120
+ returning?: string | string[];
121
+ /** Columns to use for conflict resolution */
122
+ onConflict?: string | string[];
123
+ /** Prefer header options */
124
+ prefer?: PreferOptions;
125
+ }
126
+ /**
127
+ * Update options
128
+ */
129
+ export interface UpdateOptions {
130
+ /** Columns to return */
131
+ returning?: string | string[];
132
+ /** Prefer header options */
133
+ prefer?: PreferOptions;
134
+ }
135
+ /**
136
+ * Delete options
137
+ */
138
+ export interface DeleteOptions {
139
+ /** Columns to return */
140
+ returning?: string | string[];
141
+ /** Prefer header options */
142
+ prefer?: PreferOptions;
143
+ }
144
+ /**
145
+ * RPC function options
146
+ */
147
+ export interface RpcOptions {
148
+ /** Columns to select from function result */
149
+ select?: string | string[];
150
+ /** Filter function results */
151
+ filters?: Record<string, string>;
152
+ /** Order function results */
153
+ order?: string | string[];
154
+ /** Limit function results */
155
+ limit?: number;
156
+ /** Offset for pagination */
157
+ offset?: number;
158
+ }
159
+ /**
160
+ * Error thrown by the parser
161
+ */
162
+ export declare class PostgRESTParserError extends Error {
163
+ readonly kind: "parse" | "sql_generation" | "invalid_input";
164
+ constructor(message: string, kind: "parse" | "sql_generation" | "invalid_input");
165
+ }
166
+ /**
167
+ * Filter clause result
168
+ */
169
+ export interface FilterClause {
170
+ /** WHERE clause SQL string */
171
+ clause: string;
172
+ /** Parameter values for the clause */
173
+ params: SqlParam[];
174
+ }
package/pkg/types.js ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Type-safe TypeScript definitions for PostgREST Parser
3
+ *
4
+ * This file provides strongly-typed interfaces that replace the `any` types
5
+ * in the auto-generated wasm bindings, improving TypeScript developer experience.
6
+ */
7
+ /**
8
+ * Error thrown by the parser
9
+ */
10
+ export class PostgRESTParserError extends Error {
11
+ constructor(message, kind) {
12
+ super(message);
13
+ this.kind = kind;
14
+ this.name = "PostgRESTParserError";
15
+ }
16
+ }
package/pkg/types.ts ADDED
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Type-safe TypeScript definitions for PostgREST Parser
3
+ *
4
+ * This file provides strongly-typed interfaces that replace the `any` types
5
+ * in the auto-generated wasm bindings, improving TypeScript developer experience.
6
+ */
7
+
8
+ /**
9
+ * Supported HTTP methods for PostgREST operations
10
+ */
11
+ export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
12
+
13
+ /**
14
+ * SQL parameter value types
15
+ */
16
+ export type SqlValue = string | number | boolean | null;
17
+
18
+ /**
19
+ * Array of SQL parameter values (can include arrays for IN operator)
20
+ */
21
+ export type SqlParam = SqlValue | string[];
22
+
23
+ /**
24
+ * Query result containing SQL query, parameters, and affected tables
25
+ */
26
+ export interface QueryResult {
27
+ /** The generated SQL query string */
28
+ query: string;
29
+ /** Parameterized values for the query ($1, $2, etc.) */
30
+ params: SqlParam[];
31
+ /** List of tables referenced in the query */
32
+ tables: string[];
33
+ }
34
+
35
+ /**
36
+ * PostgREST filter operators
37
+ */
38
+ export type FilterOperator =
39
+ | "eq" | "neq" | "gt" | "gte" | "lt" | "lte"
40
+ | "like" | "ilike" | "match" | "imatch"
41
+ | "in" | "is" | "fts" | "plfts" | "phfts" | "wfts"
42
+ | "cs" | "cd" | "ov" | "sl" | "sr" | "nxr" | "nxl" | "adj";
43
+
44
+ /**
45
+ * Single filter condition
46
+ */
47
+ export interface Filter {
48
+ column: string;
49
+ operator: FilterOperator;
50
+ value: string | string[];
51
+ negate?: boolean;
52
+ }
53
+
54
+ /**
55
+ * Logic tree for complex filters (AND/OR/NOT)
56
+ */
57
+ export interface LogicCondition {
58
+ operator: "and" | "or" | "not";
59
+ conditions: (Filter | LogicCondition)[];
60
+ }
61
+
62
+ /**
63
+ * Order direction
64
+ */
65
+ export type OrderDirection = "asc" | "desc";
66
+
67
+ /**
68
+ * Nulls position in ordering
69
+ */
70
+ export type NullsPosition = "first" | "last";
71
+
72
+ /**
73
+ * Single order clause
74
+ */
75
+ export interface OrderBy {
76
+ column: string;
77
+ direction: OrderDirection;
78
+ nulls?: NullsPosition;
79
+ }
80
+
81
+ /**
82
+ * Parsed query parameters
83
+ */
84
+ export interface ParsedQuery {
85
+ select?: string[];
86
+ filters?: (Filter | LogicCondition)[];
87
+ order?: OrderBy[];
88
+ limit?: number;
89
+ offset?: number;
90
+ on_conflict?: string[];
91
+ returning?: string[];
92
+ }
93
+
94
+ /**
95
+ * PostgREST Prefer header options
96
+ */
97
+ export interface PreferOptions {
98
+ /** Return representation: "minimal" | "representation" | "headers-only" */
99
+ return?: "minimal" | "representation" | "headers-only";
100
+ /** Resolution for conflicts: "merge-duplicates" | "ignore-duplicates" */
101
+ resolution?: "merge-duplicates" | "ignore-duplicates";
102
+ /** Missing columns behavior: "default" | "null" */
103
+ missing?: "default" | "null";
104
+ /** Count algorithm: "exact" | "planned" | "estimated" */
105
+ count?: "exact" | "planned" | "estimated";
106
+ }
107
+
108
+ /**
109
+ * Request headers (type-safe alternative to JSON string)
110
+ */
111
+ export interface RequestHeaders {
112
+ Prefer?: string;
113
+ [key: string]: string | undefined;
114
+ }
115
+
116
+ /**
117
+ * Query options for SELECT operations
118
+ */
119
+ export interface SelectOptions {
120
+ /** Columns to select (comma-separated or array) */
121
+ select?: string | string[];
122
+ /** Filter conditions */
123
+ filters?: Record<string, string>;
124
+ /** Order by clauses */
125
+ order?: string | string[];
126
+ /** Limit number of results */
127
+ limit?: number;
128
+ /** Offset for pagination */
129
+ offset?: number;
130
+ /** Count total rows */
131
+ count?: "exact" | "planned" | "estimated";
132
+ }
133
+
134
+ /**
135
+ * Insert options
136
+ */
137
+ export interface InsertOptions {
138
+ /** Columns to return (default: "*") */
139
+ returning?: string | string[];
140
+ /** Columns to use for conflict resolution */
141
+ onConflict?: string | string[];
142
+ /** Prefer header options */
143
+ prefer?: PreferOptions;
144
+ }
145
+
146
+ /**
147
+ * Update options
148
+ */
149
+ export interface UpdateOptions {
150
+ /** Columns to return */
151
+ returning?: string | string[];
152
+ /** Prefer header options */
153
+ prefer?: PreferOptions;
154
+ }
155
+
156
+ /**
157
+ * Delete options
158
+ */
159
+ export interface DeleteOptions {
160
+ /** Columns to return */
161
+ returning?: string | string[];
162
+ /** Prefer header options */
163
+ prefer?: PreferOptions;
164
+ }
165
+
166
+ /**
167
+ * RPC function options
168
+ */
169
+ export interface RpcOptions {
170
+ /** Columns to select from function result */
171
+ select?: string | string[];
172
+ /** Filter function results */
173
+ filters?: Record<string, string>;
174
+ /** Order function results */
175
+ order?: string | string[];
176
+ /** Limit function results */
177
+ limit?: number;
178
+ /** Offset for pagination */
179
+ offset?: number;
180
+ }
181
+
182
+ /**
183
+ * Error thrown by the parser
184
+ */
185
+ export class PostgRESTParserError extends Error {
186
+ constructor(
187
+ message: string,
188
+ public readonly kind: "parse" | "sql_generation" | "invalid_input"
189
+ ) {
190
+ super(message);
191
+ this.name = "PostgRESTParserError";
192
+ }
193
+ }
194
+
195
+ /**
196
+ * Filter clause result
197
+ */
198
+ export interface FilterClause {
199
+ /** WHERE clause SQL string */
200
+ clause: string;
201
+ /** Parameter values for the clause */
202
+ params: SqlParam[];
203
+ }