Skip to content

Commit

Permalink
feat(core): Implement Regions & support for Provinces
Browse files Browse the repository at this point in the history
Relates to #76

BREAKING CHANGE: A new `Region` entity has been introduced, which is a base class for `Country` and
the new `Province` entity. The `Zone.members` property is now an array of `Region` rather than
`Country`, since Zones may now be composed of both countries and provinces. If you have defined
any custom fields on `Country`, you'll need to change it to `Region` in your custom fields config.
  • Loading branch information
michaelbromley committed Apr 13, 2023
1 parent 7e01ecf commit 7b8f5bf
Show file tree
Hide file tree
Showing 41 changed files with 1,858 additions and 662 deletions.
185 changes: 160 additions & 25 deletions packages/admin-ui/src/lib/core/src/common/generated-types.ts

Large diffs are not rendered by default.

547 changes: 235 additions & 312 deletions packages/admin-ui/src/lib/core/src/common/introspection-result.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -750,9 +750,6 @@ export const GET_SERVER_CONFIG = gql`
Collection {
...CustomFields
}
Country {
...CustomFields
}
Customer {
...CustomFields
}
Expand Down Expand Up @@ -795,6 +792,9 @@ export const GET_SERVER_CONFIG = gql`
Promotion {
...CustomFields
}
Region {
...CustomFields
}
Seller {
...CustomFields
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class CountryDetailComponent
private notificationService: NotificationService,
) {
super(route, router, serverConfigService, dataService);
this.customFields = this.getCustomFieldConfig('Country');
this.customFields = this.getCustomFieldConfig('Region');
this.detailForm = this.formBuilder.group({
code: ['', Validators.required],
name: ['', Validators.required],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,10 @@ export type Cancellation = Node &
export type Channel = Node & {
code: Scalars['String'];
createdAt: Scalars['DateTime'];
/** @deprecated Use defaultCurrencyCode instead */
currencyCode: CurrencyCode;
customFields?: Maybe<Scalars['JSON']>;
defaultCurrencyCode: CurrencyCode;
defaultLanguageCode: LanguageCode;
defaultShippingZone?: Maybe<Zone>;
defaultTaxZone?: Maybe<Zone>;
Expand Down Expand Up @@ -517,17 +519,21 @@ export type CoordinateInput = {
y: Scalars['Float'];
};

export type Country = Node & {
code: Scalars['String'];
createdAt: Scalars['DateTime'];
customFields?: Maybe<Scalars['JSON']>;
enabled: Scalars['Boolean'];
id: Scalars['ID'];
languageCode: LanguageCode;
name: Scalars['String'];
translations: Array<CountryTranslation>;
updatedAt: Scalars['DateTime'];
};
export type Country = Node &
Region & {
code: Scalars['String'];
createdAt: Scalars['DateTime'];
customFields?: Maybe<Scalars['JSON']>;
enabled: Scalars['Boolean'];
id: Scalars['ID'];
languageCode: LanguageCode;
name: Scalars['String'];
parent?: Maybe<Region>;
parentId?: Maybe<Scalars['ID']>;
translations: Array<RegionTranslation>;
type: Scalars['String'];
updatedAt: Scalars['DateTime'];
};

export type CountryFilterParameter = {
code?: InputMaybe<StringOperators>;
Expand All @@ -536,6 +542,8 @@ export type CountryFilterParameter = {
id?: InputMaybe<IdOperators>;
languageCode?: InputMaybe<StringOperators>;
name?: InputMaybe<StringOperators>;
parentId?: InputMaybe<IdOperators>;
type?: InputMaybe<StringOperators>;
updatedAt?: InputMaybe<DateOperators>;
};

Expand All @@ -562,17 +570,11 @@ export type CountrySortParameter = {
createdAt?: InputMaybe<SortOrder>;
id?: InputMaybe<SortOrder>;
name?: InputMaybe<SortOrder>;
parentId?: InputMaybe<SortOrder>;
type?: InputMaybe<SortOrder>;
updatedAt?: InputMaybe<SortOrder>;
};

export type CountryTranslation = {
createdAt: Scalars['DateTime'];
id: Scalars['ID'];
languageCode: LanguageCode;
name: Scalars['String'];
updatedAt: Scalars['DateTime'];
};

export type CountryTranslationInput = {
customFields?: InputMaybe<Scalars['JSON']>;
id?: InputMaybe<Scalars['ID']>;
Expand Down Expand Up @@ -793,6 +795,13 @@ export type CreatePromotionInput = {

export type CreatePromotionResult = MissingConditionsError | Promotion;

export type CreateProvinceInput = {
code: Scalars['String'];
customFields?: InputMaybe<Scalars['JSON']>;
enabled: Scalars['Boolean'];
translations: Array<ProvinceTranslationInput>;
};

export type CreateRoleInput = {
channelIds?: InputMaybe<Array<Scalars['ID']>>;
code: Scalars['String'];
Expand Down Expand Up @@ -1211,7 +1220,6 @@ export type CustomFields = {
Asset: Array<CustomFieldConfig>;
Channel: Array<CustomFieldConfig>;
Collection: Array<CustomFieldConfig>;
Country: Array<CustomFieldConfig>;
Customer: Array<CustomFieldConfig>;
CustomerGroup: Array<CustomFieldConfig>;
Facet: Array<CustomFieldConfig>;
Expand All @@ -1226,6 +1234,7 @@ export type CustomFields = {
ProductOptionGroup: Array<CustomFieldConfig>;
ProductVariant: Array<CustomFieldConfig>;
Promotion: Array<CustomFieldConfig>;
Region: Array<CustomFieldConfig>;
Seller: Array<CustomFieldConfig>;
ShippingMethod: Array<CustomFieldConfig>;
StockLocation: Array<CustomFieldConfig>;
Expand Down Expand Up @@ -2470,6 +2479,8 @@ export type Mutation = {
/** Create a set of ProductVariants based on the OptionGroups assigned to the given Product */
createProductVariants: Array<Maybe<ProductVariant>>;
createPromotion: CreatePromotionResult;
/** Create a new Province */
createProvince: Province;
/** Create a new Role */
createRole: Role;
/** Create a new Seller */
Expand Down Expand Up @@ -2528,6 +2539,8 @@ export type Mutation = {
/** Delete multiple Products */
deleteProducts: Array<DeletionResponse>;
deletePromotion: DeletionResponse;
/** Delete a Province */
deleteProvince: DeletionResponse;
/** Delete an existing Role */
deleteRole: DeletionResponse;
/** Delete a Seller */
Expand Down Expand Up @@ -2633,6 +2646,8 @@ export type Mutation = {
/** Update multiple existing Products */
updateProducts: Array<Product>;
updatePromotion: UpdatePromotionResult;
/** Update an existing Province */
updateProvince: Province;
/** Update an existing Role */
updateRole: Role;
/** Update an existing Seller */
Expand Down Expand Up @@ -2808,6 +2823,10 @@ export type MutationCreatePromotionArgs = {
input: CreatePromotionInput;
};

export type MutationCreateProvinceArgs = {
input: CreateProvinceInput;
};

export type MutationCreateRoleArgs = {
input: CreateRoleInput;
};
Expand Down Expand Up @@ -2936,6 +2955,10 @@ export type MutationDeletePromotionArgs = {
id: Scalars['ID'];
};

export type MutationDeleteProvinceArgs = {
id: Scalars['ID'];
};

export type MutationDeleteRoleArgs = {
id: Scalars['ID'];
};
Expand Down Expand Up @@ -3181,6 +3204,10 @@ export type MutationUpdatePromotionArgs = {
input: UpdatePromotionInput;
};

export type MutationUpdateProvinceArgs = {
input: UpdateProvinceInput;
};

export type MutationUpdateRoleArgs = {
input: UpdateRoleInput;
};
Expand Down Expand Up @@ -4277,6 +4304,69 @@ export type PromotionTranslationInput = {
name?: InputMaybe<Scalars['String']>;
};

export type Province = Node &
Region & {
code: Scalars['String'];
createdAt: Scalars['DateTime'];
customFields?: Maybe<Scalars['JSON']>;
enabled: Scalars['Boolean'];
id: Scalars['ID'];
languageCode: LanguageCode;
name: Scalars['String'];
parent?: Maybe<Region>;
parentId?: Maybe<Scalars['ID']>;
translations: Array<RegionTranslation>;
type: Scalars['String'];
updatedAt: Scalars['DateTime'];
};

export type ProvinceFilterParameter = {
code?: InputMaybe<StringOperators>;
createdAt?: InputMaybe<DateOperators>;
enabled?: InputMaybe<BooleanOperators>;
id?: InputMaybe<IdOperators>;
languageCode?: InputMaybe<StringOperators>;
name?: InputMaybe<StringOperators>;
parentId?: InputMaybe<IdOperators>;
type?: InputMaybe<StringOperators>;
updatedAt?: InputMaybe<DateOperators>;
};

export type ProvinceList = PaginatedList & {
items: Array<Province>;
totalItems: Scalars['Int'];
};

export type ProvinceListOptions = {
/** Allows the results to be filtered */
filter?: InputMaybe<ProvinceFilterParameter>;
/** Specifies whether multiple "filter" arguments should be combines with a logical AND or OR operation. Defaults to AND. */
filterOperator?: InputMaybe<LogicalOperator>;
/** Skips the first n results, for use in pagination */
skip?: InputMaybe<Scalars['Int']>;
/** Specifies which properties to sort the results by */
sort?: InputMaybe<ProvinceSortParameter>;
/** Takes n results, for use in pagination */
take?: InputMaybe<Scalars['Int']>;
};

export type ProvinceSortParameter = {
code?: InputMaybe<SortOrder>;
createdAt?: InputMaybe<SortOrder>;
id?: InputMaybe<SortOrder>;
name?: InputMaybe<SortOrder>;
parentId?: InputMaybe<SortOrder>;
type?: InputMaybe<SortOrder>;
updatedAt?: InputMaybe<SortOrder>;
};

export type ProvinceTranslationInput = {
customFields?: InputMaybe<Scalars['JSON']>;
id?: InputMaybe<Scalars['ID']>;
languageCode: LanguageCode;
name?: InputMaybe<Scalars['String']>;
};

/** Returned if the specified quantity of an OrderLine is greater than the number of items in that line */
export type QuantityTooGreatError = ErrorResult & {
errorCode: ErrorCode;
Expand Down Expand Up @@ -4340,6 +4430,8 @@ export type Query = {
promotionActions: Array<ConfigurableOperationDefinition>;
promotionConditions: Array<ConfigurableOperationDefinition>;
promotions: PromotionList;
province?: Maybe<Province>;
provinces: ProvinceList;
role?: Maybe<Role>;
roles: RoleList;
search: SearchResponse;
Expand Down Expand Up @@ -4503,6 +4595,14 @@ export type QueryPromotionsArgs = {
options?: InputMaybe<PromotionListOptions>;
};

export type QueryProvinceArgs = {
id: Scalars['ID'];
};

export type QueryProvincesArgs = {
options?: InputMaybe<ProvinceListOptions>;
};

export type QueryRoleArgs = {
id: Scalars['ID'];
};
Expand Down Expand Up @@ -4640,6 +4740,28 @@ export type RefundStateTransitionError = ErrorResult & {
transitionError: Scalars['String'];
};

export type Region = {
code: Scalars['String'];
createdAt: Scalars['DateTime'];
enabled: Scalars['Boolean'];
id: Scalars['ID'];
languageCode: LanguageCode;
name: Scalars['String'];
parent?: Maybe<Region>;
parentId?: Maybe<Scalars['ID']>;
translations: Array<RegionTranslation>;
type: Scalars['String'];
updatedAt: Scalars['DateTime'];
};

export type RegionTranslation = {
createdAt: Scalars['DateTime'];
id: Scalars['ID'];
languageCode: LanguageCode;
name: Scalars['String'];
updatedAt: Scalars['DateTime'];
};

export type RelationCustomFieldConfig = CustomField & {
description?: Maybe<Array<LocalizedString>>;
entity: Scalars['String'];
Expand Down Expand Up @@ -5544,6 +5666,14 @@ export type UpdatePromotionInput = {

export type UpdatePromotionResult = MissingConditionsError | Promotion;

export type UpdateProvinceInput = {
code?: InputMaybe<Scalars['String']>;
customFields?: InputMaybe<Scalars['JSON']>;
enabled?: InputMaybe<Scalars['Boolean']>;
id: Scalars['ID'];
translations?: InputMaybe<Array<ProvinceTranslationInput>>;
};

export type UpdateRoleInput = {
channelIds?: InputMaybe<Array<Scalars['ID']>>;
code?: InputMaybe<Scalars['String']>;
Expand Down Expand Up @@ -5620,7 +5750,7 @@ export type Zone = Node & {
createdAt: Scalars['DateTime'];
customFields?: Maybe<Scalars['JSON']>;
id: Scalars['ID'];
members: Array<Country>;
members: Array<Region>;
name: Scalars['String'];
updatedAt: Scalars['DateTime'];
};
Expand Down
Loading

0 comments on commit 7b8f5bf

Please sign in to comment.