MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / count

Method count

integrations/shopify/src/rest.ts:221–256  ·  view source on GitHub ↗

* Fetch the number of resources of a given type.

(
    key: string,
    params?: Optional<OmitIndexSignature<Parameters<TResource["count"]>[0]>, "session">
  )

Source from the content-addressed store, hash-verified

219 * Fetch the number of resources of a given type.
220 */
221 async count(
222 key: string,
223 params?: Optional<OmitIndexSignature<Parameters<TResource["count"]>[0]>, "session">
224 ): CountReturnType {
225 return this.runTask(
226 key,
227 async (client, task, io) => {
228 const countResponse = await client.rest[this.resourceType].count(
229 this.#withSession(params ?? {})
230 );
231
232 const CountResponseSchema = z.object({
233 count: z.number(),
234 });
235
236 const parsed = CountResponseSchema.safeParse(countResponse);
237
238 if (!parsed.success) {
239 return JSON.parse(JSON.stringify(countResponse));
240 }
241
242 task.outputProperties = [
243 {
244 label: "Total",
245 text: String(parsed.data.count),
246 },
247 ];
248
249 return parsed.data;
250 },
251 {
252 name: `Count ${this.resourceType}s`,
253 params,
254 }
255 );
256 }
257
258 /**
259 * Create or update a resource of a given type. The resource will be created if no ID is specified.

Callers 10

loaderFunction · 0.80
currentPlanMethod · 0.80
getTaskCountForRunFunction · 0.80
#upsertJobMethod · 0.80
callMethod · 0.80
callMethod · 0.80
callMethod · 0.80
adminGetUsersFunction · 0.80
adminGetOrganizationsFunction · 0.80
shopify.tsFile · 0.80

Calls 3

#withSessionMethod · 0.95
parseMethod · 0.80
runTaskMethod · 0.45

Tested by

no test coverage detected