chore: prettier ignore file generated by napi-rs (#4661)

This commit is contained in:
Joooye_34 2023-10-19 15:17:04 +08:00 committed by GitHub
parent c54489ba6e
commit d835be90cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 143 additions and 173 deletions

View File

@ -15,3 +15,9 @@ packages/backend/server/src/schema.gql
packages/frontend/i18n/src/i18n-generated.ts
packages/frontend/graphql/src/graphql/index.ts
tests/affine-legacy/**/static
# auto-generated by NAPI-RS
# fixme(@joooye34): need script to check and generate ignore list here
packages/backend/storage/index.d.ts
packages/frontend/native/index.d.ts
packages/frontend/native/index.js

View File

@ -3,40 +3,30 @@
/* auto-generated by NAPI-RS */
export function verifyChallengeResponse(
response: string,
bits: number,
resource: string
): Promise<boolean>;
export function mintChallengeResponse(
resource: string,
bits?: number | undefined | null
): Promise<string>;
export function verifyChallengeResponse(response: string, bits: number, resource: string): Promise<boolean>
export function mintChallengeResponse(resource: string, bits?: number | undefined | null): Promise<string>
export interface Blob {
contentType: string;
lastModified: string;
size: number;
data: Buffer;
contentType: string
lastModified: string
size: number
data: Buffer
}
/**
* Merge updates in form like `Y.applyUpdate(doc, update)` way and return the
* result binary.
*/
export function mergeUpdatesInApplyWay(updates: Array<Buffer>): Buffer;
export function mergeUpdatesInApplyWay(updates: Array<Buffer>): Buffer
export class Storage {
/** Create a storage instance and establish connection to persist store. */
static connect(
database: string,
debugOnlyAutoMigrate?: boolean | undefined | null
): Promise<Storage>;
static connect(database: string, debugOnlyAutoMigrate?: boolean | undefined | null): Promise<Storage>
/** List all blobs in a workspace. */
listBlobs(workspaceId?: string | undefined | null): Promise<Array<string>>;
listBlobs(workspaceId?: string | undefined | null): Promise<Array<string>>
/** Fetch a workspace blob. */
getBlob(workspaceId: string, name: string): Promise<Blob | null>;
getBlob(workspaceId: string, name: string): Promise<Blob | null>
/** Upload a blob into workspace storage. */
uploadBlob(workspaceId: string, blob: Buffer): Promise<string>;
uploadBlob(workspaceId: string, blob: Buffer): Promise<string>
/** Delete a blob from workspace storage. */
deleteBlob(workspaceId: string, hash: string): Promise<boolean>;
deleteBlob(workspaceId: string, hash: string): Promise<boolean>
/** Workspace size taken by blobs. */
blobsSize(workspaces: Array<string>): Promise<number>;
blobsSize(workspaces: Array<string>): Promise<number>
}

View File

@ -4,56 +4,46 @@
/* auto-generated by NAPI-RS */
export interface BlobRow {
key: string;
data: Buffer;
timestamp: Date;
key: string
data: Buffer
timestamp: Date
}
export interface UpdateRow {
id: number;
timestamp: Date;
data: Buffer;
docId?: string;
id: number
timestamp: Date
data: Buffer
docId?: string
}
export interface InsertRow {
docId?: string;
data: Uint8Array;
docId?: string
data: Uint8Array
}
export enum ValidationResult {
MissingTables = 0,
MissingDocIdColumn = 1,
MissingVersionColumn = 2,
GeneralError = 3,
Valid = 4,
Valid = 4
}
export function verifyChallengeResponse(
response: string,
bits: number,
resource: string
): Promise<boolean>;
export function mintChallengeResponse(
resource: string,
bits?: number | undefined | null
): Promise<string>;
export function verifyChallengeResponse(response: string, bits: number, resource: string): Promise<boolean>
export function mintChallengeResponse(resource: string, bits?: number | undefined | null): Promise<string>
export class SqliteConnection {
constructor(path: string);
connect(): Promise<void>;
addBlob(key: string, blob: Uint8Array): Promise<void>;
getBlob(key: string): Promise<BlobRow | null>;
deleteBlob(key: string): Promise<void>;
getBlobKeys(): Promise<Array<string>>;
getUpdates(docId?: string | undefined | null): Promise<Array<UpdateRow>>;
getUpdatesCount(docId?: string | undefined | null): Promise<number>;
getAllUpdates(): Promise<Array<UpdateRow>>;
insertUpdates(updates: Array<InsertRow>): Promise<void>;
replaceUpdates(
docId: string | undefined | null,
updates: Array<InsertRow>
): Promise<void>;
initVersion(): Promise<void>;
setVersion(version: number): Promise<void>;
getMaxVersion(): Promise<number>;
close(): Promise<void>;
get isClose(): boolean;
static validate(path: string): Promise<ValidationResult>;
migrateAddDocId(): Promise<void>;
constructor(path: string)
connect(): Promise<void>
addBlob(key: string, blob: Uint8Array): Promise<void>
getBlob(key: string): Promise<BlobRow | null>
deleteBlob(key: string): Promise<void>
getBlobKeys(): Promise<Array<string>>
getUpdates(docId?: string | undefined | null): Promise<Array<UpdateRow>>
getUpdatesCount(docId?: string | undefined | null): Promise<number>
getAllUpdates(): Promise<Array<UpdateRow>>
insertUpdates(updates: Array<InsertRow>): Promise<void>
replaceUpdates(docId: string | undefined | null, updates: Array<InsertRow>): Promise<void>
initVersion(): Promise<void>
setVersion(version: number): Promise<void>
getMaxVersion(): Promise<number>
close(): Promise<void>
get isClose(): boolean
static validate(path: string): Promise<ValidationResult>
migrateAddDocId(): Promise<void>
}

View File

@ -5,29 +5,26 @@
/* auto-generated by NAPI-RS */
const { existsSync, readFileSync } = require('fs')
const { join } = require('path');
const { join } = require('path')
const { platform, arch } = process;
const { platform, arch } = process
let nativeBinding = null;
let localFileExisted = false;
let loadError = null;
let nativeBinding = null
let localFileExisted = false
let loadError = null
function isMusl() {
// For Node 10
if (!process.report || typeof process.report.getReport !== 'function') {
try {
const lddPath = require('child_process')
.execSync('which ldd')
.toString()
.trim();
return readFileSync(lddPath, 'utf8').includes('musl');
const lddPath = require('child_process').execSync('which ldd').toString().trim()
return readFileSync(lddPath, 'utf8').includes('musl')
} catch (e) {
return true;
return true
}
} else {
const { glibcVersionRuntime } = process.report.getReport().header;
return !glibcVersionRuntime;
const { glibcVersionRuntime } = process.report.getReport().header
return !glibcVersionRuntime
}
}
@ -35,242 +32,229 @@ switch (platform) {
case 'android':
switch (arch) {
case 'arm64':
localFileExisted = existsSync(
join(__dirname, 'affine.android-arm64.node')
);
localFileExisted = existsSync(join(__dirname, 'affine.android-arm64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./affine.android-arm64.node');
nativeBinding = require('./affine.android-arm64.node')
} else {
nativeBinding = require('@affine/native-android-arm64');
nativeBinding = require('@affine/native-android-arm64')
}
} catch (e) {
loadError = e;
loadError = e
}
break;
break
case 'arm':
localFileExisted = existsSync(
join(__dirname, 'affine.android-arm-eabi.node')
);
localFileExisted = existsSync(join(__dirname, 'affine.android-arm-eabi.node'))
try {
if (localFileExisted) {
nativeBinding = require('./affine.android-arm-eabi.node');
nativeBinding = require('./affine.android-arm-eabi.node')
} else {
nativeBinding = require('@affine/native-android-arm-eabi');
nativeBinding = require('@affine/native-android-arm-eabi')
}
} catch (e) {
loadError = e;
loadError = e
}
break;
break
default:
throw new Error(`Unsupported architecture on Android ${arch}`);
throw new Error(`Unsupported architecture on Android ${arch}`)
}
break;
break
case 'win32':
switch (arch) {
case 'x64':
localFileExisted = existsSync(
join(__dirname, 'affine.win32-x64-msvc.node')
);
)
try {
if (localFileExisted) {
nativeBinding = require('./affine.win32-x64-msvc.node');
nativeBinding = require('./affine.win32-x64-msvc.node')
} else {
nativeBinding = require('@affine/native-win32-x64-msvc');
nativeBinding = require('@affine/native-win32-x64-msvc')
}
} catch (e) {
loadError = e;
loadError = e
}
break;
break
case 'ia32':
localFileExisted = existsSync(
join(__dirname, 'affine.win32-ia32-msvc.node')
);
)
try {
if (localFileExisted) {
nativeBinding = require('./affine.win32-ia32-msvc.node');
nativeBinding = require('./affine.win32-ia32-msvc.node')
} else {
nativeBinding = require('@affine/native-win32-ia32-msvc');
nativeBinding = require('@affine/native-win32-ia32-msvc')
}
} catch (e) {
loadError = e;
loadError = e
}
break;
break
case 'arm64':
localFileExisted = existsSync(
join(__dirname, 'affine.win32-arm64-msvc.node')
);
)
try {
if (localFileExisted) {
nativeBinding = require('./affine.win32-arm64-msvc.node');
nativeBinding = require('./affine.win32-arm64-msvc.node')
} else {
nativeBinding = require('@affine/native-win32-arm64-msvc');
nativeBinding = require('@affine/native-win32-arm64-msvc')
}
} catch (e) {
loadError = e;
loadError = e
}
break;
break
default:
throw new Error(`Unsupported architecture on Windows: ${arch}`);
throw new Error(`Unsupported architecture on Windows: ${arch}`)
}
break;
break
case 'darwin':
localFileExisted = existsSync(
join(__dirname, 'affine.darwin-universal.node')
);
localFileExisted = existsSync(join(__dirname, 'affine.darwin-universal.node'))
try {
if (localFileExisted) {
nativeBinding = require('./affine.darwin-universal.node');
nativeBinding = require('./affine.darwin-universal.node')
} else {
nativeBinding = require('@affine/native-darwin-universal');
nativeBinding = require('@affine/native-darwin-universal')
}
break;
break
} catch {}
switch (arch) {
case 'x64':
localFileExisted = existsSync(
join(__dirname, 'affine.darwin-x64.node')
);
localFileExisted = existsSync(join(__dirname, 'affine.darwin-x64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./affine.darwin-x64.node');
nativeBinding = require('./affine.darwin-x64.node')
} else {
nativeBinding = require('@affine/native-darwin-x64');
nativeBinding = require('@affine/native-darwin-x64')
}
} catch (e) {
loadError = e;
loadError = e
}
break;
break
case 'arm64':
localFileExisted = existsSync(
join(__dirname, 'affine.darwin-arm64.node')
);
)
try {
if (localFileExisted) {
nativeBinding = require('./affine.darwin-arm64.node');
nativeBinding = require('./affine.darwin-arm64.node')
} else {
nativeBinding = require('@affine/native-darwin-arm64');
nativeBinding = require('@affine/native-darwin-arm64')
}
} catch (e) {
loadError = e;
loadError = e
}
break;
break
default:
throw new Error(`Unsupported architecture on macOS: ${arch}`);
throw new Error(`Unsupported architecture on macOS: ${arch}`)
}
break;
break
case 'freebsd':
if (arch !== 'x64') {
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`);
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
}
localFileExisted = existsSync(join(__dirname, 'affine.freebsd-x64.node'));
localFileExisted = existsSync(join(__dirname, 'affine.freebsd-x64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./affine.freebsd-x64.node');
nativeBinding = require('./affine.freebsd-x64.node')
} else {
nativeBinding = require('@affine/native-freebsd-x64');
nativeBinding = require('@affine/native-freebsd-x64')
}
} catch (e) {
loadError = e;
loadError = e
}
break;
break
case 'linux':
switch (arch) {
case 'x64':
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'affine.linux-x64-musl.node')
);
)
try {
if (localFileExisted) {
nativeBinding = require('./affine.linux-x64-musl.node');
nativeBinding = require('./affine.linux-x64-musl.node')
} else {
nativeBinding = require('@affine/native-linux-x64-musl');
nativeBinding = require('@affine/native-linux-x64-musl')
}
} catch (e) {
loadError = e;
loadError = e
}
} else {
localFileExisted = existsSync(
join(__dirname, 'affine.linux-x64-gnu.node')
);
)
try {
if (localFileExisted) {
nativeBinding = require('./affine.linux-x64-gnu.node');
nativeBinding = require('./affine.linux-x64-gnu.node')
} else {
nativeBinding = require('@affine/native-linux-x64-gnu');
nativeBinding = require('@affine/native-linux-x64-gnu')
}
} catch (e) {
loadError = e;
loadError = e
}
}
break;
break
case 'arm64':
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'affine.linux-arm64-musl.node')
);
)
try {
if (localFileExisted) {
nativeBinding = require('./affine.linux-arm64-musl.node');
nativeBinding = require('./affine.linux-arm64-musl.node')
} else {
nativeBinding = require('@affine/native-linux-arm64-musl');
nativeBinding = require('@affine/native-linux-arm64-musl')
}
} catch (e) {
loadError = e;
loadError = e
}
} else {
localFileExisted = existsSync(
join(__dirname, 'affine.linux-arm64-gnu.node')
);
)
try {
if (localFileExisted) {
nativeBinding = require('./affine.linux-arm64-gnu.node');
nativeBinding = require('./affine.linux-arm64-gnu.node')
} else {
nativeBinding = require('@affine/native-linux-arm64-gnu');
nativeBinding = require('@affine/native-linux-arm64-gnu')
}
} catch (e) {
loadError = e;
loadError = e
}
}
break;
break
case 'arm':
localFileExisted = existsSync(
join(__dirname, 'affine.linux-arm-gnueabihf.node')
);
)
try {
if (localFileExisted) {
nativeBinding = require('./affine.linux-arm-gnueabihf.node');
nativeBinding = require('./affine.linux-arm-gnueabihf.node')
} else {
nativeBinding = require('@affine/native-linux-arm-gnueabihf');
nativeBinding = require('@affine/native-linux-arm-gnueabihf')
}
} catch (e) {
loadError = e;
loadError = e
}
break;
break
default:
throw new Error(`Unsupported architecture on Linux: ${arch}`);
throw new Error(`Unsupported architecture on Linux: ${arch}`)
}
break;
break
default:
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
}
if (!nativeBinding) {
if (loadError) {
throw loadError;
throw loadError
}
throw new Error(`Failed to load native binding`);
throw new Error(`Failed to load native binding`)
}
const {
SqliteConnection,
ValidationResult,
verifyChallengeResponse,
mintChallengeResponse,
} = nativeBinding;
const { SqliteConnection, ValidationResult, verifyChallengeResponse, mintChallengeResponse } = nativeBinding
module.exports.SqliteConnection = SqliteConnection;
module.exports.ValidationResult = ValidationResult;
module.exports.verifyChallengeResponse = verifyChallengeResponse;
module.exports.mintChallengeResponse = mintChallengeResponse;
module.exports.SqliteConnection = SqliteConnection
module.exports.ValidationResult = ValidationResult
module.exports.verifyChallengeResponse = verifyChallengeResponse
module.exports.mintChallengeResponse = mintChallengeResponse