Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@directus/sdk

Package Overview
Dependencies
Maintainers
2
Versions
134
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@directus/sdk - npm Package Compare versions

Comparing version 11.0.3 to 12.0.0

dist/chunk-74XE5VTR.js

8

dist/auth/index.d.ts

@@ -1,4 +0,4 @@

import { D as DirectusClient } from '../client-e8d6bf91.js';
import { A as AuthenticationMode, c as AuthenticationConfig, d as AuthenticationClient, S as StaticTokenClient, b as AuthenticationStorage } from '../login-0506af09.js';
export { a as AuthenticationData } from '../login-0506af09.js';
import { D as DirectusClient } from '../client-5fa2f889.js';
import { A as AuthenticationMode, c as AuthenticationConfig, d as AuthenticationClient, S as StaticTokenClient, b as AuthenticationStorage } from '../login-170db6ff.js';
export { a as AuthenticationData } from '../login-170db6ff.js';

@@ -13,3 +13,3 @@ /**

*/
declare const authentication: (mode?: AuthenticationMode, config?: AuthenticationConfig) => <Schema extends object>(client: DirectusClient<Schema>) => AuthenticationClient<Schema>;
declare const authentication: (mode?: AuthenticationMode, config?: Partial<AuthenticationConfig>) => <Schema extends object>(client: DirectusClient<Schema>) => AuthenticationClient<Schema>;

@@ -16,0 +16,0 @@ /**

@@ -1,2 +0,2 @@

import{a,b,c}from"../chunk-IKZBOPD7.js";import"../chunk-2VYDJM4Y.js";export{b as authentication,a as memoryStorage,c as staticToken};
import{a,b,c}from"../chunk-74XE5VTR.js";import"../chunk-7KQ2R3YI.js";export{b as authentication,a as memoryStorage,c as staticToken};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import { D as DirectusClient } from '../client-e8d6bf91.js';
import { D as DirectusClient } from '../client-5fa2f889.js';

@@ -6,2 +6,5 @@ interface GraphqlClient<_Schema extends object> {

}
interface GraphqlConfig {
credentials: RequestCredentials;
}
type GqlResult<Schema extends object, Collection extends keyof Schema> = {

@@ -16,4 +19,4 @@ [Key in Collection]: Schema[Collection][];

*/
declare const graphql: () => <Schema extends object>(client: DirectusClient<Schema>) => GraphqlClient<Schema>;
declare const graphql: (config?: Partial<GraphqlConfig>) => <Schema extends object>(client: DirectusClient<Schema>) => GraphqlClient<Schema>;
export { GqlResult, GraphqlClient, graphql };
export { GqlResult, GraphqlClient, GraphqlConfig, graphql };

@@ -1,2 +0,2 @@

import{e as a}from"../chunk-IKZBOPD7.js";import"../chunk-2VYDJM4Y.js";export{a as graphql};
import{e as a}from"../chunk-74XE5VTR.js";import"../chunk-7KQ2R3YI.js";export{a as graphql};
//# sourceMappingURL=index.js.map
export { authentication, memoryStorage, staticToken } from './auth/index.js';
export { d as AuthenticationClient, c as AuthenticationConfig, a as AuthenticationData, A as AuthenticationMode, b as AuthenticationStorage, H as HttpMethod, h as RequestOptions, i as RequestTransformer, j as ResponseTransformer, f as RestClient, R as RestCommand, g as RestConfig, S as StaticTokenClient, e as login, l as loginOptions } from './login-0506af09.js';
import { D as DirectusClient } from './client-e8d6bf91.js';
export { GqlResult, GraphqlClient, graphql } from './graphql/index.js';
export { d as AuthenticationClient, c as AuthenticationConfig, a as AuthenticationData, A as AuthenticationMode, b as AuthenticationStorage, H as HttpMethod, L as LoginOptions, g as RequestOptions, h as RequestTransformer, i as ResponseTransformer, e as RestClient, R as RestCommand, f as RestConfig, S as StaticTokenClient, l as login } from './login-170db6ff.js';
import { C as ClientOptions, D as DirectusClient } from './client-5fa2f889.js';
export { a as ClientGlobals } from './client-5fa2f889.js';
export { GqlResult, GraphqlClient, GraphqlConfig, graphql } from './graphql/index.js';
export { EmailAuth, RefreshAuth, TokenAuth, auth, generateUid, messageCallback, pong, realtime, sleep } from './realtime/index.js';
export { aj as AllCollections, $ as ApplyManyToAnyFields, a0 as ApplyNestedQueryFields, _ as ApplyQueryFields, C as CollectionMetaTranslationType, ab as CollectionType, ai as CompleteSchema, j as CoreSchema, D as DirectusActivity, i as DirectusCollection, k as DirectusDashboard, l as DirectusField, o as DirectusFile, p as DirectusFlow, q as DirectusFolder, r as DirectusNotification, s as DirectusOperation, t as DirectusPanel, u as DirectusPermission, v as DirectusPreset, w as DirectusRelation, x as DirectusRevision, y as DirectusRole, z as DirectusSettings, A as DirectusShare, B as DirectusUser, E as DirectusWebhook, a3 as ExtractItem, a4 as ExtractRelation, m as FieldMetaConditionOptionType, F as FieldMetaConditionType, n as FieldMetaTranslationType, L as FieldsWildcard, U as FilterOperators, ak as GetCollection, al as GetCollectionName, J as HasManyToAnyRelation, K as HasNestedFields, aq as IfAny, ar as IsAny, as as IsNullable, aa as ItemType, Y as LogicalFilterOperators, M as ManyToAnyFields, ao as Merge, ah as MergeCoreCollection, a6 as MergeFields, a8 as MergeObjects, a5 as MergeRelationalFields, am as Mutable, at as NestedPartial, T as NestedQueryFilter, ap as NeverToUnknown, N as PickFlatFields, P as PickRelationalFields, ae as PrimitiveFields, a2 as Query, a9 as QueryAlias, Q as QueryDeep, G as QueryFields, I as QueryFieldsRelational, O as QueryFilter, a7 as QuerySort, ad as RegularCollections, a1 as RelationNullable, af as RelationalFields, V as RelationalFilterOperators, R as RemoveEventHandler, ag as RemoveRelationships, ac as SingletonCollections, S as SubscribeOptions, f as SubscriptionEvents, e as SubscriptionOptionsEvents, g as SubscriptionOutput, h as SubscriptionPayload, an as UnpackList, W as WebSocketAuthModes, d as WebSocketClient, a as WebSocketConfig, c as WebSocketEventHandler, b as WebSocketEvents, Z as WrapLogicalFilters, H as WrapQueryFields, X as WrapRelationalFilters } from './output-35b496cf.js';
export { dd as AggregateRecord, df as AggregationOptions, dg as AggregationOutput, dc as AggregationTypes, C as CreateActivityOutput, d as CreateCollectionOutput, f as CreateDashboardOutput, i as CreateFieldOutput, k as CreateFileOutput, n as CreateFlowOutput, s as CreateFolderOutput, w as CreateItemOutput, z as CreateNotificationOutput, D as CreateOperationOutput, G as CreatePanelOutput, J as CreatePermissionOutput, M as CreatePresetOutput, P as CreateRelationOutput, S as CreateRoleOutput, V as CreateShareOutput, Y as CreateTranslationOutput, $ as CreateUserOutput, a2 as CreateWebhookOutput, da as DirectusTranslation, aO as ExtensionTypes, cS as FileFormat, de as GroupByFields, db as GroupingFunctions, bU as OpenApiSpecOutput, aD as ReadActivityOutput, aH as ReadCollectionOutput, aK as ReadDashboardOutput, aN as ReadExtensionOutput, aQ as ReadFieldOutput, aU as ReadFileOutput, aX as ReadFlowOutput, a_ as ReadFolderOutput, b1 as ReadItemOutput, b4 as ReadNotificationOutput, b7 as ReadOperationOutput, ba as ReadPanelOutput, bd as ReadPermissionOutput, bg as ReadPresetOutput, R as ReadProviderOutput, bj as ReadRelationOutput, bn as ReadRevisionOutput, bq as ReadRoleOutput, bt as ReadSettingOutput, bv as ReadShareOutput, by as ReadSingletonOutput, bA as ReadTranslationOutput, bD as ReadUserOutput, bH as ReadWebhookOutput, bL as SchemaDiffOutput, bN as SchemaSnapshotOutput, bQ as ServerHealthOutput, bS as ServerInfoOutput, bX as UpdateActivityOutput, bZ as UpdateCollectionOutput, b$ as UpdateDashboardOutput, c2 as UpdateFieldOutput, c4 as UpdateFileOutput, c7 as UpdateFlowOutput, ca as UpdateFolderOutput, cd as UpdateItemOutput, cg as UpdateNotificationOutput, cj as UpdateOperationOutput, cm as UpdatePanelOutput, cp as UpdatePermissionOutput, cs as UpdatePresetOutput, cv as UpdateRelationOutput, cx as UpdateRoleOutput, cA as UpdateSettingOutput, cC as UpdateShareOutput, cF as UpdateSingletonOutput, cH as UpdateTranslationOutput, cK as UpdateUserOutput, cO as UpdateWebhookOutput, d2 as acceptUserInvite, aG as aggregate, d9 as asSearch, cZ as authenticateShare, cR as clearCache, e as createCollection, c as createComment, h as createDashboard, g as createDashboards, j as createField, q as createFlow, o as createFlows, v as createFolder, t as createFolders, y as createItem, x as createItems, B as createNotification, A as createNotifications, F as createOperation, E as createOperations, I as createPanel, H as createPanels, L as createPermission, K as createPermissions, O as createPreset, N as createPresets, Q as createRelation, U as createRole, T as createRoles, X as createShare, W as createShares, _ as createTranslation, Z as createTranslations, a1 as createUser, a0 as createUsers, a4 as createWebhook, a3 as createWebhooks, a6 as deleteCollection, a5 as deleteComment, a8 as deleteDashboard, a7 as deleteDashboards, a9 as deleteField, ab as deleteFile, aa as deleteFiles, ad as deleteFlow, ac as deleteFlows, af as deleteFolder, ae as deleteFolders, ah as deleteItem, ag as deleteItems, aj as deleteNotification, ai as deleteNotifications, al as deleteOperation, ak as deleteOperations, an as deletePanel, am as deletePanels, ap as deletePermission, ao as deletePermissions, ar as deletePreset, aq as deletePresets, as as deleteRelation, au as deleteRole, at as deleteRoles, aw as deleteShare, av as deleteShares, ay as deleteTranslation, ax as deleteTranslations, aA as deleteUser, az as deleteUsers, aC as deleteWebhook, aB as deleteWebhooks, d5 as disableTwoFactor, d4 as enableTwoFactor, cV as generateHash, d3 as generateTwoFactorSecret, m as importFile, c_ as inviteShare, d1 as inviteUser, l as logout, p as passwordRequest, a as passwordReset, d7 as queryToParams, aE as readActivities, aF as readActivity, aJ as readCollection, aI as readCollections, aM as readDashboard, aL as readDashboards, aP as readExtensions, aT as readField, aR as readFields, aS as readFieldsByCollection, aW as readFile, aV as readFiles, aZ as readFlow, aY as readFlows, b0 as readFolder, a$ as readFolders, bP as readGraphqlSdl, b3 as readItem, b2 as readItems, bG as readMe, b6 as readNotification, b5 as readNotifications, bV as readOpenApiSpec, b9 as readOperation, b8 as readOperations, bc as readPanel, bb as readPanels, bf as readPermission, be as readPermissions, bi as readPreset, bh as readPresets, r as readProviders, bm as readRelation, bl as readRelationByCollection, bk as readRelations, bp as readRevision, bo as readRevisions, bs as readRole, br as readRoles, bu as readSettings, bx as readShare, c$ as readShareInfo, bw as readShares, bz as readSingleton, bC as readTranslation, bB as readTranslations, bF as readUser, bE as readUsers, bJ as readWebhook, bI as readWebhooks, b as refresh, d6 as rest, bK as schemaApply, bM as schemaDiff, bO as schemaSnapshot, bR as serverHealth, bT as serverInfo, bW as serverPing, cU as triggerFlow, cY as triggerOperation, b_ as updateCollection, bY as updateComment, c1 as updateDashboard, c0 as updateDashboards, c3 as updateField, c6 as updateFile, c5 as updateFiles, c9 as updateFlow, c8 as updateFlows, cc as updateFolder, cb as updateFolders, cf as updateItem, ce as updateItems, cN as updateMe, ci as updateNotification, ch as updateNotifications, cl as updateOperation, ck as updateOperations, co as updatePanel, cn as updatePanels, cr as updatePermission, cq as updatePermissions, cu as updatePreset, ct as updatePresets, cw as updateRelation, cz as updateRole, cy as updateRoles, cB as updateSettings, cE as updateShare, cD as updateShares, cG as updateSingleton, cJ as updateTranslation, cI as updateTranslations, cM as updateUser, cL as updateUsers, cQ as updateWebhook, cP as updateWebhooks, u as uploadFiles, d0 as utilitySort, cT as utilsExport, cX as utilsImport, cW as verifyHash, d8 as withToken } from './index-0aafbb19.js';
export { dg as AggregateRecord, di as AggregationOptions, dj as AggregationOutput, df as AggregationTypes, C as CreateActivityOutput, d as CreateCollectionOutput, f as CreateDashboardOutput, i as CreateFieldOutput, k as CreateFileOutput, n as CreateFlowOutput, s as CreateFolderOutput, w as CreateItemOutput, z as CreateNotificationOutput, D as CreateOperationOutput, G as CreatePanelOutput, J as CreatePermissionOutput, M as CreatePresetOutput, P as CreateRelationOutput, S as CreateRoleOutput, V as CreateShareOutput, Y as CreateTranslationOutput, $ as CreateUserOutput, a2 as CreateWebhookOutput, dd as DirectusTranslation, aO as ExtensionTypes, cS as FileFormat, dh as GroupByFields, de as GroupingFunctions, bU as OpenApiSpecOutput, aD as ReadActivityOutput, aH as ReadCollectionOutput, aK as ReadDashboardOutput, aN as ReadExtensionOutput, aQ as ReadFieldOutput, aU as ReadFileOutput, aX as ReadFlowOutput, a_ as ReadFolderOutput, b1 as ReadItemOutput, b4 as ReadNotificationOutput, b7 as ReadOperationOutput, ba as ReadPanelOutput, bd as ReadPermissionOutput, bg as ReadPresetOutput, R as ReadProviderOutput, bj as ReadRelationOutput, bn as ReadRevisionOutput, bq as ReadRoleOutput, bt as ReadSettingOutput, bv as ReadShareOutput, by as ReadSingletonOutput, bA as ReadTranslationOutput, bD as ReadUserOutput, bH as ReadWebhookOutput, bL as SchemaDiffOutput, bN as SchemaSnapshotOutput, bQ as ServerHealthOutput, bS as ServerInfoOutput, bX as UpdateActivityOutput, bZ as UpdateCollectionOutput, b$ as UpdateDashboardOutput, c2 as UpdateFieldOutput, c4 as UpdateFileOutput, c7 as UpdateFlowOutput, ca as UpdateFolderOutput, cd as UpdateItemOutput, cg as UpdateNotificationOutput, cj as UpdateOperationOutput, cm as UpdatePanelOutput, cp as UpdatePermissionOutput, cs as UpdatePresetOutput, cv as UpdateRelationOutput, cx as UpdateRoleOutput, cA as UpdateSettingOutput, cC as UpdateShareOutput, cF as UpdateSingletonOutput, cH as UpdateTranslationOutput, cK as UpdateUserOutput, cO as UpdateWebhookOutput, d2 as acceptUserInvite, aG as aggregate, cZ as authenticateShare, cR as clearCache, e as createCollection, c as createComment, h as createDashboard, g as createDashboards, j as createField, q as createFlow, o as createFlows, v as createFolder, t as createFolders, y as createItem, x as createItems, B as createNotification, A as createNotifications, F as createOperation, E as createOperations, I as createPanel, H as createPanels, L as createPermission, K as createPermissions, O as createPreset, N as createPresets, Q as createRelation, U as createRole, T as createRoles, X as createShare, W as createShares, _ as createTranslation, Z as createTranslations, a1 as createUser, a0 as createUsers, a4 as createWebhook, a3 as createWebhooks, a6 as deleteCollection, a5 as deleteComment, a8 as deleteDashboard, a7 as deleteDashboards, a9 as deleteField, ab as deleteFile, aa as deleteFiles, ad as deleteFlow, ac as deleteFlows, af as deleteFolder, ae as deleteFolders, ah as deleteItem, ag as deleteItems, aj as deleteNotification, ai as deleteNotifications, al as deleteOperation, ak as deleteOperations, an as deletePanel, am as deletePanels, ap as deletePermission, ao as deletePermissions, ar as deletePreset, aq as deletePresets, as as deleteRelation, au as deleteRole, at as deleteRoles, aw as deleteShare, av as deleteShares, ay as deleteTranslation, ax as deleteTranslations, aA as deleteUser, az as deleteUsers, aC as deleteWebhook, aB as deleteWebhooks, d5 as disableTwoFactor, d4 as enableTwoFactor, cV as generateHash, d3 as generateTwoFactorSecret, m as importFile, c_ as inviteShare, d1 as inviteUser, l as logout, p as passwordRequest, a as passwordReset, da as queryToParams, aE as readActivities, aF as readActivity, aJ as readCollection, aI as readCollections, aM as readDashboard, aL as readDashboards, aP as readExtensions, aT as readField, aR as readFields, aS as readFieldsByCollection, aW as readFile, aV as readFiles, aZ as readFlow, aY as readFlows, b0 as readFolder, a$ as readFolders, bP as readGraphqlSdl, b3 as readItem, b2 as readItems, bG as readMe, b6 as readNotification, b5 as readNotifications, bV as readOpenApiSpec, b9 as readOperation, b8 as readOperations, bc as readPanel, bb as readPanels, bf as readPermission, be as readPermissions, bi as readPreset, bh as readPresets, r as readProviders, bm as readRelation, bl as readRelationByCollection, bk as readRelations, bp as readRevision, bo as readRevisions, bs as readRole, br as readRoles, bu as readSettings, bx as readShare, c$ as readShareInfo, bw as readShares, bz as readSingleton, bC as readTranslation, bB as readTranslations, bF as readUser, bE as readUsers, bJ as readWebhook, bI as readWebhooks, b as refresh, d6 as rest, bK as schemaApply, bM as schemaDiff, bO as schemaSnapshot, bR as serverHealth, bT as serverInfo, bW as serverPing, dc as throwIfCoreCollection, db as throwIfEmpty, cU as triggerFlow, cY as triggerOperation, b_ as updateCollection, bY as updateComment, c1 as updateDashboard, c0 as updateDashboards, c3 as updateField, c6 as updateFile, c5 as updateFiles, c9 as updateFlow, c8 as updateFlows, cc as updateFolder, cb as updateFolders, cf as updateItem, ce as updateItems, cN as updateMe, ci as updateNotification, ch as updateNotifications, cl as updateOperation, ck as updateOperations, co as updatePanel, cn as updatePanels, cr as updatePermission, cq as updatePermissions, cu as updatePreset, ct as updatePresets, cw as updateRelation, cz as updateRole, cy as updateRoles, cB as updateSettings, cE as updateShare, cD as updateShares, cG as updateSingleton, cJ as updateTranslation, cI as updateTranslations, cM as updateUser, cL as updateUsers, cQ as updateWebhook, cP as updateWebhooks, u as uploadFiles, d0 as utilitySort, cT as utilsExport, cX as utilsImport, cW as verifyHash, d7 as withOptions, d8 as withSearch, d9 as withToken } from './index-a2b3b0f1.js';

@@ -17,4 +18,4 @@ /**

*/
declare const createDirectus: <Schema extends object = any>(url: string) => DirectusClient<Schema>;
declare const createDirectus: <Schema extends object = any>(url: string, options?: ClientOptions) => DirectusClient<Schema>;
export { DirectusClient, createDirectus };
export { ClientOptions, DirectusClient, createDirectus };

@@ -1,2 +0,2 @@

import{$ as fa,$a as fb,$b as fc,A as G,Aa as Ga,Ab as Gb,Ac as Gc,B as H,Ba as Ha,Bb as Hb,Bc as Hc,C as I,Ca as Ia,Cb as Ib,Cc as Ic,D as J,Da as Ja,Db as Jb,E as K,Ea as Ka,Eb as Kb,F as L,Fa as La,Fb as Lb,G as M,Ga as Ma,Gb as Mb,H as N,Ha as Na,Hb as Nb,I as O,Ia as Oa,Ib as Ob,J as P,Ja as Pa,Jb as Pb,K as Q,Ka as Qa,Kb as Qb,L as R,La as Ra,Lb as Rb,M as S,Ma as Sa,Mb as Sb,N as T,Na as Ta,Nb as Tb,O as U,Oa as Ua,Ob as Ub,P as V,Pa as Va,Pb as Vb,Q as W,Qa as Wa,Qb as Wb,R as X,Ra as Xa,Rb as Xb,S as Y,Sa as Ya,Sb as Yb,T as Z,Ta as Za,Tb as Zb,U as _,Ua as _a,Ub as _b,V as $,Va as $a,Vb as $b,W as aa,Wa as ab,Wb as ac,X as ba,Xa as bb,Xb as bc,Y as ca,Ya as cb,Yb as cc,Z as da,Za as db,Zb as dc,_ as ea,_a as eb,_b as ec,a,aa as ga,ab as gb,ac as gc,b,ba as ha,bb as hb,bc as hc,c,ca as ia,cb as ib,cc as ic,d,da as ja,db as jb,dc as jc,e,ea as ka,eb as kb,ec as kc,f as l,fa as la,fb as lb,fc as lc,g as m,ga as ma,gb as mb,gc as mc,h as n,ha as na,hb as nb,hc as nc,i as o,ia as oa,ib as ob,ic as oc,j as p,ja as pa,jb as pb,jc as pc,k as q,ka as qa,kb as qb,kc as qc,l as r,la as ra,lb as rb,lc as rc,m as s,ma as sa,mb as sb,mc as sc,n as t,na as ta,nb as tb,nc as tc,o as u,oa as ua,ob as ub,oc as uc,p as v,pa as va,pb as vb,pc as vc,q as w,qa as wa,qb as wb,qc as wc,r as x,ra as xa,rb as xb,rc as xc,s as y,sa as ya,sb as yb,sc as yc,t as z,ta as za,tb as zb,tc as zc,u as A,ua as Aa,ub as Ab,uc as Ac,v as B,va as Ba,vb as Bb,vc as Bc,w as C,wa as Ca,wb as Cb,wc as Cc,x as D,xa as Da,xb as Db,xc as Dc,y as E,ya as Ea,yb as Eb,yc as Ec,z as F,za as Fa,zb as Fb,zc as Fc}from"./chunk-IKZBOPD7.js";import{a as f,b as g,c as h,d as i,e as j,f as k}from"./chunk-2VYDJM4Y.js";export{Bc as acceptUserInvite,Ha as aggregate,Ic as asSearch,f as auth,wc as authenticateShare,b as authentication,pc as clearCache,s as createCollection,r as createComment,u as createDashboard,t as createDashboards,d as createDirectus,v as createField,z as createFlow,y as createFlows,B as createFolder,A as createFolders,D as createItem,C as createItems,F as createNotification,E as createNotifications,H as createOperation,G as createOperations,J as createPanel,I as createPanels,L as createPermission,K as createPermissions,N as createPreset,M as createPresets,O as createRelation,Q as createRole,P as createRoles,S as createShare,R as createShares,U as createTranslation,T as createTranslations,W as createUser,V as createUsers,Y as createWebhook,X as createWebhooks,_ as deleteCollection,Z as deleteComment,aa as deleteDashboard,$ as deleteDashboards,ba as deleteField,da as deleteFile,ca as deleteFiles,fa as deleteFlow,ea as deleteFlows,ha as deleteFolder,ga as deleteFolders,ja as deleteItem,ia as deleteItems,la as deleteNotification,ka as deleteNotifications,na as deleteOperation,ma as deleteOperations,pa as deletePanel,oa as deletePanels,ra as deletePermission,qa as deletePermissions,ta as deletePreset,sa as deletePresets,ua as deleteRelation,wa as deleteRole,va as deleteRoles,ya as deleteShare,xa as deleteShares,Aa as deleteTranslation,za as deleteTranslations,Ca as deleteUser,Ba as deleteUsers,Ea as deleteWebhook,Da as deleteWebhooks,Ec as disableTwoFactor,Dc as enableTwoFactor,sc as generateHash,Cc as generateTwoFactorSecret,i as generateUid,e as graphql,x as importFile,xc as inviteShare,Ac as inviteUser,l as login,m as logout,a as memoryStorage,h as messageCallback,n as passwordRequest,o as passwordReset,g as pong,Gc as queryToParams,Fa as readActivities,Ga as readActivity,Ja as readCollection,Ia as readCollections,La as readDashboard,Ka as readDashboards,Ma as readExtensions,Pa as readField,Na as readFields,Oa as readFieldsByCollection,Ra as readFile,Qa as readFiles,Ta as readFlow,Sa as readFlows,Va as readFolder,Ua as readFolders,Bb as readGraphqlSdl,Xa as readItem,Wa as readItems,vb as readMe,Za as readNotification,Ya as readNotifications,Eb as readOpenApiSpec,$a as readOperation,_a as readOperations,bb as readPanel,ab as readPanels,db as readPermission,cb as readPermissions,fb as readPreset,eb as readPresets,p as readProviders,ib as readRelation,hb as readRelationByCollection,gb as readRelations,kb as readRevision,jb as readRevisions,mb as readRole,lb as readRoles,nb as readSettings,pb as readShare,yc as readShareInfo,ob as readShares,qb as readSingleton,sb as readTranslation,rb as readTranslations,ub as readUser,tb as readUsers,xb as readWebhook,wb as readWebhooks,j as realtime,q as refresh,Fc as rest,yb as schemaApply,zb as schemaDiff,Ab as schemaSnapshot,Cb as serverHealth,Db as serverInfo,Fb as serverPing,k as sleep,c as staticToken,rc as triggerFlow,vc as triggerOperation,Hb as updateCollection,Gb as updateComment,Jb as updateDashboard,Ib as updateDashboards,Kb as updateField,Mb as updateFile,Lb as updateFiles,Ob as updateFlow,Nb as updateFlows,Qb as updateFolder,Pb as updateFolders,Sb as updateItem,Rb as updateItems,mc as updateMe,Ub as updateNotification,Tb as updateNotifications,Wb as updateOperation,Vb as updateOperations,Yb as updatePanel,Xb as updatePanels,_b as updatePermission,Zb as updatePermissions,ac as updatePreset,$b as updatePresets,bc as updateRelation,dc as updateRole,cc as updateRoles,ec as updateSettings,gc as updateShare,fc as updateShares,hc as updateSingleton,jc as updateTranslation,ic as updateTranslations,lc as updateUser,kc as updateUsers,oc as updateWebhook,nc as updateWebhooks,w as uploadFiles,zc as utilitySort,qc as utilsExport,uc as utilsImport,tc as verifyHash,Hc as withToken};
import{$ as fa,$a as fb,$b as fc,A as G,Aa as Ga,Ab as Gb,Ac as Gc,B as H,Ba as Ha,Bb as Hb,Bc as Hc,C as I,Ca as Ia,Cb as Ib,Cc as Ic,D as J,Da as Ja,Db as Jb,Dc as Jc,E as K,Ea as Ka,Eb as Kb,Ec as Kc,F as L,Fa as La,Fb as Lb,Fc as Lc,G as M,Ga as Ma,Gb as Mb,H as N,Ha as Na,Hb as Nb,I as O,Ia as Oa,Ib as Ob,J as P,Ja as Pa,Jb as Pb,K as Q,Ka as Qa,Kb as Qb,L as R,La as Ra,Lb as Rb,M as S,Ma as Sa,Mb as Sb,N as T,Na as Ta,Nb as Tb,O as U,Oa as Ua,Ob as Ub,P as V,Pa as Va,Pb as Vb,Q as W,Qa as Wa,Qb as Wb,R as X,Ra as Xa,Rb as Xb,S as Y,Sa as Ya,Sb as Yb,T as Z,Ta as Za,Tb as Zb,U as _,Ua as _a,Ub as _b,V as $,Va as $a,Vb as $b,W as aa,Wa as ab,Wb as ac,X as ba,Xa as bb,Xb as bc,Y as ca,Ya as cb,Yb as cc,Z as da,Za as db,Zb as dc,_ as ea,_a as eb,_b as ec,a,aa as ga,ab as gb,ac as gc,b,ba as ha,bb as hb,bc as hc,c,ca as ia,cb as ib,cc as ic,d,da as ja,db as jb,dc as jc,e,ea as ka,eb as kb,ec as kc,f as l,fa as la,fb as lb,fc as lc,g as m,ga as ma,gb as mb,gc as mc,h as n,ha as na,hb as nb,hc as nc,i as o,ia as oa,ib as ob,ic as oc,j as p,ja as pa,jb as pb,jc as pc,k as q,ka as qa,kb as qb,kc as qc,l as r,la as ra,lb as rb,lc as rc,m as s,ma as sa,mb as sb,mc as sc,n as t,na as ta,nb as tb,nc as tc,o as u,oa as ua,ob as ub,oc as uc,p as v,pa as va,pb as vb,pc as vc,q as w,qa as wa,qb as wb,qc as wc,r as x,ra as xa,rb as xb,rc as xc,s as y,sa as ya,sb as yb,sc as yc,t as z,ta as za,tb as zb,tc as zc,u as A,ua as Aa,ub as Ab,uc as Ac,v as B,va as Ba,vb as Bb,vc as Bc,w as C,wa as Ca,wb as Cb,wc as Cc,x as D,xa as Da,xb as Db,xc as Dc,y as E,ya as Ea,yb as Eb,yc as Ec,z as F,za as Fa,zb as Fb,zc as Fc}from"./chunk-74XE5VTR.js";import{a as f,b as g,c as h,d as i,e as j,f as k}from"./chunk-7KQ2R3YI.js";export{Ec as acceptUserInvite,Ka as aggregate,f as auth,zc as authenticateShare,b as authentication,sc as clearCache,s as createCollection,r as createComment,u as createDashboard,t as createDashboards,d as createDirectus,v as createField,z as createFlow,y as createFlows,B as createFolder,A as createFolders,D as createItem,C as createItems,F as createNotification,E as createNotifications,H as createOperation,G as createOperations,J as createPanel,I as createPanels,L as createPermission,K as createPermissions,N as createPreset,M as createPresets,O as createRelation,Q as createRole,P as createRoles,S as createShare,R as createShares,U as createTranslation,T as createTranslations,W as createUser,V as createUsers,Y as createWebhook,X as createWebhooks,_ as deleteCollection,Z as deleteComment,da as deleteDashboard,ca as deleteDashboards,ea as deleteField,ga as deleteFile,fa as deleteFiles,ia as deleteFlow,ha as deleteFlows,ka as deleteFolder,ja as deleteFolders,ma as deleteItem,la as deleteItems,oa as deleteNotification,na as deleteNotifications,qa as deleteOperation,pa as deleteOperations,sa as deletePanel,ra as deletePanels,ua as deletePermission,ta as deletePermissions,wa as deletePreset,va as deletePresets,xa as deleteRelation,za as deleteRole,ya as deleteRoles,Ba as deleteShare,Aa as deleteShares,Da as deleteTranslation,Ca as deleteTranslations,Fa as deleteUser,Ea as deleteUsers,Ha as deleteWebhook,Ga as deleteWebhooks,Hc as disableTwoFactor,Gc as enableTwoFactor,vc as generateHash,Fc as generateTwoFactorSecret,i as generateUid,e as graphql,x as importFile,Ac as inviteShare,Dc as inviteUser,l as login,m as logout,a as memoryStorage,h as messageCallback,n as passwordRequest,o as passwordReset,g as pong,$ as queryToParams,Ia as readActivities,Ja as readActivity,Ma as readCollection,La as readCollections,Oa as readDashboard,Na as readDashboards,Pa as readExtensions,Sa as readField,Qa as readFields,Ra as readFieldsByCollection,Ua as readFile,Ta as readFiles,Wa as readFlow,Va as readFlows,Ya as readFolder,Xa as readFolders,Eb as readGraphqlSdl,_a as readItem,Za as readItems,yb as readMe,ab as readNotification,$a as readNotifications,Hb as readOpenApiSpec,cb as readOperation,bb as readOperations,eb as readPanel,db as readPanels,gb as readPermission,fb as readPermissions,ib as readPreset,hb as readPresets,p as readProviders,lb as readRelation,kb as readRelationByCollection,jb as readRelations,nb as readRevision,mb as readRevisions,pb as readRole,ob as readRoles,qb as readSettings,sb as readShare,Bc as readShareInfo,rb as readShares,tb as readSingleton,vb as readTranslation,ub as readTranslations,xb as readUser,wb as readUsers,Ab as readWebhook,zb as readWebhooks,j as realtime,q as refresh,Ic as rest,Bb as schemaApply,Cb as schemaDiff,Db as schemaSnapshot,Fb as serverHealth,Gb as serverInfo,Ib as serverPing,k as sleep,c as staticToken,ba as throwIfCoreCollection,aa as throwIfEmpty,uc as triggerFlow,yc as triggerOperation,Kb as updateCollection,Jb as updateComment,Mb as updateDashboard,Lb as updateDashboards,Nb as updateField,Pb as updateFile,Ob as updateFiles,Rb as updateFlow,Qb as updateFlows,Tb as updateFolder,Sb as updateFolders,Vb as updateItem,Ub as updateItems,pc as updateMe,Xb as updateNotification,Wb as updateNotifications,Zb as updateOperation,Yb as updateOperations,$b as updatePanel,_b as updatePanels,bc as updatePermission,ac as updatePermissions,dc as updatePreset,cc as updatePresets,ec as updateRelation,gc as updateRole,fc as updateRoles,hc as updateSettings,jc as updateShare,ic as updateShares,kc as updateSingleton,mc as updateTranslation,lc as updateTranslations,oc as updateUser,nc as updateUsers,rc as updateWebhook,qc as updateWebhooks,w as uploadFiles,Cc as utilitySort,tc as utilsExport,xc as utilsImport,wc as verifyHash,Jc as withOptions,Kc as withSearch,Lc as withToken};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import { D as DirectusClient } from '../client-e8d6bf91.js';
import { D as DirectusClient } from '../client-5fa2f889.js';
import { a as WebSocketConfig, d as WebSocketClient } from '../output-35b496cf.js';

@@ -40,6 +40,7 @@ export { R as RemoveEventHandler, S as SubscribeOptions, f as SubscriptionEvents, e as SubscriptionOptionsEvents, g as SubscriptionOutput, h as SubscriptionPayload, W as WebSocketAuthModes, c as WebSocketEventHandler, b as WebSocketEvents } from '../output-35b496cf.js';

* @param socket WebSocket
* @param number timeout
*
* @returns Incoming message object
*/
declare const messageCallback: (socket: globalThis.WebSocket) => Promise<Record<string, any> | MessageEvent<string>>;
declare const messageCallback: (socket: globalThis.WebSocket, timeout?: number) => Promise<Record<string, any> | MessageEvent<string> | undefined>;

@@ -46,0 +47,0 @@ /**

@@ -1,2 +0,2 @@

import{a,b,c,d,e,f}from"../chunk-2VYDJM4Y.js";export{a as auth,d as generateUid,c as messageCallback,b as pong,e as realtime,f as sleep};
import{a,b,c,d,e,f}from"../chunk-7KQ2R3YI.js";export{a as auth,d as generateUid,c as messageCallback,b as pong,e as realtime,f as sleep};
//# sourceMappingURL=index.js.map

@@ -1,4 +0,4 @@

export { f as RestClient, R as RestCommand, g as RestConfig, e as login, l as loginOptions } from '../login-0506af09.js';
export { C as CreateActivityOutput, d as CreateCollectionOutput, f as CreateDashboardOutput, i as CreateFieldOutput, k as CreateFileOutput, n as CreateFlowOutput, s as CreateFolderOutput, w as CreateItemOutput, z as CreateNotificationOutput, D as CreateOperationOutput, G as CreatePanelOutput, J as CreatePermissionOutput, M as CreatePresetOutput, P as CreateRelationOutput, S as CreateRoleOutput, V as CreateShareOutput, Y as CreateTranslationOutput, $ as CreateUserOutput, a2 as CreateWebhookOutput, aO as ExtensionTypes, cS as FileFormat, bU as OpenApiSpecOutput, aD as ReadActivityOutput, aH as ReadCollectionOutput, aK as ReadDashboardOutput, aN as ReadExtensionOutput, aQ as ReadFieldOutput, aU as ReadFileOutput, aX as ReadFlowOutput, a_ as ReadFolderOutput, b1 as ReadItemOutput, b4 as ReadNotificationOutput, b7 as ReadOperationOutput, ba as ReadPanelOutput, bd as ReadPermissionOutput, bg as ReadPresetOutput, R as ReadProviderOutput, bj as ReadRelationOutput, bn as ReadRevisionOutput, bq as ReadRoleOutput, bt as ReadSettingOutput, bv as ReadShareOutput, by as ReadSingletonOutput, bA as ReadTranslationOutput, bD as ReadUserOutput, bH as ReadWebhookOutput, bL as SchemaDiffOutput, bN as SchemaSnapshotOutput, bQ as ServerHealthOutput, bS as ServerInfoOutput, bX as UpdateActivityOutput, bZ as UpdateCollectionOutput, b$ as UpdateDashboardOutput, c2 as UpdateFieldOutput, c4 as UpdateFileOutput, c7 as UpdateFlowOutput, ca as UpdateFolderOutput, cd as UpdateItemOutput, cg as UpdateNotificationOutput, cj as UpdateOperationOutput, cm as UpdatePanelOutput, cp as UpdatePermissionOutput, cs as UpdatePresetOutput, cv as UpdateRelationOutput, cx as UpdateRoleOutput, cA as UpdateSettingOutput, cC as UpdateShareOutput, cF as UpdateSingletonOutput, cH as UpdateTranslationOutput, cK as UpdateUserOutput, cO as UpdateWebhookOutput, d2 as acceptUserInvite, aG as aggregate, d9 as asSearch, cZ as authenticateShare, cR as clearCache, e as createCollection, c as createComment, h as createDashboard, g as createDashboards, j as createField, q as createFlow, o as createFlows, v as createFolder, t as createFolders, y as createItem, x as createItems, B as createNotification, A as createNotifications, F as createOperation, E as createOperations, I as createPanel, H as createPanels, L as createPermission, K as createPermissions, O as createPreset, N as createPresets, Q as createRelation, U as createRole, T as createRoles, X as createShare, W as createShares, _ as createTranslation, Z as createTranslations, a1 as createUser, a0 as createUsers, a4 as createWebhook, a3 as createWebhooks, a6 as deleteCollection, a5 as deleteComment, a8 as deleteDashboard, a7 as deleteDashboards, a9 as deleteField, ab as deleteFile, aa as deleteFiles, ad as deleteFlow, ac as deleteFlows, af as deleteFolder, ae as deleteFolders, ah as deleteItem, ag as deleteItems, aj as deleteNotification, ai as deleteNotifications, al as deleteOperation, ak as deleteOperations, an as deletePanel, am as deletePanels, ap as deletePermission, ao as deletePermissions, ar as deletePreset, aq as deletePresets, as as deleteRelation, au as deleteRole, at as deleteRoles, aw as deleteShare, av as deleteShares, ay as deleteTranslation, ax as deleteTranslations, aA as deleteUser, az as deleteUsers, aC as deleteWebhook, aB as deleteWebhooks, d5 as disableTwoFactor, d4 as enableTwoFactor, cV as generateHash, d3 as generateTwoFactorSecret, m as importFile, c_ as inviteShare, d1 as inviteUser, l as logout, p as passwordRequest, a as passwordReset, d7 as queryToParams, aE as readActivities, aF as readActivity, aJ as readCollection, aI as readCollections, aM as readDashboard, aL as readDashboards, aP as readExtensions, aT as readField, aR as readFields, aS as readFieldsByCollection, aW as readFile, aV as readFiles, aZ as readFlow, aY as readFlows, b0 as readFolder, a$ as readFolders, bP as readGraphqlSdl, b3 as readItem, b2 as readItems, bG as readMe, b6 as readNotification, b5 as readNotifications, bV as readOpenApiSpec, b9 as readOperation, b8 as readOperations, bc as readPanel, bb as readPanels, bf as readPermission, be as readPermissions, bi as readPreset, bh as readPresets, r as readProviders, bm as readRelation, bl as readRelationByCollection, bk as readRelations, bp as readRevision, bo as readRevisions, bs as readRole, br as readRoles, bu as readSettings, bx as readShare, c$ as readShareInfo, bw as readShares, bz as readSingleton, bC as readTranslation, bB as readTranslations, bF as readUser, bE as readUsers, bJ as readWebhook, bI as readWebhooks, b as refresh, d6 as rest, bK as schemaApply, bM as schemaDiff, bO as schemaSnapshot, bR as serverHealth, bT as serverInfo, bW as serverPing, cU as triggerFlow, cY as triggerOperation, b_ as updateCollection, bY as updateComment, c1 as updateDashboard, c0 as updateDashboards, c3 as updateField, c6 as updateFile, c5 as updateFiles, c9 as updateFlow, c8 as updateFlows, cc as updateFolder, cb as updateFolders, cf as updateItem, ce as updateItems, cN as updateMe, ci as updateNotification, ch as updateNotifications, cl as updateOperation, ck as updateOperations, co as updatePanel, cn as updatePanels, cr as updatePermission, cq as updatePermissions, cu as updatePreset, ct as updatePresets, cw as updateRelation, cz as updateRole, cy as updateRoles, cB as updateSettings, cE as updateShare, cD as updateShares, cG as updateSingleton, cJ as updateTranslation, cI as updateTranslations, cM as updateUser, cL as updateUsers, cQ as updateWebhook, cP as updateWebhooks, u as uploadFiles, d0 as utilitySort, cT as utilsExport, cX as utilsImport, cW as verifyHash, d8 as withToken } from '../index-0aafbb19.js';
export { L as LoginOptions, e as RestClient, R as RestCommand, f as RestConfig, l as login } from '../login-170db6ff.js';
export { C as CreateActivityOutput, d as CreateCollectionOutput, f as CreateDashboardOutput, i as CreateFieldOutput, k as CreateFileOutput, n as CreateFlowOutput, s as CreateFolderOutput, w as CreateItemOutput, z as CreateNotificationOutput, D as CreateOperationOutput, G as CreatePanelOutput, J as CreatePermissionOutput, M as CreatePresetOutput, P as CreateRelationOutput, S as CreateRoleOutput, V as CreateShareOutput, Y as CreateTranslationOutput, $ as CreateUserOutput, a2 as CreateWebhookOutput, aO as ExtensionTypes, cS as FileFormat, bU as OpenApiSpecOutput, aD as ReadActivityOutput, aH as ReadCollectionOutput, aK as ReadDashboardOutput, aN as ReadExtensionOutput, aQ as ReadFieldOutput, aU as ReadFileOutput, aX as ReadFlowOutput, a_ as ReadFolderOutput, b1 as ReadItemOutput, b4 as ReadNotificationOutput, b7 as ReadOperationOutput, ba as ReadPanelOutput, bd as ReadPermissionOutput, bg as ReadPresetOutput, R as ReadProviderOutput, bj as ReadRelationOutput, bn as ReadRevisionOutput, bq as ReadRoleOutput, bt as ReadSettingOutput, bv as ReadShareOutput, by as ReadSingletonOutput, bA as ReadTranslationOutput, bD as ReadUserOutput, bH as ReadWebhookOutput, bL as SchemaDiffOutput, bN as SchemaSnapshotOutput, bQ as ServerHealthOutput, bS as ServerInfoOutput, bX as UpdateActivityOutput, bZ as UpdateCollectionOutput, b$ as UpdateDashboardOutput, c2 as UpdateFieldOutput, c4 as UpdateFileOutput, c7 as UpdateFlowOutput, ca as UpdateFolderOutput, cd as UpdateItemOutput, cg as UpdateNotificationOutput, cj as UpdateOperationOutput, cm as UpdatePanelOutput, cp as UpdatePermissionOutput, cs as UpdatePresetOutput, cv as UpdateRelationOutput, cx as UpdateRoleOutput, cA as UpdateSettingOutput, cC as UpdateShareOutput, cF as UpdateSingletonOutput, cH as UpdateTranslationOutput, cK as UpdateUserOutput, cO as UpdateWebhookOutput, d2 as acceptUserInvite, aG as aggregate, cZ as authenticateShare, cR as clearCache, e as createCollection, c as createComment, h as createDashboard, g as createDashboards, j as createField, q as createFlow, o as createFlows, v as createFolder, t as createFolders, y as createItem, x as createItems, B as createNotification, A as createNotifications, F as createOperation, E as createOperations, I as createPanel, H as createPanels, L as createPermission, K as createPermissions, O as createPreset, N as createPresets, Q as createRelation, U as createRole, T as createRoles, X as createShare, W as createShares, _ as createTranslation, Z as createTranslations, a1 as createUser, a0 as createUsers, a4 as createWebhook, a3 as createWebhooks, a6 as deleteCollection, a5 as deleteComment, a8 as deleteDashboard, a7 as deleteDashboards, a9 as deleteField, ab as deleteFile, aa as deleteFiles, ad as deleteFlow, ac as deleteFlows, af as deleteFolder, ae as deleteFolders, ah as deleteItem, ag as deleteItems, aj as deleteNotification, ai as deleteNotifications, al as deleteOperation, ak as deleteOperations, an as deletePanel, am as deletePanels, ap as deletePermission, ao as deletePermissions, ar as deletePreset, aq as deletePresets, as as deleteRelation, au as deleteRole, at as deleteRoles, aw as deleteShare, av as deleteShares, ay as deleteTranslation, ax as deleteTranslations, aA as deleteUser, az as deleteUsers, aC as deleteWebhook, aB as deleteWebhooks, d5 as disableTwoFactor, d4 as enableTwoFactor, cV as generateHash, d3 as generateTwoFactorSecret, m as importFile, c_ as inviteShare, d1 as inviteUser, l as logout, p as passwordRequest, a as passwordReset, da as queryToParams, aE as readActivities, aF as readActivity, aJ as readCollection, aI as readCollections, aM as readDashboard, aL as readDashboards, aP as readExtensions, aT as readField, aR as readFields, aS as readFieldsByCollection, aW as readFile, aV as readFiles, aZ as readFlow, aY as readFlows, b0 as readFolder, a$ as readFolders, bP as readGraphqlSdl, b3 as readItem, b2 as readItems, bG as readMe, b6 as readNotification, b5 as readNotifications, bV as readOpenApiSpec, b9 as readOperation, b8 as readOperations, bc as readPanel, bb as readPanels, bf as readPermission, be as readPermissions, bi as readPreset, bh as readPresets, r as readProviders, bm as readRelation, bl as readRelationByCollection, bk as readRelations, bp as readRevision, bo as readRevisions, bs as readRole, br as readRoles, bu as readSettings, bx as readShare, c$ as readShareInfo, bw as readShares, bz as readSingleton, bC as readTranslation, bB as readTranslations, bF as readUser, bE as readUsers, bJ as readWebhook, bI as readWebhooks, b as refresh, d6 as rest, bK as schemaApply, bM as schemaDiff, bO as schemaSnapshot, bR as serverHealth, bT as serverInfo, bW as serverPing, dc as throwIfCoreCollection, db as throwIfEmpty, cU as triggerFlow, cY as triggerOperation, b_ as updateCollection, bY as updateComment, c1 as updateDashboard, c0 as updateDashboards, c3 as updateField, c6 as updateFile, c5 as updateFiles, c9 as updateFlow, c8 as updateFlows, cc as updateFolder, cb as updateFolders, cf as updateItem, ce as updateItems, cN as updateMe, ci as updateNotification, ch as updateNotifications, cl as updateOperation, ck as updateOperations, co as updatePanel, cn as updatePanels, cr as updatePermission, cq as updatePermissions, cu as updatePreset, ct as updatePresets, cw as updateRelation, cz as updateRole, cy as updateRoles, cB as updateSettings, cE as updateShare, cD as updateShares, cG as updateSingleton, cJ as updateTranslation, cI as updateTranslations, cM as updateUser, cL as updateUsers, cQ as updateWebhook, cP as updateWebhooks, u as uploadFiles, d0 as utilitySort, cT as utilsExport, cX as utilsImport, cW as verifyHash, d7 as withOptions, d8 as withSearch, d9 as withToken } from '../index-a2b3b0f1.js';
import '../output-35b496cf.js';
import '../client-e8d6bf91.js';
import '../client-5fa2f889.js';

@@ -1,2 +0,2 @@

import{$ as W,$a as Wa,$b as Wb,A as v,Aa as va,Ab as vb,Ac as vc,B as w,Ba as wa,Bb as wb,Bc as wc,C as x,Ca as xa,Cb as xb,Cc as xc,D as y,Da as ya,Db as yb,E as z,Ea as za,Eb as zb,F as A,Fa as Aa,Fb as Ab,G as B,Ga as Ba,Gb as Bb,H as C,Ha as Ca,Hb as Cb,I as D,Ia as Da,Ib as Db,J as E,Ja as Ea,Jb as Eb,K as F,Ka as Fa,Kb as Fb,L as G,La as Ga,Lb as Gb,M as H,Ma as Ha,Mb as Hb,N as I,Na as Ia,Nb as Ib,O as J,Oa as Ja,Ob as Jb,P as K,Pa as Ka,Pb as Kb,Q as L,Qa as La,Qb as Lb,R as M,Ra as Ma,Rb as Mb,S as N,Sa as Na,Sb as Nb,T as O,Ta as Oa,Tb as Ob,U as P,Ua as Pa,Ub as Pb,V as Q,Va as Qa,Vb as Qb,W as R,Wa as Ra,Wb as Rb,X as S,Xa as Sa,Xb as Sb,Y as T,Ya as Ta,Yb as Tb,Z as U,Za as Ua,Zb as Ub,_ as V,_a as Va,_b as Vb,aa as X,ab as Xa,ac as Xb,ba as Y,bb as Ya,bc as Yb,ca as Z,cb as Za,cc as Zb,da as _,db as _a,dc as _b,ea as $,eb as $a,ec as $b,f as a,fa as aa,fb as ab,fc as ac,g as b,ga as ba,gb as bb,gc as bc,h as c,ha as ca,hb as cb,hc as cc,i as d,ia as da,ib as db,ic as dc,j as e,ja as ea,jb as eb,jc as ec,k as f,ka as fa,kb as fb,kc as fc,l as g,la as ga,lb as gb,lc as gc,m as h,ma as ha,mb as hb,mc as hc,n as i,na as ia,nb as ib,nc as ic,o as j,oa as ja,ob as jb,oc as jc,p as k,pa as ka,pb as kb,pc as kc,q as l,qa as la,qb as lb,qc as lc,r as m,ra as ma,rb as mb,rc as mc,s as n,sa as na,sb as nb,sc as nc,t as o,ta as oa,tb as ob,tc as oc,u as p,ua as pa,ub as pb,uc as pc,v as q,va as qa,vb as qb,vc as qc,w as r,wa as ra,wb as rb,wc as rc,x as s,xa as sa,xb as sb,xc as sc,y as t,ya as ta,yb as tb,yc as tc,z as u,za as ua,zb as ub,zc as uc}from"../chunk-IKZBOPD7.js";import"../chunk-2VYDJM4Y.js";export{qc as acceptUserInvite,wa as aggregate,xc as asSearch,lc as authenticateShare,ec as clearCache,h as createCollection,g as createComment,j as createDashboard,i as createDashboards,k as createField,o as createFlow,n as createFlows,q as createFolder,p as createFolders,s as createItem,r as createItems,u as createNotification,t as createNotifications,w as createOperation,v as createOperations,y as createPanel,x as createPanels,A as createPermission,z as createPermissions,C as createPreset,B as createPresets,D as createRelation,F as createRole,E as createRoles,H as createShare,G as createShares,J as createTranslation,I as createTranslations,L as createUser,K as createUsers,N as createWebhook,M as createWebhooks,P as deleteCollection,O as deleteComment,R as deleteDashboard,Q as deleteDashboards,S as deleteField,U as deleteFile,T as deleteFiles,W as deleteFlow,V as deleteFlows,Y as deleteFolder,X as deleteFolders,_ as deleteItem,Z as deleteItems,aa as deleteNotification,$ as deleteNotifications,ca as deleteOperation,ba as deleteOperations,ea as deletePanel,da as deletePanels,ga as deletePermission,fa as deletePermissions,ia as deletePreset,ha as deletePresets,ja as deleteRelation,la as deleteRole,ka as deleteRoles,na as deleteShare,ma as deleteShares,pa as deleteTranslation,oa as deleteTranslations,ra as deleteUser,qa as deleteUsers,ta as deleteWebhook,sa as deleteWebhooks,tc as disableTwoFactor,sc as enableTwoFactor,hc as generateHash,rc as generateTwoFactorSecret,m as importFile,mc as inviteShare,pc as inviteUser,a as login,b as logout,c as passwordRequest,d as passwordReset,vc as queryToParams,ua as readActivities,va as readActivity,ya as readCollection,xa as readCollections,Aa as readDashboard,za as readDashboards,Ba as readExtensions,Ea as readField,Ca as readFields,Da as readFieldsByCollection,Ga as readFile,Fa as readFiles,Ia as readFlow,Ha as readFlows,Ka as readFolder,Ja as readFolders,qb as readGraphqlSdl,Ma as readItem,La as readItems,kb as readMe,Oa as readNotification,Na as readNotifications,tb as readOpenApiSpec,Qa as readOperation,Pa as readOperations,Sa as readPanel,Ra as readPanels,Ua as readPermission,Ta as readPermissions,Wa as readPreset,Va as readPresets,e as readProviders,Za as readRelation,Ya as readRelationByCollection,Xa as readRelations,$a as readRevision,_a as readRevisions,bb as readRole,ab as readRoles,cb as readSettings,eb as readShare,nc as readShareInfo,db as readShares,fb as readSingleton,hb as readTranslation,gb as readTranslations,jb as readUser,ib as readUsers,mb as readWebhook,lb as readWebhooks,f as refresh,uc as rest,nb as schemaApply,ob as schemaDiff,pb as schemaSnapshot,rb as serverHealth,sb as serverInfo,ub as serverPing,gc as triggerFlow,kc as triggerOperation,wb as updateCollection,vb as updateComment,yb as updateDashboard,xb as updateDashboards,zb as updateField,Bb as updateFile,Ab as updateFiles,Db as updateFlow,Cb as updateFlows,Fb as updateFolder,Eb as updateFolders,Hb as updateItem,Gb as updateItems,bc as updateMe,Jb as updateNotification,Ib as updateNotifications,Lb as updateOperation,Kb as updateOperations,Nb as updatePanel,Mb as updatePanels,Pb as updatePermission,Ob as updatePermissions,Rb as updatePreset,Qb as updatePresets,Sb as updateRelation,Ub as updateRole,Tb as updateRoles,Vb as updateSettings,Xb as updateShare,Wb as updateShares,Yb as updateSingleton,_b as updateTranslation,Zb as updateTranslations,ac as updateUser,$b as updateUsers,dc as updateWebhook,cc as updateWebhooks,l as uploadFiles,oc as utilitySort,fc as utilsExport,jc as utilsImport,ic as verifyHash,wc as withToken};
import{$ as W,$a as Wa,$b as Wb,A as v,Aa as va,Ab as vb,Ac as vc,B as w,Ba as wa,Bb as wb,Bc as wc,C as x,Ca as xa,Cb as xb,Cc as xc,D as y,Da as ya,Db as yb,Dc as yc,E as z,Ea as za,Eb as zb,Ec as zc,F as A,Fa as Aa,Fb as Ab,Fc as Ac,G as B,Ga as Ba,Gb as Bb,H as C,Ha as Ca,Hb as Cb,I as D,Ia as Da,Ib as Db,J as E,Ja as Ea,Jb as Eb,K as F,Ka as Fa,Kb as Fb,L as G,La as Ga,Lb as Gb,M as H,Ma as Ha,Mb as Hb,N as I,Na as Ia,Nb as Ib,O as J,Oa as Ja,Ob as Jb,P as K,Pa as Ka,Pb as Kb,Q as L,Qa as La,Qb as Lb,R as M,Ra as Ma,Rb as Mb,S as N,Sa as Na,Sb as Nb,T as O,Ta as Oa,Tb as Ob,U as P,Ua as Pa,Ub as Pb,V as Q,Va as Qa,Vb as Qb,W as R,Wa as Ra,Wb as Rb,X as S,Xa as Sa,Xb as Sb,Y as T,Ya as Ta,Yb as Tb,Z as U,Za as Ua,Zb as Ub,_ as V,_a as Va,_b as Vb,aa as X,ab as Xa,ac as Xb,ba as Y,bb as Ya,bc as Yb,ca as Z,cb as Za,cc as Zb,da as _,db as _a,dc as _b,ea as $,eb as $a,ec as $b,f as a,fa as aa,fb as ab,fc as ac,g as b,ga as ba,gb as bb,gc as bc,h as c,ha as ca,hb as cb,hc as cc,i as d,ia as da,ib as db,ic as dc,j as e,ja as ea,jb as eb,jc as ec,k as f,ka as fa,kb as fb,kc as fc,l as g,la as ga,lb as gb,lc as gc,m as h,ma as ha,mb as hb,mc as hc,n as i,na as ia,nb as ib,nc as ic,o as j,oa as ja,ob as jb,oc as jc,p as k,pa as ka,pb as kb,pc as kc,q as l,qa as la,qb as lb,qc as lc,r as m,ra as ma,rb as mb,rc as mc,s as n,sa as na,sb as nb,sc as nc,t as o,ta as oa,tb as ob,tc as oc,u as p,ua as pa,ub as pb,uc as pc,v as q,va as qa,vb as qb,vc as qc,w as r,wa as ra,wb as rb,wc as rc,x as s,xa as sa,xb as sb,xc as sc,y as t,ya as ta,yb as tb,yc as tc,z as u,za as ua,zb as ub,zc as uc}from"../chunk-74XE5VTR.js";import"../chunk-7KQ2R3YI.js";export{tc as acceptUserInvite,za as aggregate,oc as authenticateShare,hc as clearCache,h as createCollection,g as createComment,j as createDashboard,i as createDashboards,k as createField,o as createFlow,n as createFlows,q as createFolder,p as createFolders,s as createItem,r as createItems,u as createNotification,t as createNotifications,w as createOperation,v as createOperations,y as createPanel,x as createPanels,A as createPermission,z as createPermissions,C as createPreset,B as createPresets,D as createRelation,F as createRole,E as createRoles,H as createShare,G as createShares,J as createTranslation,I as createTranslations,L as createUser,K as createUsers,N as createWebhook,M as createWebhooks,P as deleteCollection,O as deleteComment,U as deleteDashboard,T as deleteDashboards,V as deleteField,X as deleteFile,W as deleteFiles,Z as deleteFlow,Y as deleteFlows,$ as deleteFolder,_ as deleteFolders,ba as deleteItem,aa as deleteItems,da as deleteNotification,ca as deleteNotifications,fa as deleteOperation,ea as deleteOperations,ha as deletePanel,ga as deletePanels,ja as deletePermission,ia as deletePermissions,la as deletePreset,ka as deletePresets,ma as deleteRelation,oa as deleteRole,na as deleteRoles,qa as deleteShare,pa as deleteShares,sa as deleteTranslation,ra as deleteTranslations,ua as deleteUser,ta as deleteUsers,wa as deleteWebhook,va as deleteWebhooks,wc as disableTwoFactor,vc as enableTwoFactor,kc as generateHash,uc as generateTwoFactorSecret,m as importFile,pc as inviteShare,sc as inviteUser,a as login,b as logout,c as passwordRequest,d as passwordReset,Q as queryToParams,xa as readActivities,ya as readActivity,Ba as readCollection,Aa as readCollections,Da as readDashboard,Ca as readDashboards,Ea as readExtensions,Ha as readField,Fa as readFields,Ga as readFieldsByCollection,Ja as readFile,Ia as readFiles,La as readFlow,Ka as readFlows,Na as readFolder,Ma as readFolders,tb as readGraphqlSdl,Pa as readItem,Oa as readItems,nb as readMe,Ra as readNotification,Qa as readNotifications,wb as readOpenApiSpec,Ta as readOperation,Sa as readOperations,Va as readPanel,Ua as readPanels,Xa as readPermission,Wa as readPermissions,Za as readPreset,Ya as readPresets,e as readProviders,ab as readRelation,$a as readRelationByCollection,_a as readRelations,cb as readRevision,bb as readRevisions,eb as readRole,db as readRoles,fb as readSettings,hb as readShare,qc as readShareInfo,gb as readShares,ib as readSingleton,kb as readTranslation,jb as readTranslations,mb as readUser,lb as readUsers,pb as readWebhook,ob as readWebhooks,f as refresh,xc as rest,qb as schemaApply,rb as schemaDiff,sb as schemaSnapshot,ub as serverHealth,vb as serverInfo,xb as serverPing,S as throwIfCoreCollection,R as throwIfEmpty,jc as triggerFlow,nc as triggerOperation,zb as updateCollection,yb as updateComment,Bb as updateDashboard,Ab as updateDashboards,Cb as updateField,Eb as updateFile,Db as updateFiles,Gb as updateFlow,Fb as updateFlows,Ib as updateFolder,Hb as updateFolders,Kb as updateItem,Jb as updateItems,ec as updateMe,Mb as updateNotification,Lb as updateNotifications,Ob as updateOperation,Nb as updateOperations,Qb as updatePanel,Pb as updatePanels,Sb as updatePermission,Rb as updatePermissions,Ub as updatePreset,Tb as updatePresets,Vb as updateRelation,Xb as updateRole,Wb as updateRoles,Yb as updateSettings,_b as updateShare,Zb as updateShares,$b as updateSingleton,bc as updateTranslation,ac as updateTranslations,dc as updateUser,cc as updateUsers,gc as updateWebhook,fc as updateWebhooks,l as uploadFiles,rc as utilitySort,ic as utilsExport,mc as utilsImport,lc as verifyHash,yc as withOptions,zc as withSearch,Ac as withToken};
//# sourceMappingURL=index.js.map
{
"name": "@directus/sdk",
"version": "11.0.3",
"version": "12.0.0",
"description": "Directus JavaScript SDK",

@@ -5,0 +5,0 @@ "homepage": "https://directus.io",

@@ -1,2 +0,2 @@

import type { loginOptions } from '../index.js';
import type { LoginOptions } from '../index.js';
import type { DirectusClient } from '../types/client.js';

@@ -8,5 +8,6 @@ import { getRequestUrl } from '../utils/get-request-url.js';

const defaultConfigValues = {
const defaultConfigValues: AuthenticationConfig = {
msRefreshBeforeExpires: 30000, // 30 seconds
autoRefresh: true,
credentials: 'same-origin',
};

@@ -22,16 +23,9 @@

*/
export const authentication = (mode: AuthenticationMode = 'cookie', config: AuthenticationConfig = {}) => {
export const authentication = (mode: AuthenticationMode = 'cookie', config: Partial<AuthenticationConfig> = {}) => {
return <Schema extends object>(client: DirectusClient<Schema>): AuthenticationClient<Schema> => {
config = { ...defaultConfigValues, ...config };
const authConfig = { ...defaultConfigValues, ...config };
let refreshPromise: Promise<AuthenticationData> | null = null;
let refreshTimeout: NodeJS.Timer | null = null;
const storage = config.storage ?? memoryStorage();
const storage = authConfig.storage ?? memoryStorage();
const autoRefresh = 'autoRefresh' in config ? config.autoRefresh : defaultConfigValues.autoRefresh;
const msRefreshBeforeExpires =
typeof config.msRefreshBeforeExpires === 'number'
? config.msRefreshBeforeExpires
: defaultConfigValues.msRefreshBeforeExpires;
const resetStorage = () => {

@@ -57,3 +51,3 @@ storage.set({ access_token: null, refresh_token: null, expires: null, expires_at: null });

if (authData.expires_at < new Date().getTime() + msRefreshBeforeExpires) {
if (authData.expires_at < new Date().getTime() + authConfig.msRefreshBeforeExpires) {
refresh().catch((_err) => {

@@ -72,3 +66,3 @@ /* throw err; */

if (autoRefresh && expires > msRefreshBeforeExpires && expires < Number.MAX_SAFE_INTEGER) {
if (authConfig.autoRefresh && expires > authConfig.msRefreshBeforeExpires && expires < Number.MAX_SAFE_INTEGER) {
if (refreshTimeout) clearTimeout(refreshTimeout);

@@ -82,3 +76,3 @@

});
}, expires - msRefreshBeforeExpires);
}, expires - authConfig.msRefreshBeforeExpires);
}

@@ -97,2 +91,3 @@ };

},
credentials: authConfig.credentials,
} as RequestInit;

@@ -108,5 +103,3 @@

const data = await request<AuthenticationData>(requestUrl.toString(), options).catch((err) => {
throw err;
});
const data = await request<AuthenticationData>(requestUrl.toString(), options, client.globals.fetch);

@@ -126,8 +119,7 @@ setCredentials(data);

refresh,
async login(email: string, password: string, options: loginOptions = {}) {
async login(email: string, password: string, options: LoginOptions = {}) {
// TODO: allow for websocket only authentication
resetStorage();
const authPath = options.provider ? `/auth/login/${options.provider}` : '/auth/login';
const requestUrl = getRequestUrl(client.url, authPath);
const requestUrl = getRequestUrl(client.url, '/auth/login');

@@ -138,9 +130,14 @@ const authData: Record<string, string> = { email, password };

const data = await request<AuthenticationData>(requestUrl.toString(), {
method: 'POST',
headers: {
'Content-Type': 'application/json',
const data = await request<AuthenticationData>(
requestUrl.toString(),
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(authData),
credentials: authConfig.credentials,
},
body: JSON.stringify(authData),
});
client.globals.fetch
);

@@ -158,2 +155,3 @@ setCredentials(data);

},
credentials: authConfig.credentials,
};

@@ -168,3 +166,3 @@

const requestUrl = getRequestUrl(client.url, '/auth/logout');
await request(requestUrl.toString(), options, null);
await request(requestUrl.toString(), options, client.globals.fetch);

@@ -171,0 +169,0 @@ if (refreshTimeout) clearTimeout(refreshTimeout);

@@ -1,2 +0,2 @@

import type { loginOptions } from '../index.js';
import type { LoginOptions } from '../index.js';

@@ -18,4 +18,5 @@ export type AuthenticationMode = 'json' | 'cookie';

export interface AuthenticationConfig {
autoRefresh?: boolean;
msRefreshBeforeExpires?: number;
autoRefresh: boolean;
msRefreshBeforeExpires: number;
credentials: RequestCredentials;
storage?: AuthenticationStorage;

@@ -25,3 +26,3 @@ }

export interface AuthenticationClient<_Schema extends object> {
login(email: string, password: string, options: loginOptions): Promise<AuthenticationData>;
login(email: string, password: string, options?: LoginOptions): Promise<AuthenticationData>;
refresh(): Promise<AuthenticationData>;

@@ -28,0 +29,0 @@ logout(): Promise<void>;

@@ -1,4 +0,13 @@

import type { DirectusClient } from './types/client.js';
import type { ClientGlobals, ClientOptions, DirectusClient } from './types/client.js';
/**
* The default globals supplied to the client
*/
const defaultGlobals = {
fetch: globalThis.fetch,
WebSocket: globalThis.WebSocket,
URL: globalThis.URL,
} as ClientGlobals;
/**
* Creates a client to communicate with a Directus app.

@@ -11,5 +20,10 @@ *

*/
export const createDirectus = <Schema extends object = any>(url: string): DirectusClient<Schema> => {
export const createDirectus = <Schema extends object = any>(
url: string,
options: ClientOptions = {}
): DirectusClient<Schema> => {
const globals = options.globals ? { ...defaultGlobals, ...options.globals } : defaultGlobals;
return {
url: new URL(url),
globals,
url: new globals.URL(url),
with(createExtension) {

@@ -16,0 +30,0 @@ return {

import type { DirectusClient } from '../types/client.js';
import type { GraphqlClient } from './types.js';
import type { GraphqlClient, GraphqlConfig } from './types.js';
import { request } from '../utils/request.js';

@@ -7,2 +7,6 @@ import { getRequestUrl } from '../utils/get-request-url.js';

const defaultConfigValues: GraphqlConfig = {
credentials: 'same-origin',
};
/**

@@ -13,4 +17,5 @@ * Creates a client to communicate with Directus GraphQL.

*/
export const graphql = () => {
export const graphql = (config: Partial<GraphqlConfig> = {}) => {
return <Schema extends object>(client: DirectusClient<Schema>): GraphqlClient<Schema> => {
const gqlConfig = { ...defaultConfigValues, ...config };
return {

@@ -25,2 +30,3 @@ async query<Output extends object = Record<string, any>>(

body: JSON.stringify({ query, variables }),
credentials: gqlConfig.credentials,
};

@@ -46,3 +52,3 @@

return await request<Output>(requestUrl.toString(), options);
return await request<Output>(requestUrl.toString(), options, client.globals.fetch);
},

@@ -49,0 +55,0 @@ };

@@ -9,4 +9,8 @@ export interface GraphqlClient<_Schema extends object> {

export interface GraphqlConfig {
credentials: RequestCredentials;
}
export type GqlResult<Schema extends object, Collection extends keyof Schema> = {
[Key in Collection]: Schema[Collection][];
};

@@ -39,3 +39,3 @@ import type { DirectusClient } from '../types/client.js';

config = { ...defaultRealTimeConfig, ...config };
let socket: globalThis.WebSocket | null = null;
let socket: WebSocket | null = null;
let uid = generateUid();

@@ -57,3 +57,3 @@ let reconnectAttempts = 0;

const getSocketUrl = async (currentClient: AuthWSClient<Schema>) => {
if ('url' in config) return await withStrictAuth(new URL(config.url), currentClient);
if ('url' in config) return await withStrictAuth(new client.globals.URL(config.url), currentClient);

@@ -66,3 +66,3 @@ // if the main URL is a websocket URL use it directly!

// try filling in the defaults based on the main URL
const newUrl = new URL(client.url.toString());
const newUrl = new client.globals.URL(client.url.toString());
newUrl.protocol = client.url.protocol === 'https:' ? 'wss:' : 'ws:';

@@ -108,3 +108,3 @@ newUrl.pathname = '/websocket';

const handleMessages = async (ws: globalThis.WebSocket, currentClient: AuthWSClient<Schema>) => {
const handleMessages = async (ws: WebSocket, currentClient: AuthWSClient<Schema>) => {
while (ws.readyState !== WebSocket.CLOSED) {

@@ -118,7 +118,19 @@ const message = await messageCallback(ws).catch(() => {

if ('type' in message) {
if (message['type'] === 'auth' && hasAuth(currentClient)) {
const access_token = await currentClient.getToken();
if (
message['type'] === 'auth' &&
'status' in message &&
message['status'] === 'error' &&
'error' in message
) {
if (message['error'] === 'TOKEN_EXPIRED' && hasAuth(currentClient)) {
const access_token = await currentClient.getToken();
if (access_token) {
ws.send(auth({ access_token }));
if (access_token) {
ws.send(auth({ access_token }));
continue;
}
}
if (message['error'] === 'AUTH_TIMEOUT') {
ws.close();
continue;

@@ -146,3 +158,3 @@ }

let resolved = false;
const ws = new globalThis.WebSocket(url);
const ws = new client.globals.WebSocket(url);

@@ -165,4 +177,3 @@ ws.addEventListener('open', async (evt: Event) => {

eventHandlers['error'].forEach((handler) => handler.call(ws, evt));
resetConnection();
reconnect.call(this);
ws.close();
if (!resolved) reject(evt);

@@ -238,4 +249,2 @@ });

// const initialMessage = await messageCallback(ws);
async function* subscriptionGenerator(): AsyncGenerator<

@@ -246,4 +255,4 @@ SubscriptionOutput<Schema, Collection, Options['query'], SubscriptionEvents>,

> {
while (subscribed && socket && socket.readyState === WebSocket.OPEN) {
const message = await messageCallback(socket).catch(() => {
while (subscribed && ws && ws.readyState === WebSocket.OPEN) {
const message = await messageCallback(ws).catch(() => {
/* let the loop continue */

@@ -250,0 +259,0 @@ });

@@ -9,8 +9,9 @@ interface WebSocketListener {

* @param socket WebSocket
* @param number timeout
*
* @returns Incoming message object
*/
export const messageCallback = (socket: globalThis.WebSocket) =>
new Promise<Record<string, any> | MessageEvent<string>>((resolve, reject) => {
const handler: WebSocketListener = (data) => {
export const messageCallback = (socket: globalThis.WebSocket, timeout = 1000) =>
new Promise<Record<string, any> | MessageEvent<string> | undefined>((resolve, reject) => {
const handler: WebSocketListener = (data: MessageEvent<string>) => {
try {

@@ -20,8 +21,11 @@ const message = JSON.parse(data.data) as Record<string, any>;

if (typeof message === 'object' && !Array.isArray(message) && message !== null) {
socket.removeEventListener('message', handler);
unbind();
resolve(message);
} else {
unbind();
abort();
}
} catch (err) {
// return the original event to allow customization
socket.removeEventListener('message', handler);
unbind();
resolve(data);

@@ -31,5 +35,19 @@ }

const abort = () => reject();
const unbind = () => {
clearTimeout(timer);
socket.removeEventListener('message', handler);
socket.removeEventListener('error', abort);
socket.removeEventListener('close', abort);
};
socket.addEventListener('message', handler);
socket.addEventListener('error', () => reject());
socket.addEventListener('close', () => reject());
socket.addEventListener('error', abort);
socket.addEventListener('close', abort);
const timer = setTimeout(() => {
unbind();
resolve(undefined);
}, timeout);
});
import type { AuthenticationData, AuthenticationMode } from '../../../index.js';
import type { RestCommand } from '../../types.js';
export interface loginOptions {
export interface LoginOptions {
otp?: string;
provider?: string;
mode?: AuthenticationMode;

@@ -23,10 +22,9 @@ }

password: string,
options: loginOptions = {}
options: LoginOptions = {}
): RestCommand<AuthenticationData, Schema> =>
() => {
const path = options.provider ? `/auth/login/${options.provider}` : '/auth/login';
const data: Record<string, string> = { email, password };
if ('otp' in options) data['otp'] = options.otp;
if ('mode' in options) data['mode'] = options.mode;
return { path, method: 'POST', body: JSON.stringify(data) };
return { path: '/auth/login', method: 'POST', body: JSON.stringify(data) };
};

@@ -7,4 +7,4 @@ import type { AuthenticationData, AuthenticationMode } from '../../../index.js';

*
* @param mode Whether to retrieve the refresh token in the JSON response, or in a httpOnly secure cookie. One of json, cookie.
* @param refresh_token The refresh token to use. If you have the refresh token in a cookie through /auth/login, you don't have to submit it here.
* @param mode Whether to retrieve the refresh token in the JSON response, or in a httpOnly secure cookie. One of json, cookie.
*

@@ -15,4 +15,4 @@ * @returns The new access and refresh tokens for the session.

<Schema extends object>(
refresh_token: string,
mode: AuthenticationMode = 'json'
mode: AuthenticationMode = 'cookie',
refresh_token?: string
): RestCommand<AuthenticationData, Schema> =>

@@ -22,3 +22,3 @@ () => ({

method: 'POST',
body: JSON.stringify({ refresh_token, ...(mode ? { mode } : {}) }),
body: JSON.stringify(mode === 'json' ? { refresh_token, mode } : { mode }),
});
import type { DirectusDashboard } from '../../../schema/dashboard.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -8,11 +9,16 @@

* @returns
* @throws Will throw if keys is empty
*/
export const deleteDashboards =
<Schema extends object>(keys: DirectusDashboard<Schema>['id'][]): RestCommand<void, Schema> =>
() => ({
path: `/dashboards`,
body: JSON.stringify(keys),
method: 'DELETE',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/dashboards`,
body: JSON.stringify(keys),
method: 'DELETE',
};
};
/**

@@ -22,8 +28,13 @@ * Delete an existing dashboard.

* @returns
* @throws Will throw if key is empty
*/
export const deleteDashboard =
<Schema extends object>(key: DirectusDashboard<Schema>['id']): RestCommand<void, Schema> =>
() => ({
path: `/dashboards/${key}`,
method: 'DELETE',
});
() => {
throwIfEmpty(key, 'Key cannot be empty');
return {
path: `/dashboards/${key}`,
method: 'DELETE',
};
};
import type { DirectusField } from '../../../schema/field.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -9,2 +10,4 @@

* @returns
* @throws Will throw if collection is empty
* @throws Will throw if field is empty
*/

@@ -16,5 +19,10 @@ export const deleteField =

): RestCommand<void, Schema> =>
() => ({
path: `/fields/${collection}/${field}`,
method: 'DELETE',
});
() => {
throwIfEmpty(collection, 'Collection cannot be empty');
throwIfEmpty(field, 'Field cannot be empty');
return {
path: `/fields/${collection}/${field}`,
method: 'DELETE',
};
};
import type { DirectusFile } from '../../../schema/file.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -8,11 +9,16 @@

* @returns
* @throws Will throw if keys is empty
*/
export const deleteFiles =
<Schema extends object>(keys: DirectusFile<Schema>['id'][]): RestCommand<void, Schema> =>
() => ({
path: `/files`,
body: JSON.stringify(keys),
method: 'DELETE',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/files`,
body: JSON.stringify(keys),
method: 'DELETE',
};
};
/**

@@ -22,8 +28,13 @@ * Delete an existing file.

* @returns
* @throws Will throw if key is empty
*/
export const deleteFile =
<Schema extends object>(key: DirectusFile<Schema>['id']): RestCommand<void, Schema> =>
() => ({
path: `/files/${key}`,
method: 'DELETE',
});
() => {
throwIfEmpty(key, 'Key cannot be empty');
return {
path: `/files/${key}`,
method: 'DELETE',
};
};
import type { DirectusFlow } from '../../../schema/flow.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -8,11 +9,16 @@

* @returns
* @throws Will throw if keys is empty
*/
export const deleteFlows =
<Schema extends object>(keys: DirectusFlow<Schema>['id'][]): RestCommand<void, Schema> =>
() => ({
path: `/flows`,
body: JSON.stringify(keys),
method: 'DELETE',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/flows`,
body: JSON.stringify(keys),
method: 'DELETE',
};
};
/**

@@ -22,8 +28,13 @@ * Delete an existing flow.

* @returns
* @throws Will throw if key is empty
*/
export const deleteFlow =
<Schema extends object>(key: DirectusFlow<Schema>['id']): RestCommand<void, Schema> =>
() => ({
path: `/flows/${key}`,
method: 'DELETE',
});
() => {
throwIfEmpty(key, 'Key cannot be empty');
return {
path: `/flows/${key}`,
method: 'DELETE',
};
};
import type { DirectusFolder } from '../../../schema/folder.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -8,11 +9,16 @@

* @returns
* @throws Will throw if keys is empty
*/
export const deleteFolders =
<Schema extends object>(keys: DirectusFolder<Schema>['id'][]): RestCommand<void, Schema> =>
() => ({
path: `/folders`,
body: JSON.stringify(keys),
method: 'DELETE',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/folders`,
body: JSON.stringify(keys),
method: 'DELETE',
};
};
/**

@@ -22,8 +28,13 @@ * Delete multiple existing folders.

* @returns
* @throws Will throw if key is empty
*/
export const deleteFolder =
<Schema extends object>(key: DirectusFolder<Schema>['id']): RestCommand<void, Schema> =>
() => ({
path: `/folders/${key}`,
method: 'DELETE',
});
() => {
throwIfEmpty(key, 'Key cannot be empty');
return {
path: `/folders/${key}`,
method: 'DELETE',
};
};
import type { Query } from '../../../types/index.js';
import { throwIfCoreCollection, throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -11,2 +12,5 @@

* @returns Nothing
* @throws Will throw if collection is empty
* @throws Will throw if collection is a core collection
* @throws Will throw if keysOrQuery is empty
*/

@@ -19,14 +23,22 @@ export const deleteItems =

() => {
const _collection = String(collection);
let payload: Record<string, any> = {};
if (_collection.startsWith('directus_')) {
throw new Error('Cannot use deleteItems for core collections');
throwIfEmpty(String(collection), 'Collection cannot be empty');
throwIfCoreCollection(collection, 'Cannot use deleteItems for core collections');
if (Array.isArray(keysOrQuery)) {
throwIfEmpty(keysOrQuery, 'keysOrQuery cannot be empty');
payload = { keys: keysOrQuery };
} else {
throwIfEmpty(Object.keys(keysOrQuery), 'keysOrQuery cannot be empty');
payload = { query: keysOrQuery };
}
return {
path: `/items/${_collection}`,
body: JSON.stringify(Array.isArray(keysOrQuery) ? { keys: keysOrQuery } : { query: keysOrQuery }),
path: `/items/${collection as string}`,
body: JSON.stringify(payload),
method: 'DELETE',
};
};
/**

@@ -39,2 +51,5 @@ * Delete an existing item.

* @returns Nothing
* @throws Will throw if collection is empty
* @throws Will throw if collection is a core collection
* @throws Will throw if key is empty
*/

@@ -47,12 +62,10 @@ export const deleteItem =

() => {
const _collection = String(collection);
throwIfEmpty(String(collection), 'Collection cannot be empty');
throwIfCoreCollection(collection, 'Cannot use deleteItem for core collections');
throwIfEmpty(String(key), 'Key cannot be empty');
if (_collection.startsWith('directus_')) {
throw new Error('Cannot use deleteItem for core collections');
}
return {
path: `/items/${_collection}/${key}`,
path: `/items/${collection as string}/${key}`,
method: 'DELETE',
};
};
import type { DirectusNotification } from '../../../schema/notification.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -8,11 +9,16 @@

* @returns
* @throws Will throw if keys is empty
*/
export const deleteNotifications =
<Schema extends object>(keys: DirectusNotification<Schema>['id'][]): RestCommand<void, Schema> =>
() => ({
path: `/notifications`,
body: JSON.stringify(keys),
method: 'DELETE',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/notifications`,
body: JSON.stringify(keys),
method: 'DELETE',
};
};
/**

@@ -22,8 +28,13 @@ * Delete an existing notification.

* @returns
* @throws Will throw if key is empty
*/
export const deleteNotification =
<Schema extends object>(key: DirectusNotification<Schema>['id']): RestCommand<void, Schema> =>
() => ({
path: `/notifications/${key}`,
method: 'DELETE',
});
() => {
throwIfEmpty(key, 'Key cannot be empty');
return {
path: `/notifications/${key}`,
method: 'DELETE',
};
};
import type { DirectusOperation } from '../../../schema/operation.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -8,11 +9,16 @@

* @returns
* @throws Will throw if keys is empty
*/
export const deleteOperations =
<Schema extends object>(keys: DirectusOperation<Schema>['id'][]): RestCommand<void, Schema> =>
() => ({
path: `/operations`,
body: JSON.stringify(keys),
method: 'DELETE',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/operations`,
body: JSON.stringify(keys),
method: 'DELETE',
};
};
/**

@@ -22,8 +28,13 @@ * Delete an existing operation.

* @returns
* @throws Will throw if key is empty
*/
export const deleteOperation =
<Schema extends object>(key: DirectusOperation<Schema>['id']): RestCommand<void, Schema> =>
() => ({
path: `/operations/${key}`,
method: 'DELETE',
});
() => {
throwIfEmpty(key, 'Key cannot be empty');
return {
path: `/operations/${key}`,
method: 'DELETE',
};
};
import type { DirectusPanel } from '../../../schema/panel.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -8,11 +9,16 @@

* @returns
* @throws Will throw if keys is empty
*/
export const deletePanels =
<Schema extends object>(keys: DirectusPanel<Schema>['id'][]): RestCommand<void, Schema> =>
() => ({
path: `/panels`,
body: JSON.stringify(keys),
method: 'DELETE',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/panels`,
body: JSON.stringify(keys),
method: 'DELETE',
};
};
/**

@@ -22,8 +28,13 @@ * Delete an existing panel.

* @returns
* @throws Will throw if key is empty
*/
export const deletePanel =
<Schema extends object>(key: DirectusPanel<Schema>['id']): RestCommand<void, Schema> =>
() => ({
path: `/panels/${key}`,
method: 'DELETE',
});
() => {
throwIfEmpty(key, 'Key cannot be empty');
return {
path: `/panels/${key}`,
method: 'DELETE',
};
};
import type { DirectusPermission } from '../../../schema/permission.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -8,11 +9,16 @@

* @returns
* @throws Will throw if keys is empty
*/
export const deletePermissions =
<Schema extends object>(keys: DirectusPermission<Schema>['id'][]): RestCommand<void, Schema> =>
() => ({
path: `/permissions`,
body: JSON.stringify(keys),
method: 'DELETE',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/permissions`,
body: JSON.stringify(keys),
method: 'DELETE',
};
};
/**

@@ -22,8 +28,13 @@ * Delete an existing permissions rule

* @returns
* @throws Will throw if key is empty
*/
export const deletePermission =
<Schema extends object>(key: DirectusPermission<Schema>['id']): RestCommand<void, Schema> =>
() => ({
path: `/permissions/${key}`,
method: 'DELETE',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/permissions/${key}`,
method: 'DELETE',
};
};
import type { DirectusPreset } from '../../../schema/preset.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -8,11 +9,16 @@

* @returns
* @throws Will throw if keys is empty
*/
export const deletePresets =
<Schema extends object>(keys: DirectusPreset<Schema>['id'][]): RestCommand<void, Schema> =>
() => ({
path: `/presets`,
body: JSON.stringify(keys),
method: 'DELETE',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/presets`,
body: JSON.stringify(keys),
method: 'DELETE',
};
};
/**

@@ -22,8 +28,13 @@ * Delete an existing preset.

* @returns
* @throws Will throw if key is empty
*/
export const deletePreset =
<Schema extends object>(key: DirectusPreset<Schema>['id']): RestCommand<void, Schema> =>
() => ({
path: `/presets/${key}`,
method: 'DELETE',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/presets/${key}`,
method: 'DELETE',
};
};
import type { DirectusRelation } from '../../../schema/relation.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -9,2 +10,4 @@

* @returns
* @throws Will throw if collection is empty
* @throws Will throw if field is empty
*/

@@ -16,5 +19,10 @@ export const deleteRelation =

): RestCommand<void, Schema> =>
() => ({
path: `/relations/${collection}/${field}`,
method: 'DELETE',
});
() => {
throwIfEmpty(collection, 'Collection cannot be empty');
throwIfEmpty(field, 'Field cannot be empty');
return {
path: `/relations/${collection}/${field}`,
method: 'DELETE',
};
};
import type { DirectusRole } from '../../../schema/role.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -8,11 +9,16 @@

* @returns
* @throws Will throw if keys is empty
*/
export const deleteRoles =
<Schema extends object>(keys: DirectusRole<Schema>['id'][]): RestCommand<void, Schema> =>
() => ({
path: `/roles`,
body: JSON.stringify(keys),
method: 'DELETE',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/roles`,
body: JSON.stringify(keys),
method: 'DELETE',
};
};
/**

@@ -22,8 +28,13 @@ * Delete an existing role.

* @returns
* @throws Will throw if key is empty
*/
export const deleteRole =
<Schema extends object>(key: DirectusRole<Schema>['id']): RestCommand<void, Schema> =>
() => ({
path: `/roles/${key}`,
method: 'DELETE',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/roles/${key}`,
method: 'DELETE',
};
};
import type { DirectusShare } from '../../../schema/share.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -8,11 +9,16 @@

* @returns
* @throws Will throw if keys is empty
*/
export const deleteShares =
<Schema extends object>(keys: DirectusShare<Schema>['id'][]): RestCommand<void, Schema> =>
() => ({
path: `/shares`,
body: JSON.stringify(keys),
method: 'DELETE',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/shares`,
body: JSON.stringify(keys),
method: 'DELETE',
};
};
/**

@@ -22,8 +28,13 @@ * Delete an existing share.

* @returns
* @throws Will throw if key is empty
*/
export const deleteShare =
<Schema extends object>(key: DirectusShare<Schema>['id']): RestCommand<void, Schema> =>
() => ({
path: `/shares/${key}`,
method: 'DELETE',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/shares/${key}`,
method: 'DELETE',
};
};
import type { DirectusTranslation } from '../../../schema/translation.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -8,11 +9,16 @@

* @returns
* @throws Will throw if keys is empty
*/
export const deleteTranslations =
<Schema extends object>(keys: DirectusTranslation<Schema>['id'][]): RestCommand<void, Schema> =>
() => ({
path: `/translations`,
body: JSON.stringify(keys),
method: 'DELETE',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/translations`,
body: JSON.stringify(keys),
method: 'DELETE',
};
};
/**

@@ -22,8 +28,13 @@ * Delete an existing translation.

* @returns
* @throws Will throw if key is empty
*/
export const deleteTranslation =
<Schema extends object>(key: DirectusTranslation<Schema>['id']): RestCommand<void, Schema> =>
() => ({
path: `/translations/${key}`,
method: 'DELETE',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/translations/${key}`,
method: 'DELETE',
};
};
import type { RestCommand } from '../../types.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { DirectusUser } from '../../../schema/user.js';

@@ -7,26 +8,34 @@

*
* @param keysOrQuery The primary keys or a query
*
* @param keys
* @returns Nothing
* @throws Will throw if keys is empty
*/
export const deleteUsers =
<Schema extends object>(keys: DirectusUser<Schema>['id'][]): RestCommand<void, Schema> =>
() => ({
path: `/users`,
body: JSON.stringify(keys),
method: 'DELETE',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/users`,
body: JSON.stringify(keys),
method: 'DELETE',
};
};
/**
* Delete an existing user.
*
* @param key The primary key of the item
*
* @param key
* @returns Nothing
* @throws Will throw if key is empty
*/
export const deleteUser =
<Schema extends object>(key: DirectusUser<Schema>['id']): RestCommand<void, Schema> =>
() => ({
path: `/users/${key}`,
method: 'DELETE',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/users/${key}`,
method: 'DELETE',
};
};
import type { DirectusWebhook } from '../../../schema/webhook.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -8,11 +9,16 @@

* @returns
* @throws Will throw if keys is empty
*/
export const deleteWebhooks =
<Schema extends object>(keys: DirectusWebhook<Schema>['id'][]): RestCommand<void, Schema> =>
() => ({
path: `/webhooks`,
body: JSON.stringify(keys),
method: 'DELETE',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/webhooks`,
body: JSON.stringify(keys),
method: 'DELETE',
};
};
/**

@@ -22,8 +28,13 @@ * Delete an existing webhook.

* @returns
* @throws Will throw if key is empty
*/
export const deleteWebhook =
<Schema extends object>(key: DirectusWebhook<Schema>['id']): RestCommand<void, Schema> =>
() => ({
path: `/webhooks/${key}`,
method: 'DELETE',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/webhooks/${key}`,
method: 'DELETE',
};
};
import type { DirectusActivity } from '../../../schema/activity.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -31,2 +32,3 @@

* @returns Returns an activity object if a valid identifier was provided.
* @throws Will throw if key is empty
*/

@@ -38,6 +40,10 @@ export const readActivity =

): RestCommand<ReadActivityOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/activity/${key}`,
params: query ?? {},
method: 'GET',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/activity/${key}`,
params: query ?? {},
method: 'GET',
};
};
import type { AllCollections } from '../../../index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { AggregationOptions, AggregationOutput } from '../../../types/aggregate.js';

@@ -10,2 +11,3 @@ import type { RestCommand } from '../../types.js';

* @returns Aggregated data
* @throws Will throw if collection is empty
*/

@@ -22,5 +24,8 @@ export const aggregate =

() => {
const _collection = collection as string;
const collectionName = String(collection);
throwIfEmpty(collectionName, 'Collection cannot be empty');
const path = _collection.startsWith('directus_') ? `/${_collection.substring(9)}` : `/items/${_collection}`;
const path = collectionName.startsWith('directus_')
? `/${collectionName.substring(9)}`
: `/items/${collectionName}`;

@@ -27,0 +32,0 @@ return {

import type { DirectusCollection } from '../../../schema/collection.js';
import type { ApplyQueryFields } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -25,2 +26,3 @@

* @returns A collection object.
* @throws Will throw if collection is empty
*/

@@ -31,5 +33,9 @@ export const readCollection =

): RestCommand<ReadCollectionOutput<Schema>, Schema> =>
() => ({
path: `/collections/${collection}`,
method: 'GET',
});
() => {
throwIfEmpty(collection, 'Collection cannot be empty');
return {
path: `/collections/${collection}`,
method: 'GET',
};
};
import type { DirectusDashboard } from '../../../schema/dashboard.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -31,2 +32,3 @@

* @returns Returns the requested dashboard object.
* @throws Will throw if key is empty
*/

@@ -38,6 +40,10 @@ export const readDashboard =

): RestCommand<ReadDashboardOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/dashboards/${key}`,
params: query ?? {},
method: 'GET',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/dashboards/${key}`,
params: query ?? {},
method: 'GET',
};
};
import type { DirectusField } from '../../../schema/field.js';
import type { ApplyQueryFields } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -27,2 +28,3 @@

* @returns
* @throws Will throw if collection is empty
*/

@@ -33,7 +35,11 @@ export const readFieldsByCollection =

): RestCommand<ReadFieldOutput<Schema>[], Schema> =>
() => ({
path: `/fields/${collection}`,
method: 'GET',
});
() => {
throwIfEmpty(collection, 'Collection cannot be empty');
return {
path: `/fields/${collection}`,
method: 'GET',
};
};
/**

@@ -44,2 +50,4 @@ *

* @returns
* @throws Will throw if collection is empty
* @throws Will throw if field is empty
*/

@@ -51,5 +59,10 @@ export const readField =

): RestCommand<ReadFieldOutput<Schema>, Schema> =>
() => ({
path: `/fields/${collection}/${field}`,
method: 'GET',
});
() => {
throwIfEmpty(collection, 'Collection cannot be empty');
throwIfEmpty(field, 'Field cannot be empty');
return {
path: `/fields/${collection}/${field}`,
method: 'GET',
};
};
import type { DirectusFile } from '../../../schema/file.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -31,2 +32,3 @@

* @returns Returns a file object if a valid primary key was provided.
* @throws Will throw if key is empty
*/

@@ -38,6 +40,10 @@ export const readFile =

): RestCommand<ReadFileOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/files/${key}`,
params: query ?? {},
method: 'GET',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/files/${key}`,
params: query ?? {},
method: 'GET',
};
};
import type { DirectusFlow } from '../../../schema/flow.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -31,2 +32,3 @@

* @returns Returns the requested flow object.
* @throws Will throw if key is empty
*/

@@ -38,6 +40,10 @@ export const readFlow =

): RestCommand<ReadFlowOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/flows/${key}`,
params: query ?? {},
method: 'GET',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/flows/${key}`,
params: query ?? {},
method: 'GET',
};
};
import type { DirectusFolder } from '../../../schema/folder.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -31,2 +32,3 @@

* @returns Returns a folder object if a valid primary key was provided.
* @throws Will throw if key is empty
*/

@@ -38,6 +40,10 @@ export const readFolder =

): RestCommand<ReadFolderOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/folders/${key}`,
params: query ?? {},
method: 'GET',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/folders/${key}`,
params: query ?? {},
method: 'GET',
};
};
import type { ApplyQueryFields, CollectionType, Query, RegularCollections } from '../../../types/index.js';
import { throwIfEmpty, throwIfCoreCollection } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -17,2 +18,4 @@

* @returns An array of up to limit item objects. If no items are available, data will be an empty array.
* @throws Will throw if collection is a core collection
* @throws Will throw if collection is empty
*/

@@ -29,10 +32,7 @@ export const readItems =

() => {
const _collection = String(collection);
throwIfEmpty(String(collection), 'Collection cannot be empty');
throwIfCoreCollection(collection, 'Cannot use readItems for core collections');
if (_collection.startsWith('directus_')) {
throw new Error('Cannot use readItems for core collections');
}
return {
path: `/items/${_collection}`,
path: `/items/${collection as string}`,
params: query ?? {},

@@ -51,2 +51,5 @@ method: 'GET',

* @returns Returns an item object if a valid primary key was provided.
* @throws Will throw if collection is a core collection
* @throws Will throw if collection is empty
* @throws Will throw if key is empty
*/

@@ -64,10 +67,8 @@ export const readItem =

() => {
const _collection = String(collection);
throwIfEmpty(String(collection), 'Collection cannot be empty');
throwIfCoreCollection(collection, 'Cannot use readItem for core collections');
throwIfEmpty(String(key), 'Key cannot be empty');
if (_collection.startsWith('directus_')) {
throw new Error('Cannot use readItem for core collections');
}
return {
path: `/items/${_collection}/${key}`,
path: `/items/${collection as string}/${key}`,
params: query ?? {},

@@ -74,0 +75,0 @@ method: 'GET',

import type { DirectusNotification } from '../../../schema/notification.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -31,2 +32,3 @@

* @returns Returns the requested notification object.
* @throws Will throw if key is empty
*/

@@ -38,6 +40,10 @@ export const readNotification =

): RestCommand<ReadNotificationOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/notifications/${key}`,
params: query ?? {},
method: 'GET',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/notifications/${key}`,
params: query ?? {},
method: 'GET',
};
};
import type { DirectusOperation } from '../../../schema/operation.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -31,2 +32,3 @@

* @returns Returns a Operation object if a valid primary key was provided.
* @throws Will throw if key is empty
*/

@@ -38,6 +40,10 @@ export const readOperation =

): RestCommand<ReadOperationOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/operations/${key}`,
params: query ?? {},
method: 'GET',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/operations/${key}`,
params: query ?? {},
method: 'GET',
};
};
import type { DirectusPanel } from '../../../schema/panel.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -31,2 +32,3 @@

* @returns Returns the requested panel object.
* @throws Will throw if key is empty
*/

@@ -38,6 +40,10 @@ export const readPanel =

): RestCommand<ReadPanelOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/panels/${key}`,
params: query ?? {},
method: 'GET',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/panels/${key}`,
params: query ?? {},
method: 'GET',
};
};
import type { DirectusPermission } from '../../../schema/permission.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -31,2 +32,3 @@

* @returns Returns a Permission object if a valid primary key was provided.
* @throws Will throw if key is empty
*/

@@ -38,6 +40,10 @@ export const readPermission =

): RestCommand<ReadPermissionOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/permissions/${key}`,
params: query ?? {},
method: 'GET',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/permissions/${key}`,
params: query ?? {},
method: 'GET',
};
};
import type { DirectusPreset } from '../../../schema/preset.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -31,2 +32,3 @@

* @returns Returns a Preset object if a valid primary key was provided.
* @throws Will throw if key is empty
*/

@@ -38,6 +40,10 @@ export const readPreset =

): RestCommand<ReadPresetOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/presets/${key}`,
params: query ?? {},
method: 'GET',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/presets/${key}`,
params: query ?? {},
method: 'GET',
};
};
import type { DirectusRelation } from '../../../schema/relation.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -26,2 +27,3 @@

* @returns Returns a Relation object if a valid primary key was provided.
* @throws Will throw if collection is empty
*/

@@ -42,2 +44,4 @@ export const readRelationByCollection =

* @returns Returns a Relation object if a valid primary key was provided.
* @throws Will throw if collection is empty
* @throws Will throw if field is empty
*/

@@ -49,5 +53,10 @@ export const readRelation =

): RestCommand<ReadRelationOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/relations/${collection}/${field}`,
method: 'GET',
});
() => {
throwIfEmpty(collection, 'Collection cannot be empty');
throwIfEmpty(field, 'Field cannot be empty');
return {
path: `/relations/${collection}/${field}`,
method: 'GET',
};
};
import type { DirectusRevision } from '../../../schema/revision.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -31,2 +32,3 @@

* @returns Returns a Revision object if a valid primary key was provided.
* @throws Will throw if key is empty
*/

@@ -38,6 +40,10 @@ export const readRevision =

): RestCommand<ReadRevisionOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/revisions/${key}`,
params: query ?? {},
method: 'GET',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/revisions/${key}`,
params: query ?? {},
method: 'GET',
};
};
import type { DirectusRole } from '../../../schema/role.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -31,2 +32,3 @@

* @returns Returns a Role object if a valid primary key was provided.
* @throws Will throw if key is empty
*/

@@ -38,6 +40,10 @@ export const readRole =

): RestCommand<ReadRoleOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/roles/${key}`,
params: query ?? {},
method: 'GET',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/roles/${key}`,
params: query ?? {},
method: 'GET',
};
};
import type { DirectusShare } from '../../../schema/share.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -31,2 +32,3 @@

* @returns Returns a Share object if a valid primary key was provided.
* @throws Will throw if key is empty
*/

@@ -38,6 +40,10 @@ export const readShare =

): RestCommand<ReadShareOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/shares/${key}`,
params: query ?? {},
method: 'GET',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/shares/${key}`,
params: query ?? {},
method: 'GET',
};
};
import type { ApplyQueryFields, CollectionType, Query, SingletonCollections } from '../../../types/index.js';
import { throwIfCoreCollection, throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -17,2 +18,4 @@

* @returns An array of up to limit item objects. If no items are available, data will be an empty array.
* @throws Will throw if collection is a core collection
* @throws Will throw if collection is empty
*/

@@ -29,10 +32,7 @@ export const readSingleton =

() => {
const _collection = String(collection);
throwIfEmpty(String(collection), 'Collection cannot be empty');
throwIfCoreCollection(collection, 'Cannot use readSingleton for core collections');
if (_collection.startsWith('directus_')) {
throw new Error('Cannot use readSingleton for core collections');
}
return {
path: `/items/${_collection}`,
path: `/items/${collection as string}`,
params: query ?? {},

@@ -39,0 +39,0 @@ method: 'GET',

import type { DirectusTranslation } from '../../../schema/translation.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -31,2 +32,3 @@

* @returns Returns a Translation object if a valid primary key was provided.
* @throws Will throw if key is empty
*/

@@ -38,6 +40,10 @@ export const readTranslation =

): RestCommand<ReadTranslationOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/translations/${key}`,
params: query ?? {},
method: 'GET',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/translations/${key}`,
params: query ?? {},
method: 'GET',
};
};
import type { DirectusUser } from '../../../schema/user.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -35,2 +36,3 @@

* @returns Returns the requested user object.
* @throws Will throw if key is empty
*/

@@ -42,8 +44,12 @@ export const readUser =

): RestCommand<ReadUserOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/users/${key}`,
params: query ?? {},
method: 'GET',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/users/${key}`,
params: query ?? {},
method: 'GET',
};
};
/**

@@ -50,0 +56,0 @@ * Retrieve the currently authenticated user.

import type { DirectusWebhook } from '../../../schema/webhook.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -31,2 +32,3 @@

* @returns Returns a Webhook object if a valid primary key was provided.
* @throws Will throw if key is empty
*/

@@ -38,6 +40,10 @@ export const readWebhook =

): RestCommand<ReadWebhookOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/webhooks/${key}`,
params: query ?? {},
method: 'GET',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/webhooks/${key}`,
params: query ?? {},
method: 'GET',
};
};
import type { DirectusActivity } from '../../../schema/activity.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -17,2 +18,3 @@

* @returns Returns the activity object of the created comment.
* @throws Will throw if key is empty
*/

@@ -25,7 +27,11 @@ export const updateComment =

): RestCommand<UpdateActivityOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/activity/comment/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/activity/comment/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
};
};
import type { DirectusCollection } from '../../../schema/collection.js';
import type { ApplyQueryFields, NestedPartial, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -17,2 +18,3 @@

* @returns The collection object for the updated collection in this request.
* @throws Will throw if collection is empty
*/

@@ -25,7 +27,11 @@ export const updateCollection =

): RestCommand<UpdateCollectionOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/collections/${collection}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
});
() => {
throwIfEmpty(collection, 'Collection cannot be empty');
return {
path: `/collections/${collection}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
};
};
import type { DirectusDashboard } from '../../../schema/dashboard.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -17,2 +18,3 @@

* @returns Returns the dashboard objects for the updated dashboards.
* @throws Will throw if keys is empty
*/

@@ -25,9 +27,13 @@ export const updateDashboards =

): RestCommand<UpdateDashboardOutput<Schema, TQuery>[], Schema> =>
() => ({
path: `/dashboards`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/dashboards`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
};
};
/**

@@ -39,2 +45,3 @@ * Update an existing dashboard.

* @returns Returns the dashboard object for the updated dashboard.
* @throws Will throw if key is empty
*/

@@ -47,7 +54,11 @@ export const updateDashboard =

): RestCommand<UpdateDashboardOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/dashboards/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
});
() => {
throwIfEmpty(key, 'Key cannot be empty');
return {
path: `/dashboards/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
};
};
import type { DirectusField } from '../../../schema/field.js';
import type { ApplyQueryFields, NestedPartial, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -18,2 +19,4 @@

* @returns
* @throws Will throw if collection is empty
* @throws Will throw if field is empty
*/

@@ -27,7 +30,12 @@ export const updateField =

): RestCommand<UpdateFieldOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/fields/${collection}/${field}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
});
() => {
throwIfEmpty(collection, 'Keys cannot be empty');
throwIfEmpty(field, 'Field cannot be empty');
return {
path: `/fields/${collection}/${field}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
};
};
import type { DirectusFile } from '../../../schema/file.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -17,2 +18,3 @@

* @returns Returns the file objects for the updated files.
* @throws Will throw if keys is empty
*/

@@ -25,9 +27,13 @@ export const updateFiles =

): RestCommand<UpdateFileOutput<Schema, TQuery>[], Schema> =>
() => ({
path: `/files`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/files`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
};
};
/**

@@ -39,2 +45,3 @@ * Update an existing file, and/or replace it's file contents.

* @returns Returns the file object for the updated file.
* @throws Will throw if key is empty
*/

@@ -47,7 +54,11 @@ export const updateFile =

): RestCommand<UpdateFileOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/files/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
});
() => {
throwIfEmpty(key, 'Key cannot be empty');
return {
path: `/files/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
};
};
import type { DirectusFlow } from '../../../schema/flow.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -17,2 +18,3 @@

* @returns Returns the flow objects for the updated flows.
* @throws Will throw if keys is empty
*/

@@ -25,9 +27,13 @@ export const updateFlows =

): RestCommand<UpdateFlowOutput<Schema, TQuery>[], Schema> =>
() => ({
path: `/flows`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/flows`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
};
};
/**

@@ -39,2 +45,3 @@ * Update an existing flow.

* @returns Returns the flow object for the updated flow.
* @throws Will throw if key is empty
*/

@@ -47,7 +54,11 @@ export const updateFlow =

): RestCommand<UpdateFlowOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/flows/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
});
() => {
throwIfEmpty(key, 'Key cannot be empty');
return {
path: `/flows/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
};
};
import type { DirectusFolder } from '../../../schema/folder.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -17,2 +18,3 @@

* @returns Returns the folder objects of the folders that were updated.
* @throws Will throw if keys is empty
*/

@@ -25,9 +27,13 @@ export const updateFolders =

): RestCommand<UpdateFolderOutput<Schema, TQuery>[], Schema> =>
() => ({
path: `/folders`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/folders`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
};
};
/**

@@ -39,2 +45,3 @@ * Update an existing folder.

* @returns Returns the folder object of the folder that was updated.
* @throws Will throw if key is empty
*/

@@ -47,7 +54,11 @@ export const updateFolder =

): RestCommand<UpdateFolderOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/folders/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
});
() => {
throwIfEmpty(key, 'Key cannot be empty');
return {
path: `/folders/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
};
};
import type { ApplyQueryFields, CollectionType, Query, UnpackList } from '../../../types/index.js';
import type { RestCommand } from '../../types.js';
import { throwIfCoreCollection, throwIfEmpty } from '../../utils/index.js';

@@ -19,2 +20,5 @@ export type UpdateItemOutput<

* @returns Returns the item objects for the updated items.
* @throws Will throw if keys is empty
* @throws Will throw if collection is empty
* @throws Will throw if collection is a core collection
*/

@@ -29,6 +33,8 @@ export const updateItems =

() => {
const _collection = String(collection);
throwIfEmpty(keys, 'Keys cannot be empty');
throwIfEmpty(String(collection), 'Collection cannot be empty');
throwIfCoreCollection(collection, 'Cannot use updateItems for core collections');
return {
path: `/items/${_collection}`,
path: `/items/${collection as string}`,
params: query ?? {},

@@ -49,2 +55,5 @@ body: JSON.stringify({ keys, data: item }),

* @returns Returns the item object of the item that was updated.
* @throws Will throw if key is empty
* @throws Will throw if collection is empty
* @throws Will throw if collection is a core collection
*/

@@ -64,10 +73,8 @@ export const updateItem =

() => {
const _collection = String(collection);
throwIfEmpty(String(key), 'Key cannot be empty');
throwIfEmpty(String(collection), 'Collection cannot be empty');
throwIfCoreCollection(collection, 'Cannot use updateItem for core collections');
if (_collection.startsWith('directus_')) {
throw new Error('Cannot use updateItem for core collections');
}
return {
path: `/items/${_collection}/${key}`,
path: `/items/${collection as string}/${key}`,
params: query ?? {},

@@ -74,0 +81,0 @@ body: JSON.stringify(item),

import type { DirectusNotification } from '../../../schema/notification.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -17,2 +18,3 @@

* @returns Returns the notification objects for the updated notifications.
* @throws Will throw if keys is empty
*/

@@ -25,9 +27,13 @@ export const updateNotifications =

): RestCommand<UpdateNotificationOutput<Schema, TQuery>[], Schema> =>
() => ({
path: `/notifications`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/notifications`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
};
};
/**

@@ -39,2 +45,3 @@ * Update an existing notification.

* @returns Returns the notification object for the updated notification.
* @throws Will throw if key is empty
*/

@@ -47,7 +54,11 @@ export const updateNotification =

): RestCommand<UpdateNotificationOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/notifications/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
});
() => {
throwIfEmpty(key, 'Key cannot be empty');
return {
path: `/notifications/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
};
};
import type { DirectusOperation } from '../../../schema/operation.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -17,2 +18,3 @@

* @returns Returns the operation objects for the updated operations.
* @throws Will throw if keys is empty
*/

@@ -25,9 +27,13 @@ export const updateOperations =

): RestCommand<UpdateOperationOutput<Schema, TQuery>[], Schema> =>
() => ({
path: `/operations`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/operations`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
};
};
/**

@@ -39,2 +45,3 @@ * Update an existing operation.

* @returns Returns the operation object for the updated operation.
* @throws Will throw if key is empty
*/

@@ -47,7 +54,11 @@ export const updateOperation =

): RestCommand<UpdateOperationOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/operations/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
});
() => {
throwIfEmpty(key, 'Key cannot be empty');
return {
path: `/operations/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
};
};
import type { DirectusPanel } from '../../../schema/panel.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -17,2 +18,3 @@

* @returns Returns the panel objects for the updated panels.
* @throws Will throw if keys is empty
*/

@@ -25,9 +27,13 @@ export const updatePanels =

): RestCommand<UpdatePanelOutput<Schema, TQuery>[], Schema> =>
() => ({
path: `/panels`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/panels`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
};
};
/**

@@ -39,2 +45,3 @@ * Update an existing panel.

* @returns Returns the panel object for the updated panel.
* @throws Will throw if key is empty
*/

@@ -47,7 +54,11 @@ export const updatePanel =

): RestCommand<UpdatePanelOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/panels/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
});
() => {
throwIfEmpty(key, 'Key cannot be empty');
return {
path: `/panels/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
};
};
import type { DirectusPermission } from '../../../schema/permission.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -17,2 +18,3 @@

* @returns Returns the permission object for the updated permissions.
* @throws Will throw if keys is empty
*/

@@ -25,9 +27,13 @@ export const updatePermissions =

): RestCommand<UpdatePermissionOutput<Schema, TQuery>[], Schema> =>
() => ({
path: `/permissions`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/permissions`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
};
};
/**

@@ -39,2 +45,3 @@ * Update an existing permissions rule.

* @returns Returns the permission object for the updated permission.
* @throws Will throw if key is empty
*/

@@ -47,7 +54,11 @@ export const updatePermission =

): RestCommand<UpdatePermissionOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/permissions/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/permissions/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
};
};
import type { DirectusPreset } from '../../../schema/preset.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -17,2 +18,3 @@

* @returns Returns the preset objects for the updated presets.
* @throws Will throw if keys is empty
*/

@@ -25,9 +27,13 @@ export const updatePresets =

): RestCommand<UpdatePresetOutput<Schema, TQuery>[], Schema> =>
() => ({
path: `/presets`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/presets`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
};
};
/**

@@ -39,2 +45,3 @@ * Update an existing preset.

* @returns Returns the preset object for the updated preset.
* @throws Will throw if key is empty
*/

@@ -47,7 +54,11 @@ export const updatePreset =

): RestCommand<UpdatePresetOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/presets/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/presets/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
};
};
import type { DirectusRelation } from '../../../schema/relation.js';
import type { ApplyQueryFields, NestedPartial, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -26,7 +27,12 @@

): RestCommand<UpdateRelationOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/relations/${collection}/${field}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
});
() => {
throwIfEmpty(collection, 'Collection cannot be empty');
throwIfEmpty(field, 'Field cannot be empty');
return {
path: `/relations/${collection}/${field}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
};
};
import type { DirectusRole } from '../../../schema/role.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -17,2 +18,3 @@

* @returns Returns the role objects for the updated roles.
* @throws Will throw if keys is empty
*/

@@ -25,9 +27,13 @@ export const updateRoles =

): RestCommand<UpdateRoleOutput<Schema, TQuery>[], Schema> =>
() => ({
path: `/roles`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/roles`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
};
};
/**

@@ -39,2 +45,3 @@ * Update an existing role.

* @returns Returns the role object for the updated role.
* @throws Will throw if key is empty
*/

@@ -47,7 +54,11 @@ export const updateRole =

): RestCommand<UpdateRoleOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/roles/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
});
() => {
throwIfEmpty(key, 'Key cannot be empty');
return {
path: `/roles/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
};
};
import type { DirectusShare } from '../../../schema/share.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -17,2 +18,3 @@

* @returns Returns the share objects for the updated shares.
* @throws Will throw if keys is empty
*/

@@ -25,9 +27,13 @@ export const updateShares =

): RestCommand<UpdateShareOutput<Schema, TQuery>[], Schema> =>
() => ({
path: `/shares`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/shares`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
};
};
/**

@@ -39,2 +45,3 @@ * Update an existing share.

* @returns Returns the share object for the updated share.
* @throws Will throw if key is empty
*/

@@ -47,7 +54,11 @@ export const updateShare =

): RestCommand<UpdateShareOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/shares/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
});
() => {
throwIfEmpty(key, 'Key cannot be empty');
return {
path: `/shares/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
};
};
import type { ApplyQueryFields, CollectionType, Query, SingletonCollections } from '../../../types/index.js';
import type { RestCommand } from '../../types.js';
import { throwIfCoreCollection, throwIfEmpty } from '../../utils/index.js';

@@ -17,2 +18,4 @@ export type UpdateSingletonOutput<

* @returns An array of up to limit item objects. If no items are available, data will be an empty array.
* @throws Will throw if collection is a core collection
* @throws Will throw if collection is empty
*/

@@ -31,10 +34,7 @@ export const updateSingleton =

() => {
const _collection = String(collection);
throwIfEmpty(String(collection), 'Collection cannot be empty');
throwIfCoreCollection(collection, 'Cannot use updateSingleton for core collections');
if (_collection.startsWith('directus_')) {
throw new Error('Cannot use updateSingleton for core collections');
}
return {
path: `/items/${_collection}`,
path: `/items/${collection as string}`,
params: query ?? {},

@@ -41,0 +41,0 @@ body: JSON.stringify(item),

import type { DirectusTranslation } from '../../../schema/translation.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -17,2 +18,3 @@

* @returns Returns the translation objects for the updated translations.
* @throws Will throw if keys is empty
*/

@@ -25,9 +27,13 @@ export const updateTranslations =

): RestCommand<UpdateTranslationOutput<Schema, TQuery>[], Schema> =>
() => ({
path: `/translations`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/translations`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
};
};
/**

@@ -39,2 +45,3 @@ * Update an existing translation.

* @returns Returns the translation object for the updated translation.
* @throws Will throw if key is empty
*/

@@ -47,7 +54,11 @@ export const updateTranslation =

): RestCommand<UpdateTranslationOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/translations/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/translations/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
};
};
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import type { RestCommand } from '../../types.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { DirectusUser } from '../../../schema/user.js';

@@ -19,2 +20,3 @@

* @returns Returns the user objects for the updated users.
* @throws Will throw if keys is empty
*/

@@ -27,9 +29,13 @@ export const updateUsers =

): RestCommand<UpdateUserOutput<Schema, TQuery>[], Schema> =>
() => ({
path: `/users`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/users`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
};
};
/**

@@ -43,2 +49,3 @@ * Update an existing user.

* @returns Returns the user object for the updated user.
* @throws Will throw if key is empty
*/

@@ -51,9 +58,13 @@ export const updateUser =

): RestCommand<UpdateUserOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/users/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
});
() => {
throwIfEmpty(key, 'Key cannot be empty');
return {
path: `/users/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
};
};
/**

@@ -60,0 +71,0 @@ * Update the authenticated user.

import type { DirectusWebhook } from '../../../schema/webhook.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';

@@ -17,2 +18,3 @@

* @returns Returns the webhook objects for the updated webhooks.
* @throws Will throw if keys is empty
*/

@@ -25,9 +27,13 @@ export const updateWebhooks =

): RestCommand<UpdateWebhookOutput<Schema, TQuery>[], Schema> =>
() => ({
path: `/webhooks`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
});
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/webhooks`,
params: query ?? {},
body: JSON.stringify({ keys, data: item }),
method: 'PATCH',
};
};
/**

@@ -39,2 +45,3 @@ * Update an existing webhook.

* @returns Returns the webhook object for the updated webhook.
* @throws Will throw if key is empty
*/

@@ -47,7 +54,11 @@ export const updateWebhook =

): RestCommand<UpdateWebhookOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/webhooks/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
});
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/webhooks/${key}`,
params: query ?? {},
body: JSON.stringify(item),
method: 'PATCH',
};
};
import type { StaticTokenClient } from '../auth/types.js';
import type { DirectusClient } from '../types/client.js';
import type { ResponseTransformer } from '../index.js';
import { getRequestUrl } from '../utils/get-request-url.js';

@@ -8,2 +7,6 @@ import { request } from '../utils/request.js';

const defaultConfigValues: RestConfig = {
credentials: 'same-origin',
};
/**

@@ -14,4 +17,5 @@ * Creates a client to communicate with the Directus REST API.

*/
export const rest = (config: RestConfig = {}) => {
export const rest = (config: Partial<RestConfig> = {}) => {
return <Schema extends object>(client: DirectusClient<Schema>): RestClient<Schema> => {
const restConfig = { ...defaultConfigValues, ...config };
return {

@@ -46,2 +50,3 @@ async request<Output = any>(getOptions: RestCommand<Output, Schema>): Promise<Output> {

headers: options.headers ?? {},
credentials: restConfig.credentials,
};

@@ -59,22 +64,19 @@

// apply global onRequest hook
if (config.onRequest) {
fetchOptions = await config.onRequest(fetchOptions);
if (restConfig.onRequest) {
fetchOptions = await restConfig.onRequest(fetchOptions);
}
//const onError = config.onError ?? ((_err: any) => undefined);
let onResponse: ResponseTransformer | undefined | null;
let result = await request<Output>(requestUrl.toString(), fetchOptions, client.globals.fetch);
// chain response handlers if needed
if (config.onResponse && options.onResponse) {
onResponse = ((data: any) =>
Promise.resolve(data).then(config.onResponse).then(options.onResponse)) as ResponseTransformer;
} else if ('onResponse' in options) {
onResponse = options.onResponse;
} else if ('onResponse' in config) {
onResponse = config.onResponse;
// apply onResponse hook from command
if ('onResponse' in options) {
result = await options.onResponse(result, fetchOptions);
}
const response = await request(requestUrl.toString(), fetchOptions, onResponse); //.catch(onError);
// apply global onResponse hook
if ('onResponse' in config) {
result = await config.onResponse(result, fetchOptions);
}
return response as Output;
return result as Output;
},

@@ -81,0 +83,0 @@ };

export * from './commands/index.js';
export * from './composable.js';
export * from './helpers/index.js';
export * from './types.js';
export * from './utils/index.js';

@@ -12,2 +12,3 @@ import type { RequestOptions, RequestTransformer, ResponseTransformer } from '../types/request.js';

export interface RestConfig {
credentials: RequestCredentials;
// onError?: (error: any) => any;

@@ -14,0 +15,0 @@ onRequest?: RequestTransformer;

export * from './query-to-params.js';
export * from './with-token.js';
export * from './as-search.js';
export * from './throw-if-empty.js';
export * from './throw-core-collection.js';

@@ -6,3 +6,20 @@ /**

url: URL;
globals: ClientGlobals;
with: <Extension extends object>(createExtension: (client: DirectusClient<Schema>) => Extension) => this & Extension;
}
/**
* All used globals for the client
*/
export interface ClientGlobals {
fetch: typeof globalThis.fetch;
WebSocket: typeof globalThis.WebSocket;
URL: typeof globalThis.URL;
}
/**
* Available options on the client
*/
export interface ClientOptions {
globals?: Partial<ClientGlobals>;
}

@@ -18,3 +18,3 @@ export type HttpMethod = 'GET' | 'SEARCH' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';

export interface ResponseTransformer {
<Output = any>(data: any): Output | Promise<Output>;
<Output = any>(data: any, request: RequestInit): Output | Promise<Output>;
}

@@ -0,1 +1,3 @@

import { extractData } from './extract-data.js';
/**

@@ -12,3 +14,3 @@ * Request helper providing default settings

options: RequestInit,
formatter?: ((data: any) => Output) | null
fetcher = globalThis.fetch
): Promise<Output> => {

@@ -20,37 +22,10 @@ options.headers =

const defaultFormatter = (data: Output | { data: Output }) => {
if (typeof data === 'object' && data && 'data' in data) {
return data.data;
}
const response = await fetcher(url, options);
return data;
};
const data = await extractData(response).catch((reason) => {
const errors = typeof reason === 'object' && 'errors' in reason ? reason.errors : reason;
throw { errors, response };
});
const outputFormatter = formatter !== undefined && formatter !== null ? formatter : defaultFormatter;
const response = await globalThis
.fetch(url, options)
.then(async (response) => {
const type = response.headers.get('Content-Type')?.toLowerCase();
if (type?.startsWith('application/json')) {
const result = await response.json();
if (!response.ok) throw result;
return result;
}
if (type?.startsWith('text/html') || type?.startsWith('text/plain')) {
const result = await response.text();
if (!response.ok) throw result;
return result;
}
// empty body fallback
return;
})
.catch((err) => {
throw err;
});
return outputFormatter(response);
return data;
};

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

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

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

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc