@sanity/cli-core 0.0.2-alpha.2 → 0.1.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SanityCommand.js +34 -3
- package/dist/SanityCommand.js.map +1 -1
- package/dist/_exports/tree.d.ts +47 -0
- package/dist/_exports/tree.js +3 -0
- package/dist/_exports/tree.js.map +1 -0
- package/dist/_exports/ux.d.ts +40 -0
- package/dist/_exports/ux.js +6 -0
- package/dist/_exports/ux.js.map +1 -0
- package/dist/config/cli/getCliConfig.worker.js +2 -1
- package/dist/config/cli/getCliConfig.worker.js.map +1 -1
- package/dist/config/cli/schemas.js +5 -2
- package/dist/config/cli/schemas.js.map +1 -1
- package/dist/config/cli/types/cliConfig.js.map +1 -1
- package/dist/config/findProjectRoot.js +2 -2
- package/dist/config/findProjectRoot.js.map +1 -1
- package/dist/config/studio/getStudioConfig.js +0 -3
- package/dist/config/studio/getStudioConfig.js.map +1 -1
- package/dist/config/studio/getStudioWorkspaces.js +50 -0
- package/dist/config/studio/getStudioWorkspaces.js.map +1 -0
- package/dist/config/studio/isStudioConfig.js +19 -0
- package/dist/config/studio/isStudioConfig.js.map +1 -0
- package/dist/config/studio/readStudioConfig.js +13 -9
- package/dist/config/studio/readStudioConfig.js.map +1 -1
- package/dist/config/studio/readStudioConfig.worker.js +4 -30
- package/dist/config/studio/readStudioConfig.worker.js.map +1 -1
- package/dist/config/util/findStudioConfigPath.js +24 -3
- package/dist/config/util/findStudioConfigPath.js.map +1 -1
- package/dist/config/util/recursivelyResolveProjectRoot.js.map +1 -1
- package/dist/index.d.ts +6027 -36
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/loaders/studio/studioWorkerLoader.worker.js +10 -24
- package/dist/loaders/studio/studioWorkerLoader.worker.js.map +1 -1
- package/dist/loaders/studio/studioWorkerTask.js +41 -11
- package/dist/loaders/studio/studioWorkerTask.js.map +1 -1
- package/dist/loaders/tsx/tsxWorkerTask.js +3 -0
- package/dist/loaders/tsx/tsxWorkerTask.js.map +1 -1
- package/dist/services/apiClient.js +18 -17
- package/dist/services/apiClient.js.map +1 -1
- package/dist/telemetry/cleanupOldTelemetryFiles.js +30 -0
- package/dist/telemetry/cleanupOldTelemetryFiles.js.map +1 -0
- package/dist/telemetry/createTelemetryStore.js +95 -0
- package/dist/telemetry/createTelemetryStore.js.map +1 -0
- package/dist/telemetry/createTraceId.js +10 -0
- package/dist/telemetry/createTraceId.js.map +1 -0
- package/dist/telemetry/findTelemetryFiles.js +36 -0
- package/dist/telemetry/findTelemetryFiles.js.map +1 -0
- package/dist/telemetry/flushTelemetryFiles.js +107 -0
- package/dist/telemetry/flushTelemetryFiles.js.map +1 -0
- package/dist/telemetry/generateTelemetryFilePath.js +30 -0
- package/dist/telemetry/generateTelemetryFilePath.js.map +1 -0
- package/dist/telemetry/getTelemetryBaseInfo.js +33 -0
- package/dist/telemetry/getTelemetryBaseInfo.js.map +1 -0
- package/dist/telemetry/logger.js +54 -0
- package/dist/telemetry/logger.js.map +1 -0
- package/dist/telemetry/telemetryStoreDebug.js +7 -0
- package/dist/telemetry/telemetryStoreDebug.js.map +1 -0
- package/dist/telemetry/trace.js +150 -0
- package/dist/telemetry/trace.js.map +1 -0
- package/dist/telemetry/types.js +5 -0
- package/dist/telemetry/types.js.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -1
- package/dist/util/doImport.js +16 -0
- package/dist/util/doImport.js.map +1 -0
- package/dist/util/environment/getStudioEnvironmentVariables.js +2 -1
- package/dist/util/environment/getStudioEnvironmentVariables.js.map +1 -1
- package/dist/util/getCliTelemetry.js +36 -0
- package/dist/util/getCliTelemetry.js.map +1 -0
- package/dist/util/isStaging.js +10 -0
- package/dist/util/isStaging.js.map +1 -0
- package/dist/util/normalizePath.js +12 -0
- package/dist/util/normalizePath.js.map +1 -0
- package/dist/util/parseStringFlag.js +19 -0
- package/dist/util/parseStringFlag.js.map +1 -0
- package/dist/util/readNDJSON.js +18 -0
- package/dist/util/readNDJSON.js.map +1 -0
- package/dist/util/resolveLocalPackage.js +34 -0
- package/dist/util/resolveLocalPackage.js.map +1 -0
- package/dist/util/tree.js +108 -0
- package/dist/util/tree.js.map +1 -0
- package/dist/util/waitForAsync.js +5 -0
- package/dist/util/waitForAsync.js.map +1 -0
- package/dist/ux/boxen.js +3 -0
- package/dist/ux/boxen.js.map +1 -0
- package/dist/ux/colorizeJson.js +6 -6
- package/dist/ux/colorizeJson.js.map +1 -1
- package/dist/ux/prompts.js +3 -0
- package/dist/ux/prompts.js.map +1 -0
- package/dist/ux/spinner.js +1 -1
- package/dist/ux/spinner.js.map +1 -1
- package/package.json +53 -28
- package/dist/SanityCommand.d.ts +0 -56
- package/dist/config/__tests__/cliToken.test.js +0 -74
- package/dist/config/__tests__/cliToken.test.js.map +0 -1
- package/dist/config/__tests__/cliUserConfig.test.js +0 -131
- package/dist/config/__tests__/cliUserConfig.test.js.map +0 -1
- package/dist/config/__tests__/findProjectRoot.test.js +0 -159
- package/dist/config/__tests__/findProjectRoot.test.js.map +0 -1
- package/dist/config/__tests__/findProjectRootSync.test.js +0 -112
- package/dist/config/__tests__/findProjectRootSync.test.js.map +0 -1
- package/dist/config/__tests__/getCliConfigSync.test.js +0 -31
- package/dist/config/__tests__/getCliConfigSync.test.js.map +0 -1
- package/dist/config/cli/getCliConfig.d.ts +0 -16
- package/dist/config/cli/getCliConfig.worker.d.ts +0 -1
- package/dist/config/cli/getCliConfigSync.d.ts +0 -12
- package/dist/config/cli/schemas.d.ts +0 -255
- package/dist/config/cli/types/cliConfig.d.ts +0 -74
- package/dist/config/cli/types/userViteConfig.d.ts +0 -5
- package/dist/config/findProjectRoot.d.ts +0 -14
- package/dist/config/findProjectRootSync.d.ts +0 -27
- package/dist/config/studio/getStudioConfig.d.ts +0 -14
- package/dist/config/studio/readStudioConfig.d.ts +0 -190
- package/dist/config/studio/readStudioConfig.worker.d.ts +0 -1
- package/dist/config/util/configPathsSync.d.ts +0 -17
- package/dist/config/util/findAppConfigPath.d.ts +0 -8
- package/dist/config/util/findConfigsPaths.d.ts +0 -16
- package/dist/config/util/findStudioConfigPath.d.ts +0 -9
- package/dist/config/util/isSanityV2StudioRoot.d.ts +0 -8
- package/dist/config/util/recursivelyResolveProjectRoot.d.ts +0 -27
- package/dist/debug.d.ts +0 -15
- package/dist/loaders/studio/studioWorkerLoader.worker.d.ts +0 -1
- package/dist/loaders/studio/studioWorkerTask.d.ts +0 -40
- package/dist/loaders/tsx/tsxWorkerLoader.worker.d.ts +0 -1
- package/dist/loaders/tsx/tsxWorkerTask.d.ts +0 -28
- package/dist/services/apiClient.d.ts +0 -53
- package/dist/services/cliUserConfig.d.ts +0 -57
- package/dist/services/getCliToken.d.ts +0 -7
- package/dist/types.d.ts +0 -7
- package/dist/util/NotFoundError.d.ts +0 -20
- package/dist/util/__tests__/createExpiringConfig.test.js +0 -400
- package/dist/util/__tests__/createExpiringConfig.test.js.map +0 -1
- package/dist/util/createExpiringConfig.d.ts +0 -37
- package/dist/util/environment/getStudioEnvironmentVariables.d.ts +0 -12
- package/dist/util/environment/mockBrowserEnvironment.d.ts +0 -17
- package/dist/util/environment/setupBrowserStubs.d.ts +0 -10
- package/dist/util/environment/stubs.d.ts +0 -254
- package/dist/util/fileExists.d.ts +0 -9
- package/dist/util/generateHelpUrl.d.ts +0 -8
- package/dist/util/getEmptyAuth.d.ts +0 -5
- package/dist/util/getSanityEnvVar.d.ts +0 -19
- package/dist/util/getSanityUrl.d.ts +0 -5
- package/dist/util/getUserConfig.d.ts +0 -2
- package/dist/util/isCi.d.ts +0 -1
- package/dist/util/isHttpError.d.ts +0 -29
- package/dist/util/isHttpError.js +0 -18
- package/dist/util/isHttpError.js.map +0 -1
- package/dist/util/isInteractive.d.ts +0 -1
- package/dist/util/isRecord.d.ts +0 -8
- package/dist/util/isTrueish.d.ts +0 -1
- package/dist/util/readJsonFile.d.ts +0 -14
- package/dist/util/safeStructuredClone.d.ts +0 -8
- package/dist/util/tryGetDefaultExport.d.ts +0 -5
- package/dist/util/writeJsonFile.d.ts +0 -9
- package/dist/ux/colorizeJson.d.ts +0 -1
- package/dist/ux/formatObject.d.ts +0 -1
- package/dist/ux/logSymbols.d.ts +0 -1
- package/dist/ux/printKeyValue.d.ts +0 -1
- package/dist/ux/spinner.d.ts +0 -1
- package/dist/ux/timer.d.ts +0 -12
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/util/__tests__/createExpiringConfig.test.ts"],"sourcesContent":["import type ConfigStore from 'configstore'\n\nimport {beforeEach, describe, expect, test, vi} from 'vitest'\n\nimport {createExpiringConfig} from '../createExpiringConfig.js'\n\ndescribe('createExpiringConfig', () => {\n let mockStore: ConfigStore\n let fetchValue: ReturnType<typeof vi.fn>\n let onCacheHit: ReturnType<typeof vi.fn>\n let onFetch: ReturnType<typeof vi.fn>\n let onRevalidate: ReturnType<typeof vi.fn>\n\n beforeEach(() => {\n // Mock ConfigStore\n mockStore = {\n delete: vi.fn(),\n get: vi.fn(),\n set: vi.fn(),\n } as unknown as ConfigStore\n\n // Reset all mocks\n fetchValue = vi.fn()\n onCacheHit = vi.fn()\n onFetch = vi.fn()\n onRevalidate = vi.fn()\n })\n\n test('returns fetched value when cache is empty', async () => {\n const testValue = 'test-value'\n const config = createExpiringConfig({\n fetchValue: fetchValue.mockResolvedValue(testValue),\n key: 'test-key',\n onCacheHit,\n onFetch,\n onRevalidate,\n store: mockStore,\n ttl: 5000,\n })\n\n // Mock empty cache\n vi.mocked(mockStore.get).mockReturnValue(undefined)\n\n const result = await config.get()\n\n expect(result).toBe(testValue)\n expect(fetchValue).toHaveBeenCalledOnce()\n expect(onFetch).toHaveBeenCalledOnce()\n expect(onCacheHit).not.toHaveBeenCalled()\n expect(onRevalidate).not.toHaveBeenCalled()\n expect(mockStore.set).toHaveBeenCalledWith('test-key', {\n updatedAt: expect.any(Number),\n value: testValue,\n })\n })\n\n test('returns cached value when it has not expired', async () => {\n const cachedValue = 'cached-value'\n const ttl = 5000\n const updatedAt = Date.now() - 1000 // 1 second ago (not expired)\n\n const config = createExpiringConfig({\n fetchValue,\n key: 'test-key',\n onCacheHit,\n onFetch,\n onRevalidate,\n store: mockStore,\n ttl,\n })\n\n // Mock cached value that hasn't expired\n vi.mocked(mockStore.get).mockReturnValue({\n updatedAt,\n value: cachedValue,\n })\n\n const result = await config.get()\n\n expect(result).toBe(cachedValue)\n expect(fetchValue).not.toHaveBeenCalled()\n expect(onCacheHit).toHaveBeenCalledOnce()\n expect(onFetch).not.toHaveBeenCalled()\n expect(onRevalidate).not.toHaveBeenCalled()\n expect(mockStore.set).not.toHaveBeenCalled()\n })\n\n test('fetches new value when cached value has expired', async () => {\n const newValue = 'new-value'\n const ttl = 1000\n const updatedAt = Date.now() - 2000 // 2 seconds ago (expired)\n\n const config = createExpiringConfig({\n fetchValue: fetchValue.mockResolvedValue(newValue),\n key: 'test-key',\n onCacheHit,\n onFetch,\n onRevalidate,\n store: mockStore,\n ttl,\n })\n\n // Mock expired cached value\n vi.mocked(mockStore.get).mockReturnValue({\n updatedAt,\n value: 'old-value',\n })\n\n const result = await config.get()\n\n expect(result).toBe(newValue)\n expect(fetchValue).toHaveBeenCalledOnce()\n expect(onRevalidate).toHaveBeenCalledOnce()\n expect(onFetch).toHaveBeenCalledOnce()\n expect(onCacheHit).not.toHaveBeenCalled()\n expect(mockStore.set).toHaveBeenCalledWith('test-key', {\n updatedAt: expect.any(Number),\n value: newValue,\n })\n })\n\n test('deletes cached value from store', () => {\n const config = createExpiringConfig({\n fetchValue,\n key: 'test-key',\n store: mockStore,\n ttl: 5000,\n })\n\n config.delete()\n\n expect(mockStore.delete).toHaveBeenCalledWith('test-key')\n })\n\n test('handles concurrent get() calls correctly', async () => {\n const testValue = 'test-value'\n let resolvePromise: (value: string) => void\n const delayedFetch = new Promise<string>((resolve) => {\n resolvePromise = resolve\n })\n\n const config = createExpiringConfig({\n fetchValue: fetchValue.mockReturnValue(delayedFetch),\n key: 'test-key',\n onFetch,\n store: mockStore,\n ttl: 5000,\n })\n\n // Mock empty cache\n vi.mocked(mockStore.get).mockReturnValue(undefined)\n\n // Start multiple concurrent get() calls\n const promise1 = config.get()\n const promise2 = config.get()\n const promise3 = config.get()\n\n // Resolve the fetch\n resolvePromise!(testValue)\n\n const [result1, result2, result3] = await Promise.all([promise1, promise2, promise3])\n\n expect(result1).toBe(testValue)\n expect(result2).toBe(testValue)\n expect(result3).toBe(testValue)\n expect(fetchValue).toHaveBeenCalledOnce() // Only one fetch should happen\n expect(onFetch).toHaveBeenCalledOnce()\n })\n\n test('handles synchronous fetchValue function', async () => {\n const testValue = 'sync-value'\n const syncFetchValue = vi.fn().mockReturnValue(testValue)\n\n const config = createExpiringConfig({\n fetchValue: syncFetchValue,\n key: 'test-key',\n store: mockStore,\n ttl: 5000,\n })\n\n // Mock empty cache\n vi.mocked(mockStore.get).mockReturnValue(undefined)\n\n const result = await config.get()\n\n expect(result).toBe(testValue)\n expect(syncFetchValue).toHaveBeenCalledOnce()\n })\n\n test('handles fetchValue throwing an error', async () => {\n const error = new Error('Fetch failed')\n const config = createExpiringConfig({\n fetchValue: fetchValue.mockRejectedValue(error),\n key: 'test-key',\n store: mockStore,\n ttl: 5000,\n })\n\n // Mock empty cache\n vi.mocked(mockStore.get).mockReturnValue(undefined)\n\n await expect(config.get()).rejects.toThrow('Fetch failed')\n expect(fetchValue).toHaveBeenCalledOnce()\n expect(mockStore.set).not.toHaveBeenCalled()\n })\n\n test('handles different data types as cached values', async () => {\n const objectValue = {key: 'value', number: 42}\n const config = createExpiringConfig({\n fetchValue: fetchValue.mockResolvedValue(objectValue),\n key: 'test-key',\n store: mockStore,\n ttl: 5000,\n })\n\n // Mock empty cache\n vi.mocked(mockStore.get).mockReturnValue(undefined)\n\n const result = await config.get()\n\n expect(result).toEqual(objectValue)\n expect(mockStore.set).toHaveBeenCalledWith('test-key', {\n updatedAt: expect.any(Number),\n value: objectValue,\n })\n })\n\n test('works with TTL of 0 (immediate expiration)', async () => {\n const testValue = 'test-value'\n const config = createExpiringConfig({\n fetchValue: fetchValue.mockResolvedValue(testValue),\n key: 'test-key',\n onRevalidate,\n store: mockStore,\n ttl: 0,\n })\n\n // Mock cached value that would be immediately expired\n // Use a timestamp from 1ms ago to ensure it's > ttl (0)\n vi.mocked(mockStore.get).mockReturnValue({\n updatedAt: Date.now() - 1,\n value: 'old-value',\n })\n\n const result = await config.get()\n\n expect(result).toBe(testValue)\n expect(fetchValue).toHaveBeenCalledOnce()\n expect(onRevalidate).toHaveBeenCalledOnce()\n })\n\n test('works without optional callback functions', async () => {\n const testValue = 'test-value'\n const config = createExpiringConfig({\n fetchValue: fetchValue.mockResolvedValue(testValue),\n key: 'test-key',\n store: mockStore,\n ttl: 5000,\n })\n\n // Mock empty cache\n vi.mocked(mockStore.get).mockReturnValue(undefined)\n\n const result = await config.get()\n\n expect(result).toBe(testValue)\n expect(fetchValue).toHaveBeenCalledOnce()\n })\n\n test('handles cached value without updatedAt timestamp', async () => {\n const newValue = 'new-value'\n const config = createExpiringConfig({\n fetchValue: fetchValue.mockResolvedValue(newValue),\n key: 'test-key',\n onFetch,\n store: mockStore,\n ttl: 5000,\n })\n\n // Mock cached value without updatedAt (invalid cache entry)\n vi.mocked(mockStore.get).mockReturnValue({\n value: 'old-value',\n // updatedAt is missing\n })\n\n const result = await config.get()\n\n expect(result).toBe(newValue)\n expect(fetchValue).toHaveBeenCalledOnce()\n expect(onFetch).toHaveBeenCalledOnce()\n })\n\n test('handles cached value without value property', async () => {\n const newValue = 'new-value'\n const config = createExpiringConfig({\n fetchValue: fetchValue.mockResolvedValue(newValue),\n key: 'test-key',\n onFetch,\n store: mockStore,\n ttl: 5000,\n })\n\n // Mock cached entry without value property\n vi.mocked(mockStore.get).mockReturnValue({\n updatedAt: Date.now(),\n // value is missing\n })\n\n const result = await config.get()\n\n expect(result).toBe(newValue)\n expect(fetchValue).toHaveBeenCalledOnce()\n expect(onFetch).toHaveBeenCalledOnce()\n })\n\n test('stores timestamp correctly when caching new values', async () => {\n const testValue = 'test-value'\n\n const config = createExpiringConfig({\n fetchValue: fetchValue.mockResolvedValue(testValue),\n key: 'test-key',\n store: mockStore,\n ttl: 5000,\n })\n\n // Mock empty cache\n vi.mocked(mockStore.get).mockReturnValue(undefined)\n\n await config.get()\n\n expect(mockStore.set).toHaveBeenCalledWith('test-key', {\n updatedAt: expect.any(Number),\n value: testValue,\n })\n })\n\n test('subsequent requests after cache is populated use cached value', async () => {\n const testValue = 'test-value'\n const config = createExpiringConfig({\n fetchValue: fetchValue.mockResolvedValue(testValue),\n key: 'test-key',\n onCacheHit,\n onFetch,\n store: mockStore,\n ttl: 5000,\n })\n\n // Mock empty cache for first request\n vi.mocked(mockStore.get).mockReturnValueOnce(undefined)\n\n // First request should fetch\n const result1 = await config.get()\n\n // Mock cache populated for subsequent request\n vi.mocked(mockStore.get).mockReturnValueOnce({\n updatedAt: Date.now(),\n value: testValue,\n })\n\n // Second request should hit cache\n const result2 = await config.get()\n\n expect(result1).toBe(testValue)\n expect(result2).toBe(testValue)\n expect(fetchValue).toHaveBeenCalledOnce()\n expect(onFetch).toHaveBeenCalledOnce()\n expect(onCacheHit).toHaveBeenCalledOnce()\n })\n\n test('throws when cached value fails validateValue', async () => {\n const invalidCached = 123\n const ttl = 10_000\n\n const validateValue = vi.fn((v: unknown): v is string => typeof v === 'string')\n\n const config = createExpiringConfig<string>({\n fetchValue,\n key: 'test-key',\n onCacheHit,\n onFetch,\n onRevalidate,\n store: mockStore,\n ttl,\n // @ts-expect-error vitest mocks don't jive with assertions\n validateValue,\n })\n\n // Cached entry that is not expired but invalid per validateValue\n vi.mocked(mockStore.get).mockReturnValue({\n updatedAt: Date.now(),\n value: invalidCached,\n })\n\n await expect(config.get()).rejects.toThrow('Stored value is invalid')\n expect(validateValue).toHaveBeenCalledOnce()\n expect(onCacheHit).not.toHaveBeenCalled()\n expect(onFetch).not.toHaveBeenCalled()\n expect(onRevalidate).not.toHaveBeenCalled()\n expect(mockStore.set).not.toHaveBeenCalled()\n })\n\n test('throws when fetched value fails validateValue (cache miss)', async () => {\n const validateValue = vi.fn((v: unknown): v is string => typeof v === 'string')\n const config = createExpiringConfig<string>({\n fetchValue: fetchValue.mockResolvedValue(42 as unknown as string),\n key: 'test-key',\n onFetch,\n store: mockStore,\n ttl: 5000,\n // @ts-expect-error vitest mocks don't jive with assertions\n validateValue,\n })\n\n // Empty cache\n vi.mocked(mockStore.get).mockReturnValue(undefined)\n\n await expect(config.get()).rejects.toThrow('Fetched value is invalid')\n expect(onFetch).toHaveBeenCalledOnce()\n expect(validateValue).toHaveBeenCalledOnce()\n expect(mockStore.set).not.toHaveBeenCalled()\n })\n\n test('returns cached value when validateValue accepts it', async () => {\n const cachedValue = 'ok'\n const validateValue = vi.fn((v: unknown): v is string => typeof v === 'string')\n const config = createExpiringConfig<string>({\n fetchValue,\n key: 'test-key',\n onCacheHit,\n store: mockStore,\n ttl: 5000,\n // @ts-expect-error vitest mocks don't jive with assertions\n validateValue,\n })\n\n vi.mocked(mockStore.get).mockReturnValue({\n updatedAt: Date.now(),\n value: cachedValue,\n })\n\n const result = await config.get()\n\n expect(result).toBe(cachedValue)\n expect(validateValue).toHaveBeenCalledOnce()\n expect(onCacheHit).toHaveBeenCalledOnce()\n expect(fetchValue).not.toHaveBeenCalled()\n })\n\n test('revalidation path validates fetched value and throws if invalid', async () => {\n const validateValue = vi.fn((v: unknown): v is string => typeof v === 'string')\n const config = createExpiringConfig<string>({\n fetchValue: fetchValue.mockResolvedValue(99 as unknown as string),\n key: 'test-key',\n onFetch,\n onRevalidate,\n store: mockStore,\n ttl: 1, // ensure expiration\n // @ts-expect-error vitest mocks don't jive with assertions\n validateValue,\n })\n\n // Cached value that has expired but is otherwise valid in shape and passes validate\n vi.mocked(mockStore.get).mockReturnValue({\n updatedAt: Date.now() - 10,\n value: 'stale',\n })\n\n await expect(config.get()).rejects.toThrow('Fetched value is invalid')\n expect(onRevalidate).toHaveBeenCalledOnce()\n expect(onFetch).toHaveBeenCalledOnce()\n // validateValue called for stored value and fetched value\n expect(validateValue).toHaveBeenCalledTimes(2)\n expect(mockStore.set).not.toHaveBeenCalled()\n })\n})\n"],"names":["beforeEach","describe","expect","test","vi","createExpiringConfig","mockStore","fetchValue","onCacheHit","onFetch","onRevalidate","delete","fn","get","set","testValue","config","mockResolvedValue","key","store","ttl","mocked","mockReturnValue","undefined","result","toBe","toHaveBeenCalledOnce","not","toHaveBeenCalled","toHaveBeenCalledWith","updatedAt","any","Number","value","cachedValue","Date","now","newValue","resolvePromise","delayedFetch","Promise","resolve","promise1","promise2","promise3","result1","result2","result3","all","syncFetchValue","error","Error","mockRejectedValue","rejects","toThrow","objectValue","number","toEqual","mockReturnValueOnce","invalidCached","validateValue","v","toHaveBeenCalledTimes"],"mappings":"AAEA,SAAQA,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAEC,EAAE,QAAO,SAAQ;AAE7D,SAAQC,oBAAoB,QAAO,6BAA4B;AAE/DJ,SAAS,wBAAwB;IAC/B,IAAIK;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IAEJV,WAAW;QACT,mBAAmB;QACnBM,YAAY;YACVK,QAAQP,GAAGQ,EAAE;YACbC,KAAKT,GAAGQ,EAAE;YACVE,KAAKV,GAAGQ,EAAE;QACZ;QAEA,kBAAkB;QAClBL,aAAaH,GAAGQ,EAAE;QAClBJ,aAAaJ,GAAGQ,EAAE;QAClBH,UAAUL,GAAGQ,EAAE;QACfF,eAAeN,GAAGQ,EAAE;IACtB;IAEAT,KAAK,6CAA6C;QAChD,MAAMY,YAAY;QAClB,MAAMC,SAASX,qBAAqB;YAClCE,YAAYA,WAAWU,iBAAiB,CAACF;YACzCG,KAAK;YACLV;YACAC;YACAC;YACAS,OAAOb;YACPc,KAAK;QACP;QAEA,mBAAmB;QACnBhB,GAAGiB,MAAM,CAACf,UAAUO,GAAG,EAAES,eA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pD,OAAOQ,cAAcgB,oBAAoB;QACzCxB,OAAOO,SAASiB,oBAAoB;QACpC,0DAA0D;QAC1DxB,OAAO0D,eAAeE,qBAAqB,CAAC;QAC5C5D,OAAOI,UAAUQ,GAAG,EAAEa,GAAG,CAACC,gBAAgB;IAC5C;AACF"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type ConfigStore from 'configstore';
|
|
2
|
-
export interface ExpiringConfigOptions<Type> {
|
|
3
|
-
/** Fetch value */
|
|
4
|
-
fetchValue: () => Promise<Type> | Type;
|
|
5
|
-
/** Config key */
|
|
6
|
-
key: string;
|
|
7
|
-
/** Config store */
|
|
8
|
-
store: ConfigStore;
|
|
9
|
-
/** TTL (milliseconds) */
|
|
10
|
-
ttl: number;
|
|
11
|
-
/** Subscribe to cache hit event */
|
|
12
|
-
onCacheHit?: () => void;
|
|
13
|
-
/** Subscribe to fetch event */
|
|
14
|
-
onFetch?: () => void;
|
|
15
|
-
/** Subscribe to revalidate event */
|
|
16
|
-
onRevalidate?: () => void;
|
|
17
|
-
/**
|
|
18
|
-
* Assert the fetched value is valid, or throw if invalid.
|
|
19
|
-
* If none is provided, it will always accept the fetched value.
|
|
20
|
-
*/
|
|
21
|
-
validateValue?: (value: unknown) => value is Type;
|
|
22
|
-
}
|
|
23
|
-
export interface ExpiringConfigApi<Type> {
|
|
24
|
-
/**
|
|
25
|
-
* Delete the cached value.
|
|
26
|
-
*/
|
|
27
|
-
delete: () => void;
|
|
28
|
-
/**
|
|
29
|
-
* Attempt to get the cached value. If there is no cached value, or the cached value has expired,
|
|
30
|
-
* fetch, cache, and return the value.
|
|
31
|
-
*/
|
|
32
|
-
get: () => Promise<Type>;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Create a config in the provided config store that expires after the provided TTL.
|
|
36
|
-
*/
|
|
37
|
-
export declare function createExpiringConfig<Type>({ fetchValue, key, onCacheHit, onFetch, onRevalidate, store, ttl, validateValue, }: ExpiringConfigOptions<Type>): ExpiringConfigApi<Type>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Loads the `getStudioEnvironmentVariables` function from the studio's
|
|
3
|
-
* installed `sanity` package and returns the environment variables.
|
|
4
|
-
*
|
|
5
|
-
* This is used to ensure we're using the same version of environment variable
|
|
6
|
-
* logic as the studio itself.
|
|
7
|
-
*
|
|
8
|
-
* @param rootPath - The root path of the Sanity Studio project
|
|
9
|
-
* @returns Object containing studio environment variables
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
export declare function getStudioEnvironmentVariables(rootPath: string): Promise<Record<string, string>>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mocks a browser-like environment for processes in the main thread by:
|
|
3
|
-
* - Injecting browser globals (window, document, ResizeObserver, etc.)
|
|
4
|
-
* - Loading studio environment variables from the project's sanity installation into process.env
|
|
5
|
-
*
|
|
6
|
-
* This is useful for commands like `sanity exec` that have to run user scripts
|
|
7
|
-
* in the main thread of the process (but in a child process).
|
|
8
|
-
*
|
|
9
|
-
* Be cautious when using this, since it will pollute the global namespace with browser globals.
|
|
10
|
-
*
|
|
11
|
-
* If your code can run in a worker thread, you should use the `studioWorkerTask` function instead.
|
|
12
|
-
*
|
|
13
|
-
* @param basePath - The root path of the Sanity Studio project
|
|
14
|
-
* @returns A cleanup function that removes the injected globals and environment variables
|
|
15
|
-
* @internal
|
|
16
|
-
*/
|
|
17
|
-
export declare function mockBrowserEnvironment(basePath: string): Promise<() => void>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sets up browser globals (window, document, etc.) in the global scope.
|
|
3
|
-
*
|
|
4
|
-
* This is used by both mockBrowserEnvironment (for child processes) and
|
|
5
|
-
* studioWorkerLoader (for worker threads) to provide a browser-like environment.
|
|
6
|
-
*
|
|
7
|
-
* @returns A cleanup function that removes the injected globals
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export declare function setupBrowserStubs(): Promise<() => void>;
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
export declare const alert: (message?: any) => void;
|
|
2
|
-
export declare const atob: (data: string) => string;
|
|
3
|
-
export declare const blur: () => void;
|
|
4
|
-
export declare const btoa: (data: string) => string;
|
|
5
|
-
export declare const cancelAnimationFrame: (handle: number) => void;
|
|
6
|
-
export declare const captureEvents: () => void;
|
|
7
|
-
export declare const clearInterval: (id: number | undefined) => void;
|
|
8
|
-
export declare const clearTimeout: (id: number | undefined) => void;
|
|
9
|
-
export declare const close: () => void;
|
|
10
|
-
export declare const confirm: (message?: string) => boolean;
|
|
11
|
-
export declare const console: any;
|
|
12
|
-
export declare const crypto: Crypto;
|
|
13
|
-
export declare const CSSImportRule: {
|
|
14
|
-
new (): CSSImportRule;
|
|
15
|
-
prototype: CSSImportRule;
|
|
16
|
-
};
|
|
17
|
-
export declare const CSSMediaRule: {
|
|
18
|
-
new (): CSSMediaRule;
|
|
19
|
-
prototype: CSSMediaRule;
|
|
20
|
-
};
|
|
21
|
-
export declare const CSSRule: {
|
|
22
|
-
new (): CSSRule;
|
|
23
|
-
prototype: CSSRule;
|
|
24
|
-
readonly STYLE_RULE: 1;
|
|
25
|
-
readonly CHARSET_RULE: 2;
|
|
26
|
-
readonly IMPORT_RULE: 3;
|
|
27
|
-
readonly MEDIA_RULE: 4;
|
|
28
|
-
readonly FONT_FACE_RULE: 5;
|
|
29
|
-
readonly PAGE_RULE: 6;
|
|
30
|
-
readonly NAMESPACE_RULE: 10;
|
|
31
|
-
readonly KEYFRAMES_RULE: 7;
|
|
32
|
-
readonly KEYFRAME_RULE: 8;
|
|
33
|
-
readonly SUPPORTS_RULE: 12;
|
|
34
|
-
readonly COUNTER_STYLE_RULE: 11;
|
|
35
|
-
readonly FONT_FEATURE_VALUES_RULE: 14;
|
|
36
|
-
};
|
|
37
|
-
export declare const CSSStyleDeclaration: {
|
|
38
|
-
new (): CSSStyleDeclaration;
|
|
39
|
-
prototype: CSSStyleDeclaration;
|
|
40
|
-
};
|
|
41
|
-
export declare const CSSStyleRule: {
|
|
42
|
-
new (): CSSStyleRule;
|
|
43
|
-
prototype: CSSStyleRule;
|
|
44
|
-
};
|
|
45
|
-
export declare const CSSStyleSheet: {
|
|
46
|
-
new (options?: CSSStyleSheetInit): CSSStyleSheet;
|
|
47
|
-
prototype: CSSStyleSheet;
|
|
48
|
-
};
|
|
49
|
-
export declare const customElements: CustomElementRegistry;
|
|
50
|
-
export declare const devicePixelRatio: number;
|
|
51
|
-
export declare const document: Document;
|
|
52
|
-
export declare const event: Event | undefined;
|
|
53
|
-
export declare const external: External;
|
|
54
|
-
export declare const focus: () => void;
|
|
55
|
-
export declare const frameElement: Element | null;
|
|
56
|
-
export declare const frames: Window;
|
|
57
|
-
export declare const getComputedStyle: (elt: Element, pseudoElt?: string | null) => CSSStyleDeclaration;
|
|
58
|
-
export declare const getSelection: () => Selection | null;
|
|
59
|
-
export declare const history: History;
|
|
60
|
-
export declare const innerHeight: number;
|
|
61
|
-
export declare const innerWidth: number;
|
|
62
|
-
export declare const length: number;
|
|
63
|
-
export declare const localStorage: Storage;
|
|
64
|
-
export declare const location: Location;
|
|
65
|
-
export declare const locationbar: BarProp;
|
|
66
|
-
export declare const MediaList: {
|
|
67
|
-
new (): MediaList;
|
|
68
|
-
prototype: MediaList;
|
|
69
|
-
};
|
|
70
|
-
export declare const menubar: BarProp;
|
|
71
|
-
export declare const moveBy: (x: number, y: number) => void;
|
|
72
|
-
export declare const moveTo: (x: number, y: number) => void;
|
|
73
|
-
export declare const name: string;
|
|
74
|
-
export declare const navigator: Navigator;
|
|
75
|
-
export declare const onabort: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null;
|
|
76
|
-
export declare const onafterprint: ((this: WindowEventHandlers, ev: Event) => any) | null;
|
|
77
|
-
export declare const onautocomplete: any;
|
|
78
|
-
export declare const onautocompleteerror: any;
|
|
79
|
-
export declare const onauxclick: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
80
|
-
export declare const onbeforeinput: ((this: GlobalEventHandlers, ev: InputEvent) => any) | null;
|
|
81
|
-
export declare const onbeforematch: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
82
|
-
export declare const onbeforeprint: ((this: WindowEventHandlers, ev: Event) => any) | null;
|
|
83
|
-
export declare const onbeforetoggle: ((this: GlobalEventHandlers, ev: ToggleEvent) => any) | null;
|
|
84
|
-
export declare const onbeforeunload: ((this: WindowEventHandlers, ev: BeforeUnloadEvent) => any) | null;
|
|
85
|
-
export declare const onblur: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null;
|
|
86
|
-
export declare const oncancel: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
87
|
-
export declare const oncanplay: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
88
|
-
export declare const oncanplaythrough: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
89
|
-
export declare const onchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
90
|
-
export declare const onclick: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
91
|
-
export declare const onclose: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
92
|
-
export declare const oncontextlost: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
93
|
-
export declare const oncontextmenu: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
94
|
-
export declare const oncontextrestored: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
95
|
-
export declare const oncopy: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null;
|
|
96
|
-
export declare const oncuechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
97
|
-
export declare const oncut: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null;
|
|
98
|
-
export declare const ondblclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
99
|
-
export declare const ondrag: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
100
|
-
export declare const ondragend: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
101
|
-
export declare const ondragenter: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
102
|
-
export declare const ondragleave: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
103
|
-
export declare const ondragover: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
104
|
-
export declare const ondragstart: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
105
|
-
export declare const ondrop: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
106
|
-
export declare const ondurationchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
107
|
-
export declare const onemptied: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
108
|
-
export declare const onended: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
109
|
-
export declare const onerror: OnErrorEventHandler;
|
|
110
|
-
export declare const onfocus: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null;
|
|
111
|
-
export declare const onformdata: ((this: GlobalEventHandlers, ev: FormDataEvent) => any) | null;
|
|
112
|
-
export declare const onhashchange: ((this: WindowEventHandlers, ev: HashChangeEvent) => any) | null;
|
|
113
|
-
export declare const oninput: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
114
|
-
export declare const oninvalid: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
115
|
-
export declare const onkeydown: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null;
|
|
116
|
-
export declare const onkeypress: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null;
|
|
117
|
-
export declare const onkeyup: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null;
|
|
118
|
-
export declare const onlanguagechange: ((this: WindowEventHandlers, ev: Event) => any) | null;
|
|
119
|
-
export declare const onload: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
120
|
-
export declare const onloadeddata: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
121
|
-
export declare const onloadedmetadata: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
122
|
-
export declare const onloadstart: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
123
|
-
export declare const onmessage: ((this: WindowEventHandlers, ev: MessageEvent) => any) | null;
|
|
124
|
-
export declare const onmessageerror: ((this: WindowEventHandlers, ev: MessageEvent) => any) | null;
|
|
125
|
-
export declare const onmousedown: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
126
|
-
export declare const onmouseenter: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
127
|
-
export declare const onmouseleave: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
128
|
-
export declare const onmousemove: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
129
|
-
export declare const onmouseout: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
130
|
-
export declare const onmouseover: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
131
|
-
export declare const onmouseup: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
132
|
-
export declare const onoffline: ((this: WindowEventHandlers, ev: Event) => any) | null;
|
|
133
|
-
export declare const ononline: ((this: WindowEventHandlers, ev: Event) => any) | null;
|
|
134
|
-
export declare const onpagehide: ((this: WindowEventHandlers, ev: PageTransitionEvent) => any) | null;
|
|
135
|
-
export declare const onpageshow: ((this: WindowEventHandlers, ev: PageTransitionEvent) => any) | null;
|
|
136
|
-
export declare const onpaste: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null;
|
|
137
|
-
export declare const onpause: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
138
|
-
export declare const onplay: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
139
|
-
export declare const onplaying: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
140
|
-
export declare const onpopstate: ((this: WindowEventHandlers, ev: PopStateEvent) => any) | null;
|
|
141
|
-
export declare const onprogress: ((this: GlobalEventHandlers, ev: ProgressEvent) => any) | null;
|
|
142
|
-
export declare const onratechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
143
|
-
export declare const onrejectionhandled: ((this: WindowEventHandlers, ev: PromiseRejectionEvent) => any) | null;
|
|
144
|
-
export declare const onreset: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
145
|
-
export declare const onresize: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null;
|
|
146
|
-
export declare const onscroll: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
147
|
-
export declare const onscrollend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
148
|
-
export declare const onsecuritypolicyviolation: ((this: GlobalEventHandlers, ev: SecurityPolicyViolationEvent) => any) | null;
|
|
149
|
-
export declare const onseeked: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
150
|
-
export declare const onseeking: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
151
|
-
export declare const onselect: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
152
|
-
export declare const onslotchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
153
|
-
export declare const onsort: any;
|
|
154
|
-
export declare const onstalled: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
155
|
-
export declare const onstorage: ((this: WindowEventHandlers, ev: StorageEvent) => any) | null;
|
|
156
|
-
export declare const onsubmit: ((this: GlobalEventHandlers, ev: SubmitEvent) => any) | null;
|
|
157
|
-
export declare const onsuspend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
158
|
-
export declare const ontimeupdate: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
159
|
-
export declare const ontoggle: ((this: GlobalEventHandlers, ev: ToggleEvent) => any) | null;
|
|
160
|
-
export declare const ontouchcancel: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
|
|
161
|
-
export declare const ontouchend: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
|
|
162
|
-
export declare const ontouchmove: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
|
|
163
|
-
export declare const ontouchstart: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
|
|
164
|
-
export declare const onunhandledrejection: ((this: WindowEventHandlers, ev: PromiseRejectionEvent) => any) | null;
|
|
165
|
-
export declare const onunload: ((this: WindowEventHandlers, ev: Event) => any) | null;
|
|
166
|
-
export declare const onvolumechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
167
|
-
export declare const onwaiting: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
168
|
-
export declare const onwebkitanimationend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
169
|
-
export declare const onwebkitanimationiteration: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
170
|
-
export declare const onwebkitanimationstart: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
171
|
-
export declare const onwebkittransitionend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
172
|
-
export declare const onwheel: ((this: GlobalEventHandlers, ev: WheelEvent) => any) | null;
|
|
173
|
-
export declare const open: (url?: string | URL, target?: string, features?: string) => WindowProxy | null;
|
|
174
|
-
export declare const origin: string;
|
|
175
|
-
export declare const outerHeight: number;
|
|
176
|
-
export declare const outerWidth: number;
|
|
177
|
-
export declare const pageXOffset: number;
|
|
178
|
-
export declare const pageYOffset: number;
|
|
179
|
-
export declare const parent: Window;
|
|
180
|
-
export declare const performance: Performance;
|
|
181
|
-
export declare const personalbar: BarProp;
|
|
182
|
-
export declare const postMessage: {
|
|
183
|
-
(message: any, targetOrigin: string, transfer?: Transferable[]): void;
|
|
184
|
-
(message: any, options?: WindowPostMessageOptions): void;
|
|
185
|
-
};
|
|
186
|
-
export declare const print: () => void;
|
|
187
|
-
export declare const prompt: (message?: string, _default?: string) => string | null;
|
|
188
|
-
export declare const queueMicrotask: (callback: VoidFunction) => void;
|
|
189
|
-
export declare const releaseEvents: () => void;
|
|
190
|
-
export declare const requestAnimationFrame: (callback: FrameRequestCallback) => number;
|
|
191
|
-
export declare const resizeBy: (x: number, y: number) => void;
|
|
192
|
-
export declare const resizeTo: (width: number, height: number) => void;
|
|
193
|
-
export declare const screen: Screen;
|
|
194
|
-
export declare const screenLeft: number;
|
|
195
|
-
export declare const screenTop: number;
|
|
196
|
-
export declare const screenX: number;
|
|
197
|
-
export declare const screenY: number;
|
|
198
|
-
export declare const scroll: {
|
|
199
|
-
(options?: ScrollToOptions): void;
|
|
200
|
-
(x: number, y: number): void;
|
|
201
|
-
};
|
|
202
|
-
export declare const scrollbars: BarProp;
|
|
203
|
-
export declare const scrollBy: {
|
|
204
|
-
(options?: ScrollToOptions): void;
|
|
205
|
-
(x: number, y: number): void;
|
|
206
|
-
};
|
|
207
|
-
export declare const scrollTo: {
|
|
208
|
-
(options?: ScrollToOptions): void;
|
|
209
|
-
(x: number, y: number): void;
|
|
210
|
-
};
|
|
211
|
-
export declare const scrollX: number;
|
|
212
|
-
export declare const scrollY: number;
|
|
213
|
-
export declare const self: import("jsdom").DOMWindow;
|
|
214
|
-
export declare const sessionStorage: Storage;
|
|
215
|
-
export declare const setInterval: (handler: TimerHandler, timeout?: number, ...arguments: any[]) => number;
|
|
216
|
-
export declare const setTimeout: (handler: TimerHandler, timeout?: number, ...arguments: any[]) => number;
|
|
217
|
-
export declare const status: string;
|
|
218
|
-
export declare const statusbar: BarProp;
|
|
219
|
-
export declare const stop: () => void;
|
|
220
|
-
export declare const StyleSheet: {
|
|
221
|
-
new (): StyleSheet;
|
|
222
|
-
prototype: StyleSheet;
|
|
223
|
-
};
|
|
224
|
-
export declare const toolbar: BarProp;
|
|
225
|
-
export declare const top: import("jsdom").DOMWindow;
|
|
226
|
-
export declare const window: import("jsdom").DOMWindow;
|
|
227
|
-
export declare const XPathEvaluator: {
|
|
228
|
-
new (): XPathEvaluator;
|
|
229
|
-
prototype: XPathEvaluator;
|
|
230
|
-
};
|
|
231
|
-
export declare const XPathException: any;
|
|
232
|
-
export declare const XPathExpression: {
|
|
233
|
-
new (): XPathExpression;
|
|
234
|
-
prototype: XPathExpression;
|
|
235
|
-
};
|
|
236
|
-
export declare const XPathResult: {
|
|
237
|
-
new (): XPathResult;
|
|
238
|
-
prototype: XPathResult;
|
|
239
|
-
readonly ANY_TYPE: 0;
|
|
240
|
-
readonly NUMBER_TYPE: 1;
|
|
241
|
-
readonly STRING_TYPE: 2;
|
|
242
|
-
readonly BOOLEAN_TYPE: 3;
|
|
243
|
-
readonly UNORDERED_NODE_ITERATOR_TYPE: 4;
|
|
244
|
-
readonly ORDERED_NODE_ITERATOR_TYPE: 5;
|
|
245
|
-
readonly UNORDERED_NODE_SNAPSHOT_TYPE: 6;
|
|
246
|
-
readonly ORDERED_NODE_SNAPSHOT_TYPE: 7;
|
|
247
|
-
readonly ANY_UNORDERED_NODE_TYPE: 8;
|
|
248
|
-
readonly FIRST_ORDERED_NODE_TYPE: 9;
|
|
249
|
-
};
|
|
250
|
-
export declare const requestIdleCallback: (callback: IdleRequestCallback, options?: IdleRequestOptions) => number;
|
|
251
|
-
export declare const cancelIdleCallback: (handle: number) => void;
|
|
252
|
-
export declare const ResizeObserver: any;
|
|
253
|
-
export declare const IntersectionObserver: any;
|
|
254
|
-
export declare const matchMedia: (query: string) => MediaQueryList;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if a file exists and can be "accessed".
|
|
3
|
-
* Prone to race conditions, but good enough for our use cases.
|
|
4
|
-
*
|
|
5
|
-
* @param filePath - The path to the file to check
|
|
6
|
-
* @returns A promise that resolves to true if the file exists, false otherwise
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
export declare function fileExists(filePath: string): Promise<boolean>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gets an environment variable with the appropriate Sanity prefix based on whether it's an app or studio.
|
|
3
|
-
*
|
|
4
|
-
* @param suffix - The suffix for the environment variable (e.g., 'SERVER_HOSTNAME')
|
|
5
|
-
* @param isApp - Whether to use the app prefix (SANITY_APP_) or studio prefix (SANITY_STUDIO_)
|
|
6
|
-
* @returns The value of the environment variable, or undefined if not set
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* // For studio: SANITY_STUDIO_SERVER_HOSTNAME
|
|
11
|
-
* const studioHostname = getSanityEnvVar('SERVER_HOSTNAME', false)
|
|
12
|
-
*
|
|
13
|
-
* // For app: SANITY_APP_SERVER_HOSTNAME
|
|
14
|
-
* const appHostname = getSanityEnvVar('SERVER_HOSTNAME', true)
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
export declare function getSanityEnvVar(suffix: string, isApp: boolean): string | undefined;
|
package/dist/util/isCi.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isCi: () => boolean;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Incomplete error type for [get-it](https://github.com/sanity-io/get-it)
|
|
3
|
-
* `httpError` middleware. Should preferably be tidied up and exported
|
|
4
|
-
* from that module. Feel free to do so if you've got time! 🙏
|
|
5
|
-
*
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
interface HttpError {
|
|
9
|
-
request: {
|
|
10
|
-
headers: unknown;
|
|
11
|
-
};
|
|
12
|
-
response: {
|
|
13
|
-
body: unknown;
|
|
14
|
-
method: string;
|
|
15
|
-
statusCode: number;
|
|
16
|
-
statusMessage: string;
|
|
17
|
-
url: string;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Checks if the given `err` is an instance of `HttpError` from `get-it`
|
|
22
|
-
* (request library used by `@sanity/client`).
|
|
23
|
-
*
|
|
24
|
-
* @param err - The error to check
|
|
25
|
-
* @returns `true` if the error is an instance of `HttpError`, otherwise `false`
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
28
|
-
export declare function isHttpError(err: unknown): err is HttpError;
|
|
29
|
-
export {};
|
package/dist/util/isHttpError.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Incomplete error type for [get-it](https://github.com/sanity-io/get-it)
|
|
3
|
-
* `httpError` middleware. Should preferably be tidied up and exported
|
|
4
|
-
* from that module. Feel free to do so if you've got time! 🙏
|
|
5
|
-
*
|
|
6
|
-
* @internal
|
|
7
|
-
*/ /**
|
|
8
|
-
* Checks if the given `err` is an instance of `HttpError` from `get-it`
|
|
9
|
-
* (request library used by `@sanity/client`).
|
|
10
|
-
*
|
|
11
|
-
* @param err - The error to check
|
|
12
|
-
* @returns `true` if the error is an instance of `HttpError`, otherwise `false`
|
|
13
|
-
* @internal
|
|
14
|
-
*/ export function isHttpError(err) {
|
|
15
|
-
return err instanceof Error && 'request' in err && 'response' in err && typeof err.response === 'object' && err.response !== null && 'statusCode' in err.response && typeof err.response.statusCode === 'number';
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
//# sourceMappingURL=isHttpError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/isHttpError.ts"],"sourcesContent":["/**\n * Incomplete error type for [get-it](https://github.com/sanity-io/get-it)\n * `httpError` middleware. Should preferably be tidied up and exported\n * from that module. Feel free to do so if you've got time! 🙏\n *\n * @internal\n */\ninterface HttpError {\n request: {\n headers: unknown\n }\n response: {\n body: unknown\n method: string\n statusCode: number\n statusMessage: string\n url: string\n }\n}\n\n/**\n * Checks if the given `err` is an instance of `HttpError` from `get-it`\n * (request library used by `@sanity/client`).\n *\n * @param err - The error to check\n * @returns `true` if the error is an instance of `HttpError`, otherwise `false`\n * @internal\n */\nexport function isHttpError(err: unknown): err is HttpError {\n return (\n err instanceof Error &&\n 'request' in err &&\n 'response' in err &&\n typeof err.response === 'object' &&\n err.response !== null &&\n 'statusCode' in err.response &&\n typeof err.response.statusCode === 'number'\n )\n}\n"],"names":["isHttpError","err","Error","response","statusCode"],"mappings":"AAAA;;;;;;CAMC,GAcD;;;;;;;CAOC,GACD,OAAO,SAASA,YAAYC,GAAY;IACtC,OACEA,eAAeC,SACf,aAAaD,OACb,cAAcA,OACd,OAAOA,IAAIE,QAAQ,KAAK,YACxBF,IAAIE,QAAQ,KAAK,QACjB,gBAAgBF,IAAIE,QAAQ,IAC5B,OAAOF,IAAIE,QAAQ,CAACC,UAAU,KAAK;AAEvC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isInteractive(): boolean;
|
package/dist/util/isRecord.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if the given value is a record (javascript objectish)
|
|
3
|
-
*
|
|
4
|
-
* @param value - Value to check
|
|
5
|
-
* @returns True if the value is a record, false otherwise
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
package/dist/util/isTrueish.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isTrueish(value: string | undefined): boolean;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
type JSONValue = boolean | JSONArray | JSONObject | number | string | null;
|
|
2
|
-
type JSONObject = {
|
|
3
|
-
[key: string]: JSONValue;
|
|
4
|
-
};
|
|
5
|
-
type JSONArray = Array<JSONValue>;
|
|
6
|
-
/**
|
|
7
|
-
* Read the file at the given path and parse it as JSON.
|
|
8
|
-
*
|
|
9
|
-
* @param filePath - Path to JSON file to read
|
|
10
|
-
* @returns The parsed file
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
export declare function readJsonFile(filePath: string): Promise<JSONValue>;
|
|
14
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Serialize the given `data` as JSON and write it to the given path.
|
|
3
|
-
*
|
|
4
|
-
* @param filePath - Path to JSON file to read
|
|
5
|
-
* @internal
|
|
6
|
-
*/
|
|
7
|
-
export declare function writeJsonFile(filePath: string, data: unknown, options?: {
|
|
8
|
-
pretty?: boolean;
|
|
9
|
-
}): Promise<void>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function colorizeJson(input: unknown): string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function formatObject(obj: unknown): string;
|
package/dist/ux/logSymbols.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as logSymbols } from 'log-symbols';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function printKeyValue(obj: Record<string, unknown>): void;
|
package/dist/ux/spinner.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as spinner } from 'ora';
|
package/dist/ux/timer.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
interface TimeMeasurer {
|
|
2
|
-
end: (name: string) => number;
|
|
3
|
-
getTimings: () => Record<string, number>;
|
|
4
|
-
start: (name: string) => void;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Starts a terminal timer
|
|
8
|
-
*
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export declare function getTimer(): TimeMeasurer;
|
|
12
|
-
export {};
|