@ember-data/request-utils 4.12.8 → 4.13.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/addon-main.cjs ADDED
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ const { addonShim } = require('@warp-drive/build-config/addon-shim.cjs');
4
+
5
+ module.exports = addonShim(__dirname);
@@ -0,0 +1,187 @@
1
+ import { deprecate } from '@ember/debug';
2
+ import { macroCondition, getGlobalConfig, dependencySatisfies, importSync } from '@embroider/macros';
3
+ import { m as defaultRules, b as plural, a as singular, i as irregular, u as uncountable } from "./inflect-8aYUyMN7.js";
4
+ if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_EMBER_INFLECTOR)) {
5
+ if (macroCondition(dependencySatisfies('ember-inflector', '*'))) {
6
+ const Inflector = importSync('ember-inflector').default;
7
+ const {
8
+ inflector
9
+ } = Inflector;
10
+
11
+ // eslint-disable-next-line @typescript-eslint/unbound-method
12
+ const originalPlural = inflector.plural;
13
+ // eslint-disable-next-line @typescript-eslint/unbound-method
14
+ const originalSingular = inflector.singular;
15
+ // eslint-disable-next-line @typescript-eslint/unbound-method
16
+ const originalIrregular = inflector.irregular;
17
+ // eslint-disable-next-line @typescript-eslint/unbound-method
18
+ const originalUncountable = inflector.uncountable;
19
+
20
+ // copy over any already registered rules
21
+
22
+ // ember-inflector mutates the default rules arrays
23
+ // with user supplied rules, so we keep track of what
24
+ // is default via our own list.
25
+ const defaultPluralKeys = new Set();
26
+ const defaultSingularKeys = new Set();
27
+ defaultRules.plurals.forEach(([regex]) => {
28
+ defaultPluralKeys.add(regex.toString());
29
+ });
30
+ defaultRules.singular.forEach(([regex]) => {
31
+ defaultSingularKeys.add(regex.toString());
32
+ });
33
+ const {
34
+ defaultRules: defaultRules$1
35
+ } = Inflector;
36
+ const {
37
+ rules
38
+ } = inflector;
39
+ const irregularMap = new Map();
40
+ const toIgnore = new Set();
41
+ const uncountableSet = new Set(defaultRules$1.uncountable);
42
+ defaultRules$1.irregularPairs.forEach(([single, plur]) => {
43
+ irregularMap.set(single.toLowerCase(), plur);
44
+ toIgnore.add(plur.toLowerCase());
45
+ });
46
+ const irregularLookups = new Map();
47
+ Object.keys(rules.irregular).forEach(single => {
48
+ const plur = rules.irregular[single];
49
+ irregularLookups.set(single, plur);
50
+ });
51
+
52
+ // load plurals
53
+ rules.plurals.forEach(([regex, replacement]) => {
54
+ if (defaultPluralKeys.has(regex.toString())) {
55
+ return;
56
+ }
57
+ plural(regex, replacement);
58
+ deprecate(`WarpDrive/EmberData no longer uses ember-inflector for pluralization.\nPlease \`import { plural } from '@ember-data/request-utils/string';\` instead to register a custom pluralization rule for use with EmberData.`, /* inline-macro-config */getGlobalConfig().WarpDrive.deprecations.DISABLE_6X_DEPRECATIONS, {
59
+ id: 'warp-drive.ember-inflector',
60
+ until: '6.0.0',
61
+ for: 'warp-drive',
62
+ since: {
63
+ enabled: '5.3.4',
64
+ available: '4.13'
65
+ },
66
+ url: 'https://deprecations.emberjs.com/id/warp-drive.ember-inflector'
67
+ });
68
+ });
69
+
70
+ // load singulars
71
+ rules.singular.forEach(([regex, replacement]) => {
72
+ if (defaultSingularKeys.has(regex.toString())) {
73
+ return;
74
+ }
75
+ singular(regex, replacement);
76
+ deprecate(`WarpDrive/EmberData no longer uses ember-inflector for singularization.\nPlease \`import { singular } from '@ember-data/request-utils/string';\` instead to register a custom singularization rule for use with EmberData.`, /* inline-macro-config */getGlobalConfig().WarpDrive.deprecations.DISABLE_6X_DEPRECATIONS, {
77
+ id: 'warp-drive.ember-inflector',
78
+ until: '6.0.0',
79
+ for: 'warp-drive',
80
+ since: {
81
+ enabled: '5.3.4',
82
+ available: '4.13'
83
+ },
84
+ url: 'https://deprecations.emberjs.com/id/warp-drive.ember-inflector'
85
+ });
86
+ });
87
+
88
+ // load irregulars
89
+ Object.keys(rules.irregular).forEach(single => {
90
+ const plur = rules.irregular[single];
91
+ const defaultPlur = irregularMap.get(single);
92
+ if (defaultPlur && defaultPlur === plur) {
93
+ return;
94
+ }
95
+ if (toIgnore.has(single)) {
96
+ return;
97
+ }
98
+ const actualSingle = irregularLookups.get(plur.toLowerCase()) || single;
99
+ toIgnore.add(plur.toLowerCase());
100
+ irregular(actualSingle, plur);
101
+ deprecate(`WarpDrive/EmberData no longer uses ember-inflector for irregular rules.\nPlease \`import { irregular } from '@ember-data/request-utils/string';\` instead to register a custom irregular rule for use with EmberData for '${actualSingle}' <=> '${plur}'.`, /* inline-macro-config */getGlobalConfig().WarpDrive.deprecations.DISABLE_6X_DEPRECATIONS, {
102
+ id: 'warp-drive.ember-inflector',
103
+ until: '6.0.0',
104
+ for: 'warp-drive',
105
+ since: {
106
+ enabled: '5.3.4',
107
+ available: '4.13'
108
+ },
109
+ url: 'https://deprecations.emberjs.com/id/warp-drive.ember-inflector'
110
+ });
111
+ });
112
+
113
+ // load uncountables
114
+ Object.keys(rules.uncountable).forEach(word => {
115
+ if (uncountableSet.has(word) || rules.uncountable[word] !== true) {
116
+ return;
117
+ }
118
+ uncountable(word);
119
+ deprecate(`WarpDrive/EmberData no longer uses ember-inflector for uncountable rules.\nPlease \`import { uncountable } from '@ember-data/request-utils/string';\` instead to register a custom uncountable rule for '${word}' for use with EmberData.`, /* inline-macro-config */getGlobalConfig().WarpDrive.deprecations.DISABLE_6X_DEPRECATIONS, {
120
+ id: 'warp-drive.ember-inflector',
121
+ until: '6.0.0',
122
+ for: 'warp-drive',
123
+ since: {
124
+ enabled: '5.3.4',
125
+ available: '4.13'
126
+ },
127
+ url: 'https://deprecations.emberjs.com/id/warp-drive.ember-inflector'
128
+ });
129
+ });
130
+ inflector.plural = function (...args) {
131
+ plural(...args);
132
+ deprecate(`WarpDrive/EmberData no longer uses ember-inflector for pluralization.\nPlease \`import { plural } from '@ember-data/request-utils/string';\` instead to register a custom pluralization rule for use with EmberData.`, /* inline-macro-config */getGlobalConfig().WarpDrive.deprecations.DISABLE_6X_DEPRECATIONS, {
133
+ id: 'warp-drive.ember-inflector',
134
+ until: '6.0.0',
135
+ for: 'warp-drive',
136
+ since: {
137
+ enabled: '5.3.4',
138
+ available: '4.13'
139
+ },
140
+ url: 'https://deprecations.emberjs.com/id/warp-drive.ember-inflector'
141
+ });
142
+ return originalPlural.apply(inflector, args);
143
+ };
144
+ inflector.singular = function (...args) {
145
+ singular(...args);
146
+ deprecate(`WarpDrive/EmberData no longer uses ember-inflector for singularization.\nPlease \`import { singular } from '@ember-data/request-utils/string';\` instead to register a custom singularization rule for use with EmberData.`, /* inline-macro-config */getGlobalConfig().WarpDrive.deprecations.DISABLE_6X_DEPRECATIONS, {
147
+ id: 'warp-drive.ember-inflector',
148
+ until: '6.0.0',
149
+ for: 'warp-drive',
150
+ since: {
151
+ enabled: '5.3.4',
152
+ available: '4.13'
153
+ },
154
+ url: 'https://deprecations.emberjs.com/id/warp-drive.ember-inflector'
155
+ });
156
+ return originalSingular.apply(inflector, args);
157
+ };
158
+ inflector.irregular = function (...args) {
159
+ irregular(...args);
160
+ deprecate(`WarpDrive/EmberData no longer uses ember-inflector for irregular rules.\nPlease \`import { irregular } from '@ember-data/request-utils/string';\` instead to register a custom irregular rule for use with EmberData.`, /* inline-macro-config */getGlobalConfig().WarpDrive.deprecations.DISABLE_6X_DEPRECATIONS, {
161
+ id: 'warp-drive.ember-inflector',
162
+ until: '6.0.0',
163
+ for: 'warp-drive',
164
+ since: {
165
+ enabled: '5.3.4',
166
+ available: '4.13'
167
+ },
168
+ url: 'https://deprecations.emberjs.com/id/warp-drive.ember-inflector'
169
+ });
170
+ return originalIrregular.apply(inflector, args);
171
+ };
172
+ inflector.uncountable = function (...args) {
173
+ uncountable(...args);
174
+ deprecate(`WarpDrive/EmberData no longer uses ember-inflector for uncountable rules.\nPlease \`import { uncountable } from '@ember-data/request-utils/string';\` instead to register a custom uncountable rule for use with EmberData.`, /* inline-macro-config */getGlobalConfig().WarpDrive.deprecations.DISABLE_6X_DEPRECATIONS, {
175
+ id: 'warp-drive.ember-inflector',
176
+ until: '6.0.0',
177
+ for: 'warp-drive',
178
+ since: {
179
+ enabled: '5.3.4',
180
+ available: '4.13'
181
+ },
182
+ url: 'https://deprecations.emberjs.com/id/warp-drive.ember-inflector'
183
+ });
184
+ return originalUncountable.apply(inflector, args);
185
+ };
186
+ }
187
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deprecation-support.js","sources":["../src/deprecation-support.ts"],"sourcesContent":["import { deprecate } from '@ember/debug';\n\nimport { dependencySatisfies, importSync, macroCondition } from '@embroider/macros';\n\nimport { DEPRECATE_EMBER_INFLECTOR, DISABLE_6X_DEPRECATIONS } from '@warp-drive/build-config/deprecations';\n\nimport { defaultRules as WarpDriveDefaults } from './-private/string/inflections';\nimport { irregular, plural, singular, uncountable } from './string';\n\nif (DEPRECATE_EMBER_INFLECTOR) {\n if (macroCondition(dependencySatisfies('ember-inflector', '*'))) {\n const Inflector = (importSync('ember-inflector') as { default: typeof import('ember-inflector').default }).default;\n const { inflector } = Inflector;\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalPlural = inflector.plural;\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalSingular = inflector.singular;\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalIrregular = inflector.irregular;\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalUncountable = inflector.uncountable;\n\n // copy over any already registered rules\n type DefaultRules = {\n plurals: [RegExp, string][];\n singular: [RegExp, string][];\n irregularPairs: [string, string][];\n uncountable: string[];\n };\n type InternalRules = {\n plurals: [RegExp, string][];\n singular: [RegExp, string][];\n\n // [str1, str2] =>\n // { [str1.lower]: str2 }\n // { [str2.lower]: str2 }\n irregular: Record<string, string>;\n\n // [str1, str2] =>\n // { [str2.lower]: str1 }\n // { [str1.lower]: str1 }\n irregularInverse: Record<string, string>;\n\n // lower cased string\n uncountable: Record<string, boolean>;\n };\n\n // ember-inflector mutates the default rules arrays\n // with user supplied rules, so we keep track of what\n // is default via our own list.\n const defaultPluralKeys = new Set<string>();\n const defaultSingularKeys = new Set<string>();\n WarpDriveDefaults.plurals.forEach(([regex]) => {\n defaultPluralKeys.add(regex.toString());\n });\n WarpDriveDefaults.singular.forEach(([regex]) => {\n defaultSingularKeys.add(regex.toString());\n });\n\n const { defaultRules } = Inflector as unknown as { defaultRules: DefaultRules };\n const { rules } = inflector as unknown as { rules: InternalRules };\n\n const irregularMap = new Map<string, string>();\n const toIgnore = new Set<string>();\n const uncountableSet = new Set(defaultRules.uncountable);\n\n defaultRules.irregularPairs.forEach(([single, plur]) => {\n irregularMap.set(single.toLowerCase(), plur);\n toIgnore.add(plur.toLowerCase());\n });\n const irregularLookups = new Map<string, string>();\n Object.keys(rules.irregular).forEach((single) => {\n const plur = rules.irregular[single];\n irregularLookups.set(single, plur);\n });\n\n // load plurals\n rules.plurals.forEach(([regex, replacement]) => {\n if (defaultPluralKeys.has(regex.toString())) {\n return;\n }\n\n plural(regex, replacement);\n\n deprecate(\n `WarpDrive/EmberData no longer uses ember-inflector for pluralization.\\nPlease \\`import { plural } from '@ember-data/request-utils/string';\\` instead to register a custom pluralization rule for use with EmberData.`,\n /* inline-macro-config */ DISABLE_6X_DEPRECATIONS,\n {\n id: 'warp-drive.ember-inflector',\n until: '6.0.0',\n for: 'warp-drive',\n since: {\n enabled: '5.3.4',\n available: '4.13',\n },\n url: 'https://deprecations.emberjs.com/id/warp-drive.ember-inflector',\n }\n );\n });\n\n // load singulars\n rules.singular.forEach(([regex, replacement]) => {\n if (defaultSingularKeys.has(regex.toString())) {\n return;\n }\n\n singular(regex, replacement);\n\n deprecate(\n `WarpDrive/EmberData no longer uses ember-inflector for singularization.\\nPlease \\`import { singular } from '@ember-data/request-utils/string';\\` instead to register a custom singularization rule for use with EmberData.`,\n /* inline-macro-config */ DISABLE_6X_DEPRECATIONS,\n {\n id: 'warp-drive.ember-inflector',\n until: '6.0.0',\n for: 'warp-drive',\n since: {\n enabled: '5.3.4',\n available: '4.13',\n },\n url: 'https://deprecations.emberjs.com/id/warp-drive.ember-inflector',\n }\n );\n });\n\n // load irregulars\n Object.keys(rules.irregular).forEach((single) => {\n const plur = rules.irregular[single];\n const defaultPlur = irregularMap.get(single);\n if (defaultPlur && defaultPlur === plur) {\n return;\n }\n\n if (toIgnore.has(single)) {\n return;\n }\n\n const actualSingle = irregularLookups.get(plur.toLowerCase()) || single;\n toIgnore.add(plur.toLowerCase());\n irregular(actualSingle, plur);\n\n deprecate(\n `WarpDrive/EmberData no longer uses ember-inflector for irregular rules.\\nPlease \\`import { irregular } from '@ember-data/request-utils/string';\\` instead to register a custom irregular rule for use with EmberData for '${actualSingle}' <=> '${plur}'.`,\n /* inline-macro-config */ DISABLE_6X_DEPRECATIONS,\n {\n id: 'warp-drive.ember-inflector',\n until: '6.0.0',\n for: 'warp-drive',\n since: {\n enabled: '5.3.4',\n available: '4.13',\n },\n url: 'https://deprecations.emberjs.com/id/warp-drive.ember-inflector',\n }\n );\n });\n\n // load uncountables\n Object.keys(rules.uncountable).forEach((word) => {\n if (uncountableSet.has(word) || rules.uncountable[word] !== true) {\n return;\n }\n\n uncountable(word);\n\n deprecate(\n `WarpDrive/EmberData no longer uses ember-inflector for uncountable rules.\\nPlease \\`import { uncountable } from '@ember-data/request-utils/string';\\` instead to register a custom uncountable rule for '${word}' for use with EmberData.`,\n /* inline-macro-config */ DISABLE_6X_DEPRECATIONS,\n {\n id: 'warp-drive.ember-inflector',\n until: '6.0.0',\n for: 'warp-drive',\n since: {\n enabled: '5.3.4',\n available: '4.13',\n },\n url: 'https://deprecations.emberjs.com/id/warp-drive.ember-inflector',\n }\n );\n });\n\n inflector.plural = function (...args: Parameters<typeof originalPlural>) {\n plural(...args);\n\n deprecate(\n `WarpDrive/EmberData no longer uses ember-inflector for pluralization.\\nPlease \\`import { plural } from '@ember-data/request-utils/string';\\` instead to register a custom pluralization rule for use with EmberData.`,\n /* inline-macro-config */ DISABLE_6X_DEPRECATIONS,\n {\n id: 'warp-drive.ember-inflector',\n until: '6.0.0',\n for: 'warp-drive',\n since: {\n enabled: '5.3.4',\n available: '4.13',\n },\n url: 'https://deprecations.emberjs.com/id/warp-drive.ember-inflector',\n }\n );\n\n return originalPlural.apply(inflector, args);\n };\n\n inflector.singular = function (...args: Parameters<typeof originalSingular>) {\n singular(...args);\n\n deprecate(\n `WarpDrive/EmberData no longer uses ember-inflector for singularization.\\nPlease \\`import { singular } from '@ember-data/request-utils/string';\\` instead to register a custom singularization rule for use with EmberData.`,\n /* inline-macro-config */ DISABLE_6X_DEPRECATIONS,\n {\n id: 'warp-drive.ember-inflector',\n until: '6.0.0',\n for: 'warp-drive',\n since: {\n enabled: '5.3.4',\n available: '4.13',\n },\n url: 'https://deprecations.emberjs.com/id/warp-drive.ember-inflector',\n }\n );\n\n return originalSingular.apply(inflector, args);\n };\n\n inflector.irregular = function (...args: Parameters<typeof originalIrregular>) {\n irregular(...args);\n\n deprecate(\n `WarpDrive/EmberData no longer uses ember-inflector for irregular rules.\\nPlease \\`import { irregular } from '@ember-data/request-utils/string';\\` instead to register a custom irregular rule for use with EmberData.`,\n /* inline-macro-config */ DISABLE_6X_DEPRECATIONS,\n {\n id: 'warp-drive.ember-inflector',\n until: '6.0.0',\n for: 'warp-drive',\n since: {\n enabled: '5.3.4',\n available: '4.13',\n },\n url: 'https://deprecations.emberjs.com/id/warp-drive.ember-inflector',\n }\n );\n\n return originalIrregular.apply(inflector, args);\n };\n\n inflector.uncountable = function (...args: Parameters<typeof originalUncountable>) {\n uncountable(...args);\n\n deprecate(\n `WarpDrive/EmberData no longer uses ember-inflector for uncountable rules.\\nPlease \\`import { uncountable } from '@ember-data/request-utils/string';\\` instead to register a custom uncountable rule for use with EmberData.`,\n /* inline-macro-config */ DISABLE_6X_DEPRECATIONS,\n {\n id: 'warp-drive.ember-inflector',\n until: '6.0.0',\n for: 'warp-drive',\n since: {\n enabled: '5.3.4',\n available: '4.13',\n },\n url: 'https://deprecations.emberjs.com/id/warp-drive.ember-inflector',\n }\n );\n\n return originalUncountable.apply(inflector, args);\n };\n }\n}\n"],"names":["macroCondition","getGlobalConfig","WarpDrive","deprecations","DEPRECATE_EMBER_INFLECTOR","dependencySatisfies","Inflector","importSync","default","inflector","originalPlural","plural","originalSingular","singular","originalIrregular","irregular","originalUncountable","uncountable","defaultPluralKeys","Set","defaultSingularKeys","WarpDriveDefaults","plurals","forEach","regex","add","toString","defaultRules","rules","irregularMap","Map","toIgnore","uncountableSet","irregularPairs","single","plur","set","toLowerCase","irregularLookups","Object","keys","replacement","has","deprecate","DISABLE_6X_DEPRECATIONS","id","until","for","since","enabled","available","url","defaultPlur","get","actualSingle","word","args","apply"],"mappings":";;;;AASA,IAAAA,cAAA,CAAAC,eAAA,EAAA,CAAAC,SAAA,CAAAC,YAAA,CAAAC,yBAAA,CAA+B,EAAA;EAC7B,IAAIJ,cAAc,CAACK,mBAAmB,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC,EAAE;AAC/D,IAAA,MAAMC,SAAS,GAAIC,UAAU,CAAC,iBAAiB,CAAC,CAA2DC,OAAO;IAClH,MAAM;AAAEC,MAAAA;AAAU,KAAC,GAAGH,SAAS;;AAE/B;AACA,IAAA,MAAMI,cAAc,GAAGD,SAAS,CAACE,MAAM;AACvC;AACA,IAAA,MAAMC,gBAAgB,GAAGH,SAAS,CAACI,QAAQ;AAC3C;AACA,IAAA,MAAMC,iBAAiB,GAAGL,SAAS,CAACM,SAAS;AAC7C;AACA,IAAA,MAAMC,mBAAmB,GAAGP,SAAS,CAACQ,WAAW;;AAEjD;;AAyBA;AACA;AACA;AACA,IAAA,MAAMC,iBAAiB,GAAG,IAAIC,GAAG,EAAU;AAC3C,IAAA,MAAMC,mBAAmB,GAAG,IAAID,GAAG,EAAU;IAC7CE,YAAiB,CAACC,OAAO,CAACC,OAAO,CAAC,CAAC,CAACC,KAAK,CAAC,KAAK;MAC7CN,iBAAiB,CAACO,GAAG,CAACD,KAAK,CAACE,QAAQ,EAAE,CAAC;AACzC,KAA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S,EAAE+C,IAAI,CAAC;KAC/C;AAED/C,IAAAA,SAAS,CAACM,SAAS,GAAG,UAAU,GAAGyC,IAA0C,EAAE;MAC7EzC,SAAS,CAAC,GAAGyC,IAAI,CAAC;MAElBb,SAAS,CACP,CAAuN,qNAAA,CAAA,2BACvN1C,eAAA,EAAAC,CAAAA,SAAA,CAAAC,YAAA,CAAAyC,uBAAA,EACA;AACEC,QAAAA,EAAE,EAAE,4BAA4B;AAChCC,QAAAA,KAAK,EAAE,OAAO;AACdC,QAAAA,GAAG,EAAE,YAAY;AACjBC,QAAAA,KAAK,EAAE;AACLC,UAAAA,OAAO,EAAE,OAAO;AAChBC,UAAAA,SAAS,EAAE;SACZ;AACDC,QAAAA,GAAG,EAAE;AACP,OACF,CAAC;AAED,MAAA,OAAOrC,iBAAiB,CAAC2C,KAAK,CAAChD,SAAS,EAAE+C,IAAI,CAAC;KAChD;AAED/C,IAAAA,SAAS,CAACQ,WAAW,GAAG,UAAU,GAAGuC,IAA4C,EAAE;MACjFvC,WAAW,CAAC,GAAGuC,IAAI,CAAC;MAEpBb,SAAS,CACP,CAA6N,2NAAA,CAAA,2BAC7N1C,eAAA,EAAAC,CAAAA,SAAA,CAAAC,YAAA,CAAAyC,uBAAA,EACA;AACEC,QAAAA,EAAE,EAAE,4BAA4B;AAChCC,QAAAA,KAAK,EAAE,OAAO;AACdC,QAAAA,GAAG,EAAE,YAAY;AACjBC,QAAAA,KAAK,EAAE;AACLC,UAAAA,OAAO,EAAE,OAAO;AAChBC,UAAAA,SAAS,EAAE;SACZ;AACDC,QAAAA,GAAG,EAAE;AACP,OACF,CAAC;AAED,MAAA,OAAOnC,mBAAmB,CAACyC,KAAK,CAAChD,SAAS,EAAE+C,IAAI,CAAC;KAClD;AACH;AACF"}
@@ -1,4 +1,5 @@
1
- import { assert, deprecate } from '@ember/debug';
1
+ import { deprecate } from '@ember/debug';
2
+ import { macroCondition, getGlobalConfig } from '@embroider/macros';
2
3
 
3
4
  /**
4
5
  * Simple utility function to assist in url building,
@@ -39,11 +40,9 @@ import { assert, deprecate } from '@ember/debug';
39
40
  * @main @ember-data/request-utils
40
41
  * @public
41
42
  */
42
-
43
43
  // prevents the final constructed object from needing to add
44
44
  // host and namespace which are provided by the final consuming
45
45
  // class to the prototype which can result in overwrite errors
46
-
47
46
  const CONFIG = {
48
47
  host: '',
49
48
  namespace: ''
@@ -90,13 +89,33 @@ const CONFIG = {
90
89
  * @return void
91
90
  */
92
91
  function setBuildURLConfig(config) {
93
- assert(`setBuildURLConfig: You must pass a config object`, config);
94
- assert(`setBuildURLConfig: You must pass a config object with a 'host' or 'namespace' property`, 'host' in config || 'namespace' in config);
92
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
93
+ if (!test) {
94
+ throw new Error(`setBuildURLConfig: You must pass a config object`);
95
+ }
96
+ })(config) : {};
97
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
98
+ if (!test) {
99
+ throw new Error(`setBuildURLConfig: You must pass a config object with a 'host' or 'namespace' property`);
100
+ }
101
+ })('host' in config || 'namespace' in config) : {};
95
102
  CONFIG.host = config.host || '';
96
103
  CONFIG.namespace = config.namespace || '';
97
- assert(`buildBaseURL: host must NOT end with '/', received '${CONFIG.host}'`, CONFIG.host === '/' || !CONFIG.host.endsWith('/'));
98
- assert(`buildBaseURL: namespace must NOT start with '/', received '${CONFIG.namespace}'`, !CONFIG.namespace.startsWith('/'));
99
- assert(`buildBaseURL: namespace must NOT end with '/', received '${CONFIG.namespace}'`, !CONFIG.namespace.endsWith('/'));
104
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
105
+ if (!test) {
106
+ throw new Error(`buildBaseURL: host must NOT end with '/', received '${CONFIG.host}'`);
107
+ }
108
+ })(CONFIG.host === '/' || !CONFIG.host.endsWith('/')) : {};
109
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
110
+ if (!test) {
111
+ throw new Error(`buildBaseURL: namespace must NOT start with '/', received '${CONFIG.namespace}'`);
112
+ }
113
+ })(!CONFIG.namespace.startsWith('/')) : {};
114
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
115
+ if (!test) {
116
+ throw new Error(`buildBaseURL: namespace must NOT end with '/', received '${CONFIG.namespace}'`);
117
+ }
118
+ })(!CONFIG.namespace.endsWith('/')) : {};
100
119
  }
101
120
  const OPERATIONS_WITH_PRIMARY_RECORDS = new Set(['findRecord', 'findRelatedRecord', 'findRelatedCollection', 'updateRecord', 'deleteRecord']);
102
121
  function isOperationWithPrimaryRecord(options) {
@@ -106,7 +125,11 @@ function hasResourcePath(options) {
106
125
  return 'resourcePath' in options && typeof options.resourcePath === 'string' && options.resourcePath.length > 0;
107
126
  }
108
127
  function resourcePathForType(options) {
109
- assert(`resourcePathForType: You must pass a valid op as part of options`, 'op' in options && typeof options.op === 'string');
128
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
129
+ if (!test) {
130
+ throw new Error(`resourcePathForType: You must pass a valid op as part of options`);
131
+ }
132
+ })('op' in options && typeof options.op === 'string') : {};
110
133
  return options.op === 'findMany' ? options.identifiers[0].type : options.identifier.type;
111
134
  }
112
135
 
@@ -156,13 +179,41 @@ function buildBaseURL(urlOptions) {
156
179
  host: CONFIG.host,
157
180
  namespace: CONFIG.namespace
158
181
  }, urlOptions);
159
- assert(`buildBaseURL: You must pass \`op\` as part of options`, hasResourcePath(options) || typeof options.op === 'string' && options.op.length > 0);
160
- assert(`buildBaseURL: You must pass \`identifier\` as part of options`, hasResourcePath(options) || options.op === 'findMany' || options.identifier && typeof options.identifier === 'object');
161
- assert(`buildBaseURL: You must pass \`identifiers\` as part of options`, hasResourcePath(options) || options.op !== 'findMany' || options.identifiers && Array.isArray(options.identifiers) && options.identifiers.length > 0 && options.identifiers.every(i => i && typeof i === 'object'));
162
- assert(`buildBaseURL: You must pass valid \`identifier\` as part of options, expected 'id'`, hasResourcePath(options) || !isOperationWithPrimaryRecord(options) || typeof options.identifier.id === 'string' && options.identifier.id.length > 0);
163
- assert(`buildBaseURL: You must pass \`identifiers\` as part of options`, hasResourcePath(options) || options.op !== 'findMany' || options.identifiers.every(i => typeof i.id === 'string' && i.id.length > 0));
164
- assert(`buildBaseURL: You must pass valid \`identifier\` as part of options, expected 'type'`, hasResourcePath(options) || options.op === 'findMany' || typeof options.identifier.type === 'string' && options.identifier.type.length > 0);
165
- assert(`buildBaseURL: You must pass valid \`identifiers\` as part of options, expected 'type'`, hasResourcePath(options) || options.op !== 'findMany' || typeof options.identifiers[0].type === 'string' && options.identifiers[0].type.length > 0);
182
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
183
+ if (!test) {
184
+ throw new Error(`buildBaseURL: You must pass \`op\` as part of options`);
185
+ }
186
+ })(hasResourcePath(options) || typeof options.op === 'string' && options.op.length > 0) : {};
187
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
188
+ if (!test) {
189
+ throw new Error(`buildBaseURL: You must pass \`identifier\` as part of options`);
190
+ }
191
+ })(hasResourcePath(options) || options.op === 'findMany' || options.identifier && typeof options.identifier === 'object') : {};
192
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
193
+ if (!test) {
194
+ throw new Error(`buildBaseURL: You must pass \`identifiers\` as part of options`);
195
+ }
196
+ })(hasResourcePath(options) || options.op !== 'findMany' || options.identifiers && Array.isArray(options.identifiers) && options.identifiers.length > 0 && options.identifiers.every(i => i && typeof i === 'object')) : {};
197
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
198
+ if (!test) {
199
+ throw new Error(`buildBaseURL: You must pass valid \`identifier\` as part of options, expected 'id'`);
200
+ }
201
+ })(hasResourcePath(options) || !isOperationWithPrimaryRecord(options) || typeof options.identifier.id === 'string' && options.identifier.id.length > 0) : {};
202
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
203
+ if (!test) {
204
+ throw new Error(`buildBaseURL: You must pass \`identifiers\` as part of options`);
205
+ }
206
+ })(hasResourcePath(options) || options.op !== 'findMany' || options.identifiers.every(i => typeof i.id === 'string' && i.id.length > 0)) : {};
207
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
208
+ if (!test) {
209
+ throw new Error(`buildBaseURL: You must pass valid \`identifier\` as part of options, expected 'type'`);
210
+ }
211
+ })(hasResourcePath(options) || options.op === 'findMany' || typeof options.identifier.type === 'string' && options.identifier.type.length > 0) : {};
212
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
213
+ if (!test) {
214
+ throw new Error(`buildBaseURL: You must pass valid \`identifiers\` as part of options, expected 'type'`);
215
+ }
216
+ })(hasResourcePath(options) || options.op !== 'findMany' || typeof options.identifiers[0].type === 'string' && options.identifiers[0].type.length > 0) : {};
166
217
 
167
218
  // prettier-ignore
168
219
  const idPath = isOperationWithPrimaryRecord(options) ? encodeURIComponent(options.identifier.id) : '';
@@ -172,16 +223,56 @@ function buildBaseURL(urlOptions) {
172
223
  namespace
173
224
  } = options;
174
225
  const fieldPath = 'fieldPath' in options ? options.fieldPath : '';
175
- assert(`buildBaseURL: You tried to build a url for a ${String('op' in options ? options.op + ' ' : '')}request to ${resourcePath} but resourcePath must be set or op must be one of "${['findRecord', 'findRelatedRecord', 'findRelatedCollection', 'updateRecord', 'deleteRecord', 'createRecord', 'query', 'findMany'].join('","')}".`, hasResourcePath(options) || ['findRecord', 'query', 'findMany', 'findRelatedCollection', 'findRelatedRecord', 'createRecord', 'updateRecord', 'deleteRecord'].includes(options.op));
176
- assert(`buildBaseURL: host must NOT end with '/', received '${host}'`, host === '/' || !host.endsWith('/'));
177
- assert(`buildBaseURL: namespace must NOT start with '/', received '${namespace}'`, !namespace.startsWith('/'));
178
- assert(`buildBaseURL: namespace must NOT end with '/', received '${namespace}'`, !namespace.endsWith('/'));
179
- assert(`buildBaseURL: resourcePath must NOT start with '/', received '${resourcePath}'`, !resourcePath.startsWith('/'));
180
- assert(`buildBaseURL: resourcePath must NOT end with '/', received '${resourcePath}'`, !resourcePath.endsWith('/'));
181
- assert(`buildBaseURL: fieldPath must NOT start with '/', received '${fieldPath}'`, !fieldPath.startsWith('/'));
182
- assert(`buildBaseURL: fieldPath must NOT end with '/', received '${fieldPath}'`, !fieldPath.endsWith('/'));
183
- assert(`buildBaseURL: idPath must NOT start with '/', received '${idPath}'`, !idPath.startsWith('/'));
184
- assert(`buildBaseURL: idPath must NOT end with '/', received '${idPath}'`, !idPath.endsWith('/'));
226
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
227
+ if (!test) {
228
+ throw new Error(`buildBaseURL: You tried to build a url for a ${String('op' in options ? options.op + ' ' : '')}request to ${resourcePath} but resourcePath must be set or op must be one of "${['findRecord', 'findRelatedRecord', 'findRelatedCollection', 'updateRecord', 'deleteRecord', 'createRecord', 'query', 'findMany'].join('","')}".`);
229
+ }
230
+ })(hasResourcePath(options) || ['findRecord', 'query', 'findMany', 'findRelatedCollection', 'findRelatedRecord', 'createRecord', 'updateRecord', 'deleteRecord'].includes(options.op)) : {};
231
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
232
+ if (!test) {
233
+ throw new Error(`buildBaseURL: host must NOT end with '/', received '${host}'`);
234
+ }
235
+ })(host === '/' || !host.endsWith('/')) : {};
236
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
237
+ if (!test) {
238
+ throw new Error(`buildBaseURL: namespace must NOT start with '/', received '${namespace}'`);
239
+ }
240
+ })(!namespace.startsWith('/')) : {};
241
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
242
+ if (!test) {
243
+ throw new Error(`buildBaseURL: namespace must NOT end with '/', received '${namespace}'`);
244
+ }
245
+ })(!namespace.endsWith('/')) : {};
246
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
247
+ if (!test) {
248
+ throw new Error(`buildBaseURL: resourcePath must NOT start with '/', received '${resourcePath}'`);
249
+ }
250
+ })(!resourcePath.startsWith('/')) : {};
251
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
252
+ if (!test) {
253
+ throw new Error(`buildBaseURL: resourcePath must NOT end with '/', received '${resourcePath}'`);
254
+ }
255
+ })(!resourcePath.endsWith('/')) : {};
256
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
257
+ if (!test) {
258
+ throw new Error(`buildBaseURL: fieldPath must NOT start with '/', received '${fieldPath}'`);
259
+ }
260
+ })(!fieldPath.startsWith('/')) : {};
261
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
262
+ if (!test) {
263
+ throw new Error(`buildBaseURL: fieldPath must NOT end with '/', received '${fieldPath}'`);
264
+ }
265
+ })(!fieldPath.endsWith('/')) : {};
266
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
267
+ if (!test) {
268
+ throw new Error(`buildBaseURL: idPath must NOT start with '/', received '${idPath}'`);
269
+ }
270
+ })(!idPath.startsWith('/')) : {};
271
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
272
+ if (!test) {
273
+ throw new Error(`buildBaseURL: idPath must NOT end with '/', received '${idPath}'`);
274
+ }
275
+ })(!idPath.endsWith('/')) : {};
185
276
  const hasHost = host !== '' && host !== '/';
186
277
  const url = [hasHost ? host : '', namespace, resourcePath, idPath, fieldPath].filter(Boolean).join('/');
187
278
  return hasHost ? url : `/${url}`;
@@ -190,7 +281,11 @@ const DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS = {
190
281
  arrayFormat: 'comma'
191
282
  };
192
283
  function handleInclude(include) {
193
- assert(`Expected include to be a string or array, got ${typeof include}`, typeof include === 'string' || Array.isArray(include));
284
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
285
+ if (!test) {
286
+ throw new Error(`Expected include to be a string or array, got ${typeof include}`);
287
+ }
288
+ })(typeof include === 'string' || Array.isArray(include)) : {};
194
289
  return typeof include === 'string' ? include.split(',') : include;
195
290
  }
196
291
 
@@ -248,7 +343,7 @@ function sortQueryParams(params, options) {
248
343
  const dictionaryParams = paramsIsObject ? params : {};
249
344
  if (!paramsIsObject) {
250
345
  params.forEach((value, key) => {
251
- const hasExisting = (key in dictionaryParams);
346
+ const hasExisting = key in dictionaryParams;
252
347
  if (!hasExisting) {
253
348
  dictionaryParams[key] = value;
254
349
  } else {
@@ -358,14 +453,26 @@ function parseCacheControl(header) {
358
453
  const cacheControlValue = {};
359
454
  function parseCacheControlValue(stringToParse) {
360
455
  const parsedValue = Number.parseInt(stringToParse);
361
- assert(`Invalid Cache-Control value, expected a number but got - ${stringToParse}`, !Number.isNaN(parsedValue));
456
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
457
+ if (!test) {
458
+ throw new Error(`Invalid Cache-Control value, expected a number but got - ${stringToParse}`);
459
+ }
460
+ })(!Number.isNaN(parsedValue)) : {};
362
461
  return parsedValue;
363
462
  }
364
463
  for (let i = 0; i < header.length; i++) {
365
464
  const char = header.charAt(i);
366
465
  if (char === ',') {
367
- assert(`Invalid Cache-Control value, expected a value`, !isParsingKey || !NUMERIC_KEYS.has(key));
368
- assert(`Invalid Cache-Control value, expected a value after "=" but got ","`, i === 0 || header.charAt(i - 1) !== '=');
466
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
467
+ if (!test) {
468
+ throw new Error(`Invalid Cache-Control value, expected a value`);
469
+ }
470
+ })(!isParsingKey || !NUMERIC_KEYS.has(key)) : {};
471
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
472
+ if (!test) {
473
+ throw new Error(`Invalid Cache-Control value, expected a value after "=" but got ","`);
474
+ }
475
+ })(i === 0 || header.charAt(i - 1) !== '=') : {};
369
476
  isParsingKey = true;
370
477
  // @ts-expect-error TS incorrectly thinks that optional keys must have a type that includes undefined
371
478
  cacheControlValue[key] = NUMERIC_KEYS.has(key) ? parseCacheControlValue(value) : true;
@@ -373,7 +480,11 @@ function parseCacheControl(header) {
373
480
  value = '';
374
481
  continue;
375
482
  } else if (char === '=') {
376
- assert(`Invalid Cache-Control value, expected a value after "="`, i + 1 !== header.length);
483
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
484
+ if (!test) {
485
+ throw new Error(`Invalid Cache-Control value, expected a value after "="`);
486
+ }
487
+ })(i + 1 !== header.length) : {};
377
488
  isParsingKey = false;
378
489
  } else if (char === ' ' || char === `\t` || char === `\n`) {
379
490
  continue;
@@ -383,6 +494,7 @@ function parseCacheControl(header) {
383
494
  value += char;
384
495
  }
385
496
  if (i === header.length - 1) {
497
+ // @ts-expect-error TS incorrectly thinks that optional keys must have a type that includes undefined
386
498
  cacheControlValue[key] = NUMERIC_KEYS.has(key) ? parseCacheControlValue(value) : true;
387
499
  }
388
500
  }
@@ -404,7 +516,7 @@ function isStale(headers, expirationTime) {
404
516
  return result;
405
517
  }
406
518
  /**
407
- * A basic LifetimesService that can be added to the Store service.
519
+ * A basic CachePolicy that can be added to the Store service.
408
520
  *
409
521
  * Determines staleness based on time since the request was last received from the API
410
522
  * using the `date` header.
@@ -435,7 +547,7 @@ function isStale(headers, expirationTime) {
435
547
  * Usage:
436
548
  *
437
549
  * ```ts
438
- * import { LifetimesService } from '@ember-data/request-utils';
550
+ * import { CachePolicy } from '@ember-data/request-utils';
439
551
  * import DataStore from '@ember-data/store';
440
552
  *
441
553
  * // ...
@@ -443,16 +555,16 @@ function isStale(headers, expirationTime) {
443
555
  * export class Store extends DataStore {
444
556
  * constructor(args) {
445
557
  * super(args);
446
- * this.lifetimes = new LifetimesService({ apiCacheSoftExpires: 30_000, apiCacheHardExpires: 60_000 });
558
+ * this.lifetimes = new CachePolicy({ apiCacheSoftExpires: 30_000, apiCacheHardExpires: 60_000 });
447
559
  * }
448
560
  * }
449
561
  * ```
450
562
  *
451
- * @class LifetimesService
563
+ * @class CachePolicy
452
564
  * @public
453
565
  * @module @ember-data/request-utils
454
566
  */
455
- class LifetimesService {
567
+ class CachePolicy {
456
568
  _getStore(store) {
457
569
  let set = this._stores.get(store);
458
570
  if (!set) {
@@ -467,25 +579,37 @@ class LifetimesService {
467
579
  constructor(config) {
468
580
  this._stores = new WeakMap();
469
581
  const _config = arguments.length === 1 ? config : arguments[1];
470
- deprecate(`Passing a Store to the LifetimesService is deprecated, please pass only a config instead.`, arguments.length === 1, {
582
+ deprecate(`Passing a Store to the CachePolicy is deprecated, please pass only a config instead.`, /* inline-macro-config */getGlobalConfig().WarpDrive.deprecations.DISABLE_6X_DEPRECATIONS ? true : arguments.length === 1, {
471
583
  id: 'ember-data:request-utils:lifetimes-service-store-arg',
472
584
  since: {
473
585
  enabled: '5.4',
474
- available: '5.4'
586
+ available: '4.13'
475
587
  },
476
588
  for: '@ember-data/request-utils',
477
589
  until: '6.0'
478
590
  });
479
- assert(`You must pass a config to the LifetimesService`, _config);
480
- assert(`You must pass a apiCacheSoftExpires to the LifetimesService`, typeof _config.apiCacheSoftExpires === 'number');
481
- assert(`You must pass a apiCacheHardExpires to the LifetimesService`, typeof _config.apiCacheHardExpires === 'number');
591
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
592
+ if (!test) {
593
+ throw new Error(`You must pass a config to the CachePolicy`);
594
+ }
595
+ })(_config) : {};
596
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
597
+ if (!test) {
598
+ throw new Error(`You must pass a apiCacheSoftExpires to the CachePolicy`);
599
+ }
600
+ })(typeof _config.apiCacheSoftExpires === 'number') : {};
601
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
602
+ if (!test) {
603
+ throw new Error(`You must pass a apiCacheHardExpires to the CachePolicy`);
604
+ }
605
+ })(typeof _config.apiCacheHardExpires === 'number') : {};
482
606
  this.config = _config;
483
607
  }
484
608
 
485
609
  /**
486
610
  * Invalidate a request by its identifier for a given store instance.
487
611
  *
488
- * While the store argument may seem redundant, the lifetimes service
612
+ * While the store argument may seem redundant, the CachePolicy
489
613
  * is designed to be shared across multiple stores / forks
490
614
  * of the store.
491
615
  *
@@ -499,14 +623,14 @@ class LifetimesService {
499
623
  * @param {Store} store
500
624
  */
501
625
  invalidateRequest(identifier, store) {
502
- this._getStore(store).invalidated.add(identifier.lid);
626
+ this._getStore(store).invalidated.add(identifier);
503
627
  }
504
628
 
505
629
  /**
506
630
  * Invalidate all requests associated to a specific type
507
631
  * for a given store instance.
508
632
  *
509
- * While the store argument may seem redundant, the lifetimes service
633
+ * While the store argument may seem redundant, the CachePolicy
510
634
  * is designed to be shared across multiple stores / forks
511
635
  * of the store.
512
636
  *
@@ -525,9 +649,12 @@ class LifetimesService {
525
649
  invalidateRequestsForType(type, store) {
526
650
  const storeCache = this._getStore(store);
527
651
  const set = storeCache.types.get(type);
652
+ const notifications = store.notifications;
528
653
  if (set) {
654
+ // TODO batch notifications
529
655
  set.forEach(id => {
530
656
  storeCache.invalidated.add(id);
657
+ notifications.notify(id, 'invalidated');
531
658
  });
532
659
  }
533
660
  }
@@ -572,10 +699,10 @@ class LifetimesService {
572
699
  request.cacheOptions?.types.forEach(type => {
573
700
  const set = storeCache.types.get(type);
574
701
  if (set) {
575
- set.add(identifier.lid);
576
- storeCache.invalidated.delete(identifier.lid);
702
+ set.add(identifier);
703
+ storeCache.invalidated.delete(identifier);
577
704
  } else {
578
- storeCache.types.set(type, new Set([identifier.lid]));
705
+ storeCache.types.set(type, new Set([identifier]));
579
706
  }
580
707
  });
581
708
  }
@@ -601,7 +728,7 @@ class LifetimesService {
601
728
  isHardExpired(identifier, store) {
602
729
  // if we are explicitly invalidated, we are hard expired
603
730
  const storeCache = this._getStore(store);
604
- if (storeCache.invalidated.has(identifier.lid)) {
731
+ if (storeCache.invalidated.has(identifier)) {
605
732
  return true;
606
733
  }
607
734
  const cache = store.cache;
@@ -631,4 +758,18 @@ class LifetimesService {
631
758
  return !cached || !cached.response || isStale(cached.response.headers, this.config.apiCacheSoftExpires);
632
759
  }
633
760
  }
634
- export { LifetimesService, buildBaseURL, buildQueryParams, filterEmpty, parseCacheControl, setBuildURLConfig, sortQueryParams };
761
+ class LifetimesService extends CachePolicy {
762
+ constructor(config) {
763
+ deprecate(`\`import { LifetimesService } from '@ember-data/request-utils';\` is deprecated, please use \`import { CachePolicy } from '@ember-data/request-utils';\` instead.`, /* inline-macro-config */getGlobalConfig().WarpDrive.deprecations.DISABLE_6X_DEPRECATIONS, {
764
+ id: 'ember-data:deprecate-lifetimes-service-import',
765
+ since: {
766
+ enabled: '5.4',
767
+ available: '4.13'
768
+ },
769
+ for: 'ember-data',
770
+ until: '6.0'
771
+ });
772
+ super(config);
773
+ }
774
+ }
775
+ export { CachePolicy, LifetimesService, buildBaseURL, buildQueryParams, filterEmpty, parseCacheControl, setBuildURLConfig, sortQueryParams };