@qaecy/cue-sdk 0.0.1 → 0.0.2
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 +97 -4
- package/index-BnBbVXtu.js +20379 -0
- package/{src/index.d.ts → index.d.ts} +2 -2
- package/index.js +7 -0
- package/{src/lib → lib}/api.d.ts +7 -4
- package/{src/lib → lib}/auth.d.ts +6 -4
- package/lib/cue-node.d.ts +21 -0
- package/lib/cue.d.ts +26 -0
- package/lib/models.d.ts +103 -0
- package/lib/project.d.ts +21 -0
- package/lib/sync.d.ts +21 -0
- package/node.d.ts +3 -0
- package/node.js +6628 -0
- package/package.json +13 -38
- package/src/index.d.ts.map +0 -1
- package/src/index.js +0 -4
- package/src/index.js.map +0 -1
- package/src/lib/api.d.ts.map +0 -1
- package/src/lib/api.js +0 -56
- package/src/lib/api.js.map +0 -1
- package/src/lib/auth.d.ts.map +0 -1
- package/src/lib/auth.js +0 -48
- package/src/lib/auth.js.map +0 -1
- package/src/lib/cue.d.ts +0 -20
- package/src/lib/cue.d.ts.map +0 -1
- package/src/lib/cue.js +0 -39
- package/src/lib/cue.js.map +0 -1
- package/src/lib/models.d.ts +0 -39
- package/src/lib/models.d.ts.map +0 -1
- package/src/lib/models.js +0 -2
- package/src/lib/models.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { Cue } from './lib/cue';
|
|
2
2
|
export { CueAuth } from './lib/auth';
|
|
3
3
|
export { CueApi } from './lib/api';
|
|
4
|
-
export
|
|
4
|
+
export { CueProjects } from './lib/project';
|
|
5
|
+
export type { CueSdkConfig, SsoProvider, PasswordCredentials, SearchRequest, SearchResponse, SearchSource, ProjectData, ProjectSettings, CreateProjectOptions, SyncOptions, SyncResult, } from './lib/models';
|
|
5
6
|
export type { AuthStateListener, Unsubscribe } from './lib/auth';
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
package/index.js
ADDED
package/{src/lib → lib}/api.d.ts
RENAMED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { CueAuth } from './auth';
|
|
2
|
+
import { SearchRequest, SearchResponse } from './models';
|
|
3
|
+
import { CueProjects } from './project';
|
|
4
|
+
import { CueSyncApi } from './sync';
|
|
3
5
|
export declare class CueApi {
|
|
4
6
|
private readonly _auth;
|
|
5
7
|
private readonly _gatewayUrl;
|
|
6
|
-
|
|
8
|
+
readonly projects: CueProjects;
|
|
9
|
+
readonly sync?: CueSyncApi | undefined;
|
|
10
|
+
constructor(_auth: CueAuth, _gatewayUrl: string, projects: CueProjects, sync?: CueSyncApi | undefined);
|
|
7
11
|
private _authHeaders;
|
|
8
12
|
/**
|
|
9
13
|
* Search project documents using natural language.
|
|
@@ -16,4 +20,3 @@ export declare class CueApi {
|
|
|
16
20
|
*/
|
|
17
21
|
sparql(query: string, projectId: string): Promise<unknown>;
|
|
18
22
|
}
|
|
19
|
-
//# sourceMappingURL=api.d.ts.map
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { Auth, User } from 'firebase/auth';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import { FirebaseApp } from 'firebase/app';
|
|
3
|
+
import { CueEndpoints, PasswordCredentials, SsoProvider } from './models';
|
|
4
4
|
export type AuthStateListener = (user: User | null) => void;
|
|
5
5
|
export type Unsubscribe = () => void;
|
|
6
6
|
export declare class CueAuth {
|
|
7
7
|
private readonly _auth;
|
|
8
|
-
|
|
8
|
+
private readonly _endpoints;
|
|
9
|
+
constructor(app: FirebaseApp, useEmulator: boolean | undefined, endpoints: CueEndpoints);
|
|
9
10
|
/** Sign in with Google or Microsoft via browser popup */
|
|
10
11
|
signIn(provider: SsoProvider): Promise<User>;
|
|
11
12
|
/** Sign in with email and password */
|
|
12
13
|
signIn(provider: 'password', credentials: PasswordCredentials): Promise<User>;
|
|
14
|
+
/** Sign in with a Cue API key */
|
|
15
|
+
signInWithApiKey(cueApiKey: string, projectId: string): Promise<User>;
|
|
13
16
|
/** Sign out the current user */
|
|
14
17
|
signOut(): Promise<void>;
|
|
15
18
|
/** Currently signed-in user, or null if not authenticated */
|
|
@@ -21,4 +24,3 @@ export declare class CueAuth {
|
|
|
21
24
|
/** Raw Firebase Auth instance, for advanced use cases */
|
|
22
25
|
get firebaseAuth(): Auth;
|
|
23
26
|
}
|
|
24
|
-
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CueApi } from './api';
|
|
2
|
+
import { Cue } from './cue';
|
|
3
|
+
import { CueProjects } from './project';
|
|
4
|
+
import { CueSyncApi } from './sync';
|
|
5
|
+
import { CueSdkConfig } from './models';
|
|
6
|
+
/**
|
|
7
|
+
* Node.js entry point for the QAECY SDK.
|
|
8
|
+
* Extends `Cue` with file-sync capabilities that require Node.js APIs.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const cue = new CueNode({ apiKey: '...', appId: '...', measurementId: '...' });
|
|
12
|
+
* await cue.auth.signInWithApiKey(key);
|
|
13
|
+
* await cue.api.sync.sync(localFiles, { spaceId, providerId, userId });
|
|
14
|
+
*/
|
|
15
|
+
export declare class CueNode extends Cue {
|
|
16
|
+
readonly api: CueApi & {
|
|
17
|
+
sync: CueSyncApi;
|
|
18
|
+
};
|
|
19
|
+
constructor(config: CueSdkConfig);
|
|
20
|
+
protected _buildApi(projects: CueProjects): CueApi;
|
|
21
|
+
}
|
package/lib/cue.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FirebaseApp } from 'firebase/app';
|
|
2
|
+
import { CueAuth } from './auth';
|
|
3
|
+
import { CueApi } from './api';
|
|
4
|
+
import { CueProjects } from './project';
|
|
5
|
+
import { CueEndpoints, CueSdkConfig } from './models';
|
|
6
|
+
/**
|
|
7
|
+
* Main entry point for the QAECY SDK (browser-safe).
|
|
8
|
+
* For Node.js use with file-sync capabilities, use `CueNode` from `js-cue-sdk/node`.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const cue = new Cue({ apiKey: '...', appId: '...', measurementId: '...' });
|
|
12
|
+
* await cue.auth.signIn('google');
|
|
13
|
+
* const results = await cue.api.search({ term: 'my query', projectId: 'project-id' });
|
|
14
|
+
*/
|
|
15
|
+
export declare class Cue {
|
|
16
|
+
readonly auth: CueAuth;
|
|
17
|
+
readonly api: CueApi;
|
|
18
|
+
protected readonly _app: FirebaseApp;
|
|
19
|
+
protected readonly _endpoints: CueEndpoints;
|
|
20
|
+
protected readonly _isEmulator: boolean;
|
|
21
|
+
constructor(config: CueSdkConfig);
|
|
22
|
+
/** Override in subclasses to provide a custom CueApi (e.g. with sync). */
|
|
23
|
+
protected _buildApi(projects: CueProjects): CueApi;
|
|
24
|
+
/** Convenience: get the current user's Firebase ID token */
|
|
25
|
+
getToken(forceRefresh?: boolean): Promise<string | null>;
|
|
26
|
+
}
|
package/lib/models.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
export type CueEnvironment = 'production' | 'emulator';
|
|
2
|
+
export interface CueEndpoints {
|
|
3
|
+
/** API gateway base URL */
|
|
4
|
+
gatewayUrl: string;
|
|
5
|
+
/** Token exchange endpoint for API key sign-in */
|
|
6
|
+
tokenUrl: string;
|
|
7
|
+
/** Firebase Auth emulator URL */
|
|
8
|
+
authEmulatorUrl: string;
|
|
9
|
+
}
|
|
10
|
+
export interface CueSdkConfig {
|
|
11
|
+
/** Firebase API key for this project */
|
|
12
|
+
apiKey: string;
|
|
13
|
+
/** Firebase App ID */
|
|
14
|
+
appId: string;
|
|
15
|
+
/** Firebase Measurement ID */
|
|
16
|
+
measurementId: string;
|
|
17
|
+
/** Target environment. Defaults to 'production'. */
|
|
18
|
+
environment?: CueEnvironment;
|
|
19
|
+
/** Override individual endpoint URLs. Takes precedence over environment. */
|
|
20
|
+
endpoints?: Partial<CueEndpoints>;
|
|
21
|
+
}
|
|
22
|
+
export type SsoProvider = 'google' | 'microsoft';
|
|
23
|
+
export interface PasswordCredentials {
|
|
24
|
+
email: string;
|
|
25
|
+
password: string;
|
|
26
|
+
}
|
|
27
|
+
export interface SearchRequest {
|
|
28
|
+
/** Natural language query or search term */
|
|
29
|
+
term: string;
|
|
30
|
+
/** Project ID to search within */
|
|
31
|
+
projectId: string;
|
|
32
|
+
/** Optional category filters */
|
|
33
|
+
categories?: string[];
|
|
34
|
+
}
|
|
35
|
+
export interface SearchSource {
|
|
36
|
+
item: string;
|
|
37
|
+
parent: string;
|
|
38
|
+
content: string;
|
|
39
|
+
}
|
|
40
|
+
export interface SearchResponse {
|
|
41
|
+
id: string;
|
|
42
|
+
question: string;
|
|
43
|
+
questionHTML: string;
|
|
44
|
+
response: string;
|
|
45
|
+
sources: SearchSource[];
|
|
46
|
+
rankedSources: SearchSource[];
|
|
47
|
+
}
|
|
48
|
+
export interface ProjectSettings {
|
|
49
|
+
views?: Array<{
|
|
50
|
+
id: string;
|
|
51
|
+
pinned?: boolean;
|
|
52
|
+
}>;
|
|
53
|
+
chatDisabled: boolean;
|
|
54
|
+
graph?: {
|
|
55
|
+
type: string;
|
|
56
|
+
uri: string;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export interface ProjectData {
|
|
60
|
+
id: string;
|
|
61
|
+
name: string;
|
|
62
|
+
organizationID: string;
|
|
63
|
+
created: string;
|
|
64
|
+
lastSync: string | null;
|
|
65
|
+
isPublic: boolean;
|
|
66
|
+
members: string[];
|
|
67
|
+
syncers: string[];
|
|
68
|
+
admins: string[];
|
|
69
|
+
alternativeIDs: string[];
|
|
70
|
+
projectSettings: ProjectSettings;
|
|
71
|
+
}
|
|
72
|
+
export interface CreateProjectOptions {
|
|
73
|
+
/** The organization this project belongs to */
|
|
74
|
+
organizationID: string;
|
|
75
|
+
/** Human-readable project name */
|
|
76
|
+
name: string;
|
|
77
|
+
/** Explicit project ID. Defaults to a new UUID. */
|
|
78
|
+
id?: string;
|
|
79
|
+
}
|
|
80
|
+
export interface SyncOptions {
|
|
81
|
+
/** The project/space ID to sync into */
|
|
82
|
+
spaceId: string;
|
|
83
|
+
/** Provider ID identifying the file source (e.g. 'local', 's3') */
|
|
84
|
+
providerId: string;
|
|
85
|
+
/** Authenticated user ID */
|
|
86
|
+
userId: string;
|
|
87
|
+
/** Enable verbose logging */
|
|
88
|
+
verbose?: boolean;
|
|
89
|
+
}
|
|
90
|
+
export interface SyncResult {
|
|
91
|
+
/** Number of files successfully synced in this run */
|
|
92
|
+
syncCount: number;
|
|
93
|
+
/** Total bytes synced in this run */
|
|
94
|
+
syncSize: number;
|
|
95
|
+
/** Number of files that failed to upload */
|
|
96
|
+
failedUploads: number;
|
|
97
|
+
/** Total file count (local + remote combined) */
|
|
98
|
+
totalCount: number;
|
|
99
|
+
/** Total size across all files */
|
|
100
|
+
totalSize: number;
|
|
101
|
+
/** Whether any RDF metadata was written */
|
|
102
|
+
rdfWritten: boolean;
|
|
103
|
+
}
|
package/lib/project.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FirebaseApp } from 'firebase/app';
|
|
2
|
+
import { CueAuth } from './auth';
|
|
3
|
+
import { CreateProjectOptions, ProjectData } from './models';
|
|
4
|
+
export declare class CueProjects {
|
|
5
|
+
private readonly _auth;
|
|
6
|
+
private readonly _db;
|
|
7
|
+
constructor(_auth: CueAuth, app: FirebaseApp, useEmulator?: boolean);
|
|
8
|
+
private _requireUser;
|
|
9
|
+
/**
|
|
10
|
+
* Create a new project. The authenticated user is automatically set as admin, syncer, and member.
|
|
11
|
+
* Throws if a project with the given ID already exists.
|
|
12
|
+
*/
|
|
13
|
+
createProject(options: CreateProjectOptions): Promise<ProjectData>;
|
|
14
|
+
/**
|
|
15
|
+
* List all projects where the authenticated user appears in the members, syncers, or admins array.
|
|
16
|
+
* Runs three parallel Firestore queries and deduplicates by project ID.
|
|
17
|
+
*/
|
|
18
|
+
listProjects(): Promise<ProjectData[]>;
|
|
19
|
+
/** Fetch a single project by ID. Returns null if not found. */
|
|
20
|
+
getProject(projectId: string): Promise<ProjectData | null>;
|
|
21
|
+
}
|
package/lib/sync.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CueBlobStorage } from 'js-databases';
|
|
2
|
+
import { LocalFile } from 'js-sync-tools';
|
|
3
|
+
import { CueAuth } from './auth';
|
|
4
|
+
import { CueProjects } from './project';
|
|
5
|
+
import { SyncOptions, SyncResult } from './models';
|
|
6
|
+
export declare class CueSyncApi {
|
|
7
|
+
private readonly _auth;
|
|
8
|
+
private readonly _projects;
|
|
9
|
+
private readonly _blob;
|
|
10
|
+
private readonly _gatewayUrl;
|
|
11
|
+
private readonly _serviceId;
|
|
12
|
+
private readonly _rdfBase;
|
|
13
|
+
private readonly _graphMap;
|
|
14
|
+
constructor(_auth: CueAuth, _projects: CueProjects, _blob: CueBlobStorage, _gatewayUrl: string, _serviceId?: string, _rdfBase?: string);
|
|
15
|
+
sync(localFiles: LocalFile[], options: SyncOptions): Promise<SyncResult>;
|
|
16
|
+
private _getOrCreateGraph;
|
|
17
|
+
private _listRemoteFiles;
|
|
18
|
+
private _getGraphFiles;
|
|
19
|
+
private _uploadRdfMetadata;
|
|
20
|
+
private _logProgress;
|
|
21
|
+
}
|
package/node.d.ts
ADDED