Skip to content
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

chore: add recommended JSON:API setup test app #8832

Merged
merged 6 commits into from
Sep 4, 2023
Merged
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
/packages/request-utils/addon/
/packages/rest/addon/
/packages/active-record/addon/
/packages/data-worker/addon/

**/DEBUG/

Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ module.exports = {
'scripts/**',
'docs-generator/**',
'tests/performance/fixtures/**/*.js',
'tests/performance/server/**/*.js',
'tests/*/ember-cli-build.js',
'tests/*/index.js',
'tests/*/testem.js',
Expand All @@ -283,6 +282,7 @@ module.exports = {
'tests/*/.template-lintrc.js',
'tests/*/config/**/*.js',
'tests/*/tests/dummy/config/**/*.js',
'tests/*/server/**/*.js',
'packages/-ember-data/lib/*.js',
'packages/private-build-infra/src/**/*.js',
'packages/unpublished-test-infra/src/**/*.js',
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ packages/legacy-compat/addon
packages/request-utils/addon
packages/rest/addon
packages/active-record/addon
packages/data-worker/addon

# dependencies
bower_components
Expand Down
7 changes: 5 additions & 2 deletions .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ hoist-pattern[]=*node-fetch*

# we want true but cannot use true until the below issue is fixed
# https://github.com/pnpm/pnpm/issues/5340
strict-peer-dependencies=false
strict-peer-dependencies=true
auto-install-peers=false # probably apps should set this to true, but we need to test with it false to be sure we aren't the bad citizen
dedupe-peer-dependents=false # this currently introduces more bugs than it fixes
dedupe-peer-dependents=true # this currently introduces more bugs than it fixes
resolve-peers-from-workspace-root=false # if its not declared we don't want it resolved: ensure tests are truly isolated
save-workspace-protocol=rolling
resolution-mode=highest
dedupe-direct-deps=true
child-concurrency=10
ignore-dep-scripts=true
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
"ember-cli-babel": "^8.0.0",
"ember-cli-htmlbars": "^6.3.0",
"ember-cli-typescript": "^5.2.1",
"@ember/string": "3.1.1",
"ember-compatibility-helpers": "^1.2.6"
},
"peerDependencyRules": {
Expand Down
3 changes: 3 additions & 0 deletions packages/-ember-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
},
"@ember-data/private-build-infra": {
"injected": true
},
"@ember/string": {
"injected": true
}
},
"devDependencies": {
Expand Down
11 changes: 11 additions & 0 deletions packages/active-record/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@
"@ember/string": "^3.1.1",
"@ember-data/store": "^4.12.0 || ^5.0.0"
},
"dependenciesMeta": {
"ember-inflector": {
"injected": true
},
"@ember-data/store": {
"injected": true
},
"@ember/string": {
"injected": true
}
},
"files": [
"addon-main.js",
"addon",
Expand Down
3 changes: 3 additions & 0 deletions packages/adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
"dependenciesMeta": {
"@ember-data/private-build-infra": {
"injected": true
},
"@ember/string": {
"injected": true
}
},
"dependencies": {
Expand Down
6 changes: 6 additions & 0 deletions packages/debug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
"dependenciesMeta": {
"@ember-data/private-build-infra": {
"injected": true
},
"@ember/string": {
"injected": true
},
"@ember-data/store": {
"injected": true
}
},
"dependencies": {
Expand Down
3 changes: 3 additions & 0 deletions packages/graph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
"dependenciesMeta": {
"@ember-data/private-build-infra": {
"injected": true
},
"@ember-data/store": {
"injected": true
}
},
"dependencies": {
Expand Down
3 changes: 3 additions & 0 deletions packages/json-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"@ember-data/graph": {
"injected": true
},
"@ember-data/store": {
"injected": true
},
"@ember-data/request-utils": {
"injected": true,
"optional": true
Expand Down
6 changes: 6 additions & 0 deletions packages/model/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
"dependenciesMeta": {
"@ember-data/private-build-infra": {
"injected": true
},
"@ember-data/store": {
"injected": true
},
"@ember/string": {
"injected": true
}
},
"dependencies": {
Expand Down
10 changes: 8 additions & 2 deletions packages/model/src/-private/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ import Model from './model';
import { getModelFactory } from './schema-provider';
import { normalizeModelName } from './util';

function recast(context: Store): asserts context is ModelStore {}

export function instantiateRecord(
this: ModelStore,
this: Store,
identifier: StableRecordIdentifier,
createRecordArgs: { [key: string]: unknown }
): Model {
const type = identifier.type;

recast(this);

const cache = this.cache;
// TODO deprecate allowing unknown args setting
const createOptions = {
Expand Down Expand Up @@ -52,8 +56,10 @@ export function modelFor(this: Store, modelName: string): typeof Model | void {
`Please pass a proper model name to the store's modelFor method`,
typeof modelName === 'string' && modelName.length
);
recast(this);

const type = normalizeModelName(modelName);
const maybeFactory = getModelFactory(this as ModelStore, type);
const maybeFactory = getModelFactory(this, type);
const klass = maybeFactory && maybeFactory.class ? maybeFactory.class : null;

const ignoreType = !klass || !klass.isModel || this._forceShim;
Expand Down
8 changes: 8 additions & 0 deletions packages/rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
"@ember/string": "^3.1.1",
"@ember-data/store": "^4.12.0 || ^5.0.0"
},
"dependenciesMeta": {
"@ember/string": {
"injected": true
},
"@ember-data/store": {
"injected": true
}
},
"files": [
"addon-main.js",
"addon",
Expand Down
3 changes: 3 additions & 0 deletions packages/serializer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
"dependenciesMeta": {
"@ember-data/private-build-infra": {
"injected": true
},
"@ember/string": {
"injected": true
}
},
"dependencies": {
Expand Down
3 changes: 3 additions & 0 deletions packages/store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
"dependenciesMeta": {
"@ember-data/private-build-infra": {
"injected": true
},
"@ember/string": {
"injected": true
}
},
"dependencies": {
Expand Down
5 changes: 4 additions & 1 deletion packages/store/src/-private/cache-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export interface LifetimesService {
}

export type StoreRequestInfo = ImmutableRequestInfo;
export type LooseStoreRequestInfo = Omit<StoreRequestInfo, 'records'> & { records: ResourceIdentifierObject[] };
export type LooseStoreRequestInfo = Omit<StoreRequestInfo, 'records' | 'headers'> & {
records?: ResourceIdentifierObject[];
headers?: Headers;
};

export type StoreRequestInput = StoreRequestInfo | LooseStoreRequestInfo;

Expand Down
2 changes: 1 addition & 1 deletion packages/store/src/-private/store-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class Store extends EmberObject {
@method init
@private
*/
constructor(createArgs?: Record<string, unknown>) {
constructor(createArgs?: unknown) {
// @ts-expect-error ember-source types improperly expect createArgs to be `Owner`
super(createArgs);
Object.assign(this, createArgs);
Expand Down
Loading