@eloxiv/testing 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +6 -2
- package/dist/Admin.d.ts +20 -0
- package/dist/Admin.d.ts.map +1 -0
- package/dist/Admin.js +61 -0
- package/dist/Admin.js.map +1 -0
- package/dist/Agent.d.ts +97 -0
- package/dist/Agent.d.ts.map +1 -0
- package/dist/Agent.js +210 -0
- package/dist/Agent.js.map +1 -0
- package/dist/AgentSurface.d.ts +20 -0
- package/dist/AgentSurface.d.ts.map +1 -0
- package/dist/AgentSurface.js +36 -0
- package/dist/AgentSurface.js.map +1 -0
- package/dist/Embedder.d.ts +21 -0
- package/dist/Embedder.d.ts.map +1 -0
- package/dist/Embedder.js +54 -0
- package/dist/Embedder.js.map +1 -0
- package/dist/EvalMain.d.ts +2 -0
- package/dist/EvalMain.d.ts.map +1 -0
- package/dist/EvalMain.js +80 -0
- package/dist/EvalMain.js.map +1 -0
- package/dist/Evals.d.ts +95 -0
- package/dist/Evals.d.ts.map +1 -0
- package/dist/Evals.js +389 -0
- package/dist/Evals.js.map +1 -0
- package/dist/Kernel.d.ts +88 -0
- package/dist/Kernel.d.ts.map +1 -0
- package/dist/Kernel.js +108 -0
- package/dist/Kernel.js.map +1 -0
- package/dist/Launch.d.ts +86 -0
- package/dist/Launch.d.ts.map +1 -0
- package/dist/Launch.js +370 -0
- package/dist/Launch.js.map +1 -0
- package/dist/Locks.d.ts +39 -0
- package/dist/Locks.d.ts.map +1 -0
- package/dist/Locks.js +94 -0
- package/dist/Locks.js.map +1 -0
- package/dist/Routes.d.ts +19 -0
- package/dist/Routes.d.ts.map +1 -0
- package/dist/Routes.js +38 -0
- package/dist/Routes.js.map +1 -0
- package/dist/ScriptedChatModel.d.ts +51 -0
- package/dist/ScriptedChatModel.d.ts.map +1 -0
- package/dist/ScriptedChatModel.js +135 -0
- package/dist/ScriptedChatModel.js.map +1 -0
- package/dist/SmtpSink.d.ts +36 -0
- package/dist/SmtpSink.d.ts.map +1 -0
- package/dist/SmtpSink.js +185 -0
- package/dist/SmtpSink.js.map +1 -0
- package/dist/System.d.ts +271 -0
- package/dist/System.d.ts.map +1 -0
- package/dist/System.js +905 -0
- package/dist/System.js.map +1 -0
- package/dist/TcpProxy.d.ts +17 -0
- package/dist/TcpProxy.d.ts.map +1 -0
- package/dist/TcpProxy.js +100 -0
- package/dist/TcpProxy.js.map +1 -0
- package/dist/auth/TrustedProxyAuth.d.ts +28 -0
- package/dist/auth/TrustedProxyAuth.d.ts.map +1 -0
- package/dist/auth/TrustedProxyAuth.js +128 -0
- package/dist/auth/TrustedProxyAuth.js.map +1 -0
- package/dist/conformance/ActionConsent.d.ts +3 -0
- package/dist/conformance/ActionConsent.d.ts.map +1 -0
- package/dist/conformance/ActionConsent.js +347 -0
- package/dist/conformance/ActionConsent.js.map +1 -0
- package/dist/conformance/ActionRegistry.d.ts +64 -0
- package/dist/conformance/ActionRegistry.d.ts.map +1 -0
- package/dist/conformance/ActionRegistry.js +136 -0
- package/dist/conformance/ActionRegistry.js.map +1 -0
- package/dist/conformance/Actor.d.ts +43 -0
- package/dist/conformance/Actor.d.ts.map +1 -0
- package/dist/conformance/Actor.js +171 -0
- package/dist/conformance/Actor.js.map +1 -0
- package/dist/conformance/AgentReference.d.ts +30 -0
- package/dist/conformance/AgentReference.d.ts.map +1 -0
- package/dist/conformance/AgentReference.js +137 -0
- package/dist/conformance/AgentReference.js.map +1 -0
- package/dist/conformance/AgentResources.d.ts +3 -0
- package/dist/conformance/AgentResources.d.ts.map +1 -0
- package/dist/conformance/AgentResources.js +454 -0
- package/dist/conformance/AgentResources.js.map +1 -0
- package/dist/conformance/AgentRuntime.d.ts +3 -0
- package/dist/conformance/AgentRuntime.d.ts.map +1 -0
- package/dist/conformance/AgentRuntime.js +302 -0
- package/dist/conformance/AgentRuntime.js.map +1 -0
- package/dist/conformance/AgentSubject.d.ts +87 -0
- package/dist/conformance/AgentSubject.d.ts.map +1 -0
- package/dist/conformance/AgentSubject.js +18 -0
- package/dist/conformance/AgentSubject.js.map +1 -0
- package/dist/conformance/Approvals.d.ts +3 -0
- package/dist/conformance/Approvals.d.ts.map +1 -0
- package/dist/conformance/Approvals.js +258 -0
- package/dist/conformance/Approvals.js.map +1 -0
- package/dist/conformance/Audit.d.ts +3 -0
- package/dist/conformance/Audit.d.ts.map +1 -0
- package/dist/conformance/Audit.js +221 -0
- package/dist/conformance/Audit.js.map +1 -0
- package/dist/conformance/CalendarProvider.d.ts +4 -0
- package/dist/conformance/CalendarProvider.d.ts.map +1 -0
- package/dist/conformance/CalendarProvider.js +108 -0
- package/dist/conformance/CalendarProvider.js.map +1 -0
- package/dist/conformance/CapabilityKit.d.ts +191 -0
- package/dist/conformance/CapabilityKit.d.ts.map +1 -0
- package/dist/conformance/CapabilityKit.js +375 -0
- package/dist/conformance/CapabilityKit.js.map +1 -0
- package/dist/conformance/ClientSDK.d.ts +78 -0
- package/dist/conformance/ClientSDK.d.ts.map +1 -0
- package/dist/conformance/ClientSDK.js +163 -0
- package/dist/conformance/ClientSDK.js.map +1 -0
- package/dist/conformance/CollabDocument.d.ts +3 -0
- package/dist/conformance/CollabDocument.d.ts.map +1 -0
- package/dist/conformance/CollabDocument.js +934 -0
- package/dist/conformance/CollabDocument.js.map +1 -0
- package/dist/conformance/CollabReference.d.ts +8 -0
- package/dist/conformance/CollabReference.d.ts.map +1 -0
- package/dist/conformance/CollabReference.js +138 -0
- package/dist/conformance/CollabReference.js.map +1 -0
- package/dist/conformance/CollabSubject.d.ts +68 -0
- package/dist/conformance/CollabSubject.d.ts.map +1 -0
- package/dist/conformance/CollabSubject.js +2 -0
- package/dist/conformance/CollabSubject.js.map +1 -0
- package/dist/conformance/Command.d.ts +3 -0
- package/dist/conformance/Command.d.ts.map +1 -0
- package/dist/conformance/Command.js +73 -0
- package/dist/conformance/Command.js.map +1 -0
- package/dist/conformance/Connections.d.ts +4 -0
- package/dist/conformance/Connections.d.ts.map +1 -0
- package/dist/conformance/Connections.js +308 -0
- package/dist/conformance/Connections.js.map +1 -0
- package/dist/conformance/ConnectionsReference.d.ts +56 -0
- package/dist/conformance/ConnectionsReference.d.ts.map +1 -0
- package/dist/conformance/ConnectionsReference.js +74 -0
- package/dist/conformance/ConnectionsReference.js.map +1 -0
- package/dist/conformance/ConnectorReference.d.ts +86 -0
- package/dist/conformance/ConnectorReference.d.ts.map +1 -0
- package/dist/conformance/ConnectorReference.js +185 -0
- package/dist/conformance/ConnectorReference.js.map +1 -0
- package/dist/conformance/ContextAccounting.d.ts +8 -0
- package/dist/conformance/ContextAccounting.d.ts.map +1 -0
- package/dist/conformance/ContextAccounting.js +125 -0
- package/dist/conformance/ContextAccounting.js.map +1 -0
- package/dist/conformance/Daemon.d.ts +150 -0
- package/dist/conformance/Daemon.d.ts.map +1 -0
- package/dist/conformance/Daemon.js +718 -0
- package/dist/conformance/Daemon.js.map +1 -0
- package/dist/conformance/DaemonReference.d.ts +15 -0
- package/dist/conformance/DaemonReference.d.ts.map +1 -0
- package/dist/conformance/DaemonReference.js +163 -0
- package/dist/conformance/DaemonReference.js.map +1 -0
- package/dist/conformance/DbTx.d.ts +17 -0
- package/dist/conformance/DbTx.d.ts.map +1 -0
- package/dist/conformance/DbTx.js +184 -0
- package/dist/conformance/DbTx.js.map +1 -0
- package/dist/conformance/DecisionTokens.d.ts +3 -0
- package/dist/conformance/DecisionTokens.d.ts.map +1 -0
- package/dist/conformance/DecisionTokens.js +551 -0
- package/dist/conformance/DecisionTokens.js.map +1 -0
- package/dist/conformance/Delegation.d.ts +3 -0
- package/dist/conformance/Delegation.d.ts.map +1 -0
- package/dist/conformance/Delegation.js +149 -0
- package/dist/conformance/Delegation.js.map +1 -0
- package/dist/conformance/DeskReference.d.ts +21 -0
- package/dist/conformance/DeskReference.d.ts.map +1 -0
- package/dist/conformance/DeskReference.js +47 -0
- package/dist/conformance/DeskReference.js.map +1 -0
- package/dist/conformance/DeviceControl.d.ts +3 -0
- package/dist/conformance/DeviceControl.d.ts.map +1 -0
- package/dist/conformance/DeviceControl.js +579 -0
- package/dist/conformance/DeviceControl.js.map +1 -0
- package/dist/conformance/Directory.d.ts +36 -0
- package/dist/conformance/Directory.d.ts.map +1 -0
- package/dist/conformance/Directory.js +253 -0
- package/dist/conformance/Directory.js.map +1 -0
- package/dist/conformance/DirectoryProvider.d.ts +4 -0
- package/dist/conformance/DirectoryProvider.d.ts.map +1 -0
- package/dist/conformance/DirectoryProvider.js +58 -0
- package/dist/conformance/DirectoryProvider.js.map +1 -0
- package/dist/conformance/DocumentSource.d.ts +4 -0
- package/dist/conformance/DocumentSource.d.ts.map +1 -0
- package/dist/conformance/DocumentSource.js +43 -0
- package/dist/conformance/DocumentSource.js.map +1 -0
- package/dist/conformance/EndpointReference.d.ts +40 -0
- package/dist/conformance/EndpointReference.d.ts.map +1 -0
- package/dist/conformance/EndpointReference.js +67 -0
- package/dist/conformance/EndpointReference.js.map +1 -0
- package/dist/conformance/Files.d.ts +40 -0
- package/dist/conformance/Files.d.ts.map +1 -0
- package/dist/conformance/Files.js +592 -0
- package/dist/conformance/Files.js.map +1 -0
- package/dist/conformance/FilesReference.d.ts +31 -0
- package/dist/conformance/FilesReference.d.ts.map +1 -0
- package/dist/conformance/FilesReference.js +116 -0
- package/dist/conformance/FilesReference.js.map +1 -0
- package/dist/conformance/FilesSubject.d.ts +46 -0
- package/dist/conformance/FilesSubject.d.ts.map +1 -0
- package/dist/conformance/FilesSubject.js +3 -0
- package/dist/conformance/FilesSubject.js.map +1 -0
- package/dist/conformance/Flags.d.ts +3 -0
- package/dist/conformance/Flags.d.ts.map +1 -0
- package/dist/conformance/Flags.js +183 -0
- package/dist/conformance/Flags.js.map +1 -0
- package/dist/conformance/Host.d.ts +64 -0
- package/dist/conformance/Host.d.ts.map +1 -0
- package/dist/conformance/Host.js +152 -0
- package/dist/conformance/Host.js.map +1 -0
- package/dist/conformance/HttpApi.d.ts +5 -0
- package/dist/conformance/HttpApi.d.ts.map +1 -0
- package/dist/conformance/HttpApi.js +131 -0
- package/dist/conformance/HttpApi.js.map +1 -0
- package/dist/conformance/InboxReference.d.ts +28 -0
- package/dist/conformance/InboxReference.d.ts.map +1 -0
- package/dist/conformance/InboxReference.js +331 -0
- package/dist/conformance/InboxReference.js.map +1 -0
- package/dist/conformance/InboxSubject.d.ts +92 -0
- package/dist/conformance/InboxSubject.d.ts.map +1 -0
- package/dist/conformance/InboxSubject.js +16 -0
- package/dist/conformance/InboxSubject.js.map +1 -0
- package/dist/conformance/Ingestion.d.ts +10 -0
- package/dist/conformance/Ingestion.d.ts.map +1 -0
- package/dist/conformance/Ingestion.js +335 -0
- package/dist/conformance/Ingestion.js.map +1 -0
- package/dist/conformance/Ingress.d.ts +62 -0
- package/dist/conformance/Ingress.d.ts.map +1 -0
- package/dist/conformance/Ingress.js +346 -0
- package/dist/conformance/Ingress.js.map +1 -0
- package/dist/conformance/Invocation.d.ts +3 -0
- package/dist/conformance/Invocation.d.ts.map +1 -0
- package/dist/conformance/Invocation.js +665 -0
- package/dist/conformance/Invocation.js.map +1 -0
- package/dist/conformance/IsolationMatrix.d.ts +60 -0
- package/dist/conformance/IsolationMatrix.d.ts.map +1 -0
- package/dist/conformance/IsolationMatrix.js +196 -0
- package/dist/conformance/IsolationMatrix.js.map +1 -0
- package/dist/conformance/LiveConnection.d.ts +72 -0
- package/dist/conformance/LiveConnection.d.ts.map +1 -0
- package/dist/conformance/LiveConnection.js +125 -0
- package/dist/conformance/LiveConnection.js.map +1 -0
- package/dist/conformance/LocalClient.d.ts +62 -0
- package/dist/conformance/LocalClient.d.ts.map +1 -0
- package/dist/conformance/LocalClient.js +526 -0
- package/dist/conformance/LocalClient.js.map +1 -0
- package/dist/conformance/Locale.d.ts +28 -0
- package/dist/conformance/Locale.d.ts.map +1 -0
- package/dist/conformance/Locale.js +115 -0
- package/dist/conformance/Locale.js.map +1 -0
- package/dist/conformance/MachineIdentity.d.ts +39 -0
- package/dist/conformance/MachineIdentity.d.ts.map +1 -0
- package/dist/conformance/MachineIdentity.js +595 -0
- package/dist/conformance/MachineIdentity.js.map +1 -0
- package/dist/conformance/MailProvider.d.ts +4 -0
- package/dist/conformance/MailProvider.d.ts.map +1 -0
- package/dist/conformance/MailProvider.js +167 -0
- package/dist/conformance/MailProvider.js.map +1 -0
- package/dist/conformance/Memory.d.ts +10 -0
- package/dist/conformance/Memory.d.ts.map +1 -0
- package/dist/conformance/Memory.js +179 -0
- package/dist/conformance/Memory.js.map +1 -0
- package/dist/conformance/Messaging.d.ts +49 -0
- package/dist/conformance/Messaging.d.ts.map +1 -0
- package/dist/conformance/Messaging.js +117 -0
- package/dist/conformance/Messaging.js.map +1 -0
- package/dist/conformance/Metering.d.ts +26 -0
- package/dist/conformance/Metering.d.ts.map +1 -0
- package/dist/conformance/Metering.js +236 -0
- package/dist/conformance/Metering.js.map +1 -0
- package/dist/conformance/ModelProvider.d.ts +32 -0
- package/dist/conformance/ModelProvider.d.ts.map +1 -0
- package/dist/conformance/ModelProvider.js +100 -0
- package/dist/conformance/ModelProvider.js.map +1 -0
- package/dist/conformance/ModuleManifest.d.ts +9 -0
- package/dist/conformance/ModuleManifest.d.ts.map +1 -0
- package/dist/conformance/ModuleManifest.js +542 -0
- package/dist/conformance/ModuleManifest.js.map +1 -0
- package/dist/conformance/NotebookAgent.d.ts +32 -0
- package/dist/conformance/NotebookAgent.d.ts.map +1 -0
- package/dist/conformance/NotebookAgent.js +31 -0
- package/dist/conformance/NotebookAgent.js.map +1 -0
- package/dist/conformance/NotificationChannel.d.ts +40 -0
- package/dist/conformance/NotificationChannel.d.ts.map +1 -0
- package/dist/conformance/NotificationChannel.js +78 -0
- package/dist/conformance/NotificationChannel.js.map +1 -0
- package/dist/conformance/Notifications.d.ts +3 -0
- package/dist/conformance/Notifications.d.ts.map +1 -0
- package/dist/conformance/Notifications.js +240 -0
- package/dist/conformance/Notifications.js.map +1 -0
- package/dist/conformance/OAuthClient.d.ts +123 -0
- package/dist/conformance/OAuthClient.d.ts.map +1 -0
- package/dist/conformance/OAuthClient.js +204 -0
- package/dist/conformance/OAuthClient.js.map +1 -0
- package/dist/conformance/Outbox.d.ts +3 -0
- package/dist/conformance/Outbox.d.ts.map +1 -0
- package/dist/conformance/Outbox.js +266 -0
- package/dist/conformance/Outbox.js.map +1 -0
- package/dist/conformance/PlatformReference.d.ts +5 -0
- package/dist/conformance/PlatformReference.d.ts.map +1 -0
- package/dist/conformance/PlatformReference.js +66 -0
- package/dist/conformance/PlatformReference.js.map +1 -0
- package/dist/conformance/PlatformSubject.d.ts +45 -0
- package/dist/conformance/PlatformSubject.d.ts.map +1 -0
- package/dist/conformance/PlatformSubject.js +3 -0
- package/dist/conformance/PlatformSubject.js.map +1 -0
- package/dist/conformance/Privacy.d.ts +3 -0
- package/dist/conformance/Privacy.d.ts.map +1 -0
- package/dist/conformance/Privacy.js +437 -0
- package/dist/conformance/Privacy.js.map +1 -0
- package/dist/conformance/Progress.d.ts +3 -0
- package/dist/conformance/Progress.d.ts.map +1 -0
- package/dist/conformance/Progress.js +153 -0
- package/dist/conformance/Progress.js.map +1 -0
- package/dist/conformance/Push.d.ts +38 -0
- package/dist/conformance/Push.d.ts.map +1 -0
- package/dist/conformance/Push.js +649 -0
- package/dist/conformance/Push.js.map +1 -0
- package/dist/conformance/PushReference.d.ts +3 -0
- package/dist/conformance/PushReference.d.ts.map +1 -0
- package/dist/conformance/PushReference.js +97 -0
- package/dist/conformance/PushReference.js.map +1 -0
- package/dist/conformance/QuerySurface.d.ts +9 -0
- package/dist/conformance/QuerySurface.d.ts.map +1 -0
- package/dist/conformance/QuerySurface.js +349 -0
- package/dist/conformance/QuerySurface.js.map +1 -0
- package/dist/conformance/Readiness.d.ts +23 -0
- package/dist/conformance/Readiness.d.ts.map +1 -0
- package/dist/conformance/Readiness.js +110 -0
- package/dist/conformance/Readiness.js.map +1 -0
- package/dist/conformance/Reference.d.ts +17 -0
- package/dist/conformance/Reference.d.ts.map +1 -0
- package/dist/conformance/Reference.js +246 -0
- package/dist/conformance/Reference.js.map +1 -0
- package/dist/conformance/Release.d.ts +73 -0
- package/dist/conformance/Release.d.ts.map +1 -0
- package/dist/conformance/Release.js +556 -0
- package/dist/conformance/Release.js.map +1 -0
- package/dist/conformance/ReleaseReference.d.ts +5 -0
- package/dist/conformance/ReleaseReference.d.ts.map +1 -0
- package/dist/conformance/ReleaseReference.js +124 -0
- package/dist/conformance/ReleaseReference.js.map +1 -0
- package/dist/conformance/ResultRendering.d.ts +3 -0
- package/dist/conformance/ResultRendering.d.ts.map +1 -0
- package/dist/conformance/ResultRendering.js +120 -0
- package/dist/conformance/ResultRendering.js.map +1 -0
- package/dist/conformance/Sandbox.d.ts +58 -0
- package/dist/conformance/Sandbox.d.ts.map +1 -0
- package/dist/conformance/Sandbox.js +213 -0
- package/dist/conformance/Sandbox.js.map +1 -0
- package/dist/conformance/SandboxReference.d.ts +3 -0
- package/dist/conformance/SandboxReference.d.ts.map +1 -0
- package/dist/conformance/SandboxReference.js +44 -0
- package/dist/conformance/SandboxReference.js.map +1 -0
- package/dist/conformance/Scheduler.d.ts +106 -0
- package/dist/conformance/Scheduler.d.ts.map +1 -0
- package/dist/conformance/Scheduler.js +576 -0
- package/dist/conformance/Scheduler.js.map +1 -0
- package/dist/conformance/ScreenContext.d.ts +84 -0
- package/dist/conformance/ScreenContext.d.ts.map +1 -0
- package/dist/conformance/ScreenContext.js +290 -0
- package/dist/conformance/ScreenContext.js.map +1 -0
- package/dist/conformance/Search.d.ts +3 -0
- package/dist/conformance/Search.d.ts.map +1 -0
- package/dist/conformance/Search.js +333 -0
- package/dist/conformance/Search.js.map +1 -0
- package/dist/conformance/Secrets.d.ts +8 -0
- package/dist/conformance/Secrets.d.ts.map +1 -0
- package/dist/conformance/Secrets.js +231 -0
- package/dist/conformance/Secrets.js.map +1 -0
- package/dist/conformance/SecretsReference.d.ts +44 -0
- package/dist/conformance/SecretsReference.d.ts.map +1 -0
- package/dist/conformance/SecretsReference.js +73 -0
- package/dist/conformance/SecretsReference.js.map +1 -0
- package/dist/conformance/ServicesReference.d.ts +8 -0
- package/dist/conformance/ServicesReference.d.ts.map +1 -0
- package/dist/conformance/ServicesReference.js +273 -0
- package/dist/conformance/ServicesReference.js.map +1 -0
- package/dist/conformance/ServicesSubject.d.ts +104 -0
- package/dist/conformance/ServicesSubject.d.ts.map +1 -0
- package/dist/conformance/ServicesSubject.js +2 -0
- package/dist/conformance/ServicesSubject.js.map +1 -0
- package/dist/conformance/Settings.d.ts +3 -0
- package/dist/conformance/Settings.d.ts.map +1 -0
- package/dist/conformance/Settings.js +177 -0
- package/dist/conformance/Settings.js.map +1 -0
- package/dist/conformance/Sharing.d.ts +3 -0
- package/dist/conformance/Sharing.d.ts.map +1 -0
- package/dist/conformance/Sharing.js +368 -0
- package/dist/conformance/Sharing.js.map +1 -0
- package/dist/conformance/ShellSubject.d.ts +29 -0
- package/dist/conformance/ShellSubject.d.ts.map +1 -0
- package/dist/conformance/ShellSubject.js +13 -0
- package/dist/conformance/ShellSubject.js.map +1 -0
- package/dist/conformance/SignOutRace.d.ts +23 -0
- package/dist/conformance/SignOutRace.d.ts.map +1 -0
- package/dist/conformance/SignOutRace.js +49 -0
- package/dist/conformance/SignOutRace.js.map +1 -0
- package/dist/conformance/Slot.d.ts +3 -0
- package/dist/conformance/Slot.d.ts.map +1 -0
- package/dist/conformance/Slot.js +79 -0
- package/dist/conformance/Slot.js.map +1 -0
- package/dist/conformance/Space.d.ts +63 -0
- package/dist/conformance/Space.d.ts.map +1 -0
- package/dist/conformance/Space.js +294 -0
- package/dist/conformance/Space.js.map +1 -0
- package/dist/conformance/StorageAdapter.d.ts +76 -0
- package/dist/conformance/StorageAdapter.d.ts.map +1 -0
- package/dist/conformance/StorageAdapter.js +181 -0
- package/dist/conformance/StorageAdapter.js.map +1 -0
- package/dist/conformance/StorageBackend.d.ts +23 -0
- package/dist/conformance/StorageBackend.d.ts.map +1 -0
- package/dist/conformance/StorageBackend.js +274 -0
- package/dist/conformance/StorageBackend.js.map +1 -0
- package/dist/conformance/Subject.d.ts +198 -0
- package/dist/conformance/Subject.d.ts.map +1 -0
- package/dist/conformance/Subject.js +26 -0
- package/dist/conformance/Subject.js.map +1 -0
- package/dist/conformance/Sync.d.ts +3 -0
- package/dist/conformance/Sync.d.ts.map +1 -0
- package/dist/conformance/Sync.js +190 -0
- package/dist/conformance/Sync.js.map +1 -0
- package/dist/conformance/Telemetry.d.ts +3 -0
- package/dist/conformance/Telemetry.d.ts.map +1 -0
- package/dist/conformance/Telemetry.js +218 -0
- package/dist/conformance/Telemetry.js.map +1 -0
- package/dist/conformance/ThemeTokens.d.ts +22 -0
- package/dist/conformance/ThemeTokens.d.ts.map +1 -0
- package/dist/conformance/ThemeTokens.js +121 -0
- package/dist/conformance/ThemeTokens.js.map +1 -0
- package/dist/conformance/ToolSource.d.ts +5 -0
- package/dist/conformance/ToolSource.d.ts.map +1 -0
- package/dist/conformance/ToolSource.js +520 -0
- package/dist/conformance/ToolSource.js.map +1 -0
- package/dist/conformance/Versioning.d.ts +3 -0
- package/dist/conformance/Versioning.d.ts.map +1 -0
- package/dist/conformance/Versioning.js +160 -0
- package/dist/conformance/Versioning.js.map +1 -0
- package/dist/conformance/View.d.ts +3 -0
- package/dist/conformance/View.d.ts.map +1 -0
- package/dist/conformance/View.js +121 -0
- package/dist/conformance/View.js.map +1 -0
- package/dist/conformance/WorkItems.d.ts +3 -0
- package/dist/conformance/WorkItems.d.ts.map +1 -0
- package/dist/conformance/WorkItems.js +152 -0
- package/dist/conformance/WorkItems.js.map +1 -0
- package/dist/conformance/Workflow.d.ts +63 -0
- package/dist/conformance/Workflow.d.ts.map +1 -0
- package/dist/conformance/Workflow.js +235 -0
- package/dist/conformance/Workflow.js.map +1 -0
- package/dist/conformance/acme/chatlog.d.ts +591 -0
- package/dist/conformance/acme/chatlog.d.ts.map +1 -0
- package/dist/conformance/acme/chatlog.js +101 -0
- package/dist/conformance/acme/chatlog.js.map +1 -0
- package/dist/conformance/acme/connector.d.ts +12 -0
- package/dist/conformance/acme/connector.d.ts.map +1 -0
- package/dist/conformance/acme/connector.js +123 -0
- package/dist/conformance/acme/connector.js.map +1 -0
- package/dist/conformance/acme/migrations/0000_messages.sql +8 -0
- package/dist/conformance/archive/app.d.ts +728 -0
- package/dist/conformance/archive/app.d.ts.map +1 -0
- package/dist/conformance/archive/app.js +30 -0
- package/dist/conformance/archive/app.js.map +1 -0
- package/dist/conformance/archive/contract.d.ts +467 -0
- package/dist/conformance/archive/contract.d.ts.map +1 -0
- package/dist/conformance/archive/contract.js +187 -0
- package/dist/conformance/archive/contract.js.map +1 -0
- package/dist/conformance/archive/memo.sync.gen.d.ts +148 -0
- package/dist/conformance/archive/memo.sync.gen.d.ts.map +1 -0
- package/dist/conformance/archive/memo.sync.gen.js +23 -0
- package/dist/conformance/archive/memo.sync.gen.js.map +1 -0
- package/dist/conformance/archive/migrations/archive/0000_archive.sql +9 -0
- package/dist/conformance/archive/migrations/memo/0000_memo.sql +6 -0
- package/dist/conformance/archive/schema.d.ts +185 -0
- package/dist/conformance/archive/schema.d.ts.map +1 -0
- package/dist/conformance/archive/schema.js +22 -0
- package/dist/conformance/archive/schema.js.map +1 -0
- package/dist/conformance/archive/server.d.ts +273 -0
- package/dist/conformance/archive/server.d.ts.map +1 -0
- package/dist/conformance/archive/server.js +127 -0
- package/dist/conformance/archive/server.js.map +1 -0
- package/dist/conformance/archive/sync.gen.d.ts +319 -0
- package/dist/conformance/archive/sync.gen.d.ts.map +1 -0
- package/dist/conformance/archive/sync.gen.js +29 -0
- package/dist/conformance/archive/sync.gen.js.map +1 -0
- package/dist/conformance/atlas/app.d.ts +3 -0
- package/dist/conformance/atlas/app.d.ts.map +1 -0
- package/dist/conformance/atlas/app.js +15 -0
- package/dist/conformance/atlas/app.js.map +1 -0
- package/dist/conformance/atlas/contract.d.ts +489 -0
- package/dist/conformance/atlas/contract.d.ts.map +1 -0
- package/dist/conformance/atlas/contract.js +114 -0
- package/dist/conformance/atlas/contract.js.map +1 -0
- package/dist/conformance/crm/app.d.ts +304 -0
- package/dist/conformance/crm/app.d.ts.map +1 -0
- package/dist/conformance/crm/app.js +95 -0
- package/dist/conformance/crm/app.js.map +1 -0
- package/dist/conformance/crm/contract.d.ts +586 -0
- package/dist/conformance/crm/contract.d.ts.map +1 -0
- package/dist/conformance/crm/contract.js +153 -0
- package/dist/conformance/crm/contract.js.map +1 -0
- package/dist/conformance/crm/migrations/crm/0000_crm.sql +18 -0
- package/dist/conformance/crm/migrations/team/0000_team.sql +6 -0
- package/dist/conformance/crm/schema.d.ts +261 -0
- package/dist/conformance/crm/schema.d.ts.map +1 -0
- package/dist/conformance/crm/schema.js +25 -0
- package/dist/conformance/crm/schema.js.map +1 -0
- package/dist/conformance/crm/sync.gen.d.ts +188 -0
- package/dist/conformance/crm/sync.gen.d.ts.map +1 -0
- package/dist/conformance/crm/sync.gen.js +25 -0
- package/dist/conformance/crm/sync.gen.js.map +1 -0
- package/dist/conformance/desk/contract.d.ts +306 -0
- package/dist/conformance/desk/contract.d.ts.map +1 -0
- package/dist/conformance/desk/contract.js +56 -0
- package/dist/conformance/desk/contract.js.map +1 -0
- package/dist/conformance/desk/migrations/0000_notes.sql +7 -0
- package/dist/conformance/desk/server.d.ts +231 -0
- package/dist/conformance/desk/server.d.ts.map +1 -0
- package/dist/conformance/desk/server.js +123 -0
- package/dist/conformance/desk/server.js.map +1 -0
- package/dist/conformance/drafts/migrations/0000_drafts.sql +8 -0
- package/dist/conformance/drafts/module.d.ts +571 -0
- package/dist/conformance/drafts/module.d.ts.map +1 -0
- package/dist/conformance/drafts/module.js +190 -0
- package/dist/conformance/drafts/module.js.map +1 -0
- package/dist/conformance/fixture/app.d.ts +24 -0
- package/dist/conformance/fixture/app.d.ts.map +1 -0
- package/dist/conformance/fixture/app.js +26 -0
- package/dist/conformance/fixture/app.js.map +1 -0
- package/dist/conformance/fixture/docs/bad-sync.d.ts +105 -0
- package/dist/conformance/fixture/docs/bad-sync.d.ts.map +1 -0
- package/dist/conformance/fixture/docs/bad-sync.js +22 -0
- package/dist/conformance/fixture/docs/bad-sync.js.map +1 -0
- package/dist/conformance/fixture/docs/contract.d.ts +1091 -0
- package/dist/conformance/fixture/docs/contract.d.ts.map +1 -0
- package/dist/conformance/fixture/docs/contract.js +277 -0
- package/dist/conformance/fixture/docs/contract.js.map +1 -0
- package/dist/conformance/fixture/docs/migrations/0000_docs.sql +9 -0
- package/dist/conformance/fixture/docs/migrations/0001_seen.sql +12 -0
- package/dist/conformance/fixture/docs/migrations/0002_attachment.sql +6 -0
- package/dist/conformance/fixture/docs/policy.cedar +110 -0
- package/dist/conformance/fixture/docs/schema.d.ts +308 -0
- package/dist/conformance/fixture/docs/schema.d.ts.map +1 -0
- package/dist/conformance/fixture/docs/schema.js +36 -0
- package/dist/conformance/fixture/docs/schema.js.map +1 -0
- package/dist/conformance/fixture/docs/server.d.ts +552 -0
- package/dist/conformance/fixture/docs/server.d.ts.map +1 -0
- package/dist/conformance/fixture/docs/server.js +192 -0
- package/dist/conformance/fixture/docs/server.js.map +1 -0
- package/dist/conformance/fixture/docs/sync.d.ts +402 -0
- package/dist/conformance/fixture/docs/sync.d.ts.map +1 -0
- package/dist/conformance/fixture/docs/sync.gen.d.ts +574 -0
- package/dist/conformance/fixture/docs/sync.gen.d.ts.map +1 -0
- package/dist/conformance/fixture/docs/sync.gen.js +48 -0
- package/dist/conformance/fixture/docs/sync.gen.js.map +1 -0
- package/dist/conformance/fixture/docs/sync.js +23 -0
- package/dist/conformance/fixture/docs/sync.js.map +1 -0
- package/dist/conformance/fixture/peer/migrations/0000_peer.sql +8 -0
- package/dist/conformance/fixture/peer/module.d.ts +306 -0
- package/dist/conformance/fixture/peer/module.d.ts.map +1 -0
- package/dist/conformance/fixture/peer/module.js +44 -0
- package/dist/conformance/fixture/peer/module.js.map +1 -0
- package/dist/conformance/fixture/release/blocking/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/blocking/0001_wait.sql +2 -0
- package/dist/conformance/fixture/release/blocking-renamed/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/blocking-renamed/0001_wait.sql +5 -0
- package/dist/conformance/fixture/release/broken/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/broken/0001_extra.sql +3 -0
- package/dist/conformance/fixture/release/broken/0002_label.sql +3 -0
- package/dist/conformance/fixture/release/drift/escalate/0000_item.sql +5 -0
- package/dist/conformance/fixture/release/drift/escalate/0001_escalate.sql +8 -0
- package/dist/conformance/fixture/release/drift/v1/0000_item.sql +5 -0
- package/dist/conformance/fixture/release/escape/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/escape/0001_escape.sql +5 -0
- package/dist/conformance/fixture/release/misnamed/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/misnamed/0001_misname.sql +10 -0
- package/dist/conformance/fixture/release/module.d.ts +1878 -0
- package/dist/conformance/fixture/release/module.d.ts.map +1 -0
- package/dist/conformance/fixture/release/module.js +102 -0
- package/dist/conformance/fixture/release/module.js.map +1 -0
- package/dist/conformance/fixture/release/outside/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/outside/0001_extra.sql +3 -0
- package/dist/conformance/fixture/release/outside/0002_index.sql +4 -0
- package/dist/conformance/fixture/release/outside/0003_later.sql +1 -0
- package/dist/conformance/fixture/release/renamed/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/renamed/0001_misname.sql +10 -0
- package/dist/conformance/fixture/release/renamed/0002_restore.sql +1 -0
- package/dist/conformance/fixture/release/rogue/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/rogue/0001_extra.sql +3 -0
- package/dist/conformance/fixture/release/rogue/0002_definer.sql +1 -0
- package/dist/conformance/fixture/release/slow/0000_item.sql +5 -0
- package/dist/conformance/fixture/release/undeclared/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/undeclared/0001_extra.sql +3 -0
- package/dist/conformance/fixture/release/undeclared/0002_index.sql +1 -0
- package/dist/conformance/fixture/release/v1/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/v2/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/v2/0001_extra.sql +3 -0
- package/dist/conformance/fixture/release/v2/0002_label.sql +3 -0
- package/dist/conformance/fixture/release/viewed-retyped/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/viewed-retyped/0001_retype.sql +1 -0
- package/dist/conformance/kit-hash.d.ts +8 -0
- package/dist/conformance/kit-hash.d.ts.map +1 -0
- package/dist/conformance/kit-hash.js +20 -0
- package/dist/conformance/kit-hash.js.map +1 -0
- package/dist/conformance/ledger/contract.d.ts +380 -0
- package/dist/conformance/ledger/contract.d.ts.map +1 -0
- package/dist/conformance/ledger/contract.js +81 -0
- package/dist/conformance/ledger/contract.js.map +1 -0
- package/dist/conformance/ledger/migrations/0000_entries.sql +8 -0
- package/dist/conformance/ledger/server.d.ts +312 -0
- package/dist/conformance/ledger/server.d.ts.map +1 -0
- package/dist/conformance/ledger/server.js +152 -0
- package/dist/conformance/ledger/server.js.map +1 -0
- package/dist/conformance/library/app.d.ts +616 -0
- package/dist/conformance/library/app.d.ts.map +1 -0
- package/dist/conformance/library/app.js +35 -0
- package/dist/conformance/library/app.js.map +1 -0
- package/dist/conformance/library/contract.d.ts +377 -0
- package/dist/conformance/library/contract.d.ts.map +1 -0
- package/dist/conformance/library/contract.js +63 -0
- package/dist/conformance/library/contract.js.map +1 -0
- package/dist/conformance/library/migrations/0000_library.sql +14 -0
- package/dist/conformance/library/schema.d.ts +174 -0
- package/dist/conformance/library/schema.d.ts.map +1 -0
- package/dist/conformance/library/schema.js +24 -0
- package/dist/conformance/library/schema.js.map +1 -0
- package/dist/conformance/library/server.d.ts +191 -0
- package/dist/conformance/library/server.d.ts.map +1 -0
- package/dist/conformance/library/server.js +52 -0
- package/dist/conformance/library/server.js.map +1 -0
- package/dist/conformance/library/sync.gen.d.ts +519 -0
- package/dist/conformance/library/sync.gen.d.ts.map +1 -0
- package/dist/conformance/library/sync.gen.js +42 -0
- package/dist/conformance/library/sync.gen.js.map +1 -0
- package/dist/conformance/locale/catalog.d.ts +93 -0
- package/dist/conformance/locale/catalog.d.ts.map +1 -0
- package/dist/conformance/locale/catalog.js +104 -0
- package/dist/conformance/locale/catalog.js.map +1 -0
- package/dist/conformance/notebook/app.d.ts +1039 -0
- package/dist/conformance/notebook/app.d.ts.map +1 -0
- package/dist/conformance/notebook/app.js +88 -0
- package/dist/conformance/notebook/app.js.map +1 -0
- package/dist/conformance/notebook/evals/pages.evals.json +94 -0
- package/dist/conformance/notebook/migrations/0000_notebook.sql +10 -0
- package/dist/conformance/notebook/module.d.ts +717 -0
- package/dist/conformance/notebook/module.d.ts.map +1 -0
- package/dist/conformance/notebook/module.js +188 -0
- package/dist/conformance/notebook/module.js.map +1 -0
- package/dist/conformance/pad/app.d.ts +9 -0
- package/dist/conformance/pad/app.d.ts.map +1 -0
- package/dist/conformance/pad/app.js +13 -0
- package/dist/conformance/pad/app.js.map +1 -0
- package/dist/conformance/pad/contract.d.ts +281 -0
- package/dist/conformance/pad/contract.d.ts.map +1 -0
- package/dist/conformance/pad/contract.js +66 -0
- package/dist/conformance/pad/contract.js.map +1 -0
- package/dist/conformance/pad/migrations/pad/0000_pad.sql +8 -0
- package/dist/conformance/pad/migrations/pad/0001_live_copy.sql +2 -0
- package/dist/conformance/pad/schema.d.ts +127 -0
- package/dist/conformance/pad/schema.d.ts.map +1 -0
- package/dist/conformance/pad/schema.js +17 -0
- package/dist/conformance/pad/schema.js.map +1 -0
- package/dist/conformance/pad/server.d.ts +149 -0
- package/dist/conformance/pad/server.d.ts.map +1 -0
- package/dist/conformance/pad/server.js +81 -0
- package/dist/conformance/pad/server.js.map +1 -0
- package/dist/conformance/purchases/app.d.ts +480 -0
- package/dist/conformance/purchases/app.d.ts.map +1 -0
- package/dist/conformance/purchases/app.js +32 -0
- package/dist/conformance/purchases/app.js.map +1 -0
- package/dist/conformance/purchases/contract.d.ts +720 -0
- package/dist/conformance/purchases/contract.d.ts.map +1 -0
- package/dist/conformance/purchases/contract.js +148 -0
- package/dist/conformance/purchases/contract.js.map +1 -0
- package/dist/conformance/purchases/migrations/0000_purchases.sql +17 -0
- package/dist/conformance/purchases/server.d.ts +250 -0
- package/dist/conformance/purchases/server.d.ts.map +1 -0
- package/dist/conformance/purchases/server.js +85 -0
- package/dist/conformance/purchases/server.js.map +1 -0
- package/dist/conformance/studio/app.d.ts +996 -0
- package/dist/conformance/studio/app.d.ts.map +1 -0
- package/dist/conformance/studio/app.js +251 -0
- package/dist/conformance/studio/app.js.map +1 -0
- package/dist/conformance/studio/contract.d.ts +1318 -0
- package/dist/conformance/studio/contract.d.ts.map +1 -0
- package/dist/conformance/studio/contract.js +280 -0
- package/dist/conformance/studio/contract.js.map +1 -0
- package/dist/conformance/studio/migrations/billing/0000_billing.sql +6 -0
- package/dist/conformance/studio/migrations/journal/0000_journal.sql +9 -0
- package/dist/conformance/studio/migrations/mailbox/0000_mailbox.sql +7 -0
- package/dist/conformance/studio/migrations/tasks/0000_tasks.sql +7 -0
- package/dist/conformance/workshop/app.d.ts +8 -0
- package/dist/conformance/workshop/app.d.ts.map +1 -0
- package/dist/conformance/workshop/app.js +13 -0
- package/dist/conformance/workshop/app.js.map +1 -0
- package/dist/conformance/workshop/migrations/0000_notes.sql +7 -0
- package/dist/conformance/workshop/module.d.ts +407 -0
- package/dist/conformance/workshop/module.d.ts.map +1 -0
- package/dist/conformance/workshop/module.js +71 -0
- package/dist/conformance/workshop/module.js.map +1 -0
- package/dist/fakes/AcmeFake.d.ts +46 -0
- package/dist/fakes/AcmeFake.d.ts.map +1 -0
- package/dist/fakes/AcmeFake.js +131 -0
- package/dist/fakes/AcmeFake.js.map +1 -0
- package/dist/fakes/ApnsFake.d.ts +79 -0
- package/dist/fakes/ApnsFake.d.ts.map +1 -0
- package/dist/fakes/ApnsFake.js +220 -0
- package/dist/fakes/ApnsFake.js.map +1 -0
- package/dist/fakes/FcmFake.d.ts +46 -0
- package/dist/fakes/FcmFake.d.ts.map +1 -0
- package/dist/fakes/FcmFake.js +185 -0
- package/dist/fakes/FcmFake.js.map +1 -0
- package/dist/fakes/GoogleFake.d.ts +221 -0
- package/dist/fakes/GoogleFake.d.ts.map +1 -0
- package/dist/fakes/GoogleFake.js +1035 -0
- package/dist/fakes/GoogleFake.js.map +1 -0
- package/dist/fakes/HttpApiFake.d.ts +22 -0
- package/dist/fakes/HttpApiFake.d.ts.map +1 -0
- package/dist/fakes/HttpApiFake.js +74 -0
- package/dist/fakes/HttpApiFake.js.map +1 -0
- package/dist/fakes/McpFake.d.ts +80 -0
- package/dist/fakes/McpFake.d.ts.map +1 -0
- package/dist/fakes/McpFake.js +312 -0
- package/dist/fakes/McpFake.js.map +1 -0
- package/dist/fakes/MicrosoftGraphFake.d.ts +254 -0
- package/dist/fakes/MicrosoftGraphFake.d.ts.map +1 -0
- package/dist/fakes/MicrosoftGraphFake.js +850 -0
- package/dist/fakes/MicrosoftGraphFake.js.map +1 -0
- package/dist/fakes/S3Fake.d.ts +29 -0
- package/dist/fakes/S3Fake.d.ts.map +1 -0
- package/dist/fakes/S3Fake.js +347 -0
- package/dist/fakes/S3Fake.js.map +1 -0
- package/dist/fakes/Server.d.ts +137 -0
- package/dist/fakes/Server.d.ts.map +1 -0
- package/dist/fakes/Server.js +357 -0
- package/dist/fakes/Server.js.map +1 -0
- package/dist/fakes/SignInProviderFake.d.ts +21 -0
- package/dist/fakes/SignInProviderFake.d.ts.map +1 -0
- package/dist/fakes/SignInProviderFake.js +56 -0
- package/dist/fakes/SignInProviderFake.js.map +1 -0
- package/dist/fakes/SlackFake.d.ts +136 -0
- package/dist/fakes/SlackFake.d.ts.map +1 -0
- package/dist/fakes/SlackFake.js +787 -0
- package/dist/fakes/SlackFake.js.map +1 -0
- package/dist/fakes/Store.d.ts +40 -0
- package/dist/fakes/Store.d.ts.map +1 -0
- package/dist/fakes/Store.js +82 -0
- package/dist/fakes/Store.js.map +1 -0
- package/dist/fakes/TelemetryFakes.d.ts +77 -0
- package/dist/fakes/TelemetryFakes.d.ts.map +1 -0
- package/dist/fakes/TelemetryFakes.js +121 -0
- package/dist/fakes/TelemetryFakes.js.map +1 -0
- package/dist/fakes/TestCa.d.ts +11 -0
- package/dist/fakes/TestCa.d.ts.map +1 -0
- package/dist/fakes/TestCa.js +115 -0
- package/dist/fakes/TestCa.js.map +1 -0
- package/dist/fakes/WorkOsFake.d.ts +40 -0
- package/dist/fakes/WorkOsFake.d.ts.map +1 -0
- package/dist/fakes/WorkOsFake.js +103 -0
- package/dist/fakes/WorkOsFake.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/make/reference.d.ts +520 -0
- package/dist/make/reference.d.ts.map +1 -0
- package/dist/make/reference.js +182 -0
- package/dist/make/reference.js.map +1 -0
- package/dist/make/sources.d.ts +48 -0
- package/dist/make/sources.d.ts.map +1 -0
- package/dist/make/sources.js +806 -0
- package/dist/make/sources.js.map +1 -0
- package/package.json +77 -3
- package/src/Admin.ts +82 -0
- package/src/Agent.ts +289 -0
- package/src/AgentSurface.ts +51 -0
- package/src/Embedder.ts +69 -0
- package/src/EvalMain.ts +81 -0
- package/src/Evals.ts +490 -0
- package/src/Kernel.ts +228 -0
- package/src/Launch.ts +428 -0
- package/src/Locks.ts +123 -0
- package/src/Routes.ts +65 -0
- package/src/ScriptedChatModel.ts +189 -0
- package/src/SmtpSink.ts +205 -0
- package/src/System.ts +1072 -0
- package/src/TcpProxy.ts +102 -0
- package/src/auth/TrustedProxyAuth.ts +173 -0
- package/src/conformance/ActionConsent.ts +437 -0
- package/src/conformance/ActionRegistry.ts +174 -0
- package/src/conformance/Actor.ts +216 -0
- package/src/conformance/AgentReference.ts +171 -0
- package/src/conformance/AgentResources.ts +548 -0
- package/src/conformance/AgentRuntime.ts +388 -0
- package/src/conformance/AgentSubject.ts +103 -0
- package/src/conformance/Approvals.ts +363 -0
- package/src/conformance/Audit.ts +257 -0
- package/src/conformance/CalendarProvider.ts +156 -0
- package/src/conformance/CapabilityKit.ts +564 -0
- package/src/conformance/ClientSDK.ts +233 -0
- package/src/conformance/CollabDocument.ts +1203 -0
- package/src/conformance/CollabReference.ts +152 -0
- package/src/conformance/CollabSubject.ts +64 -0
- package/src/conformance/Command.ts +75 -0
- package/src/conformance/Connections.ts +357 -0
- package/src/conformance/ConnectionsReference.ts +172 -0
- package/src/conformance/ConnectorReference.ts +280 -0
- package/src/conformance/ContextAccounting.ts +169 -0
- package/src/conformance/Daemon.ts +936 -0
- package/src/conformance/DaemonReference.ts +189 -0
- package/src/conformance/DbTx.ts +253 -0
- package/src/conformance/DecisionTokens.ts +652 -0
- package/src/conformance/Delegation.ts +177 -0
- package/src/conformance/DeskReference.ts +73 -0
- package/src/conformance/DeviceControl.ts +700 -0
- package/src/conformance/Directory.ts +315 -0
- package/src/conformance/DirectoryProvider.ts +72 -0
- package/src/conformance/DocumentSource.ts +62 -0
- package/src/conformance/EndpointReference.ts +117 -0
- package/src/conformance/Files.ts +685 -0
- package/src/conformance/FilesReference.ts +154 -0
- package/src/conformance/FilesSubject.ts +50 -0
- package/src/conformance/Flags.ts +215 -0
- package/src/conformance/Host.ts +197 -0
- package/src/conformance/HttpApi.ts +169 -0
- package/src/conformance/InboxReference.ts +401 -0
- package/src/conformance/InboxSubject.ts +101 -0
- package/src/conformance/Ingestion.ts +425 -0
- package/src/conformance/Ingress.ts +498 -0
- package/src/conformance/Invocation.ts +780 -0
- package/src/conformance/IsolationMatrix.ts +215 -0
- package/src/conformance/LiveConnection.ts +197 -0
- package/src/conformance/LocalClient.ts +651 -0
- package/src/conformance/Locale.ts +141 -0
- package/src/conformance/MachineIdentity.ts +828 -0
- package/src/conformance/MailProvider.ts +217 -0
- package/src/conformance/Memory.ts +223 -0
- package/src/conformance/Messaging.ts +185 -0
- package/src/conformance/Metering.ts +293 -0
- package/src/conformance/ModelProvider.ts +139 -0
- package/src/conformance/ModuleManifest.ts +630 -0
- package/src/conformance/NotebookAgent.ts +41 -0
- package/src/conformance/NotificationChannel.ts +122 -0
- package/src/conformance/Notifications.ts +316 -0
- package/src/conformance/OAuthClient.ts +240 -0
- package/src/conformance/Outbox.ts +342 -0
- package/src/conformance/PlatformReference.ts +73 -0
- package/src/conformance/PlatformSubject.ts +50 -0
- package/src/conformance/Privacy.ts +577 -0
- package/src/conformance/Progress.ts +244 -0
- package/src/conformance/Push.ts +820 -0
- package/src/conformance/PushReference.ts +101 -0
- package/src/conformance/QuerySurface.ts +408 -0
- package/src/conformance/Readiness.ts +157 -0
- package/src/conformance/Reference.ts +326 -0
- package/src/conformance/Release.ts +690 -0
- package/src/conformance/ReleaseReference.ts +179 -0
- package/src/conformance/ResultRendering.ts +149 -0
- package/src/conformance/Sandbox.ts +313 -0
- package/src/conformance/SandboxReference.ts +52 -0
- package/src/conformance/Scheduler.ts +764 -0
- package/src/conformance/ScreenContext.ts +402 -0
- package/src/conformance/Search.ts +419 -0
- package/src/conformance/Secrets.ts +277 -0
- package/src/conformance/SecretsReference.ts +131 -0
- package/src/conformance/ServicesReference.ts +330 -0
- package/src/conformance/ServicesSubject.ts +105 -0
- package/src/conformance/Settings.ts +204 -0
- package/src/conformance/Sharing.ts +486 -0
- package/src/conformance/ShellSubject.ts +47 -0
- package/src/conformance/SignOutRace.ts +77 -0
- package/src/conformance/Slot.ts +84 -0
- package/src/conformance/Space.ts +432 -0
- package/src/conformance/StorageAdapter.ts +253 -0
- package/src/conformance/StorageBackend.ts +327 -0
- package/src/conformance/Subject.ts +208 -0
- package/src/conformance/Sync.ts +215 -0
- package/src/conformance/Telemetry.ts +287 -0
- package/src/conformance/ThemeTokens.ts +163 -0
- package/src/conformance/ToolSource.ts +632 -0
- package/src/conformance/Versioning.ts +199 -0
- package/src/conformance/View.ts +143 -0
- package/src/conformance/WorkItems.ts +186 -0
- package/src/conformance/Workflow.ts +304 -0
- package/src/conformance/acme/chatlog.ts +115 -0
- package/src/conformance/acme/connector.ts +151 -0
- package/src/conformance/acme/migrations/0000_messages.sql +8 -0
- package/src/conformance/archive/app.ts +33 -0
- package/src/conformance/archive/contract.ts +191 -0
- package/src/conformance/archive/memo.sync.gen.ts +25 -0
- package/src/conformance/archive/migrations/archive/0000_archive.sql +9 -0
- package/src/conformance/archive/migrations/memo/0000_memo.sql +6 -0
- package/src/conformance/archive/schema.ts +25 -0
- package/src/conformance/archive/server.ts +146 -0
- package/src/conformance/archive/sync.gen.ts +32 -0
- package/src/conformance/atlas/app.ts +16 -0
- package/src/conformance/atlas/contract.ts +118 -0
- package/src/conformance/crm/app.ts +107 -0
- package/src/conformance/crm/contract.ts +163 -0
- package/src/conformance/crm/migrations/crm/0000_crm.sql +18 -0
- package/src/conformance/crm/migrations/team/0000_team.sql +6 -0
- package/src/conformance/crm/schema.ts +28 -0
- package/src/conformance/crm/sync.gen.ts +27 -0
- package/src/conformance/desk/contract.ts +61 -0
- package/src/conformance/desk/migrations/0000_notes.sql +7 -0
- package/src/conformance/desk/server.ts +131 -0
- package/src/conformance/drafts/migrations/0000_drafts.sql +8 -0
- package/src/conformance/drafts/module.ts +211 -0
- package/src/conformance/fixture/app.ts +37 -0
- package/src/conformance/fixture/docs/bad-sync.ts +34 -0
- package/src/conformance/fixture/docs/contract.ts +297 -0
- package/src/conformance/fixture/docs/migrations/0000_docs.sql +9 -0
- package/src/conformance/fixture/docs/migrations/0001_seen.sql +12 -0
- package/src/conformance/fixture/docs/migrations/0002_attachment.sql +6 -0
- package/src/conformance/fixture/docs/policy.cedar +110 -0
- package/src/conformance/fixture/docs/schema.ts +41 -0
- package/src/conformance/fixture/docs/server.ts +292 -0
- package/src/conformance/fixture/docs/sync.gen.ts +54 -0
- package/src/conformance/fixture/docs/sync.ts +24 -0
- package/src/conformance/fixture/peer/migrations/0000_peer.sql +8 -0
- package/src/conformance/fixture/peer/module.ts +51 -0
- package/src/conformance/fixture/release/blocking/0000_item.sql +3 -0
- package/src/conformance/fixture/release/blocking/0001_wait.sql +2 -0
- package/src/conformance/fixture/release/blocking-renamed/0000_item.sql +3 -0
- package/src/conformance/fixture/release/blocking-renamed/0001_wait.sql +5 -0
- package/src/conformance/fixture/release/broken/0000_item.sql +3 -0
- package/src/conformance/fixture/release/broken/0001_extra.sql +3 -0
- package/src/conformance/fixture/release/broken/0002_label.sql +3 -0
- package/src/conformance/fixture/release/drift/escalate/0000_item.sql +5 -0
- package/src/conformance/fixture/release/drift/escalate/0001_escalate.sql +8 -0
- package/src/conformance/fixture/release/drift/v1/0000_item.sql +5 -0
- package/src/conformance/fixture/release/escape/0000_item.sql +3 -0
- package/src/conformance/fixture/release/escape/0001_escape.sql +5 -0
- package/src/conformance/fixture/release/misnamed/0000_item.sql +3 -0
- package/src/conformance/fixture/release/misnamed/0001_misname.sql +10 -0
- package/src/conformance/fixture/release/module.ts +119 -0
- package/src/conformance/fixture/release/outside/0000_item.sql +3 -0
- package/src/conformance/fixture/release/outside/0001_extra.sql +3 -0
- package/src/conformance/fixture/release/outside/0002_index.sql +4 -0
- package/src/conformance/fixture/release/outside/0003_later.sql +1 -0
- package/src/conformance/fixture/release/renamed/0000_item.sql +3 -0
- package/src/conformance/fixture/release/renamed/0001_misname.sql +10 -0
- package/src/conformance/fixture/release/renamed/0002_restore.sql +1 -0
- package/src/conformance/fixture/release/rogue/0000_item.sql +3 -0
- package/src/conformance/fixture/release/rogue/0001_extra.sql +3 -0
- package/src/conformance/fixture/release/rogue/0002_definer.sql +1 -0
- package/src/conformance/fixture/release/slow/0000_item.sql +5 -0
- package/src/conformance/fixture/release/undeclared/0000_item.sql +3 -0
- package/src/conformance/fixture/release/undeclared/0001_extra.sql +3 -0
- package/src/conformance/fixture/release/undeclared/0002_index.sql +1 -0
- package/src/conformance/fixture/release/v1/0000_item.sql +3 -0
- package/src/conformance/fixture/release/v2/0000_item.sql +3 -0
- package/src/conformance/fixture/release/v2/0001_extra.sql +3 -0
- package/src/conformance/fixture/release/v2/0002_label.sql +3 -0
- package/src/conformance/fixture/release/viewed-retyped/0000_item.sql +3 -0
- package/src/conformance/fixture/release/viewed-retyped/0001_retype.sql +1 -0
- package/src/conformance/kit-hash.ts +18 -0
- package/src/conformance/ledger/contract.ts +92 -0
- package/src/conformance/ledger/migrations/0000_entries.sql +8 -0
- package/src/conformance/ledger/server.ts +174 -0
- package/src/conformance/library/app.ts +38 -0
- package/src/conformance/library/contract.ts +66 -0
- package/src/conformance/library/migrations/0000_library.sql +14 -0
- package/src/conformance/library/schema.ts +27 -0
- package/src/conformance/library/server.ts +65 -0
- package/src/conformance/library/sync.gen.ts +47 -0
- package/src/conformance/locale/catalog.ts +111 -0
- package/src/conformance/notebook/app.ts +115 -0
- package/src/conformance/notebook/evals/pages.evals.json +94 -0
- package/src/conformance/notebook/migrations/0000_notebook.sql +10 -0
- package/src/conformance/notebook/module.ts +215 -0
- package/src/conformance/notebook/skills/meeting-notes.md +4 -0
- package/src/conformance/pad/app.ts +21 -0
- package/src/conformance/pad/contract.ts +69 -0
- package/src/conformance/pad/migrations/pad/0000_pad.sql +8 -0
- package/src/conformance/pad/migrations/pad/0001_live_copy.sql +2 -0
- package/src/conformance/pad/schema.ts +18 -0
- package/src/conformance/pad/server.ts +102 -0
- package/src/conformance/purchases/app.ts +34 -0
- package/src/conformance/purchases/contract.ts +161 -0
- package/src/conformance/purchases/migrations/0000_purchases.sql +17 -0
- package/src/conformance/purchases/server.ts +95 -0
- package/src/conformance/replica-search.mjs +22 -0
- package/src/conformance/studio/app.ts +298 -0
- package/src/conformance/studio/contract.ts +319 -0
- package/src/conformance/studio/migrations/billing/0000_billing.sql +6 -0
- package/src/conformance/studio/migrations/journal/0000_journal.sql +9 -0
- package/src/conformance/studio/migrations/mailbox/0000_mailbox.sql +7 -0
- package/src/conformance/studio/migrations/tasks/0000_tasks.sql +7 -0
- package/src/conformance/workshop/app.ts +14 -0
- package/src/conformance/workshop/migrations/0000_notes.sql +7 -0
- package/src/conformance/workshop/module.ts +79 -0
- package/src/fakes/AcmeFake.ts +182 -0
- package/src/fakes/ApnsFake.ts +245 -0
- package/src/fakes/FcmFake.ts +231 -0
- package/src/fakes/GoogleFake.ts +1346 -0
- package/src/fakes/HttpApiFake.ts +116 -0
- package/src/fakes/McpFake.ts +355 -0
- package/src/fakes/MicrosoftGraphFake.ts +1191 -0
- package/src/fakes/S3Fake.ts +376 -0
- package/src/fakes/Server.ts +445 -0
- package/src/fakes/SignInProviderFake.ts +70 -0
- package/src/fakes/SlackFake.ts +893 -0
- package/src/fakes/Store.ts +96 -0
- package/src/fakes/TelemetryFakes.ts +197 -0
- package/src/fakes/TestCa.ts +166 -0
- package/src/fakes/WorkOsFake.ts +136 -0
- package/src/index.ts +9 -0
- package/src/make/reference.ts +259 -0
- package/src/make/sources.ts +836 -0
|
@@ -0,0 +1,1346 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A protocol fake of Google's OAuth 2.0 endpoints and the subset of Google Workspace APIs the `google` connector
|
|
3
|
+
* uses, following Google's documentation:
|
|
4
|
+
*
|
|
5
|
+
* - OAuth 2.0: `/o/oauth2/v2/auth` (PKCE S256; a refresh token only with `access_type=offline`; incremental
|
|
6
|
+
* consent with `include_granted_scopes`) and `/token` (refresh tokens not rotated; `invalid_grant` errors),
|
|
7
|
+
* OpenID Connect `/v1/userinfo`
|
|
8
|
+
* - Gmail v1: labels, `messages` (list by label, get with `format` (`metadata` keeps only the `metadataHeaders`
|
|
9
|
+
* asked for, and no body), `modify`, `trash`, `send` with a raw RFC 2822 message), `drafts`, `profile` and
|
|
10
|
+
* `history` (records of `messagesAdded`, `messagesDeleted`, `labelsAdded`, `labelsRemoved`, whose messages
|
|
11
|
+
* carry only `id` and `threadId`; `historyTypes` and `labelId` filters; paged; a `startHistoryId` older than
|
|
12
|
+
* the retained history, or newer than the mailbox, is 404 Not Found); an id that is not hexadecimal is 400
|
|
13
|
+
* `Invalid id value`. As the real API (live-verified 2026-11-10): `send` replaces the sender's `Message-ID` with
|
|
14
|
+
* Gmail's own and keeps custom (`X-`) headers as written; search (`q`) knows only `rfc822msgid:` here, matches
|
|
15
|
+
* Gmail's `Message-ID` and never a custom header, and finds a message only once it is indexed
|
|
16
|
+
* (`searchIndexDelayMs`, 2 s by default), while a list by label has it at once; any other `q` is refused, so a
|
|
17
|
+
* connector relying on a search this fake cannot answer as Gmail would fails here
|
|
18
|
+
* - Gmail filters (`settings/filters`: list, get, create, delete; listing needs a read scope, writing
|
|
19
|
+
* `gmail.settings.basic`; a filter without a criterion or an action is 400 `FAILED_PRECONDITION`)
|
|
20
|
+
* - Calendar v3: `calendarList`, events `list` (time range, `singleEvents`, paging, `nextSyncToken`; with a
|
|
21
|
+
* `syncToken` only the changes, cancelled events included; a token never issued is 400 `invalid`, an expired
|
|
22
|
+
* one 410 Gone `fullSyncRequired`), `get`, `insert`, `patch`, `delete` (the event becomes `cancelled`)
|
|
23
|
+
* - Admin SDK Directory v1: `users` (list with `customer=my_customer`, get) and `groups`, with etags; no delta
|
|
24
|
+
* - Drive v3: `files` (list by parent, get, `alt=media`), `changes/startPageToken` and `changes` (removals and
|
|
25
|
+
* trashed files; an unknown page token is 400 Invalid Value on `pageToken`); only the `fields` asked for (by
|
|
26
|
+
* default a file's `kind`, `id`, `name` and `mimeType`); an upload's processing change shortly after it
|
|
27
|
+
* - Calendar's cancelled events on an incremental sync carry only `id` and `status`; the Admin SDK omits
|
|
28
|
+
* `users` from an empty page
|
|
29
|
+
* - errors in Google's JSON error formats: Gmail's and the scope errors with `status` (401 `UNAUTHENTICATED` with
|
|
30
|
+
* `WWW-Authenticate`, 403 `PERMISSION_DENIED` with `insufficientPermissions` and
|
|
31
|
+
* `ACCESS_TOKEN_SCOPE_INSUFFICIENT` and `WWW-Authenticate: ... error="insufficient_scope"`, 403
|
|
32
|
+
* `userRateLimitExceeded`, 429 `RESOURCE_EXHAUSTED` and 503 `UNAVAILABLE` with `Retry-After`, 404 `NOT_FOUND`);
|
|
33
|
+
* Calendar's, the Admin SDK's (403 `forbidden` for an account whose role lacks the privilege) and Drive's
|
|
34
|
+
* without it
|
|
35
|
+
*
|
|
36
|
+
* The error bodies, Gmail's invalid ids and future history ids, Calendar's unissued sync tokens and Drive's
|
|
37
|
+
* processing changes follow what the real services answered to the live kits (docs/connectors/google.md).
|
|
38
|
+
*/
|
|
39
|
+
import { randomBytes } from "node:crypto"
|
|
40
|
+
import { json, OAuthServer, Router, serve, Throttle, type FakeRequest, type FakeResponse } from "./Server.ts"
|
|
41
|
+
import { Collection, decodeToken, encodeToken } from "./Store.ts"
|
|
42
|
+
|
|
43
|
+
const SCOPE = "https://www.googleapis.com/auth/"
|
|
44
|
+
const id = (prefix = "") => `${prefix}${randomBytes(8).toString("hex")}`
|
|
45
|
+
const now = () => new Date().toISOString().replace(/\.\d{3}Z$/u, ".000Z")
|
|
46
|
+
|
|
47
|
+
export interface GmailMessage {
|
|
48
|
+
readonly id: string
|
|
49
|
+
readonly threadId: string
|
|
50
|
+
readonly labelIds: ReadonlyArray<string>
|
|
51
|
+
readonly from: string
|
|
52
|
+
readonly to: string
|
|
53
|
+
readonly cc: string
|
|
54
|
+
readonly subject: string
|
|
55
|
+
readonly body: string
|
|
56
|
+
readonly internalDate: number
|
|
57
|
+
/** The message's Message-ID: Gmail's own for a sent message (it replaces the sender's). */
|
|
58
|
+
readonly messageId?: string | undefined
|
|
59
|
+
/** The custom (`X-`) headers the sender set, kept as written (and never searchable). */
|
|
60
|
+
readonly extraHeaders?: ReadonlyArray<{ readonly name: string; readonly value: string }> | undefined
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface GoogleEvent {
|
|
64
|
+
readonly id: string
|
|
65
|
+
readonly calendarId: string
|
|
66
|
+
readonly status: "confirmed" | "tentative" | "cancelled"
|
|
67
|
+
readonly summary: string
|
|
68
|
+
readonly description: string | null
|
|
69
|
+
readonly location: string | null
|
|
70
|
+
readonly start: string
|
|
71
|
+
readonly end: string
|
|
72
|
+
/** `self`: the calendar owner's own entry, whatever its address (else the entry under the owner's address). */
|
|
73
|
+
readonly attendees: ReadonlyArray<{
|
|
74
|
+
readonly email: string
|
|
75
|
+
readonly responseStatus: string
|
|
76
|
+
readonly self?: boolean
|
|
77
|
+
}>
|
|
78
|
+
readonly organizer: string
|
|
79
|
+
readonly updated: string
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface GoogleUser {
|
|
83
|
+
readonly id: string
|
|
84
|
+
readonly primaryEmail: string
|
|
85
|
+
readonly givenName: string
|
|
86
|
+
readonly familyName: string
|
|
87
|
+
readonly suspended: boolean
|
|
88
|
+
readonly title: string | null
|
|
89
|
+
readonly department: string | null
|
|
90
|
+
readonly etag: string
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface DriveFile {
|
|
94
|
+
readonly id: string
|
|
95
|
+
readonly name: string
|
|
96
|
+
readonly mimeType: string
|
|
97
|
+
readonly parent: string
|
|
98
|
+
readonly content: string
|
|
99
|
+
readonly trashed: boolean
|
|
100
|
+
readonly modifiedTime: string
|
|
101
|
+
readonly version: number
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface GoogleFakeOptions {
|
|
105
|
+
readonly clientId?: string
|
|
106
|
+
readonly clientSecret?: string
|
|
107
|
+
/** How long a message takes to reach Gmail's search index (`q`); a list by label has it at once. */
|
|
108
|
+
readonly searchIndexDelayMs?: number
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const SYSTEM_LABELS = ["INBOX", "SENT", "DRAFT", "TRASH", "SPAM", "UNREAD", "STARRED", "IMPORTANT"] as const
|
|
112
|
+
|
|
113
|
+
export const startGoogleFake = async (options: GoogleFakeOptions = {}) => {
|
|
114
|
+
const clientId = options.clientId ?? "google-fake-client.apps.googleusercontent.com"
|
|
115
|
+
const clientSecret = options.clientSecret ?? "google-fake-secret"
|
|
116
|
+
const searchIndexDelayMs = options.searchIndexDelayMs ?? 2000
|
|
117
|
+
const oauth = new OAuthServer({
|
|
118
|
+
clientId,
|
|
119
|
+
clientSecret,
|
|
120
|
+
rotateRefreshTokens: false,
|
|
121
|
+
offlineParam: true,
|
|
122
|
+
// Google lists `email` as the userinfo scope.
|
|
123
|
+
scopeOut: (scope) => (scope === "email" ? `${SCOPE}userinfo.email` : scope),
|
|
124
|
+
tokenError: (error, description) => ({ error, error_description: description }),
|
|
125
|
+
})
|
|
126
|
+
const throttle = new Throttle()
|
|
127
|
+
/** Messages whose full read fails (500) while listed here: a provider that cannot answer for one message. */
|
|
128
|
+
const failingReads = new Set<string>()
|
|
129
|
+
/** Injected Drive/Gmail-style 403 `userRateLimitExceeded` answers. */
|
|
130
|
+
let userRateLimited = 0
|
|
131
|
+
const clock = { seq: 0 }
|
|
132
|
+
const minSeq = { mail: 0, calendar: 0, drive: 0 }
|
|
133
|
+
let apiRequests = 0
|
|
134
|
+
/** The API requests received (the newest 10 000): what a connector asked for, and how often. */
|
|
135
|
+
const requestLog: Array<{ readonly method: string; readonly url: URL }> = []
|
|
136
|
+
/** Answers to drop after the request was carried out (the provider acted; the caller hears a 503). */
|
|
137
|
+
let lostResponses = 0
|
|
138
|
+
const messages = new Collection<GmailMessage>(clock)
|
|
139
|
+
const events = new Collection<GoogleEvent>(clock)
|
|
140
|
+
const users = new Collection<GoogleUser>(clock)
|
|
141
|
+
const files = new Collection<DriveFile>(clock)
|
|
142
|
+
const self = {
|
|
143
|
+
id: "1144" + randomBytes(8).toString("hex").replaceAll(/\D/gu, "7"),
|
|
144
|
+
email: "adele@workspace.example",
|
|
145
|
+
name: "Adele Vance",
|
|
146
|
+
}
|
|
147
|
+
const PRIMARY = self.email
|
|
148
|
+
|
|
149
|
+
const router = new Router()
|
|
150
|
+
let base = ""
|
|
151
|
+
|
|
152
|
+
// ---- errors in Google's JSON error format
|
|
153
|
+
const googleError = (
|
|
154
|
+
code: number,
|
|
155
|
+
status: string,
|
|
156
|
+
message: string,
|
|
157
|
+
errors: ReadonlyArray<Record<string, unknown>> = [],
|
|
158
|
+
headers: Record<string, string> = {},
|
|
159
|
+
details?: ReadonlyArray<unknown>,
|
|
160
|
+
) => json(code, { error: { code, message, errors, status, ...(details === undefined ? {} : { details }) } }, headers)
|
|
161
|
+
const unauthorized = () =>
|
|
162
|
+
googleError(
|
|
163
|
+
401,
|
|
164
|
+
"UNAUTHENTICATED",
|
|
165
|
+
"Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
|
|
166
|
+
[
|
|
167
|
+
{
|
|
168
|
+
message: "Invalid Credentials",
|
|
169
|
+
domain: "global",
|
|
170
|
+
reason: "authError",
|
|
171
|
+
location: "Authorization",
|
|
172
|
+
locationType: "header",
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
{ "www-authenticate": `Bearer realm="https://accounts.google.com/"` },
|
|
176
|
+
)
|
|
177
|
+
const insufficient = (service: string, required: ReadonlyArray<string>) =>
|
|
178
|
+
googleError(
|
|
179
|
+
403,
|
|
180
|
+
"PERMISSION_DENIED",
|
|
181
|
+
"Request had insufficient authentication scopes.",
|
|
182
|
+
[{ message: "Insufficient Permission", domain: "global", reason: "insufficientPermissions" }],
|
|
183
|
+
{
|
|
184
|
+
"www-authenticate": `Bearer realm="https://accounts.google.com/", error="insufficient_scope", scope="${required.join(" ")}"`,
|
|
185
|
+
},
|
|
186
|
+
[
|
|
187
|
+
{
|
|
188
|
+
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
|
|
189
|
+
reason: "ACCESS_TOKEN_SCOPE_INSUFFICIENT",
|
|
190
|
+
domain: "googleapis.com",
|
|
191
|
+
metadata: { service },
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
)
|
|
195
|
+
const notFound = () =>
|
|
196
|
+
googleError(404, "NOT_FOUND", "Requested entity was not found.", [
|
|
197
|
+
{ message: "Requested entity was not found.", domain: "global", reason: "notFound" },
|
|
198
|
+
])
|
|
199
|
+
/**
|
|
200
|
+
* Calendar, the Admin SDK and Drive answer in the older JSON error format: `errors`, `code` and `message`, no
|
|
201
|
+
* `status` (seen from the real APIs; Gmail and the scope errors carry `status`).
|
|
202
|
+
*/
|
|
203
|
+
const legacyError = (code: number, message: string, error: Record<string, unknown>) =>
|
|
204
|
+
json(code, { error: { errors: [{ message, domain: "global", ...error }], code, message } })
|
|
205
|
+
const calendarNotFound = () => legacyError(404, "Not Found", { reason: "notFound" })
|
|
206
|
+
|
|
207
|
+
type Me = { readonly id: string; readonly email: string; readonly name: string }
|
|
208
|
+
const api =
|
|
209
|
+
(
|
|
210
|
+
service: string,
|
|
211
|
+
anyOf: ReadonlyArray<string>,
|
|
212
|
+
handler: (request: FakeRequest, me: Me) => FakeResponse | Promise<FakeResponse>,
|
|
213
|
+
) =>
|
|
214
|
+
(request: FakeRequest) => {
|
|
215
|
+
apiRequests++
|
|
216
|
+
requestLog.push({ method: request.method, url: request.url })
|
|
217
|
+
if (requestLog.length > 10_000) requestLog.shift()
|
|
218
|
+
const injected = throttle.next(request.method)
|
|
219
|
+
if (injected !== undefined) {
|
|
220
|
+
const headers: Record<string, string> =
|
|
221
|
+
injected.retryAfter === null ? {} : { "retry-after": injected.retryAfter }
|
|
222
|
+
return injected.status === 429
|
|
223
|
+
? googleError(
|
|
224
|
+
429,
|
|
225
|
+
"RESOURCE_EXHAUSTED",
|
|
226
|
+
"Quota exceeded for quota metric 'Queries' and limit 'Queries per minute per user'.",
|
|
227
|
+
[{ message: "Rate Limit Exceeded", domain: "usageLimits", reason: "rateLimitExceeded" }],
|
|
228
|
+
headers,
|
|
229
|
+
)
|
|
230
|
+
: googleError(injected.status, "UNAVAILABLE", "The service is currently unavailable.", [], headers)
|
|
231
|
+
}
|
|
232
|
+
if (userRateLimited > 0) {
|
|
233
|
+
userRateLimited--
|
|
234
|
+
return googleError(403, "PERMISSION_DENIED", "User Rate Limit Exceeded", [
|
|
235
|
+
{ message: "User Rate Limit Exceeded", domain: "usageLimits", reason: "userRateLimitExceeded" },
|
|
236
|
+
])
|
|
237
|
+
}
|
|
238
|
+
const caller = oauth.authenticate(request)
|
|
239
|
+
if (caller === undefined) return unauthorized()
|
|
240
|
+
const required = anyOf.map((s) => (s.startsWith("https://") ? s : `${SCOPE}${s}`))
|
|
241
|
+
if (!required.some((scope) => caller.scopes.has(scope))) return insufficient(service, required)
|
|
242
|
+
const answer = handler(request, caller.account)
|
|
243
|
+
if (lostResponses > 0) {
|
|
244
|
+
lostResponses--
|
|
245
|
+
return Promise.resolve(answer).then(() => json(503, { error: { code: 503, message: "The answer was lost" } }))
|
|
246
|
+
}
|
|
247
|
+
return answer
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// ---- OAuth and OpenID Connect
|
|
251
|
+
router.add("GET", "/o/oauth2/v2/auth", oauth.authorize)
|
|
252
|
+
router.add("POST", "/token", oauth.tokenEndpoint)
|
|
253
|
+
router.add(
|
|
254
|
+
"GET",
|
|
255
|
+
"/v1/userinfo",
|
|
256
|
+
api("openidconnect.googleapis.com", ["openid", "email", "userinfo.email"], (_r, me) =>
|
|
257
|
+
json(200, { sub: me.id, email: me.email, email_verified: true, name: me.name }),
|
|
258
|
+
),
|
|
259
|
+
)
|
|
260
|
+
|
|
261
|
+
// ---- Gmail v1
|
|
262
|
+
const GMAIL_READ = ["gmail.readonly", "gmail.modify", "https://mail.google.com/"]
|
|
263
|
+
const GMAIL_MODIFY = ["gmail.modify", "https://mail.google.com/"]
|
|
264
|
+
const GMAIL_SEND = ["gmail.send", "gmail.compose", "gmail.modify", "https://mail.google.com/"]
|
|
265
|
+
const GMAIL_COMPOSE = ["gmail.compose", "gmail.modify", "https://mail.google.com/"]
|
|
266
|
+
const historyFloor = () => minSeq.mail
|
|
267
|
+
const b64 = (text: string) => Buffer.from(text, "utf8").toString("base64url")
|
|
268
|
+
const renderMessage = (m: GmailMessage, format: string, metadataHeaders: ReadonlyArray<string> = []) => {
|
|
269
|
+
const all = [
|
|
270
|
+
{ name: "From", value: m.from },
|
|
271
|
+
{ name: "To", value: m.to },
|
|
272
|
+
...(m.cc ? [{ name: "Cc", value: m.cc }] : []),
|
|
273
|
+
{ name: "Subject", value: m.subject },
|
|
274
|
+
{ name: "Date", value: new Date(m.internalDate).toUTCString() },
|
|
275
|
+
...(m.messageId ? [{ name: "Message-Id", value: m.messageId }] : []),
|
|
276
|
+
...(m.extraHeaders ?? []),
|
|
277
|
+
]
|
|
278
|
+
const wanted = new Set(metadataHeaders.map((h) => h.toLowerCase()))
|
|
279
|
+
const headers = format === "metadata" && wanted.size > 0 ? all.filter((h) => wanted.has(h.name.toLowerCase())) : all
|
|
280
|
+
return {
|
|
281
|
+
id: m.id,
|
|
282
|
+
threadId: m.threadId,
|
|
283
|
+
labelIds: m.labelIds,
|
|
284
|
+
snippet: m.body.slice(0, 100),
|
|
285
|
+
// As Gmail: the last history record that changed this message.
|
|
286
|
+
historyId: String(messages.lastChange(m.id)),
|
|
287
|
+
internalDate: String(m.internalDate),
|
|
288
|
+
sizeEstimate: m.body.length + 200,
|
|
289
|
+
...(format === "minimal"
|
|
290
|
+
? {}
|
|
291
|
+
: {
|
|
292
|
+
payload: {
|
|
293
|
+
partId: "",
|
|
294
|
+
mimeType: "text/plain",
|
|
295
|
+
filename: "",
|
|
296
|
+
headers,
|
|
297
|
+
...(format === "metadata" ? {} : { body: { size: m.body.length, data: b64(m.body) } }),
|
|
298
|
+
},
|
|
299
|
+
}),
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Gmail's ids are hexadecimal. One that is not cannot name a message: the real API answers 400 `Invalid id
|
|
304
|
+
* value` before looking (a well-formed id of no message is 404).
|
|
305
|
+
*/
|
|
306
|
+
const invalidId = (value: string) =>
|
|
307
|
+
/^[0-9a-f]+$/u.test(value)
|
|
308
|
+
? undefined
|
|
309
|
+
: googleError(400, "INVALID_ARGUMENT", "Invalid id value", [
|
|
310
|
+
{ message: "Invalid id value", domain: "global", reason: "invalidArgument" },
|
|
311
|
+
])
|
|
312
|
+
const parseRaw = (raw: string) => {
|
|
313
|
+
const text = Buffer.from(raw.replaceAll("-", "+").replaceAll("_", "/"), "base64").toString("utf8")
|
|
314
|
+
const split = text.indexOf("\r\n\r\n") >= 0 ? text.indexOf("\r\n\r\n") : text.indexOf("\n\n")
|
|
315
|
+
const head = split >= 0 ? text.slice(0, split) : text
|
|
316
|
+
const body = split >= 0 ? text.slice(split).trim() : ""
|
|
317
|
+
const header = (name: string) =>
|
|
318
|
+
head
|
|
319
|
+
.split(/\r?\n/u)
|
|
320
|
+
.find((line) => line.toLowerCase().startsWith(`${name.toLowerCase()}:`))
|
|
321
|
+
?.slice(name.length + 1)
|
|
322
|
+
.trim() ?? ""
|
|
323
|
+
const extraHeaders = head
|
|
324
|
+
.split(/\r?\n/u)
|
|
325
|
+
.filter((line) => /^x-[^:]*:/iu.test(line))
|
|
326
|
+
.map((line) => ({ name: line.slice(0, line.indexOf(":")), value: line.slice(line.indexOf(":") + 1).trim() }))
|
|
327
|
+
return { from: header("From"), to: header("To"), cc: header("Cc"), subject: header("Subject"), body, extraHeaders }
|
|
328
|
+
}
|
|
329
|
+
/** The account's verified send-as aliases besides its primary address (`mail.sendAs`). */
|
|
330
|
+
const sendAs: Array<{ sendAsEmail: string; displayName: string }> = []
|
|
331
|
+
/** How many reads of the send-as addresses fail next (500), as Gmail's backend can (`mail.failSendAs`). */
|
|
332
|
+
let failingSendAs = 0
|
|
333
|
+
router.add(
|
|
334
|
+
"GET",
|
|
335
|
+
"/gmail/v1/users/me/settings/sendAs",
|
|
336
|
+
api("gmail.googleapis.com", GMAIL_READ, (_request, me) =>
|
|
337
|
+
failingSendAs-- > 0
|
|
338
|
+
? googleError(500, "INTERNAL", "Internal error encountered.", [{ domain: "global", reason: "backendError" }])
|
|
339
|
+
: json(200, {
|
|
340
|
+
sendAs: [
|
|
341
|
+
{ sendAsEmail: me.email, displayName: me.name, isPrimary: true, isDefault: true },
|
|
342
|
+
...sendAs.map((a) => ({ ...a, isPrimary: false, isDefault: false, verificationStatus: "accepted" })),
|
|
343
|
+
// One still waiting for its verification: never offered.
|
|
344
|
+
{ sendAsEmail: `pending-${me.email}`, displayName: "", isPrimary: false, verificationStatus: "pending" },
|
|
345
|
+
],
|
|
346
|
+
}),
|
|
347
|
+
),
|
|
348
|
+
)
|
|
349
|
+
// Filters (users.settings.filters): listed with any read scope, made and deleted with gmail.settings.basic (as the
|
|
350
|
+
// real API). A filter needs a criterion and an action; one that forwards needs gmail.settings.sharing.
|
|
351
|
+
const GMAIL_SETTINGS = ["gmail.settings.basic", "https://mail.google.com/"]
|
|
352
|
+
const filters = new Map<string, { id: string; criteria: Record<string, unknown>; action: Record<string, unknown> }>()
|
|
353
|
+
const filterNotFound = () =>
|
|
354
|
+
googleError(404, "NOT_FOUND", "Filter not found", [
|
|
355
|
+
{ message: "Filter not found", domain: "global", reason: "notFound" },
|
|
356
|
+
])
|
|
357
|
+
router.add(
|
|
358
|
+
"GET",
|
|
359
|
+
"/gmail/v1/users/me/settings/filters",
|
|
360
|
+
api("gmail.googleapis.com", [...GMAIL_READ, ...GMAIL_SETTINGS], () =>
|
|
361
|
+
// An account with no filters answers `{}` (as the real API).
|
|
362
|
+
json(200, filters.size === 0 ? {} : { filter: [...filters.values()] }),
|
|
363
|
+
),
|
|
364
|
+
)
|
|
365
|
+
router.add(
|
|
366
|
+
"GET",
|
|
367
|
+
"/gmail/v1/users/me/settings/filters/:id",
|
|
368
|
+
api("gmail.googleapis.com", [...GMAIL_READ, ...GMAIL_SETTINGS], (request) => {
|
|
369
|
+
const found = filters.get(request.params["id"]!)
|
|
370
|
+
return found === undefined ? filterNotFound() : json(200, found)
|
|
371
|
+
}),
|
|
372
|
+
)
|
|
373
|
+
router.add(
|
|
374
|
+
"POST",
|
|
375
|
+
"/gmail/v1/users/me/settings/filters",
|
|
376
|
+
api("gmail.googleapis.com", GMAIL_SETTINGS, (request) => {
|
|
377
|
+
const body = (request.json ?? {}) as { criteria?: Record<string, unknown>; action?: Record<string, unknown> }
|
|
378
|
+
const criteria = body.criteria ?? {}
|
|
379
|
+
const action = body.action ?? {}
|
|
380
|
+
if (Object.keys(criteria).length === 0) {
|
|
381
|
+
return googleError(400, "FAILED_PRECONDITION", "Filter doesn't have any criteria", [
|
|
382
|
+
{ message: "Filter doesn't have any criteria", domain: "global", reason: "failedPrecondition" },
|
|
383
|
+
])
|
|
384
|
+
}
|
|
385
|
+
if (Object.keys(action).length === 0) {
|
|
386
|
+
return googleError(400, "FAILED_PRECONDITION", "Filter doesn't have any actions", [
|
|
387
|
+
{ message: "Filter doesn't have any actions", domain: "global", reason: "failedPrecondition" },
|
|
388
|
+
])
|
|
389
|
+
}
|
|
390
|
+
const made = { id: `ANe1Bm${randomBytes(12).toString("hex")}`, criteria, action }
|
|
391
|
+
filters.set(made.id, made)
|
|
392
|
+
return json(200, made)
|
|
393
|
+
}),
|
|
394
|
+
)
|
|
395
|
+
router.add(
|
|
396
|
+
"DELETE",
|
|
397
|
+
"/gmail/v1/users/me/settings/filters/:id",
|
|
398
|
+
api("gmail.googleapis.com", GMAIL_SETTINGS, (request) =>
|
|
399
|
+
filters.delete(request.params["id"]!) ? { status: 204 } : filterNotFound(),
|
|
400
|
+
),
|
|
401
|
+
)
|
|
402
|
+
router.add(
|
|
403
|
+
"GET",
|
|
404
|
+
"/gmail/v1/users/me/labels",
|
|
405
|
+
api("gmail.googleapis.com", GMAIL_READ, () =>
|
|
406
|
+
json(200, { labels: SYSTEM_LABELS.map((label) => ({ id: label, name: label, type: "system" })) }),
|
|
407
|
+
),
|
|
408
|
+
)
|
|
409
|
+
router.add(
|
|
410
|
+
"GET",
|
|
411
|
+
"/gmail/v1/users/me/profile",
|
|
412
|
+
api("gmail.googleapis.com", GMAIL_READ, (_r, me) =>
|
|
413
|
+
json(200, {
|
|
414
|
+
emailAddress: me.email,
|
|
415
|
+
messagesTotal: messages.items.size,
|
|
416
|
+
threadsTotal: messages.items.size,
|
|
417
|
+
historyId: String(clock.seq),
|
|
418
|
+
}),
|
|
419
|
+
),
|
|
420
|
+
)
|
|
421
|
+
router.add(
|
|
422
|
+
"GET",
|
|
423
|
+
"/gmail/v1/users/me/messages",
|
|
424
|
+
api("gmail.googleapis.com", GMAIL_READ, (request) => {
|
|
425
|
+
const labels = request.url.searchParams.getAll("labelIds")
|
|
426
|
+
const includeSpamTrash = request.url.searchParams.get("includeSpamTrash") === "true"
|
|
427
|
+
// Search: only `rfc822msgid:<id>` (Gmail's own Message-ID, never one the sender set), and only once the
|
|
428
|
+
// message is indexed. Any other query is refused rather than answered differently from Gmail.
|
|
429
|
+
const q = request.url.searchParams.get("q")
|
|
430
|
+
const byMessageId = q === null ? undefined : /^rfc822msgid:(\S+)$/u.exec(q)?.[1]
|
|
431
|
+
if (q !== null && byMessageId === undefined)
|
|
432
|
+
return googleError(400, "INVALID_ARGUMENT", `The fake does not implement the search ${JSON.stringify(q)}`, [
|
|
433
|
+
{ domain: "global", reason: "invalidArgument" },
|
|
434
|
+
])
|
|
435
|
+
const indexedBefore = Date.now() - searchIndexDelayMs
|
|
436
|
+
const all = [...messages.items.values()]
|
|
437
|
+
.filter((m) => byMessageId === undefined || (m.messageId === byMessageId && m.internalDate <= indexedBefore))
|
|
438
|
+
.filter((m) => labels.every((l) => m.labelIds.includes(l)))
|
|
439
|
+
.filter((m) => includeSpamTrash || (!m.labelIds.includes("TRASH") && !m.labelIds.includes("SPAM")))
|
|
440
|
+
.sort((a, b) => b.internalDate - a.internalDate || (a.id < b.id ? 1 : -1))
|
|
441
|
+
const max = Math.min(500, Number(request.url.searchParams.get("maxResults") ?? 100))
|
|
442
|
+
const offset = Number(decodeToken(request.url.searchParams.get("pageToken") ?? "") ?? 0)
|
|
443
|
+
const page = all.slice(offset, offset + max)
|
|
444
|
+
return json(200, {
|
|
445
|
+
...(page.length === 0 ? {} : { messages: page.map((m) => ({ id: m.id, threadId: m.threadId })) }),
|
|
446
|
+
...(offset + max < all.length ? { nextPageToken: encodeToken(offset + max) } : {}),
|
|
447
|
+
resultSizeEstimate: all.length,
|
|
448
|
+
})
|
|
449
|
+
}),
|
|
450
|
+
)
|
|
451
|
+
router.add(
|
|
452
|
+
"GET",
|
|
453
|
+
"/gmail/v1/users/me/messages/:id",
|
|
454
|
+
api("gmail.googleapis.com", GMAIL_READ, (request) => {
|
|
455
|
+
const invalid = invalidId(request.params["id"]!)
|
|
456
|
+
if (invalid !== undefined) return invalid
|
|
457
|
+
if (failingReads.has(request.params["id"]!)) {
|
|
458
|
+
return googleError(500, "INTERNAL", "Internal error encountered.", [
|
|
459
|
+
{ domain: "global", reason: "backendError" },
|
|
460
|
+
])
|
|
461
|
+
}
|
|
462
|
+
const found = messages.items.get(request.params["id"]!)
|
|
463
|
+
return found === undefined
|
|
464
|
+
? notFound()
|
|
465
|
+
: json(
|
|
466
|
+
200,
|
|
467
|
+
renderMessage(
|
|
468
|
+
found,
|
|
469
|
+
request.url.searchParams.get("format") ?? "full",
|
|
470
|
+
request.url.searchParams.getAll("metadataHeaders"),
|
|
471
|
+
),
|
|
472
|
+
)
|
|
473
|
+
}),
|
|
474
|
+
)
|
|
475
|
+
router.add(
|
|
476
|
+
"POST",
|
|
477
|
+
"/gmail/v1/users/me/messages/:id/modify",
|
|
478
|
+
api("gmail.googleapis.com", GMAIL_MODIFY, (request) => {
|
|
479
|
+
const invalid = invalidId(request.params["id"]!)
|
|
480
|
+
if (invalid !== undefined) return invalid
|
|
481
|
+
const body = (request.json ?? {}) as { addLabelIds?: Array<string>; removeLabelIds?: Array<string> }
|
|
482
|
+
const updated = messages.update(request.params["id"]!, (m) => ({
|
|
483
|
+
...m,
|
|
484
|
+
labelIds: [
|
|
485
|
+
...new Set([
|
|
486
|
+
...m.labelIds.filter((l) => !(body.removeLabelIds ?? []).includes(l)),
|
|
487
|
+
...(body.addLabelIds ?? []),
|
|
488
|
+
]),
|
|
489
|
+
],
|
|
490
|
+
}))
|
|
491
|
+
return updated === undefined
|
|
492
|
+
? notFound()
|
|
493
|
+
: json(200, { id: updated.id, threadId: updated.threadId, labelIds: updated.labelIds })
|
|
494
|
+
}),
|
|
495
|
+
)
|
|
496
|
+
router.add(
|
|
497
|
+
"POST",
|
|
498
|
+
"/gmail/v1/users/me/messages/:id/trash",
|
|
499
|
+
api("gmail.googleapis.com", GMAIL_MODIFY, (request) => {
|
|
500
|
+
const invalid = invalidId(request.params["id"]!)
|
|
501
|
+
if (invalid !== undefined) return invalid
|
|
502
|
+
const updated = messages.update(request.params["id"]!, (m) => ({
|
|
503
|
+
...m,
|
|
504
|
+
labelIds: [...new Set([...m.labelIds, "TRASH"])],
|
|
505
|
+
}))
|
|
506
|
+
return updated === undefined
|
|
507
|
+
? notFound()
|
|
508
|
+
: json(200, { id: updated.id, threadId: updated.threadId, labelIds: updated.labelIds })
|
|
509
|
+
}),
|
|
510
|
+
)
|
|
511
|
+
router.add(
|
|
512
|
+
"POST",
|
|
513
|
+
"/gmail/v1/users/me/messages/send",
|
|
514
|
+
api("gmail.googleapis.com", GMAIL_SEND, (request, me) => {
|
|
515
|
+
const raw = (request.json as { raw?: string } | undefined)?.raw
|
|
516
|
+
if (raw === undefined)
|
|
517
|
+
return googleError(
|
|
518
|
+
400,
|
|
519
|
+
"INVALID_ARGUMENT",
|
|
520
|
+
"'raw' RFC822 payload message string or uploading message via /upload/* URL required",
|
|
521
|
+
[{ domain: "global", reason: "invalidArgument" }],
|
|
522
|
+
)
|
|
523
|
+
const { from: asked, ...parsed } = parseRaw(raw)
|
|
524
|
+
const toSelf = `${parsed.to},${parsed.cc}`.toLowerCase().includes(me.email.toLowerCase())
|
|
525
|
+
// As Gmail does: a From that is not one of the account's verified send-as addresses becomes the primary one.
|
|
526
|
+
const askedAddress = /<([^>]+)>/u.exec(asked)?.[1] ?? asked
|
|
527
|
+
const allowed = sendAs.some((a) => a.sendAsEmail.toLowerCase() === askedAddress.toLowerCase())
|
|
528
|
+
const sent = messages.put({
|
|
529
|
+
id: id(),
|
|
530
|
+
threadId: id(),
|
|
531
|
+
labelIds: toSelf ? ["SENT", "INBOX", "UNREAD"] : ["SENT"],
|
|
532
|
+
from: asked !== "" && allowed ? asked : `${me.name} <${me.email}>`,
|
|
533
|
+
...parsed,
|
|
534
|
+
// Gmail's own, whatever the sender set.
|
|
535
|
+
messageId: `<${id()}@mail.gmail.com>`,
|
|
536
|
+
internalDate: Date.now(),
|
|
537
|
+
})
|
|
538
|
+
return json(200, { id: sent.id, threadId: sent.threadId, labelIds: sent.labelIds })
|
|
539
|
+
}),
|
|
540
|
+
)
|
|
541
|
+
router.add(
|
|
542
|
+
"POST",
|
|
543
|
+
"/gmail/v1/users/me/drafts",
|
|
544
|
+
api("gmail.googleapis.com", GMAIL_COMPOSE, (request, me) => {
|
|
545
|
+
const raw = (request.json as { message?: { raw?: string } } | undefined)?.message?.raw
|
|
546
|
+
if (raw === undefined)
|
|
547
|
+
return googleError(400, "INVALID_ARGUMENT", "Missing draft message", [
|
|
548
|
+
{ domain: "global", reason: "invalidArgument" },
|
|
549
|
+
])
|
|
550
|
+
const draft = messages.put({
|
|
551
|
+
id: id(),
|
|
552
|
+
threadId: id(),
|
|
553
|
+
labelIds: ["DRAFT"],
|
|
554
|
+
...parseRaw(raw),
|
|
555
|
+
from: me.email,
|
|
556
|
+
internalDate: Date.now(),
|
|
557
|
+
})
|
|
558
|
+
return json(200, { id: id("r-"), message: { id: draft.id, threadId: draft.threadId, labelIds: draft.labelIds } })
|
|
559
|
+
}),
|
|
560
|
+
)
|
|
561
|
+
router.add(
|
|
562
|
+
"GET",
|
|
563
|
+
"/gmail/v1/users/me/history",
|
|
564
|
+
api("gmail.googleapis.com", GMAIL_READ, (request) => {
|
|
565
|
+
const start = Number(request.url.searchParams.get("startHistoryId") ?? "NaN")
|
|
566
|
+
if (!Number.isInteger(start))
|
|
567
|
+
return googleError(400, "INVALID_ARGUMENT", "Invalid startHistoryId", [
|
|
568
|
+
{ domain: "global", reason: "invalidArgument" },
|
|
569
|
+
])
|
|
570
|
+
// Older than the retained history, or newer than the mailbox: both 404 (seen from the real API).
|
|
571
|
+
if (start < historyFloor() || start > clock.seq) return notFound()
|
|
572
|
+
const max = Math.min(500, Number(request.url.searchParams.get("maxResults") ?? 100))
|
|
573
|
+
const offset = Number(decodeToken(request.url.searchParams.get("pageToken") ?? "") ?? 0)
|
|
574
|
+
// `historyTypes` (repeated): only those change types; all four when absent.
|
|
575
|
+
const types = request.url.searchParams.getAll("historyTypes")
|
|
576
|
+
const wanted = (type: string) => types.length === 0 || types.includes(type)
|
|
577
|
+
// `labelId`: only messages with that label (as they are after the change; before it for a deletion).
|
|
578
|
+
const labelId = request.url.searchParams.get("labelId")
|
|
579
|
+
// As documented: "Any messages contained in the response will typically only have id and threadId fields
|
|
580
|
+
// populated." Labels a record adds or removes are reported beside the message, never on it.
|
|
581
|
+
const ref = (m: GmailMessage) => ({ id: m.id, threadId: m.threadId })
|
|
582
|
+
const records = messages.log
|
|
583
|
+
.filter((entry) => entry.seq > start)
|
|
584
|
+
.filter((entry) => labelId === null || (entry.after ?? entry.before)!.labelIds.includes(labelId))
|
|
585
|
+
.flatMap((entry) => {
|
|
586
|
+
const record: Record<string, unknown> = {
|
|
587
|
+
id: String(entry.seq),
|
|
588
|
+
messages: [ref((entry.after ?? entry.before)!)],
|
|
589
|
+
}
|
|
590
|
+
if (entry.before === undefined) {
|
|
591
|
+
if (wanted("messageAdded")) record["messagesAdded"] = [{ message: ref(entry.after!) }]
|
|
592
|
+
} else if (entry.after === undefined) {
|
|
593
|
+
if (wanted("messageDeleted")) record["messagesDeleted"] = [{ message: ref(entry.before) }]
|
|
594
|
+
} else {
|
|
595
|
+
const added = entry.after.labelIds.filter((l) => !entry.before!.labelIds.includes(l))
|
|
596
|
+
const removed = entry.before.labelIds.filter((l) => !entry.after!.labelIds.includes(l))
|
|
597
|
+
if (added.length > 0 && wanted("labelAdded"))
|
|
598
|
+
record["labelsAdded"] = [{ message: ref(entry.after), labelIds: added }]
|
|
599
|
+
if (removed.length > 0 && wanted("labelRemoved"))
|
|
600
|
+
record["labelsRemoved"] = [{ message: ref(entry.after), labelIds: removed }]
|
|
601
|
+
}
|
|
602
|
+
return Object.keys(record).length > 2 ? [record] : []
|
|
603
|
+
})
|
|
604
|
+
const page = records.slice(offset, offset + max)
|
|
605
|
+
return json(200, {
|
|
606
|
+
...(page.length === 0 ? {} : { history: page }),
|
|
607
|
+
...(offset + max < records.length ? { nextPageToken: encodeToken(offset + max) } : {}),
|
|
608
|
+
historyId: String(clock.seq),
|
|
609
|
+
})
|
|
610
|
+
}),
|
|
611
|
+
)
|
|
612
|
+
|
|
613
|
+
// ---- Calendar v3
|
|
614
|
+
const CAL_READ = ["calendar.readonly", "calendar", "calendar.events", "calendar.events.readonly"]
|
|
615
|
+
const CAL_WRITE = ["calendar", "calendar.events"]
|
|
616
|
+
const eventTime = (value: string) =>
|
|
617
|
+
/^\d{4}-\d{2}-\d{2}$/u.test(value) ? { date: value } : { dateTime: value, timeZone: "UTC" }
|
|
618
|
+
const renderEvent = (e: GoogleEvent) => ({
|
|
619
|
+
kind: "calendar#event",
|
|
620
|
+
etag: `"${Date.parse(e.updated)}"`,
|
|
621
|
+
id: e.id,
|
|
622
|
+
status: e.status,
|
|
623
|
+
htmlLink: `https://www.google.com/calendar/event?eid=${e.id}`,
|
|
624
|
+
updated: e.updated,
|
|
625
|
+
summary: e.summary,
|
|
626
|
+
...(e.description === null ? {} : { description: e.description }),
|
|
627
|
+
...(e.location === null ? {} : { location: e.location }),
|
|
628
|
+
creator: { email: e.organizer, ...(e.organizer === e.calendarId ? { self: true } : {}) },
|
|
629
|
+
organizer: { email: e.organizer, ...(e.organizer === e.calendarId ? { self: true } : {}) },
|
|
630
|
+
start: eventTime(e.start),
|
|
631
|
+
end: eventTime(e.end),
|
|
632
|
+
// The calendar owner's own entry says so (`self`), as Google marks it.
|
|
633
|
+
...(e.attendees.length === 0
|
|
634
|
+
? {}
|
|
635
|
+
: {
|
|
636
|
+
attendees: e.attendees.map(({ self: own, ...a }) =>
|
|
637
|
+
own === true || (own === undefined && a.email === e.calendarId) ? { ...a, self: true } : a,
|
|
638
|
+
),
|
|
639
|
+
}),
|
|
640
|
+
})
|
|
641
|
+
const instant = (value: string) => Date.parse(value)
|
|
642
|
+
router.add(
|
|
643
|
+
"GET",
|
|
644
|
+
"/calendar/v3/users/me/calendarList",
|
|
645
|
+
api("calendar-json.googleapis.com", CAL_READ, (_r, me) =>
|
|
646
|
+
json(200, {
|
|
647
|
+
kind: "calendar#calendarList",
|
|
648
|
+
items: [
|
|
649
|
+
{
|
|
650
|
+
kind: "calendar#calendarListEntry",
|
|
651
|
+
id: me.email,
|
|
652
|
+
summary: me.email,
|
|
653
|
+
primary: true,
|
|
654
|
+
accessRole: "owner",
|
|
655
|
+
timeZone: "UTC",
|
|
656
|
+
},
|
|
657
|
+
],
|
|
658
|
+
}),
|
|
659
|
+
),
|
|
660
|
+
)
|
|
661
|
+
const calendarOf = (requested: string, me: Me) => (requested === "primary" ? me.email : requested)
|
|
662
|
+
/** Other people's busy time as freeBusy shares it with the account (`calendar.schedule`), by address. */
|
|
663
|
+
const busyOf = new Map<string, ReadonlyArray<{ start: string; end: string }>>()
|
|
664
|
+
router.add(
|
|
665
|
+
"POST",
|
|
666
|
+
"/calendar/v3/freeBusy",
|
|
667
|
+
api("calendar-json.googleapis.com", CAL_READ, (request, me) => {
|
|
668
|
+
const body = (request.json ?? {}) as { timeMin?: string; timeMax?: string; items?: ReadonlyArray<{ id: string }> }
|
|
669
|
+
const min = Date.parse(body.timeMin ?? "")
|
|
670
|
+
const max = Date.parse(body.timeMax ?? "")
|
|
671
|
+
if (Number.isNaN(min) || Number.isNaN(max)) {
|
|
672
|
+
return googleError(400, "INVALID_ARGUMENT", "Missing timeMin or timeMax.", [
|
|
673
|
+
{ domain: "global", reason: "required" },
|
|
674
|
+
])
|
|
675
|
+
}
|
|
676
|
+
const within = (b: { start: string; end: string }) => Date.parse(b.start) < max && Date.parse(b.end) > min
|
|
677
|
+
const own = () =>
|
|
678
|
+
[...events.items.values()]
|
|
679
|
+
.filter((e) => e.status !== "cancelled" && within(e))
|
|
680
|
+
.filter((e) => {
|
|
681
|
+
const mine = e.attendees.find((a) => a.self === true || a.email === me.email)
|
|
682
|
+
return mine?.responseStatus !== "declined"
|
|
683
|
+
})
|
|
684
|
+
.map((e) => ({ start: e.start, end: e.end }))
|
|
685
|
+
return json(200, {
|
|
686
|
+
kind: "calendar#freeBusy",
|
|
687
|
+
timeMin: new Date(min).toISOString(),
|
|
688
|
+
timeMax: new Date(max).toISOString(),
|
|
689
|
+
calendars: Object.fromEntries(
|
|
690
|
+
(body.items ?? []).map(({ id }) => {
|
|
691
|
+
if (id === me.email) return [id, { busy: own() }]
|
|
692
|
+
const known = busyOf.get(id.toLowerCase())
|
|
693
|
+
return [
|
|
694
|
+
id,
|
|
695
|
+
known === undefined
|
|
696
|
+
? { errors: [{ domain: "global", reason: "notFound" }], busy: [] }
|
|
697
|
+
: { busy: known.filter(within) },
|
|
698
|
+
]
|
|
699
|
+
}),
|
|
700
|
+
),
|
|
701
|
+
})
|
|
702
|
+
}),
|
|
703
|
+
)
|
|
704
|
+
router.add(
|
|
705
|
+
"GET",
|
|
706
|
+
"/calendar/v3/calendars/:cid/events",
|
|
707
|
+
api("calendar-json.googleapis.com", CAL_READ, (request, me) => {
|
|
708
|
+
const calendar = calendarOf(request.params["cid"]!, me)
|
|
709
|
+
if (calendar !== PRIMARY) return calendarNotFound()
|
|
710
|
+
const q = request.url.searchParams
|
|
711
|
+
const max = Math.min(2500, Number(q.get("maxResults") ?? 250))
|
|
712
|
+
const syncText = q.get("syncToken")
|
|
713
|
+
const page = decodeToken(q.get("pageToken") ?? "") as
|
|
714
|
+
| { seq: number; offset: number; sync: boolean; min?: number; max?: number }
|
|
715
|
+
| undefined
|
|
716
|
+
let state = page
|
|
717
|
+
if (syncText !== null) {
|
|
718
|
+
if (q.get("timeMin") !== null || q.get("timeMax") !== null) {
|
|
719
|
+
return legacyError(400, "Sync token cannot be used with other query parameters", { reason: "invalid" })
|
|
720
|
+
}
|
|
721
|
+
const token = decodeToken(syncText) as { seq: number } | undefined
|
|
722
|
+
// A token Calendar never issued is 400 `invalid` (seen from the real API); one it issued and no longer
|
|
723
|
+
// honours is 410 `fullSyncRequired`.
|
|
724
|
+
if (token === undefined || typeof token.seq !== "number") {
|
|
725
|
+
return legacyError(400, "Invalid sync token value.", { reason: "invalid" })
|
|
726
|
+
}
|
|
727
|
+
if (token.seq < minSeq.calendar) {
|
|
728
|
+
return legacyError(410, "Sync token is no longer valid, a full sync is required.", {
|
|
729
|
+
reason: "fullSyncRequired",
|
|
730
|
+
})
|
|
731
|
+
}
|
|
732
|
+
state ??= { seq: token.seq, offset: 0, sync: true }
|
|
733
|
+
}
|
|
734
|
+
const until = clock.seq
|
|
735
|
+
if (state?.sync === true) {
|
|
736
|
+
const changes = events.changesSince(state.seq, () => true, Number.POSITIVE_INFINITY)
|
|
737
|
+
const slice = changes.slice(state.offset, state.offset + max)
|
|
738
|
+
const more = state.offset + max < changes.length
|
|
739
|
+
return json(200, {
|
|
740
|
+
kind: "calendar#events",
|
|
741
|
+
// A cancelled (deleted) event is "only guaranteed to have the id field populated": render no more.
|
|
742
|
+
items: slice.map((c) =>
|
|
743
|
+
c.item === undefined || c.item.status === "cancelled"
|
|
744
|
+
? { kind: "calendar#event", etag: `"${clock.seq}"`, id: c.id, status: "cancelled" }
|
|
745
|
+
: renderEvent(c.item),
|
|
746
|
+
),
|
|
747
|
+
...(more
|
|
748
|
+
? { nextPageToken: encodeToken({ ...state, offset: state.offset + max }) }
|
|
749
|
+
: { nextSyncToken: encodeToken({ seq: until }) }),
|
|
750
|
+
})
|
|
751
|
+
}
|
|
752
|
+
const min = q.get("timeMin") === null ? undefined : instant(q.get("timeMin")!)
|
|
753
|
+
const maxTime = q.get("timeMax") === null ? undefined : instant(q.get("timeMax")!)
|
|
754
|
+
const showDeleted = q.get("showDeleted") === "true"
|
|
755
|
+
const all = [...events.items.values()]
|
|
756
|
+
.filter((e) => showDeleted || e.status !== "cancelled")
|
|
757
|
+
.filter(
|
|
758
|
+
(e) => (min === undefined || instant(e.end) > min) && (maxTime === undefined || instant(e.start) < maxTime),
|
|
759
|
+
)
|
|
760
|
+
.sort((a, b) => instant(a.start) - instant(b.start) || (a.id < b.id ? -1 : 1))
|
|
761
|
+
const offset = state?.offset ?? 0
|
|
762
|
+
const startSeq = state?.seq ?? until
|
|
763
|
+
const slice = all.slice(offset, offset + max)
|
|
764
|
+
return json(200, {
|
|
765
|
+
kind: "calendar#events",
|
|
766
|
+
items: slice.map(renderEvent),
|
|
767
|
+
...(offset + max < all.length
|
|
768
|
+
? { nextPageToken: encodeToken({ seq: startSeq, offset: offset + max, sync: false }) }
|
|
769
|
+
: { nextSyncToken: encodeToken({ seq: startSeq }) }),
|
|
770
|
+
})
|
|
771
|
+
}),
|
|
772
|
+
)
|
|
773
|
+
router.add(
|
|
774
|
+
"GET",
|
|
775
|
+
"/calendar/v3/calendars/:cid/events/:id",
|
|
776
|
+
api("calendar-json.googleapis.com", CAL_READ, (request) => {
|
|
777
|
+
const found = events.items.get(request.params["id"]!)
|
|
778
|
+
return found === undefined ? calendarNotFound() : json(200, renderEvent(found))
|
|
779
|
+
}),
|
|
780
|
+
)
|
|
781
|
+
const timeOf = (value: any) => String(value?.dateTime ?? value?.date ?? "")
|
|
782
|
+
router.add(
|
|
783
|
+
"POST",
|
|
784
|
+
"/calendar/v3/calendars/:cid/events",
|
|
785
|
+
api("calendar-json.googleapis.com", CAL_WRITE, (request, me) => {
|
|
786
|
+
const body = (request.json ?? {}) as Record<string, any>
|
|
787
|
+
if (timeOf(body["start"]) === "" || timeOf(body["end"]) === "") {
|
|
788
|
+
return googleError(400, "INVALID_ARGUMENT", "Missing end time.", [{ domain: "global", reason: "required" }])
|
|
789
|
+
}
|
|
790
|
+
const event = events.put({
|
|
791
|
+
id: id("evt"),
|
|
792
|
+
calendarId: calendarOf(request.params["cid"]!, me),
|
|
793
|
+
status: "confirmed",
|
|
794
|
+
summary: String(body["summary"] ?? ""),
|
|
795
|
+
description: body["description"] ?? null,
|
|
796
|
+
location: body["location"] ?? null,
|
|
797
|
+
start: body["start"]?.dateTime ? new Date(body["start"].dateTime).toISOString() : timeOf(body["start"]),
|
|
798
|
+
end: body["end"]?.dateTime ? new Date(body["end"].dateTime).toISOString() : timeOf(body["end"]),
|
|
799
|
+
attendees: ((body["attendees"] ?? []) as Array<{ email: string }>).map((a) => ({
|
|
800
|
+
email: a.email,
|
|
801
|
+
responseStatus: "needsAction",
|
|
802
|
+
})),
|
|
803
|
+
organizer: me.email,
|
|
804
|
+
updated: now(),
|
|
805
|
+
})
|
|
806
|
+
return json(200, renderEvent(event))
|
|
807
|
+
}),
|
|
808
|
+
)
|
|
809
|
+
router.add(
|
|
810
|
+
"PATCH",
|
|
811
|
+
"/calendar/v3/calendars/:cid/events/:id",
|
|
812
|
+
api("calendar-json.googleapis.com", CAL_WRITE, (request) => {
|
|
813
|
+
const body = (request.json ?? {}) as Record<string, any>
|
|
814
|
+
const current = events.items.get(request.params["id"]!)
|
|
815
|
+
if (current === undefined || current.status === "cancelled") return calendarNotFound()
|
|
816
|
+
const updated = events.put({
|
|
817
|
+
...current,
|
|
818
|
+
...(body["summary"] === undefined ? {} : { summary: String(body["summary"]) }),
|
|
819
|
+
...(body["description"] === undefined ? {} : { description: body["description"] }),
|
|
820
|
+
...(body["location"] === undefined ? {} : { location: body["location"] }),
|
|
821
|
+
...(body["start"] === undefined ? {} : { start: new Date(timeOf(body["start"])).toISOString() }),
|
|
822
|
+
...(body["end"] === undefined ? {} : { end: new Date(timeOf(body["end"])).toISOString() }),
|
|
823
|
+
...(body["attendees"] === undefined
|
|
824
|
+
? {}
|
|
825
|
+
: {
|
|
826
|
+
// `self` is Google's to say (read-only): kept from the entry under the same address.
|
|
827
|
+
attendees: (body["attendees"] as ReadonlyArray<{ email: string; responseStatus?: string }>).map((a) => {
|
|
828
|
+
const own = current.attendees.find((c) => c.email === a.email)?.self
|
|
829
|
+
const entry: { email: string; responseStatus: string; self?: boolean } = {
|
|
830
|
+
email: a.email,
|
|
831
|
+
responseStatus: a.responseStatus ?? "needsAction",
|
|
832
|
+
}
|
|
833
|
+
if (own !== undefined) entry.self = own
|
|
834
|
+
return entry
|
|
835
|
+
}),
|
|
836
|
+
}),
|
|
837
|
+
updated: now(),
|
|
838
|
+
})
|
|
839
|
+
return json(200, renderEvent(updated))
|
|
840
|
+
}),
|
|
841
|
+
)
|
|
842
|
+
router.add(
|
|
843
|
+
"DELETE",
|
|
844
|
+
"/calendar/v3/calendars/:cid/events/:id",
|
|
845
|
+
api("calendar-json.googleapis.com", CAL_WRITE, (request) => {
|
|
846
|
+
const current = events.items.get(request.params["id"]!)
|
|
847
|
+
if (current === undefined || current.status === "cancelled") {
|
|
848
|
+
return legacyError(410, "Resource has been deleted", { reason: "deleted" })
|
|
849
|
+
}
|
|
850
|
+
events.put({ ...current, status: "cancelled", updated: now() })
|
|
851
|
+
return { status: 204 }
|
|
852
|
+
}),
|
|
853
|
+
)
|
|
854
|
+
|
|
855
|
+
// ---- Admin SDK Directory v1
|
|
856
|
+
const DIR_USERS = ["admin.directory.user.readonly", "admin.directory.user"]
|
|
857
|
+
const DIR_GROUPS = ["admin.directory.group.readonly", "admin.directory.group"]
|
|
858
|
+
/** The signed-in account is an administrator unless a test says otherwise. */
|
|
859
|
+
let administrator = true
|
|
860
|
+
const notAuthorized = () => legacyError(403, "Not Authorized to access this resource/api", { reason: "forbidden" })
|
|
861
|
+
const renderUser = (u: GoogleUser) => ({
|
|
862
|
+
kind: "admin#directory#user",
|
|
863
|
+
id: u.id,
|
|
864
|
+
etag: u.etag,
|
|
865
|
+
primaryEmail: u.primaryEmail,
|
|
866
|
+
name: { givenName: u.givenName, familyName: u.familyName, fullName: `${u.givenName} ${u.familyName}` },
|
|
867
|
+
isAdmin: false,
|
|
868
|
+
suspended: u.suspended,
|
|
869
|
+
orgUnitPath: "/",
|
|
870
|
+
...(u.title === null && u.department === null
|
|
871
|
+
? {}
|
|
872
|
+
: { organizations: [{ title: u.title, department: u.department, primary: true }] }),
|
|
873
|
+
})
|
|
874
|
+
router.add(
|
|
875
|
+
"GET",
|
|
876
|
+
"/admin/directory/v1/users",
|
|
877
|
+
api("admin.googleapis.com", DIR_USERS, (request) => {
|
|
878
|
+
if (!administrator) return notAuthorized()
|
|
879
|
+
if (
|
|
880
|
+
request.url.searchParams.get("customer") !== "my_customer" &&
|
|
881
|
+
request.url.searchParams.get("domain") === null
|
|
882
|
+
) {
|
|
883
|
+
return legacyError(400, "Bad Request", { reason: "badRequest" })
|
|
884
|
+
}
|
|
885
|
+
const all = [...users.items.values()].sort((a, b) => (a.primaryEmail < b.primaryEmail ? -1 : 1))
|
|
886
|
+
const max = Math.min(500, Number(request.url.searchParams.get("maxResults") ?? 100))
|
|
887
|
+
const offset = Number(decodeToken(request.url.searchParams.get("pageToken") ?? "") ?? 0)
|
|
888
|
+
const page = all.slice(offset, offset + max)
|
|
889
|
+
return json(200, {
|
|
890
|
+
kind: "admin#directory#users",
|
|
891
|
+
// Absent, not empty, when there are none.
|
|
892
|
+
...(page.length === 0 ? {} : { users: page.map(renderUser) }),
|
|
893
|
+
...(offset + max < all.length ? { nextPageToken: encodeToken(offset + max) } : {}),
|
|
894
|
+
})
|
|
895
|
+
}),
|
|
896
|
+
)
|
|
897
|
+
router.add(
|
|
898
|
+
"GET",
|
|
899
|
+
"/admin/directory/v1/users/:key",
|
|
900
|
+
api("admin.googleapis.com", DIR_USERS, (request) => {
|
|
901
|
+
if (!administrator) return notAuthorized()
|
|
902
|
+
const key = request.params["key"]!
|
|
903
|
+
const found = users.items.get(key) ?? [...users.items.values()].find((u) => u.primaryEmail === key)
|
|
904
|
+
return found === undefined
|
|
905
|
+
? legacyError(404, "Resource Not Found: userKey", { reason: "notFound" })
|
|
906
|
+
: json(200, renderUser(found))
|
|
907
|
+
}),
|
|
908
|
+
)
|
|
909
|
+
router.add(
|
|
910
|
+
"GET",
|
|
911
|
+
"/admin/directory/v1/groups",
|
|
912
|
+
api("admin.googleapis.com", DIR_GROUPS, () =>
|
|
913
|
+
administrator
|
|
914
|
+
? json(200, {
|
|
915
|
+
kind: "admin#directory#groups",
|
|
916
|
+
groups: [{ id: "grp1", email: "everyone@workspace.example", name: "Everyone", description: "All staff" }],
|
|
917
|
+
})
|
|
918
|
+
: notAuthorized(),
|
|
919
|
+
),
|
|
920
|
+
)
|
|
921
|
+
|
|
922
|
+
// ---- Drive v3
|
|
923
|
+
/**
|
|
924
|
+
* Drive v3 returns only the fields a request asks for (`fields`, Google's partial-response syntax:
|
|
925
|
+
* `a,b(c,d),e/f`), and by default only `kind`, `id`, `name` and `mimeType` of a file.
|
|
926
|
+
*/
|
|
927
|
+
type Mask = Map<string, Mask | true>
|
|
928
|
+
const parseFields = (text: string): Mask => {
|
|
929
|
+
let i = 0
|
|
930
|
+
// A list of selectors up to `)` or the end: `name`, `name(list)` or `name/selector`.
|
|
931
|
+
const list = (): Mask => {
|
|
932
|
+
const out: Mask = new Map()
|
|
933
|
+
while (i < text.length && text[i] !== ")") {
|
|
934
|
+
const [name, sub] = selector()
|
|
935
|
+
const existing = out.get(name)
|
|
936
|
+
out.set(
|
|
937
|
+
name,
|
|
938
|
+
existing === undefined || existing === true || sub === true ? sub : new Map([...existing, ...sub]),
|
|
939
|
+
)
|
|
940
|
+
if (text[i] === ",") i++
|
|
941
|
+
}
|
|
942
|
+
return out
|
|
943
|
+
}
|
|
944
|
+
const selector = (): [string, Mask | true] => {
|
|
945
|
+
let name = ""
|
|
946
|
+
while (i < text.length && !",()/".includes(text[i]!)) name += text[i++]
|
|
947
|
+
if (text[i] === "(") {
|
|
948
|
+
i++
|
|
949
|
+
const sub = list()
|
|
950
|
+
i++
|
|
951
|
+
return [name.trim(), sub]
|
|
952
|
+
}
|
|
953
|
+
if (text[i] === "/") {
|
|
954
|
+
i++
|
|
955
|
+
const [child, sub] = selector()
|
|
956
|
+
return [name.trim(), new Map([[child, sub]])]
|
|
957
|
+
}
|
|
958
|
+
return [name.trim(), true]
|
|
959
|
+
}
|
|
960
|
+
return list()
|
|
961
|
+
}
|
|
962
|
+
const project = (value: any, mask: Mask): any => {
|
|
963
|
+
if (Array.isArray(value)) return value.map((v) => project(v, mask))
|
|
964
|
+
if (value === null || typeof value !== "object") return value
|
|
965
|
+
const out: Record<string, unknown> = {}
|
|
966
|
+
for (const [key, sub] of mask) {
|
|
967
|
+
if (key === "*") return value
|
|
968
|
+
if (!(key in value)) continue
|
|
969
|
+
out[key] = sub === true ? value[key] : project(value[key], sub)
|
|
970
|
+
}
|
|
971
|
+
return out
|
|
972
|
+
}
|
|
973
|
+
const DEFAULT_FILE = "kind,id,name,mimeType"
|
|
974
|
+
const partial = (request: FakeRequest, body: Record<string, unknown>, defaults: string) =>
|
|
975
|
+
json(200, project(body, parseFields(request.url.searchParams.get("fields") ?? defaults)))
|
|
976
|
+
const DRIVE_READ = ["drive.readonly", "drive", "drive.file", "drive.metadata.readonly"]
|
|
977
|
+
const ROOT = "0AROOT"
|
|
978
|
+
/**
|
|
979
|
+
* Drive's processing after an upload. The real Drive reports one or two more changes of an uploaded file
|
|
980
|
+
* seconds later, with nothing a client changed (its `version` and thumbnail move on), so a delta's cursor taken
|
|
981
|
+
* right after an upload is followed by them. Here, deterministically: an upload's processing change is made
|
|
982
|
+
* just after Drive answers its next request (or when a test settles the fake).
|
|
983
|
+
*/
|
|
984
|
+
const processing = new Set<string>()
|
|
985
|
+
const processPending = () => {
|
|
986
|
+
for (const fileId of processing) files.update(fileId, (f) => ({ ...f, version: f.version + 1 }))
|
|
987
|
+
processing.clear()
|
|
988
|
+
}
|
|
989
|
+
const drive =
|
|
990
|
+
(handler: (request: FakeRequest) => FakeResponse) =>
|
|
991
|
+
(request: FakeRequest): FakeResponse => {
|
|
992
|
+
const response = handler(request)
|
|
993
|
+
processPending()
|
|
994
|
+
return response
|
|
995
|
+
}
|
|
996
|
+
const renderFile = (f: DriveFile) => ({
|
|
997
|
+
kind: "drive#file",
|
|
998
|
+
id: f.id,
|
|
999
|
+
name: f.name,
|
|
1000
|
+
mimeType: f.mimeType,
|
|
1001
|
+
parents: [f.parent],
|
|
1002
|
+
trashed: f.trashed,
|
|
1003
|
+
modifiedTime: f.modifiedTime,
|
|
1004
|
+
version: String(f.version),
|
|
1005
|
+
webViewLink: `https://drive.google.com/file/d/${f.id}/view`,
|
|
1006
|
+
...(f.mimeType === "application/vnd.google-apps.folder" ? {} : { size: String(Buffer.byteLength(f.content)) }),
|
|
1007
|
+
})
|
|
1008
|
+
router.add(
|
|
1009
|
+
"GET",
|
|
1010
|
+
"/drive/v3/files",
|
|
1011
|
+
api(
|
|
1012
|
+
"drive.googleapis.com",
|
|
1013
|
+
DRIVE_READ,
|
|
1014
|
+
drive((request) => {
|
|
1015
|
+
const q = request.url.searchParams.get("q") ?? ""
|
|
1016
|
+
const parent = /'([^']+)' in parents/u.exec(q)?.[1]
|
|
1017
|
+
const parentId = parent === "root" ? ROOT : parent
|
|
1018
|
+
const excludeTrashed = /trashed\s*=\s*false/u.test(q)
|
|
1019
|
+
const all = [...files.items.values()]
|
|
1020
|
+
.filter((f) => parentId === undefined || f.parent === parentId)
|
|
1021
|
+
.filter((f) => !excludeTrashed || !f.trashed)
|
|
1022
|
+
.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : a.id < b.id ? -1 : 1))
|
|
1023
|
+
const size = Math.min(1000, Number(request.url.searchParams.get("pageSize") ?? 100))
|
|
1024
|
+
const offset = Number(decodeToken(request.url.searchParams.get("pageToken") ?? "") ?? 0)
|
|
1025
|
+
return partial(
|
|
1026
|
+
request,
|
|
1027
|
+
{
|
|
1028
|
+
kind: "drive#fileList",
|
|
1029
|
+
files: all.slice(offset, offset + size).map(renderFile),
|
|
1030
|
+
incompleteSearch: false,
|
|
1031
|
+
...(offset + size < all.length ? { nextPageToken: encodeToken(offset + size) } : {}),
|
|
1032
|
+
},
|
|
1033
|
+
`kind,nextPageToken,incompleteSearch,files(${DEFAULT_FILE})`,
|
|
1034
|
+
)
|
|
1035
|
+
}),
|
|
1036
|
+
),
|
|
1037
|
+
)
|
|
1038
|
+
router.add(
|
|
1039
|
+
"GET",
|
|
1040
|
+
"/drive/v3/files/:id",
|
|
1041
|
+
api(
|
|
1042
|
+
"drive.googleapis.com",
|
|
1043
|
+
DRIVE_READ,
|
|
1044
|
+
drive((request) => {
|
|
1045
|
+
const found = files.items.get(request.params["id"]!)
|
|
1046
|
+
if (found === undefined) {
|
|
1047
|
+
return legacyError(404, `File not found: ${request.params["id"]}.`, {
|
|
1048
|
+
reason: "notFound",
|
|
1049
|
+
location: "fileId",
|
|
1050
|
+
locationType: "parameter",
|
|
1051
|
+
})
|
|
1052
|
+
}
|
|
1053
|
+
if (request.url.searchParams.get("alt") === "media") {
|
|
1054
|
+
return { status: 200, headers: { "content-type": found.mimeType }, body: found.content }
|
|
1055
|
+
}
|
|
1056
|
+
return partial(request, renderFile(found), DEFAULT_FILE)
|
|
1057
|
+
}),
|
|
1058
|
+
),
|
|
1059
|
+
)
|
|
1060
|
+
router.add(
|
|
1061
|
+
"GET",
|
|
1062
|
+
"/drive/v3/changes/startPageToken",
|
|
1063
|
+
api(
|
|
1064
|
+
"drive.googleapis.com",
|
|
1065
|
+
DRIVE_READ,
|
|
1066
|
+
drive(() => json(200, { kind: "drive#startPageToken", startPageToken: String(clock.seq) })),
|
|
1067
|
+
),
|
|
1068
|
+
)
|
|
1069
|
+
router.add(
|
|
1070
|
+
"GET",
|
|
1071
|
+
"/drive/v3/changes",
|
|
1072
|
+
api(
|
|
1073
|
+
"drive.googleapis.com",
|
|
1074
|
+
DRIVE_READ,
|
|
1075
|
+
drive((request) => {
|
|
1076
|
+
const token = request.url.searchParams.get("pageToken") ?? ""
|
|
1077
|
+
const parsed = /^(\d+)(?::(\d+):(\d+))?$/u.exec(token)
|
|
1078
|
+
const from = parsed === null ? Number.NaN : Number(parsed[1])
|
|
1079
|
+
if (parsed === null || from < minSeq.drive) {
|
|
1080
|
+
return legacyError(400, "Invalid Value", {
|
|
1081
|
+
reason: "invalid",
|
|
1082
|
+
location: "pageToken",
|
|
1083
|
+
locationType: "parameter",
|
|
1084
|
+
})
|
|
1085
|
+
}
|
|
1086
|
+
const until = parsed[2] === undefined ? clock.seq : Number(parsed[2])
|
|
1087
|
+
const offset = parsed[3] === undefined ? 0 : Number(parsed[3])
|
|
1088
|
+
const size = Math.min(1000, Number(request.url.searchParams.get("pageSize") ?? 100))
|
|
1089
|
+
const changes = files.changesSince(from, () => true, until)
|
|
1090
|
+
const slice = changes.slice(offset, offset + size)
|
|
1091
|
+
return partial(
|
|
1092
|
+
request,
|
|
1093
|
+
{
|
|
1094
|
+
kind: "drive#changeList",
|
|
1095
|
+
changes: slice.map((c) =>
|
|
1096
|
+
c.item === undefined
|
|
1097
|
+
? { kind: "drive#change", changeType: "file", fileId: c.id, removed: true, time: now() }
|
|
1098
|
+
: {
|
|
1099
|
+
kind: "drive#change",
|
|
1100
|
+
changeType: "file",
|
|
1101
|
+
fileId: c.id,
|
|
1102
|
+
removed: false,
|
|
1103
|
+
file: renderFile(c.item),
|
|
1104
|
+
time: now(),
|
|
1105
|
+
},
|
|
1106
|
+
),
|
|
1107
|
+
...(offset + size < changes.length
|
|
1108
|
+
? { nextPageToken: `${from}:${until}:${offset + size}` }
|
|
1109
|
+
: { newStartPageToken: String(until) }),
|
|
1110
|
+
},
|
|
1111
|
+
`kind,nextPageToken,newStartPageToken,changes(kind,changeType,time,removed,fileId,file(${DEFAULT_FILE}))`,
|
|
1112
|
+
)
|
|
1113
|
+
}),
|
|
1114
|
+
),
|
|
1115
|
+
)
|
|
1116
|
+
|
|
1117
|
+
const running = await serve(router)
|
|
1118
|
+
base = running.url
|
|
1119
|
+
oauth.addAccount(self)
|
|
1120
|
+
|
|
1121
|
+
const rfcDate = () => Date.now()
|
|
1122
|
+
return {
|
|
1123
|
+
url: base,
|
|
1124
|
+
oauth,
|
|
1125
|
+
self,
|
|
1126
|
+
clientId,
|
|
1127
|
+
clientSecret,
|
|
1128
|
+
settings: {
|
|
1129
|
+
clientId,
|
|
1130
|
+
clientSecret,
|
|
1131
|
+
authorizeUrl: `${base}/o/oauth2/v2/auth`,
|
|
1132
|
+
tokenUrl: `${base}/token`,
|
|
1133
|
+
userinfoUrl: `${base}/v1/userinfo`,
|
|
1134
|
+
gmailUrl: base,
|
|
1135
|
+
calendarUrl: base,
|
|
1136
|
+
adminUrl: base,
|
|
1137
|
+
driveUrl: base,
|
|
1138
|
+
} as Record<string, string>,
|
|
1139
|
+
apiRequests: () => apiRequests,
|
|
1140
|
+
/** The API requests received so far (the newest 10 000), oldest first. */
|
|
1141
|
+
requests: (): ReadonlyArray<{ readonly method: string; readonly url: URL }> => [...requestLog],
|
|
1142
|
+
throttle,
|
|
1143
|
+
rateLimitUser: (times: number) => {
|
|
1144
|
+
userRateLimited = times
|
|
1145
|
+
},
|
|
1146
|
+
setAdministrator: (value: boolean) => {
|
|
1147
|
+
administrator = value
|
|
1148
|
+
},
|
|
1149
|
+
expireCursors: (area: "mail" | "calendar" | "drive") => {
|
|
1150
|
+
minSeq[area] = clock.seq + 1
|
|
1151
|
+
},
|
|
1152
|
+
mail: {
|
|
1153
|
+
/**
|
|
1154
|
+
* A message, by default received in the inbox now; `internalDate` (epoch ms) when Gmail took it in, and
|
|
1155
|
+
* `headers` custom (`X-`) headers it carries (a sent copy's client id).
|
|
1156
|
+
*/
|
|
1157
|
+
seed: (input: {
|
|
1158
|
+
subject: string
|
|
1159
|
+
labels?: ReadonlyArray<string>
|
|
1160
|
+
internalDate?: number
|
|
1161
|
+
headers?: ReadonlyArray<{ readonly name: string; readonly value: string }>
|
|
1162
|
+
}) =>
|
|
1163
|
+
messages.put({
|
|
1164
|
+
id: id(),
|
|
1165
|
+
threadId: id(),
|
|
1166
|
+
labelIds: [...(input.labels ?? ["INBOX", "UNREAD"])],
|
|
1167
|
+
from: "Sender <sender@fabrikam.example>",
|
|
1168
|
+
to: self.email,
|
|
1169
|
+
cc: "",
|
|
1170
|
+
subject: input.subject,
|
|
1171
|
+
body: `Body of ${input.subject}`,
|
|
1172
|
+
internalDate: input.internalDate ?? rfcDate(),
|
|
1173
|
+
...(input.headers === undefined ? {} : { extraHeaders: input.headers }),
|
|
1174
|
+
}).id,
|
|
1175
|
+
modify: (id: string, add: ReadonlyArray<string>, remove: ReadonlyArray<string>) =>
|
|
1176
|
+
void messages.update(id, (m) => ({
|
|
1177
|
+
...m,
|
|
1178
|
+
labelIds: [...new Set([...m.labelIds.filter((l) => !remove.includes(l)), ...add])],
|
|
1179
|
+
})),
|
|
1180
|
+
get: (id: string) => messages.items.get(id),
|
|
1181
|
+
/** The messages that carry `label` (drafts: `DRAFT`). */
|
|
1182
|
+
labelled: (label: string) => [...messages.items.values()].filter((m) => m.labelIds.includes(label)),
|
|
1183
|
+
/** Delete a message for good (not to TRASH): history reports it in `messagesDeleted`. */
|
|
1184
|
+
remove: (id: string) => void messages.remove(id),
|
|
1185
|
+
/** Make the next `n` reads of the send-as addresses fail with a 500. */
|
|
1186
|
+
failSendAs: (n: number) => void (failingSendAs = n),
|
|
1187
|
+
/** A verified send-as alias of the account. */
|
|
1188
|
+
sendAs: (address: string, name = "") => void sendAs.push({ sendAsEmail: address, displayName: name }),
|
|
1189
|
+
/** Make reading this message fail (500), or (`false`) answer again. */
|
|
1190
|
+
failReads: (id: string, failing: boolean) => void (failing ? failingReads.add(id) : failingReads.delete(id)),
|
|
1191
|
+
/** The account's filters as Gmail holds them (users.settings.filters). */
|
|
1192
|
+
filters: () => [...filters.values()],
|
|
1193
|
+
},
|
|
1194
|
+
calendar: {
|
|
1195
|
+
/** Someone else's busy time, as freeBusy shares it with the account (ISO instants). */
|
|
1196
|
+
schedule: (address: string, blocks: ReadonlyArray<{ start: string; end: string }>) =>
|
|
1197
|
+
void busyOf.set(address.toLowerCase(), [...blocks]),
|
|
1198
|
+
/** An event in the primary calendar; with `organizer` and `attendees`, an invitation from someone else. */
|
|
1199
|
+
seed: (input: {
|
|
1200
|
+
summary: string
|
|
1201
|
+
start: string
|
|
1202
|
+
end: string
|
|
1203
|
+
organizer?: string
|
|
1204
|
+
attendees?: ReadonlyArray<{ email: string; responseStatus?: string; self?: boolean }>
|
|
1205
|
+
}) =>
|
|
1206
|
+
events.put({
|
|
1207
|
+
id: id("evt"),
|
|
1208
|
+
calendarId: PRIMARY,
|
|
1209
|
+
status: "confirmed",
|
|
1210
|
+
summary: input.summary,
|
|
1211
|
+
description: null,
|
|
1212
|
+
location: null,
|
|
1213
|
+
start: input.start,
|
|
1214
|
+
end: input.end,
|
|
1215
|
+
attendees: (input.attendees ?? []).map((a) => {
|
|
1216
|
+
const entry: { email: string; responseStatus: string; self?: boolean } = {
|
|
1217
|
+
email: a.email,
|
|
1218
|
+
responseStatus: a.responseStatus ?? "needsAction",
|
|
1219
|
+
}
|
|
1220
|
+
if (a.self !== undefined) entry.self = a.self
|
|
1221
|
+
return entry
|
|
1222
|
+
}),
|
|
1223
|
+
organizer: input.organizer ?? self.email,
|
|
1224
|
+
updated: now(),
|
|
1225
|
+
}).id,
|
|
1226
|
+
update: (id: string, change: Partial<GoogleEvent>) =>
|
|
1227
|
+
void events.update(id, (e) => ({ ...e, ...change, updated: now() })),
|
|
1228
|
+
cancel: (id: string) => void events.update(id, (e) => ({ ...e, status: "cancelled", updated: now() })),
|
|
1229
|
+
get: (id: string) => events.items.get(id),
|
|
1230
|
+
},
|
|
1231
|
+
directory: {
|
|
1232
|
+
seed: (input: { givenName: string; familyName: string; email: string }) =>
|
|
1233
|
+
users.put({
|
|
1234
|
+
id: String(100000000000 + Math.floor(Math.random() * 1e9)),
|
|
1235
|
+
primaryEmail: input.email,
|
|
1236
|
+
givenName: input.givenName,
|
|
1237
|
+
familyName: input.familyName,
|
|
1238
|
+
suspended: false,
|
|
1239
|
+
title: null,
|
|
1240
|
+
department: null,
|
|
1241
|
+
etag: `"${id()}"`,
|
|
1242
|
+
}).id,
|
|
1243
|
+
update: (id: string, change: Partial<GoogleUser>) =>
|
|
1244
|
+
void users.update(id, (u) => ({ ...u, ...change, etag: `"${randomBytes(8).toString("hex")}"` })),
|
|
1245
|
+
remove: (id: string) => void users.remove(id),
|
|
1246
|
+
},
|
|
1247
|
+
drive: {
|
|
1248
|
+
root: ROOT,
|
|
1249
|
+
/** Upload a file (its processing change follows). */
|
|
1250
|
+
seed: (input: { name: string; content?: string; parent?: string }) => {
|
|
1251
|
+
const file = files.put({
|
|
1252
|
+
id: id("1F"),
|
|
1253
|
+
name: input.name,
|
|
1254
|
+
mimeType: "text/plain",
|
|
1255
|
+
parent: input.parent ?? ROOT,
|
|
1256
|
+
content: input.content ?? "",
|
|
1257
|
+
trashed: false,
|
|
1258
|
+
modifiedTime: now(),
|
|
1259
|
+
version: 1,
|
|
1260
|
+
})
|
|
1261
|
+
processing.add(file.id)
|
|
1262
|
+
return file.id
|
|
1263
|
+
},
|
|
1264
|
+
/** Change a file; new content is an upload, and its processing change follows. */
|
|
1265
|
+
update: (id: string, change: Partial<DriveFile>) => {
|
|
1266
|
+
files.update(id, (f) => ({ ...f, ...change, modifiedTime: now(), version: f.version + 1 }))
|
|
1267
|
+
if (change.content !== undefined) processing.add(id)
|
|
1268
|
+
},
|
|
1269
|
+
trash: (id: string) =>
|
|
1270
|
+
void files.update(id, (f) => ({ ...f, trashed: true, modifiedTime: now(), version: f.version + 1 })),
|
|
1271
|
+
remove: (id: string) => void files.remove(id),
|
|
1272
|
+
/** Every pending processing change is made now: the change feed is settled. */
|
|
1273
|
+
settled: async () => processPending(),
|
|
1274
|
+
},
|
|
1275
|
+
/** The next `times` API requests are carried out, then answered 503 as if the answer were lost on the way. */
|
|
1276
|
+
loseResponses: (times: number) => void (lostResponses = times),
|
|
1277
|
+
close: running.close,
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
export type GoogleFake = Awaited<ReturnType<typeof startGoogleFake>>
|
|
1282
|
+
|
|
1283
|
+
/** The fake as a capability kit's provider: settings, the account, its controls and item seeds. */
|
|
1284
|
+
export const googleProvider = (fake: GoogleFake) => {
|
|
1285
|
+
const email = fake.self.email
|
|
1286
|
+
const soon = (hours: number) => new Date(Math.floor(Date.now() / 1000) * 1000 + hours * 3_600_000).toISOString()
|
|
1287
|
+
return {
|
|
1288
|
+
settings: fake.settings,
|
|
1289
|
+
self: fake.self,
|
|
1290
|
+
controls: {
|
|
1291
|
+
expireAccessTokens: async () => fake.oauth.expireAccessTokens(email),
|
|
1292
|
+
revokeRefreshTokens: async () => fake.oauth.revokeRefreshTokens(email),
|
|
1293
|
+
revokeScopes: async (scopes: ReadonlyArray<string>) => fake.oauth.revokeScopes(email, scopes),
|
|
1294
|
+
restoreScopes: async () => fake.oauth.restoreScopes(email),
|
|
1295
|
+
throttle: async (options: { status: 429 | 503; retryAfter: string | null; times: number }) =>
|
|
1296
|
+
fake.throttle.set(options),
|
|
1297
|
+
throttleAfterWrite: async (options: { status: 429 | 503; retryAfter: string | null; times: number }) =>
|
|
1298
|
+
fake.throttle.afterWrite(options),
|
|
1299
|
+
apiRequests: () => fake.apiRequests(),
|
|
1300
|
+
refreshes: () => fake.oauth.stats.refreshes,
|
|
1301
|
+
expireCursors: async (capability: string) => {
|
|
1302
|
+
const area = ({ mail: "mail", calendar: "calendar", documents: "drive" } as const)[capability as "mail"]
|
|
1303
|
+
if (area === undefined) return false // the Admin SDK has no delta: the connector's cursor is a snapshot
|
|
1304
|
+
fake.expireCursors(area)
|
|
1305
|
+
return true
|
|
1306
|
+
},
|
|
1307
|
+
},
|
|
1308
|
+
seeds: {
|
|
1309
|
+
mail: {
|
|
1310
|
+
create: async (label: string) => fake.mail.seed({ subject: label }),
|
|
1311
|
+
update: async (id: string) => fake.mail.modify(id, [], ["UNREAD"]),
|
|
1312
|
+
remove: async (id: string) => fake.mail.modify(id, ["TRASH"], []),
|
|
1313
|
+
},
|
|
1314
|
+
calendar: {
|
|
1315
|
+
create: async (label: string) => fake.calendar.seed({ summary: label, start: soon(24), end: soon(25) }),
|
|
1316
|
+
update: async (id: string) => fake.calendar.update(id, { summary: "changed" }),
|
|
1317
|
+
remove: async (id: string) => fake.calendar.cancel(id),
|
|
1318
|
+
invite: async (label: string) =>
|
|
1319
|
+
fake.calendar.seed({
|
|
1320
|
+
summary: label,
|
|
1321
|
+
start: soon(48),
|
|
1322
|
+
end: soon(49),
|
|
1323
|
+
organizer: "megan@workspace.example",
|
|
1324
|
+
attendees: [{ email: fake.self.email }],
|
|
1325
|
+
}),
|
|
1326
|
+
},
|
|
1327
|
+
directory: {
|
|
1328
|
+
create: async (label: string) =>
|
|
1329
|
+
fake.directory.seed({
|
|
1330
|
+
givenName: "Person",
|
|
1331
|
+
familyName: label,
|
|
1332
|
+
email: `${label}-${crypto.randomUUID().slice(0, 8)}@workspace.example`,
|
|
1333
|
+
}),
|
|
1334
|
+
update: async (id: string) => fake.directory.update(id, { title: "Changed" }),
|
|
1335
|
+
remove: async (id: string) => fake.directory.remove(id),
|
|
1336
|
+
},
|
|
1337
|
+
documents: {
|
|
1338
|
+
create: async (label: string) => fake.drive.seed({ name: `${label}.txt`, content: `content of ${label}` }),
|
|
1339
|
+
update: async (id: string) => fake.drive.update(id, { content: "changed" }),
|
|
1340
|
+
remove: async (id: string) => fake.drive.trash(id),
|
|
1341
|
+
// Drive's change feed settles after an upload's processing (see `processing`).
|
|
1342
|
+
settle: () => fake.drive.settled(),
|
|
1343
|
+
},
|
|
1344
|
+
},
|
|
1345
|
+
}
|
|
1346
|
+
}
|