@ezpaarse-project/ezreeport-sdk-js 1.0.0-beta.1
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/CHANGELOG.md +42 -0
- package/README.md +774 -0
- package/dist/browser/ezreeport-sdk-js.mjs +2263 -0
- package/dist/browser/ezreeport-sdk-js.mjs.map +1 -0
- package/dist/browser/ezreeport-sdk-js.umd.js +4 -0
- package/dist/browser/ezreeport-sdk-js.umd.js.map +1 -0
- package/dist/node/package.json +56 -0
- package/dist/types/index.d.ts +24 -0
- package/dist/types/lib/axios.d.ts +51 -0
- package/dist/types/lib/promises.d.ts +18 -0
- package/dist/types/lib/utils.d.ts +22 -0
- package/dist/types/modules/auth.d.ts +90 -0
- package/dist/types/modules/auth.public.d.ts +1 -0
- package/dist/types/modules/crons.d.ts +78 -0
- package/dist/types/modules/crons.public.d.ts +1 -0
- package/dist/types/modules/health.d.ts +53 -0
- package/dist/types/modules/health.public.d.ts +1 -0
- package/dist/types/modules/history.d.ts +38 -0
- package/dist/types/modules/history.public.d.ts +1 -0
- package/dist/types/modules/institutions.d.ts +56 -0
- package/dist/types/modules/namespaces.d.ts +19 -0
- package/dist/types/modules/namespaces.public.d.ts +1 -0
- package/dist/types/modules/queues.d.ts +93 -0
- package/dist/types/modules/queues.public.d.ts +1 -0
- package/dist/types/modules/reports.d.ts +194 -0
- package/dist/types/modules/reports.public.d.ts +1 -0
- package/dist/types/modules/setup.d.ts +17 -0
- package/dist/types/modules/setup.public.d.ts +2 -0
- package/dist/types/modules/tasks.base.d.ts +48 -0
- package/dist/types/modules/tasks.d.ts +124 -0
- package/dist/types/modules/tasks.public.d.ts +2 -0
- package/dist/types/modules/templates.d.ts +120 -0
- package/dist/types/modules/templates.public.d.ts +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { Stream } from 'stream';
|
|
2
|
+
import { type Period, type RawPeriod } from '../lib/utils';
|
|
3
|
+
import { getJob, type FullJob, type Job } from './queues';
|
|
4
|
+
import type { RawFullTask } from './tasks';
|
|
5
|
+
interface RawReportResultDetail {
|
|
6
|
+
createdAt: string;
|
|
7
|
+
destroyAt: string;
|
|
8
|
+
took: number;
|
|
9
|
+
taskId: string;
|
|
10
|
+
files: {
|
|
11
|
+
detail: string;
|
|
12
|
+
report?: string;
|
|
13
|
+
debug?: string;
|
|
14
|
+
};
|
|
15
|
+
sendingTo?: string[];
|
|
16
|
+
period?: RawPeriod;
|
|
17
|
+
runAs?: string;
|
|
18
|
+
stats?: object;
|
|
19
|
+
error?: {
|
|
20
|
+
message: string;
|
|
21
|
+
stack: string[];
|
|
22
|
+
};
|
|
23
|
+
meta?: unknown;
|
|
24
|
+
}
|
|
25
|
+
export interface ReportResultDetail extends Omit<RawReportResultDetail, 'createdAt' | 'destroyAt' | 'period'> {
|
|
26
|
+
createdAt: Date;
|
|
27
|
+
destroyAt: Date;
|
|
28
|
+
period?: Period;
|
|
29
|
+
}
|
|
30
|
+
interface RawReportResult {
|
|
31
|
+
success: boolean;
|
|
32
|
+
detail: RawReportResultDetail;
|
|
33
|
+
}
|
|
34
|
+
export interface ReportResult extends Omit<RawReportResult, 'detail'> {
|
|
35
|
+
detail: ReportResultDetail;
|
|
36
|
+
}
|
|
37
|
+
interface RawReportData {
|
|
38
|
+
task: RawFullTask;
|
|
39
|
+
origin: string;
|
|
40
|
+
writeHistory?: boolean;
|
|
41
|
+
customPeriod?: RawPeriod;
|
|
42
|
+
debug?: boolean;
|
|
43
|
+
}
|
|
44
|
+
type ReportJob = Job<RawReportData>;
|
|
45
|
+
type FullReportJob = FullJob<RawReportData, RawReportResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Start generation of a report
|
|
48
|
+
*
|
|
49
|
+
* Needs `namespaces[namespaceId].tasks-post-task-run` permission
|
|
50
|
+
*
|
|
51
|
+
* @param taskId Id of the task
|
|
52
|
+
* @param params Other params for overriding default
|
|
53
|
+
* @param namespaces
|
|
54
|
+
*
|
|
55
|
+
* @returns Job info to track progress
|
|
56
|
+
*/
|
|
57
|
+
export declare const startGeneration: (taskId: RawFullTask['id'], params?: {
|
|
58
|
+
/**
|
|
59
|
+
* Override targets of task. Also enable first level of debugging
|
|
60
|
+
* (disable generation history)
|
|
61
|
+
*/
|
|
62
|
+
testEmails?: string[];
|
|
63
|
+
/**
|
|
64
|
+
* Override period, must match task's recurrence
|
|
65
|
+
*/
|
|
66
|
+
period?: Period;
|
|
67
|
+
}, namespaces?: string[]) => Promise<import("../lib/axios").ApiResponse<ReportJob>>;
|
|
68
|
+
export type GenerationStartedEvent = {
|
|
69
|
+
id: string | number;
|
|
70
|
+
queue: string;
|
|
71
|
+
};
|
|
72
|
+
export type GenerationProgressEvent = {
|
|
73
|
+
progress: number;
|
|
74
|
+
status: FullReportJob['status'];
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Start generation of a report and track progress
|
|
78
|
+
*
|
|
79
|
+
* Needs `namespaces[namespaceId].tasks-post-task-run`
|
|
80
|
+
* & `namespaces[namespaceId].queues-get-queue-jobs-jobId` permissions
|
|
81
|
+
*
|
|
82
|
+
* @param taskId Id of the task
|
|
83
|
+
* @param params Other params for overriding default
|
|
84
|
+
* @param namespaces
|
|
85
|
+
*
|
|
86
|
+
* @fires #started When generation started. See `GenerationStartedEvent`.
|
|
87
|
+
* @fires #progress When generation progress. See `GenerationProgressEvent`. Job's progress is
|
|
88
|
+
* between 0 and 1
|
|
89
|
+
*
|
|
90
|
+
* @throws If job's fails. **Not if generation fails !**
|
|
91
|
+
*
|
|
92
|
+
* @returns When generation ends, with detail
|
|
93
|
+
*/
|
|
94
|
+
export declare const startAndListenGeneration: (taskId: string, params?: {
|
|
95
|
+
/**
|
|
96
|
+
* Override targets of task. Also enable first level of debugging
|
|
97
|
+
* (disable generation history)
|
|
98
|
+
*/
|
|
99
|
+
testEmails?: string[] | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Override period, must match task's recurrence
|
|
102
|
+
*/
|
|
103
|
+
period?: Period | undefined;
|
|
104
|
+
} | undefined, namespaces?: string[] | undefined) => import("../lib/promises").EventfulPromise<ReportResult>;
|
|
105
|
+
interface ResponseTypeMap {
|
|
106
|
+
arraybuffer: ArrayBuffer;
|
|
107
|
+
blob: Blob;
|
|
108
|
+
json: object;
|
|
109
|
+
text: string;
|
|
110
|
+
stream: Stream;
|
|
111
|
+
}
|
|
112
|
+
type GetJobParams = Parameters<typeof getJob>;
|
|
113
|
+
/**
|
|
114
|
+
* Get report main file (the result) by giving the report's name
|
|
115
|
+
*
|
|
116
|
+
* Needs `namespaces[namespaceId].reports-get-year-yearMonth-filename` permission
|
|
117
|
+
*
|
|
118
|
+
* @param name Name of the report
|
|
119
|
+
* @param ext The extension of the result (renderer dependent)
|
|
120
|
+
* @param namespaces
|
|
121
|
+
* @param responseType Wanted response type
|
|
122
|
+
*
|
|
123
|
+
* @returns The report's content
|
|
124
|
+
*/
|
|
125
|
+
export declare const getReportFileByName: <Result extends keyof ResponseTypeMap = "text">(name: string, namespaces?: string[], responseType?: Result | undefined, ext?: string) => Promise<ResponseTypeMap[Result]>;
|
|
126
|
+
/**
|
|
127
|
+
* Get report main file (the result) by giving job's info
|
|
128
|
+
*
|
|
129
|
+
* Needs `namespaces[namespaceId].reports-get-year-yearMonth-filename`
|
|
130
|
+
* & `namespaces[namespaceId].queues-get-queue-jobs-jobId ` permission
|
|
131
|
+
*
|
|
132
|
+
* @param queueName Name of queue where job is
|
|
133
|
+
* @param jobId Id of the job in queue
|
|
134
|
+
* @param namespaces
|
|
135
|
+
* @param responseType Wanted response type
|
|
136
|
+
*
|
|
137
|
+
* @returns The report's content
|
|
138
|
+
*/
|
|
139
|
+
export declare const getReportFileByJob: <Result extends keyof ResponseTypeMap = "text">(queueName: GetJobParams[0], jobId: GetJobParams[1], namespaces?: GetJobParams[2], responseType?: Result | undefined) => Promise<ResponseTypeMap[Result]>;
|
|
140
|
+
/**
|
|
141
|
+
* Get report detail by giving the report's name
|
|
142
|
+
*
|
|
143
|
+
* Needs `namespaces[namespaceId].reports-get-year-yearMonth-filename` permission
|
|
144
|
+
*
|
|
145
|
+
* @param name Name of the report
|
|
146
|
+
* @param namespaces
|
|
147
|
+
* @param responseType Wanted response type. **If provided with anything but `json` you will have to
|
|
148
|
+
* cast in your type to avoid auto-completion issues.**
|
|
149
|
+
*
|
|
150
|
+
* @returns The detail's content
|
|
151
|
+
*/
|
|
152
|
+
export declare const getReportDetailByName: (name: string, namespaces?: string[], responseType?: keyof ResponseTypeMap) => Promise<ReportResult>;
|
|
153
|
+
/**
|
|
154
|
+
* Get report detail by giving job's info
|
|
155
|
+
*
|
|
156
|
+
* Needs `namespaces[namespaceId].reports-get-year-yearMonth-filename`
|
|
157
|
+
* & `namespaces[namespaceId].queues-get-queue-jobs-jobId` permission
|
|
158
|
+
*
|
|
159
|
+
* @param queueName Name of queue where job is
|
|
160
|
+
* @param jobId Id of the job in queue
|
|
161
|
+
* @param namespaces
|
|
162
|
+
* @param responseType Wanted response type. **If provided with anything but `json` you will have to
|
|
163
|
+
* cast in your type to avoid auto-completion issues.**
|
|
164
|
+
*
|
|
165
|
+
* @returns The detail's content
|
|
166
|
+
*/
|
|
167
|
+
export declare const getReportDetailByJob: (queueName: GetJobParams[0], jobId: GetJobParams[1], namespaces?: GetJobParams[2], responseType?: keyof ResponseTypeMap) => Promise<ReportResult>;
|
|
168
|
+
/**
|
|
169
|
+
* Get report debug file by giving the report's name
|
|
170
|
+
*
|
|
171
|
+
* Needs `namespaces[namespaceId].reports-get-year-yearMonth-filename` permission
|
|
172
|
+
*
|
|
173
|
+
* @param name Name of the report
|
|
174
|
+
* @param namespaces
|
|
175
|
+
* @param responseType Wanted response type
|
|
176
|
+
*
|
|
177
|
+
* @returns The debug's content
|
|
178
|
+
*/
|
|
179
|
+
export declare const getReportDebugByName: <Result extends keyof ResponseTypeMap = "json">(name: string, namespaces?: string[], responseType?: Result | undefined) => Promise<ResponseTypeMap[Result]>;
|
|
180
|
+
/**
|
|
181
|
+
* Get report debug file by giving job's info
|
|
182
|
+
*
|
|
183
|
+
* Needs `namespaces[namespaceId].reports-get-year-yearMonth-filename`
|
|
184
|
+
* & `namespaces[namespaceId].queues-get-queue-jobs-jobId ` permission
|
|
185
|
+
*
|
|
186
|
+
* @param queueName Name of queue where job is
|
|
187
|
+
* @param jobId Id of the job in queue
|
|
188
|
+
* @param namespaces
|
|
189
|
+
* @param responseType Wanted response type
|
|
190
|
+
*
|
|
191
|
+
* @returns The debug's content
|
|
192
|
+
*/
|
|
193
|
+
export declare const getReportDebugByJob: <Result extends keyof ResponseTypeMap = "json">(queueName: GetJobParams[0], jobId: GetJobParams[1], namespaces?: GetJobParams[2], responseType?: Result | undefined) => Promise<ResponseTypeMap[Result]>;
|
|
194
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type ReportResultDetail, type ReportResult, type GenerationStartedEvent, type GenerationProgressEvent, startGeneration, startAndListenGeneration, getReportFileByName, getReportFileByJob, getReportDetailByName, getReportDetailByJob, getReportDebugByName, getReportDebugByJob, } from './reports';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { isLogged, login, logout } from './auth';
|
|
2
|
+
/**
|
|
3
|
+
* Set API url to axios
|
|
4
|
+
*
|
|
5
|
+
* @param url The url
|
|
6
|
+
*/
|
|
7
|
+
export declare const setURL: (url: string) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Unset API url from axios
|
|
10
|
+
*/
|
|
11
|
+
export declare const unsetURL: () => void;
|
|
12
|
+
/**
|
|
13
|
+
* Check if API url is setup in axios
|
|
14
|
+
*
|
|
15
|
+
* @returns If API url is setup
|
|
16
|
+
*/
|
|
17
|
+
export declare const isURLset: () => boolean;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type RawNamespace, type Namespace } from './namespaces';
|
|
2
|
+
export declare enum Recurrence {
|
|
3
|
+
DAILY = "DAILY",
|
|
4
|
+
WEEKLY = "WEEKLY",
|
|
5
|
+
MONTHLY = "MONTHLY",
|
|
6
|
+
QUARTERLY = "QUARTERLY",
|
|
7
|
+
BIENNIAL = "BIENNIAL",
|
|
8
|
+
YEARLY = "YEARLY"
|
|
9
|
+
}
|
|
10
|
+
export interface RawTask {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
namespaceId: string;
|
|
14
|
+
recurrence: Recurrence;
|
|
15
|
+
nextRun: string;
|
|
16
|
+
lastRun?: string;
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
createdAt: string;
|
|
19
|
+
updatedAt?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface Task extends Omit<RawTask, 'nextRun' | 'lastRun' | 'createdAt' | 'updatedAt'> {
|
|
22
|
+
nextRun: Date;
|
|
23
|
+
lastRun?: Date;
|
|
24
|
+
createdAt: Date;
|
|
25
|
+
updatedAt?: Date;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Transform raw data from JSON, to JS usable data
|
|
29
|
+
*
|
|
30
|
+
* @param task Raw task
|
|
31
|
+
*
|
|
32
|
+
* @returns Parsed task
|
|
33
|
+
*/
|
|
34
|
+
export declare const parseTask: (task: RawTask) => Task;
|
|
35
|
+
export interface RawTaskWithNamespace extends Omit<RawTask, 'namespaceId'> {
|
|
36
|
+
namespace: RawNamespace;
|
|
37
|
+
}
|
|
38
|
+
export interface TaskWithNamespace extends Omit<Task, 'namespaceId'> {
|
|
39
|
+
namespace: Namespace;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Transform raw data from JSON, to JS usable data
|
|
43
|
+
*
|
|
44
|
+
* @param task Raw task with namespace
|
|
45
|
+
*
|
|
46
|
+
* @returns Parsed task with namespace
|
|
47
|
+
*/
|
|
48
|
+
export declare const parseTaskWithNamespace: (task: RawTaskWithNamespace) => TaskWithNamespace;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { type ApiResponse, type PaginatedApiResponse } from '../lib/axios';
|
|
2
|
+
import { type History, type RawHistory } from './history';
|
|
3
|
+
import type { Namespace } from './namespaces';
|
|
4
|
+
import { type Task, type RawTaskWithNamespace, type TaskWithNamespace } from './tasks.base';
|
|
5
|
+
import type { Layout } from './templates';
|
|
6
|
+
interface AdditionalRawTaskData {
|
|
7
|
+
template: {
|
|
8
|
+
extends: string;
|
|
9
|
+
fetchOptions?: object;
|
|
10
|
+
inserts?: (Layout & {
|
|
11
|
+
at: number;
|
|
12
|
+
})[];
|
|
13
|
+
};
|
|
14
|
+
targets: string[];
|
|
15
|
+
history: RawHistory[];
|
|
16
|
+
}
|
|
17
|
+
interface AdditionalTaskData extends Omit<AdditionalRawTaskData, 'history'> {
|
|
18
|
+
history: History[];
|
|
19
|
+
}
|
|
20
|
+
export interface RawFullTask extends RawTaskWithNamespace, AdditionalRawTaskData {
|
|
21
|
+
}
|
|
22
|
+
export interface FullTask extends TaskWithNamespace, AdditionalTaskData {
|
|
23
|
+
}
|
|
24
|
+
export interface InputTask extends Pick<FullTask, 'name' | 'template' | 'targets' | 'recurrence'> {
|
|
25
|
+
namespace?: Task['namespaceId'];
|
|
26
|
+
nextRun?: FullTask['nextRun'];
|
|
27
|
+
enabled?: FullTask['enabled'];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get all available tasks
|
|
31
|
+
*
|
|
32
|
+
* Needs `namespaces[namespaceId].tasks-get` permission
|
|
33
|
+
*
|
|
34
|
+
* @param paginationOpts Options for pagination
|
|
35
|
+
* @param namespaces
|
|
36
|
+
*
|
|
37
|
+
* @returns All tasks' info
|
|
38
|
+
*/
|
|
39
|
+
export declare const getAllTasks: (paginationOpts?: {
|
|
40
|
+
previous?: Task['id'];
|
|
41
|
+
count?: number;
|
|
42
|
+
}, namespaces?: Namespace['id'][]) => Promise<PaginatedApiResponse<Task[]>>;
|
|
43
|
+
/**
|
|
44
|
+
* Create a new task
|
|
45
|
+
*
|
|
46
|
+
* Needs `namespaces[namespaceId].tasks-post` permission
|
|
47
|
+
*
|
|
48
|
+
* @param task Task's data
|
|
49
|
+
* @param namespaces
|
|
50
|
+
*
|
|
51
|
+
* @returns Created task's info
|
|
52
|
+
*/
|
|
53
|
+
export declare const createTask: (task: InputTask, namespaces?: Namespace['id'][]) => Promise<ApiResponse<FullTask>>;
|
|
54
|
+
/**
|
|
55
|
+
* Get task info
|
|
56
|
+
*
|
|
57
|
+
* Needs `namespaces[namespaceId].tasks-get-task` permission
|
|
58
|
+
*
|
|
59
|
+
* @param id Task's id
|
|
60
|
+
* @param namespaces
|
|
61
|
+
*
|
|
62
|
+
* @returns Task's info
|
|
63
|
+
*/
|
|
64
|
+
export declare const getTask: (id: Task['id'], namespaces?: Namespace['id'][]) => Promise<ApiResponse<FullTask>>;
|
|
65
|
+
/**
|
|
66
|
+
* Update or create a task
|
|
67
|
+
*
|
|
68
|
+
* Needs `namespaces[namespaceId].tasks-put-task` permission
|
|
69
|
+
*
|
|
70
|
+
* @param id Task's id
|
|
71
|
+
* @param task Task's data
|
|
72
|
+
* @param namespaces
|
|
73
|
+
*
|
|
74
|
+
* @returns Updated/Created Task's info
|
|
75
|
+
*/
|
|
76
|
+
export declare const upsertTask: (id: Task['id'], task: InputTask, namespaces?: Namespace['id'][]) => Promise<ApiResponse<FullTask>>;
|
|
77
|
+
/**
|
|
78
|
+
* Update a task
|
|
79
|
+
*
|
|
80
|
+
* Needs `namespaces[namespaceId].tasks-put-task` permission
|
|
81
|
+
*
|
|
82
|
+
* @param id Task's id
|
|
83
|
+
* @param task New Task's data
|
|
84
|
+
* @param namespaces
|
|
85
|
+
*
|
|
86
|
+
* @deprecated Use `upsertTask` instead
|
|
87
|
+
*
|
|
88
|
+
* @returns Updated Task's info
|
|
89
|
+
*/
|
|
90
|
+
export declare const updateTask: (id: Task['id'], task: InputTask, namespaces?: Namespace['id'][]) => Promise<ApiResponse<FullTask>>;
|
|
91
|
+
/**
|
|
92
|
+
* Delete a task
|
|
93
|
+
*
|
|
94
|
+
* Needs `namespaces[namespaceId].tasks-delete-task` permission
|
|
95
|
+
*
|
|
96
|
+
* @param id Task's id
|
|
97
|
+
* @param namespaces
|
|
98
|
+
*
|
|
99
|
+
* @returns Deleted Task's info
|
|
100
|
+
*/
|
|
101
|
+
export declare const deleteTask: (id: Task['id'], namespaces?: Namespace['id'][]) => Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Shorthand to enable task
|
|
104
|
+
*
|
|
105
|
+
* Needs `namespaces[namespaceId].tasks-put-task-enable` permission
|
|
106
|
+
*
|
|
107
|
+
* @param id Task's id
|
|
108
|
+
* @param namespaces
|
|
109
|
+
*
|
|
110
|
+
* @returns Updated task's info
|
|
111
|
+
*/
|
|
112
|
+
export declare const enableTask: (id: Task['id'], namespaces?: Namespace['id'][]) => Promise<ApiResponse<FullTask>>;
|
|
113
|
+
/**
|
|
114
|
+
* Shorthand to disable task
|
|
115
|
+
*
|
|
116
|
+
* Needs `namespaces[namespaceId].tasks-put-task-disable` permission
|
|
117
|
+
*
|
|
118
|
+
* @param id Task's id
|
|
119
|
+
* @param namespaces
|
|
120
|
+
*
|
|
121
|
+
* @returns Updated task's info
|
|
122
|
+
*/
|
|
123
|
+
export declare const disableTask: (id: Task['id'], namespaces?: Namespace['id'][]) => Promise<ApiResponse<FullTask>>;
|
|
124
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { type ApiResponse } from '../lib/axios';
|
|
2
|
+
type JsonObject = {
|
|
3
|
+
[Key in string]?: JsonValue;
|
|
4
|
+
};
|
|
5
|
+
type JsonArray = JsonValue[];
|
|
6
|
+
type JsonValue = string | number | boolean | JsonObject | JsonArray | null;
|
|
7
|
+
export interface Figure {
|
|
8
|
+
type: string;
|
|
9
|
+
data?: string | unknown[];
|
|
10
|
+
params: JsonObject;
|
|
11
|
+
slots?: number[];
|
|
12
|
+
}
|
|
13
|
+
export interface Layout {
|
|
14
|
+
data?: unknown;
|
|
15
|
+
fetcher?: string;
|
|
16
|
+
fetchOptions?: JsonObject;
|
|
17
|
+
figures: Figure[];
|
|
18
|
+
}
|
|
19
|
+
export interface RawTemplate {
|
|
20
|
+
name: string;
|
|
21
|
+
renderer: string;
|
|
22
|
+
pageCount: number;
|
|
23
|
+
tags: {
|
|
24
|
+
name: string;
|
|
25
|
+
color?: string;
|
|
26
|
+
}[];
|
|
27
|
+
createdAt: string;
|
|
28
|
+
updatedAt?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface Template extends Omit<RawTemplate, 'createdAt' | 'updatedAt'> {
|
|
31
|
+
createdAt: Date;
|
|
32
|
+
updatedAt?: Date;
|
|
33
|
+
}
|
|
34
|
+
export interface RawFullTemplate extends RawTemplate {
|
|
35
|
+
body: {
|
|
36
|
+
renderer?: string;
|
|
37
|
+
renderOptions?: JsonObject;
|
|
38
|
+
fetchOptions?: JsonObject;
|
|
39
|
+
layouts: Layout[];
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export interface FullTemplate extends Omit<RawFullTemplate, 'createdAt' | 'updatedAt'> {
|
|
43
|
+
createdAt: Date;
|
|
44
|
+
updatedAt?: Date;
|
|
45
|
+
}
|
|
46
|
+
export interface InputTemplate {
|
|
47
|
+
body: FullTemplate['body'];
|
|
48
|
+
tags: FullTemplate['tags'];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get all available templates
|
|
52
|
+
*
|
|
53
|
+
* Needs `general.templates-get` permission
|
|
54
|
+
*
|
|
55
|
+
* @returns All templates' info
|
|
56
|
+
*/
|
|
57
|
+
export declare const getAllTemplates: () => Promise<ApiResponse<Template[]>>;
|
|
58
|
+
/**
|
|
59
|
+
* Get template info
|
|
60
|
+
*
|
|
61
|
+
* Needs `general.templates-get-name(*)` permission
|
|
62
|
+
*
|
|
63
|
+
* @param name Template's name
|
|
64
|
+
*
|
|
65
|
+
* @returns Template info
|
|
66
|
+
*/
|
|
67
|
+
export declare const getTemplate: (name: Template['name']) => Promise<ApiResponse<FullTemplate>>;
|
|
68
|
+
/**
|
|
69
|
+
* Create a new template
|
|
70
|
+
*
|
|
71
|
+
* Needs `general.templates-post` permission
|
|
72
|
+
*
|
|
73
|
+
* @param template Template's data
|
|
74
|
+
* @param namespaces
|
|
75
|
+
*
|
|
76
|
+
* @deprecated use `upsertTemplate` instead
|
|
77
|
+
*
|
|
78
|
+
* @returns Created template's info
|
|
79
|
+
*/
|
|
80
|
+
export declare const createTemplate: (template: InputTemplate & {
|
|
81
|
+
name: Template['name'];
|
|
82
|
+
}) => Promise<ApiResponse<FullTemplate>>;
|
|
83
|
+
/**
|
|
84
|
+
* Update or create a template
|
|
85
|
+
*
|
|
86
|
+
* Needs `general.templates-put-name(*)` permission
|
|
87
|
+
*
|
|
88
|
+
* @param id Template's id
|
|
89
|
+
* @param template Template's data
|
|
90
|
+
* @param namespaces
|
|
91
|
+
*
|
|
92
|
+
* @returns Updated/Created Template's info
|
|
93
|
+
*/
|
|
94
|
+
export declare const upsertTemplate: (name: Template['name'], template: InputTemplate) => Promise<ApiResponse<FullTemplate>>;
|
|
95
|
+
/**
|
|
96
|
+
* Update a template
|
|
97
|
+
*
|
|
98
|
+
* Needs `general.templates-put-name(*)` permission
|
|
99
|
+
*
|
|
100
|
+
* @param id Template's id
|
|
101
|
+
* @param template New Template's data
|
|
102
|
+
* @param namespaces
|
|
103
|
+
*
|
|
104
|
+
* @deprecated use `upsertTemplate` instead
|
|
105
|
+
*
|
|
106
|
+
* @returns Updated Template's info
|
|
107
|
+
*/
|
|
108
|
+
export declare const updateTemplate: (name: Template['name'], template: InputTemplate) => Promise<ApiResponse<FullTemplate>>;
|
|
109
|
+
/**
|
|
110
|
+
* Delete a template
|
|
111
|
+
*
|
|
112
|
+
* Needs `general.templates-delete-name(*)` permission
|
|
113
|
+
*
|
|
114
|
+
* @param id Template's id
|
|
115
|
+
* @param namespaces
|
|
116
|
+
*
|
|
117
|
+
* @returns Deleted Template's info
|
|
118
|
+
*/
|
|
119
|
+
export declare const deleteTemplate: (name: Template['name']) => Promise<void>;
|
|
120
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type Figure, type Layout, type Template, type FullTemplate, type InputTemplate, getAllTemplates, getTemplate, createTemplate, updateTemplate, upsertTemplate, deleteTemplate, } from './templates';
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ezpaarse-project/ezreeport-sdk-js",
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
|
+
"description": "JS SDK to communicate with ezReeport API",
|
|
5
|
+
"homepage": "https://github.com/ezpaarse-project/ezreeport#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/ezpaarse-project/ezreeport/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+ssh://git@github.com/ezpaarse-project/ezreeport.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "CeCILL",
|
|
14
|
+
"author": "oxypomme",
|
|
15
|
+
"exports": {
|
|
16
|
+
"browser": {
|
|
17
|
+
"import": "./dist/browser/ezreeport-sdk-js.mjs",
|
|
18
|
+
"require": "./dist/browser/ezreeport-sdk-js.umd.js"
|
|
19
|
+
},
|
|
20
|
+
"node": {
|
|
21
|
+
"default": "./dist/node/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"types": "./dist/types/index.d.ts",
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "run-s build:web build:node build:types",
|
|
30
|
+
"build:node-vite": "tsc && BUILD_TARGET=node vite build",
|
|
31
|
+
"build:node": "tsc --project tsconfig.node.json",
|
|
32
|
+
"build:types": "tsc && BUILD_TARGET=types vite build",
|
|
33
|
+
"build:web": "tsc && BUILD_TARGET=browser vite build",
|
|
34
|
+
"lint": "eslint --fix .",
|
|
35
|
+
"test": "npm run build && npm -w ezreeport-tests run test:sdk"
|
|
36
|
+
},
|
|
37
|
+
"lint-staged": {
|
|
38
|
+
"*.ts": [
|
|
39
|
+
"eslint --fix"
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"axios": "^1.3.5",
|
|
44
|
+
"date-fns": "^2.29.3",
|
|
45
|
+
"events": "^3.3.0",
|
|
46
|
+
"typescript": "^5.0.4",
|
|
47
|
+
"vite": "^4.2.1",
|
|
48
|
+
"vite-plugin-dts": "^2.2.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/node": "^18.15.11"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": "^16 || ^18"
|
|
55
|
+
}
|
|
56
|
+
}
|