@powersync/service-sync-rules 0.0.0-dev-20240708103353

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 (75) hide show
  1. package/LICENSE +67 -0
  2. package/README.md +129 -0
  3. package/dist/DartSchemaGenerator.d.ts +12 -0
  4. package/dist/DartSchemaGenerator.js +39 -0
  5. package/dist/DartSchemaGenerator.js.map +1 -0
  6. package/dist/ExpressionType.d.ts +33 -0
  7. package/dist/ExpressionType.js +61 -0
  8. package/dist/ExpressionType.js.map +1 -0
  9. package/dist/IdSequence.d.ts +4 -0
  10. package/dist/IdSequence.js +9 -0
  11. package/dist/IdSequence.js.map +1 -0
  12. package/dist/JsSchemaGenerator.d.ts +12 -0
  13. package/dist/JsSchemaGenerator.js +42 -0
  14. package/dist/JsSchemaGenerator.js.map +1 -0
  15. package/dist/SchemaGenerator.d.ts +14 -0
  16. package/dist/SchemaGenerator.js +26 -0
  17. package/dist/SchemaGenerator.js.map +1 -0
  18. package/dist/SourceTableInterface.d.ts +5 -0
  19. package/dist/SourceTableInterface.js +2 -0
  20. package/dist/SourceTableInterface.js.map +1 -0
  21. package/dist/SqlBucketDescriptor.d.ts +37 -0
  22. package/dist/SqlBucketDescriptor.js +111 -0
  23. package/dist/SqlBucketDescriptor.js.map +1 -0
  24. package/dist/SqlDataQuery.d.ts +39 -0
  25. package/dist/SqlDataQuery.js +239 -0
  26. package/dist/SqlDataQuery.js.map +1 -0
  27. package/dist/SqlParameterQuery.d.ts +85 -0
  28. package/dist/SqlParameterQuery.js +311 -0
  29. package/dist/SqlParameterQuery.js.map +1 -0
  30. package/dist/SqlSyncRules.d.ts +52 -0
  31. package/dist/SqlSyncRules.js +264 -0
  32. package/dist/SqlSyncRules.js.map +1 -0
  33. package/dist/StaticSchema.d.ts +26 -0
  34. package/dist/StaticSchema.js +61 -0
  35. package/dist/StaticSchema.js.map +1 -0
  36. package/dist/StaticSqlParameterQuery.d.ts +27 -0
  37. package/dist/StaticSqlParameterQuery.js +96 -0
  38. package/dist/StaticSqlParameterQuery.js.map +1 -0
  39. package/dist/TablePattern.d.ts +17 -0
  40. package/dist/TablePattern.js +56 -0
  41. package/dist/TablePattern.js.map +1 -0
  42. package/dist/TableQuerySchema.d.ts +9 -0
  43. package/dist/TableQuerySchema.js +34 -0
  44. package/dist/TableQuerySchema.js.map +1 -0
  45. package/dist/errors.d.ts +22 -0
  46. package/dist/errors.js +58 -0
  47. package/dist/errors.js.map +1 -0
  48. package/dist/generators.d.ts +6 -0
  49. package/dist/generators.js +7 -0
  50. package/dist/generators.js.map +1 -0
  51. package/dist/index.d.ts +19 -0
  52. package/dist/index.js +20 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/json_schema.d.ts +3 -0
  55. package/dist/json_schema.js +52 -0
  56. package/dist/json_schema.js.map +1 -0
  57. package/dist/request_functions.d.ts +17 -0
  58. package/dist/request_functions.js +41 -0
  59. package/dist/request_functions.js.map +1 -0
  60. package/dist/sql_filters.d.ts +125 -0
  61. package/dist/sql_filters.js +599 -0
  62. package/dist/sql_filters.js.map +1 -0
  63. package/dist/sql_functions.d.ts +61 -0
  64. package/dist/sql_functions.js +863 -0
  65. package/dist/sql_functions.js.map +1 -0
  66. package/dist/sql_support.d.ts +25 -0
  67. package/dist/sql_support.js +254 -0
  68. package/dist/sql_support.js.map +1 -0
  69. package/dist/types.d.ts +262 -0
  70. package/dist/types.js +28 -0
  71. package/dist/types.js.map +1 -0
  72. package/dist/utils.d.ts +44 -0
  73. package/dist/utils.js +167 -0
  74. package/dist/utils.js.map +1 -0
  75. package/package.json +32 -0
@@ -0,0 +1,61 @@
1
+ import { SqliteValue } from './types.js';
2
+ import wkx from '@syncpoint/wkx';
3
+ import { ExpressionType } from './ExpressionType.js';
4
+ export declare const BASIC_OPERATORS: Set<string>;
5
+ export interface FunctionParameter {
6
+ name: string;
7
+ type: ExpressionType;
8
+ optional: boolean;
9
+ }
10
+ export interface SqlFunction {
11
+ readonly debugName: string;
12
+ parameters: FunctionParameter[];
13
+ call: (...args: SqliteValue[]) => SqliteValue;
14
+ getReturnType(args: ExpressionType[]): ExpressionType;
15
+ }
16
+ export declare const SQL_FUNCTIONS_NAMED: {
17
+ upper: SqlFunction;
18
+ lower: SqlFunction;
19
+ hex: SqlFunction;
20
+ length: SqlFunction;
21
+ base64: SqlFunction;
22
+ typeof: SqlFunction;
23
+ ifnull: SqlFunction;
24
+ json_extract: SqlFunction;
25
+ json_array_length: SqlFunction;
26
+ json_valid: SqlFunction;
27
+ unixepoch: SqlFunction;
28
+ datetime: SqlFunction;
29
+ st_asgeojson: SqlFunction;
30
+ st_astext: SqlFunction;
31
+ st_x: SqlFunction;
32
+ st_y: SqlFunction;
33
+ };
34
+ export declare const SQL_FUNCTIONS_CALL: Record<"upper" | "lower" | "hex" | "base64" | "length" | "typeof" | "ifnull" | "json_extract" | "json_array_length" | "json_valid" | "unixepoch" | "datetime" | "st_asgeojson" | "st_astext" | "st_x" | "st_y", (...args: SqliteValue[]) => SqliteValue>;
35
+ export declare const SQL_FUNCTIONS: Record<string, SqlFunction>;
36
+ export declare const CAST_TYPES: Set<String>;
37
+ export declare function castAsText(value: SqliteValue): string | null;
38
+ export declare function castAsBlob(value: SqliteValue): Uint8Array | null;
39
+ export declare function cast(value: SqliteValue, to: string): string | number | bigint | Uint8Array | null;
40
+ export declare function sqliteTypeOf(arg: SqliteValue): "null" | "blob" | "text" | "integer" | "real";
41
+ export declare function parseGeometry(value?: SqliteValue): wkx.Geometry | null;
42
+ export declare function evaluateOperator(op: string, a: SqliteValue, b: SqliteValue): SqliteValue;
43
+ export declare function getOperatorReturnType(op: string, left: ExpressionType, right: ExpressionType): ExpressionType;
44
+ export declare function jsonExtract(sourceValue: SqliteValue, path: SqliteValue, operator: string): SqliteValue;
45
+ export declare const OPERATOR_JSON_EXTRACT_JSON: SqlFunction;
46
+ export declare const OPERATOR_JSON_EXTRACT_SQL: SqlFunction;
47
+ export declare const OPERATOR_IS_NULL: SqlFunction;
48
+ export declare const OPERATOR_IS_NOT_NULL: SqlFunction;
49
+ export declare const OPERATOR_NOT: SqlFunction;
50
+ export declare function castOperator(castTo: string | undefined): SqlFunction | null;
51
+ export interface ParseDateFlags {
52
+ /**
53
+ * True if input is unixepoch instead of julien days
54
+ */
55
+ unixepoch?: boolean;
56
+ /**
57
+ * True if output should include milliseconds
58
+ */
59
+ subsecond?: boolean;
60
+ }
61
+ export declare function convertToDate(dateTime: SqliteValue, flags: ParseDateFlags): Date | null;