@ikatec/digisac-api-sdk 4.1.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -4
- package/dist/apis/authHistory/AuthHistoryApi.cjs +12 -12
- package/dist/apis/authHistory/AuthHistoryApi.cjs.map +1 -1
- package/dist/apis/authHistory/AuthHistoryApi.d.ts +12 -19
- package/dist/apis/authHistory/AuthHistoryApi.d.ts.map +1 -1
- package/dist/apis/authHistory/AuthHistoryApi.mjs +12 -12
- package/dist/apis/authHistory/AuthHistoryApi.mjs.map +1 -1
- package/dist/apis/authHistory/types.d.ts +4 -3
- package/dist/apis/authHistory/types.d.ts.map +1 -1
- package/dist/apis/customFields/types.d.ts +21 -19
- package/dist/apis/customFields/types.d.ts.map +1 -1
- package/dist/apis/dashboard/DashboardApi.cjs +19 -0
- package/dist/apis/dashboard/DashboardApi.cjs.map +1 -0
- package/dist/apis/dashboard/DashboardApi.d.ts +12 -0
- package/dist/apis/dashboard/DashboardApi.d.ts.map +1 -0
- package/dist/apis/dashboard/DashboardApi.mjs +18 -0
- package/dist/apis/dashboard/DashboardApi.mjs.map +1 -0
- package/dist/apis/dashboard/index.cjs +4 -0
- package/dist/apis/dashboard/index.d.ts +3 -0
- package/dist/apis/dashboard/index.d.ts.map +1 -0
- package/dist/apis/dashboard/index.mjs +3 -0
- package/dist/apis/dashboard/types.cjs +0 -0
- package/dist/apis/dashboard/types.d.ts +53 -0
- package/dist/apis/dashboard/types.d.ts.map +1 -0
- package/dist/apis/dashboard/types.mjs +0 -0
- package/dist/apis/holiday/types.d.ts +34 -8
- package/dist/apis/holiday/types.d.ts.map +1 -1
- package/dist/apis/index.cjs +6 -0
- package/dist/apis/index.d.ts +2 -0
- package/dist/apis/index.d.ts.map +1 -1
- package/dist/apis/index.mjs +5 -1
- package/dist/apis/now/NowApi.cjs +37 -0
- package/dist/apis/now/NowApi.cjs.map +1 -0
- package/dist/apis/now/NowApi.d.ts +26 -0
- package/dist/apis/now/NowApi.d.ts.map +1 -0
- package/dist/apis/now/NowApi.mjs +36 -0
- package/dist/apis/now/NowApi.mjs.map +1 -0
- package/dist/apis/now/index.cjs +4 -0
- package/dist/apis/now/index.d.ts +3 -0
- package/dist/apis/now/index.d.ts.map +1 -0
- package/dist/apis/now/index.mjs +3 -0
- package/dist/apis/now/types.cjs +0 -0
- package/dist/apis/now/types.d.ts +45 -0
- package/dist/apis/now/types.d.ts.map +1 -0
- package/dist/apis/now/types.mjs +0 -0
- package/dist/apis/people/types.d.ts +7 -2
- package/dist/apis/people/types.d.ts.map +1 -1
- package/dist/apis/permissions/PermissionsApi.cjs +6 -2
- package/dist/apis/permissions/PermissionsApi.cjs.map +1 -1
- package/dist/apis/permissions/PermissionsApi.d.ts +7 -3
- package/dist/apis/permissions/PermissionsApi.d.ts.map +1 -1
- package/dist/apis/permissions/PermissionsApi.mjs +6 -2
- package/dist/apis/permissions/PermissionsApi.mjs.map +1 -1
- package/dist/apis/permissions/types.d.ts +4 -14
- package/dist/apis/permissions/types.d.ts.map +1 -1
- package/dist/apis/personalAccessTokens/PersonalAccessTokensApi.cjs +5 -0
- package/dist/apis/personalAccessTokens/PersonalAccessTokensApi.cjs.map +1 -1
- package/dist/apis/personalAccessTokens/PersonalAccessTokensApi.d.ts +5 -0
- package/dist/apis/personalAccessTokens/PersonalAccessTokensApi.d.ts.map +1 -1
- package/dist/apis/personalAccessTokens/PersonalAccessTokensApi.mjs +5 -0
- package/dist/apis/personalAccessTokens/PersonalAccessTokensApi.mjs.map +1 -1
- package/dist/apis/personalAccessTokens/types.d.ts +23 -4
- package/dist/apis/personalAccessTokens/types.d.ts.map +1 -1
- package/dist/apis/roles/RolesApi.cjs.map +1 -1
- package/dist/apis/roles/RolesApi.d.ts +2 -2
- package/dist/apis/roles/RolesApi.d.ts.map +1 -1
- package/dist/apis/roles/RolesApi.mjs.map +1 -1
- package/dist/apis/roles/types.d.ts +27 -4
- package/dist/apis/roles/types.d.ts.map +1 -1
- package/dist/apis/terms/TermsApi.cjs +4 -1
- package/dist/apis/terms/TermsApi.cjs.map +1 -1
- package/dist/apis/terms/TermsApi.d.ts +4 -1
- package/dist/apis/terms/TermsApi.d.ts.map +1 -1
- package/dist/apis/terms/TermsApi.mjs +4 -1
- package/dist/apis/terms/TermsApi.mjs.map +1 -1
- package/dist/apis/timetable/types.d.ts +12 -7
- package/dist/apis/timetable/types.d.ts.map +1 -1
- package/dist/core/BaseCrudApi.cjs +3 -30
- package/dist/core/BaseCrudApi.cjs.map +1 -1
- package/dist/core/BaseCrudApi.d.ts +4 -24
- package/dist/core/BaseCrudApi.d.ts.map +1 -1
- package/dist/core/BaseCrudApi.mjs +3 -30
- package/dist/core/BaseCrudApi.mjs.map +1 -1
- package/dist/core/BaseReadApi.cjs +44 -0
- package/dist/core/BaseReadApi.cjs.map +1 -0
- package/dist/core/BaseReadApi.d.ts +32 -0
- package/dist/core/BaseReadApi.d.ts.map +1 -0
- package/dist/core/BaseReadApi.mjs +43 -0
- package/dist/core/BaseReadApi.mjs.map +1 -0
- package/dist/core/index.cjs +2 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.mjs +2 -1
- package/dist/index.cjs +2 -0
- package/dist/index.mjs +2 -1
- package/package.json +1 -1
- package/src/apis/authHistory/AuthHistoryApi.test.ts +10 -2
- package/src/apis/authHistory/AuthHistoryApi.ts +13 -39
- package/src/apis/authHistory/types.ts +4 -3
- package/src/apis/customFields/types.ts +21 -25
- package/src/apis/dashboard/DashboardApi.test.ts +82 -0
- package/src/apis/dashboard/DashboardApi.ts +18 -0
- package/src/apis/dashboard/index.ts +2 -0
- package/src/apis/dashboard/types.ts +53 -0
- package/src/apis/holiday/types.ts +36 -8
- package/src/apis/index.ts +2 -0
- package/src/apis/now/NowApi.test.ts +125 -0
- package/src/apis/now/NowApi.ts +59 -0
- package/src/apis/now/index.ts +2 -0
- package/src/apis/now/types.ts +47 -0
- package/src/apis/payloads.test-d.ts +39 -0
- package/src/apis/payloads.test.ts +81 -0
- package/src/apis/people/types.ts +7 -2
- package/src/apis/permissions/PermissionsApi.test.ts +93 -0
- package/src/apis/permissions/PermissionsApi.ts +7 -7
- package/src/apis/permissions/types.ts +4 -16
- package/src/apis/personalAccessTokens/PersonalAccessTokensApi.ts +5 -0
- package/src/apis/personalAccessTokens/types.ts +25 -4
- package/src/apis/queryFormat.test.ts +75 -0
- package/src/apis/roles/RolesApi.ts +7 -2
- package/src/apis/roles/types.ts +27 -4
- package/src/apis/terms/TermsApi.ts +4 -1
- package/src/apis/timetable/types.ts +13 -7
- package/src/core/BaseCrudApi.ts +4 -60
- package/src/core/BaseReadApi.ts +70 -0
- package/src/core/index.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TermsApi.d.ts","sourceRoot":"","sources":["../../../src/apis/terms/TermsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAEnC;;;;;;GAMG;AACH,qBAAa,QAAS,SAAQ,OAAQ,YAAW,UAAU,CAAC,IAAI,CAAC;IAC/D,SAAgB,QAAQ,YAAW;IAEnC
|
|
1
|
+
{"version":3,"file":"TermsApi.d.ts","sourceRoot":"","sources":["../../../src/apis/terms/TermsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAEnC;;;;;;GAMG;AACH,qBAAa,QAAS,SAAQ,OAAQ,YAAW,UAAU,CAAC,IAAI,CAAC;IAC/D,SAAgB,QAAQ,YAAW;IAEnC;;;OAGG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAKhG;;;OAGG;IACH,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAI/D;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;CAO7E"}
|
|
@@ -10,7 +10,10 @@ import { BaseApi } from "../../core/BaseApi.mjs";
|
|
|
10
10
|
*/
|
|
11
11
|
var TermsApi = class extends BaseApi {
|
|
12
12
|
basePath = "/terms";
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Returns a single term by its ID, scoped to the current account. When it does not exist the
|
|
15
|
+
* backend answers 200 with an empty body, which resolves to `undefined`.
|
|
16
|
+
*/
|
|
14
17
|
getById(id, query, headers) {
|
|
15
18
|
const queryString = this.toQueryString(query);
|
|
16
19
|
return this.client.get(`${this.basePath}/${id}${queryString}`, headers);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TermsApi.mjs","names":[],"sources":["../../../src/apis/terms/TermsApi.ts"],"sourcesContent":["import { BaseApi } from '../../core/BaseApi'\nimport type { GetByIdQuery, HasGetById } from '../../core/types'\nimport type { Term } from './types'\n\n/**\n * Platform terms of use. Terms are published by Agnus (billing) and accepted by the account users,\n * so the `/terms` route has no create/list/update/delete — only the routes below.\n *\n * `GET /terms/:id/export-pdf` is not exposed: it answers a binary PDF, and `ApiClient` only\n * handles JSON/text bodies.\n */\nexport class TermsApi extends BaseApi implements HasGetById<Term> {\n public readonly basePath = '/terms'\n\n
|
|
1
|
+
{"version":3,"file":"TermsApi.mjs","names":[],"sources":["../../../src/apis/terms/TermsApi.ts"],"sourcesContent":["import { BaseApi } from '../../core/BaseApi'\nimport type { GetByIdQuery, HasGetById } from '../../core/types'\nimport type { Term } from './types'\n\n/**\n * Platform terms of use. Terms are published by Agnus (billing) and accepted by the account users,\n * so the `/terms` route has no create/list/update/delete — only the routes below.\n *\n * `GET /terms/:id/export-pdf` is not exposed: it answers a binary PDF, and `ApiClient` only\n * handles JSON/text bodies.\n */\nexport class TermsApi extends BaseApi implements HasGetById<Term> {\n public readonly basePath = '/terms'\n\n /**\n * Returns a single term by its ID, scoped to the current account. When it does not exist the\n * backend answers 200 with an empty body, which resolves to `undefined`.\n */\n getById(id: string, query?: GetByIdQuery<Term>, headers?: Record<string, string>): Promise<Term> {\n const queryString = this.toQueryString(query)\n return this.client.get<Term>(`${this.basePath}/${id}${queryString}`, headers)\n }\n\n /**\n * Returns the terms of the current account that were not agreed to yet (`agreementDate` null).\n * The backend answers a plain array (not paginated) and ignores query parameters.\n */\n getNotAgreed(headers?: Record<string, string>): Promise<Term[]> {\n return this.client.get<Term[]>(`${this.basePath}/terms-not-agreed`, headers)\n }\n\n /**\n * Agrees to the given terms on behalf of the authenticated user. IRREVERSIBLE: the acceptance is\n * registered on Agnus, the terms get `agreementDate`/`userId`, and the signed PDFs are e-mailed\n * to the user. Only terms of the current account are affected.\n *\n * The response is passed through from Agnus as-is, so it is not typed.\n */\n agree(termIds: string[], headers?: Record<string, string>): Promise<unknown> {\n return this.client.patch<unknown, { terms: string[] }>(\n `${this.basePath}/agree`,\n { terms: termIds },\n headers,\n )\n }\n}\n"],"mappings":";;;;;;;;;;AAWA,IAAa,WAAb,cAA8B,QAAoC;CAChE,AAAgB,WAAW;;;;;CAM3B,QAAQ,IAAY,OAA4B,SAAiD;EAC/F,MAAM,cAAc,KAAK,cAAc,MAAM;AAC7C,SAAO,KAAK,OAAO,IAAU,GAAG,KAAK,SAAS,GAAG,KAAK,eAAe,QAAQ;;;;;;CAO/E,aAAa,SAAmD;AAC9D,SAAO,KAAK,OAAO,IAAY,GAAG,KAAK,SAAS,oBAAoB,QAAQ;;;;;;;;;CAU9E,MAAM,SAAmB,SAAoD;AAC3E,SAAO,KAAK,OAAO,MACjB,GAAG,KAAK,SAAS,SACjB,EAAE,OAAO,SAAS,EAClB,QACD"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
export type TimetableWeekDay = 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat';
|
|
2
|
+
/**
|
|
3
|
+
* A working period of the timetable. `start`/`end` are `HH:MM` and `end` must be later than
|
|
4
|
+
* `start`; the period applies to every day in `weekDays`.
|
|
5
|
+
*/
|
|
1
6
|
export type TimetableWorkSlot = {
|
|
2
|
-
|
|
7
|
+
/** `HH:MM` */
|
|
3
8
|
start: string;
|
|
9
|
+
/** `HH:MM`, later than `start`. */
|
|
4
10
|
end: string;
|
|
5
|
-
|
|
11
|
+
weekDays: TimetableWeekDay[];
|
|
6
12
|
};
|
|
7
13
|
export type Timetable = {
|
|
8
14
|
id: string;
|
|
@@ -14,13 +20,12 @@ export type Timetable = {
|
|
|
14
20
|
updatedAt: string;
|
|
15
21
|
};
|
|
16
22
|
export type CreateTimetablePayload = {
|
|
23
|
+
/** Must be unique in the account (409 otherwise, unless the account allows duplicate names). */
|
|
17
24
|
name: string;
|
|
25
|
+
/** Minutes before the end of the period to notify. Must be truthy: `0` answers 400 `required`. */
|
|
18
26
|
previousTimeToNotification: number;
|
|
19
27
|
workPlan: TimetableWorkSlot[];
|
|
20
28
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
previousTimeToNotification?: number;
|
|
24
|
-
workPlan?: TimetableWorkSlot[];
|
|
25
|
-
};
|
|
29
|
+
/** The backend requires the three fields on every update (400 `required` otherwise). */
|
|
30
|
+
export type UpdateTimetablePayload = CreateTimetablePayload;
|
|
26
31
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/apis/timetable/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/apis/timetable/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAA;AAEpF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,cAAc;IACd,KAAK,EAAE,MAAM,CAAA;IACb,mCAAmC;IACnC,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,gBAAgB,EAAE,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,0BAA0B,EAAE,MAAM,CAAA;IAClC,QAAQ,EAAE,iBAAiB,EAAE,CAAA;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,gGAAgG;IAChG,IAAI,EAAE,MAAM,CAAA;IACZ,kGAAkG;IAClG,0BAA0B,EAAE,MAAM,CAAA;IAClC,QAAQ,EAAE,iBAAiB,EAAE,CAAA;CAC9B,CAAA;AAED,wFAAwF;AACxF,MAAM,MAAM,sBAAsB,GAAG,sBAAsB,CAAA"}
|
|
@@ -1,36 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
2
|
+
const require_core_BaseReadApi = require('./BaseReadApi.cjs');
|
|
3
3
|
|
|
4
4
|
//#region src/core/BaseCrudApi.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
constructor(client, basePath) {
|
|
8
|
-
super(client);
|
|
9
|
-
this.basePath = basePath.replace(/\/$/, "");
|
|
10
|
-
}
|
|
11
|
-
getMany(query, headers) {
|
|
12
|
-
const queryString = this.toQueryString(query);
|
|
13
|
-
return this.client.get(`${this.basePath}${queryString}`, headers);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Returns the first resource matching the query, or `null` when none match.
|
|
17
|
-
* Convenience over `getMany` with `limit: 1`.
|
|
18
|
-
* @permissions $resourceName.view
|
|
19
|
-
*/
|
|
20
|
-
async getOne(query, headers) {
|
|
21
|
-
return (await this.getMany({
|
|
22
|
-
...query,
|
|
23
|
-
limit: 1,
|
|
24
|
-
paginate: false
|
|
25
|
-
}, headers))?.[0] ?? null;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Returns a single resource by ID.
|
|
29
|
-
* @permissions $resourceName.view
|
|
30
|
-
*/
|
|
31
|
-
getById(id, query, headers) {
|
|
32
|
-
return this.client.get(`${this.basePath}/${id}${this.toQueryString(query)}`, headers);
|
|
33
|
-
}
|
|
5
|
+
/** Generic CRUD resource: the reads of `BaseReadApi` plus `create`, `updateById` and `deleteById`. */
|
|
6
|
+
var BaseCrudApi = class extends require_core_BaseReadApi.BaseReadApi {
|
|
34
7
|
/**
|
|
35
8
|
* Creates a new resource.
|
|
36
9
|
* @permissions $resourceName.create
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseCrudApi.cjs","names":["
|
|
1
|
+
{"version":3,"file":"BaseCrudApi.cjs","names":["BaseReadApi"],"sources":["../../src/core/BaseCrudApi.ts"],"sourcesContent":["import { BaseReadApi } from './BaseReadApi'\nimport type { CrudApi, ListQuery } from './types'\nexport type {\n WhereClause,\n IncludeItem,\n ListQuery,\n GetByIdQuery,\n Paginated,\n HasGetMany,\n HasGetById,\n HasCreate,\n HasUpdateById,\n HasDeleteById,\n CrudApi,\n} from './types'\n\n/** Generic CRUD resource: the reads of `BaseReadApi` plus `create`, `updateById` and `deleteById`. */\nexport class BaseCrudApi<\n TResponse,\n TCreate,\n TUpdate = TCreate,\n TQuery extends ListQuery<TResponse> = ListQuery<TResponse>,\n>\n extends BaseReadApi<TResponse, TQuery>\n implements CrudApi<TResponse, TCreate, TUpdate, TQuery>\n{\n /**\n * Creates a new resource.\n * @permissions $resourceName.create\n */\n create(body: TCreate, headers?: Record<string, string>): Promise<TResponse> {\n return this.client.post<TResponse, TCreate>(this.basePath, body, headers)\n }\n\n /**\n * Updates an existing resource by ID.\n * @permissions $resourceName.update\n */\n updateById(id: string, body: TUpdate, headers?: Record<string, string>): Promise<TResponse> {\n return this.client.put<TResponse, TUpdate>(`${this.basePath}/${id}`, body, headers)\n }\n\n /**\n * Deletes a resource by ID.\n * @permissions $resourceName.delete\n */\n deleteById(id: string, headers?: Record<string, string>): Promise<TResponse> {\n return this.client.delete<TResponse>(`${this.basePath}/${id}`, headers)\n }\n}\n"],"mappings":";;;;;AAiBA,IAAa,cAAb,cAMUA,qCAEV;;;;;CAKE,OAAO,MAAe,SAAsD;AAC1E,SAAO,KAAK,OAAO,KAAyB,KAAK,UAAU,MAAM,QAAQ;;;;;;CAO3E,WAAW,IAAY,MAAe,SAAsD;AAC1F,SAAO,KAAK,OAAO,IAAwB,GAAG,KAAK,SAAS,GAAG,MAAM,MAAM,QAAQ;;;;;;CAOrF,WAAW,IAAY,SAAsD;AAC3E,SAAO,KAAK,OAAO,OAAkB,GAAG,KAAK,SAAS,GAAG,MAAM,QAAQ"}
|
|
@@ -1,28 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import type { CrudApi, GetByIdQuery, ListQuery, Paginated } from './types';
|
|
1
|
+
import { BaseReadApi } from './BaseReadApi';
|
|
2
|
+
import type { CrudApi, ListQuery } from './types';
|
|
4
3
|
export type { WhereClause, IncludeItem, ListQuery, GetByIdQuery, Paginated, HasGetMany, HasGetById, HasCreate, HasUpdateById, HasDeleteById, CrudApi, } from './types';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
constructor(client: ApiClient, basePath: string);
|
|
8
|
-
getMany(query: TQuery & {
|
|
9
|
-
paginate: false;
|
|
10
|
-
}, headers?: Record<string, string>): Promise<TResponse[]>;
|
|
11
|
-
getMany(query?: TQuery & {
|
|
12
|
-
paginate?: true;
|
|
13
|
-
}, headers?: Record<string, string>): Promise<Paginated<TResponse>>;
|
|
14
|
-
getMany(query?: TQuery, headers?: Record<string, string>): Promise<Paginated<TResponse> | TResponse[]>;
|
|
15
|
-
/**
|
|
16
|
-
* Returns the first resource matching the query, or `null` when none match.
|
|
17
|
-
* Convenience over `getMany` with `limit: 1`.
|
|
18
|
-
* @permissions $resourceName.view
|
|
19
|
-
*/
|
|
20
|
-
getOne(query?: TQuery, headers?: Record<string, string>): Promise<TResponse | null>;
|
|
21
|
-
/**
|
|
22
|
-
* Returns a single resource by ID.
|
|
23
|
-
* @permissions $resourceName.view
|
|
24
|
-
*/
|
|
25
|
-
getById(id: string, query?: GetByIdQuery<TResponse>, headers?: Record<string, string>): Promise<TResponse>;
|
|
4
|
+
/** Generic CRUD resource: the reads of `BaseReadApi` plus `create`, `updateById` and `deleteById`. */
|
|
5
|
+
export declare class BaseCrudApi<TResponse, TCreate, TUpdate = TCreate, TQuery extends ListQuery<TResponse> = ListQuery<TResponse>> extends BaseReadApi<TResponse, TQuery> implements CrudApi<TResponse, TCreate, TUpdate, TQuery> {
|
|
26
6
|
/**
|
|
27
7
|
* Creates a new resource.
|
|
28
8
|
* @permissions $resourceName.create
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseCrudApi.d.ts","sourceRoot":"","sources":["../../src/core/BaseCrudApi.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"BaseCrudApi.d.ts","sourceRoot":"","sources":["../../src/core/BaseCrudApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACjD,YAAY,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,YAAY,EACZ,SAAS,EACT,UAAU,EACV,UAAU,EACV,SAAS,EACT,aAAa,EACb,aAAa,EACb,OAAO,GACR,MAAM,SAAS,CAAA;AAEhB,sGAAsG;AACtG,qBAAa,WAAW,CACtB,SAAS,EACT,OAAO,EACP,OAAO,GAAG,OAAO,EACjB,MAAM,SAAS,SAAS,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC,CAE1D,SAAQ,WAAW,CAAC,SAAS,EAAE,MAAM,CACrC,YAAW,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC;IAEvD;;;OAGG;IACH,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;IAI3E;;;OAGG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;IAI3F;;;OAGG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;CAG7E"}
|
|
@@ -1,35 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseReadApi } from "./BaseReadApi.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/core/BaseCrudApi.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
constructor(client, basePath) {
|
|
7
|
-
super(client);
|
|
8
|
-
this.basePath = basePath.replace(/\/$/, "");
|
|
9
|
-
}
|
|
10
|
-
getMany(query, headers) {
|
|
11
|
-
const queryString = this.toQueryString(query);
|
|
12
|
-
return this.client.get(`${this.basePath}${queryString}`, headers);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Returns the first resource matching the query, or `null` when none match.
|
|
16
|
-
* Convenience over `getMany` with `limit: 1`.
|
|
17
|
-
* @permissions $resourceName.view
|
|
18
|
-
*/
|
|
19
|
-
async getOne(query, headers) {
|
|
20
|
-
return (await this.getMany({
|
|
21
|
-
...query,
|
|
22
|
-
limit: 1,
|
|
23
|
-
paginate: false
|
|
24
|
-
}, headers))?.[0] ?? null;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Returns a single resource by ID.
|
|
28
|
-
* @permissions $resourceName.view
|
|
29
|
-
*/
|
|
30
|
-
getById(id, query, headers) {
|
|
31
|
-
return this.client.get(`${this.basePath}/${id}${this.toQueryString(query)}`, headers);
|
|
32
|
-
}
|
|
4
|
+
/** Generic CRUD resource: the reads of `BaseReadApi` plus `create`, `updateById` and `deleteById`. */
|
|
5
|
+
var BaseCrudApi = class extends BaseReadApi {
|
|
33
6
|
/**
|
|
34
7
|
* Creates a new resource.
|
|
35
8
|
* @permissions $resourceName.create
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseCrudApi.mjs","names":[],"sources":["../../src/core/BaseCrudApi.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"BaseCrudApi.mjs","names":[],"sources":["../../src/core/BaseCrudApi.ts"],"sourcesContent":["import { BaseReadApi } from './BaseReadApi'\nimport type { CrudApi, ListQuery } from './types'\nexport type {\n WhereClause,\n IncludeItem,\n ListQuery,\n GetByIdQuery,\n Paginated,\n HasGetMany,\n HasGetById,\n HasCreate,\n HasUpdateById,\n HasDeleteById,\n CrudApi,\n} from './types'\n\n/** Generic CRUD resource: the reads of `BaseReadApi` plus `create`, `updateById` and `deleteById`. */\nexport class BaseCrudApi<\n TResponse,\n TCreate,\n TUpdate = TCreate,\n TQuery extends ListQuery<TResponse> = ListQuery<TResponse>,\n>\n extends BaseReadApi<TResponse, TQuery>\n implements CrudApi<TResponse, TCreate, TUpdate, TQuery>\n{\n /**\n * Creates a new resource.\n * @permissions $resourceName.create\n */\n create(body: TCreate, headers?: Record<string, string>): Promise<TResponse> {\n return this.client.post<TResponse, TCreate>(this.basePath, body, headers)\n }\n\n /**\n * Updates an existing resource by ID.\n * @permissions $resourceName.update\n */\n updateById(id: string, body: TUpdate, headers?: Record<string, string>): Promise<TResponse> {\n return this.client.put<TResponse, TUpdate>(`${this.basePath}/${id}`, body, headers)\n }\n\n /**\n * Deletes a resource by ID.\n * @permissions $resourceName.delete\n */\n deleteById(id: string, headers?: Record<string, string>): Promise<TResponse> {\n return this.client.delete<TResponse>(`${this.basePath}/${id}`, headers)\n }\n}\n"],"mappings":";;;;AAiBA,IAAa,cAAb,cAMU,YAEV;;;;;CAKE,OAAO,MAAe,SAAsD;AAC1E,SAAO,KAAK,OAAO,KAAyB,KAAK,UAAU,MAAM,QAAQ;;;;;;CAO3E,WAAW,IAAY,MAAe,SAAsD;AAC1F,SAAO,KAAK,OAAO,IAAwB,GAAG,KAAK,SAAS,GAAG,MAAM,MAAM,QAAQ;;;;;;CAOrF,WAAW,IAAY,SAAsD;AAC3E,SAAO,KAAK,OAAO,OAAkB,GAAG,KAAK,SAAS,GAAG,MAAM,QAAQ"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_core_BaseApi = require('./BaseApi.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/core/BaseReadApi.ts
|
|
5
|
+
/**
|
|
6
|
+
* Generic read-only resource: `getMany`, `getOne` and `getById` under `basePath`. Base of
|
|
7
|
+
* `BaseCrudApi`, and of the resources the backend only serves for reading (e.g. permissions,
|
|
8
|
+
* auth history).
|
|
9
|
+
*/
|
|
10
|
+
var BaseReadApi = class extends require_core_BaseApi.BaseApi {
|
|
11
|
+
basePath;
|
|
12
|
+
constructor(client, basePath) {
|
|
13
|
+
super(client);
|
|
14
|
+
this.basePath = basePath.replace(/\/$/, "");
|
|
15
|
+
}
|
|
16
|
+
getMany(query, headers) {
|
|
17
|
+
const queryString = this.toQueryString(query);
|
|
18
|
+
return this.client.get(`${this.basePath}${queryString}`, headers);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns the first resource matching the query, or `null` when none match.
|
|
22
|
+
* Convenience over `getMany` with `limit: 1`.
|
|
23
|
+
* @permissions $resourceName.view
|
|
24
|
+
*/
|
|
25
|
+
async getOne(query, headers) {
|
|
26
|
+
return (await this.getMany({
|
|
27
|
+
...query,
|
|
28
|
+
limit: 1,
|
|
29
|
+
paginate: false
|
|
30
|
+
}, headers))?.[0] ?? null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns a single resource by ID. When it does not exist most routes answer 200 with an empty
|
|
34
|
+
* body, which resolves to `undefined`.
|
|
35
|
+
* @permissions $resourceName.view
|
|
36
|
+
*/
|
|
37
|
+
getById(id, query, headers) {
|
|
38
|
+
return this.client.get(`${this.basePath}/${id}${this.toQueryString(query)}`, headers);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
exports.BaseReadApi = BaseReadApi;
|
|
44
|
+
//# sourceMappingURL=BaseReadApi.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseReadApi.cjs","names":["BaseApi"],"sources":["../../src/core/BaseReadApi.ts"],"sourcesContent":["import type { ApiClient } from './ApiClient'\nimport { BaseApi } from './BaseApi'\nimport type { GetByIdQuery, HasGetById, HasGetMany, ListQuery, Paginated } from './types'\n\n/**\n * Generic read-only resource: `getMany`, `getOne` and `getById` under `basePath`. Base of\n * `BaseCrudApi`, and of the resources the backend only serves for reading (e.g. permissions,\n * auth history).\n */\nexport class BaseReadApi<TResponse, TQuery extends ListQuery<TResponse> = ListQuery<TResponse>>\n extends BaseApi\n implements HasGetMany<TResponse, TQuery>, HasGetById<TResponse>\n{\n public readonly basePath: string\n\n constructor(client: ApiClient, basePath: string) {\n super(client)\n this.basePath = basePath.replace(/\\/$/, '')\n }\n\n getMany(\n query: TQuery & { paginate: false },\n headers?: Record<string, string>,\n ): Promise<TResponse[]>\n getMany(\n query?: TQuery & { paginate?: true },\n headers?: Record<string, string>,\n ): Promise<Paginated<TResponse>>\n getMany(\n query?: TQuery,\n headers?: Record<string, string>,\n ): Promise<Paginated<TResponse> | TResponse[]>\n getMany(\n query?: TQuery,\n headers?: Record<string, string>,\n ): Promise<Paginated<TResponse> | TResponse[]> {\n const queryString = this.toQueryString(query)\n return this.client.get<Paginated<TResponse> | TResponse[]>(\n `${this.basePath}${queryString}`,\n headers,\n )\n }\n\n /**\n * Returns the first resource matching the query, or `null` when none match.\n * Convenience over `getMany` with `limit: 1`.\n * @permissions $resourceName.view\n */\n async getOne(query?: TQuery, headers?: Record<string, string>): Promise<TResponse | null> {\n const results = await this.getMany(\n { ...query, limit: 1, paginate: false } as TQuery & { paginate: false },\n headers,\n )\n // An empty response body resolves to `undefined`.\n return results?.[0] ?? null\n }\n\n /**\n * Returns a single resource by ID. When it does not exist most routes answer 200 with an empty\n * body, which resolves to `undefined`.\n * @permissions $resourceName.view\n */\n getById(\n id: string,\n query?: GetByIdQuery<TResponse>,\n headers?: Record<string, string>,\n ): Promise<TResponse> {\n return this.client.get<TResponse>(`${this.basePath}/${id}${this.toQueryString(query)}`, headers)\n }\n}\n"],"mappings":";;;;;;;;;AASA,IAAa,cAAb,cACUA,6BAEV;CACE,AAAgB;CAEhB,YAAY,QAAmB,UAAkB;AAC/C,QAAM,OAAO;AACb,OAAK,WAAW,SAAS,QAAQ,OAAO,GAAG;;CAe7C,QACE,OACA,SAC6C;EAC7C,MAAM,cAAc,KAAK,cAAc,MAAM;AAC7C,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,WAAW,eACnB,QACD;;;;;;;CAQH,MAAM,OAAO,OAAgB,SAA6D;AAMxF,UALgB,MAAM,KAAK,QACzB;GAAE,GAAG;GAAO,OAAO;GAAG,UAAU;GAAO,EACvC,QACD,IAEgB,MAAM;;;;;;;CAQzB,QACE,IACA,OACA,SACoB;AACpB,SAAO,KAAK,OAAO,IAAe,GAAG,KAAK,SAAS,GAAG,KAAK,KAAK,cAAc,MAAM,IAAI,QAAQ"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ApiClient } from './ApiClient';
|
|
2
|
+
import { BaseApi } from './BaseApi';
|
|
3
|
+
import type { GetByIdQuery, HasGetById, HasGetMany, ListQuery, Paginated } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Generic read-only resource: `getMany`, `getOne` and `getById` under `basePath`. Base of
|
|
6
|
+
* `BaseCrudApi`, and of the resources the backend only serves for reading (e.g. permissions,
|
|
7
|
+
* auth history).
|
|
8
|
+
*/
|
|
9
|
+
export declare class BaseReadApi<TResponse, TQuery extends ListQuery<TResponse> = ListQuery<TResponse>> extends BaseApi implements HasGetMany<TResponse, TQuery>, HasGetById<TResponse> {
|
|
10
|
+
readonly basePath: string;
|
|
11
|
+
constructor(client: ApiClient, basePath: string);
|
|
12
|
+
getMany(query: TQuery & {
|
|
13
|
+
paginate: false;
|
|
14
|
+
}, headers?: Record<string, string>): Promise<TResponse[]>;
|
|
15
|
+
getMany(query?: TQuery & {
|
|
16
|
+
paginate?: true;
|
|
17
|
+
}, headers?: Record<string, string>): Promise<Paginated<TResponse>>;
|
|
18
|
+
getMany(query?: TQuery, headers?: Record<string, string>): Promise<Paginated<TResponse> | TResponse[]>;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the first resource matching the query, or `null` when none match.
|
|
21
|
+
* Convenience over `getMany` with `limit: 1`.
|
|
22
|
+
* @permissions $resourceName.view
|
|
23
|
+
*/
|
|
24
|
+
getOne(query?: TQuery, headers?: Record<string, string>): Promise<TResponse | null>;
|
|
25
|
+
/**
|
|
26
|
+
* Returns a single resource by ID. When it does not exist most routes answer 200 with an empty
|
|
27
|
+
* body, which resolves to `undefined`.
|
|
28
|
+
* @permissions $resourceName.view
|
|
29
|
+
*/
|
|
30
|
+
getById(id: string, query?: GetByIdQuery<TResponse>, headers?: Record<string, string>): Promise<TResponse>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=BaseReadApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseReadApi.d.ts","sourceRoot":"","sources":["../../src/core/BaseReadApi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEzF;;;;GAIG;AACH,qBAAa,WAAW,CAAC,SAAS,EAAE,MAAM,SAAS,SAAS,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC,CAC5F,SAAQ,OACR,YAAW,UAAU,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC;IAE/D,SAAgB,QAAQ,EAAE,MAAM,CAAA;gBAEpB,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM;IAK/C,OAAO,CACL,KAAK,EAAE,MAAM,GAAG;QAAE,QAAQ,EAAE,KAAK,CAAA;KAAE,EACnC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC,SAAS,EAAE,CAAC;IACvB,OAAO,CACL,KAAK,CAAC,EAAE,MAAM,GAAG;QAAE,QAAQ,CAAC,EAAE,IAAI,CAAA;KAAE,EACpC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CACL,KAAK,CAAC,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,SAAS,EAAE,CAAC;IAY9C;;;;OAIG;IACG,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IASzF;;;;OAIG;IACH,OAAO,CACL,EAAE,EAAE,MAAM,EACV,KAAK,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,EAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC,SAAS,CAAC;CAGtB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { BaseApi } from "./BaseApi.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/core/BaseReadApi.ts
|
|
4
|
+
/**
|
|
5
|
+
* Generic read-only resource: `getMany`, `getOne` and `getById` under `basePath`. Base of
|
|
6
|
+
* `BaseCrudApi`, and of the resources the backend only serves for reading (e.g. permissions,
|
|
7
|
+
* auth history).
|
|
8
|
+
*/
|
|
9
|
+
var BaseReadApi = class extends BaseApi {
|
|
10
|
+
basePath;
|
|
11
|
+
constructor(client, basePath) {
|
|
12
|
+
super(client);
|
|
13
|
+
this.basePath = basePath.replace(/\/$/, "");
|
|
14
|
+
}
|
|
15
|
+
getMany(query, headers) {
|
|
16
|
+
const queryString = this.toQueryString(query);
|
|
17
|
+
return this.client.get(`${this.basePath}${queryString}`, headers);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns the first resource matching the query, or `null` when none match.
|
|
21
|
+
* Convenience over `getMany` with `limit: 1`.
|
|
22
|
+
* @permissions $resourceName.view
|
|
23
|
+
*/
|
|
24
|
+
async getOne(query, headers) {
|
|
25
|
+
return (await this.getMany({
|
|
26
|
+
...query,
|
|
27
|
+
limit: 1,
|
|
28
|
+
paginate: false
|
|
29
|
+
}, headers))?.[0] ?? null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns a single resource by ID. When it does not exist most routes answer 200 with an empty
|
|
33
|
+
* body, which resolves to `undefined`.
|
|
34
|
+
* @permissions $resourceName.view
|
|
35
|
+
*/
|
|
36
|
+
getById(id, query, headers) {
|
|
37
|
+
return this.client.get(`${this.basePath}/${id}${this.toQueryString(query)}`, headers);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { BaseReadApi };
|
|
43
|
+
//# sourceMappingURL=BaseReadApi.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseReadApi.mjs","names":[],"sources":["../../src/core/BaseReadApi.ts"],"sourcesContent":["import type { ApiClient } from './ApiClient'\nimport { BaseApi } from './BaseApi'\nimport type { GetByIdQuery, HasGetById, HasGetMany, ListQuery, Paginated } from './types'\n\n/**\n * Generic read-only resource: `getMany`, `getOne` and `getById` under `basePath`. Base of\n * `BaseCrudApi`, and of the resources the backend only serves for reading (e.g. permissions,\n * auth history).\n */\nexport class BaseReadApi<TResponse, TQuery extends ListQuery<TResponse> = ListQuery<TResponse>>\n extends BaseApi\n implements HasGetMany<TResponse, TQuery>, HasGetById<TResponse>\n{\n public readonly basePath: string\n\n constructor(client: ApiClient, basePath: string) {\n super(client)\n this.basePath = basePath.replace(/\\/$/, '')\n }\n\n getMany(\n query: TQuery & { paginate: false },\n headers?: Record<string, string>,\n ): Promise<TResponse[]>\n getMany(\n query?: TQuery & { paginate?: true },\n headers?: Record<string, string>,\n ): Promise<Paginated<TResponse>>\n getMany(\n query?: TQuery,\n headers?: Record<string, string>,\n ): Promise<Paginated<TResponse> | TResponse[]>\n getMany(\n query?: TQuery,\n headers?: Record<string, string>,\n ): Promise<Paginated<TResponse> | TResponse[]> {\n const queryString = this.toQueryString(query)\n return this.client.get<Paginated<TResponse> | TResponse[]>(\n `${this.basePath}${queryString}`,\n headers,\n )\n }\n\n /**\n * Returns the first resource matching the query, or `null` when none match.\n * Convenience over `getMany` with `limit: 1`.\n * @permissions $resourceName.view\n */\n async getOne(query?: TQuery, headers?: Record<string, string>): Promise<TResponse | null> {\n const results = await this.getMany(\n { ...query, limit: 1, paginate: false } as TQuery & { paginate: false },\n headers,\n )\n // An empty response body resolves to `undefined`.\n return results?.[0] ?? null\n }\n\n /**\n * Returns a single resource by ID. When it does not exist most routes answer 200 with an empty\n * body, which resolves to `undefined`.\n * @permissions $resourceName.view\n */\n getById(\n id: string,\n query?: GetByIdQuery<TResponse>,\n headers?: Record<string, string>,\n ): Promise<TResponse> {\n return this.client.get<TResponse>(`${this.basePath}/${id}${this.toQueryString(query)}`, headers)\n }\n}\n"],"mappings":";;;;;;;;AASA,IAAa,cAAb,cACU,QAEV;CACE,AAAgB;CAEhB,YAAY,QAAmB,UAAkB;AAC/C,QAAM,OAAO;AACb,OAAK,WAAW,SAAS,QAAQ,OAAO,GAAG;;CAe7C,QACE,OACA,SAC6C;EAC7C,MAAM,cAAc,KAAK,cAAc,MAAM;AAC7C,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,WAAW,eACnB,QACD;;;;;;;CAQH,MAAM,OAAO,OAAgB,SAA6D;AAMxF,UALgB,MAAM,KAAK,QACzB;GAAE,GAAG;GAAO,OAAO;GAAG,UAAU;GAAO,EACvC,QACD,IAEgB,MAAM;;;;;;;CAQzB,QACE,IACA,OACA,SACoB;AACpB,SAAO,KAAK,OAAO,IAAe,GAAG,KAAK,SAAS,GAAG,KAAK,KAAK,cAAc,MAAM,IAAI,QAAQ"}
|
package/dist/core/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
const require_core_errors = require('./errors.cjs');
|
|
3
3
|
const require_core_BaseApiClient = require('./BaseApiClient.cjs');
|
|
4
4
|
const require_core_BaseApi = require('./BaseApi.cjs');
|
|
5
|
+
const require_core_BaseReadApi = require('./BaseReadApi.cjs');
|
|
5
6
|
const require_core_BaseCrudApi = require('./BaseCrudApi.cjs');
|
|
6
7
|
const require_core_ArchivableCrudApi = require('./ArchivableCrudApi.cjs');
|
|
7
8
|
|
|
@@ -13,6 +14,7 @@ exports.BadRequestError = require_core_errors.BadRequestError;
|
|
|
13
14
|
exports.BaseApi = require_core_BaseApi.BaseApi;
|
|
14
15
|
exports.BaseApiClient = require_core_BaseApiClient.BaseApiClient;
|
|
15
16
|
exports.BaseCrudApi = require_core_BaseCrudApi.BaseCrudApi;
|
|
17
|
+
exports.BaseReadApi = require_core_BaseReadApi.BaseReadApi;
|
|
16
18
|
exports.ConflictError = require_core_errors.ConflictError;
|
|
17
19
|
exports.DigisacError = require_core_errors.DigisacError;
|
|
18
20
|
exports.InternalServerError = require_core_errors.InternalServerError;
|
package/dist/core/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type { QueryFormat } from './queryString';
|
|
|
5
5
|
export { DigisacError, ApiConnectionError, ApiError, BadRequestError, ValidationError, AuthenticationError, PaymentRequiredError, PermissionDeniedError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, parseFieldErrors, } from './errors';
|
|
6
6
|
export type { FieldError, ErrorClassName, ApiErrorOptions } from './errors';
|
|
7
7
|
export { BaseApi } from './BaseApi';
|
|
8
|
+
export { BaseReadApi } from './BaseReadApi';
|
|
8
9
|
export { BaseCrudApi } from './BaseCrudApi';
|
|
9
10
|
export { ArchivableCrudApi } from './ArchivableCrudApi';
|
|
10
11
|
export type { WhereClause, IncludeItem, ListQuery, GetByIdQuery, Paginated } from './types';
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,YAAY,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAC3D,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,QAAQ,EACR,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,aAAa,EACb,aAAa,EACb,wBAAwB,EACxB,cAAc,EACd,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,UAAU,CAAA;AACjB,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,YAAY,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAC3D,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,QAAQ,EACR,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,aAAa,EACb,aAAa,EACb,wBAAwB,EACxB,cAAc,EACd,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,UAAU,CAAA;AACjB,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA"}
|
package/dist/core/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ApiConnectionError, ApiError, AuthenticationError, BadRequestError, ConflictError, DigisacError, InternalServerError, NotFoundError, PaymentRequiredError, PermissionDeniedError, RateLimitError, UnprocessableEntityError, ValidationError, parseFieldErrors } from "./errors.mjs";
|
|
2
2
|
import { BaseApiClient } from "./BaseApiClient.mjs";
|
|
3
3
|
import { BaseApi } from "./BaseApi.mjs";
|
|
4
|
+
import { BaseReadApi } from "./BaseReadApi.mjs";
|
|
4
5
|
import { BaseCrudApi } from "./BaseCrudApi.mjs";
|
|
5
6
|
import { ArchivableCrudApi } from "./ArchivableCrudApi.mjs";
|
|
6
7
|
|
|
7
|
-
export { ApiConnectionError, ApiError, ArchivableCrudApi, AuthenticationError, BadRequestError, BaseApi, BaseApiClient, BaseCrudApi, ConflictError, DigisacError, InternalServerError, NotFoundError, PaymentRequiredError, PermissionDeniedError, RateLimitError, UnprocessableEntityError, ValidationError, parseFieldErrors };
|
|
8
|
+
export { ApiConnectionError, ApiError, ArchivableCrudApi, AuthenticationError, BadRequestError, BaseApi, BaseApiClient, BaseCrudApi, BaseReadApi, ConflictError, DigisacError, InternalServerError, NotFoundError, PaymentRequiredError, PermissionDeniedError, RateLimitError, UnprocessableEntityError, ValidationError, parseFieldErrors };
|
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
const require_core_errors = require('./core/errors.cjs');
|
|
3
3
|
const require_core_BaseApiClient = require('./core/BaseApiClient.cjs');
|
|
4
4
|
const require_core_BaseApi = require('./core/BaseApi.cjs');
|
|
5
|
+
const require_core_BaseReadApi = require('./core/BaseReadApi.cjs');
|
|
5
6
|
const require_core_BaseCrudApi = require('./core/BaseCrudApi.cjs');
|
|
6
7
|
const require_core_ArchivableCrudApi = require('./core/ArchivableCrudApi.cjs');
|
|
7
8
|
require('./core/index.cjs');
|
|
@@ -14,6 +15,7 @@ exports.BadRequestError = require_core_errors.BadRequestError;
|
|
|
14
15
|
exports.BaseApi = require_core_BaseApi.BaseApi;
|
|
15
16
|
exports.BaseApiClient = require_core_BaseApiClient.BaseApiClient;
|
|
16
17
|
exports.BaseCrudApi = require_core_BaseCrudApi.BaseCrudApi;
|
|
18
|
+
exports.BaseReadApi = require_core_BaseReadApi.BaseReadApi;
|
|
17
19
|
exports.ConflictError = require_core_errors.ConflictError;
|
|
18
20
|
exports.DigisacError = require_core_errors.DigisacError;
|
|
19
21
|
exports.InternalServerError = require_core_errors.InternalServerError;
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ApiConnectionError, ApiError, AuthenticationError, BadRequestError, ConflictError, DigisacError, InternalServerError, NotFoundError, PaymentRequiredError, PermissionDeniedError, RateLimitError, UnprocessableEntityError, ValidationError, parseFieldErrors } from "./core/errors.mjs";
|
|
2
2
|
import { BaseApiClient } from "./core/BaseApiClient.mjs";
|
|
3
3
|
import { BaseApi } from "./core/BaseApi.mjs";
|
|
4
|
+
import { BaseReadApi } from "./core/BaseReadApi.mjs";
|
|
4
5
|
import { BaseCrudApi } from "./core/BaseCrudApi.mjs";
|
|
5
6
|
import { ArchivableCrudApi } from "./core/ArchivableCrudApi.mjs";
|
|
6
7
|
import "./core/index.mjs";
|
|
7
8
|
|
|
8
|
-
export { ApiConnectionError, ApiError, ArchivableCrudApi, AuthenticationError, BadRequestError, BaseApi, BaseApiClient, BaseCrudApi, ConflictError, DigisacError, InternalServerError, NotFoundError, PaymentRequiredError, PermissionDeniedError, RateLimitError, UnprocessableEntityError, ValidationError, parseFieldErrors };
|
|
9
|
+
export { ApiConnectionError, ApiError, ArchivableCrudApi, AuthenticationError, BadRequestError, BaseApi, BaseApiClient, BaseCrudApi, BaseReadApi, ConflictError, DigisacError, InternalServerError, NotFoundError, PaymentRequiredError, PermissionDeniedError, RateLimitError, UnprocessableEntityError, ValidationError, parseFieldErrors };
|
package/package.json
CHANGED
|
@@ -25,7 +25,6 @@ const entry: AuthHistory = {
|
|
|
25
25
|
event: 'auth',
|
|
26
26
|
userId: 'user-1',
|
|
27
27
|
accountId: 'acc-1',
|
|
28
|
-
branch: 'main',
|
|
29
28
|
originIP: '127.0.0.1',
|
|
30
29
|
originUA: 'Mozilla/5.0',
|
|
31
30
|
createdAt: '2024-01-01T00:00:00Z',
|
|
@@ -95,10 +94,19 @@ describe('AuthHistoryApi', () => {
|
|
|
95
94
|
expect(result).toEqual(entry)
|
|
96
95
|
})
|
|
97
96
|
|
|
97
|
+
it('sends the query (e.g. include) in the query string, not as headers', async () => {
|
|
98
|
+
vi.mocked(client.get).mockResolvedValue(entry)
|
|
99
|
+
await api.getById('ah-1', { include: ['user'] })
|
|
100
|
+
expect(client.get).toHaveBeenCalledWith(
|
|
101
|
+
`/auth-history/ah-1?query=${encodeURIComponent(JSON.stringify({ include: ['user'] }))}`,
|
|
102
|
+
undefined,
|
|
103
|
+
)
|
|
104
|
+
})
|
|
105
|
+
|
|
98
106
|
it('forwards custom headers', async () => {
|
|
99
107
|
vi.mocked(client.get).mockResolvedValue(entry)
|
|
100
108
|
const headers = { 'X-Custom': 'h' }
|
|
101
|
-
await api.getById('ah-1', headers)
|
|
109
|
+
await api.getById('ah-1', undefined, headers)
|
|
102
110
|
expect(client.get).toHaveBeenCalledWith('/auth-history/ah-1', headers)
|
|
103
111
|
})
|
|
104
112
|
|
|
@@ -1,43 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { ApiClient } from '../../core/ApiClient'
|
|
2
|
+
import { BaseReadApi } from '../../core/BaseReadApi'
|
|
3
3
|
import type { AuthHistory } from './types'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
): Promise<AuthHistory[]>
|
|
17
|
-
getMany(
|
|
18
|
-
query?: ListQuery<AuthHistory> & { paginate?: true },
|
|
19
|
-
headers?: Record<string, string>,
|
|
20
|
-
): Promise<Paginated<AuthHistory>>
|
|
21
|
-
getMany(
|
|
22
|
-
query?: ListQuery<AuthHistory>,
|
|
23
|
-
headers?: Record<string, string>,
|
|
24
|
-
): Promise<Paginated<AuthHistory> | AuthHistory[]>
|
|
25
|
-
getMany(
|
|
26
|
-
query?: ListQuery<AuthHistory>,
|
|
27
|
-
headers?: Record<string, string>,
|
|
28
|
-
): Promise<Paginated<AuthHistory> | AuthHistory[]> {
|
|
29
|
-
const queryString = this.toQueryString(query)
|
|
30
|
-
return this.client.get<Paginated<AuthHistory> | AuthHistory[]>(
|
|
31
|
-
`/auth-history${queryString}`,
|
|
32
|
-
headers,
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Returns a single authentication event by its ID. Non-admin users can only access their own records.
|
|
38
|
-
* @permissions authHistory.view
|
|
39
|
-
*/
|
|
40
|
-
getById(id: string, headers?: Record<string, string>): Promise<AuthHistory> {
|
|
41
|
-
return this.client.get<AuthHistory>(`/auth-history/${id}`, headers)
|
|
5
|
+
/**
|
|
6
|
+
* Authentication events (auth, password_change, logout), read-only (guarded by
|
|
7
|
+
* `authHistory.view`). Non-admin users can only see and access their own records.
|
|
8
|
+
*
|
|
9
|
+
* Since 4.2 `getById` has the base signature `(id, query?, headers?)`: a call written as
|
|
10
|
+
* `getById(id, headers)` with the headers in a variable still compiles, but the headers are sent
|
|
11
|
+
* as the query string — move them to the third argument.
|
|
12
|
+
*/
|
|
13
|
+
export class AuthHistoryApi extends BaseReadApi<AuthHistory> {
|
|
14
|
+
constructor(client: ApiClient) {
|
|
15
|
+
super(client, '/auth-history')
|
|
42
16
|
}
|
|
43
17
|
}
|
|
@@ -8,9 +8,10 @@ export type AuthHistory = {
|
|
|
8
8
|
event: AuthHistoryEvent
|
|
9
9
|
userId: string
|
|
10
10
|
accountId: string
|
|
11
|
-
|
|
12
|
-
originIP: string
|
|
13
|
-
|
|
11
|
+
/** Nullable in the database. */
|
|
12
|
+
originIP: string | null
|
|
13
|
+
/** Nullable in the database. */
|
|
14
|
+
originUA: string | null
|
|
14
15
|
createdAt: string
|
|
15
16
|
updatedAt: string
|
|
16
17
|
// relationships
|