@ezpaarse-project/ezreeport-sdk-js 2.1.0 → 2.2.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/dist/{api-DVzOqMA2.js → api-BSUnyE6V.js} +2 -2
- package/dist/api-BSUnyE6V.js.map +1 -0
- package/dist/{api-C_g0ldUn.d.ts → api-Beaugm6M.d.ts} +2 -2
- package/dist/{api-D8l8Ds3U.mjs → api-Cwb98wAh.mjs} +2 -3
- package/dist/api-Cwb98wAh.mjs.map +1 -0
- package/dist/auth.js +1 -1
- package/dist/auth.mjs +1 -1
- package/dist/crons.js +1 -1
- package/dist/crons.js.map +1 -1
- package/dist/crons.mjs +41 -39
- package/dist/crons.mjs.map +1 -1
- package/dist/decorator-C2gcn2rK.js.map +1 -1
- package/dist/{decorator-DBkj--6g.mjs → decorator-DCiVxI72.mjs} +2 -4
- package/dist/decorator-DCiVxI72.mjs.map +1 -0
- package/dist/elastic.js +1 -1
- package/dist/elastic.js.map +1 -1
- package/dist/elastic.mjs +2 -2
- package/dist/elastic.mjs.map +1 -1
- package/dist/fetch-Cp3-cNix.mjs +44 -0
- package/dist/fetch-Cp3-cNix.mjs.map +1 -0
- package/dist/fetch-DA1lo0q0.js +2 -0
- package/dist/fetch-DA1lo0q0.js.map +1 -0
- package/dist/generations.d.ts +17 -0
- package/dist/generations.js +2 -0
- package/dist/generations.js.map +1 -0
- package/dist/generations.mjs +7 -0
- package/dist/generations.mjs.map +1 -0
- package/dist/health.d.ts +20 -32
- package/dist/health.js +1 -1
- package/dist/health.js.map +1 -1
- package/dist/health.mjs +33 -31
- package/dist/health.mjs.map +1 -1
- package/dist/helpers/aggregations.d.ts +4 -4
- package/dist/helpers/aggregations.js.map +1 -1
- package/dist/helpers/aggregations.mjs.map +1 -1
- package/dist/helpers/figures.d.ts +19 -19
- package/dist/helpers/figures.js +1 -1
- package/dist/helpers/figures.mjs +1 -1
- package/dist/helpers/filters.js.map +1 -1
- package/dist/helpers/filters.mjs.map +1 -1
- package/dist/helpers/generations.d.ts +55 -0
- package/dist/helpers/generations.js +2 -0
- package/dist/helpers/generations.js.map +1 -0
- package/dist/helpers/generations.mjs +310 -0
- package/dist/helpers/generations.mjs.map +1 -0
- package/dist/helpers/layouts.d.ts +3 -3
- package/dist/helpers/layouts.js +1 -1
- package/dist/helpers/layouts.js.map +1 -1
- package/dist/helpers/layouts.mjs +6 -6
- package/dist/helpers/layouts.mjs.map +1 -1
- package/dist/helpers/permissions.d.ts +3 -1
- package/dist/helpers/permissions.js +1 -1
- package/dist/helpers/permissions.js.map +1 -1
- package/dist/helpers/permissions.mjs +8 -4
- package/dist/helpers/permissions.mjs.map +1 -1
- package/dist/helpers/task-presets.d.ts +2 -2
- package/dist/helpers/task-presets.js +1 -1
- package/dist/helpers/task-presets.js.map +1 -1
- package/dist/helpers/task-presets.mjs +6 -3
- package/dist/helpers/task-presets.mjs.map +1 -1
- package/dist/helpers/tasks.d.ts +4 -1
- package/dist/helpers/tasks.js +1 -1
- package/dist/helpers/tasks.js.map +1 -1
- package/dist/helpers/tasks.mjs +6 -4
- package/dist/helpers/tasks.mjs.map +1 -1
- package/dist/helpers/templates.js +1 -1
- package/dist/helpers/templates.js.map +1 -1
- package/dist/helpers/templates.mjs +6 -6
- package/dist/helpers/templates.mjs.map +1 -1
- package/dist/{index-btsFMVmd.js → index-Cc9-CotA.js} +2 -2
- package/dist/index-Cc9-CotA.js.map +1 -0
- package/dist/{index-niBfS4wD.mjs → index-D6K5zKgZ.mjs} +28 -29
- package/dist/index-D6K5zKgZ.mjs.map +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{methods-sTFYWEAr.mjs → methods-B78wxcbm.mjs} +59 -56
- package/dist/methods-B78wxcbm.mjs.map +1 -0
- package/dist/{methods-C3rgYZb1.mjs → methods-Ba1XR8Ij.mjs} +5 -5
- package/dist/{methods-C3rgYZb1.mjs.map → methods-Ba1XR8Ij.mjs.map} +1 -1
- package/dist/{methods-M4GU2OL5.mjs → methods-BcKnS6pA.mjs} +3 -3
- package/dist/{methods-M4GU2OL5.mjs.map → methods-BcKnS6pA.mjs.map} +1 -1
- package/dist/methods-Bf8iqEhG.mjs +95 -0
- package/dist/methods-Bf8iqEhG.mjs.map +1 -0
- package/dist/methods-CBlHpa4P.js +2 -0
- package/dist/methods-CBlHpa4P.js.map +1 -0
- package/dist/{methods-jKz01wri.mjs → methods-Crgt0cEf.mjs} +6 -6
- package/dist/{methods-jKz01wri.mjs.map → methods-Crgt0cEf.mjs.map} +1 -1
- package/dist/{methods-Jar1Wkpj.js → methods-CvCyx_v_.js} +2 -2
- package/dist/{methods-Jar1Wkpj.js.map → methods-CvCyx_v_.js.map} +1 -1
- package/dist/methods-Cvs5hjsE.js +2 -0
- package/dist/methods-Cvs5hjsE.js.map +1 -0
- package/dist/{methods-BOf9WLn2.js → methods-DJctQ3lm.js} +2 -2
- package/dist/{methods-BOf9WLn2.js.map → methods-DJctQ3lm.js.map} +1 -1
- package/dist/methods-HbhrcB_u.js +2 -0
- package/dist/methods-HbhrcB_u.js.map +1 -0
- package/dist/methods-_8MaDPJ6.mjs +158 -0
- package/dist/methods-_8MaDPJ6.mjs.map +1 -0
- package/dist/{methods-ChKQbOFl.js → methods-eIVAWN5f.js} +2 -2
- package/dist/{methods-ChKQbOFl.js.map → methods-eIVAWN5f.js.map} +1 -1
- package/dist/recurrence.d.ts +28 -0
- package/dist/recurrence.js +2 -0
- package/dist/recurrence.js.map +1 -0
- package/dist/recurrence.mjs +49 -0
- package/dist/recurrence.mjs.map +1 -0
- package/dist/reports.d.ts +4 -5
- package/dist/reports.js +1 -1
- package/dist/reports.mjs +1 -1
- package/dist/task-activity.d.ts +2 -2
- package/dist/task-activity.js +1 -1
- package/dist/task-activity.js.map +1 -1
- package/dist/task-activity.mjs +5 -5
- package/dist/task-activity.mjs.map +1 -1
- package/dist/task-presets.d.ts +3 -3
- package/dist/task-presets.js +1 -1
- package/dist/task-presets.mjs +1 -1
- package/dist/{tasks-1x680qAf.mjs → tasks-Cc53eQzu.mjs} +2 -2
- package/dist/tasks-Cc53eQzu.mjs.map +1 -0
- package/dist/{tasks-hn70eL7B.js → tasks-FPNOmtnL.js} +2 -2
- package/dist/tasks-FPNOmtnL.js.map +1 -0
- package/dist/tasks.d.ts +3 -3
- package/dist/tasks.js +1 -1
- package/dist/tasks.mjs +1 -1
- package/dist/{templates-zMmVXt6k.mjs → templates-C_qWeEww.mjs} +5 -5
- package/dist/templates-C_qWeEww.mjs.map +1 -0
- package/dist/{templates-yZjsVuN9.js → templates-lPeMpQuz.js} +2 -2
- package/dist/templates-lPeMpQuz.js.map +1 -0
- package/dist/templates.d.ts +2 -2
- package/dist/templates.js +1 -1
- package/dist/templates.mjs +1 -1
- package/dist/{transform-EpMTJExd.mjs → transform-DrB-Z9tA.mjs} +3 -3
- package/dist/transform-DrB-Z9tA.mjs.map +1 -0
- package/dist/transform-DzLAfSJo.js.map +1 -1
- package/dist/{types-DtBHOMlQ.d.ts → types-BxhkIhgG.d.ts} +1 -1
- package/dist/{types-DP1QhOKe.d.ts → types-CCDLyhAJ.d.ts} +1 -1
- package/dist/types-Cac8HEO5.d.ts +23 -0
- package/dist/{types-jXqGnCKQ.d.ts → types-CgKoQCwb.d.ts} +12 -24
- package/package.json +29 -21
- package/dist/api-D8l8Ds3U.mjs.map +0 -1
- package/dist/api-DVzOqMA2.js.map +0 -1
- package/dist/decorator-DBkj--6g.mjs.map +0 -1
- package/dist/fetch-Hd-ajPIl.js +0 -2
- package/dist/fetch-Hd-ajPIl.js.map +0 -1
- package/dist/fetch-xZFTa3q1.mjs +0 -16
- package/dist/fetch-xZFTa3q1.mjs.map +0 -1
- package/dist/helpers/jobs.d.ts +0 -109
- package/dist/helpers/jobs.js +0 -2
- package/dist/helpers/jobs.js.map +0 -1
- package/dist/helpers/jobs.mjs +0 -390
- package/dist/helpers/jobs.mjs.map +0 -1
- package/dist/index-DfRKlMeG.d.ts +0 -109
- package/dist/index-btsFMVmd.js.map +0 -1
- package/dist/index-niBfS4wD.mjs.map +0 -1
- package/dist/methods-8bLJk-Sx.mjs +0 -161
- package/dist/methods-8bLJk-Sx.mjs.map +0 -1
- package/dist/methods-BJfwYB1p.mjs +0 -126
- package/dist/methods-BJfwYB1p.mjs.map +0 -1
- package/dist/methods-CMrpqFJZ.js +0 -2
- package/dist/methods-CMrpqFJZ.js.map +0 -1
- package/dist/methods-DC2Gjy1i.js +0 -2
- package/dist/methods-DC2Gjy1i.js.map +0 -1
- package/dist/methods-DU5cbtLn.js +0 -2
- package/dist/methods-DU5cbtLn.js.map +0 -1
- package/dist/methods-sTFYWEAr.mjs.map +0 -1
- package/dist/queues.d.ts +0 -6
- package/dist/queues.js +0 -2
- package/dist/queues.js.map +0 -1
- package/dist/queues.mjs +0 -10
- package/dist/queues.mjs.map +0 -1
- package/dist/tasks-1x680qAf.mjs.map +0 -1
- package/dist/tasks-hn70eL7B.js.map +0 -1
- package/dist/templates-yZjsVuN9.js.map +0 -1
- package/dist/templates-zMmVXt6k.mjs.map +0 -1
- package/dist/transform-EpMTJExd.mjs.map +0 -1
package/dist/index-DfRKlMeG.d.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { A as ApiRequestOptions, S as SdkPaginated } from './api-C_g0ldUn.js';
|
|
2
|
-
import { c as ReportPeriod } from './types-jXqGnCKQ.js';
|
|
3
|
-
import { T as Task } from './types-DP1QhOKe.js';
|
|
4
|
-
|
|
5
|
-
interface GenerationData {
|
|
6
|
-
task: Omit<Task, 'namespace' | 'extends'>;
|
|
7
|
-
origin: string;
|
|
8
|
-
shouldWriteActivity?: boolean;
|
|
9
|
-
period?: ReportPeriod;
|
|
10
|
-
debug?: boolean;
|
|
11
|
-
}
|
|
12
|
-
interface MailData {
|
|
13
|
-
success: boolean;
|
|
14
|
-
task: {
|
|
15
|
-
id: string;
|
|
16
|
-
name: string;
|
|
17
|
-
recurrence: string;
|
|
18
|
-
targets: string[];
|
|
19
|
-
};
|
|
20
|
-
namespace: {
|
|
21
|
-
id: string;
|
|
22
|
-
name: string;
|
|
23
|
-
logo?: string;
|
|
24
|
-
};
|
|
25
|
-
contact?: string;
|
|
26
|
-
date: Date;
|
|
27
|
-
url: string;
|
|
28
|
-
generationId: string;
|
|
29
|
-
}
|
|
30
|
-
interface MailError {
|
|
31
|
-
env: string;
|
|
32
|
-
error: {
|
|
33
|
-
file: string;
|
|
34
|
-
filename: string;
|
|
35
|
-
contact: string;
|
|
36
|
-
};
|
|
37
|
-
date: Date;
|
|
38
|
-
}
|
|
39
|
-
type JobStatus = 'completed' | 'waiting' | 'active' | 'delayed' | 'failed' | 'paused' | 'stuck';
|
|
40
|
-
interface Job<Data = {}, Result = {}> {
|
|
41
|
-
id: string;
|
|
42
|
-
data: Data;
|
|
43
|
-
result?: Result;
|
|
44
|
-
progress: number;
|
|
45
|
-
added: Date;
|
|
46
|
-
started?: Date;
|
|
47
|
-
ended?: Date;
|
|
48
|
-
attempts: number;
|
|
49
|
-
status: JobStatus;
|
|
50
|
-
}
|
|
51
|
-
interface Queue {
|
|
52
|
-
name: string;
|
|
53
|
-
status: 'active' | 'paused';
|
|
54
|
-
}
|
|
55
|
-
type InputQueue = Omit<Queue, 'name'>;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Get all available queues
|
|
59
|
-
*
|
|
60
|
-
* @returns All queues' info
|
|
61
|
-
*/
|
|
62
|
-
declare function getAllQueues(): Promise<Queue[]>;
|
|
63
|
-
/**
|
|
64
|
-
* Get specific queue
|
|
65
|
-
*
|
|
66
|
-
* @param queueOrName Queue or queue's name
|
|
67
|
-
*
|
|
68
|
-
* @returns queue info
|
|
69
|
-
*/
|
|
70
|
-
declare function getQueue(queueOrName: Queue | string): Promise<Queue>;
|
|
71
|
-
/**
|
|
72
|
-
* Update specific queue
|
|
73
|
-
*
|
|
74
|
-
* @param queueOrName Queue or queue's name
|
|
75
|
-
*
|
|
76
|
-
* @returns queue info
|
|
77
|
-
*/
|
|
78
|
-
declare function updateQueue(queue: Partial<InputQueue> & {
|
|
79
|
-
name: string;
|
|
80
|
-
}): Promise<Queue>;
|
|
81
|
-
type PaginatedJobs<D = {}, R = {}> = SdkPaginated<Job<D, R>>;
|
|
82
|
-
/**
|
|
83
|
-
* Get jobs of a queue
|
|
84
|
-
*
|
|
85
|
-
* @param queueOrName Queue or queue's name
|
|
86
|
-
*
|
|
87
|
-
* @returns jobs in queue
|
|
88
|
-
*/
|
|
89
|
-
declare function getQueueJobs<D = {}, R = {}>(queueOrName: Queue | string, opts?: ApiRequestOptions): Promise<PaginatedJobs<D, R>>;
|
|
90
|
-
/**
|
|
91
|
-
* Get specific job
|
|
92
|
-
*
|
|
93
|
-
* @param queueOrName Queue or queue's name
|
|
94
|
-
* @param jobOrId Job or job's id in queue
|
|
95
|
-
*
|
|
96
|
-
* @returns Job full info
|
|
97
|
-
*/
|
|
98
|
-
declare function getJob<D = {}, R = {}>(queueOrName: Queue | string, jobOrId: Job<D, R> | string): Promise<Job<D, R>>;
|
|
99
|
-
/**
|
|
100
|
-
* Retry job that failed
|
|
101
|
-
*
|
|
102
|
-
* @param queueOrName Queue or queue's name
|
|
103
|
-
* @param jobOrId Job or job's id in queue
|
|
104
|
-
*
|
|
105
|
-
* @returns queue info
|
|
106
|
-
*/
|
|
107
|
-
declare function retryJob<D = {}, R = {}>(queueOrName: Queue | string, jobOrId: Job<D, R> | string): Promise<Job<D, R>>;
|
|
108
|
-
|
|
109
|
-
export { type GenerationData as G, type InputQueue as I, type Job as J, type MailData as M, type PaginatedJobs as P, type Queue as Q, type MailError as a, type JobStatus as b, getQueue as c, getJob as d, getQueueJobs as e, getAllQueues as g, retryJob as r, updateQueue as u };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-btsFMVmd.js","sources":["../../../node_modules/.pnpm/nanoid@5.0.9/node_modules/nanoid/non-secure/index.js","../src/helpers/templates/editor/figures/base.ts","../src/helpers/templates/editor/figures/md.ts","../src/helpers/templates/editor/figures/metric.ts","../src/helpers/templates/editor/figures/table.ts","../src/helpers/templates/editor/figures/vega.ts","../src/helpers/templates/editor/figures/index.ts"],"sourcesContent":["let urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\nexport let customAlphabet = (alphabet, defaultSize = 21) => {\n return (size = defaultSize) => {\n let id = ''\n let i = size | 0\n while (i--) {\n id += alphabet[(Math.random() * alphabet.length) | 0]\n }\n return id\n }\n}\nexport let nanoid = (size = 21) => {\n let id = ''\n let i = size | 0\n while (i--) {\n id += urlAlphabet[(Math.random() * 64) | 0]\n }\n return id\n}\n","import { nanoid } from 'nanoid/non-secure';\nimport objectHash from 'object-hash';\n\nimport type { TemplateFilter, TemplateBodyFigure } from '~/modules/templates';\n\ninterface FigureHelper {\n readonly id: string;\n readonly type: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n params: Record<string, any>,\n slots: Set<number>,\n readonly hash: string\n}\n\nfunction hashFigure(figure: FigureHelper | TemplateBodyFigure): string {\n return objectHash({\n type: figure.type,\n data: 'data' in figure ? figure.data : undefined,\n filters: 'filters' in figure ? figure.filters : undefined,\n params: figure.params,\n slots: figure.slots,\n });\n}\n\nfunction createFigureHelper<T extends FigureHelper = FigureHelper>(\n type: string,\n params: Record<string, unknown> = {},\n slots?: number[],\n): T {\n return {\n id: nanoid(),\n type,\n params,\n slots: new Set(slots ?? []),\n hash: '',\n } satisfies FigureHelper as T;\n}\n\nexport interface FigureHelperWithData extends FigureHelper {\n data: string | unknown[];\n}\n\nexport function createFigureHelperWithData<T extends FigureHelperWithData = FigureHelperWithData>(\n type: string,\n data: string | unknown[],\n params: Record<string, unknown> = {},\n slots?: number[],\n): T {\n const figure = {\n ...createFigureHelper(type, params, slots),\n data,\n } satisfies FigureHelperWithData;\n\n figure.hash = hashFigure(figure);\n return figure as T;\n}\n\nexport interface FigureHelperWithFilters extends FigureHelper {\n filters: Map<string, TemplateFilter>;\n}\n\nexport function createFigureHelperWithFilters<\n T extends FigureHelperWithFilters = FigureHelperWithFilters,\n>(\n type: string,\n filters: TemplateFilter[] = [],\n params: Record<string, unknown> = {},\n slots?: number[],\n): T {\n const figure = {\n ...createFigureHelper(type, params, slots),\n filters: new Map(filters?.map((filter) => [filter.name, filter]) ?? []),\n hash: '',\n } satisfies FigureHelperWithFilters;\n\n figure.hash = hashFigure(figure);\n return figure as T;\n}\n","import type { TemplateBodyFigure } from '~/modules/templates';\nimport { type FigureHelperWithData, createFigureHelperWithData } from './base';\n\nexport interface MdFigure extends FigureHelperWithData {\n readonly type: 'md';\n data: string;\n readonly params: {};\n}\n\nexport function createMdFigureHelper(\n data = '',\n slots?: number[],\n): MdFigure {\n return createFigureHelperWithData(\n 'md',\n data,\n {},\n slots,\n );\n}\n\nexport function createMdFigureHelperFrom(figure: TemplateBodyFigure): MdFigure {\n const data = typeof figure.data === 'string' ? figure.data : '';\n return createMdFigureHelper(data, figure.slots);\n}\n\nexport function mdHelperParamsToJSON(params: MdFigure['params']): TemplateBodyFigure['params'] {\n return params;\n}\n","import type { TemplateFilter, TemplateBodyFigure } from '~/modules/templates';\nimport type { FigureAggregation } from '../aggregations';\nimport type { FigureOrder } from './utils';\nimport { type FigureHelperWithFilters, createFigureHelperWithFilters } from './base';\n\n/**\n * Type for labels used in metrics\n */\nexport interface MetricLabel {\n /**\n * The text of the label (rendered under the value)\n */\n text: string;\n /**\n * The aggregation used to fetch data,\n * if not set, the count of documents will be used\n */\n aggregation?: FigureAggregation,\n /**\n * Format options used to format the data\n */\n format?: {\n type: 'date' | 'number';\n params?: string[];\n }\n}\n\nexport interface MetricFigureHelper extends FigureHelperWithFilters {\n readonly type: 'metric';\n params: {\n labels: MetricLabel[];\n order: FigureOrder;\n };\n}\n\nexport function createMetricFigureHelper(\n labels: MetricLabel[] = [],\n filters: TemplateFilter[] = [],\n order: FigureOrder = true,\n slots?: number[],\n): MetricFigureHelper {\n return createFigureHelperWithFilters(\n 'metric',\n filters,\n {\n labels,\n order,\n },\n slots,\n );\n}\n\nexport function createMetricFigureHelperFrom(figure: TemplateBodyFigure): MetricFigureHelper {\n return createMetricFigureHelper(\n figure.params?.labels ?? [],\n figure.filters ?? [],\n figure.params?.order ?? true,\n figure.slots,\n );\n}\n\nexport function metricHelperParamsToJSON(params: MetricFigureHelper['params']): TemplateBodyFigure['params'] {\n return {\n labels: params.labels,\n order: params.order,\n };\n}\n\nexport function getMetricLabelKey(label: MetricLabel): string {\n return label.text;\n}\n\nexport function getAllMetricLabelKeysOfHelper(figure: MetricFigureHelper): string[] {\n return figure.params.labels.map(getMetricLabelKey);\n}\n\nexport function addMetricLabelOfHelper(\n figure: MetricFigureHelper,\n element: MetricLabel,\n index?: number,\n): MetricFigureHelper {\n const key = getMetricLabelKey(element);\n if (figure.params.labels.some((l) => getMetricLabelKey(l) === key)) {\n throw new Error(`Label \"${element.text}\" already exists`);\n }\n figure.params.labels.splice(index ?? figure.params.labels.length, 0, element);\n return figure;\n}\n\nexport function removeMetricLabelOfHelper(\n figure: MetricFigureHelper,\n element: MetricLabel,\n): MetricFigureHelper {\n const f = figure;\n const key = getMetricLabelKey(element);\n f.params.labels = figure.params.labels.filter((l) => getMetricLabelKey(l) !== key);\n return figure;\n}\n\nexport function updateMetricLabelOfHelper(\n figure: MetricFigureHelper,\n oldElement: MetricLabel,\n newElement: MetricLabel,\n): MetricFigureHelper {\n const oldKey = getMetricLabelKey(oldElement);\n const index = figure.params.labels.findIndex((l) => getMetricLabelKey(l) === oldKey);\n if (index < 0) {\n throw new Error(`Label \"${oldElement.text}\" not found`);\n }\n const f = figure;\n f.params.labels[index] = newElement;\n return figure;\n}\n","import type { TemplateFilter, TemplateBodyFigure } from '~/modules/templates';\nimport type { FigureAggregation } from '../aggregations';\nimport type { FigureOrder } from './utils';\nimport { type FigureHelperWithFilters, createFigureHelperWithFilters } from './base';\n\n/**\n * Type for columns used in tables\n */\nexport type TableColumn = {\n /**\n * The name of the column\n */\n header: string,\n /**\n * Whether the column is a metric,\n * can only be used once in a table\n */\n metric?: boolean,\n /**\n * The aggregation used to fetch data,\n * if not set, the \"value\" of the previous column will be used\n */\n aggregation?: FigureAggregation,\n /**\n * The style of the cells in this column\n */\n styles?: {\n fontStyle?: 'normal' | 'bold' | 'italic' | 'bolditalic';\n fillColor?: string | [number, number, number];\n textColor?: string | [number, number, number];\n headerColor?: string | [number, number, number];\n halign?: 'left' | 'center' | 'right' | 'justify';\n valign?: 'top' | 'middle' | 'bottom';\n fontSize?: number;\n lineColor?: string | [number, number, number];\n }\n};\n\n/**\n * Type for tables\n */\nexport interface TableFigureHelper extends FigureHelperWithFilters {\n readonly type: 'table';\n params: {\n title: string,\n columns: TableColumn[],\n total?: boolean,\n order?: FigureOrder;\n };\n}\n\nexport function createTableFigureHelper(\n title: string = '',\n columns: TableColumn[] = [],\n total: boolean = false,\n filters: TemplateFilter[] = [],\n order: FigureOrder = true,\n slots?: number[],\n): TableFigureHelper {\n return createFigureHelperWithFilters(\n 'table',\n filters,\n {\n title,\n columns,\n total,\n order,\n },\n slots,\n );\n}\n\nexport function createTableFigureHelperFrom(figure: TemplateBodyFigure): TableFigureHelper {\n return createTableFigureHelper(\n figure.params?.title,\n figure.params?.columns ?? [],\n figure.params?.total ?? false,\n figure.filters ?? [],\n figure.params?.order ?? true,\n figure.slots,\n );\n}\n\nexport function tableHelperParamsToJSON(params: TableFigureHelper['params']): TemplateBodyFigure['params'] {\n return {\n title: params.title,\n columns: params.columns,\n total: params.total,\n order: params.order,\n };\n}\n\nexport function getTableColumnKey(column: TableColumn): string {\n return column.header;\n}\n\nexport function getAllTableColumnKeysOfHelper(figure: TableFigureHelper): string[] {\n return figure.params.columns.map(getTableColumnKey);\n}\n\nexport function addTableColumnOfHelper(\n figure: TableFigureHelper,\n element: TableColumn,\n index?: number,\n): TableFigureHelper {\n const key = getTableColumnKey(element);\n if (figure.params.columns.some((c) => getTableColumnKey(c) === key)) {\n throw new Error(`Column \"${element.header}\" already exists`);\n }\n figure.params.columns.splice(index ?? figure.params.columns.length, 0, element);\n return figure;\n}\n\nexport function removeTableColumnOfHelper(\n figure: TableFigureHelper,\n element: TableColumn,\n): TableFigureHelper {\n const f = figure;\n const key = getTableColumnKey(element);\n f.params.columns = figure.params.columns.filter((c) => getTableColumnKey(c) !== key);\n return figure;\n}\n\nexport function updateTableColumnOfHelper(\n figure: TableFigureHelper,\n oldElement: TableColumn,\n newElement: TableColumn,\n): TableFigureHelper {\n const oldKey = getTableColumnKey(oldElement);\n const index = figure.params.columns.findIndex((c) => getTableColumnKey(c) === oldKey);\n if (index < 0) {\n throw new Error(`Column \"${oldKey}\" not found`);\n }\n const f = figure;\n f.params.columns[index] = newElement;\n return figure;\n}\n","import type { TemplateFilter, TemplateBodyFigure } from '~/modules/templates';\nimport type { FigureAggregation } from '../aggregations';\nimport type { FigureOrder } from './utils';\nimport { type FigureHelperWithFilters, createFigureHelperWithFilters } from './base';\n\n/**\n * Type for layers used in vega\n */\nexport interface VegaLayer extends Record<string, unknown> {\n /**\n * The aggregation used to fetch data,\n * if not set, the \"value\" of the label (or color if present) layer will be used\n */\n aggregation?: FigureAggregation;\n /**\n * The title of the axis\n */\n title?: string;\n /**\n * The legend, if `null` no legend will be shown\n */\n legend?: null | { title?: string };\n}\n\n/**\n * Type for data label options\n */\nexport interface VegaDataLabelOptions {\n format: 'percent' | 'numeric';\n position?: 'out' | 'in';\n showLabel?: boolean;\n minValue?: number;\n}\n\nexport interface VegaFigureHelper extends FigureHelperWithFilters {\n params: {\n /**\n * The title of the figure\n */\n title: string;\n /**\n * Whether the axis should be inverted\n */\n invertAxis?: boolean;\n /**\n * The label layer of the figure, often used for the x axis\n */\n label: VegaLayer;\n /**\n * The value layer of the figure, often used for the y axis\n */\n value: VegaLayer;\n /**\n * The color layer of the figure, often used for splitting the value\n */\n color?: VegaLayer;\n /**\n * The data label options\n *\n * Data labels are displayed on top of the value layer, and show details about values\n */\n dataLabel?: VegaDataLabelOptions;\n /**\n * The order of the data in the chart\n */\n order?: FigureOrder;\n };\n}\n\nexport function createVegaFigureHelper(\n type: string,\n title: string = '',\n label: VegaLayer = {},\n value: VegaLayer = {},\n color?: VegaLayer,\n dataLabel?: VegaDataLabelOptions,\n invertAxis: boolean = false,\n filters: TemplateFilter[] = [],\n order: FigureOrder = true,\n slots?: number[],\n): VegaFigureHelper {\n return createFigureHelperWithFilters(\n type,\n filters,\n {\n title,\n invertAxis,\n label,\n value,\n color,\n dataLabel,\n order,\n },\n slots,\n );\n}\n\nexport function createVegaFigureHelperFrom(figure: TemplateBodyFigure): VegaFigureHelper {\n return createVegaFigureHelper(\n figure.type,\n figure.params?.title ?? '',\n figure.params?.label ?? {},\n figure.params?.value ?? {},\n figure.params?.color,\n figure.params?.dataLabel,\n figure.params?.invertAxis ?? false,\n figure.filters ?? [],\n figure.params?.order ?? true,\n figure.slots,\n );\n}\n\nexport function vegaHelperParamsToJSON(params: VegaFigureHelper['params']): TemplateBodyFigure['params'] {\n return {\n title: params.title,\n invertAxis: params.invertAxis,\n label: params.label,\n value: params.value,\n color: params.color,\n dataLabel: params.dataLabel,\n order: params.order,\n };\n}\n","import type { TemplateFilter, TemplateBodyFigure as IFigure } from '~/modules/templates';\nimport type { FigureOrder } from './utils';\n\nimport {\n type MdFigure,\n createMdFigureHelper,\n createMdFigureHelperFrom,\n mdHelperParamsToJSON,\n} from './md';\nimport {\n type MetricFigureHelper,\n createMetricFigureHelper,\n createMetricFigureHelperFrom,\n metricHelperParamsToJSON,\n} from './metric';\nimport {\n type TableFigureHelper,\n createTableFigureHelper,\n createTableFigureHelperFrom,\n tableHelperParamsToJSON,\n} from './table';\nimport {\n type VegaFigureHelper,\n createVegaFigureHelper,\n createVegaFigureHelperFrom,\n vegaHelperParamsToJSON,\n} from './vega';\n\nexport type AnyFigureHelper = MdFigure | MetricFigureHelper | TableFigureHelper | VegaFigureHelper;\n\nexport type FigureHelperSet = Map<string, AnyFigureHelper>;\n\n/**\n * Create a figure helper\n *\n * @param figure The figure object\n *\n * @returns The figure helper\n */\nexport function createFigureHelper(\n type: AnyFigureHelper['type'],\n filters?: TemplateFilter[],\n order?: FigureOrder,\n slots?: number[],\n): AnyFigureHelper {\n switch (type) {\n case 'md':\n return createMdFigureHelper(\n undefined,\n slots,\n );\n\n case 'metric':\n return createMetricFigureHelper(\n undefined,\n filters,\n order,\n slots,\n );\n\n case 'table':\n return createTableFigureHelper(\n undefined,\n undefined,\n undefined,\n filters,\n order,\n slots,\n );\n\n default:\n return createVegaFigureHelper(\n type,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n filters,\n order,\n slots,\n );\n }\n}\n\n/**\n * Create a figure helper from a figure object\n *\n * @param figure The figure object\n *\n * @returns The figure helper\n */\nexport function createFigureHelperFrom(figure: IFigure): AnyFigureHelper {\n switch (figure.type) {\n case 'md':\n return createMdFigureHelperFrom(figure);\n\n case 'metric':\n return createMetricFigureHelperFrom(figure);\n\n case 'table':\n return createTableFigureHelperFrom(figure);\n\n default:\n return createVegaFigureHelperFrom(figure);\n }\n}\n\n/**\n * Create a figure object from a figure helper\n *\n * @param figure The figure helper\n *\n * @returns The figure object\n */\nexport function figureHelperToJSON(figure: AnyFigureHelper): IFigure {\n let params: IFigure['params'] = {};\n switch (figure.type) {\n case 'md':\n params = mdHelperParamsToJSON((figure as MdFigure).params);\n break;\n\n case 'metric':\n params = metricHelperParamsToJSON((figure as MetricFigureHelper).params);\n break;\n\n case 'table':\n params = tableHelperParamsToJSON((figure as TableFigureHelper).params);\n break;\n\n default:\n params = vegaHelperParamsToJSON((figure as VegaFigureHelper).params);\n break;\n }\n\n return {\n type: figure.type,\n data: 'data' in figure ? figure.data : undefined,\n filters: 'filters' in figure ? Array.from(figure.filters.values()) : undefined,\n params,\n slots: Array.from(figure.slots),\n };\n}\n\nexport function isFigureHelperMarkdown(figure: AnyFigureHelper): figure is MdFigure {\n return figure.type === 'md';\n}\nexport function isFigureHelperMetric(figure: AnyFigureHelper): figure is MetricFigureHelper {\n return figure.type === 'metric';\n}\nexport function isFigureHelperTable(figure: AnyFigureHelper): figure is TableFigureHelper {\n return figure.type === 'table';\n}\nexport function isFigureHelperVega(figure: AnyFigureHelper): figure is VegaFigureHelper {\n return !isFigureHelperMarkdown(figure)\n && !isFigureHelperMetric(figure)\n && !isFigureHelperTable(figure);\n}\n\nexport * from './utils';\nexport * from './md';\nexport * from './metric';\nexport * from './table';\nexport * from './vega';\n"],"names":["urlAlphabet","nanoid","size","id","i","hashFigure","figure","objectHash","createFigureHelper","type","params","slots","createFigureHelperWithData","data","__spreadProps","__spreadValues","createFigureHelperWithFilters","filters","_a","filter","createMdFigureHelper","createMdFigureHelperFrom","mdHelperParamsToJSON","createMetricFigureHelper","labels","order","createMetricFigureHelperFrom","_b","_c","_e","_d","metricHelperParamsToJSON","getMetricLabelKey","label","getAllMetricLabelKeysOfHelper","addMetricLabelOfHelper","element","index","key","removeMetricLabelOfHelper","f","updateMetricLabelOfHelper","oldElement","newElement","oldKey","l","createTableFigureHelper","title","columns","total","createTableFigureHelperFrom","_f","_h","_g","tableHelperParamsToJSON","getTableColumnKey","column","getAllTableColumnKeysOfHelper","addTableColumnOfHelper","c","removeTableColumnOfHelper","updateTableColumnOfHelper","createVegaFigureHelper","value","color","dataLabel","invertAxis","createVegaFigureHelperFrom","_j","_i","_k","_m","_l","vegaHelperParamsToJSON","createFigureHelperFrom","figureHelperToJSON","isFigureHelperMarkdown","isFigureHelperMetric","isFigureHelperTable","isFigureHelperVega"],"mappings":"ydAAA,IAAIA,EACF,mEAWSC,EAAS,CAACC,EAAO,KAAO,CACjC,IAAIC,EAAK,GACLC,EAAIF,EAAO,EACf,KAAOE,KACLD,GAAMH,EAAa,KAAK,OAAQ,EAAG,GAAM,CAAC,EAE5C,OAAOG,CACT,ECLA,SAASE,EAAWC,EAAmD,CACrE,OAAOC,EAAW,CAChB,KAAMD,EAAO,KACb,KAAM,SAAUA,E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,KAAO,OACvC,QAAS,YAAaA,EAAS,MAAM,KAAKA,EAAO,QAAQ,QAAQ,EAAI,OACrE,OAAAI,EACA,MAAO,MAAM,KAAKJ,EAAO,KAAK,CAChC,CACF,CAEO,SAASsE,EAAuBtE,EAA6C,CAClF,OAAOA,EAAO,OAAS,IACzB,CACO,SAASuE,EAAqBvE,EAAuD,CAC1F,OAAOA,EAAO,OAAS,QACzB,CACO,SAASwE,EAAoBxE,EAAsD,CACxF,OAAOA,EAAO,OAAS,OACzB,CACO,SAASyE,GAAmBzE,EAAqD,CAC/E,MAAA,CAACsE,EAAuBtE,CAAM,GAChC,CAACuE,EAAqBvE,CAAM,GAC5B,CAACwE,EAAoBxE,CAAM,CAClC","x_google_ignoreList":[0]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-niBfS4wD.mjs","sources":["../../../node_modules/.pnpm/nanoid@5.0.9/node_modules/nanoid/non-secure/index.js","../src/helpers/templates/editor/figures/base.ts","../src/helpers/templates/editor/figures/md.ts","../src/helpers/templates/editor/figures/metric.ts","../src/helpers/templates/editor/figures/table.ts","../src/helpers/templates/editor/figures/vega.ts","../src/helpers/templates/editor/figures/index.ts"],"sourcesContent":["let urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\nexport let customAlphabet = (alphabet, defaultSize = 21) => {\n return (size = defaultSize) => {\n let id = ''\n let i = size | 0\n while (i--) {\n id += alphabet[(Math.random() * alphabet.length) | 0]\n }\n return id\n }\n}\nexport let nanoid = (size = 21) => {\n let id = ''\n let i = size | 0\n while (i--) {\n id += urlAlphabet[(Math.random() * 64) | 0]\n }\n return id\n}\n","import { nanoid } from 'nanoid/non-secure';\nimport objectHash from 'object-hash';\n\nimport type { TemplateFilter, TemplateBodyFigure } from '~/modules/templates';\n\ninterface FigureHelper {\n readonly id: string;\n readonly type: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n params: Record<string, any>,\n slots: Set<number>,\n readonly hash: string\n}\n\nfunction hashFigure(figure: FigureHelper | TemplateBodyFigure): string {\n return objectHash({\n type: figure.type,\n data: 'data' in figure ? figure.data : undefined,\n filters: 'filters' in figure ? figure.filters : undefined,\n params: figure.params,\n slots: figure.slots,\n });\n}\n\nfunction createFigureHelper<T extends FigureHelper = FigureHelper>(\n type: string,\n params: Record<string, unknown> = {},\n slots?: number[],\n): T {\n return {\n id: nanoid(),\n type,\n params,\n slots: new Set(slots ?? []),\n hash: '',\n } satisfies FigureHelper as T;\n}\n\nexport interface FigureHelperWithData extends FigureHelper {\n data: string | unknown[];\n}\n\nexport function createFigureHelperWithData<T extends FigureHelperWithData = FigureHelperWithData>(\n type: string,\n data: string | unknown[],\n params: Record<string, unknown> = {},\n slots?: number[],\n): T {\n const figure = {\n ...createFigureHelper(type, params, slots),\n data,\n } satisfies FigureHelperWithData;\n\n figure.hash = hashFigure(figure);\n return figure as T;\n}\n\nexport interface FigureHelperWithFilters extends FigureHelper {\n filters: Map<string, TemplateFilter>;\n}\n\nexport function createFigureHelperWithFilters<\n T extends FigureHelperWithFilters = FigureHelperWithFilters,\n>(\n type: string,\n filters: TemplateFilter[] = [],\n params: Record<string, unknown> = {},\n slots?: number[],\n): T {\n const figure = {\n ...createFigureHelper(type, params, slots),\n filters: new Map(filters?.map((filter) => [filter.name, filter]) ?? []),\n hash: '',\n } satisfies FigureHelperWithFilters;\n\n figure.hash = hashFigure(figure);\n return figure as T;\n}\n","import type { TemplateBodyFigure } from '~/modules/templates';\nimport { type FigureHelperWithData, createFigureHelperWithData } from './base';\n\nexport interface MdFigure extends FigureHelperWithData {\n readonly type: 'md';\n data: string;\n readonly params: {};\n}\n\nexport function createMdFigureHelper(\n data = '',\n slots?: number[],\n): MdFigure {\n return createFigureHelperWithData(\n 'md',\n data,\n {},\n slots,\n );\n}\n\nexport function createMdFigureHelperFrom(figure: TemplateBodyFigure): MdFigure {\n const data = typeof figure.data === 'string' ? figure.data : '';\n return createMdFigureHelper(data, figure.slots);\n}\n\nexport function mdHelperParamsToJSON(params: MdFigure['params']): TemplateBodyFigure['params'] {\n return params;\n}\n","import type { TemplateFilter, TemplateBodyFigure } from '~/modules/templates';\nimport type { FigureAggregation } from '../aggregations';\nimport type { FigureOrder } from './utils';\nimport { type FigureHelperWithFilters, createFigureHelperWithFilters } from './base';\n\n/**\n * Type for labels used in metrics\n */\nexport interface MetricLabel {\n /**\n * The text of the label (rendered under the value)\n */\n text: string;\n /**\n * The aggregation used to fetch data,\n * if not set, the count of documents will be used\n */\n aggregation?: FigureAggregation,\n /**\n * Format options used to format the data\n */\n format?: {\n type: 'date' | 'number';\n params?: string[];\n }\n}\n\nexport interface MetricFigureHelper extends FigureHelperWithFilters {\n readonly type: 'metric';\n params: {\n labels: MetricLabel[];\n order: FigureOrder;\n };\n}\n\nexport function createMetricFigureHelper(\n labels: MetricLabel[] = [],\n filters: TemplateFilter[] = [],\n order: FigureOrder = true,\n slots?: number[],\n): MetricFigureHelper {\n return createFigureHelperWithFilters(\n 'metric',\n filters,\n {\n labels,\n order,\n },\n slots,\n );\n}\n\nexport function createMetricFigureHelperFrom(figure: TemplateBodyFigure): MetricFigureHelper {\n return createMetricFigureHelper(\n figure.params?.labels ?? [],\n figure.filters ?? [],\n figure.params?.order ?? true,\n figure.slots,\n );\n}\n\nexport function metricHelperParamsToJSON(params: MetricFigureHelper['params']): TemplateBodyFigure['params'] {\n return {\n labels: params.labels,\n order: params.order,\n };\n}\n\nexport function getMetricLabelKey(label: MetricLabel): string {\n return label.text;\n}\n\nexport function getAllMetricLabelKeysOfHelper(figure: MetricFigureHelper): string[] {\n return figure.params.labels.map(getMetricLabelKey);\n}\n\nexport function addMetricLabelOfHelper(\n figure: MetricFigureHelper,\n element: MetricLabel,\n index?: number,\n): MetricFigureHelper {\n const key = getMetricLabelKey(element);\n if (figure.params.labels.some((l) => getMetricLabelKey(l) === key)) {\n throw new Error(`Label \"${element.text}\" already exists`);\n }\n figure.params.labels.splice(index ?? figure.params.labels.length, 0, element);\n return figure;\n}\n\nexport function removeMetricLabelOfHelper(\n figure: MetricFigureHelper,\n element: MetricLabel,\n): MetricFigureHelper {\n const f = figure;\n const key = getMetricLabelKey(element);\n f.params.labels = figure.params.labels.filter((l) => getMetricLabelKey(l) !== key);\n return figure;\n}\n\nexport function updateMetricLabelOfHelper(\n figure: MetricFigureHelper,\n oldElement: MetricLabel,\n newElement: MetricLabel,\n): MetricFigureHelper {\n const oldKey = getMetricLabelKey(oldElement);\n const index = figure.params.labels.findIndex((l) => getMetricLabelKey(l) === oldKey);\n if (index < 0) {\n throw new Error(`Label \"${oldElement.text}\" not found`);\n }\n const f = figure;\n f.params.labels[index] = newElement;\n return figure;\n}\n","import type { TemplateFilter, TemplateBodyFigure } from '~/modules/templates';\nimport type { FigureAggregation } from '../aggregations';\nimport type { FigureOrder } from './utils';\nimport { type FigureHelperWithFilters, createFigureHelperWithFilters } from './base';\n\n/**\n * Type for columns used in tables\n */\nexport type TableColumn = {\n /**\n * The name of the column\n */\n header: string,\n /**\n * Whether the column is a metric,\n * can only be used once in a table\n */\n metric?: boolean,\n /**\n * The aggregation used to fetch data,\n * if not set, the \"value\" of the previous column will be used\n */\n aggregation?: FigureAggregation,\n /**\n * The style of the cells in this column\n */\n styles?: {\n fontStyle?: 'normal' | 'bold' | 'italic' | 'bolditalic';\n fillColor?: string | [number, number, number];\n textColor?: string | [number, number, number];\n headerColor?: string | [number, number, number];\n halign?: 'left' | 'center' | 'right' | 'justify';\n valign?: 'top' | 'middle' | 'bottom';\n fontSize?: number;\n lineColor?: string | [number, number, number];\n }\n};\n\n/**\n * Type for tables\n */\nexport interface TableFigureHelper extends FigureHelperWithFilters {\n readonly type: 'table';\n params: {\n title: string,\n columns: TableColumn[],\n total?: boolean,\n order?: FigureOrder;\n };\n}\n\nexport function createTableFigureHelper(\n title: string = '',\n columns: TableColumn[] = [],\n total: boolean = false,\n filters: TemplateFilter[] = [],\n order: FigureOrder = true,\n slots?: number[],\n): TableFigureHelper {\n return createFigureHelperWithFilters(\n 'table',\n filters,\n {\n title,\n columns,\n total,\n order,\n },\n slots,\n );\n}\n\nexport function createTableFigureHelperFrom(figure: TemplateBodyFigure): TableFigureHelper {\n return createTableFigureHelper(\n figure.params?.title,\n figure.params?.columns ?? [],\n figure.params?.total ?? false,\n figure.filters ?? [],\n figure.params?.order ?? true,\n figure.slots,\n );\n}\n\nexport function tableHelperParamsToJSON(params: TableFigureHelper['params']): TemplateBodyFigure['params'] {\n return {\n title: params.title,\n columns: params.columns,\n total: params.total,\n order: params.order,\n };\n}\n\nexport function getTableColumnKey(column: TableColumn): string {\n return column.header;\n}\n\nexport function getAllTableColumnKeysOfHelper(figure: TableFigureHelper): string[] {\n return figure.params.columns.map(getTableColumnKey);\n}\n\nexport function addTableColumnOfHelper(\n figure: TableFigureHelper,\n element: TableColumn,\n index?: number,\n): TableFigureHelper {\n const key = getTableColumnKey(element);\n if (figure.params.columns.some((c) => getTableColumnKey(c) === key)) {\n throw new Error(`Column \"${element.header}\" already exists`);\n }\n figure.params.columns.splice(index ?? figure.params.columns.length, 0, element);\n return figure;\n}\n\nexport function removeTableColumnOfHelper(\n figure: TableFigureHelper,\n element: TableColumn,\n): TableFigureHelper {\n const f = figure;\n const key = getTableColumnKey(element);\n f.params.columns = figure.params.columns.filter((c) => getTableColumnKey(c) !== key);\n return figure;\n}\n\nexport function updateTableColumnOfHelper(\n figure: TableFigureHelper,\n oldElement: TableColumn,\n newElement: TableColumn,\n): TableFigureHelper {\n const oldKey = getTableColumnKey(oldElement);\n const index = figure.params.columns.findIndex((c) => getTableColumnKey(c) === oldKey);\n if (index < 0) {\n throw new Error(`Column \"${oldKey}\" not found`);\n }\n const f = figure;\n f.params.columns[index] = newElement;\n return figure;\n}\n","import type { TemplateFilter, TemplateBodyFigure } from '~/modules/templates';\nimport type { FigureAggregation } from '../aggregations';\nimport type { FigureOrder } from './utils';\nimport { type FigureHelperWithFilters, createFigureHelperWithFilters } from './base';\n\n/**\n * Type for layers used in vega\n */\nexport interface VegaLayer extends Record<string, unknown> {\n /**\n * The aggregation used to fetch data,\n * if not set, the \"value\" of the label (or color if present) layer will be used\n */\n aggregation?: FigureAggregation;\n /**\n * The title of the axis\n */\n title?: string;\n /**\n * The legend, if `null` no legend will be shown\n */\n legend?: null | { title?: string };\n}\n\n/**\n * Type for data label options\n */\nexport interface VegaDataLabelOptions {\n format: 'percent' | 'numeric';\n position?: 'out' | 'in';\n showLabel?: boolean;\n minValue?: number;\n}\n\nexport interface VegaFigureHelper extends FigureHelperWithFilters {\n params: {\n /**\n * The title of the figure\n */\n title: string;\n /**\n * Whether the axis should be inverted\n */\n invertAxis?: boolean;\n /**\n * The label layer of the figure, often used for the x axis\n */\n label: VegaLayer;\n /**\n * The value layer of the figure, often used for the y axis\n */\n value: VegaLayer;\n /**\n * The color layer of the figure, often used for splitting the value\n */\n color?: VegaLayer;\n /**\n * The data label options\n *\n * Data labels are displayed on top of the value layer, and show details about values\n */\n dataLabel?: VegaDataLabelOptions;\n /**\n * The order of the data in the chart\n */\n order?: FigureOrder;\n };\n}\n\nexport function createVegaFigureHelper(\n type: string,\n title: string = '',\n label: VegaLayer = {},\n value: VegaLayer = {},\n color?: VegaLayer,\n dataLabel?: VegaDataLabelOptions,\n invertAxis: boolean = false,\n filters: TemplateFilter[] = [],\n order: FigureOrder = true,\n slots?: number[],\n): VegaFigureHelper {\n return createFigureHelperWithFilters(\n type,\n filters,\n {\n title,\n invertAxis,\n label,\n value,\n color,\n dataLabel,\n order,\n },\n slots,\n );\n}\n\nexport function createVegaFigureHelperFrom(figure: TemplateBodyFigure): VegaFigureHelper {\n return createVegaFigureHelper(\n figure.type,\n figure.params?.title ?? '',\n figure.params?.label ?? {},\n figure.params?.value ?? {},\n figure.params?.color,\n figure.params?.dataLabel,\n figure.params?.invertAxis ?? false,\n figure.filters ?? [],\n figure.params?.order ?? true,\n figure.slots,\n );\n}\n\nexport function vegaHelperParamsToJSON(params: VegaFigureHelper['params']): TemplateBodyFigure['params'] {\n return {\n title: params.title,\n invertAxis: params.invertAxis,\n label: params.label,\n value: params.value,\n color: params.color,\n dataLabel: params.dataLabel,\n order: params.order,\n };\n}\n","import type { TemplateFilter, TemplateBodyFigure as IFigure } from '~/modules/templates';\nimport type { FigureOrder } from './utils';\n\nimport {\n type MdFigure,\n createMdFigureHelper,\n createMdFigureHelperFrom,\n mdHelperParamsToJSON,\n} from './md';\nimport {\n type MetricFigureHelper,\n createMetricFigureHelper,\n createMetricFigureHelperFrom,\n metricHelperParamsToJSON,\n} from './metric';\nimport {\n type TableFigureHelper,\n createTableFigureHelper,\n createTableFigureHelperFrom,\n tableHelperParamsToJSON,\n} from './table';\nimport {\n type VegaFigureHelper,\n createVegaFigureHelper,\n createVegaFigureHelperFrom,\n vegaHelperParamsToJSON,\n} from './vega';\n\nexport type AnyFigureHelper = MdFigure | MetricFigureHelper | TableFigureHelper | VegaFigureHelper;\n\nexport type FigureHelperSet = Map<string, AnyFigureHelper>;\n\n/**\n * Create a figure helper\n *\n * @param figure The figure object\n *\n * @returns The figure helper\n */\nexport function createFigureHelper(\n type: AnyFigureHelper['type'],\n filters?: TemplateFilter[],\n order?: FigureOrder,\n slots?: number[],\n): AnyFigureHelper {\n switch (type) {\n case 'md':\n return createMdFigureHelper(\n undefined,\n slots,\n );\n\n case 'metric':\n return createMetricFigureHelper(\n undefined,\n filters,\n order,\n slots,\n );\n\n case 'table':\n return createTableFigureHelper(\n undefined,\n undefined,\n undefined,\n filters,\n order,\n slots,\n );\n\n default:\n return createVegaFigureHelper(\n type,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n filters,\n order,\n slots,\n );\n }\n}\n\n/**\n * Create a figure helper from a figure object\n *\n * @param figure The figure object\n *\n * @returns The figure helper\n */\nexport function createFigureHelperFrom(figure: IFigure): AnyFigureHelper {\n switch (figure.type) {\n case 'md':\n return createMdFigureHelperFrom(figure);\n\n case 'metric':\n return createMetricFigureHelperFrom(figure);\n\n case 'table':\n return createTableFigureHelperFrom(figure);\n\n default:\n return createVegaFigureHelperFrom(figure);\n }\n}\n\n/**\n * Create a figure object from a figure helper\n *\n * @param figure The figure helper\n *\n * @returns The figure object\n */\nexport function figureHelperToJSON(figure: AnyFigureHelper): IFigure {\n let params: IFigure['params'] = {};\n switch (figure.type) {\n case 'md':\n params = mdHelperParamsToJSON((figure as MdFigure).params);\n break;\n\n case 'metric':\n params = metricHelperParamsToJSON((figure as MetricFigureHelper).params);\n break;\n\n case 'table':\n params = tableHelperParamsToJSON((figure as TableFigureHelper).params);\n break;\n\n default:\n params = vegaHelperParamsToJSON((figure as VegaFigureHelper).params);\n break;\n }\n\n return {\n type: figure.type,\n data: 'data' in figure ? figure.data : undefined,\n filters: 'filters' in figure ? Array.from(figure.filters.values()) : undefined,\n params,\n slots: Array.from(figure.slots),\n };\n}\n\nexport function isFigureHelperMarkdown(figure: AnyFigureHelper): figure is MdFigure {\n return figure.type === 'md';\n}\nexport function isFigureHelperMetric(figure: AnyFigureHelper): figure is MetricFigureHelper {\n return figure.type === 'metric';\n}\nexport function isFigureHelperTable(figure: AnyFigureHelper): figure is TableFigureHelper {\n return figure.type === 'table';\n}\nexport function isFigureHelperVega(figure: AnyFigureHelper): figure is VegaFigureHelper {\n return !isFigureHelperMarkdown(figure)\n && !isFigureHelperMetric(figure)\n && !isFigureHelperTable(figure);\n}\n\nexport * from './utils';\nexport * from './md';\nexport * from './metric';\nexport * from './table';\nexport * from './vega';\n"],"names":["urlAlphabet","nanoid","size","id","i","hashFigure","figure","objectHash","createFigureHelper","type","params","slots","createFigureHelperWithData","data","__spreadProps","__spreadValues","createFigureHelperWithFilters","filters","_a","filter","createMdFigureHelper","createMdFigureHelperFrom","mdHelperParamsToJSON","createMetricFigureHelper","labels","order","createMetricFigureHelperFrom","_b","_c","_e","_d","metricHelperParamsToJSON","getMetricLabelKey","label","getAllMetricLabelKeysOfHelper","addMetricLabelOfHelper","element","index","key","l","removeMetricLabelOfHelper","f","updateMetricLabelOfHelper","oldElement","newElement","oldKey","createTableFigureHelper","title","columns","total","createTableFigureHelperFrom","_f","_h","_g","tableHelperParamsToJSON","getTableColumnKey","column","getAllTableColumnKeysOfHelper","addTableColumnOfHelper","c","removeTableColumnOfHelper","updateTableColumnOfHelper","createVegaFigureHelper","value","color","dataLabel","invertAxis","createVegaFigureHelperFrom","_j","_i","_k","_m","_l","vegaHelperParamsToJSON","createFigureHelperFrom","figureHelperToJSON","isFigureHelperMarkdown","isFigureHelperMetric","isFigureHelperTable","isFigureHelperVega"],"mappings":";;;;;;;;;;;;;AAAA,IAAIA,IACF,oEAWSC,IAAS,CAACC,IAAO,OAAO;AACjC,MAAIC,IAAK,IACLC,IAAIF,IAAO;AACf,SAAOE;AACL,IAAAD,KAAMH,EAAa,KAAK,OAAQ,IAAG,KAAM,CAAC;AAE5C,SAAOG;AACT;ACLA,SAASE,EAAWC,GAAmD;AACrE,SAAOC,EAAW;AAAA,IAChB,MAAMD,EAAO;AAAA,IACb,MAAM,UAAUA,IAASA,EAAO,OAAO;AAAA,IACvC,SAAS,aAAaA,IAASA,EAAO,UAAU;AAAA,IAChD,QAAQA,EAAO;AAAA,IACf,OAAOA,EAAO;AAAA,EAAA,CACf;AACH;AAEA,SAASE,EACPC,GACAC,IAAkC,CAAA,GAClCC,GACG;AACI,SAAA;AAAA,IACL,IAAIV,EAAO;AAAA,IACX,MAAAQ;AAAA,IACA,QAAAC;AAAA,IACA,OAAO,IAAI,IAAIC,KAAA,OAAAA,IAAS,EAAE;AAAA,IAC1B,MAAM;AAAA,EACR;AACF;AAMO,SAASC,EACdH,GACAI,GACAH,IAAkC,CAAA,GAClCC,GACG;AACH,QAAML,IAASQ,EAAAC,EAAA,IACVP,EAAmBC,GAAMC,GAAQC,CAAK,IAD5B;AAAA,IAEb,MAAAE;AAAA,EACF;AAEO,SAAAP,EAAA,OAAOD,EAAWC,CAAM,GACxBA;AACT;AAMgB,SAAAU,EAGdP,GACAQ,IAA4B,IAC5BP,IA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AAA,IAEF,KAAK;AACM,MAAAI,IAAAqB,EAA0BzB,EAA8B,MAAM;AACvE;AAAA,IAEF,KAAK;AACM,MAAAI,IAAA4C,EAAyBhD,EAA6B,MAAM;AACrE;AAAA,IAEF;AACW,MAAAI,IAAA+D,EAAwBnE,EAA4B,MAAM;AACnE;AAAA,EAAA;AAGG,SAAA;AAAA,IACL,MAAMA,EAAO;AAAA,IACb,MAAM,UAAUA,IAASA,EAAO,OAAO;AAAA,IACvC,SAAS,aAAaA,IAAS,MAAM,KAAKA,EAAO,QAAQ,QAAQ,IAAI;AAAA,IACrE,QAAAI;AAAA,IACA,OAAO,MAAM,KAAKJ,EAAO,KAAK;AAAA,EAChC;AACF;AAEO,SAASsE,EAAuBtE,GAA6C;AAClF,SAAOA,EAAO,SAAS;AACzB;AACO,SAASuE,EAAqBvE,GAAuD;AAC1F,SAAOA,EAAO,SAAS;AACzB;AACO,SAASwE,EAAoBxE,GAAsD;AACxF,SAAOA,EAAO,SAAS;AACzB;AACO,SAASyE,GAAmBzE,GAAqD;AAC/E,SAAA,CAACsE,EAAuBtE,CAAM,KAChC,CAACuE,EAAqBvE,CAAM,KAC5B,CAACwE,EAAoBxE,CAAM;AAClC;","x_google_ignoreList":[0]}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
var E = Object.defineProperty, l = Object.defineProperties;
|
|
2
|
-
var $ = Object.getOwnPropertyDescriptors;
|
|
3
|
-
var h = Object.getOwnPropertySymbols;
|
|
4
|
-
var q = Object.prototype.hasOwnProperty, A = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var g = (e, t, r) => t in e ? E(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, y = (e, t) => {
|
|
6
|
-
for (var r in t || (t = {}))
|
|
7
|
-
q.call(t, r) && g(e, r, t[r]);
|
|
8
|
-
if (h)
|
|
9
|
-
for (var r of h(t))
|
|
10
|
-
A.call(t, r) && g(e, r, t[r]);
|
|
11
|
-
return e;
|
|
12
|
-
}, u = (e, t) => l(e, $(t));
|
|
13
|
-
var o = (e, t, r) => new Promise((p, a) => {
|
|
14
|
-
var f = (i) => {
|
|
15
|
-
try {
|
|
16
|
-
c(r.next(i));
|
|
17
|
-
} catch (d) {
|
|
18
|
-
a(d);
|
|
19
|
-
}
|
|
20
|
-
}, w = (i) => {
|
|
21
|
-
try {
|
|
22
|
-
c(r.throw(i));
|
|
23
|
-
} catch (d) {
|
|
24
|
-
a(d);
|
|
25
|
-
}
|
|
26
|
-
}, c = (i) => i.done ? p(i.value) : Promise.resolve(i.value).then(f, w);
|
|
27
|
-
c((r = r.apply(e, t)).next());
|
|
28
|
-
});
|
|
29
|
-
import { formatISO as m, parseISO as T } from "date-fns";
|
|
30
|
-
import { c as s } from "./fetch-xZFTa3q1.mjs";
|
|
31
|
-
import { t as x } from "./transform-EpMTJExd.mjs";
|
|
32
|
-
import { a as n } from "./decorator-DBkj--6g.mjs";
|
|
33
|
-
const G = (e) => ({
|
|
34
|
-
start: T(e.start),
|
|
35
|
-
end: T(e.end)
|
|
36
|
-
}), b = (e) => u(y({}, x(e)), {
|
|
37
|
-
destroyAt: T(e.destroyAt),
|
|
38
|
-
period: e.period ? G(e.period) : void 0
|
|
39
|
-
}), z = (e) => u(y({}, e), {
|
|
40
|
-
detail: b(e.detail)
|
|
41
|
-
});
|
|
42
|
-
function R() {
|
|
43
|
-
return o(this, null, function* () {
|
|
44
|
-
const {
|
|
45
|
-
content: e
|
|
46
|
-
} = yield s.fetch(
|
|
47
|
-
"/reports"
|
|
48
|
-
);
|
|
49
|
-
return e;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
n(R, "GET /reports");
|
|
53
|
-
function F(e) {
|
|
54
|
-
return o(this, null, function* () {
|
|
55
|
-
const t = typeof e == "string" ? e : e.id;
|
|
56
|
-
if (!t)
|
|
57
|
-
throw new Error("Task id is required");
|
|
58
|
-
const {
|
|
59
|
-
content: r
|
|
60
|
-
} = yield s.fetch(
|
|
61
|
-
`/reports/${t}`
|
|
62
|
-
);
|
|
63
|
-
return r;
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
n(F, "GET /reports/:taskId", !0);
|
|
67
|
-
function M(e, t) {
|
|
68
|
-
return o(this, null, function* () {
|
|
69
|
-
const r = typeof e == "string" ? e : e.id;
|
|
70
|
-
if (!r)
|
|
71
|
-
throw new Error("Task id is required");
|
|
72
|
-
return s.fetch(`/reports/${r}/${t}`, {
|
|
73
|
-
responseType: "blob"
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
n(M, "GET /reports/:taskId/:year/:yearMonth/:reportId.:type.:ext", !0);
|
|
78
|
-
function S(e, t) {
|
|
79
|
-
return o(this, null, function* () {
|
|
80
|
-
const r = typeof e == "string" ? e : e.id;
|
|
81
|
-
if (!r)
|
|
82
|
-
throw new Error("Task id is required");
|
|
83
|
-
return s.fetch(`/reports/${r}/${t}`, {
|
|
84
|
-
responseType: "arrayBuffer"
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
n(S, "GET /reports/:taskId/:year/:yearMonth/:reportId.:type.:ext", !0);
|
|
89
|
-
function P(e, t) {
|
|
90
|
-
return o(this, null, function* () {
|
|
91
|
-
const r = typeof e == "string" ? e : e.id;
|
|
92
|
-
if (!r)
|
|
93
|
-
throw new Error("Task id is required");
|
|
94
|
-
return s.fetch(`/reports/${r}/${t}`, {
|
|
95
|
-
responseType: "stream"
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
n(P, "GET /reports/:taskId/:year/:yearMonth/:reportId.:type.:ext", !0);
|
|
100
|
-
function B(e, t) {
|
|
101
|
-
return o(this, null, function* () {
|
|
102
|
-
const r = typeof e == "string" ? e : e.id;
|
|
103
|
-
if (!r)
|
|
104
|
-
throw new Error("Task id is required");
|
|
105
|
-
return s.fetch(`/reports/${r}/${t}`, {
|
|
106
|
-
responseType: "text"
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
n(B, "GET /reports/:taskId/:year/:yearMonth/:reportId.:type.:ext", !0);
|
|
111
|
-
function k(e, t) {
|
|
112
|
-
return o(this, null, function* () {
|
|
113
|
-
const r = typeof e == "string" ? e : e.id;
|
|
114
|
-
if (!r)
|
|
115
|
-
throw new Error("Task id is required");
|
|
116
|
-
return s.fetch(`/reports/${r}/${t}`);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
n(k, "GET /reports/:taskId/:year/:yearMonth/:reportId.:type.:ext", !0);
|
|
120
|
-
function D(e, t, r) {
|
|
121
|
-
return o(this, null, function* () {
|
|
122
|
-
const p = typeof e == "string" ? e : e.id;
|
|
123
|
-
if (!p)
|
|
124
|
-
throw new Error("Task id is required");
|
|
125
|
-
let a;
|
|
126
|
-
t && (a = {
|
|
127
|
-
start: m(t.start, { representation: "date" }),
|
|
128
|
-
end: m(t.end, { representation: "date" })
|
|
129
|
-
});
|
|
130
|
-
const {
|
|
131
|
-
content: f
|
|
132
|
-
} = yield s.fetch(
|
|
133
|
-
`/reports/${p}`,
|
|
134
|
-
{
|
|
135
|
-
method: "POST",
|
|
136
|
-
body: {
|
|
137
|
-
period: a,
|
|
138
|
-
targets: r
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
);
|
|
142
|
-
return {
|
|
143
|
-
queue: f.queue,
|
|
144
|
-
jobId: f.id
|
|
145
|
-
};
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
n(D, "POST /reports/:taskId", !0);
|
|
149
|
-
export {
|
|
150
|
-
F as a,
|
|
151
|
-
D as b,
|
|
152
|
-
k as c,
|
|
153
|
-
P as d,
|
|
154
|
-
S as e,
|
|
155
|
-
M as f,
|
|
156
|
-
R as g,
|
|
157
|
-
B as h,
|
|
158
|
-
G as i,
|
|
159
|
-
z as t
|
|
160
|
-
};
|
|
161
|
-
//# sourceMappingURL=methods-8bLJk-Sx.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"methods-8bLJk-Sx.mjs","sources":["../src/modules/reports/methods.ts"],"sourcesContent":["import { formatISO, parseISO } from 'date-fns';\n\nimport { client } from '~/lib/fetch';\nimport { transformCreated } from '~/lib/transform';\nimport type { ApiResponse } from '~/lib/api';\n\nimport { assignPermission } from '~/helpers/permissions/decorator';\n\nimport type { Task } from '~/modules/tasks/types';\n\nimport type {\n ReportFiles,\n RawReportPeriod,\n ReportPeriod,\n ReportDetails,\n RawReportDetails,\n ReportResult,\n RawReportResult,\n} from './types';\n\ntype ReportMap = Record<string, ReportFiles>;\n\nexport const transformPeriod = (period: RawReportPeriod): ReportPeriod => ({\n start: parseISO(period.start),\n end: parseISO(period.end),\n});\n\nexport const transformReportDetails = (detail: RawReportDetails): ReportDetails => ({\n ...transformCreated(detail),\n destroyAt: parseISO(detail.destroyAt),\n period: detail.period ? transformPeriod(detail.period) : undefined,\n});\n\nexport const transformReportResult = (report: RawReportResult): ReportResult => ({\n ...report,\n detail: transformReportDetails(report.detail),\n});\n\n/**\n * Get all available reports\n *\n * @returns Object with keys being task IDs, values being report IDs\n */\nexport async function getAllReports(): Promise<Record<string, ReportMap>> {\n const {\n content,\n } = await client.fetch<ApiResponse<Record<string, ReportMap>>>(\n '/reports',\n );\n\n return content;\n}\nassignPermission(getAllReports, 'GET /reports');\n\n/**\n * Get all available reports of a task\n *\n * @param taskOrId Task or Task's id\n *\n * @returns Object with keys being report IDs, values being files\n */\nexport async function getReportsOfTask(taskOrId: Omit<Task, 'template'> | string): Promise<ReportMap> {\n const id = typeof taskOrId === 'string' ? taskOrId : taskOrId.id;\n if (!id) {\n throw new Error('Task id is required');\n }\n\n const {\n content,\n } = await client.fetch<ApiResponse<ReportMap>>(\n `/reports/${id}`,\n );\n\n return content;\n}\nassignPermission(getReportsOfTask, 'GET /reports/:taskId', true);\n\n/**\n * Get a report file as a blob\n *\n * @param taskOrId Task or Task's id\n * @param path Path to the file\n *\n * @returns The blob\n */\nexport async function getFileAsBlob(taskOrId: Omit<Task, 'template'> | string, path: string) {\n const id = typeof taskOrId === 'string' ? taskOrId : taskOrId.id;\n if (!id) {\n throw new Error('Task id is required');\n }\n\n return client.fetch(`/reports/${id}/${path}`, {\n responseType: 'blob',\n });\n}\nassignPermission(getFileAsBlob, 'GET /reports/:taskId/:year/:yearMonth/:reportId.:type.:ext', true);\n\n/**\n * Get a report file as an array buffer\n *\n * @param taskOrId Task or Task's id\n * @param path Path to the file\n *\n * @returns The array buffer\n */\nexport async function getFileAsArrayBuffer(taskOrId: Omit<Task, 'template'> | string, path: string) {\n const id = typeof taskOrId === 'string' ? taskOrId : taskOrId.id;\n if (!id) {\n throw new Error('Task id is required');\n }\n\n return client.fetch(`/reports/${id}/${path}`, {\n responseType: 'arrayBuffer',\n });\n}\nassignPermission(getFileAsArrayBuffer, 'GET /reports/:taskId/:year/:yearMonth/:reportId.:type.:ext', true);\n\n/**\n * Get a report file as a stream\n *\n * @param taskOrId Task or Task's id\n * @param path Path to the file\n *\n * @returns The stream\n */\nexport async function getFileAsStream(taskOrId: Omit<Task, 'template'> | string, path: string) {\n const id = typeof taskOrId === 'string' ? taskOrId : taskOrId.id;\n if (!id) {\n throw new Error('Task id is required');\n }\n\n return client.fetch(`/reports/${id}/${path}`, {\n responseType: 'stream',\n });\n}\nassignPermission(getFileAsStream, 'GET /reports/:taskId/:year/:yearMonth/:reportId.:type.:ext', true);\n\n/**\n * Get a report file as a text\n *\n * @param taskOrId Task or Task's id\n * @param path Path to the file\n *\n * @returns The text\n */\nexport async function getFileAsText(taskOrId: Omit<Task, 'template'> | string, path: string) {\n const id = typeof taskOrId === 'string' ? taskOrId : taskOrId.id;\n if (!id) {\n throw new Error('Task id is required');\n }\n\n return client.fetch(`/reports/${id}/${path}`, {\n responseType: 'text',\n });\n}\nassignPermission(getFileAsText, 'GET /reports/:taskId/:year/:yearMonth/:reportId.:type.:ext', true);\n\n/**\n * Get a report file as a JSON object\n * The file should end with `.det.json`\n *\n * @param taskOrId Task or Task's id\n * @param path Path to the file\n *\n * @returns The JSON object\n */\nexport async function getFileAsJson(taskOrId: Omit<Task, 'template'> | string, path: `${string}.det.json`) {\n const id = typeof taskOrId === 'string' ? taskOrId : taskOrId.id;\n if (!id) {\n throw new Error('Task id is required');\n }\n\n return client.fetch<ReportResult>(`/reports/${id}/${path}`);\n}\nassignPermission(getFileAsJson, 'GET /reports/:taskId/:year/:yearMonth/:reportId.:type.:ext', true);\n\n/**\n * Start a report generation\n *\n * @param taskOrId Task or Task's id\n * @param targets Override targets, also enable first level of debugging\n * @param period Override period, must match task's recurrence\n *\n * @returns Data to get job, and so the progress of the generation\n */\nexport async function generateReportOfTask(\n taskOrId: Omit<Task, 'template'> | string,\n period?: { start: Date, end: Date },\n targets?: string[],\n) {\n const id = typeof taskOrId === 'string' ? taskOrId : taskOrId.id;\n if (!id) {\n throw new Error('Task id is required');\n }\n\n let periodDate;\n if (period) {\n periodDate = {\n start: formatISO(period.start, { representation: 'date' }),\n end: formatISO(period.end, { representation: 'date' }),\n };\n }\n\n const {\n content,\n } = await client.fetch<ApiResponse<{ queue: string, id: string }>>(\n `/reports/${id}`,\n {\n method: 'POST',\n body: {\n period: periodDate,\n targets,\n },\n },\n );\n\n return {\n queue: content.queue,\n jobId: content.id,\n };\n}\nassignPermission(generateReportOfTask, 'POST /reports/:taskId', true);\n"],"names":["transformPeriod","period","parseISO","transformReportDetails","detail","__spreadProps","__spreadValues","transformCreated","transformReportResult","report","getAllReports","__async","content","client","assignPermission","getReportsOfTask","taskOrId","id","getFileAsBlob","path","getFileAsArrayBuffer","getFileAsStream","getFileAsText","getFileAsJson","generateReportOfTask","targets","periodDate","formatISO"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBa,MAAAA,IAAkB,CAACC,OAA2C;AAAA,EACzE,OAAOC,EAASD,EAAO,KAAK;AAAA,EAC5B,KAAKC,EAASD,EAAO,GAAG;AAC1B,IAEaE,IAAyB,CAACC,MAA6CC,E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AAA;AAAA,MACX,OAAOC,EAAU1B,EAAO,OAAO,EAAE,gBAAgB,QAAQ;AAAA,MACzD,KAAK0B,EAAU1B,EAAO,KAAK,EAAE,gBAAgB,OAAQ,CAAA;AAAA,IACvD;AAGI,UAAA;AAAA,MACJ,SAAAW;AAAA,IAAA,IACE,MAAMC,EAAO;AAAA,MACf,YAAYI,CAAE;AAAA,MACd;AAAA,QACE,QAAQ;AAAA,QACR,MAAM;AAAA,UACJ,QAAQS;AAAA,UACR,SAAAD;AAAA,QAAA;AAAA,MACF;AAAA,IAEJ;AAEO,WAAA;AAAA,MACL,OAAOb,EAAQ;AAAA,MACf,OAAOA,EAAQ;AAAA,IACjB;AAAA,EACF;AAAA;AACAE,EAAiBU,GAAsB,yBAAyB,EAAI;"}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
var P = Object.defineProperty, Q = Object.defineProperties;
|
|
2
|
-
var l = Object.getOwnPropertyDescriptors;
|
|
3
|
-
var r = Object.getOwnPropertySymbols;
|
|
4
|
-
var T = Object.prototype.hasOwnProperty, b = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var q = (t, e, n) => e in t ? P(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, h = (t, e) => {
|
|
6
|
-
for (var n in e || (e = {}))
|
|
7
|
-
T.call(e, n) && q(t, n, e[n]);
|
|
8
|
-
if (r)
|
|
9
|
-
for (var n of r(e))
|
|
10
|
-
b.call(e, n) && q(t, n, e[n]);
|
|
11
|
-
return t;
|
|
12
|
-
}, $ = (t, e) => Q(t, l(e));
|
|
13
|
-
var w = (t, e) => {
|
|
14
|
-
var n = {};
|
|
15
|
-
for (var s in t)
|
|
16
|
-
T.call(t, s) && e.indexOf(s) < 0 && (n[s] = t[s]);
|
|
17
|
-
if (t != null && r)
|
|
18
|
-
for (var s of r(t))
|
|
19
|
-
e.indexOf(s) < 0 && b.call(t, s) && (n[s] = t[s]);
|
|
20
|
-
return n;
|
|
21
|
-
};
|
|
22
|
-
var u = (t, e, n) => new Promise((s, o) => {
|
|
23
|
-
var d = (a) => {
|
|
24
|
-
try {
|
|
25
|
-
m(n.next(a));
|
|
26
|
-
} catch (p) {
|
|
27
|
-
o(p);
|
|
28
|
-
}
|
|
29
|
-
}, f = (a) => {
|
|
30
|
-
try {
|
|
31
|
-
m(n.throw(a));
|
|
32
|
-
} catch (p) {
|
|
33
|
-
o(p);
|
|
34
|
-
}
|
|
35
|
-
}, m = (a) => a.done ? s(a.value) : Promise.resolve(a.value).then(d, f);
|
|
36
|
-
m((n = n.apply(t, e)).next());
|
|
37
|
-
});
|
|
38
|
-
import { parseISO as y } from "date-fns";
|
|
39
|
-
import { c } from "./fetch-xZFTa3q1.mjs";
|
|
40
|
-
import { a as E } from "./api-D8l8Ds3U.mjs";
|
|
41
|
-
import { a as i } from "./decorator-DBkj--6g.mjs";
|
|
42
|
-
const g = (t) => $(h({}, t), {
|
|
43
|
-
added: y(t.added),
|
|
44
|
-
started: t.started ? y(t.started) : void 0,
|
|
45
|
-
ended: t.ended ? y(t.ended) : void 0
|
|
46
|
-
});
|
|
47
|
-
function G() {
|
|
48
|
-
return u(this, null, function* () {
|
|
49
|
-
const {
|
|
50
|
-
content: t
|
|
51
|
-
} = yield c.fetch("/queues");
|
|
52
|
-
return t;
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
i(G, "GET /queues");
|
|
56
|
-
function J(t) {
|
|
57
|
-
return u(this, null, function* () {
|
|
58
|
-
const e = typeof t == "string" ? t : t.name, {
|
|
59
|
-
content: n
|
|
60
|
-
} = yield c.fetch(`/queues/${e}`);
|
|
61
|
-
return n;
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
i(J, "GET /queues/:name");
|
|
65
|
-
function A(t) {
|
|
66
|
-
return u(this, null, function* () {
|
|
67
|
-
const o = t, { name: e } = o, n = w(o, ["name"]), {
|
|
68
|
-
content: s
|
|
69
|
-
} = yield c.fetch(`/queues/${e}`, {
|
|
70
|
-
method: "PATCH",
|
|
71
|
-
body: n
|
|
72
|
-
});
|
|
73
|
-
return s;
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
i(A, "PATCH /queues/:name");
|
|
77
|
-
function S(t, e) {
|
|
78
|
-
return u(this, null, function* () {
|
|
79
|
-
const n = typeof t == "string" ? t : t.name, {
|
|
80
|
-
content: s,
|
|
81
|
-
meta: {
|
|
82
|
-
total: o,
|
|
83
|
-
count: d,
|
|
84
|
-
page: f
|
|
85
|
-
}
|
|
86
|
-
} = yield c.fetch(
|
|
87
|
-
`/queues/${n}/jobs`,
|
|
88
|
-
{ query: E(e) }
|
|
89
|
-
);
|
|
90
|
-
return {
|
|
91
|
-
items: s.map(g),
|
|
92
|
-
total: o,
|
|
93
|
-
count: d,
|
|
94
|
-
page: f
|
|
95
|
-
};
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
i(S, "GET /queues/:name/jobs");
|
|
99
|
-
function v(t, e) {
|
|
100
|
-
return u(this, null, function* () {
|
|
101
|
-
const n = typeof t == "string" ? t : t.name, s = typeof e == "string" ? e : e.id, {
|
|
102
|
-
content: o
|
|
103
|
-
} = yield c.fetch(`/queues/${n}/jobs/${s}`);
|
|
104
|
-
return g(o);
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
i(v, "GET /queues/:name/jobs/:jobId", !0);
|
|
108
|
-
function C(t, e) {
|
|
109
|
-
return u(this, null, function* () {
|
|
110
|
-
const n = typeof t == "string" ? t : t.name, s = typeof e == "string" || typeof e == "number" ? e : e.id, { content: o } = yield c.fetch(
|
|
111
|
-
`/queues/${n}/jobs/${s}`,
|
|
112
|
-
{ method: "POST", body: {} }
|
|
113
|
-
);
|
|
114
|
-
return g(o);
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
i(C, "POST /queues/:name/jobs/:jobId", !0);
|
|
118
|
-
export {
|
|
119
|
-
J as a,
|
|
120
|
-
v as b,
|
|
121
|
-
S as c,
|
|
122
|
-
G as g,
|
|
123
|
-
C as r,
|
|
124
|
-
A as u
|
|
125
|
-
};
|
|
126
|
-
//# sourceMappingURL=methods-BJfwYB1p.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"methods-BJfwYB1p.mjs","sources":["../src/modules/queues/methods.ts"],"sourcesContent":["import { parseISO } from 'date-fns';\n\nimport { client } from '~/lib/fetch';\nimport {\n apiRequestOptionsToQuery,\n type ApiResponse,\n type ApiRequestOptions,\n type ApiResponsePaginated,\n type SdkPaginated,\n} from '~/lib/api';\n\nimport { assignPermission } from '~/helpers/permissions/decorator';\n\nimport type {\n RawJob,\n Job,\n Queue,\n InputQueue,\n} from './types';\n\nconst transformJob = <D = {}, R = {}>(job: RawJob<D, R>): Job<D, R> => ({\n ...job,\n added: parseISO(job.added),\n started: job.started ? parseISO(job.started) : undefined,\n ended: job.ended ? parseISO(job.ended) : undefined,\n});\n\n/**\n * Get all available queues\n *\n * @returns All queues' info\n */\nexport async function getAllQueues(): Promise<Queue[]> {\n const {\n content,\n } = await client.fetch<ApiResponse<Queue[]>>('/queues');\n\n return content;\n}\nassignPermission(getAllQueues, 'GET /queues');\n\n/**\n * Get specific queue\n *\n * @param queueOrName Queue or queue's name\n *\n * @returns queue info\n */\nexport async function getQueue(queueOrName: Queue | string): Promise<Queue> {\n const queueName = typeof queueOrName === 'string' ? queueOrName : queueOrName.name;\n\n const {\n content,\n } = await client.fetch<ApiResponse<Queue>>(`/queues/${queueName}`);\n\n return content;\n}\nassignPermission(getQueue, 'GET /queues/:name');\n\n/**\n * Update specific queue\n *\n * @param queueOrName Queue or queue's name\n *\n * @returns queue info\n */\nexport async function updateQueue(queue: Partial<InputQueue> & { name: string }): Promise<Queue> {\n const { name, ...data } = queue;\n\n const {\n content,\n } = await client.fetch<ApiResponse<Queue>>(`/queues/${name}`, {\n method: 'PATCH',\n body: data,\n });\n\n return content;\n}\nassignPermission(updateQueue, 'PATCH /queues/:name');\n\nexport type PaginatedJobs<D = {}, R = {}> = SdkPaginated<Job<D, R>>;\n\n/**\n * Get jobs of a queue\n *\n * @param queueOrName Queue or queue's name\n *\n * @returns jobs in queue\n */\nexport async function getQueueJobs<D = {}, R = {}>(\n queueOrName: Queue | string,\n opts?: ApiRequestOptions,\n): Promise<PaginatedJobs<D, R>> {\n const queueName = typeof queueOrName === 'string' ? queueOrName : queueOrName.name;\n\n const {\n content,\n meta: {\n total, count, page,\n },\n } = await client.fetch<ApiResponsePaginated<RawJob<D, R>>>(\n `/queues/${queueName}/jobs`,\n { query: apiRequestOptionsToQuery(opts) },\n );\n\n return {\n items: content.map(transformJob),\n total,\n count,\n page,\n };\n}\nassignPermission(getQueueJobs, 'GET /queues/:name/jobs');\n\n/**\n * Get specific job\n *\n * @param queueOrName Queue or queue's name\n * @param jobOrId Job or job's id in queue\n *\n * @returns Job full info\n */\nexport async function getJob<D = {}, R = {}>(\n queueOrName: Queue | string,\n jobOrId: Job<D, R> | string,\n): Promise<Job<D, R>> {\n const queueName = typeof queueOrName === 'string' ? queueOrName : queueOrName.name;\n const jobId = typeof jobOrId === 'string' ? jobOrId : jobOrId.id;\n\n const {\n content,\n } = await client.fetch<ApiResponse<RawJob<D, R>>>(`/queues/${queueName}/jobs/${jobId}`);\n\n return transformJob(content);\n}\nassignPermission(getJob, 'GET /queues/:name/jobs/:jobId', true);\n\n/**\n * Retry job that failed\n *\n * @param queueOrName Queue or queue's name\n * @param jobOrId Job or job's id in queue\n *\n * @returns queue info\n */\nexport async function retryJob<D = {}, R = {}>(\n queueOrName: Queue | string,\n jobOrId: Job<D, R> | string,\n): Promise<Job<D, R>> {\n const queueName = typeof queueOrName === 'string' ? queueOrName : queueOrName.name;\n const jobId = typeof jobOrId === 'string' || typeof jobOrId === 'number' ? jobOrId : jobOrId.id;\n\n const { content } = await client.fetch<ApiResponse<RawJob<D, R>>>(\n `/queues/${queueName}/jobs/${jobId}`,\n { method: 'POST', body: {} },\n );\n\n return transformJob(content);\n}\nassignPermission(retryJob, 'POST /queues/:name/jobs/:jobId', true);\n"],"names":["transformJob","job","__spreadProps","__spreadValues","parseISO","getAllQueues","__async","content","client","assignPermission","getQueue","queueOrName","queueName","updateQueue","queue","_a","name","data","__objRest","getQueueJobs","opts","total","count","page","apiRequestOptionsToQuery","getJob","jobOrId","jobId","retryJob"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAMA,IAAe,CAAiBC,MAAkCC,EAAAC,EAAA,IACnEF,IADmE;AAAA,EAEtE,OAAOG,EAASH,EAAI,KAAK;AAAA,EACzB,SAASA,EAAI,UAAUG,EAASH,EAAI,OAAO,IAAI;AAAA,EAC/C,OAAOA,EAAI,QAAQG,EAASH,EAAI,KAAK,IAAI;AAC3C;AAOA,SAAsBI,IAAiC;AAAA,SAAAC,EAAA;AAC/C,UAAA;AAAA,MACJ,SAAAC;AAAA,IAAA,IACE,MAAMC,EAAO,MAA4B,SAAS;AAE/C,WAAAD;AAAA,EACT;AAAA;AACAE,EAAiBJ,GAAc,aAAa;AAS5C,SAAsBK,EAASC,GAA6C;AAAA,SAAAL,EAAA;AAC1E,UAAMM,IAAY,OAAOD,KAAgB,WAAWA,IAAcA,EAAY,MAExE;AAAA,MACJ,SAAAJ;AAAA,IAAA,IACE,MAAMC,EAAO,MAA0B,WAAWI,CAAS,EAAE;AAE1D,WAAAL;AAAA,EACT;AAAA;AACAE,EAAiBC,GAAU,mBAAmB;AAS9C,SAAsBG,EAAYC,GAA+D;AAAA,SAAAR,EAAA;AAC/F,UAA0BS,IAAAD,GAAlB,QAAAE,MAAkBD,GAATE,IAAAC,EAASH,GAAT,CAAT,UAEF;AAAA,MACJ,SAAAR;AAAA,IAAA,IACE,MAAMC,EAAO,MAA0B,WAAWQ,CAAI,IAAI;AAAA,MAC5D,QAAQ;AAAA,MACR,MAAMC;AAAA,IAAA,CACP;AAEM,WAAAV;AAAA,EACT;AAAA;AACAE,EAAiBI,GAAa,qBAAqB;AAW7B,SAAAM,EACpBR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
|
package/dist/methods-CMrpqFJZ.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var S=Object.defineProperty,x=Object.defineProperties;var G=Object.getOwnPropertyDescriptors;var l=Object.getOwnPropertySymbols;var b=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var T=(e,t,r)=>t in e?S(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,y=(e,t)=>{for(var r in t||(t={}))b.call(t,r)&&T(e,r,t[r]);if(l)for(var r of l(t))B.call(t,r)&&T(e,r,t[r]);return e},g=(e,t)=>x(e,G(t));var s=(e,t,r)=>new Promise((c,a)=>{var f=i=>{try{d(r.next(i))}catch(u){a(u)}},R=i=>{try{d(r.throw(i))}catch(u){a(u)}},d=i=>i.done?c(i.value):Promise.resolve(i.value).then(f,R);d((r=r.apply(e,t)).next())});const p=require("date-fns"),o=require("./fetch-Hd-ajPIl.js"),M=require("./transform-DzLAfSJo.js"),n=require("./decorator-C2gcn2rK.js"),h=e=>({start:p.parseISO(e.start),end:p.parseISO(e.end)}),k=e=>g(y({},M.transformCreated(e)),{destroyAt:p.parseISO(e.destroyAt),period:e.period?h(e.period):void 0}),I=e=>g(y({},e),{detail:k(e.detail)});function m(){return s(this,null,function*(){const{content:e}=yield o.client.fetch("/reports");return e})}n.assignPermission(m,"GET /reports");function w(e){return s(this,null,function*(){const t=typeof e=="string"?e:e.id;if(!t)throw new Error("Task id is required");const{content:r}=yield o.client.fetch(`/reports/${t}`);return r})}n.assignPermission(w,"GET /reports/:taskId",!0);function A(e,t){return s(this,null,function*(){const r=typeof e=="string"?e:e.id;if(!r)throw new Error("Task id is required");return o.client.fetch(`/reports/${r}/${t}`,{responseType:"blob"})})}n.assignPermission(A,"GET /reports/:taskId/:year/:yearMonth/:reportId.:type.:ext",!0);function E(e,t){return s(this,null,function*(){const r=typeof e=="string"?e:e.id;if(!r)throw new Error("Task id is required");return o.client.fetch(`/reports/${r}/${t}`,{responseType:"arrayBuffer"})})}n.assignPermission(E,"GET /reports/:taskId/:year/:yearMonth/:reportId.:type.:ext",!0);function q(e,t){return s(this,null,function*(){const r=typeof e=="string"?e:e.id;if(!r)throw new Error("Task id is required");return o.client.fetch(`/reports/${r}/${t}`,{responseType:"stream"})})}n.assignPermission(q,"GET /reports/:taskId/:year/:yearMonth/:reportId.:type.:ext",!0);function P(e,t){return s(this,null,function*(){const r=typeof e=="string"?e:e.id;if(!r)throw new Error("Task id is required");return o.client.fetch(`/reports/${r}/${t}`,{responseType:"text"})})}n.assignPermission(P,"GET /reports/:taskId/:year/:yearMonth/:reportId.:type.:ext",!0);function $(e,t){return s(this,null,function*(){const r=typeof e=="string"?e:e.id;if(!r)throw new Error("Task id is required");return o.client.fetch(`/reports/${r}/${t}`)})}n.assignPermission($,"GET /reports/:taskId/:year/:yearMonth/:reportId.:type.:ext",!0);function F(e,t,r){return s(this,null,function*(){const c=typeof e=="string"?e:e.id;if(!c)throw new Error("Task id is required");let a;t&&(a={start:p.formatISO(t.start,{representation:"date"}),end:p.formatISO(t.end,{representation:"date"})});const{content:f}=yield o.client.fetch(`/reports/${c}`,{method:"POST",body:{period:a,targets:r}});return{queue:f.queue,jobId:f.id}})}n.assignPermission(F,"POST /reports/:taskId",!0);exports.generateReportOfTask=F;exports.getAllReports=m;exports.getFileAsArrayBuffer=E;exports.getFileAsBlob=A;exports.getFileAsJson=$;exports.getFileAsStream=q;exports.getFileAsText=P;exports.getReportsOfTask=w;exports.transformPeriod=h;exports.transformReportResult=I;
|
|
2
|
-
//# sourceMappingURL=methods-CMrpqFJZ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"methods-CMrpqFJZ.js","sources":["../src/modules/reports/methods.ts"],"sourcesContent":["import { formatISO, parseISO } from 'date-fns';\n\nimport { client } from '~/lib/fetch';\nimport { transformCreated } from '~/lib/transform';\nimport type { ApiResponse } from '~/lib/api';\n\nimport { assignPermission } from '~/helpers/permissions/decorator';\n\nimport type { Task } from '~/modules/tasks/types';\n\nimport type {\n ReportFiles,\n RawReportPeriod,\n ReportPeriod,\n ReportDetails,\n RawReportDetails,\n ReportResult,\n RawReportResult,\n} from './types';\n\ntype ReportMap = Record<string, ReportFiles>;\n\nexport const transformPeriod = (period: RawReportPeriod): ReportPeriod => ({\n start: parseISO(period.start),\n end: parseISO(period.end),\n});\n\nexport const transformReportDetails = (detail: RawReportDetails): ReportDetails => ({\n ...transformCreated(detail),\n destroyAt: parseISO(detail.destroyAt),\n period: detail.period ? transformPeriod(detail.period) : undefined,\n});\n\nexport const transformReportResult = (report: RawReportResult): ReportResult => ({\n ...report,\n detail: transformReportDetails(report.detail),\n});\n\n/**\n * Get all available reports\n *\n * @returns Object with keys being task IDs, values being report IDs\n */\nexport async function getAllReports(): Promise<Record<string, ReportMap>> {\n const {\n content,\n } = await client.fetch<ApiResponse<Record<string, ReportMap>>>(\n '/reports',\n );\n\n return content;\n}\nassignPermission(getAllReports, 'GET /reports');\n\n/**\n * Get all available reports of a task\n *\n * @param taskOrId Task or Task's id\n *\n * @returns Object with keys being report IDs, values being files\n */\nexport async function getReportsOfTask(taskOrId: Omit<Task, 'template'> | string): Promise<ReportMap> {\n const id = typeof taskOrId === 'string' ? taskOrId : taskOrId.id;\n if (!id) {\n throw new Error('Task id is required');\n }\n\n const {\n content,\n } = await client.fetch<ApiResponse<ReportMap>>(\n `/reports/${id}`,\n );\n\n return content;\n}\nassignPermission(getReportsOfTask, 'GET /reports/:taskId', true);\n\n/**\n * Get a report file as a blob\n *\n * @param taskOrId Task or Task's id\n * @param path Path to the file\n *\n * @returns The blob\n */\nexport async function getFileAsBlob(taskOrId: Omit<Task, 'template'> | string, path: string) {\n const id = typeof taskOrId === 'string' ? taskOrId : taskOrId.id;\n if (!id) {\n throw new Error('Task id is required');\n }\n\n return client.fetch(`/reports/${id}/${path}`, {\n responseType: 'blob',\n });\n}\nassignPermission(getFileAsBlob, 'GET /reports/:taskId/:year/:yearMonth/:reportId.:type.:ext', true);\n\n/**\n * Get a report file as an array buffer\n *\n * @param taskOrId Task or Task's id\n * @param path Path to the file\n *\n * @returns The array buffer\n */\nexport async function getFileAsArrayBuffer(taskOrId: Omit<Task, 'template'> | string, path: string) {\n const id = typeof taskOrId === 'string' ? taskOrId : taskOrId.id;\n if (!id) {\n throw new Error('Task id is required');\n }\n\n return client.fetch(`/reports/${id}/${path}`, {\n responseType: 'arrayBuffer',\n });\n}\nassignPermission(getFileAsArrayBuffer, 'GET /reports/:taskId/:year/:yearMonth/:reportId.:type.:ext', true);\n\n/**\n * Get a report file as a stream\n *\n * @param taskOrId Task or Task's id\n * @param path Path to the file\n *\n * @returns The stream\n */\nexport async function getFileAsStream(taskOrId: Omit<Task, 'template'> | string, path: string) {\n const id = typeof taskOrId === 'string' ? taskOrId : taskOrId.id;\n if (!id) {\n throw new Error('Task id is required');\n }\n\n return client.fetch(`/reports/${id}/${path}`, {\n responseType: 'stream',\n });\n}\nassignPermission(getFileAsStream, 'GET /reports/:taskId/:year/:yearMonth/:reportId.:type.:ext', true);\n\n/**\n * Get a report file as a text\n *\n * @param taskOrId Task or Task's id\n * @param path Path to the file\n *\n * @returns The text\n */\nexport async function getFileAsText(taskOrId: Omit<Task, 'template'> | string, path: string) {\n const id = typeof taskOrId === 'string' ? taskOrId : taskOrId.id;\n if (!id) {\n throw new Error('Task id is required');\n }\n\n return client.fetch(`/reports/${id}/${path}`, {\n responseType: 'text',\n });\n}\nassignPermission(getFileAsText, 'GET /reports/:taskId/:year/:yearMonth/:reportId.:type.:ext', true);\n\n/**\n * Get a report file as a JSON object\n * The file should end with `.det.json`\n *\n * @param taskOrId Task or Task's id\n * @param path Path to the file\n *\n * @returns The JSON object\n */\nexport async function getFileAsJson(taskOrId: Omit<Task, 'template'> | string, path: `${string}.det.json`) {\n const id = typeof taskOrId === 'string' ? taskOrId : taskOrId.id;\n if (!id) {\n throw new Error('Task id is required');\n }\n\n return client.fetch<ReportResult>(`/reports/${id}/${path}`);\n}\nassignPermission(getFileAsJson, 'GET /reports/:taskId/:year/:yearMonth/:reportId.:type.:ext', true);\n\n/**\n * Start a report generation\n *\n * @param taskOrId Task or Task's id\n * @param targets Override targets, also enable first level of debugging\n * @param period Override period, must match task's recurrence\n *\n * @returns Data to get job, and so the progress of the generation\n */\nexport async function generateReportOfTask(\n taskOrId: Omit<Task, 'template'> | string,\n period?: { start: Date, end: Date },\n targets?: string[],\n) {\n const id = typeof taskOrId === 'string' ? taskOrId : taskOrId.id;\n if (!id) {\n throw new Error('Task id is required');\n }\n\n let periodDate;\n if (period) {\n periodDate = {\n start: formatISO(period.start, { representation: 'date' }),\n end: formatISO(period.end, { representation: 'date' }),\n };\n }\n\n const {\n content,\n } = await client.fetch<ApiResponse<{ queue: string, id: string }>>(\n `/reports/${id}`,\n {\n method: 'POST',\n body: {\n period: periodDate,\n targets,\n },\n },\n );\n\n return {\n queue: content.queue,\n jobId: content.id,\n };\n}\nassignPermission(generateReportOfTask, 'POST /reports/:taskId', true);\n"],"names":["transformPeriod","period","parseISO","transformReportDetails","detail","__spreadProps","__spreadValues","transformCreated","transformReportResult","report","getAllReports","__async","content","client","assignPermission","getReportsOfTask","taskOrId","id","getFileAsBlob","path","getFileAsArrayBuffer","getFileAsStream","getFileAsText","getFileAsJson","generateReportOfTask","targets","periodDate","formatISO"],"mappings":"8wBAsBaA,EAAmBC,IAA2C,CACzE,MAAOC,EAAAA,SAASD,EAAO,KAAK,EAC5B,IAAKC,EAAAA,SAASD,EAAO,GAAG,CAC1B,GAEaE,EAA0BC,GAA6CC,EAAAC,EAAA,GAC/EC,EAAAA,iBAAiBH,CAAM,GADwD,CAElF,UAAWF,EAAAA,SAASE,EAAO,SAAS,EACpC,OAAQA,EAAO,OAASJ,EAAgBI,EAAO,MAAM,EAAI,MAC3D,GAEaI,EAAyBC,GAA2CJ,EAAAC,EAAA,GAC5EG,GAD4E,CAE/E,OAAQN,EAAuBM,EAAO,MAAM,CAC9C,GAOA,SAAsBC,GAAoD,QAAAC,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ods-DC2Gjy1i.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var U=Object.defineProperty,$=Object.defineProperties;var F=Object.getOwnPropertyDescriptors;var d=Object.getOwnPropertySymbols;var E=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable;var l=(e,t,s)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,T=(e,t)=>{for(var s in t||(t={}))E.call(t,s)&&l(e,s,t[s]);if(d)for(var s of d(t))p.call(t,s)&&l(e,s,t[s]);return e},k=(e,t)=>$(e,F(t));var g=(e,t)=>{var s={};for(var n in e)E.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(e!=null&&d)for(var n of d(e))t.indexOf(n)<0&&p.call(e,n)&&(s[n]=e[n]);return s};var i=(e,t,s)=>new Promise((n,r)=>{var L=a=>{try{m(s.next(a))}catch(f){r(f)}},S=a=>{try{m(s.throw(a))}catch(f){r(f)}},m=a=>a.done?n(a.value):Promise.resolve(a.value).then(L,S);m((s=s.apply(e,t)).next())});const y=require("date-fns"),c=require("./fetch-Hd-ajPIl.js"),h=require("./transform-DzLAfSJo.js"),b=require("./api-DVzOqMA2.js"),o=require("./decorator-C2gcn2rK.js"),A=e=>T({},h.transformCreatedUpdated(e)),u=e=>k(T({},h.transformCreatedUpdated(e)),{nextRun:y.parseISO(e.nextRun),lastRun:e.lastRun?y.parseISO(e.lastRun):void 0,namespace:e.namespace&&A(e.namespace)});function q(e){return i(this,null,function*(){const{content:t,meta:{total:s,count:n,page:r}}=yield c.client.fetch("/tasks",{query:k(T({},b.apiRequestOptionsToQuery(e)),{include:e==null?void 0:e.include})});return{items:t.map(u),total:s,count:n,page:r}})}o.assignPermission(q,"GET /tasks",!0);function w(e,t){return i(this,null,function*(){const s=typeof e=="string"?e:e.id;if(!s)throw new Error("Task id is required");const{content:n}=yield c.client.fetch(`/tasks/${s}`,{query:{include:t}});return u(n)})}o.assignPermission(w,"GET /tasks/:id",!0);function P(e){return i(this,null,function*(){const{content:t}=yield c.client.fetch("/tasks",{method:"POST",body:e});return u(t)})}o.assignPermission(P,"POST /tasks",!0);function R(s){return i(this,null,function*(){var n=s,{id:e}=n,t=g(n,["id"]);const{content:r}=yield c.client.fetch(`/tasks/${e}`,{method:"PUT",body:t});return u(r)})}o.assignPermission(R,"PUT /tasks/:id",!0);function x(e){return i(this,null,function*(){const t=typeof e=="string"?e:e.id;if(!t)return!1;const{content:s}=yield c.client.fetch(`/tasks/${t}`,{method:"DELETE"});return s.deleted})}o.assignPermission(x,"DELETE /tasks/:id",!0);function D(e){return i(this,null,function*(){const t=typeof e=="string"?e:e.id;if(!t)throw new Error("Task id is required");const{content:s}=yield c.client.fetch(`/tasks/${t}/extends`,{method:"DELETE"});return u(s)})}o.assignPermission(D,"DELETE /tasks/:id/extends",!0);exports.createTask=P;exports.deleteTask=x;exports.getAllTasks=q;exports.getTask=w;exports.transformTask=u;exports.unlinkTaskFromTemplate=D;exports.upsertTask=R;
|
|
2
|
-
//# sourceMappingURL=methods-DC2Gjy1i.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"methods-DC2Gjy1i.js","sources":["../src/modules/namespaces/methods.ts","../src/modules/tasks/methods.ts"],"sourcesContent":["import { transformCreatedUpdated } from '~/lib/transform';\n\nimport type { Namespace, RawNamespace } from './types';\n\n// eslint-disable-next-line import/prefer-default-export\nexport const transformNamespace = (n: RawNamespace): Namespace => ({\n ...transformCreatedUpdated(n),\n});\n","import { parseISO } from 'date-fns';\n\nimport { client } from '~/lib/fetch';\nimport { transformCreatedUpdated } from '~/lib/transform';\nimport {\n apiRequestOptionsToQuery,\n type ApiResponse,\n type ApiResponsePaginated,\n type ApiRequestOptions,\n type ApiDeletedResponse,\n type SdkPaginated,\n} from '~/lib/api';\n\nimport { assignPermission } from '~/helpers/permissions/decorator';\n\nimport { transformNamespace } from '~/modules/namespaces/methods';\nimport type { RawNamespace } from '~/modules/namespaces/types';\n\nimport type { InputTask, RawTask, Task } from './types';\n\nexport const transformTask = (t: RawTask): Task => ({\n ...transformCreatedUpdated(t),\n nextRun: parseISO(t.nextRun),\n lastRun: t.lastRun ? parseISO(t.lastRun) : undefined,\n namespace: t.namespace && transformNamespace(t.namespace as RawNamespace),\n});\n\ntype PaginatedTasks = SdkPaginated<Omit<Task, 'template'>>;\n\n/**\n * Get all available tasks\n *\n * @returns All tasks' info\n */\nexport async function getAllTasks(\n opts?: ApiRequestOptions & { include?: string[] },\n): Promise<PaginatedTasks> {\n const {\n content,\n meta: {\n total, count, page,\n },\n } = await client.fetch<ApiResponsePaginated<Omit<RawTask, 'body'>>>(\n '/tasks',\n {\n query: {\n ...apiRequestOptionsToQuery(opts),\n include: opts?.include,\n },\n },\n );\n\n return {\n items: content.map(transformTask),\n total,\n count,\n page,\n };\n}\nassignPermission(getAllTasks, 'GET /tasks', true);\n\n/**\n * Get task info\n *\n * @param taskOrId Task or Task's id\n * @param include Fields to include\n *\n * @returns Task info\n */\nexport async function getTask(\n taskOrId: Omit<Task, 'template'> | string,\n include?: string[],\n): Promise<Task> {\n const id = typeof taskOrId === 'string' ? taskOrId : taskOrId.id;\n if (!id) {\n throw new Error('Task id is required');\n }\n\n const {\n content,\n } = await client.fetch<ApiResponse<RawTask>>(`/tasks/${id}`, {\n query: { include },\n });\n\n return transformTask(content);\n}\nassignPermission(getTask, 'GET /tasks/:id', true);\n\n/**\n * Create a new task\n *\n * @param task Task's data\n *\n * @returns Created task's info\n */\nexport async function createTask(\n task: InputTask,\n): Promise<Task> {\n const { content } = await client.fetch<ApiResponse<RawTask>>(\n '/tasks',\n {\n method: 'POST',\n body: task,\n },\n );\n\n return transformTask(content);\n}\nassignPermission(createTask, 'POST /tasks', true);\n\n/**\n * Update or create a task\n *\n * @param task Task's data **with id**\n *\n * @returns Updated/Created Task's info\n */\nexport async function upsertTask(\n { id, ...task }: InputTask & { id: Task['id'] },\n): Promise<Task> {\n const {\n content,\n } = await client.fetch<ApiResponse<RawTask>>(\n `/tasks/${id}`,\n {\n method: 'PUT',\n body: task,\n },\n );\n\n return transformTask(content);\n}\nassignPermission(upsertTask, 'PUT /tasks/:id', true);\n\n/**\n * Delete a task\n *\n * @param taskOrId Task or Task's id\n *\n * @returns Whether the task was deleted\n */\nexport async function deleteTask(\n taskOrId: Omit<Task, 'template'> | string,\n): Promise<boolean> {\n const id = typeof taskOrId === 'string' ? taskOrId : taskOrId.id;\n if (!id) {\n return false;\n }\n\n const {\n content,\n } = await client.fetch<ApiDeletedResponse>(\n `/tasks/${id}`,\n { method: 'DELETE' },\n );\n\n return content.deleted;\n}\nassignPermission(deleteTask, 'DELETE /tasks/:id', true);\n\n/**\n * Unlink a task from it's template\n *\n * @param taskOrId Task or Task's id\n *\n * @returns Updated task\n */\nexport async function unlinkTaskFromTemplate(\n taskOrId: Omit<Task, 'template'> | string,\n): Promise<Task> {\n const id = typeof taskOrId === 'string' ? taskOrId : taskOrId.id;\n if (!id) {\n throw new Error('Task id is required');\n }\n\n const {\n content,\n } = await client.fetch<ApiResponse<RawTask>>(\n `/tasks/${id}/extends`,\n { method: 'DELETE' },\n );\n\n return transformTask(content);\n}\nassignPermission(unlinkTaskFromTemplate, 'DELETE /tasks/:id/extends', true);\n"],"names":["transformNamespace","n","__spreadValues","transformCreatedUpdated","transformTask","t","__spreadProps","parseISO","getAllTasks","opts","__async","content","total","count","page","client","apiRequestOptionsToQuery","assignPermission","getTask","taskOrId","include","id","createTask","task","upsertTask","_a","_b","__objRest","deleteTask","unlinkTaskFromTemplate"],"mappings":"+8BAKaA,EAAsBC,GAAgCC,EAAA,GAC9DC,0BAAwBF,CAAC,GCcjBG,EAAiBC,GAAsBC,EAAAJ,EAAA,GAC/CC,EAAAA,wBAAwBE,CAAC,GADsB,CAElD,QAASE,EAAAA,SAASF,EAAE,OAAO,EAC3B,QAASA,EAAE,QAAUE,EAAAA,SAASF,EAAE,OAAO,EAAI,OAC3C,UAAWA,EAAE,WAAaL,EAAmBK,EA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