@directus/sdk
Advanced tools
Comparing version 9.7.1 to 9.8.0
@@ -6,2 +6,3 @@ import { AxiosRequestConfig } from 'axios'; | ||
abstract auth_expires: number | null; | ||
abstract auth_expires_at: number | null; | ||
abstract auth_refresh_token: string | null; | ||
@@ -154,2 +155,5 @@ abstract get(key: string): string | null; | ||
declare type Filter<T> = LogicalFilter<T> | FieldFilter<T extends Array<unknown> ? T[number] : T>; | ||
declare type ItemsOptions = { | ||
requestOptions: TransportRequestOptions; | ||
}; | ||
/** | ||
@@ -159,11 +163,11 @@ * CRUD at its finest | ||
interface IItems<T extends Item> { | ||
createOne(item: PartialItem<T>, query?: QueryOne<T>): Promise<OneItem<T>>; | ||
createMany(items: PartialItem<T>[], query?: QueryMany<T>): Promise<ManyItems<T>>; | ||
readOne(id: ID, query?: QueryOne<T>): Promise<OneItem<T>>; | ||
readMany(ids: ID[], query?: QueryMany<T>): Promise<ManyItems<T>>; | ||
readByQuery(query?: QueryMany<T>): Promise<ManyItems<T>>; | ||
updateOne(id: ID, item: PartialItem<T>, query?: QueryOne<T>): Promise<OneItem<T>>; | ||
updateMany(ids: ID[], item: PartialItem<T>, query?: QueryMany<T>): Promise<ManyItems<T>>; | ||
deleteOne(id: ID): Promise<void>; | ||
deleteMany(ids: ID[]): Promise<void>; | ||
createOne(item: PartialItem<T>, query?: QueryOne<T>, options?: ItemsOptions): Promise<OneItem<T>>; | ||
createMany(items: PartialItem<T>[], query?: QueryMany<T>, options?: ItemsOptions): Promise<ManyItems<T>>; | ||
readOne(id: ID, query?: QueryOne<T>, options?: ItemsOptions): Promise<OneItem<T>>; | ||
readMany(ids: ID[], query?: QueryMany<T>, options?: ItemsOptions): Promise<ManyItems<T>>; | ||
readByQuery(query?: QueryMany<T>, options?: ItemsOptions): Promise<ManyItems<T>>; | ||
updateOne(id: ID, item: PartialItem<T>, query?: QueryOne<T>, options?: ItemsOptions): Promise<OneItem<T>>; | ||
updateMany(ids: ID[], item: PartialItem<T>, query?: QueryMany<T>, options?: ItemsOptions): Promise<ManyItems<T>>; | ||
deleteOne(id: ID, options?: ItemsOptions): Promise<void>; | ||
deleteMany(ids: ID[], options?: ItemsOptions): Promise<void>; | ||
} | ||
@@ -194,3 +198,3 @@ | ||
url: string; | ||
beforeRequest?: (config: AxiosRequestConfig) => AxiosRequestConfig; | ||
beforeRequest?: (config: AxiosRequestConfig) => Promise<AxiosRequestConfig>; | ||
}; | ||
@@ -236,3 +240,2 @@ declare abstract class ITransport { | ||
autoRefresh?: boolean; | ||
msRefreshBeforeExpires?: number; | ||
staticToken?: string; | ||
@@ -248,2 +251,3 @@ transport: ITransport; | ||
abstract refresh(): Promise<AuthResult | false>; | ||
abstract refreshIfExpired(): Promise<void>; | ||
abstract static(token: AuthToken): Promise<boolean>; | ||
@@ -258,12 +262,12 @@ abstract logout(): Promise<void>; | ||
constructor(collection: string, transport: ITransport); | ||
readOne(id: ID, query?: QueryOne<T>): Promise<OneItem<T>>; | ||
readMany(ids: ID[], query?: QueryMany<T>): Promise<ManyItems<T>>; | ||
readByQuery(query?: QueryMany<T>): Promise<ManyItems<T>>; | ||
createOne(item: PartialItem<T>, query?: QueryOne<T>): Promise<OneItem<T>>; | ||
createMany(items: PartialItem<T>[], query?: QueryMany<T>): Promise<ManyItems<T>>; | ||
updateOne(id: ID, item: PartialItem<T>, query?: QueryOne<T>): Promise<OneItem<T>>; | ||
updateMany(ids: ID[], data: PartialItem<T>, query?: QueryMany<T>): Promise<ManyItems<T>>; | ||
updateByQuery(updateQuery: QueryMany<T>, data: PartialItem<T>, query?: QueryMany<T>): Promise<ManyItems<T>>; | ||
deleteOne(id: ID): Promise<void>; | ||
deleteMany(ids: ID[]): Promise<void>; | ||
readOne(id: ID, query?: QueryOne<T>, options?: ItemsOptions): Promise<OneItem<T>>; | ||
readMany(ids: ID[], query?: QueryMany<T>, options?: ItemsOptions): Promise<ManyItems<T>>; | ||
readByQuery(query?: QueryMany<T>, options?: ItemsOptions): Promise<ManyItems<T>>; | ||
createOne(item: PartialItem<T>, query?: QueryOne<T>, options?: ItemsOptions): Promise<OneItem<T>>; | ||
createMany(items: PartialItem<T>[], query?: QueryMany<T>, options?: ItemsOptions): Promise<ManyItems<T>>; | ||
updateOne(id: ID, item: PartialItem<T>, query?: QueryOne<T>, options?: ItemsOptions): Promise<OneItem<T>>; | ||
updateMany(ids: ID[], data: PartialItem<T>, query?: QueryMany<T>, options?: ItemsOptions): Promise<ManyItems<T>>; | ||
updateByQuery(updateQuery: QueryMany<T>, data: PartialItem<T>, query?: QueryMany<T>, options?: ItemsOptions): Promise<ManyItems<T>>; | ||
deleteOne(id: ID, options?: ItemsOptions): Promise<void>; | ||
deleteMany(ids: ID[], options?: ItemsOptions): Promise<void>; | ||
} | ||
@@ -566,2 +570,4 @@ | ||
set auth_expires(value: number | null); | ||
get auth_expires_at(): number | null; | ||
set auth_expires_at(value: number | null); | ||
get auth_refresh_token(): string | null; | ||
@@ -597,3 +603,3 @@ set auth_refresh_token(value: string | null); | ||
constructor(config: TransportOptions); | ||
beforeRequest(config: AxiosRequestConfig): AxiosRequestConfig; | ||
beforeRequest(config: AxiosRequestConfig): Promise<AxiosRequestConfig>; | ||
get url(): string; | ||
@@ -617,7 +623,5 @@ protected request<T = any, R = any>(method: TransportMethods, path: string, data?: Record<string, any>, options?: Omit<TransportOptions, 'url'>): Promise<TransportResponse<T, R>>; | ||
autoRefresh: boolean; | ||
msRefreshBeforeExpires: number; | ||
staticToken: string; | ||
private _storage; | ||
private _transport; | ||
private timer; | ||
private passwords?; | ||
@@ -631,3 +635,3 @@ constructor(options: AuthOptions); | ||
private updateStorage; | ||
private autoRefreshJob; | ||
refreshIfExpired(): Promise<void>; | ||
refresh(): Promise<AuthResult | false>; | ||
@@ -694,2 +698,2 @@ login(credentials: AuthCredentials): Promise<AuthResult>; | ||
export { ActivityHandler, ActivityItem, ActivityType, Auth, AuthCredentials, AuthMode, AuthOptions, AuthResult, AuthStorage, AuthToken, AuthTokenType, BaseStorage, CollectionItem, CollectionType, CollectionsHandler, Comment, CommentsHandler, DeepQueryMany, DefaultType, Directus, DirectusOptions, DirectusStorageOptions, DirectusTypes, Field, FieldFilter, FieldItem, FieldType, FieldsHandler, FileItem, FileType, FilesHandler, Filter, FilterOperators, FolderItem, FolderType, FoldersHandler, IAuth, ID, IDirectus, IDirectusBase, IItems, ISingleton, IStorage, ITransport, Item, ItemMetadata, ItemsHandler, LocalStorage, LogicalFilter, LogicalFilterAnd, LogicalFilterOr, ManyItems, MemoryStorage, Meta, Omit$1 as Omit, OneItem, PartialBy, PartialItem, Payload, PermissionItem, PermissionType, PermissionsHandler, PresetItem, PresetType, PresetsHandler, QueryMany, QueryOne, RelationItem, RelationType, RelationsHandler, RevisionItem, RevisionType, RevisionsHandler, RoleItem, RoleType, RolesHandler, ServerHandler, ServerInfo, SettingItem, SettingType, SettingsHandler, Sort, StorageOptions, SystemType, TfaType, Transport, TransportError, TransportErrorDescription, TransportMethods, TransportOptions, TransportRequestOptions, TransportResponse, TypeMap, TypeOf, UserItem, UserType, UsersHandler, UtilsHandler }; | ||
export { ActivityHandler, ActivityItem, ActivityType, Auth, AuthCredentials, AuthMode, AuthOptions, AuthResult, AuthStorage, AuthToken, AuthTokenType, BaseStorage, CollectionItem, CollectionType, CollectionsHandler, Comment, CommentsHandler, DeepQueryMany, DefaultType, Directus, DirectusOptions, DirectusStorageOptions, DirectusTypes, Field, FieldFilter, FieldItem, FieldType, FieldsHandler, FileItem, FileType, FilesHandler, Filter, FilterOperators, FolderItem, FolderType, FoldersHandler, IAuth, ID, IDirectus, IDirectusBase, IItems, ISingleton, IStorage, ITransport, Item, ItemMetadata, ItemsHandler, ItemsOptions, LocalStorage, LogicalFilter, LogicalFilterAnd, LogicalFilterOr, ManyItems, MemoryStorage, Meta, Omit$1 as Omit, OneItem, PartialBy, PartialItem, Payload, PermissionItem, PermissionType, PermissionsHandler, PresetItem, PresetType, PresetsHandler, QueryMany, QueryOne, RelationItem, RelationType, RelationsHandler, RevisionItem, RevisionType, RevisionsHandler, RoleItem, RoleType, RolesHandler, ServerHandler, ServerInfo, SettingItem, SettingType, SettingsHandler, Sort, StorageOptions, SystemType, TfaType, Transport, TransportError, TransportErrorDescription, TransportMethods, TransportOptions, TransportRequestOptions, TransportResponse, TypeMap, TypeOf, UserItem, UserType, UsersHandler, UtilsHandler }; |
@@ -15,9 +15,10 @@ import axios from 'axios'; | ||
} | ||
async readOne(id, query) { | ||
async readOne(id, query, options) { | ||
const response = await this.transport.get(`${this.endpoint}/${encodeURI(id)}`, { | ||
params: query, | ||
...options === null || options === void 0 ? void 0 : options.requestOptions, | ||
}); | ||
return response.data; | ||
} | ||
async readMany(ids, query) { | ||
async readMany(ids, query, options) { | ||
var _a; | ||
@@ -35,2 +36,3 @@ const collectionFields = await this.transport.get(`/fields/${this.collection}`); | ||
}, | ||
...options === null || options === void 0 ? void 0 : options.requestOptions, | ||
}); | ||
@@ -42,5 +44,6 @@ return { | ||
} | ||
async readByQuery(query) { | ||
async readByQuery(query, options) { | ||
const { data, meta } = await this.transport.get(`${this.endpoint}`, { | ||
params: query, | ||
...options === null || options === void 0 ? void 0 : options.requestOptions, | ||
}); | ||
@@ -52,18 +55,21 @@ return { | ||
} | ||
async createOne(item, query) { | ||
async createOne(item, query, options) { | ||
return (await this.transport.post(`${this.endpoint}`, item, { | ||
params: query, | ||
...options === null || options === void 0 ? void 0 : options.requestOptions, | ||
})).data; | ||
} | ||
async createMany(items, query) { | ||
async createMany(items, query, options) { | ||
return await this.transport.post(`${this.endpoint}`, items, { | ||
params: query, | ||
...options === null || options === void 0 ? void 0 : options.requestOptions, | ||
}); | ||
} | ||
async updateOne(id, item, query) { | ||
async updateOne(id, item, query, options) { | ||
return (await this.transport.patch(`${this.endpoint}/${encodeURI(id)}`, item, { | ||
params: query, | ||
...options === null || options === void 0 ? void 0 : options.requestOptions, | ||
})).data; | ||
} | ||
async updateMany(ids, data, query) { | ||
async updateMany(ids, data, query, options) { | ||
return await this.transport.patch(`${this.endpoint}`, { | ||
@@ -74,5 +80,6 @@ keys: ids, | ||
params: query, | ||
...options === null || options === void 0 ? void 0 : options.requestOptions, | ||
}); | ||
} | ||
async updateByQuery(updateQuery, data, query) { | ||
async updateByQuery(updateQuery, data, query, options) { | ||
return await this.transport.patch(`${this.endpoint}`, { | ||
@@ -83,9 +90,10 @@ query: updateQuery, | ||
params: query, | ||
...options === null || options === void 0 ? void 0 : options.requestOptions, | ||
}); | ||
} | ||
async deleteOne(id) { | ||
await this.transport.delete(`${this.endpoint}/${encodeURI(id)}`); | ||
async deleteOne(id, options) { | ||
await this.transport.delete(`${this.endpoint}/${encodeURI(id)}`, undefined, options === null || options === void 0 ? void 0 : options.requestOptions); | ||
} | ||
async deleteMany(ids) { | ||
await this.transport.delete(`${this.endpoint}`, ids); | ||
async deleteMany(ids, options) { | ||
await this.transport.delete(`${this.endpoint}`, ids, options === null || options === void 0 ? void 0 : options.requestOptions); | ||
} | ||
@@ -455,2 +463,3 @@ } | ||
Keys["Expires"] = "auth_expires"; | ||
Keys["ExpiresAt"] = "auth_expires_at"; | ||
})(Keys || (Keys = {})); | ||
@@ -489,2 +498,17 @@ class BaseStorage extends IStorage { | ||
} | ||
get auth_expires_at() { | ||
const value = this.get(Keys.ExpiresAt); | ||
if (value === null) { | ||
return null; | ||
} | ||
return parseInt(value); | ||
} | ||
set auth_expires_at(value) { | ||
if (value === null) { | ||
this.delete(Keys.ExpiresAt); | ||
} | ||
else { | ||
this.set(Keys.ExpiresAt, value.toString()); | ||
} | ||
} | ||
get auth_refresh_token() { | ||
@@ -575,3 +599,3 @@ return this.get(Keys.RefreshToken); | ||
} | ||
beforeRequest(config) { | ||
async beforeRequest(config) { | ||
return config; | ||
@@ -593,3 +617,3 @@ } | ||
}; | ||
config = this.beforeRequest(config); | ||
config = await this.beforeRequest(config); | ||
const response = await this.axios.request(config); | ||
@@ -666,8 +690,6 @@ const content = { | ||
constructor(options) { | ||
var _a, _b, _c; | ||
var _a, _b; | ||
super(); | ||
this.autoRefresh = true; | ||
this.msRefreshBeforeExpires = 30000; | ||
this.staticToken = ''; | ||
this.timer = null; | ||
this._transport = options.transport; | ||
@@ -677,3 +699,2 @@ this._storage = options.storage; | ||
this.mode = (_b = options === null || options === void 0 ? void 0 : options.mode) !== null && _b !== void 0 ? _b : this.mode; | ||
this.msRefreshBeforeExpires = (_c = options === null || options === void 0 ? void 0 : options.msRefreshBeforeExpires) !== null && _c !== void 0 ? _c : this.msRefreshBeforeExpires; | ||
if (options === null || options === void 0 ? void 0 : options.staticToken) { | ||
@@ -683,5 +704,2 @@ this.staticToken = options === null || options === void 0 ? void 0 : options.staticToken; | ||
} | ||
else if (this.autoRefresh) { | ||
this.autoRefreshJob(); | ||
} | ||
} | ||
@@ -704,23 +722,24 @@ get storage() { | ||
this._storage.auth_expires = null; | ||
this._storage.auth_expires_at = null; | ||
} | ||
updateStorage(result) { | ||
var _a, _b; | ||
const expires = (_a = result.expires) !== null && _a !== void 0 ? _a : null; | ||
this._storage.auth_token = result.access_token; | ||
this._storage.auth_refresh_token = (_a = result.refresh_token) !== null && _a !== void 0 ? _a : null; | ||
this._storage.auth_expires = (_b = result.expires) !== null && _b !== void 0 ? _b : null; | ||
this._storage.auth_refresh_token = (_b = result.refresh_token) !== null && _b !== void 0 ? _b : null; | ||
this._storage.auth_expires = expires; | ||
this._storage.auth_expires_at = new Date().getTime() + (expires !== null && expires !== void 0 ? expires : 0); | ||
} | ||
autoRefreshJob() { | ||
async refreshIfExpired() { | ||
if (this.staticToken) | ||
return; | ||
if (!this.autoRefresh) | ||
return; | ||
if (!this._storage.auth_expires) | ||
if (!this._storage.auth_expires_at) | ||
return; | ||
if (this.timer) | ||
clearTimeout(this.timer); | ||
const msWaitUntilRefresh = this._storage.auth_expires - this.msRefreshBeforeExpires; | ||
this.timer = setTimeout(async () => { | ||
if (this._storage.auth_expires_at < new Date().getTime()) { | ||
await this.refresh().catch(() => { | ||
/*do nothing*/ | ||
}); | ||
this.autoRefreshJob(); | ||
}, msWaitUntilRefresh); | ||
} | ||
} | ||
@@ -736,3 +755,3 @@ async refresh() { | ||
if (this.autoRefresh) | ||
this.autoRefreshJob(); | ||
this.refreshIfExpired(); | ||
return { | ||
@@ -750,3 +769,3 @@ access_token: response.data.access_token, | ||
if (this.autoRefresh) | ||
this.autoRefreshJob(); | ||
this.refreshIfExpired(); | ||
return { | ||
@@ -770,3 +789,2 @@ access_token: response.data.access_token, | ||
this.updateStorage({ access_token: null, expires: null, refresh_token: null }); | ||
clearTimeout(this.timer); | ||
} | ||
@@ -819,3 +837,4 @@ } | ||
url: this.url, | ||
beforeRequest: (config) => { | ||
beforeRequest: async (config) => { | ||
await this._auth.refreshIfExpired(); | ||
const token = this.storage.auth_token; | ||
@@ -822,0 +841,0 @@ const bearer = token |
@@ -23,9 +23,10 @@ 'use strict'; | ||
} | ||
async readOne(id, query) { | ||
async readOne(id, query, options) { | ||
const response = await this.transport.get(`${this.endpoint}/${encodeURI(id)}`, { | ||
params: query, | ||
...options === null || options === void 0 ? void 0 : options.requestOptions, | ||
}); | ||
return response.data; | ||
} | ||
async readMany(ids, query) { | ||
async readMany(ids, query, options) { | ||
var _a; | ||
@@ -43,2 +44,3 @@ const collectionFields = await this.transport.get(`/fields/${this.collection}`); | ||
}, | ||
...options === null || options === void 0 ? void 0 : options.requestOptions, | ||
}); | ||
@@ -50,5 +52,6 @@ return { | ||
} | ||
async readByQuery(query) { | ||
async readByQuery(query, options) { | ||
const { data, meta } = await this.transport.get(`${this.endpoint}`, { | ||
params: query, | ||
...options === null || options === void 0 ? void 0 : options.requestOptions, | ||
}); | ||
@@ -60,18 +63,21 @@ return { | ||
} | ||
async createOne(item, query) { | ||
async createOne(item, query, options) { | ||
return (await this.transport.post(`${this.endpoint}`, item, { | ||
params: query, | ||
...options === null || options === void 0 ? void 0 : options.requestOptions, | ||
})).data; | ||
} | ||
async createMany(items, query) { | ||
async createMany(items, query, options) { | ||
return await this.transport.post(`${this.endpoint}`, items, { | ||
params: query, | ||
...options === null || options === void 0 ? void 0 : options.requestOptions, | ||
}); | ||
} | ||
async updateOne(id, item, query) { | ||
async updateOne(id, item, query, options) { | ||
return (await this.transport.patch(`${this.endpoint}/${encodeURI(id)}`, item, { | ||
params: query, | ||
...options === null || options === void 0 ? void 0 : options.requestOptions, | ||
})).data; | ||
} | ||
async updateMany(ids, data, query) { | ||
async updateMany(ids, data, query, options) { | ||
return await this.transport.patch(`${this.endpoint}`, { | ||
@@ -82,5 +88,6 @@ keys: ids, | ||
params: query, | ||
...options === null || options === void 0 ? void 0 : options.requestOptions, | ||
}); | ||
} | ||
async updateByQuery(updateQuery, data, query) { | ||
async updateByQuery(updateQuery, data, query, options) { | ||
return await this.transport.patch(`${this.endpoint}`, { | ||
@@ -91,9 +98,10 @@ query: updateQuery, | ||
params: query, | ||
...options === null || options === void 0 ? void 0 : options.requestOptions, | ||
}); | ||
} | ||
async deleteOne(id) { | ||
await this.transport.delete(`${this.endpoint}/${encodeURI(id)}`); | ||
async deleteOne(id, options) { | ||
await this.transport.delete(`${this.endpoint}/${encodeURI(id)}`, undefined, options === null || options === void 0 ? void 0 : options.requestOptions); | ||
} | ||
async deleteMany(ids) { | ||
await this.transport.delete(`${this.endpoint}`, ids); | ||
async deleteMany(ids, options) { | ||
await this.transport.delete(`${this.endpoint}`, ids, options === null || options === void 0 ? void 0 : options.requestOptions); | ||
} | ||
@@ -463,2 +471,3 @@ } | ||
Keys["Expires"] = "auth_expires"; | ||
Keys["ExpiresAt"] = "auth_expires_at"; | ||
})(Keys || (Keys = {})); | ||
@@ -497,2 +506,17 @@ class BaseStorage extends IStorage { | ||
} | ||
get auth_expires_at() { | ||
const value = this.get(Keys.ExpiresAt); | ||
if (value === null) { | ||
return null; | ||
} | ||
return parseInt(value); | ||
} | ||
set auth_expires_at(value) { | ||
if (value === null) { | ||
this.delete(Keys.ExpiresAt); | ||
} | ||
else { | ||
this.set(Keys.ExpiresAt, value.toString()); | ||
} | ||
} | ||
get auth_refresh_token() { | ||
@@ -583,3 +607,3 @@ return this.get(Keys.RefreshToken); | ||
} | ||
beforeRequest(config) { | ||
async beforeRequest(config) { | ||
return config; | ||
@@ -601,3 +625,3 @@ } | ||
}; | ||
config = this.beforeRequest(config); | ||
config = await this.beforeRequest(config); | ||
const response = await this.axios.request(config); | ||
@@ -674,8 +698,6 @@ const content = { | ||
constructor(options) { | ||
var _a, _b, _c; | ||
var _a, _b; | ||
super(); | ||
this.autoRefresh = true; | ||
this.msRefreshBeforeExpires = 30000; | ||
this.staticToken = ''; | ||
this.timer = null; | ||
this._transport = options.transport; | ||
@@ -685,3 +707,2 @@ this._storage = options.storage; | ||
this.mode = (_b = options === null || options === void 0 ? void 0 : options.mode) !== null && _b !== void 0 ? _b : this.mode; | ||
this.msRefreshBeforeExpires = (_c = options === null || options === void 0 ? void 0 : options.msRefreshBeforeExpires) !== null && _c !== void 0 ? _c : this.msRefreshBeforeExpires; | ||
if (options === null || options === void 0 ? void 0 : options.staticToken) { | ||
@@ -691,5 +712,2 @@ this.staticToken = options === null || options === void 0 ? void 0 : options.staticToken; | ||
} | ||
else if (this.autoRefresh) { | ||
this.autoRefreshJob(); | ||
} | ||
} | ||
@@ -712,23 +730,24 @@ get storage() { | ||
this._storage.auth_expires = null; | ||
this._storage.auth_expires_at = null; | ||
} | ||
updateStorage(result) { | ||
var _a, _b; | ||
const expires = (_a = result.expires) !== null && _a !== void 0 ? _a : null; | ||
this._storage.auth_token = result.access_token; | ||
this._storage.auth_refresh_token = (_a = result.refresh_token) !== null && _a !== void 0 ? _a : null; | ||
this._storage.auth_expires = (_b = result.expires) !== null && _b !== void 0 ? _b : null; | ||
this._storage.auth_refresh_token = (_b = result.refresh_token) !== null && _b !== void 0 ? _b : null; | ||
this._storage.auth_expires = expires; | ||
this._storage.auth_expires_at = new Date().getTime() + (expires !== null && expires !== void 0 ? expires : 0); | ||
} | ||
autoRefreshJob() { | ||
async refreshIfExpired() { | ||
if (this.staticToken) | ||
return; | ||
if (!this.autoRefresh) | ||
return; | ||
if (!this._storage.auth_expires) | ||
if (!this._storage.auth_expires_at) | ||
return; | ||
if (this.timer) | ||
clearTimeout(this.timer); | ||
const msWaitUntilRefresh = this._storage.auth_expires - this.msRefreshBeforeExpires; | ||
this.timer = setTimeout(async () => { | ||
if (this._storage.auth_expires_at < new Date().getTime()) { | ||
await this.refresh().catch(() => { | ||
/*do nothing*/ | ||
}); | ||
this.autoRefreshJob(); | ||
}, msWaitUntilRefresh); | ||
} | ||
} | ||
@@ -744,3 +763,3 @@ async refresh() { | ||
if (this.autoRefresh) | ||
this.autoRefreshJob(); | ||
this.refreshIfExpired(); | ||
return { | ||
@@ -758,3 +777,3 @@ access_token: response.data.access_token, | ||
if (this.autoRefresh) | ||
this.autoRefreshJob(); | ||
this.refreshIfExpired(); | ||
return { | ||
@@ -778,3 +797,2 @@ access_token: response.data.access_token, | ||
this.updateStorage({ access_token: null, expires: null, refresh_token: null }); | ||
clearTimeout(this.timer); | ||
} | ||
@@ -827,3 +845,4 @@ } | ||
url: this.url, | ||
beforeRequest: (config) => { | ||
beforeRequest: async (config) => { | ||
await this._auth.refreshIfExpired(); | ||
const token = this.storage.auth_token; | ||
@@ -830,0 +849,0 @@ const bearer = token |
@@ -1,2 +0,2 @@ | ||
class t{constructor(){this.mode="undefined"==typeof window?"json":"cookie"}}class e{constructor(t,e){this.collection=t,this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}async readOne(t,e){return(await this.transport.get(`${this.endpoint}/${encodeURI(t)}`,{params:e})).data}async readMany(t,e){var r;const s=null===(r=(await this.transport.get(`/fields/${this.collection}`)).data)||void 0===r?void 0:r.find((t=>!0===t.schema.is_primary_key)),{data:n,meta:a}=await this.transport.get(`${this.endpoint}`,{params:{filter:{[s.field]:{_in:t},...null==e?void 0:e.filter},sort:(null==e?void 0:e.sort)||s.field,...e}});return{data:n,meta:a}}async readByQuery(t){const{data:e,meta:r}=await this.transport.get(`${this.endpoint}`,{params:t});return{data:e,meta:r}}async createOne(t,e){return(await this.transport.post(`${this.endpoint}`,t,{params:e})).data}async createMany(t,e){return await this.transport.post(`${this.endpoint}`,t,{params:e})}async updateOne(t,e,r){return(await this.transport.patch(`${this.endpoint}/${encodeURI(t)}`,e,{params:r})).data}async updateMany(t,e,r){return await this.transport.patch(`${this.endpoint}`,{keys:t,data:e},{params:r})}async updateByQuery(t,e,r){return await this.transport.patch(`${this.endpoint}`,{query:t,data:e},{params:r})}async deleteOne(t){await this.transport.delete(`${this.endpoint}/${encodeURI(t)}`)}async deleteMany(t){await this.transport.delete(`${this.endpoint}`,t)}}class r{constructor(t){this.transport=t}async create(t){return(await this.transport.post("/activity/comment",t)).data}async update(t,e){return(await this.transport.patch(`/activity/comment/${encodeURI(t)}`,{comment:e})).data}async delete(t){await this.transport.delete(`/activity/comment/${encodeURI(t)}`)}}class s extends e{constructor(t){super("directus_activity",t),this._comments=new r(this.transport)}get comments(){return this._comments}}class n{constructor(t){this.transport=t}async readOne(t){return(await this.transport.get(`/collections/${t}`)).data}async readAll(){const{data:t,meta:e}=await this.transport.get("/collections");return{data:t,meta:e}}async createOne(t){return(await this.transport.post("/collections",t)).data}async createMany(t){const{data:e,meta:r}=await this.transport.post("/collections",t);return{data:e,meta:r}}async updateOne(t,e,r){return(await this.transport.patch(`/collections/${t}`,e,{params:r})).data}async deleteOne(t){await this.transport.delete(`/collections/${t}`)}}class a{constructor(t){this.transport=t}async readOne(t,e){return(await this.transport.get(`/fields/${t}/${e}`)).data}async readMany(t){return(await this.transport.get(`/fields/${t}`)).data}async readAll(){return(await this.transport.get("/fields")).data}async createOne(t,e){return(await this.transport.post(`/fields/${t}`,e)).data}async updateOne(t,e,r){return(await this.transport.patch(`/fields/${t}/${e}`,r)).data}async deleteOne(t,e){await this.transport.delete(`/fields/${t}/${e}`)}}class o extends e{constructor(t){super("directus_files",t)}}class i extends e{constructor(t){super("directus_folders",t)}}class u extends e{constructor(t){super("directus_permissions",t)}}class c extends e{constructor(t){super("directus_presets",t)}}class h{constructor(t){this.transport=t}async readOne(t,e){return(await this.transport.get(`/relations/${t}/${e}`)).data}async readMany(t){return(await this.transport.get(`/relations/${t}`)).data}async readAll(){return(await this.transport.get("/relations")).data}async createOne(t){return(await this.transport.post("/relations",t)).data}async updateOne(t,e,r){return(await this.transport.patch(`/relations/${t}/${e}`,{params:r})).data}async deleteOne(t,e){await this.transport.delete(`/relations/${t}/${e}`)}}class l extends e{constructor(t){super("directus_revisions",t)}}class p extends e{constructor(t){super("directus_roles",t)}}class d{constructor(t){this.transport=t}async ping(){return(await this.transport.get("/server/ping")).raw}async info(){return(await this.transport.get("/server/info")).data}}class f{constructor(t,e){this.collection=t,this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}async read(t){return(await this.transport.get(`${this.endpoint}`,{params:t})).data}async update(t,e){return(await this.transport.patch(`${this.endpoint}`,t,{params:e})).data}}class m extends f{constructor(t){super("directus_settings",t)}}class g{constructor(t){this.transport=t}async send(t,e,r){await this.transport.post("/users/invite",{email:t,role:e,invite_url:r})}async accept(t,e){await this.transport.post("/users/invite/accept",{token:t,password:e})}}class v{constructor(t){this.transport=t}async generate(t){return(await this.transport.post("/users/me/tfa/generate",{password:t})).data}async enable(t,e){await this.transport.post("/users/me/tfa/enable",{secret:t,otp:e})}async disable(t){await this.transport.post("/users/me/tfa/disable",{otp:t})}}class y{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new v(this._transport))}async read(t){return(await this._transport.get("/users/me",{params:t})).data}async update(t,e){return(await this._transport.patch("/users/me",t,{params:e})).data}}class w extends e{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new g(this.transport))}get me(){return this._me||(this._me=new y(this.transport))}}class _{constructor(t){this.random={string:async(t=32)=>(await this.transport.get("/utils/random/string",{params:{length:t}})).data},this.hash={generate:async t=>(await this.transport.post("/utils/hash/generate",{string:t})).data,verify:async(t,e)=>(await this.transport.post("/utils/hash/verify",{string:t,hash:e})).data},this.transport=t}async sort(t,e,r){await this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:e,to:r})}async revert(t){await this.transport.post(`/utils/revert/${encodeURI(t)}`)}}var b,x;!function(t){t.TOTAL_COUNT="total_count",t.FILTER_COUNT="filter_count"}(b||(b={}));class k{}class R{}class E extends Error{constructor(t,e){var r,s;(null===(r=null==e?void 0:e.errors)||void 0===r?void 0:r.length)?super(null===(s=null==e?void 0:e.errors[0])||void 0===s?void 0:s.message):super((null==t?void 0:t.message)||"Unknown transport error"),this.parent=t,this.response=e,this.errors=(null==e?void 0:e.errors)||[],Object.values(e||{}).some((t=>void 0!==t))||(this.response=void 0),Object.setPrototypeOf(this,E.prototype)}}!function(t){t.AuthToken="auth_token",t.RefreshToken="auth_refresh_token",t.Expires="auth_expires"}(x||(x={}));class O extends k{constructor(t){var e;super(),this.prefix=null!==(e=null==t?void 0:t.prefix)&&void 0!==e?e:""}get auth_token(){return this.get(x.AuthToken)}set auth_token(t){null===t?this.delete(x.AuthToken):this.set(x.AuthToken,t)}get auth_expires(){const t=this.get(x.Expires);return null===t?null:parseInt(t)}set auth_expires(t){null===t?this.delete(x.Expires):this.set(x.Expires,t.toString())}get auth_refresh_token(){return this.get(x.RefreshToken)}set auth_refresh_token(t){null===t?this.delete(x.RefreshToken):this.set(x.RefreshToken,t)}}class S extends O{constructor(){super(...arguments),this.values={}}get(t){const e=this.key(t);return e in this.values?this.values[e]:null}set(t,e){return this.values[this.key(t)]=e,e}delete(t){const e=this.key(t),r=this.get(t);return e in this.values&&delete this.values[e],r}key(t){return`${this.prefix}${t}`}}class T extends O{get(t){const e=localStorage.getItem(this.key(t));return null!==e?e:null}set(t,e){return localStorage.setItem(this.key(t),e),e}delete(t){const e=this.key(t),r=this.get(e);return r&&localStorage.removeItem(e),r}key(t){return`${this.prefix}${t}`}}var $={exports:{}},A=function(t,e){return function(){for(var r=new Array(arguments.length),s=0;s<r.length;s++)r[s]=arguments[s];return t.apply(e,r)}},j=A,q=Object.prototype.toString;function U(t){return"[object Array]"===q.call(t)}function C(t){return void 0===t}function N(t){return null!==t&&"object"==typeof t}function P(t){if("[object Object]"!==q.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function B(t){return"[object Function]"===q.call(t)}function L(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),U(t))for(var r=0,s=t.length;r<s;r++)e.call(null,t[r],r,t);else for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.call(null,t[n],n,t)}var I={isArray:U,isArrayBuffer:function(t){return"[object ArrayBuffer]"===q.call(t)},isBuffer:function(t){return null!==t&&!C(t)&&null!==t.constructor&&!C(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:N,isPlainObject:P,isUndefined:C,isDate:function(t){return"[object Date]"===q.call(t)},isFile:function(t){return"[object File]"===q.call(t)},isBlob:function(t){return"[object Blob]"===q.call(t)},isFunction:B,isStream:function(t){return N(t)&&B(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:L,merge:function t(){var e={};function r(r,s){P(e[s])&&P(r)?e[s]=t(e[s],r):P(r)?e[s]=t({},r):U(r)?e[s]=r.slice():e[s]=r}for(var s=0,n=arguments.length;s<n;s++)L(arguments[s],r);return e},extend:function(t,e,r){return L(e,(function(e,s){t[s]=r&&"function"==typeof e?j(e,r):e})),t},trim:function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t}},D=I;function J(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var M=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(D.isURLSearchParams(e))s=e.toString();else{var n=[];D.forEach(e,(function(t,e){null!=t&&(D.isArray(t)?e+="[]":t=[t],D.forEach(t,(function(t){D.isDate(t)?t=t.toISOString():D.isObject(t)&&(t=JSON.stringify(t)),n.push(J(e)+"="+J(t))})))})),s=n.join("&")}if(s){var a=t.indexOf("#");-1!==a&&(t=t.slice(0,a)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t},F=I;function z(){this.handlers=[]}z.prototype.use=function(t,e,r){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},z.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},z.prototype.forEach=function(t){F.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var H=z,W=I,V=function(t,e,r,s,n){return t.config=e,r&&(t.code=r),t.request=s,t.response=n,t.isAxiosError=!0,t.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},t},X=V,K=function(t,e,r,s,n){var a=new Error(t);return X(a,e,r,s,n)},Q=K,G=I,Y=G.isStandardBrowserEnv()?{write:function(t,e,r,s,n,a){var o=[];o.push(t+"="+encodeURIComponent(e)),G.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),G.isString(s)&&o.push("path="+s),G.isString(n)&&o.push("domain="+n),!0===a&&o.push("secure"),document.cookie=o.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},Z=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)},tt=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t},et=I,rt=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],st=I,nt=st.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function s(t){var s=t;return e&&(r.setAttribute("href",s),s=r.href),r.setAttribute("href",s),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return t=s(window.location.href),function(e){var r=st.isString(e)?s(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0};function at(t){this.message=t}at.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},at.prototype.__CANCEL__=!0;var ot=at,it=I,ut=function(t,e,r){var s=r.config.validateStatus;r.status&&s&&!s(r.status)?e(Q("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)},ct=Y,ht=M,lt=function(t,e){return t&&!Z(e)?tt(t,e):e},pt=function(t){var e,r,s,n={};return t?(et.forEach(t.split("\n"),(function(t){if(s=t.indexOf(":"),e=et.trim(t.substr(0,s)).toLowerCase(),r=et.trim(t.substr(s+1)),e){if(n[e]&&rt.indexOf(e)>=0)return;n[e]="set-cookie"===e?(n[e]?n[e]:[]).concat([r]):n[e]?n[e]+", "+r:r}})),n):n},dt=nt,ft=K,mt=Et,gt=ot,vt=function(t){return new Promise((function(e,r){var s,n=t.data,a=t.headers,o=t.responseType;function i(){t.cancelToken&&t.cancelToken.unsubscribe(s),t.signal&&t.signal.removeEventListener("abort",s)}it.isFormData(n)&&delete a["Content-Type"];var u=new XMLHttpRequest;if(t.auth){var c=t.auth.username||"",h=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";a.Authorization="Basic "+btoa(c+":"+h)}var l=lt(t.baseURL,t.url);function p(){if(u){var s="getAllResponseHeaders"in u?pt(u.getAllResponseHeaders()):null,n={data:o&&"text"!==o&&"json"!==o?u.response:u.responseText,status:u.status,statusText:u.statusText,headers:s,config:t,request:u};ut((function(t){e(t),i()}),(function(t){r(t),i()}),n),u=null}}if(u.open(t.method.toUpperCase(),ht(l,t.params,t.paramsSerializer),!0),u.timeout=t.timeout,"onloadend"in u?u.onloadend=p:u.onreadystatechange=function(){u&&4===u.readyState&&(0!==u.status||u.responseURL&&0===u.responseURL.indexOf("file:"))&&setTimeout(p)},u.onabort=function(){u&&(r(ft("Request aborted",t,"ECONNABORTED",u)),u=null)},u.onerror=function(){r(ft("Network Error",t,null,u)),u=null},u.ontimeout=function(){var e=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",s=t.transitional||mt.transitional;t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(ft(e,t,s.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",u)),u=null},it.isStandardBrowserEnv()){var d=(t.withCredentials||dt(l))&&t.xsrfCookieName?ct.read(t.xsrfCookieName):void 0;d&&(a[t.xsrfHeaderName]=d)}"setRequestHeader"in u&&it.forEach(a,(function(t,e){void 0===n&&"content-type"===e.toLowerCase()?delete a[e]:u.setRequestHeader(e,t)})),it.isUndefined(t.withCredentials)||(u.withCredentials=!!t.withCredentials),o&&"json"!==o&&(u.responseType=t.responseType),"function"==typeof t.onDownloadProgress&&u.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&u.upload&&u.upload.addEventListener("progress",t.onUploadProgress),(t.cancelToken||t.signal)&&(s=function(t){u&&(r(!t||t&&t.type?new gt("canceled"):t),u.abort(),u=null)},t.cancelToken&&t.cancelToken.subscribe(s),t.signal&&(t.signal.aborted?s():t.signal.addEventListener("abort",s))),n||(n=null),u.send(n)}))},yt=I,wt=function(t,e){W.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},_t=V,bt={"Content-Type":"application/x-www-form-urlencoded"};function xt(t,e){!yt.isUndefined(t)&&yt.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var kt,Rt={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(kt=vt),kt),transformRequest:[function(t,e){return wt(e,"Accept"),wt(e,"Content-Type"),yt.isFormData(t)||yt.isArrayBuffer(t)||yt.isBuffer(t)||yt.isStream(t)||yt.isFile(t)||yt.isBlob(t)?t:yt.isArrayBufferView(t)?t.buffer:yt.isURLSearchParams(t)?(xt(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):yt.isObject(t)||e&&"application/json"===e["Content-Type"]?(xt(e,"application/json"),function(t,e,r){if(yt.isString(t))try{return(e||JSON.parse)(t),yt.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(r||JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){var e=this.transitional||Rt.transitional,r=e&&e.silentJSONParsing,s=e&&e.forcedJSONParsing,n=!r&&"json"===this.responseType;if(n||s&&yt.isString(t)&&t.length)try{return JSON.parse(t)}catch(t){if(n){if("SyntaxError"===t.name)throw _t(t,this,"E_JSON_PARSE");throw t}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};yt.forEach(["delete","get","head"],(function(t){Rt.headers[t]={}})),yt.forEach(["post","put","patch"],(function(t){Rt.headers[t]=yt.merge(bt)}));var Et=Rt,Ot=I,St=Et,Tt=function(t){return!(!t||!t.__CANCEL__)},$t=I,At=function(t,e,r){var s=this||St;return Ot.forEach(r,(function(r){t=r.call(s,t,e)})),t},jt=Tt,qt=Et,Ut=ot;function Ct(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Ut("canceled")}var Nt=I,Pt=function(t,e){e=e||{};var r={};function s(t,e){return Nt.isPlainObject(t)&&Nt.isPlainObject(e)?Nt.merge(t,e):Nt.isPlainObject(e)?Nt.merge({},e):Nt.isArray(e)?e.slice():e}function n(r){return Nt.isUndefined(e[r])?Nt.isUndefined(t[r])?void 0:s(void 0,t[r]):s(t[r],e[r])}function a(t){if(!Nt.isUndefined(e[t]))return s(void 0,e[t])}function o(r){return Nt.isUndefined(e[r])?Nt.isUndefined(t[r])?void 0:s(void 0,t[r]):s(void 0,e[r])}function i(r){return r in e?s(t[r],e[r]):r in t?s(void 0,t[r]):void 0}var u={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:i};return Nt.forEach(Object.keys(t).concat(Object.keys(e)),(function(t){var e=u[t]||n,s=e(t);Nt.isUndefined(s)&&e!==i||(r[t]=s)})),r},Bt="0.24.0",Lt=Bt,It={};["object","boolean","number","function","string","symbol"].forEach((function(t,e){It[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}}));var Dt={};It.transitional=function(t,e,r){function s(t,e){return"[Axios v"+Lt+"] Transitional option '"+t+"'"+e+(r?". "+r:"")}return function(r,n,a){if(!1===t)throw new Error(s(n," has been removed"+(e?" in "+e:"")));return e&&!Dt[n]&&(Dt[n]=!0,console.warn(s(n," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(r,n,a)}};var Jt={assertOptions:function(t,e,r){if("object"!=typeof t)throw new TypeError("options must be an object");for(var s=Object.keys(t),n=s.length;n-- >0;){var a=s[n],o=e[a];if(o){var i=t[a],u=void 0===i||o(i,a,t);if(!0!==u)throw new TypeError("option "+a+" must be "+u)}else if(!0!==r)throw Error("Unknown option "+a)}},validators:It},Mt=I,Ft=M,zt=H,Ht=function(t){return Ct(t),t.headers=t.headers||{},t.data=At.call(t,t.data,t.headers,t.transformRequest),t.headers=$t.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),$t.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||qt.adapter)(t).then((function(e){return Ct(t),e.data=At.call(t,e.data,e.headers,t.transformResponse),e}),(function(e){return jt(e)||(Ct(t),e&&e.response&&(e.response.data=At.call(t,e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},Wt=Pt,Vt=Jt,Xt=Vt.validators;function Kt(t){this.defaults=t,this.interceptors={request:new zt,response:new zt}}Kt.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=Wt(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=t.transitional;void 0!==e&&Vt.assertOptions(e,{silentJSONParsing:Xt.transitional(Xt.boolean),forcedJSONParsing:Xt.transitional(Xt.boolean),clarifyTimeoutError:Xt.transitional(Xt.boolean)},!1);var r=[],s=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(s=s&&e.synchronous,r.unshift(e.fulfilled,e.rejected))}));var n,a=[];if(this.interceptors.response.forEach((function(t){a.push(t.fulfilled,t.rejected)})),!s){var o=[Ht,void 0];for(Array.prototype.unshift.apply(o,r),o=o.concat(a),n=Promise.resolve(t);o.length;)n=n.then(o.shift(),o.shift());return n}for(var i=t;r.length;){var u=r.shift(),c=r.shift();try{i=u(i)}catch(t){c(t);break}}try{n=Ht(i)}catch(t){return Promise.reject(t)}for(;a.length;)n=n.then(a.shift(),a.shift());return n},Kt.prototype.getUri=function(t){return t=Wt(this.defaults,t),Ft(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},Mt.forEach(["delete","get","head","options"],(function(t){Kt.prototype[t]=function(e,r){return this.request(Wt(r||{},{method:t,url:e,data:(r||{}).data}))}})),Mt.forEach(["post","put","patch"],(function(t){Kt.prototype[t]=function(e,r,s){return this.request(Wt(s||{},{method:t,url:e,data:r}))}}));var Qt=Kt,Gt=ot;function Yt(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var r=this;this.promise.then((function(t){if(r._listeners){var e,s=r._listeners.length;for(e=0;e<s;e++)r._listeners[e](t);r._listeners=null}})),this.promise.then=function(t){var e,s=new Promise((function(t){r.subscribe(t),e=t})).then(t);return s.cancel=function(){r.unsubscribe(e)},s},t((function(t){r.reason||(r.reason=new Gt(t),e(r.reason))}))}Yt.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},Yt.prototype.subscribe=function(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]},Yt.prototype.unsubscribe=function(t){if(this._listeners){var e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}},Yt.source=function(){var t;return{token:new Yt((function(e){t=e})),cancel:t}};var Zt=Yt,te=I,ee=A,re=Qt,se=Pt;var ne=function t(e){var r=new re(e),s=ee(re.prototype.request,r);return te.extend(s,re.prototype,r),te.extend(s,r),s.create=function(r){return t(se(e,r))},s}(Et);ne.Axios=re,ne.Cancel=ot,ne.CancelToken=Zt,ne.isCancel=Tt,ne.VERSION=Bt,ne.all=function(t){return Promise.all(t)},ne.spread=function(t){return function(e){return t.apply(null,e)}},ne.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError},$.exports=ne,$.exports.default=ne;var ae=$.exports;class oe extends R{constructor(t){var e;super(),this.config=t,this.axios=ae.create({baseURL:this.config.url,params:this.config.params,headers:this.config.headers,onUploadProgress:this.config.onUploadProgress,withCredentials:!0}),(null===(e=this.config)||void 0===e?void 0:e.beforeRequest)&&(this.beforeRequest=this.config.beforeRequest)}beforeRequest(t){return t}get url(){return this.config.url}async request(t,e,r,s){var n,a,o,i,u;try{let n={method:t,url:e,data:r,params:null==s?void 0:s.params,headers:null==s?void 0:s.headers,onUploadProgress:null==s?void 0:s.onUploadProgress};n=this.beforeRequest(n);const a=await this.axios.request(n),o={raw:a.data,status:a.status,statusText:a.statusText,headers:a.headers,data:a.data.data,meta:a.data.meta,errors:a.data.errors};if(a.data.errors)throw new E(null,o);return o}catch(t){if(!t||t instanceof Error==!1)throw t;if(ae.isAxiosError(t)){const e=null===(n=t.response)||void 0===n?void 0:n.data;throw new E(t,{raw:null===(a=t.response)||void 0===a?void 0:a.data,status:null===(o=t.response)||void 0===o?void 0:o.status,statusText:null===(i=t.response)||void 0===i?void 0:i.statusText,headers:null===(u=t.response)||void 0===u?void 0:u.headers,data:null==e?void 0:e.data,meta:null==e?void 0:e.meta,errors:null==e?void 0:e.errors})}throw new E(t)}}async get(t,e){return await this.request("get",t,void 0,e)}async head(t,e){return await this.request("head",t,void 0,e)}async options(t,e){return await this.request("options",t,void 0,e)}async delete(t,e,r){return await this.request("delete",t,e,r)}async put(t,e,r){return await this.request("put",t,e,r)}async post(t,e,r){return await this.request("post",t,e,r)}async patch(t,e,r){return await this.request("patch",t,e,r)}}class ie{constructor(t){this.transport=t}async request(t,e){await this.transport.post("/auth/password/request",{email:t,reset_url:e})}async reset(t,e){await this.transport.post("/auth/password/reset",{token:t,password:e})}}class ue extends t{constructor(t){var e,r,s;super(),this.autoRefresh=!0,this.msRefreshBeforeExpires=3e4,this.staticToken="",this.timer=null,this._transport=t.transport,this._storage=t.storage,this.autoRefresh=null!==(e=null==t?void 0:t.autoRefresh)&&void 0!==e?e:this.autoRefresh,this.mode=null!==(r=null==t?void 0:t.mode)&&void 0!==r?r:this.mode,this.msRefreshBeforeExpires=null!==(s=null==t?void 0:t.msRefreshBeforeExpires)&&void 0!==s?s:this.msRefreshBeforeExpires,(null==t?void 0:t.staticToken)?(this.staticToken=null==t?void 0:t.staticToken,this.updateStorage({access_token:this.staticToken,expires:null,refresh_token:null})):this.autoRefresh&&this.autoRefreshJob()}get storage(){return this._storage}get transport(){return this._transport}get token(){return this._storage.auth_token}get password(){return this.passwords=this.passwords||new ie(this._transport)}resetStorage(){this._storage.auth_token=null,this._storage.auth_refresh_token=null,this._storage.auth_expires=null}updateStorage(t){var e,r;this._storage.auth_token=t.access_token,this._storage.auth_refresh_token=null!==(e=t.refresh_token)&&void 0!==e?e:null,this._storage.auth_expires=null!==(r=t.expires)&&void 0!==r?r:null}autoRefreshJob(){if(!this.autoRefresh)return;if(!this._storage.auth_expires)return;this.timer&&clearTimeout(this.timer);const t=this._storage.auth_expires-this.msRefreshBeforeExpires;this.timer=setTimeout((async()=>{await this.refresh().catch((()=>{})),this.autoRefreshJob()}),t)}async refresh(){var t;const e=this._storage.auth_refresh_token;this.resetStorage();const r=await this._transport.post("/auth/refresh",{refresh_token:"json"===this.mode?e:void 0});return this.updateStorage(r.data),this.autoRefresh&&this.autoRefreshJob(),{access_token:r.data.access_token,refresh_token:null===(t=r.data)||void 0===t?void 0:t.refresh_token,expires:r.data.expires}}async login(t){var e;this.resetStorage();const r=await this._transport.post("/auth/login",{mode:this.mode,...t},{headers:{Authorization:null}});return this.updateStorage(r.data),this.autoRefresh&&this.autoRefreshJob(),{access_token:r.data.access_token,refresh_token:null===(e=r.data)||void 0===e?void 0:e.refresh_token,expires:r.data.expires}}async static(t){return await this._transport.get("/users/me",{params:{access_token:t},headers:{Authorization:null}}),this.updateStorage({access_token:t,expires:null,refresh_token:null}),!0}async logout(){let t;"json"===this.mode&&(t=this._storage.auth_refresh_token||void 0),await this._transport.post("/auth/logout",{refresh_token:t}),this.updateStorage({access_token:null,expires:null,refresh_token:null}),clearTimeout(this.timer)}}class ce{constructor(t){this.transport=t}async request(t,e,r){return await this.transport.post(t,{query:e,variables:void 0===r?{}:r})}async items(t,e){return await this.request("/graphql",t,e)}async system(t,e){return await this.request("/graphql/system",t,e)}}class he{constructor(e,r){var s,n,a,o,i,u,c,h,l;if(this._url=e,this._options=r,this._items={},this._singletons={},(null===(s=this._options)||void 0===s?void 0:s.storage)&&(null===(n=this._options)||void 0===n?void 0:n.storage)instanceof k)this._storage=this._options.storage;else{const t=null===(a=this._options)||void 0===a?void 0:a.storage,{mode:e,...r}=null!=t?t:{};"MemoryStorage"===e||"undefined"==typeof window?this._storage=new S(r):this._storage=new T(r)}(null===(o=this._options)||void 0===o?void 0:o.transport)&&(null===(i=this._options)||void 0===i?void 0:i.transport)instanceof R?this._transport=this._options.transport:this._transport=new oe({url:this.url,beforeRequest:t=>{const e=this.storage.auth_token,r=e?e.startsWith("Bearer ")?String(this.storage.auth_token):`Bearer ${this.storage.auth_token}`:"";return{...t,headers:{Authorization:r,...t.headers}}},...null===(u=this._options)||void 0===u?void 0:u.transport}),(null===(c=this._options)||void 0===c?void 0:c.auth)&&(null===(h=this._options)||void 0===h?void 0:h.auth)instanceof t?this._auth=this._options.auth:this._auth=new ue({transport:this._transport,storage:this._storage,...null===(l=this._options)||void 0===l?void 0:l.auth})}get url(){return this._url}get auth(){return this._auth}get storage(){return this._storage}get transport(){return this._transport}get activity(){return this._activity||(this._activity=new s(this.transport))}get collections(){return this._collections||(this._collections=new n(this.transport))}get fields(){return this._fields||(this._fields=new a(this.transport))}get files(){return this._files||(this._files=new o(this.transport))}get folders(){return this._folders||(this._folders=new i(this.transport))}get permissions(){return this._permissions||(this._permissions=new u(this.transport))}get presets(){return this._presets||(this._presets=new c(this.transport))}get relations(){return this._relations||(this._relations=new h(this.transport))}get revisions(){return this._revisions||(this._revisions=new l(this.transport))}get roles(){return this._roles||(this._roles=new p(this.transport))}get users(){return this._users||(this._users=new w(this.transport))}get settings(){return this._settings||(this._settings=new m(this.transport))}get server(){return this._server||(this._server=new d(this.transport))}get utils(){return this._utils||(this._utils=new _(this.transport))}get graphql(){return this._graphql||(this._graphql=new ce(this.transport))}singleton(t){return this._singletons[t]||(this._singletons[t]=new f(t,this.transport))}items(t){return this._items[t]||(this._items[t]=new e(t,this.transport))}}export{s as ActivityHandler,ue as Auth,O as BaseStorage,n as CollectionsHandler,r as CommentsHandler,he as Directus,a as FieldsHandler,o as FilesHandler,i as FoldersHandler,t as IAuth,k as IStorage,R as ITransport,e as ItemsHandler,T as LocalStorage,S as MemoryStorage,b as Meta,u as PermissionsHandler,c as PresetsHandler,h as RelationsHandler,l as RevisionsHandler,p as RolesHandler,d as ServerHandler,m as SettingsHandler,oe as Transport,E as TransportError,w as UsersHandler,_ as UtilsHandler}; | ||
class t{constructor(){this.mode="undefined"==typeof window?"json":"cookie"}}class e{constructor(t,e){this.collection=t,this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}async readOne(t,e,r){return(await this.transport.get(`${this.endpoint}/${encodeURI(t)}`,{params:e,...null==r?void 0:r.requestOptions})).data}async readMany(t,e,r){var s;const n=null===(s=(await this.transport.get(`/fields/${this.collection}`)).data)||void 0===s?void 0:s.find((t=>!0===t.schema.is_primary_key)),{data:a,meta:o}=await this.transport.get(`${this.endpoint}`,{params:{filter:{[n.field]:{_in:t},...null==e?void 0:e.filter},sort:(null==e?void 0:e.sort)||n.field,...e},...null==r?void 0:r.requestOptions});return{data:a,meta:o}}async readByQuery(t,e){const{data:r,meta:s}=await this.transport.get(`${this.endpoint}`,{params:t,...null==e?void 0:e.requestOptions});return{data:r,meta:s}}async createOne(t,e,r){return(await this.transport.post(`${this.endpoint}`,t,{params:e,...null==r?void 0:r.requestOptions})).data}async createMany(t,e,r){return await this.transport.post(`${this.endpoint}`,t,{params:e,...null==r?void 0:r.requestOptions})}async updateOne(t,e,r,s){return(await this.transport.patch(`${this.endpoint}/${encodeURI(t)}`,e,{params:r,...null==s?void 0:s.requestOptions})).data}async updateMany(t,e,r,s){return await this.transport.patch(`${this.endpoint}`,{keys:t,data:e},{params:r,...null==s?void 0:s.requestOptions})}async updateByQuery(t,e,r,s){return await this.transport.patch(`${this.endpoint}`,{query:t,data:e},{params:r,...null==s?void 0:s.requestOptions})}async deleteOne(t,e){await this.transport.delete(`${this.endpoint}/${encodeURI(t)}`,void 0,null==e?void 0:e.requestOptions)}async deleteMany(t,e){await this.transport.delete(`${this.endpoint}`,t,null==e?void 0:e.requestOptions)}}class r{constructor(t){this.transport=t}async create(t){return(await this.transport.post("/activity/comment",t)).data}async update(t,e){return(await this.transport.patch(`/activity/comment/${encodeURI(t)}`,{comment:e})).data}async delete(t){await this.transport.delete(`/activity/comment/${encodeURI(t)}`)}}class s extends e{constructor(t){super("directus_activity",t),this._comments=new r(this.transport)}get comments(){return this._comments}}class n{constructor(t){this.transport=t}async readOne(t){return(await this.transport.get(`/collections/${t}`)).data}async readAll(){const{data:t,meta:e}=await this.transport.get("/collections");return{data:t,meta:e}}async createOne(t){return(await this.transport.post("/collections",t)).data}async createMany(t){const{data:e,meta:r}=await this.transport.post("/collections",t);return{data:e,meta:r}}async updateOne(t,e,r){return(await this.transport.patch(`/collections/${t}`,e,{params:r})).data}async deleteOne(t){await this.transport.delete(`/collections/${t}`)}}class a{constructor(t){this.transport=t}async readOne(t,e){return(await this.transport.get(`/fields/${t}/${e}`)).data}async readMany(t){return(await this.transport.get(`/fields/${t}`)).data}async readAll(){return(await this.transport.get("/fields")).data}async createOne(t,e){return(await this.transport.post(`/fields/${t}`,e)).data}async updateOne(t,e,r){return(await this.transport.patch(`/fields/${t}/${e}`,r)).data}async deleteOne(t,e){await this.transport.delete(`/fields/${t}/${e}`)}}class o extends e{constructor(t){super("directus_files",t)}}class i extends e{constructor(t){super("directus_folders",t)}}class u extends e{constructor(t){super("directus_permissions",t)}}class c extends e{constructor(t){super("directus_presets",t)}}class h{constructor(t){this.transport=t}async readOne(t,e){return(await this.transport.get(`/relations/${t}/${e}`)).data}async readMany(t){return(await this.transport.get(`/relations/${t}`)).data}async readAll(){return(await this.transport.get("/relations")).data}async createOne(t){return(await this.transport.post("/relations",t)).data}async updateOne(t,e,r){return(await this.transport.patch(`/relations/${t}/${e}`,{params:r})).data}async deleteOne(t,e){await this.transport.delete(`/relations/${t}/${e}`)}}class l extends e{constructor(t){super("directus_revisions",t)}}class p extends e{constructor(t){super("directus_roles",t)}}class d{constructor(t){this.transport=t}async ping(){return(await this.transport.get("/server/ping")).raw}async info(){return(await this.transport.get("/server/info")).data}}class f{constructor(t,e){this.collection=t,this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}async read(t){return(await this.transport.get(`${this.endpoint}`,{params:t})).data}async update(t,e){return(await this.transport.patch(`${this.endpoint}`,t,{params:e})).data}}class g extends f{constructor(t){super("directus_settings",t)}}class m{constructor(t){this.transport=t}async send(t,e,r){await this.transport.post("/users/invite",{email:t,role:e,invite_url:r})}async accept(t,e){await this.transport.post("/users/invite/accept",{token:t,password:e})}}class v{constructor(t){this.transport=t}async generate(t){return(await this.transport.post("/users/me/tfa/generate",{password:t})).data}async enable(t,e){await this.transport.post("/users/me/tfa/enable",{secret:t,otp:e})}async disable(t){await this.transport.post("/users/me/tfa/disable",{otp:t})}}class y{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new v(this._transport))}async read(t){return(await this._transport.get("/users/me",{params:t})).data}async update(t,e){return(await this._transport.patch("/users/me",t,{params:e})).data}}class _ extends e{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new m(this.transport))}get me(){return this._me||(this._me=new y(this.transport))}}class w{constructor(t){this.random={string:async(t=32)=>(await this.transport.get("/utils/random/string",{params:{length:t}})).data},this.hash={generate:async t=>(await this.transport.post("/utils/hash/generate",{string:t})).data,verify:async(t,e)=>(await this.transport.post("/utils/hash/verify",{string:t,hash:e})).data},this.transport=t}async sort(t,e,r){await this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:e,to:r})}async revert(t){await this.transport.post(`/utils/revert/${encodeURI(t)}`)}}var x,b;!function(t){t.TOTAL_COUNT="total_count",t.FILTER_COUNT="filter_count"}(x||(x={}));class k{}class O{}class E extends Error{constructor(t,e){var r,s;(null===(r=null==e?void 0:e.errors)||void 0===r?void 0:r.length)?super(null===(s=null==e?void 0:e.errors[0])||void 0===s?void 0:s.message):super((null==t?void 0:t.message)||"Unknown transport error"),this.parent=t,this.response=e,this.errors=(null==e?void 0:e.errors)||[],Object.values(e||{}).some((t=>void 0!==t))||(this.response=void 0),Object.setPrototypeOf(this,E.prototype)}}!function(t){t.AuthToken="auth_token",t.RefreshToken="auth_refresh_token",t.Expires="auth_expires",t.ExpiresAt="auth_expires_at"}(b||(b={}));class S extends k{constructor(t){var e;super(),this.prefix=null!==(e=null==t?void 0:t.prefix)&&void 0!==e?e:""}get auth_token(){return this.get(b.AuthToken)}set auth_token(t){null===t?this.delete(b.AuthToken):this.set(b.AuthToken,t)}get auth_expires(){const t=this.get(b.Expires);return null===t?null:parseInt(t)}set auth_expires(t){null===t?this.delete(b.Expires):this.set(b.Expires,t.toString())}get auth_expires_at(){const t=this.get(b.ExpiresAt);return null===t?null:parseInt(t)}set auth_expires_at(t){null===t?this.delete(b.ExpiresAt):this.set(b.ExpiresAt,t.toString())}get auth_refresh_token(){return this.get(b.RefreshToken)}set auth_refresh_token(t){null===t?this.delete(b.RefreshToken):this.set(b.RefreshToken,t)}}class R extends S{constructor(){super(...arguments),this.values={}}get(t){const e=this.key(t);return e in this.values?this.values[e]:null}set(t,e){return this.values[this.key(t)]=e,e}delete(t){const e=this.key(t),r=this.get(t);return e in this.values&&delete this.values[e],r}key(t){return`${this.prefix}${t}`}}class T extends S{get(t){const e=localStorage.getItem(this.key(t));return null!==e?e:null}set(t,e){return localStorage.setItem(this.key(t),e),e}delete(t){const e=this.key(t),r=this.get(e);return r&&localStorage.removeItem(e),r}key(t){return`${this.prefix}${t}`}}var q={exports:{}},A=function(t,e){return function(){for(var r=new Array(arguments.length),s=0;s<r.length;s++)r[s]=arguments[s];return t.apply(e,r)}},$=A,j=Object.prototype.toString;function U(t){return"[object Array]"===j.call(t)}function C(t){return void 0===t}function N(t){return null!==t&&"object"==typeof t}function P(t){if("[object Object]"!==j.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function B(t){return"[object Function]"===j.call(t)}function L(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),U(t))for(var r=0,s=t.length;r<s;r++)e.call(null,t[r],r,t);else for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.call(null,t[n],n,t)}var I={isArray:U,isArrayBuffer:function(t){return"[object ArrayBuffer]"===j.call(t)},isBuffer:function(t){return null!==t&&!C(t)&&null!==t.constructor&&!C(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:N,isPlainObject:P,isUndefined:C,isDate:function(t){return"[object Date]"===j.call(t)},isFile:function(t){return"[object File]"===j.call(t)},isBlob:function(t){return"[object Blob]"===j.call(t)},isFunction:B,isStream:function(t){return N(t)&&B(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:L,merge:function t(){var e={};function r(r,s){P(e[s])&&P(r)?e[s]=t(e[s],r):P(r)?e[s]=t({},r):U(r)?e[s]=r.slice():e[s]=r}for(var s=0,n=arguments.length;s<n;s++)L(arguments[s],r);return e},extend:function(t,e,r){return L(e,(function(e,s){t[s]=r&&"function"==typeof e?$(e,r):e})),t},trim:function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t}},D=I;function M(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var F=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(D.isURLSearchParams(e))s=e.toString();else{var n=[];D.forEach(e,(function(t,e){null!=t&&(D.isArray(t)?e+="[]":t=[t],D.forEach(t,(function(t){D.isDate(t)?t=t.toISOString():D.isObject(t)&&(t=JSON.stringify(t)),n.push(M(e)+"="+M(t))})))})),s=n.join("&")}if(s){var a=t.indexOf("#");-1!==a&&(t=t.slice(0,a)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t},J=I;function z(){this.handlers=[]}z.prototype.use=function(t,e,r){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},z.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},z.prototype.forEach=function(t){J.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var H=z,W=I,V=function(t,e,r,s,n){return t.config=e,r&&(t.code=r),t.request=s,t.response=n,t.isAxiosError=!0,t.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},t},X=V,K=function(t,e,r,s,n){var a=new Error(t);return X(a,e,r,s,n)},Q=K,G=I,Y=G.isStandardBrowserEnv()?{write:function(t,e,r,s,n,a){var o=[];o.push(t+"="+encodeURIComponent(e)),G.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),G.isString(s)&&o.push("path="+s),G.isString(n)&&o.push("domain="+n),!0===a&&o.push("secure"),document.cookie=o.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},Z=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)},tt=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t},et=I,rt=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],st=I,nt=st.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function s(t){var s=t;return e&&(r.setAttribute("href",s),s=r.href),r.setAttribute("href",s),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return t=s(window.location.href),function(e){var r=st.isString(e)?s(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0};function at(t){this.message=t}at.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},at.prototype.__CANCEL__=!0;var ot=at,it=I,ut=function(t,e,r){var s=r.config.validateStatus;r.status&&s&&!s(r.status)?e(Q("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)},ct=Y,ht=F,lt=function(t,e){return t&&!Z(e)?tt(t,e):e},pt=function(t){var e,r,s,n={};return t?(et.forEach(t.split("\n"),(function(t){if(s=t.indexOf(":"),e=et.trim(t.substr(0,s)).toLowerCase(),r=et.trim(t.substr(s+1)),e){if(n[e]&&rt.indexOf(e)>=0)return;n[e]="set-cookie"===e?(n[e]?n[e]:[]).concat([r]):n[e]?n[e]+", "+r:r}})),n):n},dt=nt,ft=K,gt=Et,mt=ot,vt=function(t){return new Promise((function(e,r){var s,n=t.data,a=t.headers,o=t.responseType;function i(){t.cancelToken&&t.cancelToken.unsubscribe(s),t.signal&&t.signal.removeEventListener("abort",s)}it.isFormData(n)&&delete a["Content-Type"];var u=new XMLHttpRequest;if(t.auth){var c=t.auth.username||"",h=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";a.Authorization="Basic "+btoa(c+":"+h)}var l=lt(t.baseURL,t.url);function p(){if(u){var s="getAllResponseHeaders"in u?pt(u.getAllResponseHeaders()):null,n={data:o&&"text"!==o&&"json"!==o?u.response:u.responseText,status:u.status,statusText:u.statusText,headers:s,config:t,request:u};ut((function(t){e(t),i()}),(function(t){r(t),i()}),n),u=null}}if(u.open(t.method.toUpperCase(),ht(l,t.params,t.paramsSerializer),!0),u.timeout=t.timeout,"onloadend"in u?u.onloadend=p:u.onreadystatechange=function(){u&&4===u.readyState&&(0!==u.status||u.responseURL&&0===u.responseURL.indexOf("file:"))&&setTimeout(p)},u.onabort=function(){u&&(r(ft("Request aborted",t,"ECONNABORTED",u)),u=null)},u.onerror=function(){r(ft("Network Error",t,null,u)),u=null},u.ontimeout=function(){var e=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",s=t.transitional||gt.transitional;t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(ft(e,t,s.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",u)),u=null},it.isStandardBrowserEnv()){var d=(t.withCredentials||dt(l))&&t.xsrfCookieName?ct.read(t.xsrfCookieName):void 0;d&&(a[t.xsrfHeaderName]=d)}"setRequestHeader"in u&&it.forEach(a,(function(t,e){void 0===n&&"content-type"===e.toLowerCase()?delete a[e]:u.setRequestHeader(e,t)})),it.isUndefined(t.withCredentials)||(u.withCredentials=!!t.withCredentials),o&&"json"!==o&&(u.responseType=t.responseType),"function"==typeof t.onDownloadProgress&&u.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&u.upload&&u.upload.addEventListener("progress",t.onUploadProgress),(t.cancelToken||t.signal)&&(s=function(t){u&&(r(!t||t&&t.type?new mt("canceled"):t),u.abort(),u=null)},t.cancelToken&&t.cancelToken.subscribe(s),t.signal&&(t.signal.aborted?s():t.signal.addEventListener("abort",s))),n||(n=null),u.send(n)}))},yt=I,_t=function(t,e){W.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},wt=V,xt={"Content-Type":"application/x-www-form-urlencoded"};function bt(t,e){!yt.isUndefined(t)&&yt.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var kt,Ot={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(kt=vt),kt),transformRequest:[function(t,e){return _t(e,"Accept"),_t(e,"Content-Type"),yt.isFormData(t)||yt.isArrayBuffer(t)||yt.isBuffer(t)||yt.isStream(t)||yt.isFile(t)||yt.isBlob(t)?t:yt.isArrayBufferView(t)?t.buffer:yt.isURLSearchParams(t)?(bt(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):yt.isObject(t)||e&&"application/json"===e["Content-Type"]?(bt(e,"application/json"),function(t,e,r){if(yt.isString(t))try{return(e||JSON.parse)(t),yt.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(r||JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){var e=this.transitional||Ot.transitional,r=e&&e.silentJSONParsing,s=e&&e.forcedJSONParsing,n=!r&&"json"===this.responseType;if(n||s&&yt.isString(t)&&t.length)try{return JSON.parse(t)}catch(t){if(n){if("SyntaxError"===t.name)throw wt(t,this,"E_JSON_PARSE");throw t}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};yt.forEach(["delete","get","head"],(function(t){Ot.headers[t]={}})),yt.forEach(["post","put","patch"],(function(t){Ot.headers[t]=yt.merge(xt)}));var Et=Ot,St=I,Rt=Et,Tt=function(t){return!(!t||!t.__CANCEL__)},qt=I,At=function(t,e,r){var s=this||Rt;return St.forEach(r,(function(r){t=r.call(s,t,e)})),t},$t=Tt,jt=Et,Ut=ot;function Ct(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Ut("canceled")}var Nt=I,Pt=function(t,e){e=e||{};var r={};function s(t,e){return Nt.isPlainObject(t)&&Nt.isPlainObject(e)?Nt.merge(t,e):Nt.isPlainObject(e)?Nt.merge({},e):Nt.isArray(e)?e.slice():e}function n(r){return Nt.isUndefined(e[r])?Nt.isUndefined(t[r])?void 0:s(void 0,t[r]):s(t[r],e[r])}function a(t){if(!Nt.isUndefined(e[t]))return s(void 0,e[t])}function o(r){return Nt.isUndefined(e[r])?Nt.isUndefined(t[r])?void 0:s(void 0,t[r]):s(void 0,e[r])}function i(r){return r in e?s(t[r],e[r]):r in t?s(void 0,t[r]):void 0}var u={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:i};return Nt.forEach(Object.keys(t).concat(Object.keys(e)),(function(t){var e=u[t]||n,s=e(t);Nt.isUndefined(s)&&e!==i||(r[t]=s)})),r},Bt="0.24.0",Lt=Bt,It={};["object","boolean","number","function","string","symbol"].forEach((function(t,e){It[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}}));var Dt={};It.transitional=function(t,e,r){function s(t,e){return"[Axios v"+Lt+"] Transitional option '"+t+"'"+e+(r?". "+r:"")}return function(r,n,a){if(!1===t)throw new Error(s(n," has been removed"+(e?" in "+e:"")));return e&&!Dt[n]&&(Dt[n]=!0,console.warn(s(n," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(r,n,a)}};var Mt={assertOptions:function(t,e,r){if("object"!=typeof t)throw new TypeError("options must be an object");for(var s=Object.keys(t),n=s.length;n-- >0;){var a=s[n],o=e[a];if(o){var i=t[a],u=void 0===i||o(i,a,t);if(!0!==u)throw new TypeError("option "+a+" must be "+u)}else if(!0!==r)throw Error("Unknown option "+a)}},validators:It},Ft=I,Jt=F,zt=H,Ht=function(t){return Ct(t),t.headers=t.headers||{},t.data=At.call(t,t.data,t.headers,t.transformRequest),t.headers=qt.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),qt.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||jt.adapter)(t).then((function(e){return Ct(t),e.data=At.call(t,e.data,e.headers,t.transformResponse),e}),(function(e){return $t(e)||(Ct(t),e&&e.response&&(e.response.data=At.call(t,e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},Wt=Pt,Vt=Mt,Xt=Vt.validators;function Kt(t){this.defaults=t,this.interceptors={request:new zt,response:new zt}}Kt.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=Wt(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=t.transitional;void 0!==e&&Vt.assertOptions(e,{silentJSONParsing:Xt.transitional(Xt.boolean),forcedJSONParsing:Xt.transitional(Xt.boolean),clarifyTimeoutError:Xt.transitional(Xt.boolean)},!1);var r=[],s=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(s=s&&e.synchronous,r.unshift(e.fulfilled,e.rejected))}));var n,a=[];if(this.interceptors.response.forEach((function(t){a.push(t.fulfilled,t.rejected)})),!s){var o=[Ht,void 0];for(Array.prototype.unshift.apply(o,r),o=o.concat(a),n=Promise.resolve(t);o.length;)n=n.then(o.shift(),o.shift());return n}for(var i=t;r.length;){var u=r.shift(),c=r.shift();try{i=u(i)}catch(t){c(t);break}}try{n=Ht(i)}catch(t){return Promise.reject(t)}for(;a.length;)n=n.then(a.shift(),a.shift());return n},Kt.prototype.getUri=function(t){return t=Wt(this.defaults,t),Jt(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},Ft.forEach(["delete","get","head","options"],(function(t){Kt.prototype[t]=function(e,r){return this.request(Wt(r||{},{method:t,url:e,data:(r||{}).data}))}})),Ft.forEach(["post","put","patch"],(function(t){Kt.prototype[t]=function(e,r,s){return this.request(Wt(s||{},{method:t,url:e,data:r}))}}));var Qt=Kt,Gt=ot;function Yt(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var r=this;this.promise.then((function(t){if(r._listeners){var e,s=r._listeners.length;for(e=0;e<s;e++)r._listeners[e](t);r._listeners=null}})),this.promise.then=function(t){var e,s=new Promise((function(t){r.subscribe(t),e=t})).then(t);return s.cancel=function(){r.unsubscribe(e)},s},t((function(t){r.reason||(r.reason=new Gt(t),e(r.reason))}))}Yt.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},Yt.prototype.subscribe=function(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]},Yt.prototype.unsubscribe=function(t){if(this._listeners){var e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}},Yt.source=function(){var t;return{token:new Yt((function(e){t=e})),cancel:t}};var Zt=Yt,te=I,ee=A,re=Qt,se=Pt;var ne=function t(e){var r=new re(e),s=ee(re.prototype.request,r);return te.extend(s,re.prototype,r),te.extend(s,r),s.create=function(r){return t(se(e,r))},s}(Et);ne.Axios=re,ne.Cancel=ot,ne.CancelToken=Zt,ne.isCancel=Tt,ne.VERSION=Bt,ne.all=function(t){return Promise.all(t)},ne.spread=function(t){return function(e){return t.apply(null,e)}},ne.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError},q.exports=ne,q.exports.default=ne;var ae=q.exports;class oe extends O{constructor(t){var e;super(),this.config=t,this.axios=ae.create({baseURL:this.config.url,params:this.config.params,headers:this.config.headers,onUploadProgress:this.config.onUploadProgress,withCredentials:!0}),(null===(e=this.config)||void 0===e?void 0:e.beforeRequest)&&(this.beforeRequest=this.config.beforeRequest)}async beforeRequest(t){return t}get url(){return this.config.url}async request(t,e,r,s){var n,a,o,i,u;try{let n={method:t,url:e,data:r,params:null==s?void 0:s.params,headers:null==s?void 0:s.headers,onUploadProgress:null==s?void 0:s.onUploadProgress};n=await this.beforeRequest(n);const a=await this.axios.request(n),o={raw:a.data,status:a.status,statusText:a.statusText,headers:a.headers,data:a.data.data,meta:a.data.meta,errors:a.data.errors};if(a.data.errors)throw new E(null,o);return o}catch(t){if(!t||t instanceof Error==!1)throw t;if(ae.isAxiosError(t)){const e=null===(n=t.response)||void 0===n?void 0:n.data;throw new E(t,{raw:null===(a=t.response)||void 0===a?void 0:a.data,status:null===(o=t.response)||void 0===o?void 0:o.status,statusText:null===(i=t.response)||void 0===i?void 0:i.statusText,headers:null===(u=t.response)||void 0===u?void 0:u.headers,data:null==e?void 0:e.data,meta:null==e?void 0:e.meta,errors:null==e?void 0:e.errors})}throw new E(t)}}async get(t,e){return await this.request("get",t,void 0,e)}async head(t,e){return await this.request("head",t,void 0,e)}async options(t,e){return await this.request("options",t,void 0,e)}async delete(t,e,r){return await this.request("delete",t,e,r)}async put(t,e,r){return await this.request("put",t,e,r)}async post(t,e,r){return await this.request("post",t,e,r)}async patch(t,e,r){return await this.request("patch",t,e,r)}}class ie{constructor(t){this.transport=t}async request(t,e){await this.transport.post("/auth/password/request",{email:t,reset_url:e})}async reset(t,e){await this.transport.post("/auth/password/reset",{token:t,password:e})}}class ue extends t{constructor(t){var e,r;super(),this.autoRefresh=!0,this.staticToken="",this._transport=t.transport,this._storage=t.storage,this.autoRefresh=null!==(e=null==t?void 0:t.autoRefresh)&&void 0!==e?e:this.autoRefresh,this.mode=null!==(r=null==t?void 0:t.mode)&&void 0!==r?r:this.mode,(null==t?void 0:t.staticToken)&&(this.staticToken=null==t?void 0:t.staticToken,this.updateStorage({access_token:this.staticToken,expires:null,refresh_token:null}))}get storage(){return this._storage}get transport(){return this._transport}get token(){return this._storage.auth_token}get password(){return this.passwords=this.passwords||new ie(this._transport)}resetStorage(){this._storage.auth_token=null,this._storage.auth_refresh_token=null,this._storage.auth_expires=null,this._storage.auth_expires_at=null}updateStorage(t){var e,r;const s=null!==(e=t.expires)&&void 0!==e?e:null;this._storage.auth_token=t.access_token,this._storage.auth_refresh_token=null!==(r=t.refresh_token)&&void 0!==r?r:null,this._storage.auth_expires=s,this._storage.auth_expires_at=(new Date).getTime()+(null!=s?s:0)}async refreshIfExpired(){this.staticToken||this.autoRefresh&&this._storage.auth_expires_at&&this._storage.auth_expires_at<(new Date).getTime()&&await this.refresh().catch((()=>{}))}async refresh(){var t;const e=this._storage.auth_refresh_token;this.resetStorage();const r=await this._transport.post("/auth/refresh",{refresh_token:"json"===this.mode?e:void 0});return this.updateStorage(r.data),this.autoRefresh&&this.refreshIfExpired(),{access_token:r.data.access_token,refresh_token:null===(t=r.data)||void 0===t?void 0:t.refresh_token,expires:r.data.expires}}async login(t){var e;this.resetStorage();const r=await this._transport.post("/auth/login",{mode:this.mode,...t},{headers:{Authorization:null}});return this.updateStorage(r.data),this.autoRefresh&&this.refreshIfExpired(),{access_token:r.data.access_token,refresh_token:null===(e=r.data)||void 0===e?void 0:e.refresh_token,expires:r.data.expires}}async static(t){return await this._transport.get("/users/me",{params:{access_token:t},headers:{Authorization:null}}),this.updateStorage({access_token:t,expires:null,refresh_token:null}),!0}async logout(){let t;"json"===this.mode&&(t=this._storage.auth_refresh_token||void 0),await this._transport.post("/auth/logout",{refresh_token:t}),this.updateStorage({access_token:null,expires:null,refresh_token:null})}}class ce{constructor(t){this.transport=t}async request(t,e,r){return await this.transport.post(t,{query:e,variables:void 0===r?{}:r})}async items(t,e){return await this.request("/graphql",t,e)}async system(t,e){return await this.request("/graphql/system",t,e)}}class he{constructor(e,r){var s,n,a,o,i,u,c,h,l;if(this._url=e,this._options=r,this._items={},this._singletons={},(null===(s=this._options)||void 0===s?void 0:s.storage)&&(null===(n=this._options)||void 0===n?void 0:n.storage)instanceof k)this._storage=this._options.storage;else{const t=null===(a=this._options)||void 0===a?void 0:a.storage,{mode:e,...r}=null!=t?t:{};"MemoryStorage"===e||"undefined"==typeof window?this._storage=new R(r):this._storage=new T(r)}(null===(o=this._options)||void 0===o?void 0:o.transport)&&(null===(i=this._options)||void 0===i?void 0:i.transport)instanceof O?this._transport=this._options.transport:this._transport=new oe({url:this.url,beforeRequest:async t=>{await this._auth.refreshIfExpired();const e=this.storage.auth_token,r=e?e.startsWith("Bearer ")?String(this.storage.auth_token):`Bearer ${this.storage.auth_token}`:"";return{...t,headers:{Authorization:r,...t.headers}}},...null===(u=this._options)||void 0===u?void 0:u.transport}),(null===(c=this._options)||void 0===c?void 0:c.auth)&&(null===(h=this._options)||void 0===h?void 0:h.auth)instanceof t?this._auth=this._options.auth:this._auth=new ue({transport:this._transport,storage:this._storage,...null===(l=this._options)||void 0===l?void 0:l.auth})}get url(){return this._url}get auth(){return this._auth}get storage(){return this._storage}get transport(){return this._transport}get activity(){return this._activity||(this._activity=new s(this.transport))}get collections(){return this._collections||(this._collections=new n(this.transport))}get fields(){return this._fields||(this._fields=new a(this.transport))}get files(){return this._files||(this._files=new o(this.transport))}get folders(){return this._folders||(this._folders=new i(this.transport))}get permissions(){return this._permissions||(this._permissions=new u(this.transport))}get presets(){return this._presets||(this._presets=new c(this.transport))}get relations(){return this._relations||(this._relations=new h(this.transport))}get revisions(){return this._revisions||(this._revisions=new l(this.transport))}get roles(){return this._roles||(this._roles=new p(this.transport))}get users(){return this._users||(this._users=new _(this.transport))}get settings(){return this._settings||(this._settings=new g(this.transport))}get server(){return this._server||(this._server=new d(this.transport))}get utils(){return this._utils||(this._utils=new w(this.transport))}get graphql(){return this._graphql||(this._graphql=new ce(this.transport))}singleton(t){return this._singletons[t]||(this._singletons[t]=new f(t,this.transport))}items(t){return this._items[t]||(this._items[t]=new e(t,this.transport))}}export{s as ActivityHandler,ue as Auth,S as BaseStorage,n as CollectionsHandler,r as CommentsHandler,he as Directus,a as FieldsHandler,o as FilesHandler,i as FoldersHandler,t as IAuth,k as IStorage,O as ITransport,e as ItemsHandler,T as LocalStorage,R as MemoryStorage,x as Meta,u as PermissionsHandler,c as PresetsHandler,h as RelationsHandler,l as RevisionsHandler,p as RolesHandler,d as ServerHandler,g as SettingsHandler,oe as Transport,E as TransportError,_ as UsersHandler,w as UtilsHandler}; | ||
//# sourceMappingURL=sdk.esm.min.js.map |
@@ -1,2 +0,2 @@ | ||
var DirectusSdk=function(t,e){"use strict";function n(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=n(e),o=function(){this.mode="undefined"==typeof window?"json":"cookie"},i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},i(t,e)};function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var u=function(){return u=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},u.apply(this,arguments)};function a(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{a(r.next(t))}catch(t){i(t)}}function u(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,u)}a((r=r.apply(t,e||[])).next())}))}function c(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var h,l=function(){function t(t,e){this.collection=t,this.transport=e,this.endpoint=t.startsWith("directus_")?"/".concat(t.substring(9)):"/items/".concat(t)}return t.prototype.readOne=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.get("".concat(this.endpoint,"/").concat(encodeURI(t)),{params:e})];case 1:return[2,n.sent().data]}}))}))},t.prototype.readMany=function(t,e){var n;return a(this,void 0,void 0,(function(){var r,o,i,s,a,h;return c(this,(function(c){switch(c.label){case 0:return[4,this.transport.get("/fields/".concat(this.collection))];case 1:return r=c.sent(),o=null===(n=r.data)||void 0===n?void 0:n.find((function(t){return!0===t.schema.is_primary_key})),[4,this.transport.get("".concat(this.endpoint),{params:u({filter:u((h={},h[o.field]={_in:t},h),null==e?void 0:e.filter),sort:(null==e?void 0:e.sort)||o.field},e)})];case 2:return i=c.sent(),s=i.data,a=i.meta,[2,{data:s,meta:a}]}}))}))},t.prototype.readByQuery=function(t){return a(this,void 0,void 0,(function(){var e,n,r;return c(this,(function(o){switch(o.label){case 0:return[4,this.transport.get("".concat(this.endpoint),{params:t})];case 1:return e=o.sent(),n=e.data,r=e.meta,[2,{data:n,meta:r}]}}))}))},t.prototype.createOne=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.post("".concat(this.endpoint),t,{params:e})];case 1:return[2,n.sent().data]}}))}))},t.prototype.createMany=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.post("".concat(this.endpoint),t,{params:e})];case 1:return[2,n.sent()]}}))}))},t.prototype.updateOne=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.transport.patch("".concat(this.endpoint,"/").concat(encodeURI(t)),e,{params:n})];case 1:return[2,r.sent().data]}}))}))},t.prototype.updateMany=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.transport.patch("".concat(this.endpoint),{keys:t,data:e},{params:n})];case 1:return[2,r.sent()]}}))}))},t.prototype.updateByQuery=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.transport.patch("".concat(this.endpoint),{query:t,data:e},{params:n})];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteOne=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.delete("".concat(this.endpoint,"/").concat(encodeURI(t)))];case 1:return e.sent(),[2]}}))}))},t.prototype.deleteMany=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.delete("".concat(this.endpoint),t)];case 1:return e.sent(),[2]}}))}))},t}(),p=function(){function t(t){this.transport=t}return t.prototype.create=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/activity/comment",t)];case 1:return[2,e.sent().data]}}))}))},t.prototype.update=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.patch("/activity/comment/".concat(encodeURI(t)),{comment:e})];case 1:return[2,n.sent().data]}}))}))},t.prototype.delete=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.delete("/activity/comment/".concat(encodeURI(t)))];case 1:return e.sent(),[2]}}))}))},t}(),f=function(t){function e(e){var n=t.call(this,"directus_activity",e)||this;return n._comments=new p(n.transport),n}return s(e,t),Object.defineProperty(e.prototype,"comments",{get:function(){return this._comments},enumerable:!1,configurable:!0}),e}(l),d=function(){function t(t){this.transport=t}return t.prototype.readOne=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.get("/collections/".concat(t))];case 1:return[2,e.sent().data]}}))}))},t.prototype.readAll=function(){return a(this,void 0,void 0,(function(){var t,e,n;return c(this,(function(r){switch(r.label){case 0:return[4,this.transport.get("/collections")];case 1:return t=r.sent(),e=t.data,n=t.meta,[2,{data:e,meta:n}]}}))}))},t.prototype.createOne=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/collections",t)];case 1:return[2,e.sent().data]}}))}))},t.prototype.createMany=function(t){return a(this,void 0,void 0,(function(){var e,n,r;return c(this,(function(o){switch(o.label){case 0:return[4,this.transport.post("/collections",t)];case 1:return e=o.sent(),n=e.data,r=e.meta,[2,{data:n,meta:r}]}}))}))},t.prototype.updateOne=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.transport.patch("/collections/".concat(t),e,{params:n})];case 1:return[2,r.sent().data]}}))}))},t.prototype.deleteOne=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.delete("/collections/".concat(t))];case 1:return e.sent(),[2]}}))}))},t}(),v=function(){function t(t){this.transport=t}return t.prototype.readOne=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.get("/fields/".concat(t,"/").concat(e))];case 1:return[2,n.sent().data]}}))}))},t.prototype.readMany=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.get("/fields/".concat(t))];case 1:return[2,e.sent().data]}}))}))},t.prototype.readAll=function(){return a(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this.transport.get("/fields")];case 1:return[2,t.sent().data]}}))}))},t.prototype.createOne=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.post("/fields/".concat(t),e)];case 1:return[2,n.sent().data]}}))}))},t.prototype.updateOne=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.transport.patch("/fields/".concat(t,"/").concat(e),n)];case 1:return[2,r.sent().data]}}))}))},t.prototype.deleteOne=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.delete("/fields/".concat(t,"/").concat(e))];case 1:return n.sent(),[2]}}))}))},t}(),y=function(t){function e(e){return t.call(this,"directus_files",e)||this}return s(e,t),e}(l),b=function(t){function e(e){return t.call(this,"directus_folders",e)||this}return s(e,t),e}(l),g=function(t){function e(e){return t.call(this,"directus_permissions",e)||this}return s(e,t),e}(l),_=function(t){function e(e){return t.call(this,"directus_presets",e)||this}return s(e,t),e}(l),m=function(){function t(t){this.transport=t}return t.prototype.readOne=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.get("/relations/".concat(t,"/").concat(e))];case 1:return[2,n.sent().data]}}))}))},t.prototype.readMany=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.get("/relations/".concat(t))];case 1:return[2,e.sent().data]}}))}))},t.prototype.readAll=function(){return a(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this.transport.get("/relations")];case 1:return[2,t.sent().data]}}))}))},t.prototype.createOne=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/relations",t)];case 1:return[2,e.sent().data]}}))}))},t.prototype.updateOne=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.transport.patch("/relations/".concat(t,"/").concat(e),{params:n})];case 1:return[2,r.sent().data]}}))}))},t.prototype.deleteOne=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.delete("/relations/".concat(t,"/").concat(e))];case 1:return n.sent(),[2]}}))}))},t}(),w=function(t){function e(e){return t.call(this,"directus_revisions",e)||this}return s(e,t),e}(l),O=function(t){function e(e){return t.call(this,"directus_roles",e)||this}return s(e,t),e}(l),k=function(){function t(t){this.transport=t}return t.prototype.ping=function(){return a(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this.transport.get("/server/ping")];case 1:return[2,t.sent().raw]}}))}))},t.prototype.info=function(){return a(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this.transport.get("/server/info")];case 1:return[2,t.sent().data]}}))}))},t}(),j=function(){function t(t,e){this.collection=t,this.transport=e,this.endpoint=t.startsWith("directus_")?"/".concat(t.substring(9)):"/items/".concat(t)}return t.prototype.read=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.get("".concat(this.endpoint),{params:t})];case 1:return[2,e.sent().data]}}))}))},t.prototype.update=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.patch("".concat(this.endpoint),t,{params:e})];case 1:return[2,n.sent().data]}}))}))},t}(),P=function(t){function e(e){return t.call(this,"directus_settings",e)||this}return s(e,t),e}(j),x=function(){function t(t){this.transport=t}return t.prototype.send=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.transport.post("/users/invite",{email:t,role:e,invite_url:n})];case 1:return r.sent(),[2]}}))}))},t.prototype.accept=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.post("/users/invite/accept",{token:t,password:e})];case 1:return n.sent(),[2]}}))}))},t}(),R=function(){function t(t){this.transport=t}return t.prototype.generate=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/users/me/tfa/generate",{password:t})];case 1:return[2,e.sent().data]}}))}))},t.prototype.enable=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.post("/users/me/tfa/enable",{secret:t,otp:e})];case 1:return n.sent(),[2]}}))}))},t.prototype.disable=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/users/me/tfa/disable",{otp:t})];case 1:return e.sent(),[2]}}))}))},t}(),T=function(){function t(t){this._transport=t}return Object.defineProperty(t.prototype,"tfa",{get:function(){return this._tfa||(this._tfa=new R(this._transport))},enumerable:!1,configurable:!0}),t.prototype.read=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this._transport.get("/users/me",{params:t})];case 1:return[2,e.sent().data]}}))}))},t.prototype.update=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this._transport.patch("/users/me",t,{params:e})];case 1:return[2,n.sent().data]}}))}))},t}(),q=function(t){function e(e){return t.call(this,"directus_users",e)||this}return s(e,t),Object.defineProperty(e.prototype,"invites",{get:function(){return this._invites||(this._invites=new x(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"me",{get:function(){return this._me||(this._me=new T(this.transport))},enumerable:!1,configurable:!0}),e}(l),S=function(){function t(t){var e=this;this.random={string:function(t){return void 0===t&&(t=32),a(e,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.get("/utils/random/string",{params:{length:t}})];case 1:return[2,e.sent().data]}}))}))}},this.hash={generate:function(t){return a(e,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/utils/hash/generate",{string:t})];case 1:return[2,e.sent().data]}}))}))},verify:function(t,n){return a(e,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/utils/hash/verify",{string:t,hash:n})];case 1:return[2,e.sent().data]}}))}))}},this.transport=t}return t.prototype.sort=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.transport.post("/utils/sort/".concat(encodeURI(t)),{item:e,to:n})];case 1:return r.sent(),[2]}}))}))},t.prototype.revert=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/utils/revert/".concat(encodeURI(t)))];case 1:return e.sent(),[2]}}))}))},t}();t.Meta=void 0,(h=t.Meta||(t.Meta={})).TOTAL_COUNT="total_count",h.FILTER_COUNT="filter_count";var E,I=function(){},U=function(){},A=function(t){function e(n,r){var o,i,s=this;return(s=(null===(o=null==r?void 0:r.errors)||void 0===o?void 0:o.length)?t.call(this,null===(i=null==r?void 0:r.errors[0])||void 0===i?void 0:i.message)||this:t.call(this,(null==n?void 0:n.message)||"Unknown transport error")||this).parent=n,s.response=r,s.errors=(null==r?void 0:r.errors)||[],Object.values(r||{}).some((function(t){return void 0!==t}))||(s.response=void 0),Object.setPrototypeOf(s,e.prototype),s}return s(e,t),e}(Error);!function(t){t.AuthToken="auth_token",t.RefreshToken="auth_refresh_token",t.Expires="auth_expires"}(E||(E={}));var H=function(t){function e(e){var n,r=t.call(this)||this;return r.prefix=null!==(n=null==e?void 0:e.prefix)&&void 0!==n?n:"",r}return s(e,t),Object.defineProperty(e.prototype,"auth_token",{get:function(){return this.get(E.AuthToken)},set:function(t){null===t?this.delete(E.AuthToken):this.set(E.AuthToken,t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"auth_expires",{get:function(){var t=this.get(E.Expires);return null===t?null:parseInt(t)},set:function(t){null===t?this.delete(E.Expires):this.set(E.Expires,t.toString())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"auth_refresh_token",{get:function(){return this.get(E.RefreshToken)},set:function(t){null===t?this.delete(E.RefreshToken):this.set(E.RefreshToken,t)},enumerable:!1,configurable:!0}),e}(I),M=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.values={},e}return s(e,t),e.prototype.get=function(t){var e=this.key(t);return e in this.values?this.values[e]:null},e.prototype.set=function(t,e){return this.values[this.key(t)]=e,e},e.prototype.delete=function(t){var e=this.key(t),n=this.get(t);return e in this.values&&delete this.values[e],n},e.prototype.key=function(t){return"".concat(this.prefix).concat(t)},e}(H),B=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype.get=function(t){var e=localStorage.getItem(this.key(t));return null!==e?e:null},e.prototype.set=function(t,e){return localStorage.setItem(this.key(t),e),e},e.prototype.delete=function(t){var e=this.key(t),n=this.get(e);return n&&localStorage.removeItem(e),n},e.prototype.key=function(t){return"".concat(this.prefix).concat(t)},e}(H),C=function(t){function e(e){var n,o=t.call(this)||this;return o.config=e,o.axios=r.default.create({baseURL:o.config.url,params:o.config.params,headers:o.config.headers,onUploadProgress:o.config.onUploadProgress,withCredentials:!0}),(null===(n=o.config)||void 0===n?void 0:n.beforeRequest)&&(o.beforeRequest=o.config.beforeRequest),o}return s(e,t),e.prototype.beforeRequest=function(t){return t},Object.defineProperty(e.prototype,"url",{get:function(){return this.config.url},enumerable:!1,configurable:!0}),e.prototype.request=function(t,e,n,o){var i,s,u,h,l;return a(this,void 0,void 0,(function(){var a,p,f,d,v;return c(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),a={method:t,url:e,data:n,params:null==o?void 0:o.params,headers:null==o?void 0:o.headers,onUploadProgress:null==o?void 0:o.onUploadProgress},a=this.beforeRequest(a),[4,this.axios.request(a)];case 1:if(p=c.sent(),f={raw:p.data,status:p.status,statusText:p.statusText,headers:p.headers,data:p.data.data,meta:p.data.meta,errors:p.data.errors},p.data.errors)throw new A(null,f);return[2,f];case 2:if(!(d=c.sent())||d instanceof Error==!1)throw d;if(r.default.isAxiosError(d))throw v=null===(i=d.response)||void 0===i?void 0:i.data,new A(d,{raw:null===(s=d.response)||void 0===s?void 0:s.data,status:null===(u=d.response)||void 0===u?void 0:u.status,statusText:null===(h=d.response)||void 0===h?void 0:h.statusText,headers:null===(l=d.response)||void 0===l?void 0:l.headers,data:null==v?void 0:v.data,meta:null==v?void 0:v.meta,errors:null==v?void 0:v.errors});throw new A(d);case 3:return[2]}}))}))},e.prototype.get=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.request("get",t,void 0,e)];case 1:return[2,n.sent()]}}))}))},e.prototype.head=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.request("head",t,void 0,e)];case 1:return[2,n.sent()]}}))}))},e.prototype.options=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.request("options",t,void 0,e)];case 1:return[2,n.sent()]}}))}))},e.prototype.delete=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.request("delete",t,e,n)];case 1:return[2,r.sent()]}}))}))},e.prototype.put=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.request("put",t,e,n)];case 1:return[2,r.sent()]}}))}))},e.prototype.post=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.request("post",t,e,n)];case 1:return[2,r.sent()]}}))}))},e.prototype.patch=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.request("patch",t,e,n)];case 1:return[2,r.sent()]}}))}))},e}(U),J=function(){function t(t){this.transport=t}return t.prototype.request=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.post("/auth/password/request",{email:t,reset_url:e})];case 1:return n.sent(),[2]}}))}))},t.prototype.reset=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.post("/auth/password/reset",{token:t,password:e})];case 1:return n.sent(),[2]}}))}))},t}(),F=function(t){function e(e){var n,r,o,i=t.call(this)||this;return i.autoRefresh=!0,i.msRefreshBeforeExpires=3e4,i.staticToken="",i.timer=null,i._transport=e.transport,i._storage=e.storage,i.autoRefresh=null!==(n=null==e?void 0:e.autoRefresh)&&void 0!==n?n:i.autoRefresh,i.mode=null!==(r=null==e?void 0:e.mode)&&void 0!==r?r:i.mode,i.msRefreshBeforeExpires=null!==(o=null==e?void 0:e.msRefreshBeforeExpires)&&void 0!==o?o:i.msRefreshBeforeExpires,(null==e?void 0:e.staticToken)?(i.staticToken=null==e?void 0:e.staticToken,i.updateStorage({access_token:i.staticToken,expires:null,refresh_token:null})):i.autoRefresh&&i.autoRefreshJob(),i}return s(e,t),Object.defineProperty(e.prototype,"storage",{get:function(){return this._storage},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transport",{get:function(){return this._transport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"token",{get:function(){return this._storage.auth_token},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"password",{get:function(){return this.passwords=this.passwords||new J(this._transport)},enumerable:!1,configurable:!0}),e.prototype.resetStorage=function(){this._storage.auth_token=null,this._storage.auth_refresh_token=null,this._storage.auth_expires=null},e.prototype.updateStorage=function(t){var e,n;this._storage.auth_token=t.access_token,this._storage.auth_refresh_token=null!==(e=t.refresh_token)&&void 0!==e?e:null,this._storage.auth_expires=null!==(n=t.expires)&&void 0!==n?n:null},e.prototype.autoRefreshJob=function(){var t=this;if(this.autoRefresh&&this._storage.auth_expires){this.timer&&clearTimeout(this.timer);var e=this._storage.auth_expires-this.msRefreshBeforeExpires;this.timer=setTimeout((function(){return a(t,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this.refresh().catch((function(){}))];case 1:return t.sent(),this.autoRefreshJob(),[2]}}))}))}),e)}},e.prototype.refresh=function(){var t;return a(this,void 0,void 0,(function(){var e,n;return c(this,(function(r){switch(r.label){case 0:return e=this._storage.auth_refresh_token,this.resetStorage(),[4,this._transport.post("/auth/refresh",{refresh_token:"json"===this.mode?e:void 0})];case 1:return n=r.sent(),this.updateStorage(n.data),this.autoRefresh&&this.autoRefreshJob(),[2,{access_token:n.data.access_token,refresh_token:null===(t=n.data)||void 0===t?void 0:t.refresh_token,expires:n.data.expires}]}}))}))},e.prototype.login=function(t){var e;return a(this,void 0,void 0,(function(){var n;return c(this,(function(r){switch(r.label){case 0:return this.resetStorage(),[4,this._transport.post("/auth/login",u({mode:this.mode},t),{headers:{Authorization:null}})];case 1:return n=r.sent(),this.updateStorage(n.data),this.autoRefresh&&this.autoRefreshJob(),[2,{access_token:n.data.access_token,refresh_token:null===(e=n.data)||void 0===e?void 0:e.refresh_token,expires:n.data.expires}]}}))}))},e.prototype.static=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this._transport.get("/users/me",{params:{access_token:t},headers:{Authorization:null}})];case 1:return e.sent(),this.updateStorage({access_token:t,expires:null,refresh_token:null}),[2,!0]}}))}))},e.prototype.logout=function(){return a(this,void 0,void 0,(function(){var t;return c(this,(function(e){switch(e.label){case 0:return"json"===this.mode&&(t=this._storage.auth_refresh_token||void 0),[4,this._transport.post("/auth/logout",{refresh_token:t})];case 1:return e.sent(),this.updateStorage({access_token:null,expires:null,refresh_token:null}),clearTimeout(this.timer),[2]}}))}))},e}(o),L=function(){function t(t){this.transport=t}return t.prototype.request=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.transport.post(t,{query:e,variables:void 0===n?{}:n})];case 1:return[2,r.sent()]}}))}))},t.prototype.items=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.request("/graphql",t,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.system=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.request("/graphql/system",t,e)];case 1:return[2,n.sent()]}}))}))},t}(),z=function(){function t(t,e){var n,r,i,s,a,c,h,l,p,f=this;if(this._url=t,this._options=e,this._items={},this._singletons={},(null===(n=this._options)||void 0===n?void 0:n.storage)&&(null===(r=this._options)||void 0===r?void 0:r.storage)instanceof I)this._storage=this._options.storage;else{var d=null===(i=this._options)||void 0===i?void 0:i.storage,v=null!=d?d:{},y=v.mode,b=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}(v,["mode"]);"MemoryStorage"===y||"undefined"==typeof window?this._storage=new M(b):this._storage=new B(b)}(null===(s=this._options)||void 0===s?void 0:s.transport)&&(null===(a=this._options)||void 0===a?void 0:a.transport)instanceof U?this._transport=this._options.transport:this._transport=new C(u({url:this.url,beforeRequest:function(t){var e=f.storage.auth_token,n=e?e.startsWith("Bearer ")?String(f.storage.auth_token):"Bearer ".concat(f.storage.auth_token):"";return u(u({},t),{headers:u({Authorization:n},t.headers)})}},null===(c=this._options)||void 0===c?void 0:c.transport)),(null===(h=this._options)||void 0===h?void 0:h.auth)&&(null===(l=this._options)||void 0===l?void 0:l.auth)instanceof o?this._auth=this._options.auth:this._auth=new F(u({transport:this._transport,storage:this._storage},null===(p=this._options)||void 0===p?void 0:p.auth))}return Object.defineProperty(t.prototype,"url",{get:function(){return this._url},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"auth",{get:function(){return this._auth},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"storage",{get:function(){return this._storage},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transport",{get:function(){return this._transport},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"activity",{get:function(){return this._activity||(this._activity=new f(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collections",{get:function(){return this._collections||(this._collections=new d(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fields",{get:function(){return this._fields||(this._fields=new v(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"files",{get:function(){return this._files||(this._files=new y(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"folders",{get:function(){return this._folders||(this._folders=new b(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"permissions",{get:function(){return this._permissions||(this._permissions=new g(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"presets",{get:function(){return this._presets||(this._presets=new _(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"relations",{get:function(){return this._relations||(this._relations=new m(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"revisions",{get:function(){return this._revisions||(this._revisions=new w(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roles",{get:function(){return this._roles||(this._roles=new O(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"users",{get:function(){return this._users||(this._users=new q(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"settings",{get:function(){return this._settings||(this._settings=new P(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"server",{get:function(){return this._server||(this._server=new k(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"utils",{get:function(){return this._utils||(this._utils=new S(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"graphql",{get:function(){return this._graphql||(this._graphql=new L(this.transport))},enumerable:!1,configurable:!0}),t.prototype.singleton=function(t){return this._singletons[t]||(this._singletons[t]=new j(t,this.transport))},t.prototype.items=function(t){return this._items[t]||(this._items[t]=new l(t,this.transport))},t}();return t.ActivityHandler=f,t.Auth=F,t.BaseStorage=H,t.CollectionsHandler=d,t.CommentsHandler=p,t.Directus=z,t.FieldsHandler=v,t.FilesHandler=y,t.FoldersHandler=b,t.IAuth=o,t.IStorage=I,t.ITransport=U,t.ItemsHandler=l,t.LocalStorage=B,t.MemoryStorage=M,t.PermissionsHandler=g,t.PresetsHandler=_,t.RelationsHandler=m,t.RevisionsHandler=w,t.RolesHandler=O,t.ServerHandler=k,t.SettingsHandler=P,t.Transport=C,t.TransportError=A,t.UsersHandler=q,t.UtilsHandler=S,Object.defineProperty(t,"__esModule",{value:!0}),t}({},axios); | ||
var DirectusSdk=function(t,e){"use strict";function n(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=n(e),o=function(){this.mode="undefined"==typeof window?"json":"cookie"},i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},i(t,e)};function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var u=function(){return u=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},u.apply(this,arguments)};function a(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{a(r.next(t))}catch(t){i(t)}}function u(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,u)}a((r=r.apply(t,e||[])).next())}))}function c(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var h,l=function(){function t(t,e){this.collection=t,this.transport=e,this.endpoint=t.startsWith("directus_")?"/".concat(t.substring(9)):"/items/".concat(t)}return t.prototype.readOne=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.transport.get("".concat(this.endpoint,"/").concat(encodeURI(t)),u({params:e},null==n?void 0:n.requestOptions))];case 1:return[2,r.sent().data]}}))}))},t.prototype.readMany=function(t,e,n){var r;return a(this,void 0,void 0,(function(){var o,i,s,a,h,l;return c(this,(function(c){switch(c.label){case 0:return[4,this.transport.get("/fields/".concat(this.collection))];case 1:return o=c.sent(),i=null===(r=o.data)||void 0===r?void 0:r.find((function(t){return!0===t.schema.is_primary_key})),[4,this.transport.get("".concat(this.endpoint),u({params:u({filter:u((l={},l[i.field]={_in:t},l),null==e?void 0:e.filter),sort:(null==e?void 0:e.sort)||i.field},e)},null==n?void 0:n.requestOptions))];case 2:return s=c.sent(),a=s.data,h=s.meta,[2,{data:a,meta:h}]}}))}))},t.prototype.readByQuery=function(t,e){return a(this,void 0,void 0,(function(){var n,r,o;return c(this,(function(i){switch(i.label){case 0:return[4,this.transport.get("".concat(this.endpoint),u({params:t},null==e?void 0:e.requestOptions))];case 1:return n=i.sent(),r=n.data,o=n.meta,[2,{data:r,meta:o}]}}))}))},t.prototype.createOne=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.transport.post("".concat(this.endpoint),t,u({params:e},null==n?void 0:n.requestOptions))];case 1:return[2,r.sent().data]}}))}))},t.prototype.createMany=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.transport.post("".concat(this.endpoint),t,u({params:e},null==n?void 0:n.requestOptions))];case 1:return[2,r.sent()]}}))}))},t.prototype.updateOne=function(t,e,n,r){return a(this,void 0,void 0,(function(){return c(this,(function(o){switch(o.label){case 0:return[4,this.transport.patch("".concat(this.endpoint,"/").concat(encodeURI(t)),e,u({params:n},null==r?void 0:r.requestOptions))];case 1:return[2,o.sent().data]}}))}))},t.prototype.updateMany=function(t,e,n,r){return a(this,void 0,void 0,(function(){return c(this,(function(o){switch(o.label){case 0:return[4,this.transport.patch("".concat(this.endpoint),{keys:t,data:e},u({params:n},null==r?void 0:r.requestOptions))];case 1:return[2,o.sent()]}}))}))},t.prototype.updateByQuery=function(t,e,n,r){return a(this,void 0,void 0,(function(){return c(this,(function(o){switch(o.label){case 0:return[4,this.transport.patch("".concat(this.endpoint),{query:t,data:e},u({params:n},null==r?void 0:r.requestOptions))];case 1:return[2,o.sent()]}}))}))},t.prototype.deleteOne=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.delete("".concat(this.endpoint,"/").concat(encodeURI(t)),void 0,null==e?void 0:e.requestOptions)];case 1:return n.sent(),[2]}}))}))},t.prototype.deleteMany=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.delete("".concat(this.endpoint),t,null==e?void 0:e.requestOptions)];case 1:return n.sent(),[2]}}))}))},t}(),p=function(){function t(t){this.transport=t}return t.prototype.create=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/activity/comment",t)];case 1:return[2,e.sent().data]}}))}))},t.prototype.update=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.patch("/activity/comment/".concat(encodeURI(t)),{comment:e})];case 1:return[2,n.sent().data]}}))}))},t.prototype.delete=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.delete("/activity/comment/".concat(encodeURI(t)))];case 1:return e.sent(),[2]}}))}))},t}(),f=function(t){function e(e){var n=t.call(this,"directus_activity",e)||this;return n._comments=new p(n.transport),n}return s(e,t),Object.defineProperty(e.prototype,"comments",{get:function(){return this._comments},enumerable:!1,configurable:!0}),e}(l),d=function(){function t(t){this.transport=t}return t.prototype.readOne=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.get("/collections/".concat(t))];case 1:return[2,e.sent().data]}}))}))},t.prototype.readAll=function(){return a(this,void 0,void 0,(function(){var t,e,n;return c(this,(function(r){switch(r.label){case 0:return[4,this.transport.get("/collections")];case 1:return t=r.sent(),e=t.data,n=t.meta,[2,{data:e,meta:n}]}}))}))},t.prototype.createOne=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/collections",t)];case 1:return[2,e.sent().data]}}))}))},t.prototype.createMany=function(t){return a(this,void 0,void 0,(function(){var e,n,r;return c(this,(function(o){switch(o.label){case 0:return[4,this.transport.post("/collections",t)];case 1:return e=o.sent(),n=e.data,r=e.meta,[2,{data:n,meta:r}]}}))}))},t.prototype.updateOne=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.transport.patch("/collections/".concat(t),e,{params:n})];case 1:return[2,r.sent().data]}}))}))},t.prototype.deleteOne=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.delete("/collections/".concat(t))];case 1:return e.sent(),[2]}}))}))},t}(),v=function(){function t(t){this.transport=t}return t.prototype.readOne=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.get("/fields/".concat(t,"/").concat(e))];case 1:return[2,n.sent().data]}}))}))},t.prototype.readMany=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.get("/fields/".concat(t))];case 1:return[2,e.sent().data]}}))}))},t.prototype.readAll=function(){return a(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this.transport.get("/fields")];case 1:return[2,t.sent().data]}}))}))},t.prototype.createOne=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.post("/fields/".concat(t),e)];case 1:return[2,n.sent().data]}}))}))},t.prototype.updateOne=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.transport.patch("/fields/".concat(t,"/").concat(e),n)];case 1:return[2,r.sent().data]}}))}))},t.prototype.deleteOne=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.delete("/fields/".concat(t,"/").concat(e))];case 1:return n.sent(),[2]}}))}))},t}(),y=function(t){function e(e){return t.call(this,"directus_files",e)||this}return s(e,t),e}(l),b=function(t){function e(e){return t.call(this,"directus_folders",e)||this}return s(e,t),e}(l),g=function(t){function e(e){return t.call(this,"directus_permissions",e)||this}return s(e,t),e}(l),_=function(t){function e(e){return t.call(this,"directus_presets",e)||this}return s(e,t),e}(l),m=function(){function t(t){this.transport=t}return t.prototype.readOne=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.get("/relations/".concat(t,"/").concat(e))];case 1:return[2,n.sent().data]}}))}))},t.prototype.readMany=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.get("/relations/".concat(t))];case 1:return[2,e.sent().data]}}))}))},t.prototype.readAll=function(){return a(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this.transport.get("/relations")];case 1:return[2,t.sent().data]}}))}))},t.prototype.createOne=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/relations",t)];case 1:return[2,e.sent().data]}}))}))},t.prototype.updateOne=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.transport.patch("/relations/".concat(t,"/").concat(e),{params:n})];case 1:return[2,r.sent().data]}}))}))},t.prototype.deleteOne=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.delete("/relations/".concat(t,"/").concat(e))];case 1:return n.sent(),[2]}}))}))},t}(),w=function(t){function e(e){return t.call(this,"directus_revisions",e)||this}return s(e,t),e}(l),O=function(t){function e(e){return t.call(this,"directus_roles",e)||this}return s(e,t),e}(l),k=function(){function t(t){this.transport=t}return t.prototype.ping=function(){return a(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this.transport.get("/server/ping")];case 1:return[2,t.sent().raw]}}))}))},t.prototype.info=function(){return a(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this.transport.get("/server/info")];case 1:return[2,t.sent().data]}}))}))},t}(),x=function(){function t(t,e){this.collection=t,this.transport=e,this.endpoint=t.startsWith("directus_")?"/".concat(t.substring(9)):"/items/".concat(t)}return t.prototype.read=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.get("".concat(this.endpoint),{params:t})];case 1:return[2,e.sent().data]}}))}))},t.prototype.update=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.patch("".concat(this.endpoint),t,{params:e})];case 1:return[2,n.sent().data]}}))}))},t}(),j=function(t){function e(e){return t.call(this,"directus_settings",e)||this}return s(e,t),e}(x),P=function(){function t(t){this.transport=t}return t.prototype.send=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.transport.post("/users/invite",{email:t,role:e,invite_url:n})];case 1:return r.sent(),[2]}}))}))},t.prototype.accept=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.post("/users/invite/accept",{token:t,password:e})];case 1:return n.sent(),[2]}}))}))},t}(),q=function(){function t(t){this.transport=t}return t.prototype.generate=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/users/me/tfa/generate",{password:t})];case 1:return[2,e.sent().data]}}))}))},t.prototype.enable=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.post("/users/me/tfa/enable",{secret:t,otp:e})];case 1:return n.sent(),[2]}}))}))},t.prototype.disable=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/users/me/tfa/disable",{otp:t})];case 1:return e.sent(),[2]}}))}))},t}(),T=function(){function t(t){this._transport=t}return Object.defineProperty(t.prototype,"tfa",{get:function(){return this._tfa||(this._tfa=new q(this._transport))},enumerable:!1,configurable:!0}),t.prototype.read=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this._transport.get("/users/me",{params:t})];case 1:return[2,e.sent().data]}}))}))},t.prototype.update=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this._transport.patch("/users/me",t,{params:e})];case 1:return[2,n.sent().data]}}))}))},t}(),R=function(t){function e(e){return t.call(this,"directus_users",e)||this}return s(e,t),Object.defineProperty(e.prototype,"invites",{get:function(){return this._invites||(this._invites=new P(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"me",{get:function(){return this._me||(this._me=new T(this.transport))},enumerable:!1,configurable:!0}),e}(l),S=function(){function t(t){var e=this;this.random={string:function(t){return void 0===t&&(t=32),a(e,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.get("/utils/random/string",{params:{length:t}})];case 1:return[2,e.sent().data]}}))}))}},this.hash={generate:function(t){return a(e,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/utils/hash/generate",{string:t})];case 1:return[2,e.sent().data]}}))}))},verify:function(t,n){return a(e,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/utils/hash/verify",{string:t,hash:n})];case 1:return[2,e.sent().data]}}))}))}},this.transport=t}return t.prototype.sort=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.transport.post("/utils/sort/".concat(encodeURI(t)),{item:e,to:n})];case 1:return r.sent(),[2]}}))}))},t.prototype.revert=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/utils/revert/".concat(encodeURI(t)))];case 1:return e.sent(),[2]}}))}))},t}();t.Meta=void 0,(h=t.Meta||(t.Meta={})).TOTAL_COUNT="total_count",h.FILTER_COUNT="filter_count";var I,A=function(){},E=function(){},U=function(t){function e(n,r){var o,i,s=this;return(s=(null===(o=null==r?void 0:r.errors)||void 0===o?void 0:o.length)?t.call(this,null===(i=null==r?void 0:r.errors[0])||void 0===i?void 0:i.message)||this:t.call(this,(null==n?void 0:n.message)||"Unknown transport error")||this).parent=n,s.response=r,s.errors=(null==r?void 0:r.errors)||[],Object.values(r||{}).some((function(t){return void 0!==t}))||(s.response=void 0),Object.setPrototypeOf(s,e.prototype),s}return s(e,t),e}(Error);!function(t){t.AuthToken="auth_token",t.RefreshToken="auth_refresh_token",t.Expires="auth_expires",t.ExpiresAt="auth_expires_at"}(I||(I={}));var H=function(t){function e(e){var n,r=t.call(this)||this;return r.prefix=null!==(n=null==e?void 0:e.prefix)&&void 0!==n?n:"",r}return s(e,t),Object.defineProperty(e.prototype,"auth_token",{get:function(){return this.get(I.AuthToken)},set:function(t){null===t?this.delete(I.AuthToken):this.set(I.AuthToken,t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"auth_expires",{get:function(){var t=this.get(I.Expires);return null===t?null:parseInt(t)},set:function(t){null===t?this.delete(I.Expires):this.set(I.Expires,t.toString())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"auth_expires_at",{get:function(){var t=this.get(I.ExpiresAt);return null===t?null:parseInt(t)},set:function(t){null===t?this.delete(I.ExpiresAt):this.set(I.ExpiresAt,t.toString())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"auth_refresh_token",{get:function(){return this.get(I.RefreshToken)},set:function(t){null===t?this.delete(I.RefreshToken):this.set(I.RefreshToken,t)},enumerable:!1,configurable:!0}),e}(A),M=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.values={},e}return s(e,t),e.prototype.get=function(t){var e=this.key(t);return e in this.values?this.values[e]:null},e.prototype.set=function(t,e){return this.values[this.key(t)]=e,e},e.prototype.delete=function(t){var e=this.key(t),n=this.get(t);return e in this.values&&delete this.values[e],n},e.prototype.key=function(t){return"".concat(this.prefix).concat(t)},e}(H),C=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype.get=function(t){var e=localStorage.getItem(this.key(t));return null!==e?e:null},e.prototype.set=function(t,e){return localStorage.setItem(this.key(t),e),e},e.prototype.delete=function(t){var e=this.key(t),n=this.get(e);return n&&localStorage.removeItem(e),n},e.prototype.key=function(t){return"".concat(this.prefix).concat(t)},e}(H),B=function(t){function e(e){var n,o=t.call(this)||this;return o.config=e,o.axios=r.default.create({baseURL:o.config.url,params:o.config.params,headers:o.config.headers,onUploadProgress:o.config.onUploadProgress,withCredentials:!0}),(null===(n=o.config)||void 0===n?void 0:n.beforeRequest)&&(o.beforeRequest=o.config.beforeRequest),o}return s(e,t),e.prototype.beforeRequest=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){return[2,t]}))}))},Object.defineProperty(e.prototype,"url",{get:function(){return this.config.url},enumerable:!1,configurable:!0}),e.prototype.request=function(t,e,n,o){var i,s,u,h,l;return a(this,void 0,void 0,(function(){var a,p,f,d,v;return c(this,(function(c){switch(c.label){case 0:return c.trys.push([0,3,,4]),a={method:t,url:e,data:n,params:null==o?void 0:o.params,headers:null==o?void 0:o.headers,onUploadProgress:null==o?void 0:o.onUploadProgress},[4,this.beforeRequest(a)];case 1:return a=c.sent(),[4,this.axios.request(a)];case 2:if(p=c.sent(),f={raw:p.data,status:p.status,statusText:p.statusText,headers:p.headers,data:p.data.data,meta:p.data.meta,errors:p.data.errors},p.data.errors)throw new U(null,f);return[2,f];case 3:if(!(d=c.sent())||d instanceof Error==!1)throw d;if(r.default.isAxiosError(d))throw v=null===(i=d.response)||void 0===i?void 0:i.data,new U(d,{raw:null===(s=d.response)||void 0===s?void 0:s.data,status:null===(u=d.response)||void 0===u?void 0:u.status,statusText:null===(h=d.response)||void 0===h?void 0:h.statusText,headers:null===(l=d.response)||void 0===l?void 0:l.headers,data:null==v?void 0:v.data,meta:null==v?void 0:v.meta,errors:null==v?void 0:v.errors});throw new U(d);case 4:return[2]}}))}))},e.prototype.get=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.request("get",t,void 0,e)];case 1:return[2,n.sent()]}}))}))},e.prototype.head=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.request("head",t,void 0,e)];case 1:return[2,n.sent()]}}))}))},e.prototype.options=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.request("options",t,void 0,e)];case 1:return[2,n.sent()]}}))}))},e.prototype.delete=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.request("delete",t,e,n)];case 1:return[2,r.sent()]}}))}))},e.prototype.put=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.request("put",t,e,n)];case 1:return[2,r.sent()]}}))}))},e.prototype.post=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.request("post",t,e,n)];case 1:return[2,r.sent()]}}))}))},e.prototype.patch=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.request("patch",t,e,n)];case 1:return[2,r.sent()]}}))}))},e}(E),D=function(){function t(t){this.transport=t}return t.prototype.request=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.post("/auth/password/request",{email:t,reset_url:e})];case 1:return n.sent(),[2]}}))}))},t.prototype.reset=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.transport.post("/auth/password/reset",{token:t,password:e})];case 1:return n.sent(),[2]}}))}))},t}(),F=function(t){function e(e){var n,r,o=t.call(this)||this;return o.autoRefresh=!0,o.staticToken="",o._transport=e.transport,o._storage=e.storage,o.autoRefresh=null!==(n=null==e?void 0:e.autoRefresh)&&void 0!==n?n:o.autoRefresh,o.mode=null!==(r=null==e?void 0:e.mode)&&void 0!==r?r:o.mode,(null==e?void 0:e.staticToken)&&(o.staticToken=null==e?void 0:e.staticToken,o.updateStorage({access_token:o.staticToken,expires:null,refresh_token:null})),o}return s(e,t),Object.defineProperty(e.prototype,"storage",{get:function(){return this._storage},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transport",{get:function(){return this._transport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"token",{get:function(){return this._storage.auth_token},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"password",{get:function(){return this.passwords=this.passwords||new D(this._transport)},enumerable:!1,configurable:!0}),e.prototype.resetStorage=function(){this._storage.auth_token=null,this._storage.auth_refresh_token=null,this._storage.auth_expires=null,this._storage.auth_expires_at=null},e.prototype.updateStorage=function(t){var e,n,r=null!==(e=t.expires)&&void 0!==e?e:null;this._storage.auth_token=t.access_token,this._storage.auth_refresh_token=null!==(n=t.refresh_token)&&void 0!==n?n:null,this._storage.auth_expires=r,this._storage.auth_expires_at=(new Date).getTime()+(null!=r?r:0)},e.prototype.refreshIfExpired=function(){return a(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return this.staticToken?[2]:this.autoRefresh&&this._storage.auth_expires_at?this._storage.auth_expires_at<(new Date).getTime()?[4,this.refresh().catch((function(){}))]:[3,2]:[2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},e.prototype.refresh=function(){var t;return a(this,void 0,void 0,(function(){var e,n;return c(this,(function(r){switch(r.label){case 0:return e=this._storage.auth_refresh_token,this.resetStorage(),[4,this._transport.post("/auth/refresh",{refresh_token:"json"===this.mode?e:void 0})];case 1:return n=r.sent(),this.updateStorage(n.data),this.autoRefresh&&this.refreshIfExpired(),[2,{access_token:n.data.access_token,refresh_token:null===(t=n.data)||void 0===t?void 0:t.refresh_token,expires:n.data.expires}]}}))}))},e.prototype.login=function(t){var e;return a(this,void 0,void 0,(function(){var n;return c(this,(function(r){switch(r.label){case 0:return this.resetStorage(),[4,this._transport.post("/auth/login",u({mode:this.mode},t),{headers:{Authorization:null}})];case 1:return n=r.sent(),this.updateStorage(n.data),this.autoRefresh&&this.refreshIfExpired(),[2,{access_token:n.data.access_token,refresh_token:null===(e=n.data)||void 0===e?void 0:e.refresh_token,expires:n.data.expires}]}}))}))},e.prototype.static=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this._transport.get("/users/me",{params:{access_token:t},headers:{Authorization:null}})];case 1:return e.sent(),this.updateStorage({access_token:t,expires:null,refresh_token:null}),[2,!0]}}))}))},e.prototype.logout=function(){return a(this,void 0,void 0,(function(){var t;return c(this,(function(e){switch(e.label){case 0:return"json"===this.mode&&(t=this._storage.auth_refresh_token||void 0),[4,this._transport.post("/auth/logout",{refresh_token:t})];case 1:return e.sent(),this.updateStorage({access_token:null,expires:null,refresh_token:null}),[2]}}))}))},e}(o),L=function(){function t(t){this.transport=t}return t.prototype.request=function(t,e,n){return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.transport.post(t,{query:e,variables:void 0===n?{}:n})];case 1:return[2,r.sent()]}}))}))},t.prototype.items=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.request("/graphql",t,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.system=function(t,e){return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,this.request("/graphql/system",t,e)];case 1:return[2,n.sent()]}}))}))},t}(),z=function(){function t(t,e){var n,r,i,s,h,l,p,f,d,v=this;if(this._url=t,this._options=e,this._items={},this._singletons={},(null===(n=this._options)||void 0===n?void 0:n.storage)&&(null===(r=this._options)||void 0===r?void 0:r.storage)instanceof A)this._storage=this._options.storage;else{var y=null===(i=this._options)||void 0===i?void 0:i.storage,b=null!=y?y:{},g=b.mode,_=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}(b,["mode"]);"MemoryStorage"===g||"undefined"==typeof window?this._storage=new M(_):this._storage=new C(_)}(null===(s=this._options)||void 0===s?void 0:s.transport)&&(null===(h=this._options)||void 0===h?void 0:h.transport)instanceof E?this._transport=this._options.transport:this._transport=new B(u({url:this.url,beforeRequest:function(t){return a(v,void 0,void 0,(function(){var e,n;return c(this,(function(r){switch(r.label){case 0:return[4,this._auth.refreshIfExpired()];case 1:return r.sent(),e=this.storage.auth_token,n=e?e.startsWith("Bearer ")?String(this.storage.auth_token):"Bearer ".concat(this.storage.auth_token):"",[2,u(u({},t),{headers:u({Authorization:n},t.headers)})]}}))}))}},null===(l=this._options)||void 0===l?void 0:l.transport)),(null===(p=this._options)||void 0===p?void 0:p.auth)&&(null===(f=this._options)||void 0===f?void 0:f.auth)instanceof o?this._auth=this._options.auth:this._auth=new F(u({transport:this._transport,storage:this._storage},null===(d=this._options)||void 0===d?void 0:d.auth))}return Object.defineProperty(t.prototype,"url",{get:function(){return this._url},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"auth",{get:function(){return this._auth},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"storage",{get:function(){return this._storage},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transport",{get:function(){return this._transport},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"activity",{get:function(){return this._activity||(this._activity=new f(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collections",{get:function(){return this._collections||(this._collections=new d(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fields",{get:function(){return this._fields||(this._fields=new v(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"files",{get:function(){return this._files||(this._files=new y(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"folders",{get:function(){return this._folders||(this._folders=new b(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"permissions",{get:function(){return this._permissions||(this._permissions=new g(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"presets",{get:function(){return this._presets||(this._presets=new _(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"relations",{get:function(){return this._relations||(this._relations=new m(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"revisions",{get:function(){return this._revisions||(this._revisions=new w(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roles",{get:function(){return this._roles||(this._roles=new O(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"users",{get:function(){return this._users||(this._users=new R(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"settings",{get:function(){return this._settings||(this._settings=new j(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"server",{get:function(){return this._server||(this._server=new k(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"utils",{get:function(){return this._utils||(this._utils=new S(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"graphql",{get:function(){return this._graphql||(this._graphql=new L(this.transport))},enumerable:!1,configurable:!0}),t.prototype.singleton=function(t){return this._singletons[t]||(this._singletons[t]=new x(t,this.transport))},t.prototype.items=function(t){return this._items[t]||(this._items[t]=new l(t,this.transport))},t}();return t.ActivityHandler=f,t.Auth=F,t.BaseStorage=H,t.CollectionsHandler=d,t.CommentsHandler=p,t.Directus=z,t.FieldsHandler=v,t.FilesHandler=y,t.FoldersHandler=b,t.IAuth=o,t.IStorage=A,t.ITransport=E,t.ItemsHandler=l,t.LocalStorage=C,t.MemoryStorage=M,t.PermissionsHandler=g,t.PresetsHandler=_,t.RelationsHandler=m,t.RevisionsHandler=w,t.RolesHandler=O,t.ServerHandler=k,t.SettingsHandler=j,t.Transport=B,t.TransportError=U,t.UsersHandler=R,t.UtilsHandler=S,Object.defineProperty(t,"__esModule",{value:!0}),t}({},axios); | ||
//# sourceMappingURL=sdk.global.min.js.map |
{ | ||
"name": "@directus/sdk", | ||
"version": "9.7.1", | ||
"version": "9.8.0", | ||
"description": "The official Directus SDK for use in JavaScript!", | ||
@@ -73,3 +73,3 @@ "repository": { | ||
}, | ||
"gitHead": "7b1594727686ab8bfac416d851b1f0063f38f893" | ||
"gitHead": "2a6db01c42dd1d7524962e7153d1d7e1bd63fb2f" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
266809
2684