Skip to content

Commit e69ba94

Browse files
committed
Stabilize node package
1 parent 8a53d7a commit e69ba94

16 files changed

Lines changed: 705 additions & 498 deletions

.changeset/fuzzy-dodos-begin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/node': major
3+
---
4+
5+
Mark package as stable.

.github/workflows/build-packages.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,5 @@ jobs:
3434
- name: Build typescript
3535
run: pnpm exec tsc -b
3636

37-
- name: Verify @powersync/common API
38-
working-directory: packages/common
39-
run: pnpm exec api-extractor run --verbose
37+
- name: Verify API reports
38+
run: pnpm -r --if-present run api-diff

api-extractor.json

Lines changed: 454 additions & 0 deletions
Large diffs are not rendered by default.

packages/common/api-extractor.json

Lines changed: 2 additions & 451 deletions
Large diffs are not rendered by default.

packages/common/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"build:prod": "tsc -b",
3535
"clean": "rm -rf lib dist tsconfig.tsbuildinfo",
3636
"test": "vitest",
37-
"test:exports": "attw --pack . --ignore-rules no-resolution cjs-resolves-to-esm"
37+
"test:exports": "attw --pack . --ignore-rules no-resolution cjs-resolves-to-esm",
38+
"api-diff": "api-extractor run --verbose"
3839
},
3940
"devDependencies": {
4041
"@types/node": "catalog:",

packages/node/api-extractor.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3+
"extends": "../../api-extractor.json",
4+
"mainEntryPointFilePath": "<projectFolder>/lib/index.d.ts"
5+
}

packages/node/etc/node.api.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
## API Report File for "@powersync/node"
2+
3+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4+
5+
```ts
6+
7+
import { AttachmentData } from '@powersync/common';
8+
import type { AttachmentRecord } from '@powersync/common';
9+
import { AttachmentTransportAdapter } from '@powersync/common';
10+
import { BasePowerSyncDatabaseOptions } from '@powersync/common';
11+
import { CommonPowerSyncDatabase } from '@powersync/common';
12+
import { DatabaseSource } from '@powersync/common';
13+
import { Dispatcher } from 'undici';
14+
import { EncodingType } from '@powersync/common';
15+
import type { LocatedAttachmentRecord } from '@powersync/common';
16+
import { LockContext } from '@powersync/common';
17+
import { PowerSyncDatabaseConstructor } from '@powersync/common';
18+
import { SQLOpenOptions } from '@powersync/common';
19+
import { StreamingLocalStorageAdapter } from '@powersync/common';
20+
import { Worker as Worker_2 } from 'node:worker_threads';
21+
22+
// @public
23+
export interface BetterSqlite3Options {
24+
// (undocumented)
25+
type: 'better-sqlite3';
26+
}
27+
28+
// Warning: (ae-incompatible-release-tags) The symbol "NodeDatabaseImplementation" is marked as @public, but its signature references "NodeSqliteOptions" which is marked as @alpha
29+
//
30+
// @public
31+
export type NodeDatabaseImplementation = BetterSqlite3Options | NodeSqliteOptions;
32+
33+
// @alpha
34+
export interface NodeDownloadRequest {
35+
headers?: Record<string, string>;
36+
url: string;
37+
}
38+
39+
// @public
40+
export class NodeFileSystemAdapter implements StreamingLocalStorageAdapter {
41+
constructor(storageDirectory?: string);
42+
// (undocumented)
43+
clear(): Promise<void>;
44+
// Warning: (ae-incompatible-release-tags) The symbol "createTransportAdapter" is marked as @public, but its signature references "NodeFileSystemTransportAdapterOptions" which is marked as @alpha
45+
createTransportAdapter(options: NodeFileSystemTransportAdapterOptions): AttachmentTransportAdapter;
46+
// (undocumented)
47+
deleteFile(path: string, options?: {
48+
filename?: string;
49+
}): Promise<void>;
50+
// (undocumented)
51+
downloadFile(filePath: string): Promise<Blob>;
52+
// (undocumented)
53+
fileExists(filePath: string): Promise<boolean>;
54+
// (undocumented)
55+
getLocalUri(filename: string): string;
56+
// (undocumented)
57+
initialize(): Promise<void>;
58+
// (undocumented)
59+
makeDir(path: string): Promise<void>;
60+
// (undocumented)
61+
moveFile(sourceUri: string, targetUri: string): Promise<number>;
62+
// (undocumented)
63+
readFile(filePath: string, options?: {
64+
encoding?: EncodingType;
65+
mediaType?: string;
66+
}): Promise<ArrayBuffer>;
67+
// (undocumented)
68+
rmDir(path: string): Promise<void>;
69+
// (undocumented)
70+
saveFile(filePath: string, data: AttachmentData, options?: {
71+
encoding?: EncodingType;
72+
mediaType?: string;
73+
}): Promise<number>;
74+
// (undocumented)
75+
uploadFile(filePath: string, data: ArrayBuffer, options?: {
76+
encoding: EncodingType;
77+
}): Promise<void>;
78+
}
79+
80+
// @alpha
81+
export interface NodeFileSystemTransportAdapterOptions {
82+
deleteFile: (attachment: AttachmentRecord) => Promise<void>;
83+
resolveDownload: (attachment: LocatedAttachmentRecord) => Promise<NodeDownloadRequest> | NodeDownloadRequest;
84+
resolveUpload: (attachment: LocatedAttachmentRecord) => Promise<NodeUploadRequest> | NodeUploadRequest;
85+
}
86+
87+
// @public
88+
export type NodePowerSyncDatabaseOptions = BasePowerSyncDatabaseOptions & DatabaseSource<NodeSQLOpenOptions> & {
89+
remoteOptions?: NodeRemoteOptions;
90+
};
91+
92+
// @public
93+
export interface NodeRemoteOptions {
94+
// @internal
95+
customFetch?: typeof fetch;
96+
dispatcher?: Dispatcher;
97+
}
98+
99+
// @alpha
100+
export interface NodeSqliteOptions {
101+
// (undocumented)
102+
type: 'node:sqlite';
103+
}
104+
105+
// @public
106+
export interface NodeSQLOpenOptions extends SQLOpenOptions {
107+
// (undocumented)
108+
implementation?: NodeDatabaseImplementation;
109+
initializeConnection?: (db: LockContext, isWriter: boolean) => Promise<void>;
110+
openWorker?: WorkerOpener;
111+
readWorkerCount?: number;
112+
}
113+
114+
// @alpha
115+
export interface NodeUploadRequest {
116+
headers?: Record<string, string>;
117+
httpMethod?: 'POST' | 'PUT' | 'PATCH';
118+
mimeType?: string;
119+
url: string;
120+
}
121+
122+
// @public
123+
export const PowerSyncDatabase: PowerSyncDatabaseConstructor<NodePowerSyncDatabaseOptions>;
124+
125+
// @public (undocumented)
126+
export interface PowerSyncDatabase extends CommonPowerSyncDatabase {
127+
}
128+
129+
// @public
130+
export type WorkerOpener = (...args: ConstructorParameters<typeof Worker_2>) => InstanceType<typeof Worker_2>;
131+
132+
133+
export * from "@powersync/common";
134+
135+
// (No @packageDocumentation comment for this package)
136+
137+
```

packages/node/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"clean": "rm -rf lib dist tsconfig.tsbuildinfo",
2121
"watch": "tsc -b -w",
2222
"test": " pnpm prepare:core && vitest",
23-
"test:exports": "attw --pack . --ignore-rules no-resolution cjs-resolves-to-esm"
23+
"test:exports": "attw --pack . --ignore-rules no-resolution cjs-resolves-to-esm",
24+
"api-diff": "api-extractor run --verbose"
2425
},
2526
"type": "module",
2627
"exports": {
@@ -69,7 +70,8 @@
6970
"bson": "catalog:",
7071
"drizzle-orm": "catalog:",
7172
"typescript": "catalog:",
72-
"vitest": "catalog:"
73+
"vitest": "catalog:",
74+
"@microsoft/api-extractor": "catalog:"
7375
},
7476
"keywords": [
7577
"data sync",

packages/node/src/attachments/NodeFileSystemAdapter.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { promises as fs } from 'fs';
22
import * as path from 'path';
3-
import { AttachmentData, AttachmentTransportAdapter, EncodingType, StreamingLocalStorageAdapter } from '@powersync/common';
3+
import {
4+
AttachmentData,
5+
AttachmentTransportAdapter,
6+
EncodingType,
7+
StreamingLocalStorageAdapter
8+
} from '@powersync/common';
49

510
import {
611
NodeFileSystemTransportAdapter,
@@ -10,6 +15,8 @@ import {
1015
/**
1116
* NodeFileSystemAdapter implements LocalStorageAdapter using Node.js filesystem.
1217
* Suitable for Node.js environments and Electron applications.
18+
*
19+
* @public
1320
*/
1421
export class NodeFileSystemAdapter implements StreamingLocalStorageAdapter {
1522
constructor(private storageDirectory: string = './user_data') {}

packages/node/src/attachments/NodeFileSystemTransportAdapter.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import type { AttachmentRecord, AttachmentTransportAdapter, LocatedAttachmentRec
77
/**
88
* Describes the HTTP request used to upload a file's bytes to remote storage.
99
* Typically points at a presigned URL.
10+
*
11+
* @alpha
1012
*/
1113
export interface NodeUploadRequest {
1214
/** Destination URL (e.g. a presigned upload URL). */
@@ -22,6 +24,8 @@ export interface NodeUploadRequest {
2224
/**
2325
* Describes the HTTP request used to download a file's bytes from remote storage.
2426
* Typically points at a presigned URL.
27+
*
28+
* @alpha
2529
*/
2630
export interface NodeDownloadRequest {
2731
/** Source URL (e.g. a presigned download URL). */
@@ -35,6 +39,8 @@ export interface NodeDownloadRequest {
3539
*
3640
* The resolvers map an attachment to the request that transfers its bytes, keeping
3741
* the transport agnostic of the remote storage backend (S3, Supabase, etc.).
42+
*
43+
* @alpha
3844
*/
3945
export interface NodeFileSystemTransportAdapterOptions {
4046
/** Resolves the upload request (e.g. a presigned URL) for an attachment. */

0 commit comments

Comments
 (0)