Skip to content

[WIP] Simplify template by removing aliasing #616

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ description = "t:description"

[[extensions.targeting]]
target = "cart.lines.discounts.generate.run"
input_query = "src/generate_cart_run.graphql"
export = "generate-cart-run"
input_query = "src/cart_lines_discounts_generate_run.graphql"
export = "cart-lines-discounts-generate-run"

[[extensions.targeting]]
target = "cart.delivery-options.discounts.generate.run"
input_query = "src/generate_delivery_run.graphql"
export = "generate-delivery-run"
input_query = "src/cart_delivery_options_discounts_generate_run.graphql"
export = "cart-delivery-options-discounts-generate-run"

[extensions.build]
command = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { DeliveryDiscountSelectionStrategy} from '../generated/api';
* @typedef {import("../generated/api").CartDeliveryOptionsDiscountsGenerateRunResult} CartDeliveryOptionsDiscountsGenerateRunResult
*/
/**
* generateDeliveryRun
* cartDeliveryOptionsDiscountsGenerateRun
* @param {RunInput} input - The DeliveryInput
* @returns {CartDeliveryOptionsDiscountsGenerateRunResult} - The function result with discounts.
*/
export function generateDeliveryRun(input) {
export function cartDeliveryOptionsDiscountsGenerateRun(input) {
const firstDeliveryGroup = input.cart.deliveryGroups[0];
if (!firstDeliveryGroup) {
throw new Error('No delivery groups found');
Expand Down Expand Up @@ -51,7 +51,7 @@ import {
CartDeliveryOptionsDiscountsGenerateRunResult,
} from '../generated/api';

export function generateDeliveryRun(
export function cartDeliveryOptionsDiscountsGenerateRun(
input: DeliveryInput,
): CartDeliveryOptionsDiscountsGenerateRunResult {
const firstDeliveryGroup = input.cart.deliveryGroups[0];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{%- if flavor contains "vanilla-js" -%}
import { describe, it, expect } from "vitest";

import { generateDeliveryRun } from "./generate_delivery_run";
import { cartDeliveryOptionsDiscountsGenerateRun } from "./cart_delivery_options_discounts_generate_run";
import {
DeliveryDiscountSelectionStrategy,
} from "../generated/api";
Expand All @@ -11,7 +11,7 @@ import {
* @typedef {import("../generated/api").DeliveryInput} DeliveryInput
*/

describe("generateDeliveryRun", () => {
describe("cartDeliveryOptionsDiscountsGenerateRun", () => {
it("returns a delivery discount", () => {
const input = /** @type {DeliveryInput} */ ({
cart: {
Expand All @@ -23,7 +23,7 @@ describe("generateDeliveryRun", () => {
},
});

const result = generateDeliveryRun(input);
const result = cartDeliveryOptionsDiscountsGenerateRun(input);

expect(result.operations.length).toBe(1);
expect(result.operations[0]).toMatchObject({
Expand Down Expand Up @@ -53,14 +53,14 @@ describe("generateDeliveryRun", () => {
{%- elsif flavor contains "typescript" -%}
import { describe, it, expect } from "vitest";

import { generateDeliveryRun } from "./generate_delivery_run";
import { cartDeliveryOptionsDiscountsGenerateRun } from "./cart_delivery_options_discounts_generate_run";
import {
DeliveryDiscountSelectionStrategy,
DeliveryInput,
CartDeliveryOptionsDiscountsGenerateRunResult
} from "../generated/api";

describe("generateDeliveryRun", () => {
describe("cartDeliveryOptionsDiscountsGenerateRun", () => {
it("returns a delivery discount", () => {
const input: DeliveryInput = {
cart: {
Expand All @@ -72,7 +72,7 @@ describe("generateDeliveryRun", () => {
},
};

const result: CartDeliveryOptionsDiscountsGenerateRunResult = generateDeliveryRun(input);
const result: CartDeliveryOptionsDiscountsGenerateRunResult = cartDeliveryOptionsDiscountsGenerateRun(input);

expect(result.operations.length).toBe(1);
expect(result.operations[0]).toMatchObject({
Expand All @@ -99,4 +99,4 @@ describe("generateDeliveryRun", () => {
});
});
});
{%- endif -%}
{%- endif -%}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import {
*/

/**
* generateCartRun
* cartLinesDiscountsGenerateRun
* @param {CartInput} input - The CartInput
* @returns {CartLinesDiscountsGenerateRunResult} - The function result with discounts.
*/
export function generateCartRun(input) {
export function cartLinesDiscountsGenerateRun(input) {
if (!input.cart.lines.length) {
throw new Error('No cart lines found');
}
Expand Down Expand Up @@ -83,7 +83,7 @@ import {
CartLinesDiscountsGenerateRunResult,
} from '../generated/api';

export function generateCartRun(input: CartInput): CartLinesDiscountsGenerateRunResult {
export function cartLinesDiscountsGenerateRun(input: CartInput): CartLinesDiscountsGenerateRunResult {
if (!input.cart.lines.length) {
throw new Error('No cart lines found');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{%- if flavor contains "vanilla-js" -%}
import { describe, it, expect } from "vitest";

import { generateCartRun } from "./generate_cart_run";
import { cartLinesDiscountsGenerateRun } from "./cart_lines_discounts_generate_run";
import {
OrderDiscountSelectionStrategy,
ProductDiscountSelectionStrategy,
Expand All @@ -11,7 +11,7 @@ import {
* @typedef {import("../generated/api").CartLinesDiscountsGenerateRunResult} CartLinesDiscountsGenerateRunResult
*/

describe("generateCartRun", () => {
describe("cartLinesDiscountsGenerateRun", () => {
it("returns a product and order discount", () => {
const input = {
cart: {
Expand All @@ -26,7 +26,7 @@ describe("generateCartRun", () => {
},
};

const result = generateCartRun(input);
const result = cartLinesDiscountsGenerateRun(input);

expect(result.operations.length).toBe(2);
expect(result.operations[0]).toMatchObject({
Expand Down Expand Up @@ -79,15 +79,15 @@ describe("generateCartRun", () => {
{%- elsif flavor contains "typescript" -%}
import { describe, it, expect } from "vitest";

import { generateCartRun } from "./generate_cart_run";
import { cartLinesDiscountsGenerateRun } from "./cart_lines_discounts_generate_run";
import {
OrderDiscountSelectionStrategy,
ProductDiscountSelectionStrategy,
CartInput,
CartLinesDiscountsGenerateRunResult
} from "../generated/api";

describe("generateCartRun", () => {
describe("cartLinesDiscountsGenerateRun", () => {
it("returns a product and order discount", () => {
const input: CartInput = {
cart: {
Expand All @@ -102,7 +102,7 @@ describe("generateCartRun", () => {
},
};

const result: CartLinesDiscountsGenerateRunResult = generateCartRun(input);
const result: CartLinesDiscountsGenerateRunResult = cartLinesDiscountsGenerateRun(input);

expect(result.operations.length).toBe(2);
expect(result.operations[0]).toMatchObject({
Expand Down Expand Up @@ -152,4 +152,4 @@ describe("generateCartRun", () => {
});
});
});
{%- endif -%}
{%- endif -%}
4 changes: 2 additions & 2 deletions discounts/javascript/discount/default/src/index.liquid
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './generate_cart_run';
export * from './generate_delivery_run';
export * from './cart_lines_discounts_generate_run';
export * from './cart_delivery_options_discounts_generate_run';
8 changes: 4 additions & 4 deletions discounts/rust/discount/default/shopify.extension.toml.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ description = "t:description"

[[extensions.targeting]]
target = "cart.lines.discounts.generate.run"
input_query = "src/generate_cart_run.graphql"
export = "generate_cart_run"
input_query = "src/cart_lines_discounts_generate_run.graphql"
export = "cart_lines_discounts_generate_run"

[[extensions.targeting]]
target = "cart.delivery-options.discounts.generate.run"
input_query = "src/generate_delivery_run.graphql"
export = "generate_delivery_run"
input_query = "src/cart_delivery_options_discounts_generate_run.graphql"
export = "cart_delivery_options_discounts_generate_run"

[extensions.build]
command = "cargo build --target=wasm32-wasip1 --release"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ use cart_delivery_options_discounts_generate_run::output::{
use cart_delivery_options_discounts_generate_run::input::ResponseData;

#[shopify_function_target(
target = "cartDeliveryOptionsDiscountsGenerateRun",
query_path = "src/generate_delivery_run.graphql",
query_path = "src/cart_delivery_options_discounts_generate_run.graphql",
schema_path = "schema.graphql"
)]
fn generate_delivery_run(
fn cart_delivery_options_discounts_generate_run(
input: ResponseData,
) -> Result<CartDeliveryOptionsDiscountsGenerateRunResult> {
let first_delivery_group = input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ use cart_lines_discounts_generate_run::output::{
use cart_lines_discounts_generate_run::input::ResponseData;

#[shopify_function_target(
target = "cartLinesDiscountsGenerateRun",
query_path = "src/generate_cart_run.graphql",
query_path = "src/cart_lines_discounts_generate_run.graphql",
schema_path = "schema.graphql"
)]
fn generate_cart_run(input: ResponseData) -> Result<CartLinesDiscountsGenerateRunResult> {
fn cart_lines_discounts_generate_run(
input: ResponseData,
) -> Result<CartLinesDiscountsGenerateRunResult> {
let max_cart_line = input
.cart
.lines
Expand Down
4 changes: 2 additions & 2 deletions discounts/rust/discount/default/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::process;
pub mod generate_cart_run;
pub mod generate_delivery_run;
pub mod cart_delivery_options_discounts_generate_run;
pub mod cart_lines_discounts_generate_run;

fn main() {
eprintln!("Please invoke a named export.");
Expand Down