@prisme.ai/sdk 0.0.2 → 1.0.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/dist/lib/api.d.ts +58 -21
- package/dist/lib/endpoints/workspaces.d.ts +9 -0
- package/dist/lib/endpoints/workspacesVersions.d.ts +10 -0
- package/dist/lib/events.d.ts +26 -4
- package/dist/lib/fetcher.d.ts +5 -0
- package/dist/lib/types.d.ts +5 -1
- package/dist/sdk/lib/api.js +325 -46
- package/dist/sdk/lib/endpoints/workspaces.js +23 -0
- package/dist/sdk/lib/endpoints/workspacesVersions.js +40 -0
- package/dist/sdk/lib/events.js +74 -8
- package/dist/sdk/lib/fetcher.js +53 -17
- package/lib/api.test.ts +568 -42
- package/lib/api.ts +348 -77
- package/lib/endpoints/workspaces.ts +18 -0
- package/lib/endpoints/workspacesVersions.ts +34 -0
- package/lib/events.test.ts +39 -7
- package/lib/events.ts +123 -16
- package/lib/fetcher.test.ts +59 -13
- package/lib/fetcher.ts +54 -18
- package/lib/types.ts +5 -1
- package/package.json +1 -1
package/dist/lib/api.d.ts
CHANGED
|
@@ -1,42 +1,72 @@
|
|
|
1
1
|
import Fetcher from './fetcher';
|
|
2
2
|
import { Event, Workspace } from './types';
|
|
3
3
|
import { Events } from './events';
|
|
4
|
-
|
|
4
|
+
import WorkspacesEndpoint from './endpoints/workspaces';
|
|
5
|
+
export type UserPermissions = {
|
|
6
|
+
permissions: Prismeai.UserPermissions['permissions'];
|
|
7
|
+
target: {
|
|
8
|
+
id?: string;
|
|
9
|
+
email?: string;
|
|
10
|
+
public?: boolean;
|
|
11
|
+
role?: string;
|
|
12
|
+
displayName?: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
5
15
|
export declare class Api extends Fetcher {
|
|
16
|
+
private sessionId?;
|
|
17
|
+
private _user?;
|
|
18
|
+
get user(): Prismeai.User | undefined;
|
|
6
19
|
me(): Promise<any>;
|
|
7
20
|
signin(email: string, password: string): Promise<Prismeai.User & {
|
|
8
21
|
token: string;
|
|
9
22
|
}>;
|
|
10
|
-
|
|
23
|
+
createAnonymousSession(): Promise<Prismeai.User & {
|
|
24
|
+
token: string;
|
|
25
|
+
}>;
|
|
26
|
+
signup(email: string, password: string, firstName: string, lastName: string, language: string): Promise<Prismeai.User & {
|
|
11
27
|
token: string;
|
|
12
28
|
}>;
|
|
13
29
|
signout(): Promise<void>;
|
|
30
|
+
sendValidationMail(email: string, language: string): Promise<unknown>;
|
|
31
|
+
validateMail(token: string): Promise<unknown>;
|
|
32
|
+
sendPasswordResetMail(email: string, language: string): Promise<unknown>;
|
|
33
|
+
passwordReset(token: string, password: string): Promise<unknown>;
|
|
14
34
|
getWorkspaces(): Promise<Workspace[]>;
|
|
15
|
-
getWorkspace(id: string): Promise<
|
|
35
|
+
getWorkspace(id: string): Promise<PrismeaiAPI.GetWorkspace.Responses.$200>;
|
|
36
|
+
getWorkspaceSecurity(id: string): Promise<PrismeaiAPI.GetSecurity.Responses.$200>;
|
|
37
|
+
updateWorkspaceSecurity(workspaceId: string, security: Prismeai.WorkspaceSecurity): Promise<PrismeaiAPI.UpdateSecurity.Responses.$200>;
|
|
38
|
+
getWorkspaceRoles(id: string): Promise<PrismeaiAPI.GetRoles.Responses.$200>;
|
|
16
39
|
createWorkspace(name: string): Promise<Workspace>;
|
|
17
|
-
|
|
40
|
+
duplicateWorkspace({ id }: {
|
|
41
|
+
id: string;
|
|
42
|
+
}): Promise<Workspace | null>;
|
|
43
|
+
updateWorkspace(workspace: Prismeai.DSULPatch): Promise<PrismeaiAPI.UpdateWorkspace.Responses.$200 | null>;
|
|
18
44
|
deleteWorkspace(workspaceId: Workspace['id']): Promise<Workspace>;
|
|
19
|
-
|
|
45
|
+
generateApiKey(workspaceId: Workspace['id'], events: string[], uploads?: string[]): Promise<string>;
|
|
46
|
+
updateApiKey(workspaceId: Workspace['id'], apiKey: string, events: string[], uploads?: string[]): Promise<string>;
|
|
47
|
+
getAutomation(workspaceId: string, automationSlug: string): Promise<PrismeaiAPI.GetAutomation.Responses.$200>;
|
|
48
|
+
createAutomation(workspaceId: Workspace['id'], automation: Prismeai.Automation): Promise<Prismeai.Automation & {
|
|
20
49
|
slug: string;
|
|
21
50
|
}>;
|
|
22
|
-
updateAutomation(
|
|
51
|
+
updateAutomation(workspaceId: string, slug: string, automation: Prismeai.Automation): Promise<Prismeai.Automation & {
|
|
23
52
|
slug: string;
|
|
24
53
|
}>;
|
|
25
|
-
deleteAutomation(
|
|
54
|
+
deleteAutomation(workspaceId: string, slug: string): Promise<string>;
|
|
26
55
|
getPages(workspaceId: NonNullable<Workspace['id']>): Promise<Prismeai.Page[]>;
|
|
27
|
-
getPage(workspaceId: PrismeaiAPI.GetPage.Parameters.WorkspaceId,
|
|
28
|
-
getPageBySlug(pageSlug: PrismeaiAPI.GetPageBySlug.Parameters.
|
|
29
|
-
createPage(workspaceId:
|
|
30
|
-
updatePage(workspaceId:
|
|
31
|
-
deletePage(workspaceId:
|
|
32
|
-
streamEvents(workspaceId: string): Promise<Events>;
|
|
33
|
-
getEvents(workspaceId: string, options?:
|
|
34
|
-
beforeDate?: Date | string;
|
|
35
|
-
}): Promise<Event<Date>[]>;
|
|
56
|
+
getPage(workspaceId: PrismeaiAPI.GetPage.Parameters.WorkspaceId, pageSlug: PrismeaiAPI.GetPage.Parameters.Slug): Promise<Prismeai.DetailedPage>;
|
|
57
|
+
getPageBySlug(workspaceSlug: PrismeaiAPI.GetPageBySlug.Parameters.WorkspaceSlug, pageSlug: PrismeaiAPI.GetPageBySlug.Parameters.PageSlug): Promise<Prismeai.DetailedPage>;
|
|
58
|
+
createPage(workspaceId: PrismeaiAPI.CreatePage.Parameters.WorkspaceId, page: PrismeaiAPI.CreatePage.RequestBody): Promise<Prismeai.Page>;
|
|
59
|
+
updatePage(workspaceId: PrismeaiAPI.UpdatePage.Parameters.WorkspaceId, page: PrismeaiAPI.UpdatePage.RequestBody, prevSlug?: PrismeaiAPI.DeletePage.Parameters.Slug): Promise<Prismeai.Page>;
|
|
60
|
+
deletePage(workspaceId: PrismeaiAPI.DeletePage.Parameters.WorkspaceId, pageSlug: PrismeaiAPI.DeletePage.Parameters.Slug): Promise<PrismeaiAPI.DeletePage.Responses.$200>;
|
|
61
|
+
streamEvents(workspaceId: string, filters?: Record<string, any>): Promise<Events>;
|
|
62
|
+
getEvents(workspaceId: string, options?: Record<string, any>): Promise<Event<Date>[]>;
|
|
36
63
|
postEvents(workspaceId: PrismeaiAPI.SendWorkspaceEvent.Parameters.WorkspaceId, events: PrismeaiAPI.SendWorkspaceEvent.RequestBody['events']): Promise<boolean>;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
64
|
+
findContacts(query: PrismeaiAPI.FindContacts.RequestBody): Promise<PrismeaiAPI.FindContacts.Responses.$200>;
|
|
65
|
+
getPermissions(subjectType: PrismeaiAPI.GetPermissions.Parameters.SubjectType, subjectId: string): Promise<{
|
|
66
|
+
result: UserPermissions[];
|
|
67
|
+
}>;
|
|
68
|
+
addPermissions(subjectType: PrismeaiAPI.GetPermissions.Parameters.SubjectType, subjectId: string, permissions: UserPermissions): Promise<UserPermissions>;
|
|
69
|
+
deletePermissions(subjectType: PrismeaiAPI.GetPermissions.Parameters.SubjectType, subjectId: string, id: string): Promise<PrismeaiAPI.RevokePermissions.Responses.$200>;
|
|
40
70
|
getApps({ query, page, limit, workspaceId, }: {
|
|
41
71
|
query?: PrismeaiAPI.SearchApps.QueryParameters['text'];
|
|
42
72
|
page?: PrismeaiAPI.SearchApps.QueryParameters['page'];
|
|
@@ -48,12 +78,19 @@ export declare class Api extends Fetcher {
|
|
|
48
78
|
uninstallApp(workspaceId: PrismeaiAPI.UninstallAppInstance.PathParameters['workspaceId'], slug: PrismeaiAPI.ConfigureAppInstance.PathParameters['slug']): Promise<PrismeaiAPI.UninstallAppInstance.Responses.$200>;
|
|
49
79
|
publishApp(body: PrismeaiAPI.PublishApp.RequestBody): Promise<PrismeaiAPI.PublishApp.Responses.$200>;
|
|
50
80
|
listAppInstances(workspaceId: PrismeaiAPI.ListAppInstances.PathParameters['workspaceId']): Promise<PrismeaiAPI.ListAppInstances.Responses.$200>;
|
|
51
|
-
fetchImports(workspaceId: PrismeaiAPI.ListAppInstances.Parameters.WorkspaceId): Promise<PrismeaiAPI.ListAppInstances.Responses.$200>;
|
|
52
81
|
getAppConfig<T>(workspaceId: PrismeaiAPI.GetAppInstanceConfig.Parameters.WorkspaceId, slug: PrismeaiAPI.GetAppInstanceConfig.Parameters.Slug): Promise<T>;
|
|
53
82
|
updateAppConfig(workspaceId: PrismeaiAPI.UpdateAppInstanceConfig.Parameters.WorkspaceId, slug: PrismeaiAPI.UpdateAppInstanceConfig.Parameters.Slug, config: any): Promise<PrismeaiAPI.UpdateAppInstanceConfig.Responses.$200['config']>;
|
|
83
|
+
getAppInstance(workspaceId: string, slug: string): Promise<PrismeaiAPI.GetAppInstance.Responses.$200>;
|
|
84
|
+
saveAppInstance(workspaceId: PrismeaiAPI.ConfigureAppInstance.Parameters.WorkspaceId, slug: PrismeaiAPI.ConfigureAppInstance.Parameters.Slug, appInstance: PrismeaiAPI.ConfigureAppInstance.RequestBody): Promise<PrismeaiAPI.ConfigureAppInstance.Responses.$200>;
|
|
54
85
|
uploadFiles(files: string | string[], workspaceId: string): Promise<PrismeaiAPI.UploadFile.Responses.$200>;
|
|
55
86
|
replaceAllImagesData(original: any, workspaceId: string): Promise<any>;
|
|
56
|
-
callAutomation(workspaceId: string, automation: string): Promise<any>;
|
|
87
|
+
callAutomation(workspaceId: string, automation: string, params?: any): Promise<any>;
|
|
88
|
+
getWorkspaceUsage(workspaceId: PrismeaiAPI.WorkspaceUsage.Parameters.WorkspaceId, { afterDate, beforeDate, details, }?: {
|
|
89
|
+
afterDate?: PrismeaiAPI.WorkspaceUsage.Parameters.AfterDate;
|
|
90
|
+
beforeDate?: PrismeaiAPI.WorkspaceUsage.Parameters.BeforeDate;
|
|
91
|
+
details?: PrismeaiAPI.WorkspaceUsage.Parameters.Details;
|
|
92
|
+
}): Promise<PrismeaiAPI.WorkspaceUsage.Responses.$200>;
|
|
93
|
+
workspaces(id: string): WorkspacesEndpoint;
|
|
57
94
|
}
|
|
58
95
|
declare const _default: Api;
|
|
59
96
|
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Api } from '../api';
|
|
2
|
+
import WorkspacesVersionsEndpoint from './workspacesVersions';
|
|
3
|
+
export declare class WorkspacesEndpoint {
|
|
4
|
+
private id;
|
|
5
|
+
private api;
|
|
6
|
+
constructor(id: string, api: Api);
|
|
7
|
+
get versions(): WorkspacesVersionsEndpoint;
|
|
8
|
+
}
|
|
9
|
+
export default WorkspacesEndpoint;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Api } from '../api';
|
|
2
|
+
export declare class WorkspacesVersionsEndpoint {
|
|
3
|
+
private workspaceId;
|
|
4
|
+
private api;
|
|
5
|
+
constructor(workspaceId: string, api: Api);
|
|
6
|
+
create(version?: PrismeaiAPI.PublishWorkspaceVersion.RequestBody): void;
|
|
7
|
+
rollback(versionId: PrismeaiAPI.RollbackWorkspaceVersion.PathParameters['versionId']): void;
|
|
8
|
+
export(version?: PrismeaiAPI.ExportWorkspaceVersion.Parameters.VersionId): Promise<Blob>;
|
|
9
|
+
}
|
|
10
|
+
export default WorkspacesVersionsEndpoint;
|
package/dist/lib/events.d.ts
CHANGED
|
@@ -1,14 +1,36 @@
|
|
|
1
1
|
import { Socket } from 'socket.io-client';
|
|
2
|
+
import { Api } from './api';
|
|
3
|
+
export type PayloadQuery = Record<string, string | string[]>;
|
|
4
|
+
export type OrQuery = PayloadQuery[];
|
|
5
|
+
export type SearchOptions = Omit<PrismeaiAPI.EventsLongpolling.QueryParameters, 'query' | 'types'> & {
|
|
6
|
+
payloadQuery?: PayloadQuery | OrQuery;
|
|
7
|
+
types?: string[];
|
|
8
|
+
};
|
|
2
9
|
export declare class Events {
|
|
3
10
|
protected client: Socket;
|
|
4
11
|
workspaceId: string;
|
|
5
|
-
|
|
12
|
+
private filters;
|
|
13
|
+
private listenedUserTopics;
|
|
14
|
+
private listeners;
|
|
15
|
+
constructor({ workspaceId, token, apiKey, apiHost, filters, api, }: {
|
|
16
|
+
workspaceId: string;
|
|
17
|
+
token: string;
|
|
18
|
+
apiKey?: string;
|
|
19
|
+
apiHost?: string;
|
|
20
|
+
filters?: Record<string, any>;
|
|
21
|
+
api: Api;
|
|
22
|
+
});
|
|
6
23
|
get socket(): Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap>;
|
|
7
24
|
destroy(): void;
|
|
8
25
|
all(listener: (eventName: string, eventData: Prismeai.PrismeEvent) => void): () => Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap>;
|
|
9
|
-
on(ev: string, listener: (
|
|
10
|
-
emit(event: string, payload?: any): void;
|
|
11
|
-
|
|
26
|
+
on(ev: string, listener: (eventData: Prismeai.PrismeEvent) => void): () => void;
|
|
27
|
+
emit(event: string, payload?: any, options?: any): void;
|
|
28
|
+
listenTopics({ event, topics, }: {
|
|
29
|
+
event: string;
|
|
30
|
+
topics: string | string[];
|
|
31
|
+
}): void;
|
|
32
|
+
updateFilters(filters: SearchOptions): void;
|
|
33
|
+
once(ev: string, listener: (eventName: string, eventData: Prismeai.PrismeEvent) => void): () => void;
|
|
12
34
|
close(): void;
|
|
13
35
|
}
|
|
14
36
|
export default Events;
|
package/dist/lib/fetcher.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
export declare class Fetcher {
|
|
2
2
|
host: string;
|
|
3
3
|
token: string | null;
|
|
4
|
+
protected _apiKey: string | null;
|
|
5
|
+
language: string | undefined;
|
|
4
6
|
constructor(host: string);
|
|
7
|
+
set apiKey(apiKey: string);
|
|
8
|
+
prepareRequest(url: string, options?: RequestInit): Promise<Response>;
|
|
5
9
|
protected _fetch<T>(url: string, options?: RequestInit): Promise<T>;
|
|
6
10
|
get<T = any>(url: string): Promise<T>;
|
|
7
11
|
post<T>(url: string, body?: Record<string, any>): Promise<T>;
|
|
12
|
+
put<T>(url: string, body: Record<string, any>): Promise<T>;
|
|
8
13
|
patch<T>(url: string, body: Record<string, any>): Promise<T>;
|
|
9
14
|
delete<T>(url: string): Promise<T>;
|
|
10
15
|
}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import '@prisme.ai/types';
|
|
2
2
|
export interface Workspace extends Prismeai.Workspace {
|
|
3
3
|
id: string;
|
|
4
|
+
updatedAt: Date;
|
|
5
|
+
updatedBy: string;
|
|
6
|
+
createdAt: Date;
|
|
7
|
+
createdBy: string;
|
|
4
8
|
}
|
|
5
9
|
export interface Event<DateType extends Date | string> extends Omit<Prismeai.PrismeEvent, 'createdAt'> {
|
|
6
10
|
createdAt: DateType;
|
|
7
11
|
}
|
|
8
|
-
export
|
|
12
|
+
export type EventsFilters = Record<string, string> & {
|
|
9
13
|
afterDate?: PrismeaiAPI.EventsLongpolling.Parameters.AfterDate;
|
|
10
14
|
beforeDate?: PrismeaiAPI.EventsLongpolling.Parameters.BeforeDate;
|
|
11
15
|
text?: PrismeaiAPI.EventsLongpolling.Parameters.Text;
|