Skip to content

Commit d04792c

Browse files
Merge remote-tracking branch 'origin/main' into probes
2 parents eea14d0 + c672380 commit d04792c

File tree

13 files changed

+676
-184
lines changed

13 files changed

+676
-184
lines changed

.changeset/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
33
"changelog": "@changesets/cli/changelog",
44
"commit": false,
5-
"fixed": [["@powersync/service-core", "@powersync/service-image"]],
5+
"fixed": [["@powersync/service-core", "@powersync/service-image", "@powersync/service-schema"]],
66
"linked": [],
77
"access": "restricted",
88
"baseBranch": "origin/main",

.changeset/lemon-hotels-fold.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@powersync/service-types': minor
3+
'@powersync/service-core': minor
4+
'@powersync/service-schema': minor
5+
---
6+
7+
Added JSON schema export for base PowerSyncConfig

packages/schema/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
json-schema/

packages/schema/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# @powersync/service-schema

packages/schema/LICENSE

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Functional Source License, Version 1.1, Apache 2.0 Future License
2+
3+
## Abbreviation
4+
5+
FSL-1.1-Apache-2.0
6+
7+
## Notice
8+
9+
Copyright 2023-2024 Journey Mobile, Inc.
10+
11+
## Terms and Conditions
12+
13+
### Licensor ("We")
14+
15+
The party offering the Software under these Terms and Conditions.
16+
17+
### The Software
18+
19+
The "Software" is each version of the software that we make available under these Terms and Conditions, as indicated by our inclusion of these Terms and Conditions with the Software.
20+
21+
### License Grant
22+
23+
Subject to your compliance with this License Grant and the Patents, Redistribution and Trademark clauses below, we hereby grant you the right to use, copy, modify, create derivative works, publicly perform, publicly display and redistribute the Software for any Permitted Purpose identified below.
24+
25+
### Permitted Purpose
26+
27+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use means making the Software available to others in a commercial product or service that:
28+
29+
1. substitutes for the Software;
30+
2. substitutes for any other product or service we offer using the Software that exists as of the date we make the Software available; or
31+
3. offers the same or substantially similar functionality as the Software.
32+
33+
Permitted Purposes specifically include using the Software:
34+
35+
1. for your internal use and access;
36+
2. for non-commercial education;
37+
3. for non-commercial research; and
38+
4. in connection with professional services that you provide to a licensee using the Software in accordance with these Terms and Conditions.
39+
40+
### Patents
41+
42+
To the extent your use for a Permitted Purpose would necessarily infringe our patents, the license grant above includes a license under our patents. If you make a claim against any party that the Software infringes or contributes to the infringement of any patent, then your patent license to the Software ends immediately.
43+
44+
### Redistribution
45+
46+
The Terms and Conditions apply to all copies, modifications and derivatives of the Software.
47+
If you redistribute any copies, modifications or derivatives of the Software, you must include a copy of or a link to these Terms and Conditions and not remove any copyright notices provided in or with the Software.
48+
49+
### Disclaimer
50+
51+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
52+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
53+
54+
### Trademarks
55+
56+
Except for displaying the License Details and identifying us as the origin of the Software, you have no right under these Terms and Conditions to use our trademarks, trade names, service marks or product names.
57+
58+
## Grant of Future License
59+
60+
We hereby irrevocably grant you an additional license to use the Software under the Apache License, Version 2.0 that is effective on the second anniversary of the date we make the Software available. On or after that date, you may use the Software under the Apache License, Version 2.0, in which case the following will apply:
61+
62+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
63+
You may obtain a copy of the License at
64+
65+
http://www.apache.org/licenses/LICENSE-2.0
66+
67+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

packages/schema/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# PowerSync Service Schema
2+
3+
This package includes a JSON Schema for the PowerSync service configuration file.
4+
5+
This can be used to provide validations and suggestions for configuration files
6+
7+
```yaml
8+
# yaml-language-server: $schema=https://unpkg.com/@powersync/service-schema@latest/json-schema/powersync-config.json
9+
```

packages/schema/package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "@powersync/service-schema",
3+
"version": "1.11.3",
4+
"main": "dist/index.js",
5+
"types": "dist/index.d.ts",
6+
"license": "FSL-1.1-Apache-2.0",
7+
"type": "module",
8+
"publishConfig": {
9+
"access": "public"
10+
},
11+
"files": [
12+
"dist/**/*",
13+
"json-schema/*"
14+
],
15+
"repository": "https://github.com/powersync-ja/powersync-service",
16+
"scripts": {
17+
"clean": "rm -r ./dist && tsc -b --clean",
18+
"build:ts": "tsc -b",
19+
"build": "pnpm build:ts && node ./dist/scripts/compile-json-schema.js"
20+
},
21+
"dependencies": {},
22+
"devDependencies": {
23+
"@powersync/service-module-postgres": "workspace:*",
24+
"@powersync/service-module-postgres-storage": "workspace:*",
25+
"@powersync/service-module-mongodb": "workspace:*",
26+
"@powersync/service-module-mongodb-storage": "workspace:*",
27+
"@powersync/service-module-mysql": "workspace:*",
28+
"@powersync/service-types": "workspace:*",
29+
"ts-codec": "^1.3.0"
30+
}
31+
}

packages/schema/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// This project does not yet include TypeScript source, but it does use TypeScript to depend on the build of @powersync/service-types.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { MongoStorageConfig } from '@powersync/service-module-mongodb-storage/types';
2+
import { MongoConnectionConfig } from '@powersync/service-module-mongodb/types';
3+
import { MySQLConnectionConfig } from '@powersync/service-module-mysql/types';
4+
import { PostgresStorageConfig } from '@powersync/service-module-postgres-storage/types';
5+
import { PostgresConnectionConfig } from '@powersync/service-module-postgres/types';
6+
import { configFile } from '@powersync/service-types';
7+
import fs from 'fs';
8+
import path from 'path';
9+
import * as t from 'ts-codec';
10+
import { fileURLToPath } from 'url';
11+
12+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
13+
const schemaDir = path.join(__dirname, '../../json-schema');
14+
15+
fs.mkdirSync(schemaDir, { recursive: true });
16+
17+
// Merge configs for modules
18+
const baseShape = configFile.powerSyncConfig.props.shape;
19+
20+
const mergedDataSourceConfig = configFile.genericDataSourceConfig
21+
.or(PostgresConnectionConfig)
22+
.or(MongoConnectionConfig)
23+
.or(MySQLConnectionConfig);
24+
25+
const mergedStorageConfig = configFile.GenericStorageConfig.or(PostgresStorageConfig).or(MongoStorageConfig);
26+
27+
const mergedConfig = t.object({
28+
...baseShape,
29+
replication: t
30+
.object({
31+
...baseShape.replication.props.shape,
32+
connections: t.array(mergedDataSourceConfig).optional()
33+
})
34+
.optional(),
35+
storage: mergedStorageConfig.optional()
36+
});
37+
38+
const mergedConfigSchema = t.generateJSONSchema(mergedConfig, {
39+
allowAdditional: true,
40+
parsers: [configFile.portParser]
41+
});
42+
43+
fs.writeFileSync(path.join(schemaDir, 'powersync-config.json'), JSON.stringify(mergedConfigSchema, null, '\t'));

packages/schema/tsconfig.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"outDir": "dist",
5+
"declarationDir": "dist",
6+
"rootDir": "src",
7+
"skipLibCheck": true
8+
},
9+
"include": ["src"],
10+
"references": [
11+
{
12+
"path": "../types"
13+
},
14+
{
15+
"path": "../../modules/module-postgres"
16+
},
17+
{
18+
"path": "../../modules/module-postgres-storage"
19+
},
20+
{
21+
"path": "../../modules/module-mongodb"
22+
},
23+
{
24+
"path": "../../modules/module-mongodb-storage"
25+
},
26+
{
27+
"path": "../../modules/module-mysql"
28+
}
29+
]
30+
}

0 commit comments

Comments
 (0)