Skip to content

Commit 8320a64

Browse files
authored
Merge pull request #118 from gadget-inc/nonem-shopify-ts
non-embedded Shopify app TS
2 parents a53f9bf + 45fcaa8 commit 8320a64

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+860
-885
lines changed
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
.gadget/
22
node_modules/
3-
**/.DS_Store
3+
**/.DS_Store
4+
5+
# Shopify
6+
extensions/**/dist
7+
extensions/**/node_modules
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Shopify
2+
extensions/**/dist
3+
extensions/**/node_modules

shopify/standalone-shopify-template/api/actions/verifyConnections.js renamed to shopify/standalone-shopify-template/api/actions/verifyConnections.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
import { VerifyConnectionsGlobalActionContext } from "gadget-server";
1+
export const run: ActionRun = async ({
2+
params,
3+
logger,
4+
api,
5+
connections,
6+
session,
7+
}) => {
8+
if (!session) throw new Error("No session found");
29

3-
/**
4-
* @param { VerifyConnectionsGlobalActionContext } context
5-
*/
6-
export async function run({ params, logger, api, connections, session }) {
710
// Get the user and shop from the session
811
const user = session.get("user");
912
const shop = session.get("shop");
1013

1114
// Clear shop from session
12-
session.set("shop", null);
15+
session?.set("shop", null);
1316

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

shopify/standalone-shopify-template/api/models/shopPermission/actions/create.js

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { applyParams, save, ActionOptions } from "gadget-server";
2+
3+
export const run: ActionRun = async ({
4+
params,
5+
record,
6+
logger,
7+
api,
8+
connections,
9+
}) => {
10+
applyParams(params, record);
11+
await save(record);
12+
};
13+
14+
export const options: ActionOptions = {
15+
actionType: "create",
16+
};

shopify/standalone-shopify-template/api/models/shopPermission/actions/delete.js

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { deleteRecord, ActionOptions } from "gadget-server";
2+
3+
export const run: ActionRun = async ({
4+
params,
5+
record,
6+
logger,
7+
api,
8+
connections,
9+
}) => {
10+
await deleteRecord(record);
11+
};
12+
13+
export const options: ActionOptions = {
14+
actionType: "delete",
15+
};

shopify/standalone-shopify-template/api/models/shopPermission/actions/update.js

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { applyParams, save, ActionOptions } from "gadget-server";
2+
3+
export const run: ActionRun = async ({
4+
params,
5+
record,
6+
logger,
7+
api,
8+
connections,
9+
}) => {
10+
applyParams(params, record);
11+
await save(record);
12+
};
13+
14+
export const options: ActionOptions = {
15+
actionType: "update",
16+
};
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,47 @@
1-
import { applyParams, preventCrossShopDataAccess, save, ActionOptions, CreateShopifyGdprRequestActionContext } from "gadget-server";
1+
import {
2+
applyParams,
3+
preventCrossShopDataAccess,
4+
save,
5+
ActionOptions,
6+
} from "gadget-server";
27

3-
/**
4-
* @param { CreateShopifyGdprRequestActionContext } context
5-
*/
6-
export async function run({ params, record, logger, api, connections }) {
8+
export const run: ActionRun = async ({
9+
params,
10+
record,
11+
logger,
12+
api,
13+
connections,
14+
}) => {
715
applyParams(params, record);
816
await preventCrossShopDataAccess(params, record);
917
await save(record);
1018
};
1119

12-
/**
13-
* @param { CreateShopifyGdprRequestActionContext } context
14-
*/
15-
export async function onSuccess({ params, record, logger, api, connections }) {
16-
switch(record.topic) {
17-
case "customers/data_request":
20+
export const onSuccess: ActionOnSuccess = async ({
21+
params,
22+
record,
23+
logger,
24+
api,
25+
connections,
26+
}) => {
27+
switch (record.topic) {
28+
case "customers/data_request": {
1829
// This process is a manual one. You must provide the customer's data to the store owners directly.
1930
// See https://shopify.dev/apps/webhooks/configuration/mandatory-webhooks#customers-data_request for more information.
2031
break;
21-
case "customers/redact":
32+
}
33+
case "customers/redact": {
2234
// Any modifications that are initiated by Shopify and emitted via webhook will automatically be handled by your existing model actions.
2335
// The responsibility falls on you to redact any additional customer related data you may have in custom models.
2436
break;
25-
case "shop/redact":
37+
}
38+
case "shop/redact": {
2639
// 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.
2740
// The responsibility falls on you to redact any additional shop related data you may have in custom models.
2841
// See https://shopify.dev/apps/webhooks/configuration/mandatory-webhooks#shop-redact for more information.
2942
break;
43+
}
3044
}
3145
};
3246

33-
/** @type { ActionOptions } */
34-
export const options = { actionType: "create" };
47+
export const options: ActionOptions = { actionType: "create" };

0 commit comments

Comments
 (0)