Skip to content

Commit d203ef0

Browse files
authored
feat: @ember-data/json-api/-private/graph => @ember-data/graph (emberjs#8356)
* feat: @ember-data/json-api/-private/graph => @ember-data/graph * adds docs path * inject graph * fix lockfile * fix serializer encapsulation test * fix graph tests * udpate lock * fix adapter encapsulation
1 parent 347c606 commit d203ef0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+580
-237
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
/packages/serializer/addon/
1717
/packages/model/addon/
1818
/packages/json-api/addon/
19+
/packages/graph/addon/
1920

2021
**/DEBUG/
2122

.eslintrc.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -213,21 +213,21 @@ module.exports = {
213213
'tests/graph/tests/integration/graph/edge-removal/helpers.ts',
214214
'tests/graph/tests/integration/graph/edge-removal/abstract-edge-removal-test.ts',
215215
'tests/graph/tests/integration/graph.ts',
216-
'packages/json-api/src/-private/relationships/state/has-many.ts',
217-
'packages/json-api/src/-private/relationships/state/belongs-to.ts',
216+
'packages/graph/src/-private/relationships/state/has-many.ts',
217+
'packages/graph/src/-private/relationships/state/belongs-to.ts',
218+
'packages/graph/src/-private/normalize-link.ts',
219+
'packages/graph/src/-private/graph/operations/update-relationship.ts',
220+
'packages/graph/src/-private/graph/operations/replace-related-records.ts',
221+
'packages/graph/src/-private/graph/operations/replace-related-record.ts',
222+
'packages/graph/src/-private/graph/operations/remove-from-related-records.ts',
223+
'packages/graph/src/-private/graph/operations/add-to-related-records.ts',
224+
'packages/graph/src/-private/graph/index.ts',
225+
'packages/graph/src/-private/graph/-utils.ts',
226+
'packages/graph/src/-private/graph/-state.ts',
227+
'packages/graph/src/-private/graph/-operations.ts',
228+
'packages/graph/src/-private/graph/-edge-definition.ts',
229+
'packages/graph/src/-private/coerce-id.ts',
218230
'packages/json-api/src/-private/record-data.ts',
219-
'packages/json-api/src/-private/normalize-link.ts',
220-
'packages/json-api/src/-private/graph/operations/update-relationship.ts',
221-
'packages/json-api/src/-private/graph/operations/replace-related-records.ts',
222-
'packages/json-api/src/-private/graph/operations/replace-related-record.ts',
223-
'packages/json-api/src/-private/graph/operations/remove-from-related-records.ts',
224-
'packages/json-api/src/-private/graph/operations/add-to-related-records.ts',
225-
'packages/json-api/src/-private/graph/index.ts',
226-
'packages/json-api/src/-private/graph/-utils.ts',
227-
'packages/json-api/src/-private/graph/-state.ts',
228-
'packages/json-api/src/-private/graph/-operations.ts',
229-
'packages/json-api/src/-private/graph/-edge-definition.ts',
230-
'packages/json-api/src/-private/coerce-id.ts',
231231
'packages/private-build-infra/addon/index.ts',
232232
'packages/private-build-infra/addon/deprecations.ts',
233233
'packages/private-build-infra/addon/current-deprecations.ts',

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ packages/adapter/addon
1313
packages/serializer/addon
1414
packages/model/addon
1515
packages/json-api/addon
16+
packages/graph/addon
1617

1718
# dependencies
1819
bower_components

docs-generator/yuidoc.json

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"../packages/serializer/src",
1919
"../packages/store/src",
2020
"../packages/json-api/src",
21+
"../packages/graph/src",
2122
"../packages/debug/addon",
2223
"../packages/private-build-infra/addon",
2324
"../packages/canary-features/addon",

ember-data-types/q/record-data.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LocalRelationshipOperation } from '@ember-data/json-api/-private/graph/-operations';
1+
import { LocalRelationshipOperation } from '@ember-data/graph/-private/graph/-operations';
22

33
import type { CollectionResourceRelationship, SingleResourceRelationship } from './ember-data-json-api';
44
import type { RecordIdentifier, StableRecordIdentifier } from './identifier';

packages/-ember-data/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@ember-data/serializer": "workspace:4.10.0-alpha.4",
2626
"@ember-data/store": "workspace:4.10.0-alpha.4",
2727
"@ember-data/tracking": "workspace:4.10.0-alpha.4",
28+
"@ember-data/graph": "workspace:4.10.0-alpha.4",
2829
"@ember/edition-utils": "^1.2.0",
2930
"@ember/string": "^3.0.0",
3031
"@embroider/macros": "^1.10.0",
@@ -38,6 +39,9 @@
3839
"@ember-data/adapter": {
3940
"injected": true
4041
},
42+
"@ember-data/graph":{
43+
"injected": true
44+
},
4145
"@ember-data/debug": {
4246
"injected": true
4347
},

packages/graph/.npmignore

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# compiled output
2+
/dist/
3+
/dist/**/*
4+
/tmp/
5+
/types/
6+
**/*.d.ts
7+
8+
# dependencies
9+
/bower_components/
10+
11+
# misc
12+
/.bowerrc
13+
/.editorconfig
14+
/.ember-cli
15+
/.env*
16+
/.eslintignore
17+
/.eslintrc.js
18+
/.gitignore
19+
/.template-lintrc.js
20+
/.travis.yml
21+
/.watchmanconfig
22+
/bower.json
23+
/config/ember-try.js
24+
/CONTRIBUTING.md
25+
/ember-cli-build.js
26+
/testem.js
27+
/tests/
28+
/yarn.lock
29+
.gitkeep
30+
31+
# ember-try
32+
/.node_modules.ember-try/
33+
/bower.json.ember-try
34+
/package.json.ember-try
35+
36+
# ember-data
37+
/node-tests
38+
39+
# whitelist yuidoc's data.json for api docs generation
40+
!/dist/docs/data.json

packages/graph/LICENSE.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
The MIT License (MIT)
2+
3+
Copyright (C) 2017-2022 Ember.js contributors
4+
Portions Copyright (C) 2011-2017 Tilde, Inc. and contributors.
5+
Portions Copyright (C) 2011 LivingSocial Inc.
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8+
9+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10+
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

packages/graph/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# @ember-data/json-api
2+
3+
Provides the default JSON:API Cache implementation for EmberData.
4+
5+
## Installation
6+
7+
```
8+
ember install @ember-data/json-api
9+
```
10+
11+
## License
12+
13+
This project is licensed under the [MIT License](LICENSE.md).

packages/graph/addon-main.js

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
const pkg = require('./package.json');
2+
3+
module.exports = {
4+
name: pkg.name,
5+
6+
options: {
7+
'@embroider/macros': {
8+
setOwnConfig: {},
9+
},
10+
},
11+
12+
_emberDataConfig: null,
13+
configureEmberData() {
14+
if (this._emberDataConfig) {
15+
return this._emberDataConfig;
16+
}
17+
const app = this._findHost();
18+
const isProd = /production/.test(process.env.EMBER_ENV);
19+
const hostOptions = app.options?.emberData || {};
20+
const debugOptions = Object.assign(
21+
{
22+
LOG_PAYLOADS: false,
23+
LOG_OPERATIONS: false,
24+
LOG_MUTATIONS: false,
25+
LOG_NOTIFICATIONS: false,
26+
LOG_REQUEST_STATUS: false,
27+
LOG_IDENTIFIERS: false,
28+
LOG_GRAPH: false,
29+
LOG_INSTANCE_CACHE: false,
30+
},
31+
hostOptions.debug || {}
32+
);
33+
let HAS_DEBUG_PACKAGE, HAS_META_PACKAGE;
34+
35+
try {
36+
// eslint-disable-next-line node/no-missing-require
37+
require.resolve('@ember-data/debug', { paths: [process.cwd(), __dirname] });
38+
HAS_DEBUG_PACKAGE = true;
39+
} catch {
40+
HAS_DEBUG_PACKAGE = false;
41+
}
42+
try {
43+
// eslint-disable-next-line node/no-missing-require
44+
require.resolve('ember-data', { paths: [process.cwd(), __dirname] });
45+
HAS_META_PACKAGE = true;
46+
} catch {
47+
HAS_META_PACKAGE = false;
48+
}
49+
const includeDataAdapterInProduction =
50+
typeof hostOptions.includeDataAdapterInProduction === 'boolean'
51+
? hostOptions.includeDataAdapterInProduction
52+
: HAS_META_PACKAGE;
53+
54+
const includeDataAdapter = HAS_DEBUG_PACKAGE ? (isProd ? includeDataAdapterInProduction : true) : false;
55+
const DEPRECATIONS = require('@ember-data/private-build-infra/src/deprecations')(hostOptions.compatWith || null);
56+
const FEATURES = require('@ember-data/private-build-infra/src/features')(isProd);
57+
58+
// copy configs forward
59+
const ownConfig = this.options['@embroider/macros'].setOwnConfig;
60+
ownConfig.compatWith = hostOptions.compatWith || null;
61+
ownConfig.debug = debugOptions;
62+
ownConfig.deprecations = Object.assign(DEPRECATIONS, ownConfig.deprecations || {});
63+
ownConfig.features = Object.assign({}, FEATURES);
64+
ownConfig.includeDataAdapter = includeDataAdapter;
65+
66+
this._emberDataConfig = ownConfig;
67+
return ownConfig;
68+
},
69+
70+
included() {
71+
this.configureEmberData();
72+
return this._super.included.call(this, ...arguments);
73+
},
74+
75+
treeForVendor() {
76+
return;
77+
},
78+
treeForPublic() {
79+
return;
80+
},
81+
treeForStyles() {
82+
return;
83+
},
84+
treeForAddonStyles() {
85+
return;
86+
},
87+
treeForApp() {
88+
return;
89+
},
90+
};

packages/graph/babel.config.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const macros = require('@ember-data/private-build-infra/src/v2-babel-build-pack');
2+
3+
module.exports = {
4+
plugins: [
5+
...macros,
6+
// '@embroider/macros/src/babel/macros-babel-plugin.js',
7+
['@babel/plugin-transform-runtime', { loose: true }],
8+
['@babel/plugin-transform-typescript', { allowDeclareFields: true }],
9+
['@babel/plugin-proposal-decorators', { legacy: true, loose: true }],
10+
['@babel/plugin-proposal-private-methods', { loose: true }],
11+
['@babel/plugin-proposal-class-properties', { loose: true }],
12+
],
13+
};

packages/graph/index.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
3+
const addonBuildConfigForDataPackage = require('@ember-data/private-build-infra/src/addon-build-config-for-data-package');
4+
5+
const name = require('./package').name;
6+
7+
const addonBaseConfig = addonBuildConfigForDataPackage(name);
8+
9+
module.exports = Object.assign({}, addonBaseConfig, {
10+
shouldRollupPrivate: true,
11+
externalDependenciesForPrivateModule() {
12+
return [
13+
'@ember/debug',
14+
'@ember/runloop',
15+
'@ember/polyfills',
16+
'@ember/object',
17+
'@ember/object/internals',
18+
'@ember/utils',
19+
'ember',
20+
'@ember-data/store/-private',
21+
'@ember-data/store',
22+
'@ember-data/canary-features',
23+
'@ember-data/private-build-infra/debugging',
24+
];
25+
},
26+
});

packages/graph/package.json

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
"name": "@ember-data/graph",
3+
"version": "4.10.0-alpha.4",
4+
"description": "Provides the default resource cache (RecordData) implementation for ember-data",
5+
"keywords": [
6+
"ember-addon"
7+
],
8+
"repository": {
9+
"type": "git",
10+
"url": "git+ssh://[email protected]:emberjs/data.git",
11+
"directory": "packages/record-data"
12+
},
13+
"license": "MIT",
14+
"author": "",
15+
"scripts": {
16+
"build": "rollup --config && babel ./addon --out-dir addon --plugins=../private-build-infra/src/transforms/babel-plugin-transform-ext.js",
17+
"start": "rollup --config --watch",
18+
"prepack": "pnpm build",
19+
"prepare": "pnpm build"
20+
},
21+
"ember-addon": {
22+
"main": "addon-main.js",
23+
"type": "addon",
24+
"version": 1
25+
},
26+
"files": [
27+
"addon-main.js",
28+
"addon"
29+
],
30+
"peerDependencies": {
31+
"@ember-data/store": "workspace:4.10.0-alpha.4"
32+
},
33+
"dependenciesMeta": {
34+
"@ember-data/canary-features": {
35+
"injected": true
36+
},
37+
"@ember-data/private-build-infra": {
38+
"injected": true
39+
}
40+
},
41+
"dependencies": {
42+
"@ember-data/private-build-infra": "workspace:4.10.0-alpha.4",
43+
"@ember/edition-utils": "^1.2.0",
44+
"@embroider/macros": "^1.10.0",
45+
"ember-cli-babel": "^7.26.11"
46+
},
47+
"devDependencies": {
48+
"@ember-data/canary-features": "workspace:4.10.0-alpha.4",
49+
"@babel/core": "^7.20.2",
50+
"@babel/cli": "^7.19.3",
51+
"@glimmer/component": "^1.1.2",
52+
"ember-source": "~4.8.2",
53+
"@embroider/addon-dev": "^2.0.0",
54+
"rollup": "^3.2.3",
55+
"@babel/plugin-proposal-class-properties": "^7.18.6",
56+
"@babel/plugin-proposal-private-methods": "^7.18.6",
57+
"@babel/plugin-proposal-decorators": "^7.20.0",
58+
"@babel/plugin-transform-typescript": "^7.20.0",
59+
"@babel/plugin-transform-runtime": "^7.19.6",
60+
"@babel/preset-typescript": "^7.18.6",
61+
"@babel/preset-env": "^7.19.4",
62+
"@babel/runtime": "^7.20.0",
63+
"@rollup/plugin-babel":"^6.0.2",
64+
"@rollup/plugin-node-resolve": "^15.0.1",
65+
"tslib": "^2.4.0",
66+
"walk-sync": "^3.0.0",
67+
"typescript": "^4.8.4"
68+
},
69+
"ember": {
70+
"edition": "octane"
71+
},
72+
"engines": {
73+
"node": "^14.8.0 || 16.* || >= 18.*"
74+
},
75+
"volta": {
76+
"extends": "../../package.json"
77+
},
78+
"packageManager": "[email protected]"
79+
}

0 commit comments

Comments
 (0)