Skip to content

Commit

Permalink
Merge branch 'master' into advance-rfc-0811
Browse files Browse the repository at this point in the history
  • Loading branch information
wagenet authored Apr 7, 2023
2 parents 7d19427 + 178440a commit 6ef2f4f
Show file tree
Hide file tree
Showing 22 changed files with 2,337 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup-rfcs-tooling/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ runs:
with:
repository: emberjs/rfcs-tooling
path: rfcs-tooling
ref: 'v2.1.1'
ref: 'v3.0.0'

- uses: actions/setup-node@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/advance-rfc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
echo "A new RFC was added"
echo "value=true" >> $GITHUB_OUTPUT
else
node rfcs-tooling/has-stage-changed.js ${{ github.event.before }} ${{ steps.rfcs.outputs.modified-rfc }}
node rfcs-tooling/scripts/has-stage-changed.mjs ${{ github.event.before }} ${{ steps.rfcs.outputs.modified-rfc }}
if [[ $? == 0 ]]; then
echo "## Yes, stage has changed" >> $GITHUB_STEP_SUMMARY
echo "value=true" >> $GITHUB_OUTPUT
Expand All @@ -69,7 +69,7 @@ jobs:
if: steps.has-stage-changed.outputs.value == 'true'
id: new-stage
run: |
new_stage=`node rfcs-tooling/find-next-stage.js ${{ steps.rfcs.outputs.modified-rfc }}`
new_stage=`node rfcs-tooling/scripts/find-next-stage.mjs ${{ steps.rfcs.outputs.modified-rfc }}`
echo "New Stage: $new_stage"
echo "value=$new_stage" >> $GITHUB_OUTPUT
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
uses: ./.github/actions/setup-rfcs-tooling

- name: Lint the frontmatter of all RFCs
run: node ./rfcs-tooling/lint-rfc-frontmatter.js text/*.md
run: node ./rfcs-tooling/scripts/lint-rfc-frontmatter.mjs text/*.md
2 changes: 1 addition & 1 deletion .github/workflows/generate-rfc-frontmatter-json.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- name: Generate frontmatter data file
run: |
node rfcs-tooling/list-frontmatter.js text/*.md > rfc-data.json
node rfcs-tooling/scripts/list-frontmatter.mjs text/*.md > rfc-data.json
- uses: actions/upload-artifact@v3
with:
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/newly-added-rfcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:

- name: Verify stage of newly added RFC is `accepted` in frontmatter
run: |
frontmatter=`node rfcs-tooling/rfc-frontmatter.js ${{ needs.check-rfcs.outputs.modified-rfc }}`
frontmatter=`node rfcs-tooling/scripts/rfc-frontmatter.mjs ${{ needs.check-rfcs.outputs.modified-rfc }}`
stage=`echo $frontmatter | jq '.stage'`
if [[ $stage != '"accepted"' ]]; then
echo "::error::Newly added RFCs must have the stage 'accepted' in the frontmatter"
Expand All @@ -113,8 +113,7 @@ jobs:
- name: Test RFC Filename matches PR Number that adds it
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: node check-filename-matches-pr.js $PR_NUMBER ${{ needs.check-rfcs.outputs.modified-rfc }}
working-directory: rfcs-tooling
run: node rfcs-tooling/scripts/check-filename-matches-pr.mjs $PR_NUMBER ${{ needs.check-rfcs.outputs.modified-rfc }}

check-accepted-pr-url:
name: Verify Accepted PR URL is correct
Expand All @@ -129,7 +128,7 @@ jobs:

- name: Verify Accepted PR URL is correct
run: |
frontmatter=`node rfcs-tooling/rfc-frontmatter.js ${{ needs.check-rfcs.outputs.modified-rfc }}`
frontmatter=`node rfcs-tooling/scripts/rfc-frontmatter.mjs ${{ needs.check-rfcs.outputs.modified-rfc }}`
accepted_pr=`echo $frontmatter | jq '.prs.accepted'`
accepted_pr=${accepted_pr//\"/}
expected_pr="${{ github.event.pull_request.html_url }}"
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/open-advancement-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ jobs:

- name: Update frontmatter
run: |
node rfcs-tooling/update-rfc-stage.js ${{ inputs.new-stage }} ${{ inputs.rfc-path }}
node rfcs-tooling/scripts/update-rfc-stage.mjs ${{ inputs.new-stage }} ${{ inputs.rfc-path }}
- name: Set variables for use in PR
id: pr-variables
run: |
frontmatter=`node rfcs-tooling/rfc-frontmatter.js ${{ inputs.rfc-path }}`
frontmatter=`node rfcs-tooling/scripts/rfc-frontmatter.mjs ${{ inputs.rfc-path }}`
ready_for_release_pr=`echo $frontmatter | jq '.prs."ready-for-release"'`
ready_for_release_pr=${ready_for_release_pr//\"/}
released_pr=`echo $frontmatter | jq '.prs.released'`
released_pr=${released_pr//\"/}
title=`echo $frontmatter | jq '.title'`
if [[ ${{ inputs.new-stage }} == "ready-for-release" ]]; then
pretty_stage="Ready for Release"
template=`sed -e 's/__RFC_NUMBER__/${{ inputs.rfc-number }}/g' .github/PULL_REQUEST_TEMPLATE/advance-to-ready-for-release.md`
Expand All @@ -53,23 +54,24 @@ jobs:
echo 'EOF' >> $GITHUB_OUTPUT
echo "Pretty Stage: $pretty_stage"
echo "pretty-stage=$pretty_stage" >> $GITHUB_OUTPUT
echo "title=$title" >> $GITHUB_OUTPUT
- name: Open PR
id: create-pr
uses: peter-evans/create-pull-request@v4.2.0
with:
token: ${{ secrets.personal-access-token }}
commit-message: "Advance RFC to Stage ${{ inputs.new-stage }}"
commit-message: "Advance RFC {{ inputs.rfc-number }} to Stage ${{ inputs.new-stage }}"
add-paths: 'text'
branch: "advance-rfc-${{ inputs.rfc-number }}"
title: "Advance RFC #${{ inputs.rfc-number}} to Stage ${{ steps.pr-variables.outputs.pretty-stage }}"
title: "Advance RFC #${{ inputs.rfc-number}} `${{ steps.pr-variables.outputs.title }}` to Stage ${{ steps.pr-variables.outputs.pretty-stage }}"
body: "${{ steps.pr-variables.outputs.body }}"
labels: "RFC Advancement,S-${{ steps.pr-variables.outputs.pretty-stage}}"
draft: true

- name: Add new PR link to RFC frontmatter
run: |
node rfcs-tooling/update-advancement-pr.js ${{ inputs.rfc-path }} ${{ inputs.new-stage}} ${{ steps.create-pr.outputs.pull-request-url }}
node rfcs-tooling/scripts/update-advancement-pr.mjs ${{ inputs.rfc-path }} ${{ inputs.new-stage}} ${{ steps.create-pr.outputs.pull-request-url }}
- name: Update PR
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/trigger-opening-advancement-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Find new stage
id: new-stage
run: |
new_stage=`node rfcs-tooling/find-next-stage.js ${{ inputs.rfc-path }}`
new_stage=`node rfcs-tooling/scripts/find-next-stage.mjs ${{ inputs.rfc-path }}`
echo "New Stage: $new_stage"
echo "value=$new_stage" >> $GITHUB_OUTPUT
Expand Down
14 changes: 9 additions & 5 deletions text/0236-deprecation-ember-string.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
---
stage: recommended
start-date: 2017-07-14T00:00:00.000Z
release-date: 2020-12-28T00:00:00.000Z
release-date: 2023-01-12T00:00:00.000Z
release-versions:
ember-source: v3.24.0

ember-source: v4.10.0
teams:
- framework
- typescript
prs:
accepted: https://github.com/emberjs/rfcs/pull/236
accepted: 'https://github.com/emberjs/rfcs/pull/236'
ready-for-release: 'https://github.com/emberjs/rfcs/pull/892'
released: 'https://github.com/emberjs/rfcs/pull/897'
recommended: 'https://github.com/emberjs/rfcs/pull/898'
project-link:
meta:
tracking: https://github.com/emberjs/rfc-tracking/issues/26
tracking: 'https://github.com/emberjs/ember.js/issues/20340'
legacy-tracking: 'https://github.com/emberjs/rfc-tracking/issues/26'
---

# Summary
Expand Down
2 changes: 1 addition & 1 deletion text/0331-deprecate-globals-resolver.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
stage: released
stage: recommended
start-date: 2018-05-08T00:00:00.000Z
release-date: 2020-01-20T00:00:00.000Z
release-versions:
Expand Down
4 changes: 2 additions & 2 deletions text/0487-custom-model-classes.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
stage: released # FIXME: This may be recommended
start-date: 2019-05-09T00:00:00.000Z
release-date: 2019-09-19T00:00:00.000Z
release-date: 2021-08-20T00:00:00.000Z
release-versions:
ember-source: v3.13.0
ember-data: v3.28.0

teams:
- data
Expand Down
2 changes: 1 addition & 1 deletion text/0625-helper-managers.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
stage: released # FIXME: This may be a further stage
stage: recommended
start-date: 2020-04-28T00:00:00.000Z
release-date: 2020-11-16T00:00:00.000Z
release-versions:
Expand Down
5 changes: 3 additions & 2 deletions text/0739-ember-data-deprecate-non-strict-relationships.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
stage: accepted # FIXME: This may be a further stage
stage: ready-for-release
start-date: 2021-04-23T00:00:00.000Z
release-date:
release-versions:
teams:
- data
prs:
accepted: https://github.com/emberjs/rfcs/pull/739
accepted: 'https://github.com/emberjs/rfcs/pull/739'
ready-for-release: 'https://github.com/emberjs/rfcs/pull/909'
project-link:
---

Expand Down
6 changes: 3 additions & 3 deletions text/0756-helper-default-manager.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
stage: released # FIXME: This may be recommended
stage: recommended
start-date: 2021-05-17T00:00:00.000Z
release-date: 2022-05-13T00:00:00.000Z
release-versions:
ember-source: v4.5.0

teams:
- framework
- learning
prs:
accepted: https://github.com/emberjs/rfcs/pull/756
accepted: 'https://github.com/emberjs/rfcs/pull/756'
recommended: 'https://github.com/emberjs/rfcs/pull/866'
project-link:
---

Expand Down
89 changes: 89 additions & 0 deletions text/0774-implicit-record-route-loading.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
stage: accepted
start-date: 2021-11-14
release-date:
release-versions:
teams: # delete teams that aren't relevant
- framework
prs:
accepted: https://github.com/emberjs/rfcs/pull/774
---

# Deprecate Implicit Record Loading in Routes

## Summary

This RFC seeks to deprecate and remove the default record loading behaviour on Ember's Route. By consequence, this will also deprecate and remove the default store on every Route. This behaviour is likely something you either know you have or do not know but it may be occuring in your app.

```js
export default class PostRoute extends Route {
beforeModel() {
// do stuff
}

afterModel() {
// do stuff
}
}
```

In this example, the `model` hook is not defined. However, Ember will attempt to try a few things before rendering this route's template.

1. If there is a `store` property on your route, it will attempt to call it's `find` method. Assuming you have `ember-data` installed, you may be expecting this. The arguments will be extracted from the params.
a. For example, if a dynamic segment is `:post_id`, there exists logic to split on the underscore and find a record of type `post`.

2. As a fallback, it will attempt to define a `find` method and use your `Model` instance's find method to fetch. If a `Model` cannot be found or if the found `Model` does not have a `find` method, an assertion is thrown.

## Motivation

If a user does not define a `model` hook, a side effect of going to the network has long confused developers. Users have come to associate `Route.model()` with a hook that returns `ember-data` models in the absense of explicit injection. While this can be true, it is not wholly true. New patterns of data loading are becoming accepted in the community including opting to fetch data in a Component or using different libraries.

By removing this behaviour, we will encourage developers to explicitly define what data is being fetched and from where.

## Detailed design

We will issue a deprecation to [`findModel`](https://github.com/emberjs/ember.js/blob/017b11e2f58880869a5b8c647bf7f3199fc07f26/packages/%40ember/-internals/routing/lib/system/route.ts#L1376) notifying the user that if they want to continue this behaviour of attempting to fetch a resource implicitly, they should try and replicate with their own explicitly defined `model` hook.

In addition, we will include an [optional feature](https://github.com/emberjs/ember-optional-features) to disable this feature and clear the deprecation.

In v6.0.0, we will remove `findModel` and logic to determine arguments for this method. This will not remove returning the `transition` context when no `model` hook is defined.

## How we teach this

Most of this behaviour is lightly documented. Developers often come to this by mistake after some difficult searching. First, we will have to remove this sentence from the [docs](https://guides.emberjs.com/release/routing/defining-your-routes/#toc_dynamic-segments).

> The first reason is that Routes know how to fetch the right model by default, if you follow the convention.
A direct one to one replacement might look like this.

```js
import { inject as service } from '@ember/service';

export default class PostRoute extends Route {
// assuming you have ember-data installed
@service store;

beforeModel() {
// do stuff
}

model({ post_id }) {
return this.store.findRecord('post', post_id);
}

afterModel() {
// do stuff
}
}
```

## Alternatives

- Continue to provide fallback fetching behaviour but ensure no `assert` is called for users that have neither a store nor a `Model` with a `find` method.

## Open Questions

## Related links and RFCs
- [Deprecate defaultStore located at `Route.store`](https://github.com/emberjs/rfcs/issues/377)
- [Pre-RFC: Deprecate implicit injections (owner.inject)](https://github.com/emberjs/rfcs/issues/508)
- [Deprecate implicit record loading in routes](https://github.com/emberjs/rfcs/issues/557)
10 changes: 7 additions & 3 deletions text/0776-typescript-blueprints.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
---
stage: accepted
stage: released
start-date: 2021-11-11T00:00:00.000Z
release-date:
release-date: 2022-12-08T00:00:00.000Z
release-versions:
ember-cli: v4.9.0
ember-source: v4.9.0
teams:
- cli
- framework
prs:
accepted: https://github.com/emberjs/rfcs/pull/776
accepted: 'https://github.com/emberjs/rfcs/pull/776'
ready-for-release: 'https://github.com/emberjs/rfcs/pull/873'
released: 'https://github.com/emberjs/rfcs/pull/911'
project-link:
---

Expand Down
59 changes: 59 additions & 0 deletions text/0790-deprecate-ember-data-ajax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
stage: accepted
start-date: 2022-01-29
release-date: Unreleased
release_versions:
teams:
- data
prs:
accepted: https://github.com/emberjs/rfcs/pull/790
project-link:
suite:
---

# EmberData | Deprecate ajax requests

## Summary

Deprecates use of `ajax` methods in favor of `fetch` to request API data.

## Motivation

Currently, `ember-data` maintains two methods for users to fetch data from their backend - fetching with `jQuery.ajax` and `fetch`. Confusion further exists in the adapters if users implement functionality to change out of the box behaviour. They can override [`ajax`](https://github.com/emberjs/data/blob/e076e0ae71ae6426ca53ad3c5501a0af7ceca883/packages/adapter/addon/rest.ts#L1091-L1126) methods but without a clean interface to operate with, what they really may be doing is overriding how fetch works.

With Ember 4.0 dropping jQuery, we should take a hard stance on dropping the use of `ajax` in the next major release.

## Detailed design

The first step is putting in place a deprecation if an adapter uses `ajax` to make a request. Since `ember-data` switched the default behaviour to use fetch in 4.0, this deprecation will only apply to those who have overrided the default with `useFetch = true` in their adapters.

Second, we will expose fetch related methods on the adapters that are equivalent in use and flexibility as the current `ajax` options. Note the [`minimum-adapter-interface`](https://github.com/emberjs/data/blob/master/packages/store/addon/-private/ts-interfaces/minimum-adapter-interface.ts) does not assert the method by which a request is made. As a result, how we design and implement these methods should not have an effect on those users who have implemented their own adapter.

In 5.0, all `ajax` methods and supporting infrastructure will be removed. The list of affected methods includes:

- ajax
- _ajaxRequest
- _ajax
- ajaxOptions
- _ajaxUrl

Moreover, we may rename methods not part of the minimum-adapter-interface. Moreover, we expect to implement the following methods with [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch), although could be changed in the actual implementation.

- fetch
- fetchOptions
- fetchSuccess
- fetchError
- fetchUrl

## How we teach this

This is best taught through a deprecation guide. Users using `ajax` will need to install `ember-fetch` or rely on the default global `fetch` API provided by the browser. This has some implications, for example, with how query params are serialized. Users will have to be careful to ensure the behaviour of their API changes with any changes that result from switching to fetch.

## Drawbacks

Some user's technology stacks may be entirely dependent on `ajax` for requesting API data. This isn't necessarily an easy switch and may require multiple improvements to various layers to use `fetch`. For those users, we can document how they can still implement their own adapter to use `ajax`. This will involve overriding the existing `fetch` methods. For example, if your API still needs to be serviced with `ajax` to perhaps take advantage of [ajax options](https://api.jquery.com/jquery.ajax/#jQuery-ajax-url-settings) or [ajaxPrefilter](https://api.jquery.com/jquery.ajaxprefilter/), simply override the existing `fetch` methods. The goal of this refactor would be to ensure users who still need to use `ajax` has a happy path to doing so.

## Alternatives

- Continue providing and exposing public-ish adapters methods as `ajax`.
- Provide both `fetch` and `ajax` methods together in the adapters.
Loading

0 comments on commit 6ef2f4f

Please sign in to comment.