powersync 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.
Files changed (191) hide show
  1. package/README.md +14 -14
  2. package/dist/commands/init.d.ts +0 -1
  3. package/dist/commands/init.js +11 -8
  4. package/dist/commands/instance/sync-rules/generate-schema.js +6 -6
  5. package/dist/constants.d.ts +2 -5
  6. package/dist/constants.js +4 -2
  7. package/dist/service/accounts.client.js +11129 -25
  8. package/dist/service/powersync.client.js +37453 -113
  9. package/dist/service/types.js +1 -1
  10. package/dist/service/utils.js +6 -6
  11. package/dist/utils.js +5 -7
  12. package/oclif.manifest.json +1 -1
  13. package/package.json +28 -20
  14. package/dist/powersync-sdk/accounts/api.d.ts +0 -717
  15. package/dist/powersync-sdk/accounts/api.js +0 -182
  16. package/dist/powersync-sdk/accounts/client.d.ts +0 -1096
  17. package/dist/powersync-sdk/accounts/client.js +0 -124
  18. package/dist/powersync-sdk/accounts/codecs.d.ts +0 -32
  19. package/dist/powersync-sdk/accounts/codecs.js +0 -93
  20. package/dist/powersync-sdk/accounts/index.d.ts +0 -4
  21. package/dist/powersync-sdk/accounts/index.js +0 -4
  22. package/dist/powersync-sdk/accounts/models.d.ts +0 -260
  23. package/dist/powersync-sdk/accounts/models.js +0 -96
  24. package/dist/powersync-sdk/accounts/routes.d.ts +0 -44
  25. package/dist/powersync-sdk/accounts/routes.js +0 -45
  26. package/dist/powersync-sdk/accounts/source.d.ts +0 -76
  27. package/dist/powersync-sdk/accounts/source.js +0 -32
  28. package/dist/powersync-sdk/errors/errors.d.ts +0 -62
  29. package/dist/powersync-sdk/errors/errors.js +0 -115
  30. package/dist/powersync-sdk/errors/index.d.ts +0 -2
  31. package/dist/powersync-sdk/errors/index.js +0 -2
  32. package/dist/powersync-sdk/errors/utils.d.ts +0 -4
  33. package/dist/powersync-sdk/errors/utils.js +0 -18
  34. package/dist/powersync-sdk/fetch-clients/codecs.d.ts +0 -4
  35. package/dist/powersync-sdk/fetch-clients/codecs.js +0 -34
  36. package/dist/powersync-sdk/fetch-clients/decoders.d.ts +0 -3
  37. package/dist/powersync-sdk/fetch-clients/decoders.js +0 -35
  38. package/dist/powersync-sdk/fetch-clients/definitions.d.ts +0 -97
  39. package/dist/powersync-sdk/fetch-clients/definitions.js +0 -22
  40. package/dist/powersync-sdk/fetch-clients/errors.d.ts +0 -7
  41. package/dist/powersync-sdk/fetch-clients/errors.js +0 -19
  42. package/dist/powersync-sdk/fetch-clients/index.d.ts +0 -5
  43. package/dist/powersync-sdk/fetch-clients/index.js +0 -5
  44. package/dist/powersync-sdk/fetch-clients/node-client.d.ts +0 -9
  45. package/dist/powersync-sdk/fetch-clients/node-client.js +0 -107
  46. package/dist/powersync-sdk/fetch-clients/request.d.ts +0 -11
  47. package/dist/powersync-sdk/fetch-clients/request.js +0 -138
  48. package/dist/powersync-sdk/fetch-clients/streaming.d.ts +0 -65
  49. package/dist/powersync-sdk/fetch-clients/streaming.js +0 -99
  50. package/dist/powersync-sdk/fetch-clients/utils.d.ts +0 -13
  51. package/dist/powersync-sdk/fetch-clients/utils.js +0 -43
  52. package/dist/powersync-sdk/fetch-clients/web-client.d.ts +0 -14
  53. package/dist/powersync-sdk/fetch-clients/web-client.js +0 -56
  54. package/dist/powersync-sdk/json/index.d.ts +0 -4
  55. package/dist/powersync-sdk/json/index.js +0 -3
  56. package/dist/powersync-sdk/json/json.d.ts +0 -5
  57. package/dist/powersync-sdk/json/json.js +0 -35
  58. package/dist/powersync-sdk/json/json_container.d.ts +0 -18
  59. package/dist/powersync-sdk/json/json_container.js +0 -28
  60. package/dist/powersync-sdk/json/json_stringify.d.ts +0 -36
  61. package/dist/powersync-sdk/json/json_stringify.js +0 -162
  62. package/dist/powersync-sdk/powersync/client.d.ts +0 -449
  63. package/dist/powersync-sdk/powersync/client.js +0 -53
  64. package/dist/powersync-sdk/powersync/config/HostedConfig.d.ts +0 -327
  65. package/dist/powersync-sdk/powersync/config/HostedConfig.js +0 -92
  66. package/dist/powersync-sdk/powersync/config/PowerSyncConfig.d.ts +0 -211
  67. package/dist/powersync-sdk/powersync/config/PowerSyncConfig.js +0 -97
  68. package/dist/powersync-sdk/powersync/config/normalize.d.ts +0 -32
  69. package/dist/powersync-sdk/powersync/config/normalize.js +0 -85
  70. package/dist/powersync-sdk/powersync/definitions.d.ts +0 -149
  71. package/dist/powersync-sdk/powersync/definitions.js +0 -97
  72. package/dist/powersync-sdk/powersync/index.d.ts +0 -8
  73. package/dist/powersync-sdk/powersync/index.js +0 -8
  74. package/dist/powersync-sdk/powersync/internal_routes.d.ts +0 -247
  75. package/dist/powersync-sdk/powersync/internal_routes.js +0 -69
  76. package/dist/powersync-sdk/powersync/routes.d.ts +0 -779
  77. package/dist/powersync-sdk/powersync/routes.js +0 -191
  78. package/dist/powersync-sdk/sdk-clients/endpoints.d.ts +0 -31
  79. package/dist/powersync-sdk/sdk-clients/endpoints.js +0 -48
  80. package/dist/powersync-sdk/sdk-clients/index.d.ts +0 -3
  81. package/dist/powersync-sdk/sdk-clients/index.js +0 -3
  82. package/dist/powersync-sdk/sdk-clients/pagination.d.ts +0 -14
  83. package/dist/powersync-sdk/sdk-clients/pagination.js +0 -21
  84. package/dist/powersync-sdk/sdk-clients/sdk-client.d.ts +0 -17
  85. package/dist/powersync-sdk/sdk-clients/sdk-client.js +0 -30
  86. package/dist/powersync-sdk/streaming/bson/buffer-array.d.ts +0 -31
  87. package/dist/powersync-sdk/streaming/bson/buffer-array.js +0 -79
  88. package/dist/powersync-sdk/streaming/bson/constants.d.ts +0 -2
  89. package/dist/powersync-sdk/streaming/bson/constants.js +0 -1
  90. package/dist/powersync-sdk/streaming/bson/decoder.d.ts +0 -10
  91. package/dist/powersync-sdk/streaming/bson/decoder.js +0 -62
  92. package/dist/powersync-sdk/streaming/bson/encoder.d.ts +0 -10
  93. package/dist/powersync-sdk/streaming/bson/encoder.js +0 -23
  94. package/dist/powersync-sdk/streaming/bson/header.d.ts +0 -11
  95. package/dist/powersync-sdk/streaming/bson/header.js +0 -52
  96. package/dist/powersync-sdk/streaming/bson/index.d.ts +0 -5
  97. package/dist/powersync-sdk/streaming/bson/index.js +0 -5
  98. package/dist/powersync-sdk/streaming/core/backpressure.d.ts +0 -15
  99. package/dist/powersync-sdk/streaming/core/backpressure.js +0 -34
  100. package/dist/powersync-sdk/streaming/core/cross-stream.d.ts +0 -6
  101. package/dist/powersync-sdk/streaming/core/cross-stream.js +0 -17
  102. package/dist/powersync-sdk/streaming/core/index.d.ts +0 -4
  103. package/dist/powersync-sdk/streaming/core/index.js +0 -4
  104. package/dist/powersync-sdk/streaming/core/node-utils.d.ts +0 -7
  105. package/dist/powersync-sdk/streaming/core/node-utils.js +0 -11
  106. package/dist/powersync-sdk/streaming/core/transformers.d.ts +0 -41
  107. package/dist/powersync-sdk/streaming/core/transformers.js +0 -70
  108. package/dist/powersync-sdk/streaming/core/utils.d.ts +0 -36
  109. package/dist/powersync-sdk/streaming/core/utils.js +0 -66
  110. package/dist/powersync-sdk/streaming/index.d.ts +0 -3
  111. package/dist/powersync-sdk/streaming/index.js +0 -3
  112. package/dist/powersync-sdk/streaming/web.d.ts +0 -4
  113. package/dist/powersync-sdk/streaming/web.js +0 -4
  114. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binaryreader.d.ts +0 -2
  115. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binaryreader.js +0 -36
  116. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binarywriter.d.ts +0 -2
  117. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binarywriter.js +0 -58
  118. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometry.d.ts +0 -18
  119. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometry.js +0 -348
  120. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometrycollection.d.ts +0 -11
  121. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometrycollection.js +0 -118
  122. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/linestring.d.ts +0 -11
  123. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/linestring.js +0 -131
  124. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multilinestring.d.ts +0 -11
  125. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multilinestring.js +0 -134
  126. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipoint.d.ts +0 -11
  127. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipoint.js +0 -122
  128. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipolygon.d.ts +0 -11
  129. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipolygon.js +0 -158
  130. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/point.d.ts +0 -14
  131. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/point.js +0 -165
  132. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/polygon.d.ts +0 -11
  133. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/polygon.js +0 -207
  134. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/types.d.ts +0 -30
  135. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/types.js +0 -29
  136. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wktparser.d.ts +0 -2
  137. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wktparser.js +0 -111
  138. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wkx.d.ts +0 -9
  139. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wkx.js +0 -9
  140. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/zigzag.d.ts +0 -5
  141. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/zigzag.js +0 -9
  142. package/dist/powersync-sdk/sync-rules/DartSchemaGenerator.d.ts +0 -12
  143. package/dist/powersync-sdk/sync-rules/DartSchemaGenerator.js +0 -35
  144. package/dist/powersync-sdk/sync-rules/ExpressionType.d.ts +0 -33
  145. package/dist/powersync-sdk/sync-rules/ExpressionType.js +0 -62
  146. package/dist/powersync-sdk/sync-rules/IdSequence.d.ts +0 -4
  147. package/dist/powersync-sdk/sync-rules/IdSequence.js +0 -7
  148. package/dist/powersync-sdk/sync-rules/JsSchemaGenerator.d.ts +0 -12
  149. package/dist/powersync-sdk/sync-rules/JsSchemaGenerator.js +0 -38
  150. package/dist/powersync-sdk/sync-rules/SchemaGenerator.d.ts +0 -14
  151. package/dist/powersync-sdk/sync-rules/SchemaGenerator.js +0 -24
  152. package/dist/powersync-sdk/sync-rules/SourceTableInterface.d.ts +0 -5
  153. package/dist/powersync-sdk/sync-rules/SourceTableInterface.js +0 -1
  154. package/dist/powersync-sdk/sync-rules/SqlBucketDescriptor.d.ts +0 -37
  155. package/dist/powersync-sdk/sync-rules/SqlBucketDescriptor.js +0 -116
  156. package/dist/powersync-sdk/sync-rules/SqlDataQuery.d.ts +0 -39
  157. package/dist/powersync-sdk/sync-rules/SqlDataQuery.js +0 -245
  158. package/dist/powersync-sdk/sync-rules/SqlParameterQuery.d.ts +0 -43
  159. package/dist/powersync-sdk/sync-rules/SqlParameterQuery.js +0 -254
  160. package/dist/powersync-sdk/sync-rules/SqlSyncRules.d.ts +0 -52
  161. package/dist/powersync-sdk/sync-rules/SqlSyncRules.js +0 -252
  162. package/dist/powersync-sdk/sync-rules/StaticSchema.d.ts +0 -26
  163. package/dist/powersync-sdk/sync-rules/StaticSchema.js +0 -71
  164. package/dist/powersync-sdk/sync-rules/StaticSqlParameterQuery.d.ts +0 -24
  165. package/dist/powersync-sdk/sync-rules/StaticSqlParameterQuery.js +0 -71
  166. package/dist/powersync-sdk/sync-rules/TablePattern.d.ts +0 -17
  167. package/dist/powersync-sdk/sync-rules/TablePattern.js +0 -56
  168. package/dist/powersync-sdk/sync-rules/TableQuerySchema.d.ts +0 -9
  169. package/dist/powersync-sdk/sync-rules/TableQuerySchema.js +0 -41
  170. package/dist/powersync-sdk/sync-rules/errors.d.ts +0 -22
  171. package/dist/powersync-sdk/sync-rules/errors.js +0 -60
  172. package/dist/powersync-sdk/sync-rules/generators.d.ts +0 -6
  173. package/dist/powersync-sdk/sync-rules/generators.js +0 -6
  174. package/dist/powersync-sdk/sync-rules/index.d.ts +0 -17
  175. package/dist/powersync-sdk/sync-rules/index.js +0 -17
  176. package/dist/powersync-sdk/sync-rules/json_schema.d.ts +0 -3
  177. package/dist/powersync-sdk/sync-rules/json_schema.js +0 -50
  178. package/dist/powersync-sdk/sync-rules/sql_filters.d.ts +0 -91
  179. package/dist/powersync-sdk/sync-rules/sql_filters.js +0 -491
  180. package/dist/powersync-sdk/sync-rules/sql_functions.d.ts +0 -53
  181. package/dist/powersync-sdk/sync-rules/sql_functions.js +0 -755
  182. package/dist/powersync-sdk/sync-rules/sql_support.d.ts +0 -22
  183. package/dist/powersync-sdk/sync-rules/sql_support.js +0 -208
  184. package/dist/powersync-sdk/sync-rules/types.d.ts +0 -174
  185. package/dist/powersync-sdk/sync-rules/types.js +0 -9
  186. package/dist/powersync-sdk/sync-rules/utils.d.ts +0 -45
  187. package/dist/powersync-sdk/sync-rules/utils.js +0 -163
  188. package/dist/service/accounts.client.d.ts +0 -26
  189. package/dist/service/powersync.client.d.ts +0 -269
  190. package/dist/service/types.d.ts +0 -69
  191. package/dist/service/utils.d.ts +0 -5
@@ -1,207 +0,0 @@
1
- import BinaryWriter from './binarywriter.js';
2
- import Geometry from './geometry.js';
3
- import Point from './point.js';
4
- import Types from './types.js';
5
- function Polygon(exteriorRing, interiorRings, srid) {
6
- Geometry.call(this);
7
- this.exteriorRing = exteriorRing || [];
8
- this.interiorRings = interiorRings || [];
9
- this.srid = srid;
10
- if (this.exteriorRing.length > 0) {
11
- this.hasZ = this.exteriorRing[0].hasZ;
12
- this.hasM = this.exteriorRing[0].hasM;
13
- }
14
- }
15
- // util.inherits(Polygon, Geometry);
16
- Polygon.Z = function (exteriorRing, interiorRings, srid) {
17
- const polygon = new Polygon(exteriorRing, interiorRings, srid);
18
- polygon.hasZ = true;
19
- return polygon;
20
- };
21
- Polygon.M = function (exteriorRing, interiorRings, srid) {
22
- const polygon = new Polygon(exteriorRing, interiorRings, srid);
23
- polygon.hasM = true;
24
- return polygon;
25
- };
26
- Polygon.ZM = function (exteriorRing, interiorRings, srid) {
27
- const polygon = new Polygon(exteriorRing, interiorRings, srid);
28
- polygon.hasZ = true;
29
- polygon.hasM = true;
30
- return polygon;
31
- };
32
- Polygon._parseWkt = function (value, options) {
33
- const polygon = new Polygon();
34
- polygon.srid = options.srid;
35
- polygon.hasZ = options.hasZ;
36
- polygon.hasM = options.hasM;
37
- if (value.isMatch(['EMPTY']))
38
- return polygon;
39
- value.expectGroupStart();
40
- value.expectGroupStart();
41
- polygon.exteriorRing.push.apply(polygon.exteriorRing, value.matchCoordinates(options));
42
- value.expectGroupEnd();
43
- while (value.isMatch([','])) {
44
- value.expectGroupStart();
45
- polygon.interiorRings.push(value.matchCoordinates(options));
46
- value.expectGroupEnd();
47
- }
48
- value.expectGroupEnd();
49
- return polygon;
50
- };
51
- Polygon._parseWkb = function (value, options) {
52
- const polygon = new Polygon();
53
- polygon.srid = options.srid;
54
- polygon.hasZ = options.hasZ;
55
- polygon.hasM = options.hasM;
56
- const ringCount = value.readUInt32();
57
- if (ringCount > 0) {
58
- const exteriorRingCount = value.readUInt32();
59
- for (var i = 0; i < exteriorRingCount; i++)
60
- polygon.exteriorRing.push(Point._readWkbPoint(value, options));
61
- for (i = 1; i < ringCount; i++) {
62
- const interiorRing = [];
63
- const interiorRingCount = value.readUInt32();
64
- for (let j = 0; j < interiorRingCount; j++)
65
- interiorRing.push(Point._readWkbPoint(value, options));
66
- polygon.interiorRings.push(interiorRing);
67
- }
68
- }
69
- return polygon;
70
- };
71
- Polygon._parseTwkb = function (value, options) {
72
- const polygon = new Polygon();
73
- polygon.hasZ = options.hasZ;
74
- polygon.hasM = options.hasM;
75
- if (options.isEmpty)
76
- return polygon;
77
- const previousPoint = new Point(0, 0, options.hasZ ? 0 : undefined, options.hasM ? 0 : undefined);
78
- const ringCount = value.readVarInt();
79
- const exteriorRingCount = value.readVarInt();
80
- for (var i = 0; i < exteriorRingCount; i++)
81
- polygon.exteriorRing.push(Point._readTwkbPoint(value, options, previousPoint));
82
- for (i = 1; i < ringCount; i++) {
83
- const interiorRing = [];
84
- const interiorRingCount = value.readVarInt();
85
- for (let j = 0; j < interiorRingCount; j++)
86
- interiorRing.push(Point._readTwkbPoint(value, options, previousPoint));
87
- polygon.interiorRings.push(interiorRing);
88
- }
89
- return polygon;
90
- };
91
- Polygon._parseGeoJSON = function (value) {
92
- const polygon = new Polygon();
93
- if (value.coordinates.length > 0 && value.coordinates[0].length > 0)
94
- polygon.hasZ = value.coordinates[0][0].length > 2;
95
- for (let i = 0; i < value.coordinates.length; i++) {
96
- if (i > 0)
97
- polygon.interiorRings.push([]);
98
- for (let j = 0; j < value.coordinates[i].length; j++) {
99
- if (i === 0)
100
- polygon.exteriorRing.push(Point._readGeoJSONPoint(value.coordinates[i][j]));
101
- else
102
- polygon.interiorRings[i - 1].push(Point._readGeoJSONPoint(value.coordinates[i][j]));
103
- }
104
- }
105
- return polygon;
106
- };
107
- Polygon.prototype.toWkt = function () {
108
- if (this.exteriorRing.length === 0)
109
- return this._getWktType(Types.wkt.Polygon, true);
110
- return this._getWktType(Types.wkt.Polygon, false) + this._toInnerWkt();
111
- };
112
- Polygon.prototype._toInnerWkt = function () {
113
- let innerWkt = '((';
114
- for (var i = 0; i < this.exteriorRing.length; i++)
115
- innerWkt += this._getWktCoordinate(this.exteriorRing[i]) + ',';
116
- innerWkt = innerWkt.slice(0, -1);
117
- innerWkt += ')';
118
- for (i = 0; i < this.interiorRings.length; i++) {
119
- innerWkt += ',(';
120
- for (let j = 0; j < this.interiorRings[i].length; j++) {
121
- innerWkt += this._getWktCoordinate(this.interiorRings[i][j]) + ',';
122
- }
123
- innerWkt = innerWkt.slice(0, -1);
124
- innerWkt += ')';
125
- }
126
- innerWkt += ')';
127
- return innerWkt;
128
- };
129
- Polygon.prototype.toWkb = function (parentOptions) {
130
- const wkb = new BinaryWriter(this._getWkbSize());
131
- wkb.writeInt8(1);
132
- this._writeWkbType(wkb, Types.wkb.Polygon, parentOptions);
133
- if (this.exteriorRing.length > 0) {
134
- wkb.writeUInt32LE(1 + this.interiorRings.length);
135
- wkb.writeUInt32LE(this.exteriorRing.length);
136
- }
137
- else {
138
- wkb.writeUInt32LE(0);
139
- }
140
- for (var i = 0; i < this.exteriorRing.length; i++)
141
- this.exteriorRing[i]._writeWkbPoint(wkb);
142
- for (i = 0; i < this.interiorRings.length; i++) {
143
- wkb.writeUInt32LE(this.interiorRings[i].length);
144
- for (let j = 0; j < this.interiorRings[i].length; j++)
145
- this.interiorRings[i][j]._writeWkbPoint(wkb);
146
- }
147
- return wkb.buffer;
148
- };
149
- Polygon.prototype.toTwkb = function () {
150
- const twkb = new BinaryWriter(0, true);
151
- const precision = Geometry.getTwkbPrecision(5, 0, 0);
152
- const isEmpty = this.exteriorRing.length === 0;
153
- this._writeTwkbHeader(twkb, Types.wkb.Polygon, precision, isEmpty);
154
- if (this.exteriorRing.length > 0) {
155
- twkb.writeVarInt(1 + this.interiorRings.length);
156
- twkb.writeVarInt(this.exteriorRing.length);
157
- const previousPoint = new Point(0, 0, 0, 0);
158
- for (var i = 0; i < this.exteriorRing.length; i++)
159
- this.exteriorRing[i]._writeTwkbPoint(twkb, precision, previousPoint);
160
- for (i = 0; i < this.interiorRings.length; i++) {
161
- twkb.writeVarInt(this.interiorRings[i].length);
162
- for (let j = 0; j < this.interiorRings[i].length; j++)
163
- this.interiorRings[i][j]._writeTwkbPoint(twkb, precision, previousPoint);
164
- }
165
- }
166
- return twkb.buffer;
167
- };
168
- Polygon.prototype._getWkbSize = function () {
169
- let coordinateSize = 16;
170
- if (this.hasZ)
171
- coordinateSize += 8;
172
- if (this.hasM)
173
- coordinateSize += 8;
174
- let size = 1 + 4 + 4;
175
- if (this.exteriorRing.length > 0)
176
- size += 4 + this.exteriorRing.length * coordinateSize;
177
- for (let i = 0; i < this.interiorRings.length; i++)
178
- size += 4 + this.interiorRings[i].length * coordinateSize;
179
- return size;
180
- };
181
- Polygon.prototype.toGeoJSON = function (options) {
182
- const geoJSON = Geometry.prototype.toGeoJSON.call(this, options);
183
- geoJSON.type = Types.geoJSON.Polygon;
184
- geoJSON.coordinates = [];
185
- if (this.exteriorRing.length > 0) {
186
- const exteriorRing = [];
187
- for (let i = 0; i < this.exteriorRing.length; i++) {
188
- if (this.hasZ)
189
- exteriorRing.push([this.exteriorRing[i].x, this.exteriorRing[i].y, this.exteriorRing[i].z]);
190
- else
191
- exteriorRing.push([this.exteriorRing[i].x, this.exteriorRing[i].y]);
192
- }
193
- geoJSON.coordinates.push(exteriorRing);
194
- }
195
- for (let j = 0; j < this.interiorRings.length; j++) {
196
- const interiorRing = [];
197
- for (let k = 0; k < this.interiorRings[j].length; k++) {
198
- if (this.hasZ)
199
- interiorRing.push([this.interiorRings[j][k].x, this.interiorRings[j][k].y, this.interiorRings[j][k].z]);
200
- else
201
- interiorRing.push([this.interiorRings[j][k].x, this.interiorRings[j][k].y]);
202
- }
203
- geoJSON.coordinates.push(interiorRing);
204
- }
205
- return geoJSON;
206
- };
207
- export default Polygon;
@@ -1,30 +0,0 @@
1
- declare const _default: {
2
- geoJSON: {
3
- GeometryCollection: string;
4
- LineString: string;
5
- MultiLineString: string;
6
- MultiPoint: string;
7
- MultiPolygon: string;
8
- Point: string;
9
- Polygon: string;
10
- };
11
- wkb: {
12
- GeometryCollection: number;
13
- LineString: number;
14
- MultiLineString: number;
15
- MultiPoint: number;
16
- MultiPolygon: number;
17
- Point: number;
18
- Polygon: number;
19
- };
20
- wkt: {
21
- GeometryCollection: string;
22
- LineString: string;
23
- MultiLineString: string;
24
- MultiPoint: string;
25
- MultiPolygon: string;
26
- Point: string;
27
- Polygon: string;
28
- };
29
- };
30
- export default _default;
@@ -1,29 +0,0 @@
1
- export default {
2
- geoJSON: {
3
- GeometryCollection: 'GeometryCollection',
4
- LineString: 'LineString',
5
- MultiLineString: 'MultiLineString',
6
- MultiPoint: 'MultiPoint',
7
- MultiPolygon: 'MultiPolygon',
8
- Point: 'Point',
9
- Polygon: 'Polygon'
10
- },
11
- wkb: {
12
- GeometryCollection: 7,
13
- LineString: 2,
14
- MultiLineString: 5,
15
- MultiPoint: 4,
16
- MultiPolygon: 6,
17
- Point: 1,
18
- Polygon: 3
19
- },
20
- wkt: {
21
- GeometryCollection: 'GEOMETRYCOLLECTION',
22
- LineString: 'LINESTRING',
23
- MultiLineString: 'MULTILINESTRING',
24
- MultiPoint: 'MULTIPOINT',
25
- MultiPolygon: 'MULTIPOLYGON',
26
- Point: 'POINT',
27
- Polygon: 'POLYGON'
28
- }
29
- };
@@ -1,2 +0,0 @@
1
- declare function WktParser(value: any): void;
2
- export default WktParser;
@@ -1,111 +0,0 @@
1
- /* eslint-disable @typescript-eslint/ban-ts-comment */
2
- // @ts-nocheck
3
- import Point from './point.js';
4
- import Types from './types.js';
5
- function WktParser(value) {
6
- this.value = value;
7
- this.position = 0;
8
- }
9
- WktParser.prototype.match = function (tokens) {
10
- this.skipWhitespaces();
11
- for (const token of tokens) {
12
- if (this.value.slice(Math.max(0, this.position)).indexOf(token) === 0) {
13
- this.position += token.length;
14
- return token;
15
- }
16
- }
17
- return null;
18
- };
19
- WktParser.prototype.matchRegex = function (tokens) {
20
- this.skipWhitespaces();
21
- for (const token of tokens) {
22
- const match = this.value.slice(Math.max(0, this.position)).match(token);
23
- if (match) {
24
- this.position += match[0].length;
25
- return match;
26
- }
27
- }
28
- return null;
29
- };
30
- WktParser.prototype.isMatch = function (tokens) {
31
- this.skipWhitespaces();
32
- for (const token of tokens) {
33
- if (this.value.slice(Math.max(0, this.position)).indexOf(token) === 0) {
34
- this.position += token.length;
35
- return true;
36
- }
37
- }
38
- return false;
39
- };
40
- WktParser.prototype.matchType = function () {
41
- const geometryType = this.match([
42
- Types.wkt.Point,
43
- Types.wkt.LineString,
44
- Types.wkt.Polygon,
45
- Types.wkt.MultiPoint,
46
- Types.wkt.MultiLineString,
47
- Types.wkt.MultiPolygon,
48
- Types.wkt.GeometryCollection
49
- ]);
50
- if (!geometryType)
51
- throw new Error('Expected geometry type');
52
- return geometryType;
53
- };
54
- WktParser.prototype.matchDimension = function () {
55
- const dimension = this.match(['ZM', 'Z', 'M']);
56
- switch (dimension) {
57
- case 'ZM': {
58
- return { hasM: true, hasZ: true };
59
- }
60
- case 'Z': {
61
- return { hasM: false, hasZ: true };
62
- }
63
- case 'M': {
64
- return { hasM: true, hasZ: false };
65
- }
66
- default: {
67
- return { hasM: false, hasZ: false };
68
- }
69
- }
70
- };
71
- WktParser.prototype.expectGroupStart = function () {
72
- if (!this.isMatch(['(']))
73
- throw new Error('Expected group start');
74
- };
75
- WktParser.prototype.expectGroupEnd = function () {
76
- if (!this.isMatch([')']))
77
- throw new Error('Expected group end');
78
- };
79
- WktParser.prototype.matchCoordinate = function (options) {
80
- let match;
81
- if (options.hasZ && options.hasM)
82
- match = this.matchRegex([/^(\S*)\s+(\S*)\s+(\S*)\s+([^\s),]*)/]);
83
- else if (options.hasZ || options.hasM)
84
- match = this.matchRegex([/^(\S*)\s+(\S*)\s+([^\s),]*)/]);
85
- else
86
- match = this.matchRegex([/^(\S*)\s+([^\s),]*)/]);
87
- if (!match)
88
- throw new Error('Expected coordinates');
89
- if (options.hasZ && options.hasM)
90
- return new Point(Number.parseFloat(match[1]), Number.parseFloat(match[2]), Number.parseFloat(match[3]), Number.parseFloat(match[4]));
91
- if (options.hasZ)
92
- return new Point(Number.parseFloat(match[1]), Number.parseFloat(match[2]), Number.parseFloat(match[3]));
93
- if (options.hasM)
94
- return new Point(Number.parseFloat(match[1]), Number.parseFloat(match[2]), undefined, Number.parseFloat(match[3]));
95
- return new Point(Number.parseFloat(match[1]), Number.parseFloat(match[2]));
96
- };
97
- WktParser.prototype.matchCoordinates = function (options) {
98
- const coordinates = [];
99
- do {
100
- const startsWithBracket = this.isMatch(['(']);
101
- coordinates.push(this.matchCoordinate(options));
102
- if (startsWithBracket)
103
- this.expectGroupEnd();
104
- } while (this.isMatch([',']));
105
- return coordinates;
106
- };
107
- WktParser.prototype.skipWhitespaces = function () {
108
- while (this.position < this.value.length && this.value[this.position] === ' ')
109
- this.position++;
110
- };
111
- export default WktParser;
@@ -1,9 +0,0 @@
1
- export * from './types.js';
2
- export * from './geometry.js';
3
- export * from './point.js';
4
- export * from './linestring.js';
5
- export * from './polygon.js';
6
- export * from './multipoint.js';
7
- export * from './multilinestring.js';
8
- export * from './multipolygon.js';
9
- export * from './geometrycollection.js';
@@ -1,9 +0,0 @@
1
- export * from './types.js';
2
- export * from './geometry.js';
3
- export * from './point.js';
4
- export * from './linestring.js';
5
- export * from './polygon.js';
6
- export * from './multipoint.js';
7
- export * from './multilinestring.js';
8
- export * from './multipolygon.js';
9
- export * from './geometrycollection.js';
@@ -1,5 +0,0 @@
1
- declare const _default: {
2
- decode(value: number): number;
3
- encode(value: number): number;
4
- };
5
- export default _default;
@@ -1,9 +0,0 @@
1
- /* eslint-disable no-bitwise */
2
- export default {
3
- decode(value) {
4
- return (value >> 1) ^ -(value & 1);
5
- },
6
- encode(value) {
7
- return (value << 1) ^ (value >> 31);
8
- }
9
- };
@@ -1,12 +0,0 @@
1
- import { SchemaGenerator } from './SchemaGenerator.js';
2
- import { SqlSyncRules } from './SqlSyncRules.js';
3
- import { SourceSchema } from './types.js';
4
- export declare class DartSchemaGenerator extends SchemaGenerator {
5
- readonly fileName = "schema.dart";
6
- readonly key = "dart";
7
- readonly label = "Dart";
8
- readonly mediaType = "text/x-dart";
9
- generate(source: SqlSyncRules, schema: SourceSchema): string;
10
- private generateColumn;
11
- private generateTable;
12
- }
@@ -1,35 +0,0 @@
1
- /* eslint-disable unicorn/filename-case */
2
- /* eslint-disable no-bitwise */
3
- import { TYPE_INTEGER, TYPE_REAL, TYPE_TEXT } from './ExpressionType.js';
4
- import { SchemaGenerator } from './SchemaGenerator.js';
5
- export class DartSchemaGenerator extends SchemaGenerator {
6
- fileName = 'schema.dart';
7
- key = 'dart';
8
- label = 'Dart';
9
- mediaType = 'text/x-dart';
10
- generate(source, schema) {
11
- const tables = super.getAllTables(source, schema);
12
- return `Schema([
13
- ${tables.map((table) => this.generateTable(table.name, table.columns)).join(',\n ')}
14
- ])
15
- `;
16
- }
17
- generateColumn(column) {
18
- const t = column.type;
19
- if (t.typeFlags & TYPE_TEXT) {
20
- return `Column.text('${column.name}')`;
21
- }
22
- if (t.typeFlags & TYPE_REAL) {
23
- return `Column.real('${column.name}')`;
24
- }
25
- if (t.typeFlags & TYPE_INTEGER) {
26
- return `Column.integer('${column.name}')`;
27
- }
28
- return `Column.text('${column.name}')`;
29
- }
30
- generateTable(name, columns) {
31
- return `Table('${name}', [
32
- ${columns.map((c) => this.generateColumn(c)).join(',\n ')}
33
- ])`;
34
- }
35
- }
@@ -1,33 +0,0 @@
1
- export declare const TYPE_NONE = 0;
2
- export declare const TYPE_BLOB = 1;
3
- export declare const TYPE_TEXT = 2;
4
- export declare const TYPE_INTEGER = 4;
5
- export declare const TYPE_REAL = 8;
6
- export type SqliteType = 'blob' | 'integer' | 'null' | 'real' | 'text';
7
- export interface ColumnDefinition {
8
- name: string;
9
- type: ExpressionType;
10
- }
11
- export declare class ExpressionType {
12
- /**
13
- * Any type.
14
- */
15
- static ANY: ExpressionType;
16
- static ANY_JSON: ExpressionType;
17
- static BLOB: ExpressionType;
18
- static INTEGER: ExpressionType;
19
- /**
20
- * Always null.
21
- */
22
- static NONE: ExpressionType;
23
- static NUMERIC: ExpressionType;
24
- static REAL: ExpressionType;
25
- static TEXT: ExpressionType;
26
- readonly typeFlags: number;
27
- private constructor();
28
- static fromTypeText(type: 'numeric' | SqliteType): ExpressionType;
29
- static of(typeFlags: number): ExpressionType;
30
- and(other: ExpressionType): ExpressionType;
31
- isNumericOnly(): boolean;
32
- or(other: ExpressionType): ExpressionType;
33
- }
@@ -1,62 +0,0 @@
1
- /* eslint-disable unicorn/filename-case */
2
- /* eslint-disable eqeqeq */
3
- /* eslint-disable no-bitwise */
4
- export const TYPE_NONE = 0;
5
- export const TYPE_BLOB = 1;
6
- export const TYPE_TEXT = 2;
7
- export const TYPE_INTEGER = 4;
8
- export const TYPE_REAL = 8;
9
- export class ExpressionType {
10
- /**
11
- * Any type.
12
- */
13
- static ANY = new ExpressionType(TYPE_BLOB | TYPE_TEXT | TYPE_INTEGER | TYPE_REAL);
14
- static ANY_JSON = new ExpressionType(TYPE_TEXT | TYPE_INTEGER | TYPE_REAL);
15
- static BLOB = new ExpressionType(TYPE_BLOB);
16
- static INTEGER = new ExpressionType(TYPE_INTEGER);
17
- /**
18
- * Always null.
19
- */
20
- static NONE = new ExpressionType(0);
21
- static NUMERIC = new ExpressionType(TYPE_INTEGER | TYPE_REAL);
22
- static REAL = new ExpressionType(TYPE_REAL);
23
- static TEXT = new ExpressionType(TYPE_TEXT);
24
- typeFlags;
25
- constructor(typeFlags) {
26
- this.typeFlags = typeFlags;
27
- }
28
- static fromTypeText(type) {
29
- if (type == 'null') {
30
- return ExpressionType.NONE;
31
- }
32
- if (type == 'blob') {
33
- return ExpressionType.BLOB;
34
- }
35
- if (type == 'text') {
36
- return ExpressionType.TEXT;
37
- }
38
- if (type == 'integer') {
39
- return ExpressionType.INTEGER;
40
- }
41
- if (type == 'real') {
42
- return ExpressionType.REAL;
43
- }
44
- if (type == 'numeric') {
45
- return ExpressionType.NUMERIC;
46
- }
47
- return ExpressionType.NONE;
48
- }
49
- static of(typeFlags) {
50
- // TODO: cache?
51
- return new ExpressionType(typeFlags);
52
- }
53
- and(other) {
54
- return ExpressionType.of(this.typeFlags & other.typeFlags);
55
- }
56
- isNumericOnly() {
57
- return this.typeFlags != TYPE_NONE && (this.typeFlags & (TYPE_INTEGER | TYPE_REAL)) == this.typeFlags;
58
- }
59
- or(other) {
60
- return ExpressionType.of(this.typeFlags | other.typeFlags);
61
- }
62
- }
@@ -1,4 +0,0 @@
1
- export declare class IdSequence {
2
- private count;
3
- nextId(): string;
4
- }
@@ -1,7 +0,0 @@
1
- /* eslint-disable unicorn/filename-case */
2
- export class IdSequence {
3
- count = 0;
4
- nextId() {
5
- return `${++this.count}`;
6
- }
7
- }
@@ -1,12 +0,0 @@
1
- import { SchemaGenerator } from './SchemaGenerator.js';
2
- import { SqlSyncRules } from './SqlSyncRules.js';
3
- import { SourceSchema } from './types.js';
4
- export declare class JsSchemaGenerator extends SchemaGenerator {
5
- readonly fileName = "schema.js";
6
- readonly key = "js";
7
- readonly label = "JavaScript";
8
- readonly mediaType = "application/javascript";
9
- generate(source: SqlSyncRules, schema: SourceSchema): string;
10
- private generateColumn;
11
- private generateTable;
12
- }
@@ -1,38 +0,0 @@
1
- /* eslint-disable unicorn/filename-case */
2
- /* eslint-disable no-bitwise */
3
- import { TYPE_INTEGER, TYPE_REAL, TYPE_TEXT } from './ExpressionType.js';
4
- import { SchemaGenerator } from './SchemaGenerator.js';
5
- export class JsSchemaGenerator extends SchemaGenerator {
6
- fileName = 'schema.js';
7
- key = 'js';
8
- label = 'JavaScript';
9
- mediaType = 'application/javascript';
10
- generate(source, schema) {
11
- const tables = super.getAllTables(source, schema);
12
- return `new Schema([
13
- ${tables.map((table) => this.generateTable(table.name, table.columns)).join(',\n ')}
14
- ])
15
- `;
16
- }
17
- generateColumn(column) {
18
- const t = column.type;
19
- if (t.typeFlags & TYPE_TEXT) {
20
- return `new Column({ name: '${column.name}', type: ColumnType.TEXT })`;
21
- }
22
- if (t.typeFlags & TYPE_REAL) {
23
- return `new Column({ name: '${column.name}', type: ColumnType.REAL })`;
24
- }
25
- if (t.typeFlags & TYPE_INTEGER) {
26
- return `new Column({ name: '${column.name}', type: ColumnType.INTEGER })`;
27
- }
28
- return `new Column({ name: '${column.name}', type: ColumnType.TEXT })`;
29
- }
30
- generateTable(name, columns) {
31
- return `new Table({
32
- name: '${name}',
33
- columns: [
34
- ${columns.map((c) => this.generateColumn(c)).join(',\n ')}
35
- ]
36
- })`;
37
- }
38
- }
@@ -1,14 +0,0 @@
1
- import { ColumnDefinition } from './ExpressionType.js';
2
- import { SqlSyncRules } from './SqlSyncRules.js';
3
- import { SourceSchema } from './types.js';
4
- export declare abstract class SchemaGenerator {
5
- protected getAllTables(source: SqlSyncRules, schema: SourceSchema): {
6
- columns: ColumnDefinition[];
7
- name: string;
8
- }[];
9
- abstract readonly fileName: string;
10
- abstract generate(source: SqlSyncRules, schema: SourceSchema): string;
11
- abstract readonly key: string;
12
- abstract readonly label: string;
13
- abstract readonly mediaType: string;
14
- }
@@ -1,24 +0,0 @@
1
- export class SchemaGenerator {
2
- getAllTables(source, schema) {
3
- const tables = {};
4
- for (const descriptor of source.bucket_descriptors) {
5
- for (const query of descriptor.data_queries) {
6
- const outTables = query.getColumnOutputs(schema);
7
- for (const table of outTables) {
8
- tables[table.name] ??= {};
9
- for (const column of table.columns) {
10
- if (column.name !== 'id') {
11
- tables[table.name][column.name] ??= column;
12
- }
13
- }
14
- }
15
- }
16
- }
17
- return Object.entries(tables).map(([name, columns]) => {
18
- return {
19
- columns: Object.values(columns),
20
- name
21
- };
22
- });
23
- }
24
- }
@@ -1,5 +0,0 @@
1
- export interface SourceTableInterface {
2
- readonly connectionTag: string;
3
- readonly schema: string;
4
- readonly table: string;
5
- }