@powersync/service-types 0.1.0 → 0.3.0
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.
- package/CHANGELOG.md +21 -0
- package/dist/config/PowerSyncConfig.d.ts +51 -52
- package/dist/config/PowerSyncConfig.js +29 -28
- package/dist/config/PowerSyncConfig.js.map +1 -1
- package/dist/config/normalize.d.ts +1 -32
- package/dist/config/normalize.js +0 -108
- package/dist/config/normalize.js.map +1 -1
- package/dist/definitions.d.ts +82 -0
- package/dist/definitions.js +49 -15
- package/dist/definitions.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js.map +1 -1
- package/dist/routes.d.ts +5 -13
- package/dist/routes.js +1 -12
- package/dist/routes.js.map +1 -1
- package/package.json +1 -1
- package/src/config/PowerSyncConfig.ts +37 -32
- package/src/config/normalize.ts +0 -114
- package/src/definitions.ts +57 -16
- package/src/index.ts +0 -1
- package/src/routes.ts +0 -15
- package/tsconfig.json +2 -2
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @powersync/service-types
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 57bd18b: - Introduced modules to the powersync service architecture
|
|
8
|
+
- Core functionality has been moved to "engine" classes. Modules can register additional functionality with these engines.
|
|
9
|
+
- The sync API functionality used by the routes has been abstracted to an interface. API routes are now managed by the RouterEngine.
|
|
10
|
+
- Replication is managed by the ReplicationEngine and new replication data sources can be registered to the engine by modules.
|
|
11
|
+
- Refactored existing Postgres replication as a module.
|
|
12
|
+
- Removed Postgres specific code from the core service packages.
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 57bd18b: Updates from Replication events changes
|
|
17
|
+
|
|
18
|
+
## 0.2.0
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- c9ad713: Removed unused development routes
|
|
23
|
+
|
|
3
24
|
## 0.1.0
|
|
4
25
|
|
|
5
26
|
### Minor Changes
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import * as t from 'ts-codec';
|
|
2
|
+
/**
|
|
3
|
+
* Users might specify ports as strings if using YAML custom tag environment substitutions
|
|
4
|
+
*/
|
|
5
|
+
export declare const portCodec: t.Codec<number, string | number, string, t.CodecProps>;
|
|
2
6
|
/**
|
|
3
7
|
* This gets used whenever generating a JSON schema
|
|
4
8
|
*/
|
|
@@ -10,34 +14,52 @@ export declare const portParser: {
|
|
|
10
14
|
}[];
|
|
11
15
|
};
|
|
12
16
|
};
|
|
13
|
-
export declare const
|
|
14
|
-
type: t.
|
|
17
|
+
export declare const DataSourceConfig: t.ObjectCodec<{
|
|
18
|
+
type: t.IdentityCodec<t.CodecType.String>;
|
|
15
19
|
/** Unique identifier for the connection - optional when a single connection is present. */
|
|
16
20
|
id: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
|
|
17
|
-
/**
|
|
21
|
+
/** Additional meta tag for connection */
|
|
18
22
|
tag: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
|
|
19
|
-
uri: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
|
|
20
|
-
hostname: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
|
|
21
|
-
port: t.OptionalCodec<t.Codec<number, string | number, string, t.CodecProps>>;
|
|
22
|
-
username: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
|
|
23
|
-
password: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
|
|
24
|
-
database: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
|
|
25
|
-
/** Defaults to verify-full */
|
|
26
|
-
sslmode: t.OptionalCodec<t.Codec<"verify-full" | "verify-ca" | "disable", "verify-full" | "verify-ca" | "disable", string, t.CodecProps>>;
|
|
27
|
-
/** Required for verify-ca, optional for verify-full */
|
|
28
|
-
cacert: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
|
|
29
|
-
client_certificate: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
|
|
30
|
-
client_private_key: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
|
|
31
|
-
/** Expose database credentials */
|
|
32
|
-
demo_database: t.OptionalCodec<t.Codec<boolean, boolean, string, t.CodecProps>>;
|
|
33
|
-
/** Expose "execute-sql" */
|
|
34
|
-
debug_api: t.OptionalCodec<t.Codec<boolean, boolean, string, t.CodecProps>>;
|
|
35
23
|
/**
|
|
36
|
-
*
|
|
24
|
+
* Allows for debug query execution
|
|
37
25
|
*/
|
|
38
|
-
|
|
26
|
+
debug_api: t.OptionalCodec<t.Codec<boolean, boolean, string, t.CodecProps>>;
|
|
39
27
|
}>;
|
|
40
|
-
export type
|
|
28
|
+
export type DataSourceConfig = t.Decoded<typeof DataSourceConfig>;
|
|
29
|
+
/**
|
|
30
|
+
* Resolved version of {@link DataSourceConfig} where the optional
|
|
31
|
+
* `id` and `tag` field is now required.
|
|
32
|
+
*/
|
|
33
|
+
export declare const ResolvedDataSourceConfig: t.Intersection<t.Codec<{
|
|
34
|
+
type: string;
|
|
35
|
+
id?: string | undefined;
|
|
36
|
+
tag?: string | undefined;
|
|
37
|
+
debug_api?: boolean | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
type: string;
|
|
40
|
+
id?: string | undefined;
|
|
41
|
+
tag?: string | undefined;
|
|
42
|
+
debug_api?: boolean | undefined;
|
|
43
|
+
}, string, t.CodecProps>, t.ObjectCodec<{
|
|
44
|
+
id: t.IdentityCodec<t.CodecType.String>;
|
|
45
|
+
tag: t.IdentityCodec<t.CodecType.String>;
|
|
46
|
+
}>>;
|
|
47
|
+
export type ResolvedDataSourceConfig = t.Decoded<typeof ResolvedDataSourceConfig>;
|
|
48
|
+
/**
|
|
49
|
+
* This essentially allows any extra fields on this type
|
|
50
|
+
*/
|
|
51
|
+
export declare const genericDataSourceConfig: t.Intersection<t.Codec<{
|
|
52
|
+
type: string;
|
|
53
|
+
id?: string | undefined;
|
|
54
|
+
tag?: string | undefined;
|
|
55
|
+
debug_api?: boolean | undefined;
|
|
56
|
+
}, {
|
|
57
|
+
type: string;
|
|
58
|
+
id?: string | undefined;
|
|
59
|
+
tag?: string | undefined;
|
|
60
|
+
debug_api?: boolean | undefined;
|
|
61
|
+
}, string, t.CodecProps>, t.RecordCodec<t.Codec<any, any, t.CodecType.Any, t.CodecProps>>>;
|
|
62
|
+
export type GenericDataSourceConfig = t.Decoded<typeof genericDataSourceConfig>;
|
|
41
63
|
export declare const jwkRSA: t.ObjectCodec<{
|
|
42
64
|
kty: t.LiteralCodec<"RSA">;
|
|
43
65
|
kid: t.IdentityCodec<t.CodecType.String>;
|
|
@@ -106,43 +128,19 @@ export declare const storageConfig: t.ObjectCodec<{
|
|
|
106
128
|
export type StorageConfig = t.Decoded<typeof storageConfig>;
|
|
107
129
|
export declare const powerSyncConfig: t.ObjectCodec<{
|
|
108
130
|
replication: t.OptionalCodec<t.Codec<{
|
|
109
|
-
connections?: {
|
|
110
|
-
type:
|
|
131
|
+
connections?: ({
|
|
132
|
+
type: string;
|
|
111
133
|
id?: string | undefined;
|
|
112
134
|
tag?: string | undefined;
|
|
113
|
-
uri?: string | undefined;
|
|
114
|
-
hostname?: string | undefined;
|
|
115
|
-
port?: number | undefined;
|
|
116
|
-
username?: string | undefined;
|
|
117
|
-
password?: string | undefined;
|
|
118
|
-
database?: string | undefined;
|
|
119
|
-
sslmode?: "verify-full" | "verify-ca" | "disable" | undefined;
|
|
120
|
-
cacert?: string | undefined;
|
|
121
|
-
client_certificate?: string | undefined;
|
|
122
|
-
client_private_key?: string | undefined;
|
|
123
|
-
demo_database?: boolean | undefined;
|
|
124
135
|
debug_api?: boolean | undefined;
|
|
125
|
-
|
|
126
|
-
}[] | undefined;
|
|
136
|
+
} & Record<string, any>)[] | undefined;
|
|
127
137
|
}, {
|
|
128
|
-
connections?: {
|
|
129
|
-
type:
|
|
138
|
+
connections?: ({
|
|
139
|
+
type: string;
|
|
130
140
|
id?: string | undefined;
|
|
131
141
|
tag?: string | undefined;
|
|
132
|
-
uri?: string | undefined;
|
|
133
|
-
hostname?: string | undefined;
|
|
134
|
-
port?: string | number | undefined;
|
|
135
|
-
username?: string | undefined;
|
|
136
|
-
password?: string | undefined;
|
|
137
|
-
database?: string | undefined;
|
|
138
|
-
sslmode?: "verify-full" | "verify-ca" | "disable" | undefined;
|
|
139
|
-
cacert?: string | undefined;
|
|
140
|
-
client_certificate?: string | undefined;
|
|
141
|
-
client_private_key?: string | undefined;
|
|
142
|
-
demo_database?: boolean | undefined;
|
|
143
142
|
debug_api?: boolean | undefined;
|
|
144
|
-
|
|
145
|
-
}[] | undefined;
|
|
143
|
+
} & Record<string, any>)[] | undefined;
|
|
146
144
|
}, string, t.CodecProps>>;
|
|
147
145
|
dev: t.OptionalCodec<t.Codec<{
|
|
148
146
|
demo_auth?: boolean | undefined;
|
|
@@ -231,6 +229,7 @@ export declare const powerSyncConfig: t.ObjectCodec<{
|
|
|
231
229
|
disable_telemetry_sharing: boolean;
|
|
232
230
|
internal_service_endpoint?: string | undefined;
|
|
233
231
|
}, string, t.CodecProps>>;
|
|
232
|
+
parameters: t.OptionalCodec<t.Codec<Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>, string, t.CodecProps>>;
|
|
234
233
|
}>;
|
|
235
234
|
export type PowerSyncConfig = t.Decoded<typeof powerSyncConfig>;
|
|
236
235
|
export type SerializedPowerSyncConfig = t.Encoded<typeof powerSyncConfig>;
|
|
@@ -23,48 +23,45 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.powerSyncConfig = exports.storageConfig = exports.strictJwks = exports.jwkHmac = exports.jwkRSA = exports.
|
|
26
|
+
exports.powerSyncConfig = exports.storageConfig = exports.strictJwks = exports.jwkHmac = exports.jwkRSA = exports.genericDataSourceConfig = exports.ResolvedDataSourceConfig = exports.DataSourceConfig = exports.portParser = exports.portCodec = void 0;
|
|
27
27
|
const t = __importStar(require("ts-codec"));
|
|
28
28
|
/**
|
|
29
29
|
* Users might specify ports as strings if using YAML custom tag environment substitutions
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
exports.portCodec = t.codec('Port', (value) => value, (value) => (typeof value == 'number' ? value : parseInt(value)));
|
|
32
32
|
/**
|
|
33
33
|
* This gets used whenever generating a JSON schema
|
|
34
34
|
*/
|
|
35
35
|
exports.portParser = {
|
|
36
|
-
tag: portCodec._tag,
|
|
36
|
+
tag: exports.portCodec._tag,
|
|
37
37
|
parse: () => ({
|
|
38
38
|
anyOf: [{ type: 'number' }, { type: 'string' }]
|
|
39
39
|
})
|
|
40
40
|
};
|
|
41
|
-
exports.
|
|
42
|
-
|
|
41
|
+
exports.DataSourceConfig = t.object({
|
|
42
|
+
// Unique string identifier for the data source
|
|
43
|
+
type: t.string,
|
|
43
44
|
/** Unique identifier for the connection - optional when a single connection is present. */
|
|
44
45
|
id: t.string.optional(),
|
|
45
|
-
/**
|
|
46
|
+
/** Additional meta tag for connection */
|
|
46
47
|
tag: t.string.optional(),
|
|
47
|
-
uri: t.string.optional(),
|
|
48
|
-
hostname: t.string.optional(),
|
|
49
|
-
port: portCodec.optional(),
|
|
50
|
-
username: t.string.optional(),
|
|
51
|
-
password: t.string.optional(),
|
|
52
|
-
database: t.string.optional(),
|
|
53
|
-
/** Defaults to verify-full */
|
|
54
|
-
sslmode: t.literal('verify-full').or(t.literal('verify-ca')).or(t.literal('disable')).optional(),
|
|
55
|
-
/** Required for verify-ca, optional for verify-full */
|
|
56
|
-
cacert: t.string.optional(),
|
|
57
|
-
client_certificate: t.string.optional(),
|
|
58
|
-
client_private_key: t.string.optional(),
|
|
59
|
-
/** Expose database credentials */
|
|
60
|
-
demo_database: t.boolean.optional(),
|
|
61
|
-
/** Expose "execute-sql" */
|
|
62
|
-
debug_api: t.boolean.optional(),
|
|
63
48
|
/**
|
|
64
|
-
*
|
|
49
|
+
* Allows for debug query execution
|
|
65
50
|
*/
|
|
66
|
-
|
|
51
|
+
debug_api: t.boolean.optional()
|
|
67
52
|
});
|
|
53
|
+
/**
|
|
54
|
+
* Resolved version of {@link DataSourceConfig} where the optional
|
|
55
|
+
* `id` and `tag` field is now required.
|
|
56
|
+
*/
|
|
57
|
+
exports.ResolvedDataSourceConfig = exports.DataSourceConfig.and(t.object({
|
|
58
|
+
id: t.string,
|
|
59
|
+
tag: t.string
|
|
60
|
+
}));
|
|
61
|
+
/**
|
|
62
|
+
* This essentially allows any extra fields on this type
|
|
63
|
+
*/
|
|
64
|
+
exports.genericDataSourceConfig = exports.DataSourceConfig.and(t.record(t.any));
|
|
68
65
|
exports.jwkRSA = t.object({
|
|
69
66
|
kty: t.literal('RSA'),
|
|
70
67
|
kid: t.string,
|
|
@@ -98,7 +95,8 @@ exports.storageConfig = t.object({
|
|
|
98
95
|
exports.powerSyncConfig = t.object({
|
|
99
96
|
replication: t
|
|
100
97
|
.object({
|
|
101
|
-
|
|
98
|
+
// This uses the generic config which may have additional fields
|
|
99
|
+
connections: t.array(exports.genericDataSourceConfig).optional()
|
|
102
100
|
})
|
|
103
101
|
.optional(),
|
|
104
102
|
dev: t
|
|
@@ -124,7 +122,7 @@ exports.powerSyncConfig = t.object({
|
|
|
124
122
|
})
|
|
125
123
|
.optional(),
|
|
126
124
|
storage: exports.storageConfig,
|
|
127
|
-
port: portCodec.optional(),
|
|
125
|
+
port: exports.portCodec.optional(),
|
|
128
126
|
sync_rules: t
|
|
129
127
|
.object({
|
|
130
128
|
path: t.string.optional(),
|
|
@@ -137,9 +135,12 @@ exports.powerSyncConfig = t.object({
|
|
|
137
135
|
disable_auto_migration: t.boolean.optional()
|
|
138
136
|
})
|
|
139
137
|
.optional(),
|
|
140
|
-
telemetry: t
|
|
138
|
+
telemetry: t
|
|
139
|
+
.object({
|
|
141
140
|
disable_telemetry_sharing: t.boolean,
|
|
142
141
|
internal_service_endpoint: t.string.optional()
|
|
143
|
-
})
|
|
142
|
+
})
|
|
143
|
+
.optional(),
|
|
144
|
+
parameters: t.record(t.number.or(t.string).or(t.boolean).or(t.Null)).optional()
|
|
144
145
|
});
|
|
145
146
|
//# sourceMappingURL=PowerSyncConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PowerSyncConfig.js","sourceRoot":"","sources":["../../src/config/PowerSyncConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAE9B;;GAEG;
|
|
1
|
+
{"version":3,"file":"PowerSyncConfig.js","sourceRoot":"","sources":["../../src/config/PowerSyncConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAE9B;;GAEG;AACU,QAAA,SAAS,GAAG,CAAC,CAAC,KAAK,CAC9B,MAAM,EACN,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAChB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAChE,CAAC;AAEF;;GAEG;AACU,QAAA,UAAU,GAAG;IACxB,GAAG,EAAE,iBAAS,CAAC,IAAI;IACnB,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QACZ,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;KAChD,CAAC;CACH,CAAC;AAEW,QAAA,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,+CAA+C;IAC/C,IAAI,EAAE,CAAC,CAAC,MAAM;IACd,2FAA2F;IAC3F,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE;IACv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M,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE;CAChF,CAAC,CAAC"}
|
|
@@ -1,32 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Validate and normalize connection options.
|
|
4
|
-
*
|
|
5
|
-
* Returns destructured options.
|
|
6
|
-
*/
|
|
7
|
-
export declare function normalizeConnection(options: PostgresConnection): NormalizedPostgresConnection;
|
|
8
|
-
export interface NormalizedPostgresConnection {
|
|
9
|
-
id: string;
|
|
10
|
-
tag: string;
|
|
11
|
-
hostname: string;
|
|
12
|
-
port: number;
|
|
13
|
-
database: string;
|
|
14
|
-
username: string;
|
|
15
|
-
password: string;
|
|
16
|
-
sslmode: 'verify-full' | 'verify-ca' | 'disable';
|
|
17
|
-
cacert: string | undefined;
|
|
18
|
-
client_certificate: string | undefined;
|
|
19
|
-
client_private_key: string | undefined;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Check whether the port is in a "safe" range.
|
|
23
|
-
*
|
|
24
|
-
* We do not support connecting to "privileged" ports.
|
|
25
|
-
*/
|
|
26
|
-
export declare function validatePort(port: string | number): number;
|
|
27
|
-
/**
|
|
28
|
-
* Construct a postgres URI, without username, password or ssl options.
|
|
29
|
-
*
|
|
30
|
-
* Only contains hostname, port, database.
|
|
31
|
-
*/
|
|
32
|
-
export declare function baseUri(options: NormalizedPostgresConnection): string;
|
|
1
|
+
export {};
|
package/dist/config/normalize.js
CHANGED
|
@@ -1,111 +1,3 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.baseUri = exports.validatePort = exports.normalizeConnection = void 0;
|
|
27
|
-
const urijs = __importStar(require("uri-js"));
|
|
28
|
-
/**
|
|
29
|
-
* Validate and normalize connection options.
|
|
30
|
-
*
|
|
31
|
-
* Returns destructured options.
|
|
32
|
-
*/
|
|
33
|
-
function normalizeConnection(options) {
|
|
34
|
-
let uri;
|
|
35
|
-
if (options.uri) {
|
|
36
|
-
uri = urijs.parse(options.uri);
|
|
37
|
-
if (uri.scheme != 'postgresql' && uri.scheme != 'postgres') {
|
|
38
|
-
`Invalid URI - protocol must be postgresql, got ${uri.scheme}`;
|
|
39
|
-
}
|
|
40
|
-
else if (uri.scheme != 'postgresql') {
|
|
41
|
-
uri.scheme = 'postgresql';
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
uri = urijs.parse('postgresql:///');
|
|
46
|
-
}
|
|
47
|
-
const hostname = options.hostname ?? uri.host ?? '';
|
|
48
|
-
const port = validatePort(options.port ?? uri.port ?? 5432);
|
|
49
|
-
const database = options.database ?? uri.path?.substring(1) ?? '';
|
|
50
|
-
const [uri_username, uri_password] = (uri.userinfo ?? '').split(':');
|
|
51
|
-
const username = options.username ?? uri_username ?? '';
|
|
52
|
-
const password = options.password ?? uri_password ?? '';
|
|
53
|
-
const sslmode = options.sslmode ?? 'verify-full'; // Configuration not supported via URI
|
|
54
|
-
const cacert = options.cacert;
|
|
55
|
-
if (sslmode == 'verify-ca' && cacert == null) {
|
|
56
|
-
throw new Error('Explicit cacert is required for sslmode=verify-ca');
|
|
57
|
-
}
|
|
58
|
-
if (hostname == '') {
|
|
59
|
-
throw new Error(`hostname required`);
|
|
60
|
-
}
|
|
61
|
-
if (username == '') {
|
|
62
|
-
throw new Error(`username required`);
|
|
63
|
-
}
|
|
64
|
-
if (password == '') {
|
|
65
|
-
throw new Error(`password required`);
|
|
66
|
-
}
|
|
67
|
-
if (database == '') {
|
|
68
|
-
throw new Error(`database required`);
|
|
69
|
-
}
|
|
70
|
-
return {
|
|
71
|
-
id: options.id ?? 'default',
|
|
72
|
-
tag: options.tag ?? 'default',
|
|
73
|
-
hostname,
|
|
74
|
-
port,
|
|
75
|
-
database,
|
|
76
|
-
username,
|
|
77
|
-
password,
|
|
78
|
-
sslmode,
|
|
79
|
-
cacert,
|
|
80
|
-
client_certificate: options.client_certificate ?? undefined,
|
|
81
|
-
client_private_key: options.client_private_key ?? undefined
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
exports.normalizeConnection = normalizeConnection;
|
|
85
|
-
/**
|
|
86
|
-
* Check whether the port is in a "safe" range.
|
|
87
|
-
*
|
|
88
|
-
* We do not support connecting to "privileged" ports.
|
|
89
|
-
*/
|
|
90
|
-
function validatePort(port) {
|
|
91
|
-
if (typeof port == 'string') {
|
|
92
|
-
port = parseInt(port);
|
|
93
|
-
}
|
|
94
|
-
if (port >= 1024 && port <= 49151) {
|
|
95
|
-
return port;
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
throw new Error(`Port ${port} not supported`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
exports.validatePort = validatePort;
|
|
102
|
-
/**
|
|
103
|
-
* Construct a postgres URI, without username, password or ssl options.
|
|
104
|
-
*
|
|
105
|
-
* Only contains hostname, port, database.
|
|
106
|
-
*/
|
|
107
|
-
function baseUri(options) {
|
|
108
|
-
return `postgresql://${options.hostname}:${options.port}/${options.database}`;
|
|
109
|
-
}
|
|
110
|
-
exports.baseUri = baseUri;
|
|
111
3
|
//# sourceMappingURL=normalize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../src/config/normalize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../src/config/normalize.ts"],"names":[],"mappings":""}
|
package/dist/definitions.d.ts
CHANGED
|
@@ -94,18 +94,83 @@ export declare const ConnectionStatus: t.ObjectCodec<{
|
|
|
94
94
|
}>>;
|
|
95
95
|
}>;
|
|
96
96
|
export type ConnectionStatus = t.Encoded<typeof ConnectionStatus>;
|
|
97
|
+
export declare const ConnectionStatusV2: t.ObjectCodec<{
|
|
98
|
+
id: t.IdentityCodec<t.CodecType.String>;
|
|
99
|
+
uri: t.IdentityCodec<t.CodecType.String>;
|
|
100
|
+
connected: t.IdentityCodec<t.CodecType.Boolean>;
|
|
101
|
+
/** Connection-level errors */
|
|
102
|
+
errors: t.ArrayCodec<t.ObjectCodec<{
|
|
103
|
+
/** Warning: Could indicate an issue. Fatal: Prevents replicating. */
|
|
104
|
+
level: t.Union<t.Codec<"warning", "warning", string, t.CodecProps>, t.LiteralCodec<"fatal">>;
|
|
105
|
+
message: t.IdentityCodec<t.CodecType.String>;
|
|
106
|
+
}>>;
|
|
107
|
+
}>;
|
|
108
|
+
export type ConnectionStatusV2 = t.Encoded<typeof ConnectionStatusV2>;
|
|
109
|
+
export declare enum SqliteSchemaTypeText {
|
|
110
|
+
null = "null",
|
|
111
|
+
blob = "blob",
|
|
112
|
+
text = "text",
|
|
113
|
+
integer = "integer",
|
|
114
|
+
real = "real",
|
|
115
|
+
numeric = "numeric"
|
|
116
|
+
}
|
|
117
|
+
export declare const TableSchema: t.ObjectCodec<{
|
|
118
|
+
name: t.IdentityCodec<t.CodecType.String>;
|
|
119
|
+
columns: t.ArrayCodec<t.ObjectCodec<{
|
|
120
|
+
name: t.IdentityCodec<t.CodecType.String>;
|
|
121
|
+
/**
|
|
122
|
+
* Option 1: SQLite type flags - see ExpressionType.typeFlags.
|
|
123
|
+
* Option 2: SQLite type name in lowercase - 'text' | 'integer' | 'real' | 'numeric' | 'blob' | 'null'
|
|
124
|
+
*/
|
|
125
|
+
sqlite_type: t.Union<t.Codec<number, number, string, t.CodecProps>, t.EnumCodec<typeof SqliteSchemaTypeText>>;
|
|
126
|
+
/**
|
|
127
|
+
* Type name from the source database, e.g. "character varying(255)[]"
|
|
128
|
+
*/
|
|
129
|
+
internal_type: t.IdentityCodec<t.CodecType.String>;
|
|
130
|
+
/**
|
|
131
|
+
* Description for the field if available.
|
|
132
|
+
*/
|
|
133
|
+
description: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
|
|
134
|
+
/**
|
|
135
|
+
* Full type name, e.g. "character varying(255)[]"
|
|
136
|
+
* @deprecated - use internal_type
|
|
137
|
+
*/
|
|
138
|
+
type: t.IdentityCodec<t.CodecType.String>;
|
|
139
|
+
/**
|
|
140
|
+
* Internal postgres type, e.g. "varchar[]".
|
|
141
|
+
* @deprecated - use internal_type instead
|
|
142
|
+
*/
|
|
143
|
+
pg_type: t.IdentityCodec<t.CodecType.String>;
|
|
144
|
+
}>>;
|
|
145
|
+
}>;
|
|
146
|
+
export type TableSchema = t.Encoded<typeof TableSchema>;
|
|
97
147
|
export declare const DatabaseSchema: t.ObjectCodec<{
|
|
98
148
|
name: t.IdentityCodec<t.CodecType.String>;
|
|
99
149
|
tables: t.ArrayCodec<t.ObjectCodec<{
|
|
100
150
|
name: t.IdentityCodec<t.CodecType.String>;
|
|
101
151
|
columns: t.ArrayCodec<t.ObjectCodec<{
|
|
102
152
|
name: t.IdentityCodec<t.CodecType.String>;
|
|
153
|
+
/**
|
|
154
|
+
* Option 1: SQLite type flags - see ExpressionType.typeFlags.
|
|
155
|
+
* Option 2: SQLite type name in lowercase - 'text' | 'integer' | 'real' | 'numeric' | 'blob' | 'null'
|
|
156
|
+
*/
|
|
157
|
+
sqlite_type: t.Union<t.Codec<number, number, string, t.CodecProps>, t.EnumCodec<typeof SqliteSchemaTypeText>>;
|
|
158
|
+
/**
|
|
159
|
+
* Type name from the source database, e.g. "character varying(255)[]"
|
|
160
|
+
*/
|
|
161
|
+
internal_type: t.IdentityCodec<t.CodecType.String>;
|
|
162
|
+
/**
|
|
163
|
+
* Description for the field if available.
|
|
164
|
+
*/
|
|
165
|
+
description: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
|
|
103
166
|
/**
|
|
104
167
|
* Full type name, e.g. "character varying(255)[]"
|
|
168
|
+
* @deprecated - use internal_type
|
|
105
169
|
*/
|
|
106
170
|
type: t.IdentityCodec<t.CodecType.String>;
|
|
107
171
|
/**
|
|
108
172
|
* Internal postgres type, e.g. "varchar[]".
|
|
173
|
+
* @deprecated - use internal_type instead
|
|
109
174
|
*/
|
|
110
175
|
pg_type: t.IdentityCodec<t.CodecType.String>;
|
|
111
176
|
}>>;
|
|
@@ -122,17 +187,34 @@ export declare const InstanceSchema: t.ObjectCodec<{
|
|
|
122
187
|
name: t.IdentityCodec<t.CodecType.String>;
|
|
123
188
|
columns: t.ArrayCodec<t.ObjectCodec<{
|
|
124
189
|
name: t.IdentityCodec<t.CodecType.String>;
|
|
190
|
+
/**
|
|
191
|
+
* Option 1: SQLite type flags - see ExpressionType.typeFlags.
|
|
192
|
+
* Option 2: SQLite type name in lowercase - 'text' | 'integer' | 'real' | 'numeric' | 'blob' | 'null'
|
|
193
|
+
*/
|
|
194
|
+
sqlite_type: t.Union<t.Codec<number, number, string, t.CodecProps>, t.EnumCodec<typeof SqliteSchemaTypeText>>;
|
|
195
|
+
/**
|
|
196
|
+
* Type name from the source database, e.g. "character varying(255)[]"
|
|
197
|
+
*/
|
|
198
|
+
internal_type: t.IdentityCodec<t.CodecType.String>;
|
|
199
|
+
/**
|
|
200
|
+
* Description for the field if available.
|
|
201
|
+
*/
|
|
202
|
+
description: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
|
|
125
203
|
/**
|
|
126
204
|
* Full type name, e.g. "character varying(255)[]"
|
|
205
|
+
* @deprecated - use internal_type
|
|
127
206
|
*/
|
|
128
207
|
type: t.IdentityCodec<t.CodecType.String>;
|
|
129
208
|
/**
|
|
130
209
|
* Internal postgres type, e.g. "varchar[]".
|
|
210
|
+
* @deprecated - use internal_type instead
|
|
131
211
|
*/
|
|
132
212
|
pg_type: t.IdentityCodec<t.CodecType.String>;
|
|
133
213
|
}>>;
|
|
134
214
|
}>>;
|
|
135
215
|
}>>;
|
|
136
216
|
}>>;
|
|
217
|
+
defaultConnectionTag: t.IdentityCodec<t.CodecType.String>;
|
|
218
|
+
defaultSchema: t.IdentityCodec<t.CodecType.String>;
|
|
137
219
|
}>;
|
|
138
220
|
export type InstanceSchema = t.Encoded<typeof InstanceSchema>;
|
package/dist/definitions.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.InstanceSchema = exports.DatabaseSchema = exports.ConnectionStatus = exports.SyncRulesStatus = exports.TableInfo = exports.ReplicationError = void 0;
|
|
26
|
+
exports.InstanceSchema = exports.DatabaseSchema = exports.TableSchema = exports.SqliteSchemaTypeText = exports.ConnectionStatusV2 = exports.ConnectionStatus = exports.SyncRulesStatus = exports.TableInfo = exports.ReplicationError = void 0;
|
|
27
27
|
const t = __importStar(require("ts-codec"));
|
|
28
28
|
exports.ReplicationError = t.object({
|
|
29
29
|
/** Warning: Could indicate an issue. Fatal: Prevents replicating. */
|
|
@@ -87,28 +87,62 @@ exports.ConnectionStatus = t.object({
|
|
|
87
87
|
/** Connection-level errors */
|
|
88
88
|
errors: t.array(exports.ReplicationError)
|
|
89
89
|
});
|
|
90
|
-
exports.
|
|
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
|
+
var SqliteSchemaTypeText;
|
|
98
|
+
(function (SqliteSchemaTypeText) {
|
|
99
|
+
SqliteSchemaTypeText["null"] = "null";
|
|
100
|
+
SqliteSchemaTypeText["blob"] = "blob";
|
|
101
|
+
SqliteSchemaTypeText["text"] = "text";
|
|
102
|
+
SqliteSchemaTypeText["integer"] = "integer";
|
|
103
|
+
SqliteSchemaTypeText["real"] = "real";
|
|
104
|
+
SqliteSchemaTypeText["numeric"] = "numeric";
|
|
105
|
+
})(SqliteSchemaTypeText || (exports.SqliteSchemaTypeText = SqliteSchemaTypeText = {}));
|
|
106
|
+
exports.TableSchema = t.object({
|
|
91
107
|
name: t.string,
|
|
92
|
-
|
|
108
|
+
columns: t.array(t.object({
|
|
93
109
|
name: t.string,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Option 1: SQLite type flags - see ExpressionType.typeFlags.
|
|
112
|
+
* Option 2: SQLite type name in lowercase - 'text' | 'integer' | 'real' | 'numeric' | 'blob' | 'null'
|
|
113
|
+
*/
|
|
114
|
+
sqlite_type: t.number.or(t.Enum(SqliteSchemaTypeText)),
|
|
115
|
+
/**
|
|
116
|
+
* Type name from the source database, e.g. "character varying(255)[]"
|
|
117
|
+
*/
|
|
118
|
+
internal_type: t.string,
|
|
119
|
+
/**
|
|
120
|
+
* Description for the field if available.
|
|
121
|
+
*/
|
|
122
|
+
description: t.string.optional(),
|
|
123
|
+
/**
|
|
124
|
+
* Full type name, e.g. "character varying(255)[]"
|
|
125
|
+
* @deprecated - use internal_type
|
|
126
|
+
*/
|
|
127
|
+
type: t.string,
|
|
128
|
+
/**
|
|
129
|
+
* Internal postgres type, e.g. "varchar[]".
|
|
130
|
+
* @deprecated - use internal_type instead
|
|
131
|
+
*/
|
|
132
|
+
pg_type: t.string
|
|
105
133
|
}))
|
|
106
134
|
});
|
|
135
|
+
exports.DatabaseSchema = t.object({
|
|
136
|
+
name: t.string,
|
|
137
|
+
tables: t.array(exports.TableSchema)
|
|
138
|
+
});
|
|
107
139
|
exports.InstanceSchema = t.object({
|
|
108
140
|
connections: t.array(t.object({
|
|
109
141
|
id: t.string.optional(),
|
|
110
142
|
tag: t.string,
|
|
111
143
|
schemas: t.array(exports.DatabaseSchema)
|
|
112
|
-
}))
|
|
144
|
+
})),
|
|
145
|
+
defaultConnectionTag: t.string,
|
|
146
|
+
defaultSchema: t.string
|
|
113
147
|
});
|
|
114
148
|
//# sourceMappingURL=definitions.js.map
|