Skip to content

Commit 33d6b99

Browse files
committed
Cleanup local pickup examples
1 parent aa7b3db commit 33d6b99

File tree

9 files changed

+118
-86
lines changed

9 files changed

+118
-86
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "{{name}}",
3+
"description": "{{name}}"
4+
}

order-routing/javascript/local-pickup-delivery-option-generators/default/package.json.liquid

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@
1111
},
1212
"codegen": {
1313
"schema": "schema.graphql",
14-
"documents": "input.graphql",
14+
"documents": "src/*.graphql",
1515
"generates": {
1616
"./generated/api.ts": {
1717
"plugins": [
1818
"typescript",
1919
"typescript-operations"
2020
]
2121
}
22+
},
23+
"config": {
24+
"omitOperationSuffix": true
2225
}
2326
},
2427
"devDependencies": {
Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1-
name = "{{name}}"
2-
type = "local_pickup_delivery_option_generator"
3-
{% if uid %}uid = "{{ uid }}"{% endif %}
41
api_version = "unstable"
52

6-
[build]
7-
command = ""
8-
path = "dist/function.wasm"
3+
[[extensions]]
4+
name = "t:name"
5+
handle = "{{handle}}"
6+
type = "function"
7+
{% if uid %}uid = "{{ uid }}"{% endif %}
8+
9+
[[extensions.targeting]]
10+
target = "purchase.local-pickup-delivery-option-generator.run"
11+
input_query = "src/run.graphql"
12+
export = "run"
13+
14+
[extensions.build]
15+
command = ""
16+
path = "dist/function.wasm"
17+
18+
[extensions.ui.paths]
19+
create = "/"
20+
details = "/"
Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1 @@
1-
{%- if flavor contains "vanilla-js" -%}
2-
// @ts-check
3-
4-
/**
5-
* @typedef {import("../generated/api").InputQuery} InputQuery
6-
* @typedef {import("../generated/api").FunctionResult} FunctionResult
7-
*/
8-
9-
/**
10-
* @type {FunctionResult}
11-
*/
12-
const DELIVERY_OPTION = {
13-
operations: [
14-
{
15-
add: {
16-
title: "Main St.",
17-
cost: 1.99,
18-
pickupLocation: {
19-
locationHandle: "2578303",
20-
pickupInstruction: "Usually ready in 24 hours."
21-
}
22-
}
23-
}
24-
],
25-
};
26-
27-
export default /**
28-
* @param {InputQuery} input
29-
* @returns {FunctionResult}
30-
*/
31-
(input) => {
32-
const configuration = JSON.parse(
33-
input?.deliveryOptionGenerator?.metafield?.value ?? "{}"
34-
);
35-
36-
return DELIVERY_OPTION;
37-
};
38-
{%- elsif flavor contains "typescript" -%}
39-
import {
40-
InputQuery,
41-
FunctionResult,
42-
} from "../generated/api";
43-
44-
const DELIVERY_OPTION: FunctionResult = {
45-
operations: [
46-
{
47-
add: {
48-
title: "Main St.",
49-
cost: 1.99,
50-
pickupLocation: {
51-
locationHandle: "2578303",
52-
pickupInstruction: "Usually ready in 24 hours."
53-
}
54-
}
55-
}
56-
],
57-
};
58-
59-
type Configuration = {};
60-
61-
export default (input: InputQuery): FunctionResult => {
62-
const configuration: Configuration = JSON.parse(
63-
input?.deliveryOptionGenerator?.metafield?.value ?? "{}"
64-
);
65-
return DELIVERY_OPTION;
66-
};
67-
{%- endif -%}
1+
export * from './run';

order-routing/javascript/local-pickup-delivery-option-generators/default/input.graphql.liquid renamed to order-routing/javascript/local-pickup-delivery-option-generators/default/src/run.graphql.liquid

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
query Input {
1+
query RunInput {
22
cart {
33
lines {
44
id
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{%- if flavor contains "vanilla-js" -%}
2+
// @ts-check
3+
4+
/**
5+
* @typedef {import("../generated/api").InputQuery} InputQuery
6+
* @typedef {import("../generated/api").FunctionResult} FunctionResult
7+
*/
8+
9+
/**
10+
* @type {FunctionResult}
11+
*/
12+
const DELIVERY_OPTION = {
13+
operations: [
14+
{
15+
add: {
16+
title: "Main St.",
17+
cost: 1.99,
18+
pickupLocation: {
19+
locationHandle: "2578303",
20+
pickupInstruction: "Usually ready in 24 hours."
21+
}
22+
}
23+
}
24+
],
25+
};
26+
27+
export default /**
28+
* @param {InputQuery} input
29+
* @returns {FunctionResult}
30+
*/
31+
(input) => {
32+
const configuration = JSON.parse(
33+
input?.deliveryOptionGenerator?.metafield?.value ?? "{}"
34+
);
35+
36+
return DELIVERY_OPTION;
37+
};
38+
{%- elsif flavor contains "typescript" -%}
39+
import {
40+
InputQuery,
41+
FunctionResult,
42+
} from "../generated/api";
43+
44+
const DELIVERY_OPTION: FunctionResult = {
45+
operations: [
46+
{
47+
add: {
48+
title: "Main St.",
49+
cost: 1.99,
50+
pickupLocation: {
51+
locationHandle: "2578303",
52+
pickupInstruction: "Usually ready in 24 hours."
53+
}
54+
}
55+
}
56+
],
57+
};
58+
59+
type Configuration = {};
60+
61+
export default (input: InputQuery): FunctionResult => {
62+
const configuration: Configuration = JSON.parse(
63+
input?.deliveryOptionGenerator?.metafield?.value ?? "{}"
64+
);
65+
return DELIVERY_OPTION;
66+
};
67+
{%- endif -%}

order-routing/javascript/local-pickup-delivery-option-generators/default/src/index.test.liquid renamed to order-routing/javascript/local-pickup-delivery-option-generators/default/src/run.test.liquid

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{%- if flavor contains "vanilla-js" -%}
22
import { describe, it, expect } from 'vitest';
3-
import deliveryOptionGenerator from './index';
3+
import deliveryOptionGenerator from './run';
44

55
/**
66
* @typedef {import("../generated/api").FunctionResult} FunctionResult
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "{{name}}",
3+
"description": "{{name}}"
4+
}
Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1-
name = "{{name}}"
2-
type = "local_pickup_delivery_option_generator"
3-
{% if uid %}uid = "{{ uid }}"{% endif %}
41
api_version = "unstable"
52

6-
[build]
7-
command = "cargo build --target=wasm32-wasip1 --release"
8-
path = "target/wasm32-wasip1/release/{{name | replace: " ", "-" | downcase}}.wasm"
9-
watch = [ "src/**/*.rs" ]
3+
[[extensions]]
4+
name = "t:name"
5+
handle = "{{handle}}"
6+
type = "function"
7+
{% if uid %}uid = "{{ uid }}"{% endif %}
8+
9+
[[extensions.targeting]]
10+
target = "purchase.local-pickup-delivery-option-generator.run"
11+
input_query = "src/run.graphql"
12+
export = "run"
13+
14+
[extensions.build]
15+
command = "cargo build --target=wasm32-wasip1 --release"
16+
path = "target/wasm32-wasip1/release/{{handle | replace: " ", "-" | downcase}}.wasm"
17+
watch = [ "src/**/*.rs" ]
1018

11-
[ui.paths]
12-
create = "/"
13-
details = "/"
19+
[extensions.ui.paths]
20+
create = "/"
21+
details = "/"

0 commit comments

Comments
 (0)