-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed from productImage to productMedia
- Loading branch information
Showing
19 changed files
with
191 additions
and
33 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
shopify/product-reviews-template/accessControl/filters/shopify/shopifyFile.gelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
filter ($session: Session) on ShopifyFile [ | ||
where shopId == $session.shopId | ||
] |
3 changes: 3 additions & 0 deletions
3
shopify/product-reviews-template/accessControl/filters/shopify/shopifyProductMedia.gelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
filter ($session: Session) on ShopifyProductMedia [ | ||
where shopId == $session.shopId | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
shopify/product-reviews-template/api/actions/scheduledShopifySync.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ActionOptions, ScheduledShopifySyncGlobalActionContext } from "gadget-server"; | ||
import { globalShopifySync } from "gadget-server/shopify"; | ||
|
||
const HourInMs = 60 * 60 * 1000; | ||
|
||
/** | ||
* @param { ScheduledShopifySyncGlobalActionContext } context | ||
*/ | ||
export async function run({ params, logger, api, connections }) { | ||
const syncOnlyModels = connections.shopify.enabledModels | ||
.filter(model => model.syncOnly) | ||
.map(model => model.apiIdentifier); | ||
|
||
const syncSince = new Date(Date.now() - 25 * HourInMs) | ||
|
||
await globalShopifySync({ | ||
apiKeys: connections.shopify.apiKeys, | ||
syncSince, | ||
models: syncOnlyModels | ||
}); | ||
}; | ||
|
||
/** @type { ActionOptions } */ | ||
export const options = { | ||
triggers: { | ||
scheduler: [ | ||
{ | ||
every: "day", | ||
at: "14:21 UTC", | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
shopify/product-reviews-template/api/models/shopifyFile/actions/delete.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { deleteRecord, ActionOptions, DeleteShopifyFileActionContext } from "gadget-server"; | ||
import { preventCrossShopDataAccess } from "gadget-server/shopify"; | ||
|
||
/** | ||
* @param { DeleteShopifyFileActionContext } context | ||
*/ | ||
export async function run({ params, record, logger, api, connections }) { | ||
await preventCrossShopDataAccess(params, record); | ||
await deleteRecord(record); | ||
}; | ||
|
||
/** | ||
* @param { DeleteShopifyFileActionContext } context | ||
*/ | ||
export async function onSuccess({ params, record, logger, api, connections }) { | ||
// Your logic goes here | ||
}; | ||
|
||
/** @type { ActionOptions } */ | ||
export const options = { actionType: "delete" }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
shopify/product-reviews-template/api/models/shopifyFile/schema.gadget.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import type { GadgetModel } from "gadget-server"; | ||
|
||
// This file describes the schema for the "shopifyFile" model, go to https://product-reviews-template.gadget.app/edit to view/edit your model in Gadget | ||
// For more information on how to update this file http://docs.gadget.dev | ||
|
||
export const schema: GadgetModel = { | ||
type: "gadget/model-schema/v1", | ||
storageKey: "DataModel-Shopify-File", | ||
fields: {}, | ||
shopify: { | ||
fields: [ | ||
"alt", | ||
"boundingBox", | ||
"duration", | ||
"embedUrl", | ||
"fileErrors", | ||
"fileStatus", | ||
"filename", | ||
"host", | ||
"image", | ||
"mediaContentType", | ||
"mediaErrors", | ||
"mediaWarnings", | ||
"mimetype", | ||
"originUrl", | ||
"originalFileSize", | ||
"originalSource", | ||
"preview", | ||
"product", | ||
"shop", | ||
"shopifyCreatedAt", | ||
"shopifyUpdatedAt", | ||
"sources", | ||
"status", | ||
"type", | ||
"url", | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
shopify/product-reviews-template/api/models/shopifyProductMedia/actions/create.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { applyParams, save, ActionOptions, CreateShopifyProductMediaActionContext } from "gadget-server"; | ||
import { preventCrossShopDataAccess } from "gadget-server/shopify"; | ||
|
||
/** | ||
* @param { CreateShopifyProductMediaActionContext } context | ||
*/ | ||
export async function run({ params, record, logger, api, connections }) { | ||
applyParams(params, record); | ||
await preventCrossShopDataAccess(params, record); | ||
await save(record); | ||
}; | ||
|
||
/** | ||
* @param { CreateShopifyProductMediaActionContext } context | ||
*/ | ||
export async function onSuccess({ params, record, logger, api, connections }) { | ||
// Your logic goes here | ||
}; | ||
|
||
/** @type { ActionOptions } */ | ||
export const options = { actionType: "create" }; |
6 changes: 3 additions & 3 deletions
6
...els/shopifyProductImage/actions/delete.js → ...els/shopifyProductMedia/actions/delete.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
shopify/product-reviews-template/api/models/shopifyProductMedia/actions/update.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { applyParams, save, ActionOptions, UpdateShopifyProductMediaActionContext } from "gadget-server"; | ||
import { preventCrossShopDataAccess } from "gadget-server/shopify"; | ||
|
||
/** | ||
* @param { UpdateShopifyProductMediaActionContext } context | ||
*/ | ||
export async function run({ params, record, logger, api, connections }) { | ||
applyParams(params, record); | ||
await preventCrossShopDataAccess(params, record); | ||
await save(record); | ||
}; | ||
|
||
/** | ||
* @param { UpdateShopifyProductMediaActionContext } context | ||
*/ | ||
export async function onSuccess({ params, record, logger, api, connections }) { | ||
// Your logic goes here | ||
}; | ||
|
||
/** @type { ActionOptions } */ | ||
export const options = { actionType: "update" }; |
12 changes: 4 additions & 8 deletions
12
...dels/shopifyProductImage/schema.gadget.ts → ...dels/shopifyProductMedia/schema.gadget.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,19 @@ | ||
import type { GadgetModel } from "gadget-server"; | ||
|
||
// This file describes the schema for the "shopifyProductImage" model, go to https://product-reviews-template.gadget.app/edit to view/edit your model in Gadget | ||
// This file describes the schema for the "shopifyProductMedia" model, go to https://product-reviews-template.gadget.app/edit to view/edit your model in Gadget | ||
// For more information on how to update this file http://docs.gadget.dev | ||
|
||
export const schema: GadgetModel = { | ||
type: "gadget/model-schema/v1", | ||
storageKey: "DataModel-Shopify-ProductImage", | ||
storageKey: "DataModel-Shopify-ProductMedia", | ||
fields: {}, | ||
shopify: { | ||
fields: [ | ||
"alt", | ||
"height", | ||
"featuredMediaForProduct", | ||
"file", | ||
"position", | ||
"product", | ||
"shop", | ||
"shopifyCreatedAt", | ||
"shopifyUpdatedAt", | ||
"source", | ||
"width", | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters