powersync 0.1.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/README.md +339 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +9 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +8 -0
- package/dist/commands/init.d.ts +7 -0
- package/dist/commands/init.js +49 -0
- package/dist/commands/instance/config.d.ts +6 -0
- package/dist/commands/instance/config.js +23 -0
- package/dist/commands/instance/create.d.ts +16 -0
- package/dist/commands/instance/create.js +163 -0
- package/dist/commands/instance/deploy.d.ts +15 -0
- package/dist/commands/instance/deploy.js +142 -0
- package/dist/commands/instance/destroy.d.ts +9 -0
- package/dist/commands/instance/destroy.js +42 -0
- package/dist/commands/instance/schema.d.ts +6 -0
- package/dist/commands/instance/schema.js +20 -0
- package/dist/commands/instance/set.d.ts +9 -0
- package/dist/commands/instance/set.js +31 -0
- package/dist/commands/instance/status.d.ts +6 -0
- package/dist/commands/instance/status.js +21 -0
- package/dist/commands/instance/stop.d.ts +9 -0
- package/dist/commands/instance/stop.js +42 -0
- package/dist/commands/instance/sync-rules/deploy.d.ts +10 -0
- package/dist/commands/instance/sync-rules/deploy.js +49 -0
- package/dist/commands/instance/sync-rules/generate-schema.d.ts +10 -0
- package/dist/commands/instance/sync-rules/generate-schema.js +55 -0
- package/dist/commands/instance/sync-rules/validate.d.ts +9 -0
- package/dist/commands/instance/sync-rules/validate.js +29 -0
- package/dist/commands/instances.d.ts +6 -0
- package/dist/commands/instances.js +20 -0
- package/dist/constants.d.ts +11 -0
- package/dist/constants.js +8 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/powersync-sdk/accounts/api.d.ts +717 -0
- package/dist/powersync-sdk/accounts/api.js +182 -0
- package/dist/powersync-sdk/accounts/client.d.ts +1096 -0
- package/dist/powersync-sdk/accounts/client.js +124 -0
- package/dist/powersync-sdk/accounts/codecs.d.ts +32 -0
- package/dist/powersync-sdk/accounts/codecs.js +93 -0
- package/dist/powersync-sdk/accounts/index.d.ts +4 -0
- package/dist/powersync-sdk/accounts/index.js +4 -0
- package/dist/powersync-sdk/accounts/models.d.ts +260 -0
- package/dist/powersync-sdk/accounts/models.js +96 -0
- package/dist/powersync-sdk/accounts/routes.d.ts +44 -0
- package/dist/powersync-sdk/accounts/routes.js +45 -0
- package/dist/powersync-sdk/accounts/source.d.ts +76 -0
- package/dist/powersync-sdk/accounts/source.js +32 -0
- package/dist/powersync-sdk/errors/errors.d.ts +62 -0
- package/dist/powersync-sdk/errors/errors.js +115 -0
- package/dist/powersync-sdk/errors/index.d.ts +2 -0
- package/dist/powersync-sdk/errors/index.js +2 -0
- package/dist/powersync-sdk/errors/utils.d.ts +4 -0
- package/dist/powersync-sdk/errors/utils.js +18 -0
- package/dist/powersync-sdk/fetch-clients/codecs.d.ts +4 -0
- package/dist/powersync-sdk/fetch-clients/codecs.js +34 -0
- package/dist/powersync-sdk/fetch-clients/decoders.d.ts +3 -0
- package/dist/powersync-sdk/fetch-clients/decoders.js +35 -0
- package/dist/powersync-sdk/fetch-clients/definitions.d.ts +97 -0
- package/dist/powersync-sdk/fetch-clients/definitions.js +22 -0
- package/dist/powersync-sdk/fetch-clients/errors.d.ts +7 -0
- package/dist/powersync-sdk/fetch-clients/errors.js +19 -0
- package/dist/powersync-sdk/fetch-clients/index.d.ts +5 -0
- package/dist/powersync-sdk/fetch-clients/index.js +5 -0
- package/dist/powersync-sdk/fetch-clients/node-client.d.ts +9 -0
- package/dist/powersync-sdk/fetch-clients/node-client.js +107 -0
- package/dist/powersync-sdk/fetch-clients/request.d.ts +11 -0
- package/dist/powersync-sdk/fetch-clients/request.js +138 -0
- package/dist/powersync-sdk/fetch-clients/streaming.d.ts +65 -0
- package/dist/powersync-sdk/fetch-clients/streaming.js +99 -0
- package/dist/powersync-sdk/fetch-clients/utils.d.ts +13 -0
- package/dist/powersync-sdk/fetch-clients/utils.js +43 -0
- package/dist/powersync-sdk/fetch-clients/web-client.d.ts +14 -0
- package/dist/powersync-sdk/fetch-clients/web-client.js +56 -0
- package/dist/powersync-sdk/json/index.d.ts +4 -0
- package/dist/powersync-sdk/json/index.js +3 -0
- package/dist/powersync-sdk/json/json.d.ts +5 -0
- package/dist/powersync-sdk/json/json.js +35 -0
- package/dist/powersync-sdk/json/json_container.d.ts +18 -0
- package/dist/powersync-sdk/json/json_container.js +28 -0
- package/dist/powersync-sdk/json/json_stringify.d.ts +36 -0
- package/dist/powersync-sdk/json/json_stringify.js +162 -0
- package/dist/powersync-sdk/powersync/client.d.ts +449 -0
- package/dist/powersync-sdk/powersync/client.js +53 -0
- package/dist/powersync-sdk/powersync/config/HostedConfig.d.ts +327 -0
- package/dist/powersync-sdk/powersync/config/HostedConfig.js +92 -0
- package/dist/powersync-sdk/powersync/config/PowerSyncConfig.d.ts +211 -0
- package/dist/powersync-sdk/powersync/config/PowerSyncConfig.js +97 -0
- package/dist/powersync-sdk/powersync/config/normalize.d.ts +32 -0
- package/dist/powersync-sdk/powersync/config/normalize.js +85 -0
- package/dist/powersync-sdk/powersync/definitions.d.ts +149 -0
- package/dist/powersync-sdk/powersync/definitions.js +97 -0
- package/dist/powersync-sdk/powersync/index.d.ts +8 -0
- package/dist/powersync-sdk/powersync/index.js +8 -0
- package/dist/powersync-sdk/powersync/internal_routes.d.ts +247 -0
- package/dist/powersync-sdk/powersync/internal_routes.js +69 -0
- package/dist/powersync-sdk/powersync/routes.d.ts +779 -0
- package/dist/powersync-sdk/powersync/routes.js +191 -0
- package/dist/powersync-sdk/sdk-clients/endpoints.d.ts +31 -0
- package/dist/powersync-sdk/sdk-clients/endpoints.js +48 -0
- package/dist/powersync-sdk/sdk-clients/index.d.ts +3 -0
- package/dist/powersync-sdk/sdk-clients/index.js +3 -0
- package/dist/powersync-sdk/sdk-clients/pagination.d.ts +14 -0
- package/dist/powersync-sdk/sdk-clients/pagination.js +21 -0
- package/dist/powersync-sdk/sdk-clients/sdk-client.d.ts +17 -0
- package/dist/powersync-sdk/sdk-clients/sdk-client.js +30 -0
- package/dist/powersync-sdk/streaming/bson/buffer-array.d.ts +31 -0
- package/dist/powersync-sdk/streaming/bson/buffer-array.js +79 -0
- package/dist/powersync-sdk/streaming/bson/constants.d.ts +2 -0
- package/dist/powersync-sdk/streaming/bson/constants.js +1 -0
- package/dist/powersync-sdk/streaming/bson/decoder.d.ts +10 -0
- package/dist/powersync-sdk/streaming/bson/decoder.js +62 -0
- package/dist/powersync-sdk/streaming/bson/encoder.d.ts +10 -0
- package/dist/powersync-sdk/streaming/bson/encoder.js +23 -0
- package/dist/powersync-sdk/streaming/bson/header.d.ts +11 -0
- package/dist/powersync-sdk/streaming/bson/header.js +52 -0
- package/dist/powersync-sdk/streaming/bson/index.d.ts +5 -0
- package/dist/powersync-sdk/streaming/bson/index.js +5 -0
- package/dist/powersync-sdk/streaming/core/backpressure.d.ts +15 -0
- package/dist/powersync-sdk/streaming/core/backpressure.js +34 -0
- package/dist/powersync-sdk/streaming/core/cross-stream.d.ts +6 -0
- package/dist/powersync-sdk/streaming/core/cross-stream.js +17 -0
- package/dist/powersync-sdk/streaming/core/index.d.ts +4 -0
- package/dist/powersync-sdk/streaming/core/index.js +4 -0
- package/dist/powersync-sdk/streaming/core/node-utils.d.ts +7 -0
- package/dist/powersync-sdk/streaming/core/node-utils.js +11 -0
- package/dist/powersync-sdk/streaming/core/transformers.d.ts +41 -0
- package/dist/powersync-sdk/streaming/core/transformers.js +70 -0
- package/dist/powersync-sdk/streaming/core/utils.d.ts +36 -0
- package/dist/powersync-sdk/streaming/core/utils.js +66 -0
- package/dist/powersync-sdk/streaming/index.d.ts +3 -0
- package/dist/powersync-sdk/streaming/index.js +3 -0
- package/dist/powersync-sdk/streaming/web.d.ts +4 -0
- package/dist/powersync-sdk/streaming/web.js +4 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binaryreader.d.ts +2 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binaryreader.js +36 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binarywriter.d.ts +2 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binarywriter.js +58 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometry.d.ts +18 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometry.js +348 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometrycollection.d.ts +11 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometrycollection.js +118 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/linestring.d.ts +11 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/linestring.js +131 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multilinestring.d.ts +11 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multilinestring.js +134 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipoint.d.ts +11 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipoint.js +122 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipolygon.d.ts +11 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipolygon.js +158 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/point.d.ts +14 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/point.js +165 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/polygon.d.ts +11 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/polygon.js +207 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/types.d.ts +30 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/types.js +29 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wktparser.d.ts +2 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wktparser.js +111 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wkx.d.ts +9 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wkx.js +9 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/zigzag.d.ts +5 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/zigzag.js +9 -0
- package/dist/powersync-sdk/sync-rules/DartSchemaGenerator.d.ts +12 -0
- package/dist/powersync-sdk/sync-rules/DartSchemaGenerator.js +35 -0
- package/dist/powersync-sdk/sync-rules/ExpressionType.d.ts +33 -0
- package/dist/powersync-sdk/sync-rules/ExpressionType.js +62 -0
- package/dist/powersync-sdk/sync-rules/IdSequence.d.ts +4 -0
- package/dist/powersync-sdk/sync-rules/IdSequence.js +7 -0
- package/dist/powersync-sdk/sync-rules/JsSchemaGenerator.d.ts +12 -0
- package/dist/powersync-sdk/sync-rules/JsSchemaGenerator.js +38 -0
- package/dist/powersync-sdk/sync-rules/SchemaGenerator.d.ts +14 -0
- package/dist/powersync-sdk/sync-rules/SchemaGenerator.js +24 -0
- package/dist/powersync-sdk/sync-rules/SourceTableInterface.d.ts +5 -0
- package/dist/powersync-sdk/sync-rules/SourceTableInterface.js +1 -0
- package/dist/powersync-sdk/sync-rules/SqlBucketDescriptor.d.ts +37 -0
- package/dist/powersync-sdk/sync-rules/SqlBucketDescriptor.js +116 -0
- package/dist/powersync-sdk/sync-rules/SqlDataQuery.d.ts +39 -0
- package/dist/powersync-sdk/sync-rules/SqlDataQuery.js +245 -0
- package/dist/powersync-sdk/sync-rules/SqlParameterQuery.d.ts +43 -0
- package/dist/powersync-sdk/sync-rules/SqlParameterQuery.js +254 -0
- package/dist/powersync-sdk/sync-rules/SqlSyncRules.d.ts +52 -0
- package/dist/powersync-sdk/sync-rules/SqlSyncRules.js +252 -0
- package/dist/powersync-sdk/sync-rules/StaticSchema.d.ts +26 -0
- package/dist/powersync-sdk/sync-rules/StaticSchema.js +71 -0
- package/dist/powersync-sdk/sync-rules/StaticSqlParameterQuery.d.ts +24 -0
- package/dist/powersync-sdk/sync-rules/StaticSqlParameterQuery.js +71 -0
- package/dist/powersync-sdk/sync-rules/TablePattern.d.ts +17 -0
- package/dist/powersync-sdk/sync-rules/TablePattern.js +56 -0
- package/dist/powersync-sdk/sync-rules/TableQuerySchema.d.ts +9 -0
- package/dist/powersync-sdk/sync-rules/TableQuerySchema.js +41 -0
- package/dist/powersync-sdk/sync-rules/errors.d.ts +22 -0
- package/dist/powersync-sdk/sync-rules/errors.js +60 -0
- package/dist/powersync-sdk/sync-rules/generators.d.ts +6 -0
- package/dist/powersync-sdk/sync-rules/generators.js +6 -0
- package/dist/powersync-sdk/sync-rules/index.d.ts +17 -0
- package/dist/powersync-sdk/sync-rules/index.js +17 -0
- package/dist/powersync-sdk/sync-rules/json_schema.d.ts +3 -0
- package/dist/powersync-sdk/sync-rules/json_schema.js +50 -0
- package/dist/powersync-sdk/sync-rules/sql_filters.d.ts +91 -0
- package/dist/powersync-sdk/sync-rules/sql_filters.js +491 -0
- package/dist/powersync-sdk/sync-rules/sql_functions.d.ts +53 -0
- package/dist/powersync-sdk/sync-rules/sql_functions.js +755 -0
- package/dist/powersync-sdk/sync-rules/sql_support.d.ts +22 -0
- package/dist/powersync-sdk/sync-rules/sql_support.js +208 -0
- package/dist/powersync-sdk/sync-rules/types.d.ts +174 -0
- package/dist/powersync-sdk/sync-rules/types.js +9 -0
- package/dist/powersync-sdk/sync-rules/utils.d.ts +45 -0
- package/dist/powersync-sdk/sync-rules/utils.js +163 -0
- package/dist/service/accounts.client.d.ts +26 -0
- package/dist/service/accounts.client.js +26 -0
- package/dist/service/powersync.client.d.ts +269 -0
- package/dist/service/powersync.client.js +135 -0
- package/dist/service/types.d.ts +69 -0
- package/dist/service/types.js +1 -0
- package/dist/service/utils.d.ts +5 -0
- package/dist/service/utils.js +7 -0
- package/dist/utils.d.ts +6 -0
- package/dist/utils.js +52 -0
- package/oclif.manifest.json +514 -0
- package/package.json +81 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import 'dotenv/config';
|
|
2
|
+
import { Client } from '../powersync-sdk/powersync/client.js';
|
|
3
|
+
import { type DeployConfig } from './types.js';
|
|
4
|
+
export declare enum ENV_VARIABLES {
|
|
5
|
+
APP_ID = "APP_ID",
|
|
6
|
+
CARDINAL_TOKEN = "CARDINAL_TOKEN",
|
|
7
|
+
INSTANCE_ID = "INSTANCE_ID",
|
|
8
|
+
ORG_ID = "ORG_ID"
|
|
9
|
+
}
|
|
10
|
+
export declare const powerSyncClient: (requiresInstanceId?: boolean) => Client<import("../powersync-sdk/fetch-clients/web-client.js").WebNetworkClient>;
|
|
11
|
+
export declare const getInstancesList: () => Promise<{
|
|
12
|
+
instances: {
|
|
13
|
+
name: string;
|
|
14
|
+
id: string;
|
|
15
|
+
}[];
|
|
16
|
+
}>;
|
|
17
|
+
export declare const getInstanceConfig: () => Promise<{
|
|
18
|
+
name: string;
|
|
19
|
+
id: string;
|
|
20
|
+
config?: {
|
|
21
|
+
region: string;
|
|
22
|
+
api?: {
|
|
23
|
+
tokens?: ({
|
|
24
|
+
secret: string;
|
|
25
|
+
} | {
|
|
26
|
+
secret_ref: string;
|
|
27
|
+
})[] | undefined;
|
|
28
|
+
} | undefined;
|
|
29
|
+
client_auth?: {
|
|
30
|
+
additional_audiences?: string[] | undefined;
|
|
31
|
+
allow_temporary_tokens?: boolean | undefined;
|
|
32
|
+
jwks?: {
|
|
33
|
+
keys: ({
|
|
34
|
+
e: string;
|
|
35
|
+
kty: "RSA";
|
|
36
|
+
n: string;
|
|
37
|
+
kid: string;
|
|
38
|
+
alg?: "RS256" | "RS384" | "RS512" | undefined;
|
|
39
|
+
use?: string | undefined;
|
|
40
|
+
} | {
|
|
41
|
+
k: {
|
|
42
|
+
secret: string;
|
|
43
|
+
} | {
|
|
44
|
+
secret_ref: string;
|
|
45
|
+
};
|
|
46
|
+
kty: "oct";
|
|
47
|
+
alg: "HS256" | "HS384" | "HS512";
|
|
48
|
+
kid: string;
|
|
49
|
+
use?: string | undefined;
|
|
50
|
+
})[];
|
|
51
|
+
} | undefined;
|
|
52
|
+
jwks_uri?: string | undefined;
|
|
53
|
+
supabase?: boolean | undefined;
|
|
54
|
+
} | undefined;
|
|
55
|
+
dev?: {
|
|
56
|
+
crud_api?: boolean | undefined;
|
|
57
|
+
demo_auth?: boolean | undefined;
|
|
58
|
+
demo_client?: boolean | undefined;
|
|
59
|
+
demo_password?: {
|
|
60
|
+
secret: string;
|
|
61
|
+
} | {
|
|
62
|
+
secret_ref: string;
|
|
63
|
+
} | undefined;
|
|
64
|
+
} | undefined;
|
|
65
|
+
replication?: {
|
|
66
|
+
connections?: ({
|
|
67
|
+
type: "postgresql";
|
|
68
|
+
uri?: string | undefined;
|
|
69
|
+
hostname?: string | undefined;
|
|
70
|
+
port?: number | undefined;
|
|
71
|
+
name?: string | undefined;
|
|
72
|
+
id?: string | undefined;
|
|
73
|
+
cacert?: string | undefined;
|
|
74
|
+
client_certificate?: string | undefined;
|
|
75
|
+
client_private_key?: {
|
|
76
|
+
secret: string;
|
|
77
|
+
} | {
|
|
78
|
+
secret_ref: string;
|
|
79
|
+
} | undefined;
|
|
80
|
+
database?: string | undefined;
|
|
81
|
+
debug_api?: boolean | undefined;
|
|
82
|
+
password?: {
|
|
83
|
+
secret: string;
|
|
84
|
+
} | {
|
|
85
|
+
secret_ref: string;
|
|
86
|
+
} | undefined;
|
|
87
|
+
sslmode?: "verify-full" | "verify-ca" | undefined;
|
|
88
|
+
tag?: string | undefined;
|
|
89
|
+
username?: string | undefined;
|
|
90
|
+
} | {
|
|
91
|
+
type: "postgresql-demo";
|
|
92
|
+
tag?: string | undefined;
|
|
93
|
+
})[] | undefined;
|
|
94
|
+
} | undefined;
|
|
95
|
+
} | undefined;
|
|
96
|
+
sync_rules?: string | undefined;
|
|
97
|
+
}>;
|
|
98
|
+
export declare const getInstanceDiagnostics: () => Promise<{
|
|
99
|
+
connections: {
|
|
100
|
+
id: string;
|
|
101
|
+
errors: {
|
|
102
|
+
message: string;
|
|
103
|
+
level: "warning" | "fatal";
|
|
104
|
+
}[];
|
|
105
|
+
connected: boolean;
|
|
106
|
+
postgres_uri: string;
|
|
107
|
+
}[];
|
|
108
|
+
active_sync_rules?: {
|
|
109
|
+
connections: {
|
|
110
|
+
id: string;
|
|
111
|
+
tag: string;
|
|
112
|
+
initial_replication_done: boolean;
|
|
113
|
+
slot_name: string;
|
|
114
|
+
tables: {
|
|
115
|
+
name: string;
|
|
116
|
+
data_queries: boolean;
|
|
117
|
+
errors: {
|
|
118
|
+
message: string;
|
|
119
|
+
level: "warning" | "fatal";
|
|
120
|
+
}[];
|
|
121
|
+
parameter_queries: boolean;
|
|
122
|
+
replication_id: string[];
|
|
123
|
+
schema: string;
|
|
124
|
+
pattern?: string | undefined;
|
|
125
|
+
}[];
|
|
126
|
+
last_checkpoint_ts?: string | undefined;
|
|
127
|
+
last_keepalive_ts?: string | undefined;
|
|
128
|
+
last_lsn?: string | undefined;
|
|
129
|
+
replication_lag_bytes?: number | undefined;
|
|
130
|
+
}[];
|
|
131
|
+
errors: {
|
|
132
|
+
message: string;
|
|
133
|
+
level: "warning" | "fatal";
|
|
134
|
+
}[];
|
|
135
|
+
content?: string | undefined;
|
|
136
|
+
} | undefined;
|
|
137
|
+
deploying_sync_rules?: {
|
|
138
|
+
connections: {
|
|
139
|
+
id: string;
|
|
140
|
+
tag: string;
|
|
141
|
+
initial_replication_done: boolean;
|
|
142
|
+
slot_name: string;
|
|
143
|
+
tables: {
|
|
144
|
+
name: string;
|
|
145
|
+
data_queries: boolean;
|
|
146
|
+
errors: {
|
|
147
|
+
message: string;
|
|
148
|
+
level: "warning" | "fatal";
|
|
149
|
+
}[];
|
|
150
|
+
parameter_queries: boolean;
|
|
151
|
+
replication_id: string[];
|
|
152
|
+
schema: string;
|
|
153
|
+
pattern?: string | undefined;
|
|
154
|
+
}[];
|
|
155
|
+
last_checkpoint_ts?: string | undefined;
|
|
156
|
+
last_keepalive_ts?: string | undefined;
|
|
157
|
+
last_lsn?: string | undefined;
|
|
158
|
+
replication_lag_bytes?: number | undefined;
|
|
159
|
+
}[];
|
|
160
|
+
errors: {
|
|
161
|
+
message: string;
|
|
162
|
+
level: "warning" | "fatal";
|
|
163
|
+
}[];
|
|
164
|
+
content?: string | undefined;
|
|
165
|
+
} | undefined;
|
|
166
|
+
}>;
|
|
167
|
+
export declare const getInstanceSchema: () => Promise<{
|
|
168
|
+
connections: {
|
|
169
|
+
tag: string;
|
|
170
|
+
schemas: {
|
|
171
|
+
name: string;
|
|
172
|
+
tables: {
|
|
173
|
+
name: string;
|
|
174
|
+
columns: {
|
|
175
|
+
name: string;
|
|
176
|
+
type: string;
|
|
177
|
+
pg_type: string;
|
|
178
|
+
}[];
|
|
179
|
+
}[];
|
|
180
|
+
}[];
|
|
181
|
+
id?: string | undefined;
|
|
182
|
+
}[];
|
|
183
|
+
}>;
|
|
184
|
+
export declare const getInstanceStatus: (instanceId?: string) => Promise<{
|
|
185
|
+
id: string;
|
|
186
|
+
operations: {
|
|
187
|
+
type: "up" | "down";
|
|
188
|
+
id: string;
|
|
189
|
+
created_at: string;
|
|
190
|
+
status: "pending" | "running" | "failed" | "completed";
|
|
191
|
+
finished_at?: string | undefined;
|
|
192
|
+
started_at?: string | undefined;
|
|
193
|
+
}[];
|
|
194
|
+
provisioned: boolean;
|
|
195
|
+
instance_url?: string | undefined;
|
|
196
|
+
}>;
|
|
197
|
+
export declare const destroyInstance: () => Promise<{
|
|
198
|
+
id: string;
|
|
199
|
+
operation_id?: string | undefined;
|
|
200
|
+
}>;
|
|
201
|
+
export declare const deactivateInstance: () => Promise<{
|
|
202
|
+
id: string;
|
|
203
|
+
operation_id?: string | undefined;
|
|
204
|
+
}>;
|
|
205
|
+
export declare const createInstance: (name: string) => Promise<{
|
|
206
|
+
id: string;
|
|
207
|
+
}>;
|
|
208
|
+
export declare const testConnection: (connection: any) => Promise<{
|
|
209
|
+
connection: {
|
|
210
|
+
success: boolean;
|
|
211
|
+
reachable: boolean;
|
|
212
|
+
authenticated?: boolean | undefined;
|
|
213
|
+
suggested_cacert?: string | undefined;
|
|
214
|
+
suggested_sslmode?: string | undefined;
|
|
215
|
+
tls_valid?: boolean | undefined;
|
|
216
|
+
};
|
|
217
|
+
success: boolean;
|
|
218
|
+
error?: string | undefined;
|
|
219
|
+
configuration?: {
|
|
220
|
+
success: boolean;
|
|
221
|
+
publication_valid?: boolean | undefined;
|
|
222
|
+
wal_valid?: boolean | undefined;
|
|
223
|
+
} | undefined;
|
|
224
|
+
}>;
|
|
225
|
+
export declare const deployInstance: (config: DeployConfig, instanceId: string) => Promise<{
|
|
226
|
+
id: string;
|
|
227
|
+
operation_id: string;
|
|
228
|
+
}>;
|
|
229
|
+
export declare const validateSyncRules: (syncRules: string) => Promise<{
|
|
230
|
+
connections: {
|
|
231
|
+
id: string;
|
|
232
|
+
tag: string;
|
|
233
|
+
initial_replication_done: boolean;
|
|
234
|
+
slot_name: string;
|
|
235
|
+
tables: {
|
|
236
|
+
name: string;
|
|
237
|
+
data_queries: boolean;
|
|
238
|
+
errors: {
|
|
239
|
+
message: string;
|
|
240
|
+
level: "warning" | "fatal";
|
|
241
|
+
}[];
|
|
242
|
+
parameter_queries: boolean;
|
|
243
|
+
replication_id: string[];
|
|
244
|
+
schema: string;
|
|
245
|
+
pattern?: string | undefined;
|
|
246
|
+
}[];
|
|
247
|
+
last_checkpoint_ts?: string | undefined;
|
|
248
|
+
last_keepalive_ts?: string | undefined;
|
|
249
|
+
last_lsn?: string | undefined;
|
|
250
|
+
replication_lag_bytes?: number | undefined;
|
|
251
|
+
}[];
|
|
252
|
+
errors: {
|
|
253
|
+
message: string;
|
|
254
|
+
level: "warning" | "fatal";
|
|
255
|
+
}[];
|
|
256
|
+
content?: string | undefined;
|
|
257
|
+
}>;
|
|
258
|
+
export declare const deploySyncRules: (syncRules: string) => Promise<{
|
|
259
|
+
id: string;
|
|
260
|
+
operation_id: string;
|
|
261
|
+
}>;
|
|
262
|
+
export declare const processSyncRules: () => Promise<{
|
|
263
|
+
connections: {
|
|
264
|
+
tag: string;
|
|
265
|
+
slot_name: string;
|
|
266
|
+
id?: string | undefined;
|
|
267
|
+
}[];
|
|
268
|
+
}>;
|
|
269
|
+
export declare const waitForStatusChange: (instanceId: string) => Promise<"failed" | "completed">;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/* eslint-disable no-await-in-loop */
|
|
3
|
+
/* eslint-disable camelcase */
|
|
4
|
+
import 'dotenv/config';
|
|
5
|
+
import { ENDPOINTS } from '../constants.js';
|
|
6
|
+
import { createWebNetworkClient } from '../powersync-sdk/fetch-clients/web-client.js';
|
|
7
|
+
import { Client } from '../powersync-sdk/powersync/client.js';
|
|
8
|
+
import { generateHeader } from './utils.js';
|
|
9
|
+
const { APP_ID, INSTANCE_ID, ORG_ID, CARDINAL_TOKEN } = process.env;
|
|
10
|
+
export var ENV_VARIABLES;
|
|
11
|
+
(function (ENV_VARIABLES) {
|
|
12
|
+
ENV_VARIABLES["APP_ID"] = "APP_ID";
|
|
13
|
+
ENV_VARIABLES["CARDINAL_TOKEN"] = "CARDINAL_TOKEN";
|
|
14
|
+
ENV_VARIABLES["INSTANCE_ID"] = "INSTANCE_ID";
|
|
15
|
+
ENV_VARIABLES["ORG_ID"] = "ORG_ID";
|
|
16
|
+
})(ENV_VARIABLES || (ENV_VARIABLES = {}));
|
|
17
|
+
export const powerSyncClient = (requiresInstanceId = true) => {
|
|
18
|
+
if (!CARDINAL_TOKEN) {
|
|
19
|
+
throw new Error(`${ENV_VARIABLES.CARDINAL_TOKEN} is not set in environment`);
|
|
20
|
+
}
|
|
21
|
+
if (!APP_ID) {
|
|
22
|
+
throw new Error(`${ENV_VARIABLES.APP_ID} is not set in environment`);
|
|
23
|
+
}
|
|
24
|
+
if (!ORG_ID) {
|
|
25
|
+
throw new Error(`${ENV_VARIABLES.ORG_ID} is not set in environment`);
|
|
26
|
+
}
|
|
27
|
+
if (requiresInstanceId && !INSTANCE_ID) {
|
|
28
|
+
throw new Error(`${ENV_VARIABLES.INSTANCE_ID} is not set in environment. You need to set an instance using \`powersync instance set\``);
|
|
29
|
+
}
|
|
30
|
+
const HEADERS = generateHeader(CARDINAL_TOKEN);
|
|
31
|
+
return new Client({
|
|
32
|
+
client: createWebNetworkClient({ headers: HEADERS }),
|
|
33
|
+
endpoint: ENDPOINTS.POWERSYNC_URL
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
// Instances
|
|
37
|
+
export const getInstancesList = async () => powerSyncClient(false).listInstances({
|
|
38
|
+
app_id: APP_ID,
|
|
39
|
+
org_id: ORG_ID
|
|
40
|
+
});
|
|
41
|
+
// Instance
|
|
42
|
+
export const getInstanceConfig = async () => powerSyncClient().getInstanceConfig({
|
|
43
|
+
app_id: APP_ID,
|
|
44
|
+
id: INSTANCE_ID,
|
|
45
|
+
org_id: ORG_ID
|
|
46
|
+
});
|
|
47
|
+
export const getInstanceDiagnostics = async () => powerSyncClient().getInstanceDiagnostics({
|
|
48
|
+
app_id: APP_ID,
|
|
49
|
+
id: INSTANCE_ID,
|
|
50
|
+
org_id: ORG_ID
|
|
51
|
+
});
|
|
52
|
+
export const getInstanceSchema = async () => powerSyncClient().getInstanceSchema({
|
|
53
|
+
app_id: APP_ID,
|
|
54
|
+
id: INSTANCE_ID,
|
|
55
|
+
org_id: ORG_ID
|
|
56
|
+
});
|
|
57
|
+
export const getInstanceStatus = async (instanceId) => powerSyncClient(!instanceId).getInstanceStatus({
|
|
58
|
+
app_id: APP_ID,
|
|
59
|
+
id: instanceId ?? INSTANCE_ID,
|
|
60
|
+
org_id: ORG_ID
|
|
61
|
+
});
|
|
62
|
+
export const destroyInstance = async () => powerSyncClient().destroyInstance({
|
|
63
|
+
app_id: APP_ID,
|
|
64
|
+
id: INSTANCE_ID,
|
|
65
|
+
org_id: ORG_ID
|
|
66
|
+
});
|
|
67
|
+
export const deactivateInstance = async () => powerSyncClient().deactivateInstance({
|
|
68
|
+
app_id: APP_ID,
|
|
69
|
+
id: INSTANCE_ID,
|
|
70
|
+
org_id: ORG_ID
|
|
71
|
+
});
|
|
72
|
+
export const createInstance = async (name) => powerSyncClient(false).createInstance({
|
|
73
|
+
app_id: APP_ID,
|
|
74
|
+
name,
|
|
75
|
+
org_id: ORG_ID
|
|
76
|
+
});
|
|
77
|
+
export const testConnection = async (connection) => powerSyncClient().testConnection({
|
|
78
|
+
app_id: APP_ID,
|
|
79
|
+
connection,
|
|
80
|
+
id: INSTANCE_ID,
|
|
81
|
+
org_id: ORG_ID
|
|
82
|
+
});
|
|
83
|
+
export const deployInstance = async (config, instanceId) => powerSyncClient(false).deployInstance({
|
|
84
|
+
app_id: APP_ID,
|
|
85
|
+
config,
|
|
86
|
+
id: instanceId,
|
|
87
|
+
org_id: ORG_ID
|
|
88
|
+
});
|
|
89
|
+
export const validateSyncRules = async (syncRules) => {
|
|
90
|
+
return powerSyncClient().validateSyncRules({
|
|
91
|
+
app_id: APP_ID,
|
|
92
|
+
id: INSTANCE_ID,
|
|
93
|
+
org_id: ORG_ID,
|
|
94
|
+
sync_rules: syncRules
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
export const deploySyncRules = async (syncRules) => {
|
|
98
|
+
const config = await getInstanceConfig();
|
|
99
|
+
if (!config.config) {
|
|
100
|
+
throw new Error('No instance config found');
|
|
101
|
+
}
|
|
102
|
+
if (!syncRules) {
|
|
103
|
+
throw new Error('No sync rules found');
|
|
104
|
+
}
|
|
105
|
+
return powerSyncClient().deployInstance({
|
|
106
|
+
app_id: APP_ID,
|
|
107
|
+
config: config.config,
|
|
108
|
+
id: INSTANCE_ID,
|
|
109
|
+
org_id: ORG_ID,
|
|
110
|
+
sync_rules: syncRules
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
export const processSyncRules = async () => powerSyncClient().reprocessSyncRules({
|
|
114
|
+
app_id: APP_ID,
|
|
115
|
+
id: INSTANCE_ID,
|
|
116
|
+
org_id: ORG_ID
|
|
117
|
+
});
|
|
118
|
+
export const waitForStatusChange = async (instanceId) => {
|
|
119
|
+
const interval = 5000; // 5 seconds
|
|
120
|
+
try {
|
|
121
|
+
const result = await getInstanceStatus(instanceId);
|
|
122
|
+
let { status } = result.operations[0];
|
|
123
|
+
while (status !== 'failed' && status !== 'completed') {
|
|
124
|
+
await new Promise((resolve) => {
|
|
125
|
+
setTimeout(resolve, interval);
|
|
126
|
+
});
|
|
127
|
+
const response = await getInstanceStatus(instanceId);
|
|
128
|
+
status = response.operations[0].status;
|
|
129
|
+
}
|
|
130
|
+
return status;
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
throw new Error(error.message);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export type DeployConfig = {
|
|
2
|
+
client_auth?: {
|
|
3
|
+
additional_audiences?: string[] | undefined;
|
|
4
|
+
allow_temporary_tokens?: boolean | undefined;
|
|
5
|
+
jwks?: {
|
|
6
|
+
keys: ({
|
|
7
|
+
alg: 'HS256' | 'HS384' | 'HS512';
|
|
8
|
+
k: {
|
|
9
|
+
secret: string;
|
|
10
|
+
} | {
|
|
11
|
+
secret_ref: string;
|
|
12
|
+
};
|
|
13
|
+
kid: string;
|
|
14
|
+
kty: 'oct';
|
|
15
|
+
use?: string | undefined;
|
|
16
|
+
} | {
|
|
17
|
+
alg?: 'RS256' | 'RS384' | 'RS512' | undefined;
|
|
18
|
+
e: string;
|
|
19
|
+
kid: string;
|
|
20
|
+
kty: 'RSA';
|
|
21
|
+
n: string;
|
|
22
|
+
use?: string | undefined;
|
|
23
|
+
})[];
|
|
24
|
+
} | undefined;
|
|
25
|
+
jwks_uri?: string | undefined;
|
|
26
|
+
supabase?: boolean | undefined;
|
|
27
|
+
} | undefined;
|
|
28
|
+
dev?: {
|
|
29
|
+
crud_api?: boolean | undefined;
|
|
30
|
+
demo_auth?: boolean | undefined;
|
|
31
|
+
demo_client?: boolean | undefined;
|
|
32
|
+
demo_password?: {
|
|
33
|
+
secret: string;
|
|
34
|
+
} | {
|
|
35
|
+
secret_ref: string;
|
|
36
|
+
} | undefined;
|
|
37
|
+
} | undefined;
|
|
38
|
+
region: string;
|
|
39
|
+
replication?: {
|
|
40
|
+
connections?: ({
|
|
41
|
+
cacert?: string | undefined;
|
|
42
|
+
client_certificate?: string | undefined;
|
|
43
|
+
client_private_key?: {
|
|
44
|
+
secret: string;
|
|
45
|
+
} | {
|
|
46
|
+
secret_ref: string;
|
|
47
|
+
} | undefined;
|
|
48
|
+
database?: string | undefined;
|
|
49
|
+
debug_api?: boolean | undefined;
|
|
50
|
+
hostname?: string | undefined;
|
|
51
|
+
id?: string | undefined;
|
|
52
|
+
name?: string | undefined;
|
|
53
|
+
password?: {
|
|
54
|
+
secret: string;
|
|
55
|
+
} | {
|
|
56
|
+
secret_ref: string;
|
|
57
|
+
} | undefined;
|
|
58
|
+
port?: number | undefined;
|
|
59
|
+
sslmode?: 'verify-ca' | 'verify-full' | undefined;
|
|
60
|
+
tag?: string | undefined;
|
|
61
|
+
type: 'postgresql';
|
|
62
|
+
uri?: string | undefined;
|
|
63
|
+
username?: string | undefined;
|
|
64
|
+
} | {
|
|
65
|
+
tag?: string | undefined;
|
|
66
|
+
type: 'postgresql-demo';
|
|
67
|
+
})[] | undefined;
|
|
68
|
+
} | undefined;
|
|
69
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const checkForValidEnvFile: (cliName: string, requiresInstanceId?: boolean) => undefined;
|
|
2
|
+
export declare const updateEnvFileVariableValue: (variableName: string, newValue: string) => void;
|
|
3
|
+
export declare const bold: (text: string) => string;
|
|
4
|
+
export declare const green: (text: string) => string;
|
|
5
|
+
export declare const yellow: (text: string) => string;
|
|
6
|
+
export declare const red: (text: string) => string;
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ux } from '@oclif/core';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { ENV_VARIABLES } from './service/powersync.client.js';
|
|
4
|
+
export const checkForValidEnvFile = (cliName, requiresInstanceId = false) => {
|
|
5
|
+
const envPath = '.env';
|
|
6
|
+
if (!fs.existsSync(envPath)) {
|
|
7
|
+
ux.error(`No .env file found. Please run ${green(`"${cliName} init"`)}.`, { exit: 1 });
|
|
8
|
+
}
|
|
9
|
+
const requiredProperties = [ENV_VARIABLES.APP_ID, ENV_VARIABLES.CARDINAL_TOKEN, ENV_VARIABLES.ORG_ID];
|
|
10
|
+
const missingProperties = requiredProperties.filter((prop) => !process.env[prop]);
|
|
11
|
+
if (missingProperties.length > 0) {
|
|
12
|
+
return ux.error(`It appears you have not initialized the CLI. Please run ${green(`"${cliName} init"`)}.`, {
|
|
13
|
+
exit: 1
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
if (requiresInstanceId && !process.env[ENV_VARIABLES.INSTANCE_ID]) {
|
|
17
|
+
return ux.error(`Missing INSTANCE_ID. Please set one by running ${green('"powersync instance set"')}.`, {
|
|
18
|
+
exit: 1
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export const updateEnvFileVariableValue = (variableName, newValue) => {
|
|
23
|
+
// Currently assume there is only a .env file in the root of the project
|
|
24
|
+
const envFilePath = '.env';
|
|
25
|
+
try {
|
|
26
|
+
const data = fs.readFileSync(envFilePath, 'utf8');
|
|
27
|
+
const lines = data.split('\n');
|
|
28
|
+
let variableFound = false;
|
|
29
|
+
// Find and update the desired variable
|
|
30
|
+
for (let i = 0; i < lines.length; i++) {
|
|
31
|
+
const line = lines[i];
|
|
32
|
+
if (line.startsWith(variableName + '=')) {
|
|
33
|
+
lines[i] = variableName + '=' + newValue;
|
|
34
|
+
variableFound = true;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Variable not found, add it to the end of the file
|
|
39
|
+
if (!variableFound) {
|
|
40
|
+
lines.push(variableName + '=' + newValue);
|
|
41
|
+
}
|
|
42
|
+
const updatedContent = lines.join('\n');
|
|
43
|
+
fs.writeFileSync(envFilePath, updatedContent, 'utf8');
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
console.error(error);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
export const bold = (text) => ux.colorize('bold', text);
|
|
50
|
+
export const green = (text) => ux.colorize('green', text);
|
|
51
|
+
export const yellow = (text) => ux.colorize('yellow', text);
|
|
52
|
+
export const red = (text) => ux.colorize('red', text);
|