@warp-drive/legacy 5.7.0-alpha.0 → 5.7.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/model/-private/model-methods.d.ts +3 -0
- package/declarations/model/-private/model.d.ts +3 -0
- package/declarations/model/migration-support.d.ts +1 -19
- package/declarations/model.d.ts +1 -1
- package/declarations/store/-private.d.ts +235 -0
- package/declarations/store.d.ts +3 -0
- package/dist/compat/builders.js +1 -21
- package/dist/model/migration-support.js +83 -6
- package/dist/model.js +3 -2
- package/dist/{schema-provider-BdQhkT-Q.js → schema-provider-Cbnf6sKm.js} +104 -35
- package/dist/store.js +631 -0
- package/dist/util-Dul6TZts.js +35 -0
- package/dist/utils-Cqw9eRj5.js +23 -0
- package/package.json +6 -6
|
@@ -2,45 +2,14 @@ import { getOwner } from '@ember/application';
|
|
|
2
2
|
import { deprecate } from '@ember/debug';
|
|
3
3
|
import EmberObject from '@ember/object';
|
|
4
4
|
import { recordIdentifierFor, storeFor } from '@warp-drive/core';
|
|
5
|
-
import { peekCache, notifyInternalSignal, peekInternalSignal, withSignalStore, ARRAY_SIGNAL, recordIdentifierFor as recordIdentifierFor$1, gate, memoized, defineSignal, coerceId, entangleSignal } from '@warp-drive/core/store/-private';
|
|
5
|
+
import { peekCache, notifyInternalSignal, peekInternalSignal, withSignalStore, ARRAY_SIGNAL, recordIdentifierFor as recordIdentifierFor$1, gate, memoized, defineSignal, coerceId, entangleSignal, defineGate } from '@warp-drive/core/store/-private';
|
|
6
6
|
import { RecordStore } from '@warp-drive/core/types/symbols';
|
|
7
7
|
import { l as lookupLegacySupport, L as LEGACY_SUPPORT, E as Errors } from "./errors-BX5wowuz.js";
|
|
8
8
|
import { u as upgradeStore, F as FetchManager } from "./-private-CKrP0ogQ.js";
|
|
9
9
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
10
10
|
import { cacheFor } from '@ember/object/internals';
|
|
11
11
|
import { d as decorateMethodV2 } from "./runtime-BPCpkOf1-BKOwiRJp.js";
|
|
12
|
-
import {
|
|
13
|
-
function isElementDescriptor(args) {
|
|
14
|
-
const [maybeTarget, maybeKey, maybeDesc] = args;
|
|
15
|
-
return (
|
|
16
|
-
// Ensure we have the right number of args
|
|
17
|
-
args.length === 3 && (
|
|
18
|
-
// Make sure the target is a class or object (prototype)
|
|
19
|
-
typeof maybeTarget === 'function' || typeof maybeTarget === 'object' && maybeTarget !== null) &&
|
|
20
|
-
// Make sure the key is a string
|
|
21
|
-
typeof maybeKey === 'string' && (
|
|
22
|
-
// Make sure the descriptor is the right shape
|
|
23
|
-
typeof maybeDesc === 'object' && maybeDesc !== null && 'enumerable' in maybeDesc && 'configurable' in maybeDesc ||
|
|
24
|
-
// TS compatibility
|
|
25
|
-
maybeDesc === undefined)
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
function normalizeModelName(type) {
|
|
29
|
-
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_NON_STRICT_TYPES)) {
|
|
30
|
-
const result = dasherize(type);
|
|
31
|
-
deprecate(`The resource type '${type}' is not normalized. Update your application code to use '${result}' instead of '${type}'.`, result === type, {
|
|
32
|
-
id: 'ember-data:deprecate-non-strict-types',
|
|
33
|
-
until: '6.0',
|
|
34
|
-
for: 'ember-data',
|
|
35
|
-
since: {
|
|
36
|
-
available: '4.13',
|
|
37
|
-
enabled: '5.3'
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
return type;
|
|
43
|
-
}
|
|
12
|
+
import { n as normalizeModelName } from "./util-Dul6TZts.js";
|
|
44
13
|
function rollbackAttributes() {
|
|
45
14
|
const {
|
|
46
15
|
currentState
|
|
@@ -70,6 +39,27 @@ function hasMany(prop) {
|
|
|
70
39
|
return lookupLegacySupport(this).referenceFor('hasMany', prop);
|
|
71
40
|
}
|
|
72
41
|
function reload(options = {}) {
|
|
42
|
+
if (macroCondition(!getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_REQUEST_METHODS)) {
|
|
43
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
44
|
+
{
|
|
45
|
+
throw new Error(`You cannot use reload() on a record when ENABLE_LEGACY_REQUEST_METHODS is false.`);
|
|
46
|
+
}
|
|
47
|
+
})() : {};
|
|
48
|
+
} else {
|
|
49
|
+
deprecate(`record.reload is deprecated, please use store.request to initiate a request instead.`, false, {
|
|
50
|
+
id: 'warp-drive:deprecate-legacy-request-methods',
|
|
51
|
+
until: '6.0',
|
|
52
|
+
for: '@warp-drive/core',
|
|
53
|
+
url: 'https://docs.warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS',
|
|
54
|
+
since: {
|
|
55
|
+
enabled: '5.7',
|
|
56
|
+
available: '5.7'
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return _reload.call(this, options);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function _reload(options = {}) {
|
|
73
63
|
options.isReloading = true;
|
|
74
64
|
options.reload = true;
|
|
75
65
|
const identifier = recordIdentifierFor(this);
|
|
@@ -107,6 +97,27 @@ function deleteRecord() {
|
|
|
107
97
|
}
|
|
108
98
|
}
|
|
109
99
|
function save(options) {
|
|
100
|
+
if (macroCondition(!getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_REQUEST_METHODS)) {
|
|
101
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
102
|
+
{
|
|
103
|
+
throw new Error(`You cannot use save() on a record when ENABLE_LEGACY_REQUEST_METHODS is false.`);
|
|
104
|
+
}
|
|
105
|
+
})() : {};
|
|
106
|
+
} else {
|
|
107
|
+
deprecate(`record.save is deprecated, please use store.request to initiate a request instead.`, false, {
|
|
108
|
+
id: 'warp-drive:deprecate-legacy-request-methods',
|
|
109
|
+
until: '6.0',
|
|
110
|
+
for: '@warp-drive/core',
|
|
111
|
+
url: 'https://docs.warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS',
|
|
112
|
+
since: {
|
|
113
|
+
enabled: '5.7',
|
|
114
|
+
available: '5.7'
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
return _save.call(this, options);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function _save(options) {
|
|
110
121
|
let promise;
|
|
111
122
|
if (this.currentState.isNew && this.currentState.isDeleted) {
|
|
112
123
|
promise = Promise.resolve(this);
|
|
@@ -117,6 +128,27 @@ function save(options) {
|
|
|
117
128
|
return promise;
|
|
118
129
|
}
|
|
119
130
|
function destroyRecord(options) {
|
|
131
|
+
if (macroCondition(!getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_REQUEST_METHODS)) {
|
|
132
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
133
|
+
{
|
|
134
|
+
throw new Error(`You cannot use destroyRecord() on a record when ENABLE_LEGACY_REQUEST_METHODS is false.`);
|
|
135
|
+
}
|
|
136
|
+
})() : {};
|
|
137
|
+
} else {
|
|
138
|
+
deprecate(`record.destroyRecord is deprecated, please use store.request to initiate a request instead.`, false, {
|
|
139
|
+
id: 'warp-drive:deprecate-legacy-request-methods',
|
|
140
|
+
until: '6.0',
|
|
141
|
+
for: '@warp-drive/core',
|
|
142
|
+
url: 'https://docs.warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS',
|
|
143
|
+
since: {
|
|
144
|
+
enabled: '5.7',
|
|
145
|
+
available: '5.7'
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
return _destroyRecord.call(this, options);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function _destroyRecord(options) {
|
|
120
152
|
const {
|
|
121
153
|
isNew
|
|
122
154
|
} = this.currentState;
|
|
@@ -1917,7 +1949,44 @@ Model.prototype.deleteRecord = deleteRecord;
|
|
|
1917
1949
|
Model.prototype.changedAttributes = changedAttributes;
|
|
1918
1950
|
Model.prototype.rollbackAttributes = rollbackAttributes;
|
|
1919
1951
|
Model.prototype.reload = reload;
|
|
1920
|
-
|
|
1952
|
+
defineGate(Model.prototype, 'isReloading', {
|
|
1953
|
+
get() {
|
|
1954
|
+
deprecate(`record.isReloading is deprecated, please use store.request and either <Request> or getRequuestState to keep track of the request state instead.`, false, {
|
|
1955
|
+
id: 'warp-drive:deprecate-legacy-request-methods',
|
|
1956
|
+
until: '6.0',
|
|
1957
|
+
for: '@warp-drive/core',
|
|
1958
|
+
url: 'https://docs.warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS',
|
|
1959
|
+
since: {
|
|
1960
|
+
enabled: '5.7',
|
|
1961
|
+
available: '5.7'
|
|
1962
|
+
}
|
|
1963
|
+
});
|
|
1964
|
+
return this._isReloading ?? false;
|
|
1965
|
+
},
|
|
1966
|
+
set(v) {
|
|
1967
|
+
this._isReloading = v;
|
|
1968
|
+
},
|
|
1969
|
+
configurable: true,
|
|
1970
|
+
// @ts-expect-error specially handled prop
|
|
1971
|
+
isLocal: true
|
|
1972
|
+
});
|
|
1973
|
+
function restoreDeprecatedModelRequestBehaviors(ModelKlass) {
|
|
1974
|
+
// @ts-expect-error TS doesn't know how to do `this` function overloads
|
|
1975
|
+
ModelKlass.prototype.save = _save;
|
|
1976
|
+
// @ts-expect-error TS doesn't know how to do `this` function overloads
|
|
1977
|
+
ModelKlass.prototype.destroyRecord = _destroyRecord;
|
|
1978
|
+
ModelKlass.prototype.reload = _reload;
|
|
1979
|
+
defineGate(Model.prototype, 'isReloading', {
|
|
1980
|
+
get() {
|
|
1981
|
+
return this._isReloading ?? false;
|
|
1982
|
+
},
|
|
1983
|
+
set(v) {
|
|
1984
|
+
this._isReloading = v;
|
|
1985
|
+
},
|
|
1986
|
+
// @ts-expect-error specially handled prop
|
|
1987
|
+
isLocal: true
|
|
1988
|
+
});
|
|
1989
|
+
}
|
|
1921
1990
|
|
|
1922
1991
|
// this is required to prevent `init` from passing
|
|
1923
1992
|
// the values initialized during create to `setUnknownProperty`
|
|
@@ -2232,4 +2301,4 @@ function getModelFactory(store, type) {
|
|
|
2232
2301
|
}
|
|
2233
2302
|
return factory;
|
|
2234
2303
|
}
|
|
2235
|
-
export { Model as M, RecordState as R, save as a, buildSchema as b,
|
|
2304
|
+
export { Model as M, RecordState as R, _save as _, save as a, buildSchema as b, _reload as c, reload as d, _destroyRecord as e, destroyRecord as f, deleteRecord as g, hasMany as h, changedAttributes as i, belongsTo as j, createSnapshot as k, getModelFactory as l, restoreDeprecatedModelRequestBehaviors as m, rollbackAttributes as r, serialize as s, unloadRecord as u };
|