@loaders.gl/sql 5.0.0-alpha.1 → 5.0.0-alpha.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.
Files changed (41) hide show
  1. package/LICENSE +14 -3
  2. package/README.md +49 -0
  3. package/dist/duckdb-sql-source.js +1 -1
  4. package/dist/index.cjs +1699 -19
  5. package/dist/index.cjs.map +3 -4
  6. package/dist/index.d.ts +3 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +2 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/parse-sql-predicate.d.ts +10 -0
  11. package/dist/parse-sql-predicate.d.ts.map +1 -0
  12. package/dist/parse-sql-predicate.js +316 -0
  13. package/dist/parse-sql-predicate.js.map +1 -0
  14. package/dist/snowflake-sql-source.js +1 -1
  15. package/dist/sql-predicate-schema.d.ts +141 -0
  16. package/dist/sql-predicate-schema.d.ts.map +1 -0
  17. package/dist/sql-predicate-schema.js +205 -0
  18. package/dist/sql-predicate-schema.js.map +1 -0
  19. package/dist/sql-predicate-types.d.ts +55 -0
  20. package/dist/sql-predicate-types.d.ts.map +1 -0
  21. package/dist/sql-predicate-types.js +5 -0
  22. package/dist/sql-predicate-types.js.map +1 -0
  23. package/dist/sql-predicate-zod.cjs +53 -0
  24. package/dist/sql-predicate-zod.cjs.map +6 -0
  25. package/dist/sql-predicate-zod.d.ts +11 -0
  26. package/dist/sql-predicate-zod.d.ts.map +1 -0
  27. package/dist/sql-predicate-zod.js +42 -0
  28. package/dist/sql-predicate-zod.js.map +1 -0
  29. package/dist/sql-predicate.cjs +500 -0
  30. package/dist/sql-predicate.cjs.map +6 -0
  31. package/dist/sql-predicate.d.ts +4 -0
  32. package/dist/sql-predicate.d.ts.map +1 -0
  33. package/dist/sql-predicate.js +6 -0
  34. package/dist/sql-predicate.js.map +1 -0
  35. package/package.json +35 -8
  36. package/src/index.ts +18 -0
  37. package/src/parse-sql-predicate.ts +365 -0
  38. package/src/sql-predicate-schema.ts +226 -0
  39. package/src/sql-predicate-types.ts +71 -0
  40. package/src/sql-predicate-zod.ts +49 -0
  41. package/src/sql-predicate.ts +22 -0
@@ -0,0 +1,49 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {z} from 'zod';
6
+
7
+ import type {SQLPredicate, SQLPredicateValue} from './sql-predicate-types';
8
+
9
+ /** Zod schema for scalar values accepted by in-process SQL predicates. */
10
+ export const SQLPredicateValueSchema: z.ZodType<SQLPredicateValue> = z.union([
11
+ z.boolean(),
12
+ z.number().finite(),
13
+ z.bigint(),
14
+ z.string(),
15
+ z.date(),
16
+ z.instanceof(Uint8Array)
17
+ ]);
18
+
19
+ const SQLPredicatePropertySchema = z.object({property: z.string().min(1)}).strict();
20
+
21
+ /**
22
+ * Optional Zod schema for validating the portable loaders.gl SQL predicate AST.
23
+ *
24
+ * Import from `@loaders.gl/sql/sql-predicate-zod`; the package root does not load Zod.
25
+ */
26
+ export const SQLPredicateSchema: z.ZodType<SQLPredicate> = z.lazy(() =>
27
+ z.union([
28
+ z
29
+ .object({
30
+ op: z.enum(['=', '<>', '<', '<=', '>', '>=']),
31
+ args: z.tuple([SQLPredicatePropertySchema, SQLPredicateValueSchema])
32
+ })
33
+ .strict(),
34
+ z
35
+ .object({
36
+ op: z.literal('in'),
37
+ args: z.tuple([SQLPredicatePropertySchema, z.array(SQLPredicateValueSchema).min(1)])
38
+ })
39
+ .strict(),
40
+ z.object({op: z.literal('isNull'), args: z.tuple([SQLPredicatePropertySchema])}).strict(),
41
+ z
42
+ .object({
43
+ op: z.enum(['and', 'or']),
44
+ args: z.array(SQLPredicateSchema).min(2)
45
+ })
46
+ .strict(),
47
+ z.object({op: z.literal('not'), args: z.tuple([SQLPredicateSchema])}).strict()
48
+ ])
49
+ );
@@ -0,0 +1,22 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ export {parseSQLPredicate} from './parse-sql-predicate';
6
+ export {
7
+ isSQLPredicate,
8
+ SQL_PREDICATE_JSON_SCHEMA,
9
+ validateSQLPredicate
10
+ } from './sql-predicate-schema';
11
+
12
+ export type {
13
+ SQLComparisonPredicate,
14
+ SQLInPredicate,
15
+ SQLLogicalPredicate,
16
+ SQLNotPredicate,
17
+ SQLNullPredicate,
18
+ SQLPredicate,
19
+ SQLPredicateParserOptions,
20
+ SQLPredicateProperty,
21
+ SQLPredicateValue
22
+ } from './sql-predicate-types';