Skip to content

Commit

Permalink
Merge pull request #118 from gadget-inc/nonem-shopify-ts
Browse files Browse the repository at this point in the history
non-embedded Shopify app TS
  • Loading branch information
DevAOC authored Dec 11, 2024
2 parents a53f9bf + 45fcaa8 commit 8320a64
Show file tree
Hide file tree
Showing 69 changed files with 860 additions and 885 deletions.
6 changes: 5 additions & 1 deletion shopify/standalone-shopify-template/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.gadget/
node_modules/
**/.DS_Store
**/.DS_Store

# Shopify
extensions/**/dist
extensions/**/node_modules
3 changes: 3 additions & 0 deletions shopify/standalone-shopify-template/.ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Shopify
extensions/**/dist
extensions/**/node_modules
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { VerifyConnectionsGlobalActionContext } from "gadget-server";
export const run: ActionRun = async ({
params,
logger,
api,
connections,
session,
}) => {
if (!session) throw new Error("No session found");

/**
* @param { VerifyConnectionsGlobalActionContext } context
*/
export async function run({ params, logger, api, connections, session }) {
// Get the user and shop from the session
const user = session.get("user");
const shop = session.get("shop");

// Clear shop from session
session.set("shop", null);
session?.set("shop", null);

// Throw error if this global action is called from outside of the signed-in area
if (!user) throw new Error("User is not signed in");
Expand Down Expand Up @@ -38,4 +41,4 @@ export async function run({ params, logger, api, connections, session }) {
},
});
}
}
};

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { applyParams, save, ActionOptions } from "gadget-server";

export const run: ActionRun = async ({
params,
record,
logger,
api,
connections,
}) => {
applyParams(params, record);
await save(record);
};

export const options: ActionOptions = {
actionType: "create",
};

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { deleteRecord, ActionOptions } from "gadget-server";

export const run: ActionRun = async ({
params,
record,
logger,
api,
connections,
}) => {
await deleteRecord(record);
};

export const options: ActionOptions = {
actionType: "delete",
};

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { applyParams, save, ActionOptions } from "gadget-server";

export const run: ActionRun = async ({
params,
record,
logger,
api,
connections,
}) => {
applyParams(params, record);
await save(record);
};

export const options: ActionOptions = {
actionType: "update",
};
Original file line number Diff line number Diff line change
@@ -1,34 +1,47 @@
import { applyParams, preventCrossShopDataAccess, save, ActionOptions, CreateShopifyGdprRequestActionContext } from "gadget-server";
import {
applyParams,
preventCrossShopDataAccess,
save,
ActionOptions,
} from "gadget-server";

/**
* @param { CreateShopifyGdprRequestActionContext } context
*/
export async function run({ params, record, logger, api, connections }) {
export const run: ActionRun = async ({
params,
record,
logger,
api,
connections,
}) => {
applyParams(params, record);
await preventCrossShopDataAccess(params, record);
await save(record);
};

/**
* @param { CreateShopifyGdprRequestActionContext } context
*/
export async function onSuccess({ params, record, logger, api, connections }) {
switch(record.topic) {
case "customers/data_request":
export const onSuccess: ActionOnSuccess = async ({
params,
record,
logger,
api,
connections,
}) => {
switch (record.topic) {
case "customers/data_request": {
// This process is a manual one. You must provide the customer's data to the store owners directly.
// See https://shopify.dev/apps/webhooks/configuration/mandatory-webhooks#customers-data_request for more information.
break;
case "customers/redact":
}
case "customers/redact": {
// Any modifications that are initiated by Shopify and emitted via webhook will automatically be handled by your existing model actions.
// The responsibility falls on you to redact any additional customer related data you may have in custom models.
break;
case "shop/redact":
}
case "shop/redact": {
// This will be received 48 hours after a store owner uninstalls your app. Any modifications that are initiated by Shopify and emitted via webhook will automatically be handled by your existing model actions.
// The responsibility falls on you to redact any additional shop related data you may have in custom models.
// See https://shopify.dev/apps/webhooks/configuration/mandatory-webhooks#shop-redact for more information.
break;
}
}
};

/** @type { ActionOptions } */
export const options = { actionType: "create" };
export const options: ActionOptions = { actionType: "create" };

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {
applyParams,
preventCrossShopDataAccess,
save,
ActionOptions,
} from "gadget-server";

export const run: ActionRun = async ({
params,
record,
logger,
api,
connections,
}) => {
applyParams(params, record);
await preventCrossShopDataAccess(params, record);
await save(record);
};

export const onSuccess: ActionOnSuccess = async ({
params,
record,
logger,
api,
connections,
}) => {
// Your logic goes here
};

export const options: ActionOptions = { actionType: "update" };

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { applyParams, save, ActionOptions } from "gadget-server";

export const run: ActionRun = async ({
params,
record,
logger,
api,
connections,
}) => {
applyParams(params, record);
await save(record);
};

export const onSuccess: ActionOnSuccess = async ({
params,
record,
logger,
api,
connections,
}) => {
// Your logic goes here
};

export const options: ActionOptions = { actionType: "create" };

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {
applyParams,
preventCrossShopDataAccess,
save,
ActionOptions,
} from "gadget-server";

export const run: ActionRun = async ({
params,
record,
logger,
api,
connections,
}) => {
applyParams(params, record);
await preventCrossShopDataAccess(params, record);
await save(record);
};

export const onSuccess: ActionOnSuccess = async ({
params,
record,
logger,
api,
connections,
}) => {
// Your logic goes here
};

export const options: ActionOptions = { actionType: "update" };

This file was deleted.

Loading

0 comments on commit 8320a64

Please sign in to comment.