@powersync-community/sync-config-rewriter 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 +39 -0
- package/lib/compiled.mjs +378 -0
- package/lib/compiled.support.js +1 -0
- package/lib/compiled.wasm +0 -0
- package/lib/compiled.wasm.map +1 -0
- package/lib/index.d.ts +30 -0
- package/lib/index.js +17 -0
- package/package.json +28 -0
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare function instantiate(
|
|
2
|
+
source: ArrayBuffer | ArrayBufferView | Response | Promise<Response>,
|
|
3
|
+
): Promise<SyncConfigRewriter>;
|
|
4
|
+
|
|
5
|
+
export interface SyncConfigRewriter {
|
|
6
|
+
/**
|
|
7
|
+
* Translates a YAML file containing Sync Rules defined as (`bucket_definitions`)
|
|
8
|
+
* into a file containing equivalent Sync Streams.
|
|
9
|
+
*/
|
|
10
|
+
syncRulesToSyncStreams: (
|
|
11
|
+
source: string,
|
|
12
|
+
) => CompilerError | TranslatedSyncStreams;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface DiagnosticMessage {
|
|
16
|
+
startOffset: number;
|
|
17
|
+
length: number;
|
|
18
|
+
message: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface CompilerError {
|
|
22
|
+
type: "error";
|
|
23
|
+
diagnostics: DiagnosticMessage[];
|
|
24
|
+
internalMessage: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface TranslatedSyncStreams {
|
|
28
|
+
type: "success";
|
|
29
|
+
result: string;
|
|
30
|
+
}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { compile, compileStreaming } from "./compiled.mjs";
|
|
2
|
+
|
|
3
|
+
export async function instantiate(source) {
|
|
4
|
+
let compiled;
|
|
5
|
+
if (ArrayBuffer.isView(source) || source instanceof ArrayBuffer) {
|
|
6
|
+
compiled = await compile(source);
|
|
7
|
+
} else {
|
|
8
|
+
compiled = await compileStreaming(source);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const instantiated = await compiled.instantiate();
|
|
12
|
+
instantiated.invokeMain();
|
|
13
|
+
const exports = instantiated.instantiatedModule.exports;
|
|
14
|
+
return {
|
|
15
|
+
syncRulesToSyncStreams: exports.syncRulesToSyncStreams,
|
|
16
|
+
};
|
|
17
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@powersync-community/sync-config-rewriter",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"registry": "https://registry.npmjs.org/",
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"description": "Tools to rewrite Sync Configurations for PowerSync",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"files": ["lib"],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "dart compile wasm -O3 -E --enable-experimental-wasm-interop index.dart -o lib/compiled.wasm",
|
|
13
|
+
"test": "node --test"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"import": {
|
|
18
|
+
"types": "./lib/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"./compiled.wasm": "./lib/compiled.wasm"
|
|
23
|
+
},
|
|
24
|
+
"keywords": ["powersync"],
|
|
25
|
+
"author": "JOURNEYAPPS",
|
|
26
|
+
"license": "Apache-2.0",
|
|
27
|
+
"packageManager": "pnpm@10.30.0+sha512.2b5753de015d480eeb88f5b5b61e0051f05b4301808a82ec8b840c9d2adf7748eb352c83f5c1593ca703ff1017295bc3fdd3119abb9686efc96b9fcb18200937"
|
|
28
|
+
}
|