Skip to content

Commit f041b7d

Browse files
authored
Merge pull request #2433 from Shopify/merge-unstable-to-internal
Merge unstable to internal
2 parents fad8cf0 + c1369d3 commit f041b7d

File tree

29 files changed

+609
-45
lines changed

29 files changed

+609
-45
lines changed

.changeset/bright-lemons-knock.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/data-extensions': patch
3+
---
4+
5+
Add data-extensions package

.changeset/orange-baboons-grab.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/ui-extensions': minor
3+
---
4+
5+
Add metafields to ShippingOption
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Create Stable Version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'New stable version (YYYY-MM)'
8+
required: true
9+
type: string
10+
11+
jobs:
12+
create-stable-version:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
token: ${{ secrets.SHOPIFY_GH_ACCESS_TOKEN }}
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: '16'
25+
26+
- name: Update GitHub Actions files
27+
run: |
28+
sed -i '/branches:/a\ - ${{ github.event.inputs.version }}' .github/workflows/changesets-reminder.yml
29+
sed -i '/branches:/a\ - ${{ github.event.inputs.version }}' .github/workflows/deploy.yml
30+
31+
- name: Create new branch
32+
run: |
33+
git checkout -b ${{ github.event.inputs.version }} origin/unstable
34+
git push -u origin ${{ github.event.inputs.version }}
35+
36+
- name: Create Pull Request
37+
uses: peter-evans/create-pull-request@v5
38+
with:
39+
token: ${{ secrets.SHOPIFY_GH_ACCESS_TOKEN }}
40+
commit-message: 'Add ${{ github.event.inputs.version }} to watched branches'
41+
title: 'Add ${{ github.event.inputs.version }} to watched branches'
42+
body: 'This PR adds the new stable version ${{ github.event.inputs.version }} to the list of watched branches in the changesets-reminder and deploy GitHub actions.'
43+
branch: 'update-watched-branches-${{ github.event.inputs.version }}'
44+
base: '${{ github.event.inputs.version }}'
45+
46+
- name: Create branch protection rule
47+
uses: octokit/[email protected]
48+
with:
49+
route: PUT /repos/{owner}/{repo}/branches/{branch}/protection
50+
owner: ${{ github.repository_owner }}
51+
repo: ${{ github.event.repository.name }}
52+
branch: ${{ github.event.inputs.version }}
53+
required_status_checks: '{"strict": true, "contexts": []}'
54+
enforce_admins: 'true'
55+
required_pull_request_reviews: '{"required_approving_review_count": 1}'
56+
restrictions: 'null'
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.SHOPIFY_GH_ACCESS_TOKEN }}
59+
60+
- name: Update LATEST_STABLE_VERSION
61+
uses: octokit/[email protected]
62+
with:
63+
route: PATCH /repos/{owner}/{repo}/actions/variables/LATEST_STABLE_VERSION
64+
owner: ${{ github.repository_owner }}
65+
repo: ${{ github.event.repository.name }}
66+
name: LATEST_STABLE_VERSION
67+
value: ${{ github.event.inputs.version }}
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.SHOPIFY_GH_ACCESS_TOKEN }}

documentation/versions-and-deploys.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,10 @@ Like the `unstable` branch, the `internal` branch also publishes snapshot releas
4545
4646
To create a new stable version, you will need to follow these steps:
4747

48-
1. Add the new stable calver version `YYYY-MM` to the list of watched branches in the [`changesets-reminder`](https://github.com/Shopify/ui-extensions/blob/unstable/.github/workflows/changesets-reminder.yml) and [`deploy`](https://github.com/Shopify/ui-extensions/blob/unstable/.github/workflows/deploy.yml) GitHub actions.
49-
1. Create a new branch for the calver version you set from the previous step. This branch should be named with the format `YYYY-MM`. You will likely branch off of `unstable` to create this branch.
50-
1. Push your new branch to GitHub. This will trigger the GitHub action that creates a new PR to consume all the changesets you copied over from `unstable` into your new version.
51-
1. Add a [branch protection rule](https://github.com/Shopify/ui-extensions/settings/branches) for your branch, following the other branch rules.
48+
1. Run the "create stable version" action.
5249
1. Pull down the branch that that was created by the GitHub action (it should have the name `changeset-release/{{BRANCH_NAME}}`). Instead of the patch version changes that were made by the action, update the version of all packages manually to be the first patch release of a new version range. For example, if you are creating a `2025-01` API version, you will set the package versions of all packages to `2025.1.0`. Apply this change to `packages/ui-extensions/package.json`, `packages/ui-extensions/CHANGELOG.md`, `packages/ui-extensions-react/package.json`, and `packages/ui-extensions-react/CHANGELOG.md`.
5350
> Note: do not update the root-level `package.json`.
54-
1. Push your new changes, and make sure you get the PR reviewed by one other member of the [UI Extension Stewards GitHub team](https://github.com/orgs/Shopify/teams/ui-extension-stewards). Make sure to check with all teams with changes included to make sure those changes are ready to release.
55-
1. Update the [`LATEST_STABLE_VERSION`](https://github.com/Shopify/ui-extensions/settings/variables/actions) repository variable to your stable version (i.e. `2025-01`). This ensures means it will be marked with a `latest` npm dist-tag on NPM.
51+
1. Push your new changes, and make sure you get the PR reviewed by one other member of the [UI Extension Stewards GitHub team](https://github.com/orgs/Shopify/teams/ui-extension-stewards).
5652
1. Merge the PR, and let robots release the new versions to NPM and tag it appropriately.
5753
1. For any changes from `unstable` that have been incorporated into the new version, delete their changeset files on the `unstable` branch and replace the existing `CHANGELOG.md` files in `unstable` with what was just shipped.
5854
1. Send a message announcing the release. Let teams know that now is the time to update their section's docs and CLI templates.

packages/data-extensions/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# `@shopify/data-extensions`
2+
3+
This package contains the public type definitions and utilities needed to create a Shopify data extension.
4+
5+
## What is a data extension?
6+
7+
A data extension is a JavaScript-based module that can hook in to client-side behaviors on Shopify’s first party UI surface areas. It differs from a UI extension in that it does not establish a long-lived channel or render any UI on the surface. It is a stateless function that executes and returns data.
8+
9+
Currently, this package contains the API for one surface.
10+
11+
- [`admin`](./src/surfaces/admin)
12+
13+
All extensions, regardless of where they appear in Shopify, make use of the same [underlying technology](../../documentation/how-extensions-work.md) and most of the same capabilities (e.g., direct API access, session tokens).
14+
15+
A data extension using “vanilla” JavaScript would be written as follows:
16+
17+
```ts
18+
import {dataExtension} from '@shopify/data-extensions/admin';
19+
20+
export default dataExtension(
21+
'admin.product-details.action.should-render',
22+
(root, {data}) => {
23+
...
24+
return {display: true}
25+
},
26+
);
27+
```
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {createPackage} from '@shopify/loom';
2+
3+
import {defaultProjectPlugin} from '../../config/loom';
4+
5+
export default createPackage((pkg) => {
6+
pkg.entry({root: './src/index.ts'});
7+
pkg.entry({name: 'admin', root: './src/surfaces/admin.ts'});
8+
pkg.use(defaultProjectPlugin());
9+
});
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "@shopify/data-extensions",
3+
"version": "0.0.0-unstable",
4+
"main": "index.js",
5+
"module": "index.mjs",
6+
"esnext": "index.esnext",
7+
"types": "./build/ts/index.d.ts",
8+
"typesVersions": {
9+
"*": {
10+
"admin": [
11+
"./build/ts/surfaces/admin.d.ts"
12+
]
13+
}
14+
},
15+
"exports": {
16+
".": {
17+
"types": "./build/ts/index.d.ts",
18+
"esnext": "./index.esnext",
19+
"import": "./index.mjs",
20+
"require": "./index.js"
21+
},
22+
"./admin": {
23+
"types": "./build/ts/surfaces/admin.d.ts",
24+
"esnext": "./build/esnext/surfaces/admin.esnext",
25+
"import": "./build/esm/surfaces/admin.mjs",
26+
"require": "./build/cjs/surfaces/admin.js"
27+
}
28+
},
29+
"license": "MIT",
30+
"sideEffects": false,
31+
"devDependencies": {
32+
"typescript": "^4.9.0"
33+
},
34+
"publishConfig": {
35+
"access": "public",
36+
"@shopify:registry": "https://registry.npmjs.org/"
37+
},
38+
"files": [
39+
"build",
40+
"src",
41+
"index.*",
42+
"README.md"
43+
]
44+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/**
2+
* Union of supported API versions
3+
*/
4+
export type ApiVersion = 'unstable';
5+
6+
export interface Auth {
7+
/**
8+
* Retrieves a Shopify OpenID Connect ID token for the current user.
9+
*/
10+
idToken: () => Promise<string | null>;
11+
}
12+
13+
/**
14+
* GraphQL error returned by the Shopify Admin API.
15+
*/
16+
export interface GraphQLError {
17+
message: string;
18+
locations: {
19+
line: number;
20+
column: string;
21+
};
22+
}
23+
24+
/**
25+
* This defines the i18n.translate() signature.
26+
*/
27+
export interface I18nTranslate {
28+
/**
29+
* This returns a translated string matching a key in a locale file.
30+
*
31+
* @example translate("banner.title")
32+
*/
33+
<ReplacementType = string>(
34+
key: string,
35+
options?: Record<string, ReplacementType | string | number>,
36+
): ReplacementType extends string | number
37+
? string
38+
: (string | ReplacementType)[];
39+
}
40+
41+
export interface I18n {
42+
/**
43+
* Returns a localized number.
44+
*
45+
* This function behaves like the standard `Intl.NumberFormat()`
46+
* with a style of `decimal` applied. It uses the buyer's locale by default.
47+
*
48+
* @param options.inExtensionLocale - if true, use the extension's locale
49+
*/
50+
formatNumber: (
51+
number: number | bigint,
52+
options?: {inExtensionLocale?: boolean} & Intl.NumberFormatOptions,
53+
) => string;
54+
55+
/**
56+
* Returns a localized currency value.
57+
*
58+
* This function behaves like the standard `Intl.NumberFormat()`
59+
* with a style of `currency` applied. It uses the buyer's locale by default.
60+
*
61+
* @param options.inExtensionLocale - if true, use the extension's locale
62+
*/
63+
formatCurrency: (
64+
number: number | bigint,
65+
options?: {inExtensionLocale?: boolean} & Intl.NumberFormatOptions,
66+
) => string;
67+
68+
/**
69+
* Returns a localized date value.
70+
*
71+
* This function behaves like the standard `Intl.DateTimeFormatOptions()` and uses
72+
* the buyer's locale by default. Formatting options can be passed in as
73+
* options.
74+
*
75+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat0
76+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat#using_options
77+
*
78+
* @param options.inExtensionLocale - if true, use the extension's locale
79+
*/
80+
formatDate: (
81+
date: Date,
82+
options?: {inExtensionLocale?: boolean} & Intl.DateTimeFormatOptions,
83+
) => string;
84+
85+
/**
86+
* Returns translated content in the buyer's locale,
87+
* as supported by the extension.
88+
*
89+
* - `options.count` is a special numeric value used in pluralization.
90+
* - The other option keys and values are treated as replacements for interpolation.
91+
* - If the replacements are all primitives, then `translate()` returns a single string.
92+
* - If replacements contain UI components, then `translate()` returns an array of elements.
93+
*/
94+
translate: I18nTranslate;
95+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export interface Extension<Api, Result> {
2+
(api: Api): Result;
3+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './api';
2+
export * from './extension';

0 commit comments

Comments
 (0)