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

Method save

integrations/shopify/src/rest.ts:261–291  ·  view source on GitHub ↗

* Create or update a resource of a given type. The resource will be created if no ID is specified.

(
    key: string,
    params: {
      update?: TUpdate;
      fromData: TFromData;
      session?: Session;
    }
  )

Source from the content-addressed store, hash-verified

259 * Create or update a resource of a given type. The resource will be created if no ID is specified.
260 */
261 async save<TFromData extends ShopifyInputType[TResourceType], TUpdate extends boolean = true>(
262 key: string,
263 params: {
264 update?: TUpdate;
265 fromData: TFromData;
266 session?: Session;
267 }
268 ): SaveReturnType<TResource, TUpdate, TFromData> {
269 return this.runTask(
270 key,
271 async (client, task, io) => {
272 const resource = new client.rest[this.resourceType](this.#withSession(params));
273
274 // mutate resource object with upserted data by default
275 await resource.save({ update: params.update ?? true });
276
277 return JSON.parse(JSON.stringify(resource));
278 },
279 {
280 name: `Upsert ${this.resourceType}`,
281 params,
282 properties: [
283 ...(params.fromData.id ? basicProperties({ id: params.fromData.id }) : []),
284 {
285 label: "Action",
286 text: params.fromData.id ? "Update" : "Create",
287 },
288 ],
289 }
290 );
291 }
292
293 /**
294 * Delete an existing resource.

Callers 3

createWebhookEventSourceFunction · 0.80
shopify.tsFile · 0.80
decorators.tsFile · 0.80

Calls 4

#withSessionMethod · 0.95
basicPropertiesFunction · 0.90
parseMethod · 0.80
runTaskMethod · 0.45

Tested by

no test coverage detected