@sanity/sdk 3.0.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/dist/_exports/_internal.d.ts +72 -19
  2. package/dist/_exports/_internal.d.ts.map +1 -1
  3. package/dist/_exports/_internal.js +130 -11
  4. package/dist/_exports/_internal.js.map +1 -1
  5. package/dist/_exports/agent.d.ts +7 -7
  6. package/dist/_exports/agent.d.ts.map +1 -1
  7. package/dist/_exports/agent.js +1 -1
  8. package/dist/_exports/comlink.d.ts +9 -9
  9. package/dist/_exports/comlink.d.ts.map +1 -1
  10. package/dist/_exports/comlink.js +2 -2
  11. package/dist/_exports/dashboard.d.ts +2 -0
  12. package/dist/_exports/dashboard.js +2 -0
  13. package/dist/{authStore-C0o1NOxW.d.ts → authStore-BO2vch3I.d.ts} +516 -63
  14. package/dist/authStore-BO2vch3I.d.ts.map +1 -0
  15. package/dist/{authStore-CtE9bLHW.js → clientStore-BI4D8HhJ.js} +390 -15
  16. package/dist/clientStore-BI4D8HhJ.js.map +1 -0
  17. package/dist/{createSanityInstance-DUI1bGIg.d.ts → createSanityInstance-BQIqyGLX.d.ts} +17 -2
  18. package/dist/createSanityInstance-BQIqyGLX.d.ts.map +1 -0
  19. package/dist/{createStateSourceAction-BOKtqFNm.js → createStateSourceAction-DdAhEfnZ.js} +7 -3
  20. package/dist/createStateSourceAction-DdAhEfnZ.js.map +1 -0
  21. package/dist/defineProperty-Bho9Ngsi.js +31 -0
  22. package/dist/{getNodeState-CR3__B2D.js → getNodeState-B4nG0sjm.js} +2 -2
  23. package/dist/{getNodeState-CR3__B2D.js.map → getNodeState-B4nG0sjm.js.map} +1 -1
  24. package/dist/index.d.ts +3 -3
  25. package/dist/index.js +370 -90
  26. package/dist/index.js.map +1 -1
  27. package/dist/topicStore-Ct7IFNtY.js +565 -0
  28. package/dist/topicStore-Ct7IFNtY.js.map +1 -0
  29. package/dist/topicStore-D0WqhQGF.d.ts +435 -0
  30. package/dist/topicStore-D0WqhQGF.d.ts.map +1 -0
  31. package/dist/{queryStore-C7yMHPUI.js → version-BcRmCiYi.js} +48 -16
  32. package/dist/version-BcRmCiYi.js.map +1 -0
  33. package/package.json +19 -18
  34. package/src/_exports/_internal.ts +13 -0
  35. package/src/_exports/dashboard.ts +36 -0
  36. package/src/_exports/index.ts +17 -1
  37. package/src/access/checkPermissions.test.ts +1 -1
  38. package/src/access/checkPermissions.ts +1 -1
  39. package/src/applications/applications.test-d.ts +28 -4
  40. package/src/applications/applications.test.ts +4 -4
  41. package/src/applications/applications.ts +43 -18
  42. package/src/auth/authMode.test.ts +24 -0
  43. package/src/auth/authMode.ts +8 -3
  44. package/src/auth/authStore.ts +12 -0
  45. package/src/auth/authStrategy.ts +2 -0
  46. package/src/auth/handleAuthCallback.test.ts +2 -2
  47. package/src/auth/handleAuthCallback.ts +1 -1
  48. package/src/auth/logout.test.ts +46 -1
  49. package/src/auth/logout.ts +2 -1
  50. package/src/auth/oauth/oauthActions.test.ts +457 -0
  51. package/src/auth/oauth/oauthActions.ts +389 -0
  52. package/src/auth/oauth/oauthAuth.test.ts +206 -0
  53. package/src/auth/oauth/oauthAuth.ts +168 -0
  54. package/src/auth/oauth/pkce.test.ts +44 -0
  55. package/src/auth/oauth/pkce.ts +60 -0
  56. package/src/auth/oauth/types.ts +12 -0
  57. package/src/auth/refreshStampedToken.ts +1 -1
  58. package/src/auth/studioModeAuth.test.ts +1 -1
  59. package/src/auth/studioModeAuth.ts +1 -1
  60. package/src/auth/subscribeToStateAndFetchCurrentUser.test.ts +2 -2
  61. package/src/auth/subscribeToStateAndFetchCurrentUser.ts +1 -1
  62. package/src/comments/addonDatasetStore.test.ts +2 -2
  63. package/src/comments/addonDatasetStore.ts +2 -2
  64. package/src/comments/commentActions.ts +6 -5
  65. package/src/comments/commentsStore.ts +4 -4
  66. package/src/config/authConfig.ts +18 -0
  67. package/src/dashboard/messageBus/__fixtures__/test-topics.ts +18 -0
  68. package/src/dashboard/messageBus/bus.test.ts +1033 -0
  69. package/src/dashboard/messageBus/bus.ts +1246 -0
  70. package/src/dashboard/messageBus/store.test.ts +142 -0
  71. package/src/dashboard/messageBus/store.ts +74 -0
  72. package/src/dashboard/messageBus/topicStore.test.ts +172 -0
  73. package/src/dashboard/messageBus/topicStore.ts +184 -0
  74. package/src/dashboard/messageBus/topics.test.ts +71 -0
  75. package/src/dashboard/messageBus/topics.ts +260 -0
  76. package/src/document/actions.ts +3 -3
  77. package/src/document/applyDocumentActions.ts +5 -9
  78. package/src/document/documentStore.concurrency.test.ts +2 -1
  79. package/src/document/documentStore.test.ts +19 -18
  80. package/src/document/documentStore.ts +17 -17
  81. package/src/document/permissions.ts +2 -1
  82. package/src/document/processActions.test.ts +2 -1
  83. package/src/document/processMutations.ts +61 -24
  84. package/src/document/reducers.ts +2 -2
  85. package/src/installations/installations.test-d.ts +3 -3
  86. package/src/installations/installations.test.ts +2 -2
  87. package/src/installations/installations.ts +4 -21
  88. package/src/organization/organization.test.ts +2 -2
  89. package/src/organization/organization.ts +1 -1
  90. package/src/organizations/organizations.test.ts +2 -2
  91. package/src/organizations/organizations.ts +1 -1
  92. package/src/presence/presenceStore.test.ts +15 -22
  93. package/src/presence/presenceStore.ts +3 -2
  94. package/src/project/project.test.ts +3 -3
  95. package/src/project/project.ts +1 -1
  96. package/src/projection/getProjectionState.test.ts +6 -4
  97. package/src/projection/getProjectionState.ts +4 -4
  98. package/src/projection/resolveProjection.ts +2 -2
  99. package/src/projects/projects.test.ts +2 -2
  100. package/src/projects/projects.ts +1 -1
  101. package/src/query/queryStore.ts +6 -6
  102. package/src/store/createSanityInstance.test.ts +1 -1
  103. package/src/store/createSanityInstance.ts +4 -4
  104. package/src/store/createStoreInstance.test.ts +0 -5
  105. package/src/telemetry/telemetryManager.test.ts +1 -1
  106. package/src/telemetry/telemetryManager.ts +2 -2
  107. package/src/typegen/defineProjection.test.ts +17 -0
  108. package/src/typegen/defineProjection.ts +19 -0
  109. package/src/typegen/groqCompat.ts +122 -0
  110. package/src/typegen/resolve.ts +37 -0
  111. package/src/users/usersStore.test.ts +1 -1
  112. package/src/users/usersStore.ts +5 -5
  113. package/src/utils/createGroqSearchFilter.test.ts +8 -0
  114. package/src/utils/createGroqSearchFilter.ts +6 -3
  115. package/src/utils/ids.test.ts +40 -15
  116. package/src/utils/ids.ts +47 -2
  117. package/dist/authStore-C0o1NOxW.d.ts.map +0 -1
  118. package/dist/authStore-CtE9bLHW.js.map +0 -1
  119. package/dist/clientStore-BtE2-q2i.js +0 -90
  120. package/dist/clientStore-BtE2-q2i.js.map +0 -1
  121. package/dist/createSanityInstance-DUI1bGIg.d.ts.map +0 -1
  122. package/dist/createStateSourceAction-BOKtqFNm.js.map +0 -1
  123. package/dist/getEnv-D5RGkQLu.js +0 -8
  124. package/dist/getEnv-D5RGkQLu.js.map +0 -1
  125. package/dist/logger-DAtJb5RQ.js +0 -173
  126. package/dist/logger-DAtJb5RQ.js.map +0 -1
  127. package/dist/queryStore-C7yMHPUI.js.map +0 -1
  128. package/dist/rolldown-runtime-vyAXikos.js +0 -9
  129. package/dist/telemetryManager-UIEiMtC0.js +0 -127
  130. package/dist/telemetryManager-UIEiMtC0.js.map +0 -1
  131. package/dist/version-D8RP_Q59.js +0 -9
  132. package/dist/version-D8RP_Q59.js.map +0 -1
@@ -6,7 +6,7 @@ import {createSanityInstance} from './createSanityInstance'
6
6
  describe('createSanityInstance', () => {
7
7
  it('should create an instance with a unique instanceId and given config', () => {
8
8
  const instance = createSanityInstance({projectId: 'proj1', dataset: 'ds1'})
9
- expect(typeof instance.instanceId).toBe('string')
9
+ expect(instance.instanceId).toMatch(/^[a-zA-Z0-9]{16}$/)
10
10
  expect(instance.config).toEqual({projectId: 'proj1', dataset: 'ds1'})
11
11
  expect(instance.isDisposed()).toBe(false)
12
12
  })
@@ -1,5 +1,5 @@
1
1
  import {type SanityConfig} from '../config/sanityConfig'
2
- import {insecureRandomId} from '../utils/ids'
2
+ import {randomId} from '../utils/ids'
3
3
  import {createLogger, type InstanceContext} from '../utils/logger'
4
4
 
5
5
  /**
@@ -10,7 +10,7 @@ import {createLogger, type InstanceContext} from '../utils/logger'
10
10
  export interface SanityInstance {
11
11
  /**
12
12
  * Unique identifier for this instance
13
- * @remarks Generated using crypto.randomUUID()
13
+ * @remarks Generated as a random 16-character alphanumeric ID
14
14
  */
15
15
  readonly instanceId: string
16
16
 
@@ -47,7 +47,7 @@ export interface SanityInstance {
47
47
  * @public
48
48
  */
49
49
  export function createSanityInstance(config: SanityConfig = {}): SanityInstance {
50
- const instanceId = crypto.randomUUID()
50
+ const instanceId = randomId(16)
51
51
  const disposeListeners = new Map<string, () => void>()
52
52
  const disposed = {current: false}
53
53
 
@@ -99,7 +99,7 @@ export function createSanityInstance(config: SanityConfig = {}): SanityInstance
99
99
  logger.info('Instance disposed')
100
100
  },
101
101
  onDispose: (cb) => {
102
- const listenerId = insecureRandomId()
102
+ const listenerId = randomId(16)
103
103
  disposeListeners.set(listenerId, cb)
104
104
  return () => {
105
105
  disposeListeners.delete(listenerId)
@@ -8,11 +8,6 @@ describe('createStoreInstance', () => {
8
8
  let instance: ReturnType<typeof createSanityInstance>
9
9
 
10
10
  beforeEach(() => {
11
- // Mock crypto for predictable instance IDs
12
- vi.stubGlobal('crypto', {
13
- randomUUID: () => 'test-uuid-1234',
14
- })
15
-
16
11
  instance = createSanityInstance({projectId: 'test', dataset: 'test'})
17
12
  })
18
13
 
@@ -280,7 +280,7 @@ describe('createTelemetryManager', () => {
280
280
  const result = await manager.checkConsent()
281
281
  expect(result).toBe(true)
282
282
  expect(mockClient.request).toHaveBeenCalledWith(
283
- expect.objectContaining({uri: '/intake/telemetry-status'}),
283
+ expect.objectContaining({url: '/intake/telemetry-status'}),
284
284
  )
285
285
  })
286
286
 
@@ -86,7 +86,7 @@ export function createTelemetryManager(options: TelemetryManagerOptions): Teleme
86
86
  try {
87
87
  const client = getClient()
88
88
  const result = await client.request<{status: ConsentStatus}>({
89
- uri: '/intake/telemetry-status',
89
+ url: '/intake/telemetry-status',
90
90
  tag: CONSENT_TAG,
91
91
  })
92
92
  cachedConsent = result
@@ -120,7 +120,7 @@ export function createTelemetryManager(options: TelemetryManagerOptions): Teleme
120
120
  const client = getClient()
121
121
  log.debug('sending event batch', {batchSize: batch.length, environment})
122
122
  return client.request({
123
- uri: '/intake/batch',
123
+ url: '/intake/batch',
124
124
  method: 'POST',
125
125
  body: {projectId, batch: enrichBatch(batch)},
126
126
  tag: BATCH_TAG,
@@ -0,0 +1,17 @@
1
+ import {describe, expect, expectTypeOf, it} from 'vitest'
2
+
3
+ import {defineProjection} from './defineProjection'
4
+
5
+ describe('defineProjection', () => {
6
+ it('returns the projection unchanged', () => {
7
+ const projection = '{name, "awardCount": count(awards)}'
8
+ expect(defineProjection(projection)).toBe(projection)
9
+ expectTypeOf(defineProjection(projection)).toEqualTypeOf<typeof projection>()
10
+ })
11
+
12
+ it('preserves whitespace used in existing generated projection keys', () => {
13
+ const projection = '{\n name,\n role\n}'
14
+ expect(defineProjection(projection)).toBe(projection)
15
+ expectTypeOf(defineProjection(projection)).toEqualTypeOf<typeof projection>()
16
+ })
17
+ })
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Preserves a projection string's literal type and returns the string unchanged.
3
+ * Use this import when migrating an app with existing experimental Typegen output.
4
+ *
5
+ * Current Typegen does not scan this helper. New or changed projections need an
6
+ * explicit result type until projection generation is supported.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const preview = defineProjection('{title, "author": author->name}')
11
+ * ```
12
+ *
13
+ * @beta
14
+ */
15
+ export function defineProjection<const TProjection extends string>(
16
+ projection: TProjection,
17
+ ): TProjection {
18
+ return projection
19
+ }
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Augments `groq` with the type surface of `groq@3.88.1-typegen-experimental.0`, the fork
3
+ * this package depended on before GA `groq`.
4
+ *
5
+ * A `sanity.types.ts` from the experimental Typegen flow imports these helpers from
6
+ * `groq` and augments these interfaces. GA `groq` exports only `defineQuery` and the
7
+ * template tag, so those files stop typechecking without this one.
8
+ *
9
+ * `defineProjection` is absent: it is a runtime function, and declaring it in a
10
+ * type-only augmentation turns a compile error into `undefined is not a function`.
11
+ * `@sanity/sdk` exports it instead.
12
+ *
13
+ * Keep these declarations while the SDK supports existing experimental generated files.
14
+ */
15
+
16
+ /* eslint-disable @typescript-eslint/no-empty-object-type -- augmentation targets:
17
+ generated files merge entries in, so they stay empty interfaces here. */
18
+ declare module 'groq' {
19
+ /**
20
+ * Brands a type with the resource it came from so one flat interface can hold entries
21
+ * from more than one schema; {@link PickSchema} narrows it back out.
22
+ */
23
+ export type SchemaOrigin<TBase, TSchemaId extends string> = TBase & {
24
+ /**
25
+ * @internal
26
+ * @deprecated typescript helper only
27
+ */
28
+ __schemaId?: TSchemaId
29
+ }
30
+
31
+ /**
32
+ * Brands a projection result with the document type it was evaluated against;
33
+ * {@link PickProjectionResult} narrows it back out.
34
+ */
35
+ export type ProjectionBase<TBase, TProjectionBaseTypeName extends string> = TBase & {
36
+ /**
37
+ * @internal
38
+ * @deprecated typescript helper only
39
+ */
40
+ __schemaTypeName?: TProjectionBaseTypeName
41
+ }
42
+
43
+ /** Extracts the members of `T` that came from the schema `TSchemaId`. */
44
+ export type PickSchema<T, TSchemaId extends string = string> = Extract<
45
+ T,
46
+ SchemaOrigin<T, TSchemaId>
47
+ >
48
+
49
+ /** Extracts the members of `T` projected from the document type `TProjectionBaseTypeName`. */
50
+ export type PickProjectionResult<T, TProjectionBaseTypeName extends string = string> = Extract<
51
+ T,
52
+ ProjectionBase<T, TProjectionBaseTypeName>
53
+ >
54
+
55
+ /** Augmented by generated files: resource key to the union of that schema's types. */
56
+ export interface SanitySchemas {}
57
+
58
+ /** Augmented by generated files: query string to its result type. */
59
+ export interface SanityQueries {}
60
+
61
+ /** Augmented by generated files: projection string to its result type. */
62
+ export interface SanityProjections {}
63
+
64
+ /**
65
+ * Indexes an augmented interface, falling back to the union of every registered value
66
+ * when the key is absent. Code generated against the fork relies on that fallback, so
67
+ * narrowing it to `never` changes what existing apps infer.
68
+ */
69
+ type SafeAccess<T, K extends string> = K extends keyof T ? T[K] : T[keyof T]
70
+
71
+ /** Fields Sanity adds to every document. */
72
+ interface SanityDocumentShape {
73
+ _id: string
74
+ _type: string
75
+ _createdAt: string
76
+ _updatedAt: string
77
+ _rev: string
78
+ [key: string]: unknown
79
+ }
80
+
81
+ /** All types registered for one resource. */
82
+ export type SanitySchema<TSchemaId extends string = string> = PickSchema<
83
+ SafeAccess<SanitySchemas, TSchemaId>,
84
+ TSchemaId
85
+ >
86
+
87
+ /** One schema type, selected by its `_type` and its resource. */
88
+ export type SanitySchemaType<
89
+ TSchemaTypeName extends string = string,
90
+ TSchemaId extends string = string,
91
+ > = Extract<SanitySchema<TSchemaId>, {_type: TSchemaTypeName}>
92
+
93
+ /** One document type, selected by its `_type` and its resource. */
94
+ export type SanityDocument<
95
+ TDocumentType extends string = string,
96
+ TSchemaId extends string = string,
97
+ > = Extract<
98
+ Extract<SanitySchema<TSchemaId>, SanityDocumentShape> | SanityDocumentShape,
99
+ {_type: TDocumentType}
100
+ >
101
+
102
+ /** The result of a registered query, for one resource. */
103
+ export type SanityQueryResult<
104
+ TQuery extends string = string,
105
+ TSchemaId extends string = string,
106
+ > = Extract<
107
+ SafeAccess<SanityQueries, TQuery>,
108
+ SchemaOrigin<SafeAccess<SanityQueries, TQuery>, TSchemaId>
109
+ >
110
+
111
+ /** The result of a registered projection, for one document type and one resource. */
112
+ export type SanityProjectionResult<
113
+ TProjection extends string = string,
114
+ TProjectionBaseTypeName extends string = string,
115
+ TSchemaId extends string = string,
116
+ > = PickSchema<
117
+ PickProjectionResult<SafeAccess<SanityProjections, TProjection>, TProjectionBaseTypeName>,
118
+ TSchemaId
119
+ >
120
+ }
121
+
122
+ export {}
@@ -0,0 +1,37 @@
1
+ import './groqCompat'
2
+
3
+ import {type SanityDocument, type SanityProjectionResult, type SanityQueryResult} from 'groq'
4
+
5
+ /**
6
+ * Resolves a document using declarations from experimental Typegen.
7
+ * Preserves the legacy lookup behavior while the SDK uses released `groq`.
8
+ *
9
+ * @beta
10
+ */
11
+ export type ResolveDocument<
12
+ TDocumentType extends string = string,
13
+ TSchemaId extends string = string,
14
+ > = SanityDocument<TDocumentType, TSchemaId>
15
+
16
+ /**
17
+ * Resolves a query using declarations from experimental Typegen.
18
+ * For types generated by current Typegen, pass the result type to the hook explicitly.
19
+ *
20
+ * @beta
21
+ */
22
+ export type ResolveQueryResult<
23
+ TQuery extends string = string,
24
+ TSchemaId extends string = string,
25
+ > = SanityQueryResult<TQuery, TSchemaId>
26
+
27
+ /**
28
+ * Resolves a projection using declarations from experimental Typegen.
29
+ * Selects the result by projection string, document type, and schema ID.
30
+ *
31
+ * @beta
32
+ */
33
+ export type ResolveProjectionResult<
34
+ TProjection extends string = string,
35
+ TDocumentType extends string = string,
36
+ TSchemaId extends string = string,
37
+ > = SanityProjectionResult<TProjection, TDocumentType, TSchemaId>
@@ -450,7 +450,7 @@ describe('usersStore', () => {
450
450
  )
451
451
  expect(specificRequest).toHaveBeenCalledWith({
452
452
  method: 'GET',
453
- uri: `/users/${projectUserId}`,
453
+ url: `/users/${projectUserId}`,
454
454
  tag: 'users.get',
455
455
  })
456
456
 
@@ -30,7 +30,7 @@ import {bindActionGlobally} from '../store/createActionBinder'
30
30
  import {createStateSourceAction, type SelectorContext} from '../store/createStateSourceAction'
31
31
  import {type StoreState} from '../store/createStoreState'
32
32
  import {defineStore, type StoreContext} from '../store/defineStore'
33
- import {insecureRandomId} from '../utils/ids'
33
+ import {randomId} from '../utils/ids'
34
34
  import {setCleanupTimeout} from '../utils/setCleanupTimeout'
35
35
  import {
36
36
  addSubscription,
@@ -130,7 +130,7 @@ const listenForLoadMoreAndFetch = ({state, instance}: StoreContext<UsersStoreSta
130
130
  return client.observable
131
131
  .request<PatchedSanityUserFromClient>({
132
132
  method: 'GET',
133
- uri: `/users/${userId}`,
133
+ url: `/users/${userId}`,
134
134
  tag: 'users.get',
135
135
  })
136
136
  .pipe(
@@ -184,7 +184,7 @@ const listenForLoadMoreAndFetch = ({state, instance}: StoreContext<UsersStoreSta
184
184
  return client.observable
185
185
  .request<SanityUser | SanityUserResponse>({
186
186
  method: 'GET',
187
- uri: `access/${resourceType}/${resourceId}/users/${userId}`,
187
+ url: `access/${resourceType}/${resourceId}/users/${userId}`,
188
188
  tag: 'users.get',
189
189
  })
190
190
  .pipe(
@@ -253,7 +253,7 @@ const listenForLoadMoreAndFetch = ({state, instance}: StoreContext<UsersStoreSta
253
253
  switchMap(([[resource, client], cursor]) =>
254
254
  client.observable.request<SanityUserResponse>({
255
255
  method: 'GET',
256
- uri: `access/${resource.type}/${resource.id}/users`,
256
+ url: `access/${resource.type}/${resource.id}/users`,
257
257
  tag: 'users.list',
258
258
  query: cursor
259
259
  ? {nextCursor: cursor, limit: batchSize.toString()}
@@ -310,7 +310,7 @@ export const getUsersState = bindActionGlobally(
310
310
  },
311
311
  ),
312
312
  onSubscribe: ({instance, state}, options?: GetUsersOptions) => {
313
- const subscriptionId = insecureRandomId()
313
+ const subscriptionId = randomId(16)
314
314
  const key = getUsersKey(instance, options)
315
315
  state.set('addSubscription', addSubscription(subscriptionId, key))
316
316
  return () => {
@@ -31,6 +31,14 @@ describe('createGroqSearchFilter', () => {
31
31
  )
32
32
  })
33
33
 
34
+ test('should escape backslashes so they cannot escape the closing quote', () => {
35
+ expect(createGroqSearchFilter('hello\\')).toBe('[@] match text::query("hello\\\\*")')
36
+ })
37
+
38
+ test('should escape backslashes inside an exact match phrase', () => {
39
+ expect(createGroqSearchFilter('"a\\b"')).toBe('[@] match text::query("\\"a\\\\b\\"")')
40
+ })
41
+
34
42
  test('should return empty string for empty input', () => {
35
43
  expect(createGroqSearchFilter('')).toBe('')
36
44
  })
@@ -34,7 +34,7 @@ function isExactMatchToken(token: string | undefined): boolean {
34
34
  * from a raw search query string.
35
35
  *
36
36
  * It applies wildcard ('*') logic to the last eligible token and escapes
37
- * double quotes within the search term.
37
+ * backslashes and double quotes within the search term.
38
38
  *
39
39
  * If the input query is empty or only whitespace, it returns an empty string.
40
40
  *
@@ -77,8 +77,11 @@ export function createGroqSearchFilter(query: string): string {
77
77
  // Join the tokens back into a space-separated string
78
78
  const wildcardSearch = processedTokens.join(' ')
79
79
 
80
- // Escape double quotes within the final search term for the GROQ query
81
- const escapedSearch = wildcardSearch.replace(/"/g, '\\"')
80
+ // Escape backslashes and double quotes within the final search term for the
81
+ // GROQ query. Backslashes go first, so the escapes added for quotes are not
82
+ // themselves escaped. Without this a trailing backslash would escape the
83
+ // closing quote and let the input break out of the string literal.
84
+ const escapedSearch = wildcardSearch.replace(/\\/g, '\\\\').replace(/"/g, '\\"')
82
85
 
83
86
  // Construct the final GROQ filter clause
84
87
  return `[@] match text::query("${escapedSearch}")`
@@ -1,26 +1,51 @@
1
- import {describe, expect, it} from 'vitest'
1
+ import {afterEach, describe, expect, it, vi} from 'vitest'
2
2
 
3
- import {insecureRandomId} from './ids'
3
+ import {randomId, randomUuid} from './ids'
4
4
 
5
- describe('insecureRandomId', () => {
6
- it('should generate 16-character string', () => {
7
- expect(insecureRandomId()).toHaveLength(16)
5
+ describe('randomId', () => {
6
+ it('should generate an 8-character base62 id by default', () => {
7
+ expect(randomId()).toMatch(/^[a-zA-Z0-9]{8}$/)
8
8
  })
9
9
 
10
- it('should generate hex string', () => {
11
- expect(insecureRandomId()).toMatch(/^[0-9a-f]{16}$/)
10
+ it('should generate an id of the given length', () => {
11
+ expect(randomId(16)).toMatch(/^[a-zA-Z0-9]{16}$/)
12
12
  })
13
13
 
14
14
  it('should generate different ids on each call', () => {
15
- const id1 = insecureRandomId()
16
- const id2 = insecureRandomId()
17
- expect(id1).not.toBe(id2)
15
+ expect(randomId()).not.toBe(randomId())
16
+ })
17
+ })
18
+
19
+ describe('randomUuid', () => {
20
+ const uuidV4Pattern = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/
21
+
22
+ afterEach(() => {
23
+ vi.unstubAllGlobals()
24
+ })
25
+
26
+ it('should generate a v4 UUID', () => {
27
+ expect(randomUuid()).toMatch(uuidV4Pattern)
28
+ })
29
+
30
+ it('should use crypto.randomUUID when available', () => {
31
+ vi.stubGlobal('crypto', {randomUUID: () => 'native-uuid'})
32
+ expect(randomUuid()).toBe('native-uuid')
33
+ })
34
+
35
+ it('should generate a v4 UUID when crypto.randomUUID is unavailable (insecure contexts)', () => {
36
+ const originalCrypto = globalThis.crypto
37
+ vi.stubGlobal('crypto', {
38
+ getRandomValues: (array: Uint8Array<ArrayBuffer>) => originalCrypto.getRandomValues(array),
39
+ })
40
+ expect(randomUuid()).toMatch(uuidV4Pattern)
18
41
  })
19
42
 
20
- it('should generate properly formatted strings multiple times', () => {
21
- for (let i = 0; i < 100; i++) {
22
- const id = insecureRandomId()
23
- expect(id).toMatch(/^[0-9a-f]{16}$/)
24
- }
43
+ it('should generate unique ids when crypto.randomUUID is unavailable', () => {
44
+ const originalCrypto = globalThis.crypto
45
+ vi.stubGlobal('crypto', {
46
+ getRandomValues: (array: Uint8Array<ArrayBuffer>) => originalCrypto.getRandomValues(array),
47
+ })
48
+ const ids = new Set(Array.from({length: 100}, () => randomUuid()))
49
+ expect(ids.size).toBe(100)
25
50
  })
26
51
  })
package/src/utils/ids.ts CHANGED
@@ -1,3 +1,48 @@
1
- export function insecureRandomId(): string {
2
- return Array.from({length: 16}, () => Math.floor(Math.random() * 16).toString(16)).join('')
1
+ const ID_ALPHABET = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
2
+
3
+ /**
4
+ * Generates a random ID of the given length from the alphabet `[a-zA-Z0-9]`, the same shape
5
+ * `@sanity/client` and Sanity Studio use for short IDs such as release IDs.
6
+ *
7
+ * Ported from `@sanity/client`'s `generateReleaseId`, which uses rejection sampling to keep
8
+ * the output unbiased. Uses `crypto.getRandomValues`, which unlike `crypto.randomUUID` is
9
+ * also available on insecure origins (plain http).
10
+ *
11
+ * @internal
12
+ */
13
+ export function randomId(length: number = 8): string {
14
+ let id = ''
15
+ while (id.length < length) {
16
+ const bytes = crypto.getRandomValues(new Uint8Array(length - id.length))
17
+ for (const byte of bytes) {
18
+ const index = byte & 63
19
+ if (index < ID_ALPHABET.length) id += ID_ALPHABET.charAt(index)
20
+ }
21
+ }
22
+ return id
23
+ }
24
+
25
+ /**
26
+ * Generates a random v4 UUID.
27
+ *
28
+ * Prefers the native `crypto.randomUUID`, which is only available in secure contexts
29
+ * (https, localhost). Falls back to deriving the UUID from `crypto.getRandomValues`,
30
+ * which has no such restriction, so ID generation also works when an app is served over
31
+ * plain http, e.g. when testing from a phone on a local network.
32
+ *
33
+ * @internal
34
+ */
35
+ export function randomUuid(): string {
36
+ // eslint-disable-next-line no-restricted-properties -- this is the sanctioned wrapper around crypto.randomUUID
37
+ if (typeof crypto.randomUUID === 'function') return crypto.randomUUID()
38
+
39
+ const bytes = crypto.getRandomValues(new Uint8Array(16))
40
+ const hex = Array.from(bytes, (byte, index) => {
41
+ // Set the version (4) and variant (RFC 4122) bits
42
+ if (index === 6) byte = (byte & 0x0f) | 0x40
43
+ if (index === 8) byte = (byte & 0x3f) | 0x80
44
+ return byte.toString(16).padStart(2, '0')
45
+ }).join('')
46
+
47
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`
3
48
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"authStore-C0o1NOxW.d.ts","names":[],"sources":["../src/store/createStoreState.ts","../src/store/defineStore.ts","../src/store/createActionBinder.ts","../src/store/createStateSourceAction.ts","../src/store/fetcherStore.ts","../src/access/checkPermissions.ts","../src/utils/includeShape.ts","../src/applications/applications.ts","../src/auth/authStateType.ts","../src/project/organizationVerification.ts","../src/auth/getOrganizationVerificationState.ts","../src/auth/handleAuthCallback.ts","../src/auth/logout.ts","../src/client/clientStore.ts","../src/comments/types.ts","../src/comments/commentActions.ts","../src/comments/commentsStore.ts","../src/config/handles.ts","../src/utils/logger.ts","../src/config/loggingConfig.ts","../src/datasets/datasets.ts","../src/document/actions.ts","../src/document/patchOperations.ts","../src/document/processMutations.ts","../src/document/permissions.ts","../src/document/sharedListener.ts","../src/document/documentStore.ts","../src/document/reducers.ts","../src/document/events.ts","../src/document/applyDocumentActions.ts","../src/document/processActions/releaseUtil.ts","../src/favorites/favorites.ts","../src/installations/installations.ts","../src/organization/organization.ts","../src/organizations/organizations.ts","../src/users/types.ts","../src/presence/types.ts","../src/presence/presenceStore.ts","../src/projection/types.ts","../src/preview/types.ts","../src/project/project.ts","../src/projection/getProjectionState.ts","../src/projection/resolveProjection.ts","../src/projects/projects.ts","../src/query/queryStore.ts","../src/releases/releasesStore.ts","../src/releases/getPerspectiveState.ts","../src/users/usersStore.ts","../src/utils/getCorsErrorProjectId.ts","../src/utils/isImportError.ts","../src/version.ts","../src/_exports/index.ts","../src/auth/authStore.ts"],"mappings":";;;;;;;;;;;;;UAOiB,WAAW;;;;;;;EAO1B,WAAW;;;;;;;;;;EAWX,MAAM,cAAc,cAAc,QAAQ,YAAY,GAAG,WAAW,QAAQ;;;;;;;;;EAU5E,YAAY,WAAW;;;;;UC7BR,aAAa,QAAQ;;;;;;;EAOpC,UAAU;;;;;;;EAQV,OAAO,WAAW;;;;EAKlB,KAAK;;;;;KCAK,YAAY,QAAQ,2BAA2B,SAAS,mBAClE,SAAS,aAAa,QAAQ,UAC3B,QAAQ,YACR;;;;KAKO,iBAAiB,SAAS,2BAA2B,YAC/D,UAAU,mBACP,QAAQ,YACR;;;;;;;;;;;;UCpBY,YAAY;;;;;;EAM3B,YAAY;;;;;;;;EASZ,kBAAkB;;;;;;;;;;EAWlB,YAAY,WAAW;;;;;;;;;;;;;;;;;;;;;;;UAwBR,gBAAgB;;;;EAI/B,OAAO;;;;EAKP,UAAU;;;;;;KAOA,SAAS,QAAQ,2BAA2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