@shopify/shopify_function 1.0.6 → 2.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ # Changesets
2
+
3
+ Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4
+ with multi-package repos, or single-package repos to help you version and publish your code. You can
5
+ find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6
+
7
+ We have a quick list of common questions to get you started engaging with this project in
8
+ [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
3
+ "changelog": "@changesets/cli/changelog",
4
+ "commit": false,
5
+ "fixed": [],
6
+ "linked": [],
7
+ "access": "restricted",
8
+ "baseBranch": "main",
9
+ "updateInternalDependencies": "patch",
10
+ "ignore": []
11
+ }
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@shopify/shopify_function": major
3
+ ---
4
+
5
+ Using javy v2 globals for MsgPack IO
@@ -0,0 +1,26 @@
1
+ name: Snapit
2
+
3
+ on:
4
+ issue_comment:
5
+ types:
6
+ - created
7
+
8
+ jobs:
9
+ snapit:
10
+ name: Snapit
11
+ if: ${{ github.event.issue.pull_request && github.event.comment.body == '/snapit' }}
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: Checkout default branch
15
+ uses: actions/checkout@v4
16
+ - uses: pnpm/action-setup@v4
17
+ with:
18
+ version: 10
19
+ - name: Create snapshot version
20
+ uses: Shopify/snapit@main
21
+ env:
22
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
24
+ with:
25
+ build_script: echo "hello"
26
+ working_directory: ./
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public",
5
5
  "@shopify:registry": "https://registry.npmjs.org/"
6
6
  },
7
- "version": "1.0.6",
7
+ "version": "2.0.0-rc.0",
8
8
  "description": "",
9
9
  "main": "index.ts",
10
10
  "keywords": [],
@@ -16,7 +16,10 @@
16
16
  "graphql-config": "5.1.3",
17
17
  "@graphql-codegen/typescript-operations": "4.6.0",
18
18
  "@graphql-tools/url-loader": "8.0.16",
19
- "graphql": "16.10.0",
19
+ "graphql": "16.11.0",
20
20
  "typescript": "5.8.3"
21
+ },
22
+ "devDependencies": {
23
+ "@changesets/cli": "^2.28.1"
21
24
  }
22
25
  }
package/run.ts CHANGED
@@ -1,23 +1,28 @@
1
- export type ShopifyFunction<Input extends {}, Output extends {}> = (
1
+ export type UserFunction<Input extends {}, Output extends {}> = (
2
2
  input: Input
3
3
  ) => Output;
4
4
 
5
- interface Javy {
6
- JSON: {
7
- fromStdin(): any;
8
- toStdout(val: any);
9
- }
5
+ interface ShopifyFunction {
6
+ readInput(): any;
7
+ writeOutput(val: any);
10
8
  }
11
9
 
12
10
  declare global {
13
- const Javy: Javy;
11
+ const ShopifyFunction: ShopifyFunction;
14
12
  }
15
13
 
16
- export default function <I extends {}, O extends {}>(userfunction: ShopifyFunction<I, O>) {
17
- if (!Javy.JSON) {
18
- throw new Error('Javy.JSON is not defined. Please rebuild your function using the latest version of Shopify CLI.');
14
+ export default function <I extends {}, O extends {}>(
15
+ userfunction: UserFunction<I, O>
16
+ ) {
17
+ try {
18
+ ShopifyFunction;
19
+ } catch (e) {
20
+ throw new Error(
21
+ "ShopifyFunction is not defined. Please rebuild your function using the latest version of Shopify CLI."
22
+ );
19
23
  }
20
- const input_obj = Javy.JSON.fromStdin();
24
+
25
+ const input_obj = ShopifyFunction.readInput();
21
26
  const output_obj = userfunction(input_obj);
22
- Javy.JSON.toStdout(output_obj)
27
+ ShopifyFunction.writeOutput(output_obj);
23
28
  }