@powersync/service-types 0.0.0-dev-20240918082156

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.
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.InstanceSchema = exports.DatabaseSchema = exports.ConnectionStatusV2 = exports.ConnectionStatus = exports.SyncRulesStatus = exports.TableInfo = exports.ReplicationError = void 0;
27
+ const t = __importStar(require("ts-codec"));
28
+ exports.ReplicationError = t.object({
29
+ /** Warning: Could indicate an issue. Fatal: Prevents replicating. */
30
+ level: t.literal('warning').or(t.literal('fatal')),
31
+ message: t.string
32
+ });
33
+ exports.TableInfo = t.object({
34
+ schema: t.string,
35
+ name: t.string,
36
+ /** Specified if this table is part of a wildcard pattern. */
37
+ pattern: t.string.optional(),
38
+ /** Usually just ['id'] */
39
+ replication_id: t.array(t.string),
40
+ /** Used in data replication */
41
+ data_queries: t.boolean,
42
+ /** Used for parameter query replication */
43
+ parameter_queries: t.boolean,
44
+ /** Also included in the global errors array. */
45
+ errors: t.array(exports.ReplicationError)
46
+ });
47
+ exports.SyncRulesStatus = t.object({
48
+ content: t.string.optional(),
49
+ connections: t.array(t.object({
50
+ id: t.string,
51
+ tag: t.string,
52
+ /**
53
+ * PostgreSQL logical replication slot name.
54
+ */
55
+ slot_name: t.string,
56
+ /**
57
+ * Once initial replication is done, this moves over to
58
+ * logical replication.
59
+ */
60
+ initial_replication_done: t.boolean,
61
+ /**
62
+ * The last LSN that has been replicated. This may be in the middle of a transaction.
63
+ */
64
+ last_lsn: t.string.optional(),
65
+ /**
66
+ * The last time any replication activity was recorded.
67
+ *
68
+ * This is typically (but not always) updated together with last_lsn
69
+ */
70
+ last_keepalive_ts: t.string.optional(),
71
+ /**
72
+ * The last time we created a new checkpoint. In other words, a transaction
73
+ * was successfully replicated.
74
+ */
75
+ last_checkpoint_ts: t.string.optional(),
76
+ /** Replication lag in bytes. undefined if we cannot calculate this. */
77
+ replication_lag_bytes: t.number.optional(),
78
+ tables: t.array(exports.TableInfo)
79
+ })),
80
+ /** Sync-rule-level errors */
81
+ errors: t.array(exports.ReplicationError)
82
+ });
83
+ exports.ConnectionStatus = t.object({
84
+ id: t.string,
85
+ postgres_uri: t.string,
86
+ connected: t.boolean,
87
+ /** Connection-level errors */
88
+ errors: t.array(exports.ReplicationError)
89
+ });
90
+ exports.ConnectionStatusV2 = t.object({
91
+ id: t.string,
92
+ uri: t.string,
93
+ connected: t.boolean,
94
+ /** Connection-level errors */
95
+ errors: t.array(exports.ReplicationError)
96
+ });
97
+ exports.DatabaseSchema = t.object({
98
+ name: t.string,
99
+ tables: t.array(t.object({
100
+ name: t.string,
101
+ columns: t.array(t.object({
102
+ name: t.string,
103
+ /**
104
+ * Full type name, e.g. "character varying(255)[]"
105
+ */
106
+ type: t.string,
107
+ /**
108
+ * Internal postgres type, e.g. "varchar[]".
109
+ */
110
+ pg_type: t.string
111
+ }))
112
+ }))
113
+ });
114
+ exports.InstanceSchema = t.object({
115
+ connections: t.array(t.object({
116
+ id: t.string.optional(),
117
+ tag: t.string,
118
+ schemas: t.array(exports.DatabaseSchema)
119
+ }))
120
+ });
121
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../src/definitions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAEjB,QAAA,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,qEAAqE;IACrE,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAClD,OAAO,EAAE,CAAC,CAAC,MAAM;CAClB,CAAC,CAAC;AAGU,QAAA,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,MAAM,EAAE,CAAC,CAAC,MAAM;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM;IAEd,6DAA6D;IAC7D,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE;IAE5B,0BAA0B;IAC1B,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;IACjC,+BAA+B;IAC/B,YAAY,EAAE,CAAC,CAAC,OAAO;IACvB,2CAA2C;IAC3C,iBAAiB,EAAE,CAAC,CAAC,OAAO;IAE5B,gDAAgD;IAChD,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,wBAAgB,CAAC;CAClC,CAAC,CAAC;AAGU,QAAA,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE;IAC5B,WAAW,EAAE,CAAC,CAAC,KAAK,CAClB,CAAC,CAAC,MAAM,CAAC;QACP,EAAE,EAAE,CAAC,CAAC,MAAM;QACZ,GAAG,EAAE,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,CAAC,CAAC,MAAM;QACd,OAAO,EAAE,CAAC,CAAC,KAAK,CACd,CAAC,CAAC,MAAM,CAAC;YACP,IAAI,EAAE,CAAC,CAAC,MAAM;YACd;;eAEG;YACH,IAAI,EAAE,CAAC,CAAC,MAAM;YACd;;eAEG;YACH,OAAO,EAAE,CAAC,CAAC,MAAM;SAClB,CAAC,CACH;KACF,CAAC,CACH;CACF,CAAC,CAAC;AAGU,QAAA,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,WAAW,EAAE,CAAC,CAAC,KAAK,CAClB,CAAC,CAAC,MAAM,CAAC;QACP,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE;QACvB,GAAG,EAAE,CAAC,CAAC,MAAM;QACb,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,sBAAc,CAAC;KACjC,CAAC,CACH;CACF,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * as configFile from './config/PowerSyncConfig.js';
2
+ export * from './definitions.js';
3
+ export * from './config/normalize.js';
4
+ export * as internal_routes from './routes.js';
package/dist/index.js ADDED
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.internal_routes = exports.configFile = void 0;
30
+ exports.configFile = __importStar(require("./config/PowerSyncConfig.js"));
31
+ __exportStar(require("./definitions.js"), exports);
32
+ __exportStar(require("./config/normalize.js"), exports);
33
+ exports.internal_routes = __importStar(require("./routes.js"));
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0EAA0D;AAE1D,mDAAiC;AACjC,wDAAsC;AACtC,+DAA+C"}
@@ -0,0 +1,228 @@
1
+ import * as t from 'ts-codec';
2
+ export declare const GetSchemaRequest: t.ObjectCodec<{}>;
3
+ export type GetSchemaRequest = t.Encoded<typeof GetSchemaRequest>;
4
+ export declare const GetSchemaResponse: t.ObjectCodec<{
5
+ connections: t.ArrayCodec<t.ObjectCodec<{
6
+ id: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
7
+ tag: t.IdentityCodec<t.CodecType.String>;
8
+ schemas: t.ArrayCodec<t.ObjectCodec<{
9
+ name: t.IdentityCodec<t.CodecType.String>;
10
+ tables: t.ArrayCodec<t.ObjectCodec<{
11
+ name: t.IdentityCodec<t.CodecType.String>;
12
+ columns: t.ArrayCodec<t.ObjectCodec<{
13
+ name: t.IdentityCodec<t.CodecType.String>;
14
+ type: t.IdentityCodec<t.CodecType.String>;
15
+ pg_type: t.IdentityCodec<t.CodecType.String>;
16
+ }>>;
17
+ }>>;
18
+ }>>;
19
+ }>>;
20
+ }>;
21
+ export type GetSchemaResponse = t.Encoded<typeof GetSchemaResponse>;
22
+ export declare const ExecuteSqlRequest: t.ObjectCodec<{
23
+ connection_id: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
24
+ sql: t.ObjectCodec<{
25
+ query: t.IdentityCodec<t.CodecType.String>;
26
+ args: t.ArrayCodec<t.Union<t.Codec<string | number, string | number, string, t.CodecProps>, t.IdentityCodec<t.CodecType.Boolean>>>;
27
+ }>;
28
+ }>;
29
+ export type ExecuteSqlRequest = t.Encoded<typeof ExecuteSqlRequest>;
30
+ export declare const ExecuteSqlResponse: t.ObjectCodec<{
31
+ success: t.IdentityCodec<t.CodecType.Boolean>;
32
+ results: t.ObjectCodec<{
33
+ columns: t.ArrayCodec<t.IdentityCodec<t.CodecType.String>>;
34
+ rows: t.ArrayCodec<t.ArrayCodec<t.Union<t.Codec<string | number | boolean, string | number | boolean, string, t.CodecProps>, t.Codec<null, null, t.CodecType.Null, t.CodecProps>>>>;
35
+ }>;
36
+ /** Set if success = false */
37
+ error: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
38
+ }>;
39
+ export type ExecuteSqlResponse = t.Encoded<typeof ExecuteSqlResponse>;
40
+ export declare const DiagnosticsRequest: t.ObjectCodec<{
41
+ sync_rules_content: t.OptionalCodec<t.Codec<boolean, boolean, string, t.CodecProps>>;
42
+ }>;
43
+ export type DiagnosticsRequest = t.Encoded<typeof DiagnosticsRequest>;
44
+ export declare const DiagnosticsResponse: t.ObjectCodec<{
45
+ /**
46
+ * Connection-level errors are listed here.
47
+ */
48
+ connections: t.ArrayCodec<t.ObjectCodec<{
49
+ id: t.IdentityCodec<t.CodecType.String>;
50
+ postgres_uri: t.IdentityCodec<t.CodecType.String>;
51
+ connected: t.IdentityCodec<t.CodecType.Boolean>;
52
+ errors: t.ArrayCodec<t.ObjectCodec<{
53
+ level: t.Union<t.Codec<"warning", "warning", string, t.CodecProps>, t.LiteralCodec<"fatal">>;
54
+ message: t.IdentityCodec<t.CodecType.String>;
55
+ }>>;
56
+ }>>;
57
+ /**
58
+ * Present if there are fully-deployed sync rules.
59
+ *
60
+ * Sync-rule-level errors are listed here.
61
+ */
62
+ active_sync_rules: t.OptionalCodec<t.Codec<{
63
+ errors: {
64
+ level: "warning" | "fatal";
65
+ message: string;
66
+ }[];
67
+ connections: {
68
+ id: string;
69
+ tag: string;
70
+ slot_name: string;
71
+ initial_replication_done: boolean;
72
+ tables: {
73
+ schema: string;
74
+ name: string;
75
+ replication_id: string[];
76
+ data_queries: boolean;
77
+ parameter_queries: boolean;
78
+ errors: {
79
+ level: "warning" | "fatal";
80
+ message: string;
81
+ }[];
82
+ pattern?: string | undefined;
83
+ }[];
84
+ last_lsn?: string | undefined;
85
+ last_keepalive_ts?: string | undefined;
86
+ last_checkpoint_ts?: string | undefined;
87
+ replication_lag_bytes?: number | undefined;
88
+ }[];
89
+ content?: string | undefined;
90
+ }, {
91
+ errors: {
92
+ level: "warning" | "fatal";
93
+ message: string;
94
+ }[];
95
+ connections: {
96
+ id: string;
97
+ tag: string;
98
+ slot_name: string;
99
+ initial_replication_done: boolean;
100
+ tables: {
101
+ schema: string;
102
+ name: string;
103
+ replication_id: string[];
104
+ data_queries: boolean;
105
+ parameter_queries: boolean;
106
+ errors: {
107
+ level: "warning" | "fatal";
108
+ message: string;
109
+ }[];
110
+ pattern?: string | undefined;
111
+ }[];
112
+ last_lsn?: string | undefined;
113
+ last_keepalive_ts?: string | undefined;
114
+ last_checkpoint_ts?: string | undefined;
115
+ replication_lag_bytes?: number | undefined;
116
+ }[];
117
+ content?: string | undefined;
118
+ }, string, t.CodecProps>>;
119
+ /**
120
+ * Present if there are sync rules in the process of being deployed / initial replication.
121
+ *
122
+ * Once initial replication is done, this will be placed in `active_sync_rules`.
123
+ *
124
+ * Sync-rule-level errors are listed here.
125
+ */
126
+ deploying_sync_rules: t.OptionalCodec<t.Codec<{
127
+ errors: {
128
+ level: "warning" | "fatal";
129
+ message: string;
130
+ }[];
131
+ connections: {
132
+ id: string;
133
+ tag: string;
134
+ slot_name: string;
135
+ initial_replication_done: boolean;
136
+ tables: {
137
+ schema: string;
138
+ name: string;
139
+ replication_id: string[];
140
+ data_queries: boolean;
141
+ parameter_queries: boolean;
142
+ errors: {
143
+ level: "warning" | "fatal";
144
+ message: string;
145
+ }[];
146
+ pattern?: string | undefined;
147
+ }[];
148
+ last_lsn?: string | undefined;
149
+ last_keepalive_ts?: string | undefined;
150
+ last_checkpoint_ts?: string | undefined;
151
+ replication_lag_bytes?: number | undefined;
152
+ }[];
153
+ content?: string | undefined;
154
+ }, {
155
+ errors: {
156
+ level: "warning" | "fatal";
157
+ message: string;
158
+ }[];
159
+ connections: {
160
+ id: string;
161
+ tag: string;
162
+ slot_name: string;
163
+ initial_replication_done: boolean;
164
+ tables: {
165
+ schema: string;
166
+ name: string;
167
+ replication_id: string[];
168
+ data_queries: boolean;
169
+ parameter_queries: boolean;
170
+ errors: {
171
+ level: "warning" | "fatal";
172
+ message: string;
173
+ }[];
174
+ pattern?: string | undefined;
175
+ }[];
176
+ last_lsn?: string | undefined;
177
+ last_keepalive_ts?: string | undefined;
178
+ last_checkpoint_ts?: string | undefined;
179
+ replication_lag_bytes?: number | undefined;
180
+ }[];
181
+ content?: string | undefined;
182
+ }, string, t.CodecProps>>;
183
+ }>;
184
+ export type DiagnosticsResponse = t.Encoded<typeof DiagnosticsResponse>;
185
+ export declare const ReprocessRequest: t.ObjectCodec<{}>;
186
+ export type ReprocessRequest = t.Encoded<typeof ReprocessRequest>;
187
+ export declare const ReprocessResponse: t.ObjectCodec<{
188
+ connections: t.ArrayCodec<t.ObjectCodec<{
189
+ id: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
190
+ tag: t.IdentityCodec<t.CodecType.String>;
191
+ slot_name: t.IdentityCodec<t.CodecType.String>;
192
+ }>>;
193
+ }>;
194
+ export type ReprocessResponse = t.Encoded<typeof ReprocessResponse>;
195
+ export declare const ValidateRequest: t.ObjectCodec<{
196
+ sync_rules: t.IdentityCodec<t.CodecType.String>;
197
+ }>;
198
+ export type ValidateRequest = t.Encoded<typeof ValidateRequest>;
199
+ export declare const ValidateResponse: t.ObjectCodec<{
200
+ content: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
201
+ connections: t.ArrayCodec<t.ObjectCodec<{
202
+ id: t.IdentityCodec<t.CodecType.String>;
203
+ tag: t.IdentityCodec<t.CodecType.String>;
204
+ slot_name: t.IdentityCodec<t.CodecType.String>;
205
+ initial_replication_done: t.IdentityCodec<t.CodecType.Boolean>;
206
+ last_lsn: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
207
+ last_keepalive_ts: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
208
+ last_checkpoint_ts: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
209
+ replication_lag_bytes: t.OptionalCodec<t.Codec<number, number, string, t.CodecProps>>;
210
+ tables: t.ArrayCodec<t.ObjectCodec<{
211
+ schema: t.IdentityCodec<t.CodecType.String>;
212
+ name: t.IdentityCodec<t.CodecType.String>;
213
+ pattern: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
214
+ replication_id: t.ArrayCodec<t.IdentityCodec<t.CodecType.String>>;
215
+ data_queries: t.IdentityCodec<t.CodecType.Boolean>;
216
+ parameter_queries: t.IdentityCodec<t.CodecType.Boolean>;
217
+ errors: t.ArrayCodec<t.ObjectCodec<{
218
+ level: t.Union<t.Codec<"warning", "warning", string, t.CodecProps>, t.LiteralCodec<"fatal">>;
219
+ message: t.IdentityCodec<t.CodecType.String>;
220
+ }>>;
221
+ }>>;
222
+ }>>;
223
+ errors: t.ArrayCodec<t.ObjectCodec<{
224
+ level: t.Union<t.Codec<"warning", "warning", string, t.CodecProps>, t.LiteralCodec<"fatal">>;
225
+ message: t.IdentityCodec<t.CodecType.String>;
226
+ }>>;
227
+ }>;
228
+ export type ValidateResponse = t.Encoded<typeof ValidateResponse>;
package/dist/routes.js ADDED
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ValidateResponse = exports.ValidateRequest = exports.ReprocessResponse = exports.ReprocessRequest = exports.DiagnosticsResponse = exports.DiagnosticsRequest = exports.ExecuteSqlResponse = exports.ExecuteSqlRequest = exports.GetSchemaResponse = exports.GetSchemaRequest = void 0;
27
+ const t = __importStar(require("ts-codec"));
28
+ const definitions_1 = require("./definitions");
29
+ exports.GetSchemaRequest = t.object({});
30
+ exports.GetSchemaResponse = definitions_1.InstanceSchema;
31
+ exports.ExecuteSqlRequest = t.object({
32
+ connection_id: t.string.optional(),
33
+ sql: t.object({
34
+ query: t.string,
35
+ args: t.array(t.string.or(t.number).or(t.boolean))
36
+ })
37
+ });
38
+ exports.ExecuteSqlResponse = t.object({
39
+ success: t.boolean,
40
+ results: t.object({
41
+ columns: t.array(t.string),
42
+ rows: t.array(t.array(t.string.or(t.number).or(t.boolean).or(t.Null)))
43
+ }),
44
+ /** Set if success = false */
45
+ error: t.string.optional()
46
+ });
47
+ exports.DiagnosticsRequest = t.object({
48
+ sync_rules_content: t.boolean.optional()
49
+ });
50
+ exports.DiagnosticsResponse = t.object({
51
+ /**
52
+ * Connection-level errors are listed here.
53
+ */
54
+ connections: t.array(definitions_1.ConnectionStatus),
55
+ /**
56
+ * Present if there are fully-deployed sync rules.
57
+ *
58
+ * Sync-rule-level errors are listed here.
59
+ */
60
+ active_sync_rules: definitions_1.SyncRulesStatus.optional(),
61
+ /**
62
+ * Present if there are sync rules in the process of being deployed / initial replication.
63
+ *
64
+ * Once initial replication is done, this will be placed in `active_sync_rules`.
65
+ *
66
+ * Sync-rule-level errors are listed here.
67
+ */
68
+ deploying_sync_rules: definitions_1.SyncRulesStatus.optional()
69
+ });
70
+ exports.ReprocessRequest = t.object({});
71
+ exports.ReprocessResponse = t.object({
72
+ connections: t.array(t.object({
73
+ id: t.string.optional(),
74
+ tag: t.string,
75
+ slot_name: t.string
76
+ }))
77
+ });
78
+ exports.ValidateRequest = t.object({
79
+ sync_rules: t.string
80
+ });
81
+ exports.ValidateResponse = definitions_1.SyncRulesStatus;
82
+ //# sourceMappingURL=routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.js","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAC9B,+CAAkF;AAErE,QAAA,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAGhC,QAAA,iBAAiB,GAAG,4BAAc,CAAC;AAGnC,QAAA,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,aAAa,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE;IAClC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC;QACZ,KAAK,EAAE,CAAC,CAAC,MAAM;QACf,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAA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QACP,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE;QACvB,GAAG,EAAE,CAAC,CAAC,MAAM;QACb,SAAS,EAAE,CAAC,CAAC,MAAM;KACpB,CAAC,CACH;CACF,CAAC,CAAC;AAGU,QAAA,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,UAAU,EAAE,CAAC,CAAC,MAAM;CACrB,CAAC,CAAC;AAGU,QAAA,gBAAgB,GAAG,6BAAe,CAAC"}
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@powersync/service-types",
3
+ "version": "0.0.0-dev-20240918082156",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "license": "FSL-1.1-Apache-2.0",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "repository": "https://github.com/powersync-ja/powersync-service",
11
+ "dependencies": {
12
+ "ts-codec": "^1.2.2",
13
+ "uri-js": "^4.4.1"
14
+ },
15
+ "scripts": {
16
+ "clean": "rm -r ./dist && tsc -b --clean",
17
+ "build": "tsc -b"
18
+ }
19
+ }
@@ -0,0 +1,142 @@
1
+ import * as t from 'ts-codec';
2
+
3
+ /**
4
+ * Users might specify ports as strings if using YAML custom tag environment substitutions
5
+ */
6
+ export const portCodec = t.codec<number, number | string>(
7
+ 'Port',
8
+ (value) => value,
9
+ (value) => (typeof value == 'number' ? value : parseInt(value))
10
+ );
11
+
12
+ /**
13
+ * This gets used whenever generating a JSON schema
14
+ */
15
+ export const portParser = {
16
+ tag: portCodec._tag,
17
+ parse: () => ({
18
+ anyOf: [{ type: 'number' }, { type: 'string' }]
19
+ })
20
+ };
21
+
22
+ export const dataSourceConfig = t.object({
23
+ // Unique string identifier for the data source
24
+ type: t.string,
25
+ /** Unique identifier for the connection - optional when a single connection is present. */
26
+ id: t.string.optional(),
27
+ /** Additional meta tag for connection */
28
+ tag: t.string.optional(),
29
+ /**
30
+ * Allows for debug query execution
31
+ */
32
+ debug_api: t.boolean.optional()
33
+ });
34
+
35
+ export type DataSourceConfig = t.Decoded<typeof dataSourceConfig>;
36
+
37
+ /**
38
+ * This essentially allows any extra fields on this type
39
+ */
40
+ export const genericDataSourceConfig = dataSourceConfig.and(t.record(t.any));
41
+ export type GenericDataSourceConfig = t.Decoded<typeof genericDataSourceConfig>;
42
+
43
+ export const jwkRSA = t.object({
44
+ kty: t.literal('RSA'),
45
+ kid: t.string,
46
+ n: t.string,
47
+ e: t.string,
48
+ alg: t.literal('RS256').or(t.literal('RS384')).or(t.literal('RS512')).optional(),
49
+ use: t.string.optional()
50
+ });
51
+
52
+ export const jwkHmac = t.object({
53
+ kty: t.literal('oct'),
54
+ /**
55
+ * undefined kid indicates it can match any JWT, with or without a kid.
56
+ * Use a kid wherever possible.
57
+ */
58
+ kid: t.string.optional(),
59
+ k: t.string,
60
+ alg: t.literal('HS256').or(t.literal('HS384')).or(t.literal('HS512')),
61
+ use: t.string.optional()
62
+ });
63
+
64
+ const jwk = t.union(jwkRSA, jwkHmac);
65
+
66
+ export const strictJwks = t.object({
67
+ keys: t.array(jwk)
68
+ });
69
+
70
+ export type StrictJwk = t.Decoded<typeof jwk>;
71
+
72
+ export const storageConfig = t.object({
73
+ type: t.literal('mongodb'),
74
+ uri: t.string,
75
+ database: t.string.optional(),
76
+ username: t.string.optional(),
77
+ password: t.string.optional()
78
+ });
79
+
80
+ export type StorageConfig = t.Decoded<typeof storageConfig>;
81
+
82
+ export const powerSyncConfig = t.object({
83
+ replication: t
84
+ .object({
85
+ // This uses the generic config which may have additional fields
86
+ connections: t.array(genericDataSourceConfig).optional()
87
+ })
88
+ .optional(),
89
+
90
+ dev: t
91
+ .object({
92
+ demo_auth: t.boolean.optional(),
93
+ demo_password: t.string.optional(),
94
+ crud_api: t.boolean.optional(),
95
+ demo_client: t.boolean.optional()
96
+ })
97
+ .optional(),
98
+
99
+ client_auth: t
100
+ .object({
101
+ jwks_uri: t.string.or(t.array(t.string)).optional(),
102
+ block_local_jwks: t.boolean.optional(),
103
+ jwks: strictJwks.optional(),
104
+ supabase: t.boolean.optional(),
105
+ audience: t.array(t.string).optional()
106
+ })
107
+ .optional(),
108
+
109
+ api: t
110
+ .object({
111
+ tokens: t.array(t.string).optional()
112
+ })
113
+ .optional(),
114
+
115
+ storage: storageConfig,
116
+
117
+ port: portCodec.optional(),
118
+ sync_rules: t
119
+ .object({
120
+ path: t.string.optional(),
121
+ content: t.string.optional()
122
+ })
123
+ .optional(),
124
+
125
+ metadata: t.record(t.string).optional(),
126
+
127
+ migrations: t
128
+ .object({
129
+ disable_auto_migration: t.boolean.optional()
130
+ })
131
+ .optional(),
132
+
133
+ telemetry: t
134
+ .object({
135
+ disable_telemetry_sharing: t.boolean,
136
+ internal_service_endpoint: t.string.optional()
137
+ })
138
+ .optional()
139
+ });
140
+
141
+ export type PowerSyncConfig = t.Decoded<typeof powerSyncConfig>;
142
+ export type SerializedPowerSyncConfig = t.Encoded<typeof powerSyncConfig>;
File without changes