@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.
@@ -1 +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,CAAC,CAAC,MAAM;QAEb;;WAEG;QACH,SAAS,EAAE,CAAC,CAAC,MAAM;QA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';
2
- export { PostgresConnection } from './config/PowerSyncConfig.js';
3
2
  export * from './definitions.js';
4
3
  export * from './config/normalize.js';
5
4
  export * as internal_routes from './routes.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0EAA0D;AAG1D,mDAAiC;AACjC,wDAAsC;AACtC,+DAA+C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0EAA0D;AAE1D,mDAAiC;AACjC,wDAAsC;AACtC,+DAA+C"}
package/dist/routes.d.ts CHANGED
@@ -11,12 +11,17 @@ export declare const GetSchemaResponse: t.ObjectCodec<{
11
11
  name: t.IdentityCodec<t.CodecType.String>;
12
12
  columns: t.ArrayCodec<t.ObjectCodec<{
13
13
  name: t.IdentityCodec<t.CodecType.String>;
14
+ sqlite_type: t.Union<t.Codec<number, number, string, t.CodecProps>, t.EnumCodec<typeof import("./definitions").SqliteSchemaTypeText>>;
15
+ internal_type: t.IdentityCodec<t.CodecType.String>;
16
+ description: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
14
17
  type: t.IdentityCodec<t.CodecType.String>;
15
18
  pg_type: t.IdentityCodec<t.CodecType.String>;
16
19
  }>>;
17
20
  }>>;
18
21
  }>>;
19
22
  }>>;
23
+ defaultConnectionTag: t.IdentityCodec<t.CodecType.String>;
24
+ defaultSchema: t.IdentityCodec<t.CodecType.String>;
20
25
  }>;
21
26
  export type GetSchemaResponse = t.Encoded<typeof GetSchemaResponse>;
22
27
  export declare const ExecuteSqlRequest: t.ObjectCodec<{
@@ -37,19 +42,6 @@ export declare const ExecuteSqlResponse: t.ObjectCodec<{
37
42
  error: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
38
43
  }>;
39
44
  export type ExecuteSqlResponse = t.Encoded<typeof ExecuteSqlResponse>;
40
- export declare const DemoCredentialsRequest: t.ObjectCodec<{
41
- connection_id: t.OptionalCodec<t.Codec<string, string, string, t.CodecProps>>;
42
- }>;
43
- export type DemoCredentialsRequest = t.Encoded<typeof DemoCredentialsRequest>;
44
- export declare const DemoCredentialsResponse: t.ObjectCodec<{
45
- /** If this instance has a demo database, this contains the credentials. */
46
- credentials: t.OptionalCodec<t.Codec<{
47
- postgres_uri: string;
48
- }, {
49
- postgres_uri: string;
50
- }, string, t.CodecProps>>;
51
- }>;
52
- export type DemoCredentialsResponse = t.Encoded<typeof DemoCredentialsResponse>;
53
45
  export declare const DiagnosticsRequest: t.ObjectCodec<{
54
46
  sync_rules_content: t.OptionalCodec<t.Codec<boolean, boolean, string, t.CodecProps>>;
55
47
  }>;
package/dist/routes.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.ValidateResponse = exports.ValidateRequest = exports.ReprocessResponse = exports.ReprocessRequest = exports.DiagnosticsResponse = exports.DiagnosticsRequest = exports.DemoCredentialsResponse = exports.DemoCredentialsRequest = exports.ExecuteSqlResponse = exports.ExecuteSqlRequest = exports.GetSchemaResponse = exports.GetSchemaRequest = void 0;
26
+ exports.ValidateResponse = exports.ValidateRequest = exports.ReprocessResponse = exports.ReprocessRequest = exports.DiagnosticsResponse = exports.DiagnosticsRequest = exports.ExecuteSqlResponse = exports.ExecuteSqlRequest = exports.GetSchemaResponse = exports.GetSchemaRequest = void 0;
27
27
  const t = __importStar(require("ts-codec"));
28
28
  const definitions_1 = require("./definitions");
29
29
  exports.GetSchemaRequest = t.object({});
@@ -44,17 +44,6 @@ exports.ExecuteSqlResponse = t.object({
44
44
  /** Set if success = false */
45
45
  error: t.string.optional()
46
46
  });
47
- exports.DemoCredentialsRequest = t.object({
48
- connection_id: t.string.optional()
49
- });
50
- exports.DemoCredentialsResponse = t.object({
51
- /** If this instance has a demo database, this contains the credentials. */
52
- credentials: t
53
- .object({
54
- postgres_uri: t.string
55
- })
56
- .optional()
57
- });
58
47
  exports.DiagnosticsRequest = t.object({
59
48
  sync_rules_content: t.boolean.optional()
60
49
  });
@@ -1 +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,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;KACnD,CAAC;CACH,CAAC,CAAC;AAGU,QAAA,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,OAAO,EAAE,CAAC,CAAC,OAAO;IAClB,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;QAChB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;QAC1B,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,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;KACvE,CAAC;IACF,6BAA6B;IAC7B,KAAK,EAAE,CAA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AQ,EAAE;CACzC,CAAC,CAAC;AAGU,QAAA,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C;;OAEG;IACH,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,8BAAgB,CAAC;IAEtC;;;;OAIG;IACH,iBAAiB,EAAE,6BAAe,CAAC,QAAQ,EAAE;IAE7C;;;;;;OAMG;IACH,oBAAoB,EAAE,6BAAe,CAAC,QAAQ,EAAE;CACjD,CAAC,CAAC;AAGU,QAAA,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAGhC,QAAA,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,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,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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powersync/service-types",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "FSL-1.1-Apache-2.0",
@@ -3,7 +3,7 @@ import * as t from 'ts-codec';
3
3
  /**
4
4
  * Users might specify ports as strings if using YAML custom tag environment substitutions
5
5
  */
6
- const portCodec = t.codec<number, number | string>(
6
+ export const portCodec = t.codec<number, number | string>(
7
7
  'Port',
8
8
  (value) => value,
9
9
  (value) => (typeof value == 'number' ? value : parseInt(value))
@@ -19,39 +19,39 @@ export const portParser = {
19
19
  })
20
20
  };
21
21
 
22
- export const postgresConnection = t.object({
23
- type: t.literal('postgresql'),
22
+ export const DataSourceConfig = t.object({
23
+ // Unique string identifier for the data source
24
+ type: t.string,
24
25
  /** Unique identifier for the connection - optional when a single connection is present. */
25
26
  id: t.string.optional(),
26
- /** Tag used as reference in sync rules. Defaults to "default". Does not have to be unique. */
27
+ /** Additional meta tag for connection */
27
28
  tag: t.string.optional(),
28
- uri: t.string.optional(),
29
- hostname: t.string.optional(),
30
- port: portCodec.optional(),
31
- username: t.string.optional(),
32
- password: t.string.optional(),
33
- database: t.string.optional(),
34
-
35
- /** Defaults to verify-full */
36
- sslmode: t.literal('verify-full').or(t.literal('verify-ca')).or(t.literal('disable')).optional(),
37
- /** Required for verify-ca, optional for verify-full */
38
- cacert: t.string.optional(),
39
-
40
- client_certificate: t.string.optional(),
41
- client_private_key: t.string.optional(),
42
-
43
- /** Expose database credentials */
44
- demo_database: t.boolean.optional(),
45
- /** Expose "execute-sql" */
46
- debug_api: t.boolean.optional(),
47
-
48
29
  /**
49
- * Prefix for the slot name. Defaults to "powersync_"
30
+ * Allows for debug query execution
50
31
  */
51
- slot_name_prefix: t.string.optional()
32
+ debug_api: t.boolean.optional()
52
33
  });
53
34
 
54
- export type PostgresConnection = t.Decoded<typeof postgresConnection>;
35
+ export type DataSourceConfig = t.Decoded<typeof DataSourceConfig>;
36
+
37
+ /**
38
+ * Resolved version of {@link DataSourceConfig} where the optional
39
+ * `id` and `tag` field is now required.
40
+ */
41
+ export const ResolvedDataSourceConfig = DataSourceConfig.and(
42
+ t.object({
43
+ id: t.string,
44
+ tag: t.string
45
+ })
46
+ );
47
+
48
+ export type ResolvedDataSourceConfig = t.Decoded<typeof ResolvedDataSourceConfig>;
49
+
50
+ /**
51
+ * This essentially allows any extra fields on this type
52
+ */
53
+ export const genericDataSourceConfig = DataSourceConfig.and(t.record(t.any));
54
+ export type GenericDataSourceConfig = t.Decoded<typeof genericDataSourceConfig>;
55
55
 
56
56
  export const jwkRSA = t.object({
57
57
  kty: t.literal('RSA'),
@@ -95,7 +95,8 @@ export type StorageConfig = t.Decoded<typeof storageConfig>;
95
95
  export const powerSyncConfig = t.object({
96
96
  replication: t
97
97
  .object({
98
- connections: t.array(postgresConnection).optional()
98
+ // This uses the generic config which may have additional fields
99
+ connections: t.array(genericDataSourceConfig).optional()
99
100
  })
100
101
  .optional(),
101
102
 
@@ -142,10 +143,14 @@ export const powerSyncConfig = t.object({
142
143
  })
143
144
  .optional(),
144
145
 
145
- telemetry: t.object({
146
- disable_telemetry_sharing: t.boolean,
147
- internal_service_endpoint: t.string.optional()
148
- }).optional()
146
+ telemetry: t
147
+ .object({
148
+ disable_telemetry_sharing: t.boolean,
149
+ internal_service_endpoint: t.string.optional()
150
+ })
151
+ .optional(),
152
+
153
+ parameters: t.record(t.number.or(t.string).or(t.boolean).or(t.Null)).optional()
149
154
  });
150
155
 
151
156
  export type PowerSyncConfig = t.Decoded<typeof powerSyncConfig>;
@@ -1,114 +0,0 @@
1
- import { PostgresConnection } from './PowerSyncConfig.js';
2
- import * as urijs from 'uri-js';
3
-
4
- /**
5
- * Validate and normalize connection options.
6
- *
7
- * Returns destructured options.
8
- */
9
- export function normalizeConnection(options: PostgresConnection): NormalizedPostgresConnection {
10
- let uri: urijs.URIComponents;
11
- if (options.uri) {
12
- uri = urijs.parse(options.uri);
13
- if (uri.scheme != 'postgresql' && uri.scheme != 'postgres') {
14
- `Invalid URI - protocol must be postgresql, got ${uri.scheme}`;
15
- } else if (uri.scheme != 'postgresql') {
16
- uri.scheme = 'postgresql';
17
- }
18
- } else {
19
- uri = urijs.parse('postgresql:///');
20
- }
21
-
22
- const hostname = options.hostname ?? uri.host ?? '';
23
- const port = validatePort(options.port ?? uri.port ?? 5432);
24
-
25
- const database = options.database ?? uri.path?.substring(1) ?? '';
26
-
27
- const [uri_username, uri_password] = (uri.userinfo ?? '').split(':');
28
-
29
- const username = options.username ?? uri_username ?? '';
30
- const password = options.password ?? uri_password ?? '';
31
-
32
- const sslmode = options.sslmode ?? 'verify-full'; // Configuration not supported via URI
33
- const cacert = options.cacert;
34
-
35
- if (sslmode == 'verify-ca' && cacert == null) {
36
- throw new Error('Explicit cacert is required for sslmode=verify-ca');
37
- }
38
-
39
- if (hostname == '') {
40
- throw new Error(`hostname required`);
41
- }
42
-
43
- if (username == '') {
44
- throw new Error(`username required`);
45
- }
46
-
47
- if (password == '') {
48
- throw new Error(`password required`);
49
- }
50
-
51
- if (database == '') {
52
- throw new Error(`database required`);
53
- }
54
-
55
- return {
56
- id: options.id ?? 'default',
57
- tag: options.tag ?? 'default',
58
-
59
- hostname,
60
- port,
61
- database,
62
-
63
- username,
64
- password,
65
- sslmode,
66
- cacert,
67
-
68
- client_certificate: options.client_certificate ?? undefined,
69
- client_private_key: options.client_private_key ?? undefined
70
- };
71
- }
72
-
73
- export interface NormalizedPostgresConnection {
74
- id: string;
75
- tag: string;
76
-
77
- hostname: string;
78
- port: number;
79
- database: string;
80
-
81
- username: string;
82
- password: string;
83
-
84
- sslmode: 'verify-full' | 'verify-ca' | 'disable';
85
- cacert: string | undefined;
86
-
87
- client_certificate: string | undefined;
88
- client_private_key: string | undefined;
89
- }
90
-
91
- /**
92
- * Check whether the port is in a "safe" range.
93
- *
94
- * We do not support connecting to "privileged" ports.
95
- */
96
- export function validatePort(port: string | number): number {
97
- if (typeof port == 'string') {
98
- port = parseInt(port);
99
- }
100
- if (port >= 1024 && port <= 49151) {
101
- return port;
102
- } else {
103
- throw new Error(`Port ${port} not supported`);
104
- }
105
- }
106
-
107
- /**
108
- * Construct a postgres URI, without username, password or ssl options.
109
- *
110
- * Only contains hostname, port, database.
111
- */
112
- export function baseUri(options: NormalizedPostgresConnection) {
113
- return `postgresql://${options.hostname}:${options.port}/${options.database}`;
114
- }
@@ -82,27 +82,66 @@ export const ConnectionStatus = t.object({
82
82
  });
83
83
  export type ConnectionStatus = t.Encoded<typeof ConnectionStatus>;
84
84
 
85
- export const DatabaseSchema = t.object({
85
+ export const ConnectionStatusV2 = t.object({
86
+ id: t.string,
87
+ uri: t.string,
88
+ connected: t.boolean,
89
+ /** Connection-level errors */
90
+ errors: t.array(ReplicationError)
91
+ });
92
+ export type ConnectionStatusV2 = t.Encoded<typeof ConnectionStatusV2>;
93
+
94
+ export enum SqliteSchemaTypeText {
95
+ null = 'null',
96
+ blob = 'blob',
97
+ text = 'text',
98
+ integer = 'integer',
99
+ real = 'real',
100
+ numeric = 'numeric'
101
+ }
102
+
103
+ export const TableSchema = t.object({
86
104
  name: t.string,
87
- tables: t.array(
105
+ columns: t.array(
88
106
  t.object({
89
107
  name: t.string,
90
- columns: t.array(
91
- t.object({
92
- name: t.string,
93
- /**
94
- * Full type name, e.g. "character varying(255)[]"
95
- */
96
- type: t.string,
97
- /**
98
- * Internal postgres type, e.g. "varchar[]".
99
- */
100
- pg_type: t.string
101
- })
102
- )
108
+
109
+ /**
110
+ * Option 1: SQLite type flags - see ExpressionType.typeFlags.
111
+ * Option 2: SQLite type name in lowercase - 'text' | 'integer' | 'real' | 'numeric' | 'blob' | 'null'
112
+ */
113
+ sqlite_type: t.number.or(t.Enum(SqliteSchemaTypeText)),
114
+
115
+ /**
116
+ * Type name from the source database, e.g. "character varying(255)[]"
117
+ */
118
+ internal_type: t.string,
119
+
120
+ /**
121
+ * Description for the field if available.
122
+ */
123
+ description: t.string.optional(),
124
+
125
+ /**
126
+ * Full type name, e.g. "character varying(255)[]"
127
+ * @deprecated - use internal_type
128
+ */
129
+ type: t.string,
130
+
131
+ /**
132
+ * Internal postgres type, e.g. "varchar[]".
133
+ * @deprecated - use internal_type instead
134
+ */
135
+ pg_type: t.string
103
136
  })
104
137
  )
105
138
  });
139
+ export type TableSchema = t.Encoded<typeof TableSchema>;
140
+
141
+ export const DatabaseSchema = t.object({
142
+ name: t.string,
143
+ tables: t.array(TableSchema)
144
+ });
106
145
  export type DatabaseSchema = t.Encoded<typeof DatabaseSchema>;
107
146
 
108
147
  export const InstanceSchema = t.object({
@@ -112,6 +151,8 @@ export const InstanceSchema = t.object({
112
151
  tag: t.string,
113
152
  schemas: t.array(DatabaseSchema)
114
153
  })
115
- )
154
+ ),
155
+ defaultConnectionTag: t.string,
156
+ defaultSchema: t.string
116
157
  });
117
158
  export type InstanceSchema = t.Encoded<typeof InstanceSchema>;
package/src/index.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export * as configFile from './config/PowerSyncConfig.js';
2
- export { PostgresConnection } from './config/PowerSyncConfig.js';
3
2
 
4
3
  export * from './definitions.js';
5
4
  export * from './config/normalize.js';
package/src/routes.ts CHANGED
@@ -27,21 +27,6 @@ export const ExecuteSqlResponse = t.object({
27
27
  });
28
28
  export type ExecuteSqlResponse = t.Encoded<typeof ExecuteSqlResponse>;
29
29
 
30
- export const DemoCredentialsRequest = t.object({
31
- connection_id: t.string.optional()
32
- });
33
- export type DemoCredentialsRequest = t.Encoded<typeof DemoCredentialsRequest>;
34
-
35
- export const DemoCredentialsResponse = t.object({
36
- /** If this instance has a demo database, this contains the credentials. */
37
- credentials: t
38
- .object({
39
- postgres_uri: t.string
40
- })
41
- .optional()
42
- });
43
- export type DemoCredentialsResponse = t.Encoded<typeof DemoCredentialsResponse>;
44
-
45
30
  export const DiagnosticsRequest = t.object({
46
31
  sync_rules_content: t.boolean.optional()
47
32
  });
package/tsconfig.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
- "extends": "@journeyapps-platform/micro-dev/tsconfig.base.json",
2
+ "extends": "../../tsconfig.base.json",
3
3
  "compilerOptions": {
4
4
  "outDir": "dist",
5
5
  "declarationDir": "dist",
6
6
  "rootDir": "src",
7
7
  "skipLibCheck": true
8
8
  },
9
- "include": ["src"],
9
+ "include": ["src"]
10
10
  }