Skip to content

Update delivery customizations examples to use renamed targets #625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: update-function-templates-2025-07
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
888 changes: 673 additions & 215 deletions checkout/javascript/delivery-customization/default/schema.graphql

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
api_version = "2025-01"
api_version = "2025-07"

[[extensions]]
name = "t:name"
Expand All @@ -8,7 +8,7 @@ type = "function"
description = "t:description"

[[extensions.targeting]]
target = "purchase.delivery-customization.run"
target = "cart.delivery-options.transform.run"
input_query = "src/run.graphql"
export = "run"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@

/**
* @typedef {import("../generated/api").RunInput} RunInput
* @typedef {import("../generated/api").FunctionRunResult} FunctionRunResult
* @typedef {import("../generated/api").CartDeliveryOptionsTransformRunResult} CartDeliveryOptionsTransformRunResult
*/

/**
* @type {FunctionRunResult}
* @type {CartDeliveryOptionsTransformRunResult}
*/
const NO_CHANGES = {
operations: [],
};

/**
* @param {RunInput} input
* @returns {FunctionRunResult}
* @returns {CartDeliveryOptionsTransformRunResult}
*/
export function run(input) {
const configuration = JSON.parse(
Expand All @@ -27,16 +27,16 @@ export function run(input) {
{%- elsif flavor contains "typescript" -%}
import type {
RunInput,
FunctionRunResult,
CartDeliveryOptionsTransformRunResult,
} from "../generated/api";

const NO_CHANGES: FunctionRunResult = {
const NO_CHANGES: CartDeliveryOptionsTransformRunResult = {
operations: [],
};

type Configuration = {};

export function run(input: RunInput): FunctionRunResult {
export function run(input: RunInput): CartDeliveryOptionsTransformRunResult {
const configuration: Configuration = JSON.parse(
input?.deliveryCustomization?.metafield?.value ?? "{}"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { describe, it, expect } from 'vitest';
import { run } from './run';

/**
* @typedef {import("../generated/api").FunctionRunResult} FunctionRunResult
* @typedef {import("../generated/api").CartDeliveryOptionsTransformRunResult} CartDeliveryOptionsTransformRunResult
*/

describe('delivery customization function', () => {
Expand All @@ -13,15 +13,15 @@ describe('delivery customization function', () => {
metafield: null
}
});
const expected = /** @type {FunctionRunResult} */ ({ operations: [] });
const expected = /** @type {CartDeliveryOptionsTransformRunResult} */ ({ operations: [] });

expect(result).toEqual(expected);
});
});
{%- elsif flavor contains "typescript" -%}
import { describe, it, expect } from 'vitest';
import { run } from './run';
import { FunctionRunResult } from '../generated/api';
import { CartDeliveryOptionsTransformRunResult } from '../generated/api';

describe('delivery customization function', () => {
it('returns no operations without configuration', () => {
Expand All @@ -30,7 +30,7 @@ describe('delivery customization function', () => {
metafield: null
}
});
const expected: FunctionRunResult = { operations: [] };
const expected: CartDeliveryOptionsTransformRunResult = { operations: [] };

expect(result).toEqual(expected);
});
Expand Down
Loading