@stonecrop/graphql-client 0.30.0 → 0.32.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.
@@ -1,4 +1,16 @@
1
- const s = `
1
+ //#region src/queries.ts
2
+ /**
3
+ * GraphQL query documents sent by {@link StonecropClient} to the middleware.
4
+ *
5
+ * These are the client's half of the wire contract with `@stonecrop/graphql-middleware`.
6
+ * They live here as exported constants (rather than inline in the client methods) so the
7
+ * cross-package contract test can validate the exact strings the client sends against the
8
+ * middleware's published SDL — a field the server drops while a query still selects it must
9
+ * fail CI, not production.
10
+ *
11
+ * @public
12
+ */
13
+ var GET_META_QUERY = `
2
14
  query GetMeta($doctype: String!) {
3
15
  stonecropMeta(doctype: $doctype) {
4
16
  name
@@ -44,7 +56,12 @@ const s = `
44
56
  inherits
45
57
  }
46
58
  }
47
- `, i = `
59
+ `;
60
+ /**
61
+ * Mutation document for dispatching a workflow action (the server-owned transition).
62
+ * @public
63
+ */
64
+ var RUN_ACTION_MUTATION = `
48
65
  mutation RunAction($doctype: String!, $action: String!, $args: JSON) {
49
66
  stonecropAction(doctype: $doctype, action: $action, args: $args) {
50
67
  success
@@ -52,7 +69,12 @@ const s = `
52
69
  error
53
70
  }
54
71
  }
55
- `, d = `
72
+ `;
73
+ /**
74
+ * Query document for fetching all doctype metadata.
75
+ * @public
76
+ */
77
+ var GET_ALL_META_QUERY = `
56
78
  query GetAllMeta {
57
79
  stonecropAllMeta {
58
80
  name
@@ -99,109 +121,114 @@ const s = `
99
121
  }
100
122
  }
101
123
  `;
102
- class l {
103
- endpoint;
104
- headers;
105
- metaCache = /* @__PURE__ */ new Map();
106
- constructor(e) {
107
- this.endpoint = e.endpoint, this.headers = {
108
- "Content-Type": "application/json",
109
- ...e.headers
110
- };
111
- }
112
- /**
113
- * Execute a GraphQL query against the configured endpoint.
114
- *
115
- * @param query - GraphQL query string
116
- * @param variables - Query variables
117
- * @throws Error if the GraphQL response contains errors
118
- */
119
- async query(e, t) {
120
- const n = await (await fetch(this.endpoint, {
121
- method: "POST",
122
- headers: this.headers,
123
- body: JSON.stringify({ query: e, variables: t })
124
- })).json();
125
- if (n.errors?.length)
126
- throw new Error(n.errors[0].message);
127
- if (n.data === void 0)
128
- throw new Error("GraphQL response missing data field");
129
- return n.data;
130
- }
131
- /**
132
- * Execute a GraphQL mutation. Delegates to query() since both use POST.
133
- *
134
- * @param mutation - GraphQL mutation string
135
- * @param variables - Mutation variables
136
- */
137
- async mutate(e, t) {
138
- return this.query(e, t);
139
- }
140
- /**
141
- * Get doctype metadata
142
- * @param context - Doctype context containing doctype name
143
- */
144
- async getMeta(e) {
145
- const t = this.metaCache.get(e.doctype);
146
- if (t) return t;
147
- const o = await this.query(s, {
148
- doctype: e.doctype
149
- });
150
- return o.stonecropMeta && this.metaCache.set(e.doctype, o.stonecropMeta), o.stonecropMeta;
151
- }
152
- /**
153
- * Get all doctype metadata
154
- */
155
- async getAllMeta() {
156
- const e = await this.query(d);
157
- for (const t of e.stonecropAllMeta)
158
- this.metaCache.set(t.name, t);
159
- return e.stonecropAllMeta;
160
- }
161
- /**
162
- * Get a single record by ID.
163
- *
164
- * Routes through the stonecropRecord resolver which handles nested data
165
- * fetching based on the includeNested option.
166
- *
167
- * @param doctype - Doctype reference (name and optional slug)
168
- * @param recordId - Record ID to fetch
169
- * @param options - Query options (includeNested, maxDepth)
170
- */
171
- async getRecord(e, t, o) {
172
- const n = await this.query(
173
- `query GetRecord($doctype: String!, $id: String!, $options: JSON) {
124
+ //#endregion
125
+ //#region src/client.ts
126
+ /**
127
+ * Client for interacting with Stonecrop GraphQL API.
128
+ *
129
+ * Acts as a transport layer for stonecropRecord/stonecropRecords/stonecropAction.
130
+ *
131
+ * @public
132
+ */
133
+ var StonecropClient = class {
134
+ endpoint;
135
+ headers;
136
+ metaCache = /* @__PURE__ */ new Map();
137
+ constructor(options) {
138
+ this.endpoint = options.endpoint;
139
+ this.headers = {
140
+ "Content-Type": "application/json",
141
+ ...options.headers
142
+ };
143
+ }
144
+ /**
145
+ * Execute a GraphQL query against the configured endpoint.
146
+ *
147
+ * @param query - GraphQL query string
148
+ * @param variables - Query variables
149
+ * @throws Error if the GraphQL response contains errors
150
+ */
151
+ async query(query, variables) {
152
+ const json = await (await fetch(this.endpoint, {
153
+ method: "POST",
154
+ headers: this.headers,
155
+ body: JSON.stringify({
156
+ query,
157
+ variables
158
+ })
159
+ })).json();
160
+ if (json.errors?.length) throw new Error(json.errors[0].message);
161
+ if (json.data === void 0) throw new Error("GraphQL response missing data field");
162
+ return json.data;
163
+ }
164
+ /**
165
+ * Execute a GraphQL mutation. Delegates to query() since both use POST.
166
+ *
167
+ * @param mutation - GraphQL mutation string
168
+ * @param variables - Mutation variables
169
+ */
170
+ async mutate(mutation, variables) {
171
+ return this.query(mutation, variables);
172
+ }
173
+ /**
174
+ * Get doctype metadata
175
+ * @param context - Doctype context containing doctype name
176
+ */
177
+ async getMeta(context) {
178
+ const cached = this.metaCache.get(context.doctype);
179
+ if (cached) return cached;
180
+ const result = await this.query(GET_META_QUERY, { doctype: context.doctype });
181
+ if (result.stonecropMeta) this.metaCache.set(context.doctype, result.stonecropMeta);
182
+ return result.stonecropMeta;
183
+ }
184
+ /**
185
+ * Get all doctype metadata
186
+ */
187
+ async getAllMeta() {
188
+ const result = await this.query(GET_ALL_META_QUERY);
189
+ for (const meta of result.stonecropAllMeta) this.metaCache.set(meta.name, meta);
190
+ return result.stonecropAllMeta;
191
+ }
192
+ /**
193
+ * Get a single record by ID.
194
+ *
195
+ * Routes through the stonecropRecord resolver which handles nested data
196
+ * fetching based on the includeNested option.
197
+ *
198
+ * @param doctype - Doctype reference (name and optional slug)
199
+ * @param recordId - Record ID to fetch
200
+ * @param options - Query options (includeNested, maxDepth)
201
+ */
202
+ async getRecord(doctype, recordId, options) {
203
+ const result = await this.query(`query GetRecord($doctype: String!, $id: String!, $options: JSON) {
174
204
  stonecropRecord(doctype: $doctype, id: $id, options: $options) {
175
205
  data
176
206
  unknownLinks
177
207
  }
178
- }`,
179
- {
180
- doctype: e.name,
181
- id: t,
182
- options: o?.includeNested ? {
183
- includeNested: o.includeNested,
184
- maxDepth: o.maxDepth
185
- } : void 0
186
- }
187
- );
188
- return {
189
- record: n.stonecropRecord?.data ?? null,
190
- unknownLinks: n.stonecropRecord?.unknownLinks
191
- };
192
- }
193
- /**
194
- * Get multiple records with optional filtering and pagination.
195
- *
196
- * Returns flat arrays — the middleware merges connection format (\{ nodes: [...] \})
197
- * into plain arrays before returning.
198
- *
199
- * @param doctype - Doctype reference (name and optional slug)
200
- * @param options - Query options (filters, orderBy, limit, offset)
201
- */
202
- async getRecords(e, t) {
203
- const o = await this.query(
204
- `
208
+ }`, {
209
+ doctype: doctype.name,
210
+ id: recordId,
211
+ options: options?.includeNested ? {
212
+ includeNested: options.includeNested,
213
+ maxDepth: options.maxDepth
214
+ } : void 0
215
+ });
216
+ return {
217
+ record: result.stonecropRecord?.data ?? null,
218
+ unknownLinks: result.stonecropRecord?.unknownLinks
219
+ };
220
+ }
221
+ /**
222
+ * Get multiple records with optional filtering and pagination.
223
+ *
224
+ * Returns flat arrays — the middleware merges connection format (\{ nodes: [...] \})
225
+ * into plain arrays before returning.
226
+ *
227
+ * @param doctype - Doctype reference (name and optional slug)
228
+ * @param options - Query options (filters, orderBy, limit, offset)
229
+ */
230
+ async getRecords(doctype, options) {
231
+ const { data, hasMore, count } = (await this.query(`
205
232
  query GetRecords(
206
233
  $doctype: String!
207
234
  $filters: JSON
@@ -223,38 +250,43 @@ class l {
223
250
  count
224
251
  }
225
252
  }
226
- `,
227
- {
228
- doctype: e.name,
229
- ...t
230
- }
231
- ), { data: n, hasMore: a, count: r } = o.stonecropRecords;
232
- return r == null ? { data: n, hasMore: a } : { data: n, hasMore: a, count: r };
233
- }
234
- /**
235
- * Execute a doctype action
236
- * @param doctype - Doctype reference (name and optional slug)
237
- * @param action - Action name to execute
238
- * @param args - Action arguments
239
- */
240
- async runAction(e, t, o) {
241
- return (await this.query(i, {
242
- doctype: e.name,
243
- action: t,
244
- args: o
245
- })).stonecropAction;
246
- }
247
- /**
248
- * Clear the cached doctype metadata.
249
- *
250
- * Call this if the server-side doctype schema has changed and you need
251
- * to fetch fresh metadata (e.g., after adding a new field).
252
- */
253
- clearMetaCache() {
254
- this.metaCache.clear();
255
- }
256
- }
257
- export {
258
- l as StonecropClient
253
+ `, {
254
+ doctype: doctype.name,
255
+ ...options
256
+ })).stonecropRecords;
257
+ return count == null ? {
258
+ data,
259
+ hasMore
260
+ } : {
261
+ data,
262
+ hasMore,
263
+ count
264
+ };
265
+ }
266
+ /**
267
+ * Execute a doctype action
268
+ * @param doctype - Doctype reference (name and optional slug)
269
+ * @param action - Action name to execute
270
+ * @param args - Action arguments
271
+ */
272
+ async runAction(doctype, action, args) {
273
+ return (await this.query(RUN_ACTION_MUTATION, {
274
+ doctype: doctype.name,
275
+ action,
276
+ args
277
+ })).stonecropAction;
278
+ }
279
+ /**
280
+ * Clear the cached doctype metadata.
281
+ *
282
+ * Call this if the server-side doctype schema has changed and you need
283
+ * to fetch fresh metadata (e.g., after adding a new field).
284
+ */
285
+ clearMetaCache() {
286
+ this.metaCache.clear();
287
+ }
259
288
  };
260
- //# sourceMappingURL=graphql-client.js.map
289
+ //#endregion
290
+ export { StonecropClient };
291
+
292
+ //# sourceMappingURL=graphql-client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"graphql-client.js","sources":["../src/queries.ts","../src/client.ts"],"sourcesContent":["/**\n * GraphQL query documents sent by {@link StonecropClient} to the middleware.\n *\n * These are the client's half of the wire contract with `@stonecrop/graphql-middleware`.\n * They live here as exported constants (rather than inline in the client methods) so the\n * cross-package contract test can validate the exact strings the client sends against the\n * middleware's published SDL — a field the server drops while a query still selects it must\n * fail CI, not production.\n *\n * @public\n */\nexport const GET_META_QUERY = `\n\tquery GetMeta($doctype: String!) {\n\t\tstonecropMeta(doctype: $doctype) {\n\t\t\tname\n\t\t\tslug\n\t\t\tdisplayField\n\t\t\tfields {\n\t\t\t\tkind\n\t\t\t\tfieldname\n\t\t\t\tcomponent\n\t\t\t\tprimaryKey\n\t\t\t\tcomputed\n\t\t\t\tlanguage\n\t\t\t\tdoctype\n\t\t\t\tlabel\n\t\t\t\twidth\n\t\t\t\theight\n\t\t\t\talign\n\t\t\t\tedit\n\t\t\t\tmask\n\t\t\t\tformat\n\t\t\t\tmode\n\t\t\t\toptions\n\t\t\t\trequired\n\t\t\t\treadOnly\n\t\t\t\thidden\n\t\t\t\tdefault\n\t\t\t\tvalidation\n\t\t\t\tcardinality\n\t\t\t\tsource\n\t\t\t}\n\t\t\tworkflow {\n\t\t\t\tstates\n\t\t\t\tactions {\n\t\t\t\t\tlabel\n\t\t\t\t\trequiredFields\n\t\t\t\t\tallowedStates\n\t\t\t\t\tnextState\n\t\t\t\t\tstateless\n\t\t\t\t\tselfTransition\n\t\t\t\t\tclientHandler\n\t\t\t\t}\n\t\t\t}\n\t\t\tinherits\n\t\t}\n\t}\n`\n\n/**\n * Mutation document for dispatching a workflow action (the server-owned transition).\n * @public\n */\nexport const RUN_ACTION_MUTATION = `\n\tmutation RunAction($doctype: String!, $action: String!, $args: JSON) {\n\t\tstonecropAction(doctype: $doctype, action: $action, args: $args) {\n\t\t\tsuccess\n\t\t\tdata\n\t\t\terror\n\t\t}\n\t}\n`\n\n/**\n * Query document for fetching all doctype metadata.\n * @public\n */\nexport const GET_ALL_META_QUERY = `\n\tquery GetAllMeta {\n\t\tstonecropAllMeta {\n\t\t\tname\n\t\t\tslug\n\t\t\tdisplayField\n\t\t\tfields {\n\t\t\t\tkind\n\t\t\t\tfieldname\n\t\t\t\tcomponent\n\t\t\t\tprimaryKey\n\t\t\t\tcomputed\n\t\t\t\tlanguage\n\t\t\t\tdoctype\n\t\t\t\tlabel\n\t\t\t\twidth\n\t\t\t\theight\n\t\t\t\talign\n\t\t\t\tedit\n\t\t\t\tmask\n\t\t\t\tformat\n\t\t\t\tmode\n\t\t\t\toptions\n\t\t\t\trequired\n\t\t\t\treadOnly\n\t\t\t\thidden\n\t\t\t\tdefault\n\t\t\t\tvalidation\n\t\t\t\tcardinality\n\t\t\t\tsource\n\t\t\t}\n\t\t\tworkflow {\n\t\t\t\tstates\n\t\t\t\tactions {\n\t\t\t\t\tlabel\n\t\t\t\t\trequiredFields\n\t\t\t\t\tallowedStates\n\t\t\t\t\tnextState\n\t\t\t\t\tstateless\n\t\t\t\t\tselfTransition\n\t\t\t\t\tclientHandler\n\t\t\t\t}\n\t\t\t}\n\t\t\tinherits\n\t\t}\n\t}\n`\n","import type {\n\tDataClient,\n\tDoctypeMeta,\n\tDoctypeContext,\n\tDoctypeRef,\n\tGetRecordOptions,\n\tGetRecordsOptions,\n\tGetRecordsResult,\n} from '@stonecrop/schema'\nimport type { GetRecordResult } from './types'\nimport { GET_META_QUERY, GET_ALL_META_QUERY, RUN_ACTION_MUTATION } from './queries'\n\nexport type { DoctypeContext, DoctypeRef }\nexport type { GetRecordResult, GetRecordsResult }\n\n/**\n * Options for creating a Stonecrop client\n * @public\n */\nexport interface StonecropClientOptions {\n\t/** GraphQL endpoint URL */\n\tendpoint: string\n\t/** Additional HTTP headers to include in requests */\n\theaders?: Record<string, string>\n}\n\n/**\n * Client for interacting with Stonecrop GraphQL API.\n *\n * Acts as a transport layer for stonecropRecord/stonecropRecords/stonecropAction.\n *\n * @public\n */\nexport class StonecropClient implements DataClient {\n\tprivate endpoint: string\n\tprivate headers: Record<string, string>\n\tprivate metaCache: Map<string, DoctypeMeta> = new Map()\n\n\tconstructor(options: StonecropClientOptions) {\n\t\tthis.endpoint = options.endpoint\n\t\tthis.headers = {\n\t\t\t'Content-Type': 'application/json',\n\t\t\t...options.headers,\n\t\t}\n\t}\n\n\t/**\n\t * Execute a GraphQL query against the configured endpoint.\n\t *\n\t * @param query - GraphQL query string\n\t * @param variables - Query variables\n\t * @throws Error if the GraphQL response contains errors\n\t */\n\tasync query<T = unknown>(query: string, variables?: Record<string, unknown>): Promise<T> {\n\t\tconst response = await fetch(this.endpoint, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: this.headers,\n\t\t\tbody: JSON.stringify({ query, variables }),\n\t\t})\n\n\t\tconst json: { data?: T; errors?: Array<{ message: string }> } = await response.json()\n\n\t\tif (json.errors?.length) {\n\t\t\tthrow new Error(json.errors[0].message)\n\t\t}\n\n\t\tif (json.data === undefined) {\n\t\t\tthrow new Error('GraphQL response missing data field')\n\t\t}\n\n\t\treturn json.data\n\t}\n\n\t/**\n\t * Execute a GraphQL mutation. Delegates to query() since both use POST.\n\t *\n\t * @param mutation - GraphQL mutation string\n\t * @param variables - Mutation variables\n\t */\n\tasync mutate<T = unknown>(mutation: string, variables?: Record<string, unknown>): Promise<T> {\n\t\treturn this.query<T>(mutation, variables)\n\t}\n\n\t/**\n\t * Get doctype metadata\n\t * @param context - Doctype context containing doctype name\n\t */\n\tasync getMeta(context: DoctypeContext): Promise<DoctypeMeta | null> {\n\t\tconst cached = this.metaCache.get(context.doctype)\n\t\tif (cached) return cached\n\n\t\tconst result = await this.query<{ stonecropMeta: DoctypeMeta | null }>(GET_META_QUERY, {\n\t\t\tdoctype: context.doctype,\n\t\t})\n\n\t\tif (result.stonecropMeta) {\n\t\t\tthis.metaCache.set(context.doctype, result.stonecropMeta)\n\t\t}\n\n\t\treturn result.stonecropMeta\n\t}\n\n\t/**\n\t * Get all doctype metadata\n\t */\n\tasync getAllMeta(): Promise<DoctypeMeta[]> {\n\t\tconst result = await this.query<{ stonecropAllMeta: DoctypeMeta[] }>(GET_ALL_META_QUERY)\n\n\t\tfor (const meta of result.stonecropAllMeta) {\n\t\t\tthis.metaCache.set(meta.name, meta)\n\t\t}\n\n\t\treturn result.stonecropAllMeta\n\t}\n\n\t/**\n\t * Get a single record by ID.\n\t *\n\t * Routes through the stonecropRecord resolver which handles nested data\n\t * fetching based on the includeNested option.\n\t *\n\t * @param doctype - Doctype reference (name and optional slug)\n\t * @param recordId - Record ID to fetch\n\t * @param options - Query options (includeNested, maxDepth)\n\t */\n\tasync getRecord(doctype: DoctypeRef, recordId: string, options?: GetRecordOptions): Promise<GetRecordResult> {\n\t\tconst result = await this.query<{\n\t\t\tstonecropRecord: { data: Record<string, unknown> | null; unknownLinks?: string[] }\n\t\t}>(\n\t\t\t`query GetRecord($doctype: String!, $id: String!, $options: JSON) {\n\t\t\t\tstonecropRecord(doctype: $doctype, id: $id, options: $options) {\n\t\t\t\t\tdata\n\t\t\t\t\tunknownLinks\n\t\t\t\t}\n\t\t\t}`,\n\t\t\t{\n\t\t\t\tdoctype: doctype.name,\n\t\t\t\tid: recordId,\n\t\t\t\toptions: options?.includeNested\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tincludeNested: options.includeNested,\n\t\t\t\t\t\t\tmaxDepth: options.maxDepth,\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t}\n\t\t)\n\n\t\treturn {\n\t\t\trecord: result.stonecropRecord?.data ?? null,\n\t\t\tunknownLinks: result.stonecropRecord?.unknownLinks,\n\t\t}\n\t}\n\n\t/**\n\t * Get multiple records with optional filtering and pagination.\n\t *\n\t * Returns flat arrays — the middleware merges connection format (\\{ nodes: [...] \\})\n\t * into plain arrays before returning.\n\t *\n\t * @param doctype - Doctype reference (name and optional slug)\n\t * @param options - Query options (filters, orderBy, limit, offset)\n\t */\n\tasync getRecords(doctype: DoctypeRef, options?: GetRecordsOptions): Promise<GetRecordsResult> {\n\t\tconst result = await this.query<{\n\t\t\tstonecropRecords: { data: Record<string, unknown>[]; hasMore: boolean; count: number | null }\n\t\t}>(\n\t\t\t`\n\t\t\tquery GetRecords(\n\t\t\t\t$doctype: String!\n\t\t\t\t$filters: JSON\n\t\t\t\t$orderBy: String\n\t\t\t\t$limit: Int\n\t\t\t\t$offset: Int\n\t\t\t\t$includeTotal: Boolean\n\t\t\t) {\n\t\t\t\tstonecropRecords(\n\t\t\t\t\tdoctype: $doctype\n\t\t\t\t\tfilters: $filters\n\t\t\t\t\torderBy: $orderBy\n\t\t\t\t\tlimit: $limit\n\t\t\t\t\toffset: $offset\n\t\t\t\t\tincludeTotal: $includeTotal\n\t\t\t\t) {\n\t\t\t\t\tdata\n\t\t\t\t\thasMore\n\t\t\t\t\tcount\n\t\t\t\t}\n\t\t\t}\n\t\t\t`,\n\t\t\t{\n\t\t\t\tdoctype: doctype.name,\n\t\t\t\t...options,\n\t\t\t}\n\t\t)\n\n\t\tconst { data, hasMore, count } = result.stonecropRecords\n\t\t// `count` is null unless includeTotal was set. Omitting the key rather than passing null\n\t\t// through keeps \"not asked for\" and \"asked for, and it is zero\" distinguishable.\n\t\treturn count == null ? { data, hasMore } : { data, hasMore, count }\n\t}\n\n\t/**\n\t * Execute a doctype action\n\t * @param doctype - Doctype reference (name and optional slug)\n\t * @param action - Action name to execute\n\t * @param args - Action arguments\n\t */\n\tasync runAction(\n\t\tdoctype: DoctypeRef,\n\t\taction: string,\n\t\targs?: unknown[]\n\t): Promise<{ success: boolean; data: unknown; error: string | null }> {\n\t\tconst result = await this.query<{\n\t\t\tstonecropAction: { success: boolean; data: unknown; error: string | null }\n\t\t}>(RUN_ACTION_MUTATION, {\n\t\t\tdoctype: doctype.name,\n\t\t\taction,\n\t\t\targs,\n\t\t})\n\n\t\treturn result.stonecropAction\n\t}\n\n\t/**\n\t * Clear the cached doctype metadata.\n\t *\n\t * Call this if the server-side doctype schema has changed and you need\n\t * to fetch fresh metadata (e.g., after adding a new field).\n\t */\n\tclearMetaCache(): void {\n\t\tthis.metaCache.clear()\n\t}\n}\n"],"names":["GET_META_QUERY","RUN_ACTION_MUTATION","GET_ALL_META_QUERY","StonecropClient","options","query","variables","json","mutation","context","cached","result","meta","doctype","recordId","data","hasMore","count","action","args"],"mappings":"AAWO,MAAMA,IAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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AA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAuBA;AAAA,QACC,SAASE,EAAQ;AAAA,QACjB,GAAGT;AAAA,MAAA;AAAA,IACJ,GAGK,EAAE,MAAAW,GAAM,SAAAC,GAAS,OAAAC,EAAA,IAAUN,EAAO;AAGxC,WAAOM,KAAS,OAAO,EAAE,MAAAF,GAAM,SAAAC,MAAY,EAAE,MAAAD,GAAM,SAAAC,GAAS,OAAAC,EAAA;AAAA,EAC7D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,UACLJ,GACAK,GACAC,GACqE;AASrE,YARe,MAAM,KAAK,MAEvBlB,GAAqB;AAAA,MACvB,SAASY,EAAQ;AAAA,MACjB,QAAAK;AAAA,MACA,MAAAC;AAAA,IAAA,CACA,GAEa;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,iBAAuB;AACtB,SAAK,UAAU,MAAA;AAAA,EAChB;AACD;"}
1
+ {"version":3,"file":"graphql-client.js","names":[],"sources":["../src/queries.ts","../src/client.ts"],"sourcesContent":["/**\n * GraphQL query documents sent by {@link StonecropClient} to the middleware.\n *\n * These are the client's half of the wire contract with `@stonecrop/graphql-middleware`.\n * They live here as exported constants (rather than inline in the client methods) so the\n * cross-package contract test can validate the exact strings the client sends against the\n * middleware's published SDL — a field the server drops while a query still selects it must\n * fail CI, not production.\n *\n * @public\n */\nexport const GET_META_QUERY = `\n\tquery GetMeta($doctype: String!) {\n\t\tstonecropMeta(doctype: $doctype) {\n\t\t\tname\n\t\t\tslug\n\t\t\tdisplayField\n\t\t\tfields {\n\t\t\t\tkind\n\t\t\t\tfieldname\n\t\t\t\tcomponent\n\t\t\t\tprimaryKey\n\t\t\t\tcomputed\n\t\t\t\tlanguage\n\t\t\t\tdoctype\n\t\t\t\tlabel\n\t\t\t\twidth\n\t\t\t\theight\n\t\t\t\talign\n\t\t\t\tedit\n\t\t\t\tmask\n\t\t\t\tformat\n\t\t\t\tmode\n\t\t\t\toptions\n\t\t\t\trequired\n\t\t\t\treadOnly\n\t\t\t\thidden\n\t\t\t\tdefault\n\t\t\t\tvalidation\n\t\t\t\tcardinality\n\t\t\t\tsource\n\t\t\t}\n\t\t\tworkflow {\n\t\t\t\tstates\n\t\t\t\tactions {\n\t\t\t\t\tlabel\n\t\t\t\t\trequiredFields\n\t\t\t\t\tallowedStates\n\t\t\t\t\tnextState\n\t\t\t\t\tstateless\n\t\t\t\t\tselfTransition\n\t\t\t\t\tclientHandler\n\t\t\t\t}\n\t\t\t}\n\t\t\tinherits\n\t\t}\n\t}\n`\n\n/**\n * Mutation document for dispatching a workflow action (the server-owned transition).\n * @public\n */\nexport const RUN_ACTION_MUTATION = `\n\tmutation RunAction($doctype: String!, $action: String!, $args: JSON) {\n\t\tstonecropAction(doctype: $doctype, action: $action, args: $args) {\n\t\t\tsuccess\n\t\t\tdata\n\t\t\terror\n\t\t}\n\t}\n`\n\n/**\n * Query document for fetching all doctype metadata.\n * @public\n */\nexport const GET_ALL_META_QUERY = `\n\tquery GetAllMeta {\n\t\tstonecropAllMeta {\n\t\t\tname\n\t\t\tslug\n\t\t\tdisplayField\n\t\t\tfields {\n\t\t\t\tkind\n\t\t\t\tfieldname\n\t\t\t\tcomponent\n\t\t\t\tprimaryKey\n\t\t\t\tcomputed\n\t\t\t\tlanguage\n\t\t\t\tdoctype\n\t\t\t\tlabel\n\t\t\t\twidth\n\t\t\t\theight\n\t\t\t\talign\n\t\t\t\tedit\n\t\t\t\tmask\n\t\t\t\tformat\n\t\t\t\tmode\n\t\t\t\toptions\n\t\t\t\trequired\n\t\t\t\treadOnly\n\t\t\t\thidden\n\t\t\t\tdefault\n\t\t\t\tvalidation\n\t\t\t\tcardinality\n\t\t\t\tsource\n\t\t\t}\n\t\t\tworkflow {\n\t\t\t\tstates\n\t\t\t\tactions {\n\t\t\t\t\tlabel\n\t\t\t\t\trequiredFields\n\t\t\t\t\tallowedStates\n\t\t\t\t\tnextState\n\t\t\t\t\tstateless\n\t\t\t\t\tselfTransition\n\t\t\t\t\tclientHandler\n\t\t\t\t}\n\t\t\t}\n\t\t\tinherits\n\t\t}\n\t}\n`\n","import type {\n\tDataClient,\n\tDoctypeMeta,\n\tDoctypeContext,\n\tDoctypeRef,\n\tGetRecordOptions,\n\tGetRecordsOptions,\n\tGetRecordsResult,\n} from '@stonecrop/schema'\nimport type { GetRecordResult } from './types'\nimport { GET_META_QUERY, GET_ALL_META_QUERY, RUN_ACTION_MUTATION } from './queries'\n\nexport type { DoctypeContext, DoctypeRef }\nexport type { GetRecordResult, GetRecordsResult }\n\n/**\n * Options for creating a Stonecrop client\n * @public\n */\nexport interface StonecropClientOptions {\n\t/** GraphQL endpoint URL */\n\tendpoint: string\n\t/** Additional HTTP headers to include in requests */\n\theaders?: Record<string, string>\n}\n\n/**\n * Client for interacting with Stonecrop GraphQL API.\n *\n * Acts as a transport layer for stonecropRecord/stonecropRecords/stonecropAction.\n *\n * @public\n */\nexport class StonecropClient implements DataClient {\n\tprivate endpoint: string\n\tprivate headers: Record<string, string>\n\tprivate metaCache: Map<string, DoctypeMeta> = new Map()\n\n\tconstructor(options: StonecropClientOptions) {\n\t\tthis.endpoint = options.endpoint\n\t\tthis.headers = {\n\t\t\t'Content-Type': 'application/json',\n\t\t\t...options.headers,\n\t\t}\n\t}\n\n\t/**\n\t * Execute a GraphQL query against the configured endpoint.\n\t *\n\t * @param query - GraphQL query string\n\t * @param variables - Query variables\n\t * @throws Error if the GraphQL response contains errors\n\t */\n\tasync query<T = unknown>(query: string, variables?: Record<string, unknown>): Promise<T> {\n\t\tconst response = await fetch(this.endpoint, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: this.headers,\n\t\t\tbody: JSON.stringify({ query, variables }),\n\t\t})\n\n\t\tconst json: { data?: T; errors?: Array<{ message: string }> } = await response.json()\n\n\t\tif (json.errors?.length) {\n\t\t\tthrow new Error(json.errors[0].message)\n\t\t}\n\n\t\tif (json.data === undefined) {\n\t\t\tthrow new Error('GraphQL response missing data field')\n\t\t}\n\n\t\treturn json.data\n\t}\n\n\t/**\n\t * Execute a GraphQL mutation. Delegates to query() since both use POST.\n\t *\n\t * @param mutation - GraphQL mutation string\n\t * @param variables - Mutation variables\n\t */\n\tasync mutate<T = unknown>(mutation: string, variables?: Record<string, unknown>): Promise<T> {\n\t\treturn this.query<T>(mutation, variables)\n\t}\n\n\t/**\n\t * Get doctype metadata\n\t * @param context - Doctype context containing doctype name\n\t */\n\tasync getMeta(context: DoctypeContext): Promise<DoctypeMeta | null> {\n\t\tconst cached = this.metaCache.get(context.doctype)\n\t\tif (cached) return cached\n\n\t\tconst result = await this.query<{ stonecropMeta: DoctypeMeta | null }>(GET_META_QUERY, {\n\t\t\tdoctype: context.doctype,\n\t\t})\n\n\t\tif (result.stonecropMeta) {\n\t\t\tthis.metaCache.set(context.doctype, result.stonecropMeta)\n\t\t}\n\n\t\treturn result.stonecropMeta\n\t}\n\n\t/**\n\t * Get all doctype metadata\n\t */\n\tasync getAllMeta(): Promise<DoctypeMeta[]> {\n\t\tconst result = await this.query<{ stonecropAllMeta: DoctypeMeta[] }>(GET_ALL_META_QUERY)\n\n\t\tfor (const meta of result.stonecropAllMeta) {\n\t\t\tthis.metaCache.set(meta.name, meta)\n\t\t}\n\n\t\treturn result.stonecropAllMeta\n\t}\n\n\t/**\n\t * Get a single record by ID.\n\t *\n\t * Routes through the stonecropRecord resolver which handles nested data\n\t * fetching based on the includeNested option.\n\t *\n\t * @param doctype - Doctype reference (name and optional slug)\n\t * @param recordId - Record ID to fetch\n\t * @param options - Query options (includeNested, maxDepth)\n\t */\n\tasync getRecord(doctype: DoctypeRef, recordId: string, options?: GetRecordOptions): Promise<GetRecordResult> {\n\t\tconst result = await this.query<{\n\t\t\tstonecropRecord: { data: Record<string, unknown> | null; unknownLinks?: string[] }\n\t\t}>(\n\t\t\t`query GetRecord($doctype: String!, $id: String!, $options: JSON) {\n\t\t\t\tstonecropRecord(doctype: $doctype, id: $id, options: $options) {\n\t\t\t\t\tdata\n\t\t\t\t\tunknownLinks\n\t\t\t\t}\n\t\t\t}`,\n\t\t\t{\n\t\t\t\tdoctype: doctype.name,\n\t\t\t\tid: recordId,\n\t\t\t\toptions: options?.includeNested\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tincludeNested: options.includeNested,\n\t\t\t\t\t\t\tmaxDepth: options.maxDepth,\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t}\n\t\t)\n\n\t\treturn {\n\t\t\trecord: result.stonecropRecord?.data ?? null,\n\t\t\tunknownLinks: result.stonecropRecord?.unknownLinks,\n\t\t}\n\t}\n\n\t/**\n\t * Get multiple records with optional filtering and pagination.\n\t *\n\t * Returns flat arrays — the middleware merges connection format (\\{ nodes: [...] \\})\n\t * into plain arrays before returning.\n\t *\n\t * @param doctype - Doctype reference (name and optional slug)\n\t * @param options - Query options (filters, orderBy, limit, offset)\n\t */\n\tasync getRecords(doctype: DoctypeRef, options?: GetRecordsOptions): Promise<GetRecordsResult> {\n\t\tconst result = await this.query<{\n\t\t\tstonecropRecords: { data: Record<string, unknown>[]; hasMore: boolean; count: number | null }\n\t\t}>(\n\t\t\t`\n\t\t\tquery GetRecords(\n\t\t\t\t$doctype: String!\n\t\t\t\t$filters: JSON\n\t\t\t\t$orderBy: String\n\t\t\t\t$limit: Int\n\t\t\t\t$offset: Int\n\t\t\t\t$includeTotal: Boolean\n\t\t\t) {\n\t\t\t\tstonecropRecords(\n\t\t\t\t\tdoctype: $doctype\n\t\t\t\t\tfilters: $filters\n\t\t\t\t\torderBy: $orderBy\n\t\t\t\t\tlimit: $limit\n\t\t\t\t\toffset: $offset\n\t\t\t\t\tincludeTotal: $includeTotal\n\t\t\t\t) {\n\t\t\t\t\tdata\n\t\t\t\t\thasMore\n\t\t\t\t\tcount\n\t\t\t\t}\n\t\t\t}\n\t\t\t`,\n\t\t\t{\n\t\t\t\tdoctype: doctype.name,\n\t\t\t\t...options,\n\t\t\t}\n\t\t)\n\n\t\tconst { data, hasMore, count } = result.stonecropRecords\n\t\t// `count` is null unless includeTotal was set. Omitting the key rather than passing null\n\t\t// through keeps \"not asked for\" and \"asked for, and it is zero\" distinguishable.\n\t\treturn count == null ? { data, hasMore } : { data, hasMore, count }\n\t}\n\n\t/**\n\t * Execute a doctype action\n\t * @param doctype - Doctype reference (name and optional slug)\n\t * @param action - Action name to execute\n\t * @param args - Action arguments\n\t */\n\tasync runAction(\n\t\tdoctype: DoctypeRef,\n\t\taction: string,\n\t\targs?: unknown[]\n\t): Promise<{ success: boolean; data: unknown; error: string | null }> {\n\t\tconst result = await this.query<{\n\t\t\tstonecropAction: { success: boolean; data: unknown; error: string | null }\n\t\t}>(RUN_ACTION_MUTATION, {\n\t\t\tdoctype: doctype.name,\n\t\t\taction,\n\t\t\targs,\n\t\t})\n\n\t\treturn result.stonecropAction\n\t}\n\n\t/**\n\t * Clear the cached doctype metadata.\n\t *\n\t * Call this if the server-side doctype schema has changed and you need\n\t * to fetch fresh metadata (e.g., after adding a new field).\n\t */\n\tclearMetaCache(): void {\n\t\tthis.metaCache.clear()\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAWA,IAAa,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoD9B,IAAa,sBAAsB;;;;;;;;;;;;;AAcnC,IAAa,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC5ClC,IAAa,kBAAb,MAAmD;CAClD;CACA;CACA,4BAA8C,IAAI,IAAI;CAEtD,YAAY,SAAiC;EAC5C,KAAK,WAAW,QAAQ;EACxB,KAAK,UAAU;GACd,gBAAgB;GAChB,GAAG,QAAQ;EACZ;CACD;;;;;;;;CASA,MAAM,MAAmB,OAAe,WAAiD;EAOxF,MAAM,OAA0D,OAAM,MAN/C,MAAM,KAAK,UAAU;GAC3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;MAuBA;GACC,SAAS,QAAQ;GACjB,GAAG;EACJ,CACD,EAAA,CAEwC;EAGxC,OAAO,SAAS,OAAO;GAAE;GAAM;EAAQ,IAAI;GAAE;GAAM;GAAS;EAAM;CACnE;;;;;;;CAQA,MAAM,UACL,SACA,QACA,MACqE;EASrE,QAAO,MARc,KAAK,MAEvB,qBAAqB;GACvB,SAAS,QAAQ;GACjB;GACA;EACD,CAAC,EAAA,CAEa;CACf;;;;;;;CAQA,iBAAuB;EACtB,KAAK,UAAU,MAAM;CACtB;AACD"}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.58.11"
8
+ "packageVersion": "7.59.0"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,41 +1,51 @@
1
1
  {
2
2
  "name": "@stonecrop/graphql-client",
3
- "version": "0.30.0",
3
+ "version": "0.32.0",
4
4
  "description": "GraphQL client integration for Stonecrop",
5
+ "keywords": [
6
+ "client",
7
+ "graphql",
8
+ "stonecrop",
9
+ "vue"
10
+ ],
11
+ "homepage": "https://github.com/agritheory/stonecrop#readme",
5
12
  "bugs": {
6
13
  "url": "https://github.com/agritheory/stonecrop/issues"
7
14
  },
8
- "repository": {
9
- "type": "git",
10
- "url": "https://github.com/agritheory/stonecrop",
11
- "directory": "graphql_client"
12
- },
13
15
  "license": "MIT",
14
16
  "author": {
15
17
  "name": "Tyler Matteson",
16
18
  "email": "tyler@agritheory.com"
17
19
  },
18
- "sideEffects": false,
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/agritheory/stonecrop",
23
+ "directory": "graphql_client"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "!dist/src"
28
+ ],
19
29
  "type": "module",
30
+ "sideEffects": false,
31
+ "types": "./dist/graphql-client.d.ts",
20
32
  "exports": {
21
33
  ".": {
22
34
  "types": "./dist/graphql-client.d.ts",
23
35
  "import": "./dist/graphql-client.js"
24
36
  },
25
- "./types": "./dist/src/types/index.d.ts"
37
+ "./types": "./dist/graphql-client.d.ts",
38
+ "./package.json": "./package.json"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
26
42
  },
27
- "types": "./dist/graphql-client.d.ts",
28
- "files": [
29
- "dist/*",
30
- "src/*"
31
- ],
32
43
  "dependencies": {
33
- "@stonecrop/schema": "0.30.0"
44
+ "@stonecrop/schema": "0.32.0"
34
45
  },
35
46
  "devDependencies": {
36
- "@microsoft/api-documenter": "^7.30.5",
47
+ "@microsoft/api-extractor": "^7.58.7",
37
48
  "@miragejs/graphql": "^0.1.13",
38
- "@rushstack/heft": "^1.2.17",
39
49
  "@types/node": "^24.12.4",
40
50
  "@vitejs/plugin-vue": "^6.0.6",
41
51
  "@vitest/coverage-istanbul": "^4.1.5",
@@ -44,24 +54,18 @@
44
54
  "oxlint": "1.67.0",
45
55
  "oxlint-tsgolint": "0.23.0",
46
56
  "typescript": "^6.0.3",
47
- "vite": "^7.3.2",
57
+ "vite": "^8.2.2",
48
58
  "vitest": "^4.1.5",
49
59
  "vue": "^3.5.33",
50
60
  "vue-router": "^5.0.6",
51
- "@stonecrop/graphql-middleware": "0.30.0",
52
- "stonecrop-rig": "0.7.0"
61
+ "@stonecrop/graphql-middleware": "0.32.0"
53
62
  },
54
63
  "engines": {
55
64
  "node": ">=24.0.0"
56
65
  },
57
- "publishConfig": {
58
- "access": "public"
59
- },
60
66
  "scripts": {
61
- "_phase:build": "heft build --clean && vite build && rushx docs",
62
- "build": "heft build --clean && vite build && rushx docs",
63
- "dev": "vite",
64
- "docs": "bash ../common/scripts/run-docs.sh graphql_client",
67
+ "dev": "vite build --watch",
68
+ "docs": "bash ../tools/scripts/run-docs.sh graphql_client",
65
69
  "lint": "oxlint",
66
70
  "lint:fix": "oxlint --fix",
67
71
  "preview": "vite preview",
@@ -1 +0,0 @@
1
- {"version":"6.0.3"}
@@ -1,91 +0,0 @@
1
- import type { DataClient, DoctypeMeta, DoctypeContext, DoctypeRef, GetRecordOptions, GetRecordsOptions, GetRecordsResult } from '@stonecrop/schema';
2
- import type { GetRecordResult } from './types';
3
- export type { DoctypeContext, DoctypeRef };
4
- export type { GetRecordResult, GetRecordsResult };
5
- /**
6
- * Options for creating a Stonecrop client
7
- * @public
8
- */
9
- export interface StonecropClientOptions {
10
- /** GraphQL endpoint URL */
11
- endpoint: string;
12
- /** Additional HTTP headers to include in requests */
13
- headers?: Record<string, string>;
14
- }
15
- /**
16
- * Client for interacting with Stonecrop GraphQL API.
17
- *
18
- * Acts as a transport layer for stonecropRecord/stonecropRecords/stonecropAction.
19
- *
20
- * @public
21
- */
22
- export declare class StonecropClient implements DataClient {
23
- private endpoint;
24
- private headers;
25
- private metaCache;
26
- constructor(options: StonecropClientOptions);
27
- /**
28
- * Execute a GraphQL query against the configured endpoint.
29
- *
30
- * @param query - GraphQL query string
31
- * @param variables - Query variables
32
- * @throws Error if the GraphQL response contains errors
33
- */
34
- query<T = unknown>(query: string, variables?: Record<string, unknown>): Promise<T>;
35
- /**
36
- * Execute a GraphQL mutation. Delegates to query() since both use POST.
37
- *
38
- * @param mutation - GraphQL mutation string
39
- * @param variables - Mutation variables
40
- */
41
- mutate<T = unknown>(mutation: string, variables?: Record<string, unknown>): Promise<T>;
42
- /**
43
- * Get doctype metadata
44
- * @param context - Doctype context containing doctype name
45
- */
46
- getMeta(context: DoctypeContext): Promise<DoctypeMeta | null>;
47
- /**
48
- * Get all doctype metadata
49
- */
50
- getAllMeta(): Promise<DoctypeMeta[]>;
51
- /**
52
- * Get a single record by ID.
53
- *
54
- * Routes through the stonecropRecord resolver which handles nested data
55
- * fetching based on the includeNested option.
56
- *
57
- * @param doctype - Doctype reference (name and optional slug)
58
- * @param recordId - Record ID to fetch
59
- * @param options - Query options (includeNested, maxDepth)
60
- */
61
- getRecord(doctype: DoctypeRef, recordId: string, options?: GetRecordOptions): Promise<GetRecordResult>;
62
- /**
63
- * Get multiple records with optional filtering and pagination.
64
- *
65
- * Returns flat arrays — the middleware merges connection format (\{ nodes: [...] \})
66
- * into plain arrays before returning.
67
- *
68
- * @param doctype - Doctype reference (name and optional slug)
69
- * @param options - Query options (filters, orderBy, limit, offset)
70
- */
71
- getRecords(doctype: DoctypeRef, options?: GetRecordsOptions): Promise<GetRecordsResult>;
72
- /**
73
- * Execute a doctype action
74
- * @param doctype - Doctype reference (name and optional slug)
75
- * @param action - Action name to execute
76
- * @param args - Action arguments
77
- */
78
- runAction(doctype: DoctypeRef, action: string, args?: unknown[]): Promise<{
79
- success: boolean;
80
- data: unknown;
81
- error: string | null;
82
- }>;
83
- /**
84
- * Clear the cached doctype metadata.
85
- *
86
- * Call this if the server-side doctype schema has changed and you need
87
- * to fetch fresh metadata (e.g., after adding a new field).
88
- */
89
- clearMetaCache(): void;
90
- }
91
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,UAAU,EACV,WAAW,EACX,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAG9C,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,CAAA;AAC1C,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAA;AAEjD;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACtC,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC;AAED;;;;;;GAMG;AACH,qBAAa,eAAgB,YAAW,UAAU;IACjD,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,OAAO,CAAwB;IACvC,OAAO,CAAC,SAAS,CAAsC;gBAE3C,OAAO,EAAE,sBAA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