@warp-drive/build-config 0.0.0-beta.0 → 0.0.0-beta.10

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +21 -2
  3. package/dist/babel-macros.js +5 -2
  4. package/dist/babel-macros.js.map +1 -1
  5. package/dist/babel-plugin-transform-asserts.cjs.map +1 -1
  6. package/dist/babel-plugin-transform-deprecations.cjs +20 -6
  7. package/dist/babel-plugin-transform-deprecations.cjs.map +1 -1
  8. package/dist/babel-plugin-transform-features.cjs +4 -4
  9. package/dist/babel-plugin-transform-features.cjs.map +1 -1
  10. package/dist/babel-plugin-transform-logging.cjs +3 -3
  11. package/dist/babel-plugin-transform-logging.cjs.map +1 -1
  12. package/dist/cjs-set-config.cjs +895 -0
  13. package/dist/cjs-set-config.cjs.map +1 -0
  14. package/dist/{deprecations-BXAnWRDO.js → deprecations-ChFQtx-4.js} +6 -2
  15. package/dist/deprecations-ChFQtx-4.js.map +1 -0
  16. package/dist/deprecations.js +1 -1
  17. package/dist/env.js +4 -1
  18. package/dist/env.js.map +1 -1
  19. package/dist/index.js +133 -36
  20. package/dist/index.js.map +1 -1
  21. package/package.json +24 -14
  22. package/unstable-preview-types/-private/utils/deprecations.d.ts +3 -1
  23. package/unstable-preview-types/-private/utils/deprecations.d.ts.map +1 -1
  24. package/unstable-preview-types/-private/utils/features.d.ts.map +1 -1
  25. package/unstable-preview-types/-private/utils/get-env.d.ts +3 -0
  26. package/unstable-preview-types/-private/utils/get-env.d.ts.map +1 -1
  27. package/unstable-preview-types/babel-macros.d.ts +3 -0
  28. package/unstable-preview-types/babel-macros.d.ts.map +1 -1
  29. package/unstable-preview-types/cjs-set-config.d.ts +4 -0
  30. package/unstable-preview-types/cjs-set-config.d.ts.map +1 -0
  31. package/unstable-preview-types/deprecation-versions.d.ts +71 -19
  32. package/unstable-preview-types/deprecation-versions.d.ts.map +1 -1
  33. package/unstable-preview-types/deprecations.d.ts +2 -0
  34. package/unstable-preview-types/deprecations.d.ts.map +1 -1
  35. package/unstable-preview-types/env.d.ts +3 -0
  36. package/unstable-preview-types/env.d.ts.map +1 -1
  37. package/unstable-preview-types/index.d.ts +6 -5
  38. package/unstable-preview-types/index.d.ts.map +1 -1
  39. package/dist/deprecations-BXAnWRDO.js.map +0 -1
@@ -0,0 +1,895 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const EmbroiderMacros = require('@embroider/macros/src/node.js');
6
+ const semver = require('semver');
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+ const url = require('url');
10
+
11
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
12
+ function getEnv() {
13
+ const {
14
+ EMBER_ENV,
15
+ IS_TESTING,
16
+ EMBER_CLI_TEST_COMMAND,
17
+ NODE_ENV,
18
+ CI,
19
+ IS_RECORDING
20
+ } = process.env;
21
+ const PRODUCTION = EMBER_ENV === 'production' || !EMBER_ENV && NODE_ENV === 'production';
22
+ const DEBUG = !PRODUCTION;
23
+ const TESTING = DEBUG || Boolean(EMBER_ENV === 'test' || IS_TESTING || EMBER_CLI_TEST_COMMAND);
24
+ const SHOULD_RECORD = Boolean(!CI || IS_RECORDING);
25
+ return {
26
+ TESTING,
27
+ PRODUCTION,
28
+ DEBUG,
29
+ IS_RECORDING: Boolean(IS_RECORDING),
30
+ IS_CI: Boolean(CI),
31
+ SHOULD_RECORD
32
+ };
33
+ }
34
+
35
+ // ========================
36
+ // FOR CONTRIBUTING AUTHORS
37
+ //
38
+ // Deprecations here should also have guides PR'd to the emberjs deprecation app
39
+ //
40
+ // github: https://github.com/ember-learn/deprecation-app
41
+ // website: https://deprecations.emberjs.com
42
+ //
43
+ // Each deprecation should also be given an associated URL pointing to the
44
+ // relevant guide.
45
+ //
46
+ // URLs should be of the form: https://deprecations.emberjs.com/v<major>.x#toc_<fileName>
47
+ // where <major> is the major version of the deprecation and <fileName> is the
48
+ // name of the markdown file in the guides repo.
49
+ //
50
+ // ========================
51
+ //
52
+
53
+ /**
54
+ * ## Deprecations
55
+ *
56
+ * EmberData allows users to opt-in and remove code that exists to support deprecated
57
+ * behaviors.
58
+ *
59
+ * If your app has resolved all deprecations present in a given version,
60
+ * you may specify that version as your "compatibility" version to remove
61
+ * the code that supported the deprecated behavior from your app.
62
+ *
63
+ * For instance, if a deprecation was introduced in 3.13, and the app specifies
64
+ * 3.13 as its minimum version compatibility, any deprecations introduced before
65
+ * or during 3.13 would be stripped away.
66
+ *
67
+ * An app can use a different version than what it specifies as it's compatibility
68
+ * version. For instance, an App could be using `3.16` while specifying compatibility
69
+ * with `3.12`. This would remove any deprecations that were present in or before `3.12`
70
+ * but keep support for anything deprecated in or above `3.13`.
71
+ *
72
+ * ### Configuring Compatibility
73
+ *
74
+ * To configure your compatibility version, set the `compatWith` to the version you
75
+ * are compatible with on the `emberData` config in your `ember-cli-build.js` file.
76
+ *
77
+ * ```js
78
+ * const { setConfig } = await import('@warp-drive/build-config');
79
+ *
80
+ * let app = new EmberApp(defaults, {});
81
+ *
82
+ * setConfig(app, __dirname, { compatWith: '3.12' });
83
+ * ```
84
+ *
85
+ * Alternatively, individual deprecations can be resolved (and thus have its support stripped)
86
+ * via one of the flag names listed below. For instance, given a flag named `DEPRECATE_FOO_BEHAVIOR`.
87
+ *
88
+ * This capability is interopable with `compatWith`. You may set `compatWith` and then selectively resolve
89
+ * additional deprecations, or set compatWith and selectively un-resolve specific deprecations.
90
+ *
91
+ * Note: EmberData does not test against permutations of deprecations being stripped, our tests run against
92
+ * "all deprecated code included" and "all deprecated code removed". Unspecified behavior may sometimes occur
93
+ * when removing code for only some deprecations associated to a version number.
94
+ *
95
+ * ```js
96
+ * const { setConfig } = await import('@warp-drive/build-config');
97
+ *
98
+ * let app = new EmberApp(defaults, {});
99
+ *
100
+ * setConfig(app, __dirname, {
101
+ * deprecations: {
102
+ * DEPRECATE_FOO_BEHAVIOR: false // set to false to strip this code
103
+ * DEPRECATE_BAR_BEHAVIOR: true // force to true to not strip this code
104
+ * }
105
+ * });
106
+ * ```
107
+ *
108
+ * The complete list of which versions specific deprecations will be removed in
109
+ * can be found [here](https://github.com/emberjs/data/blob/main/packages/build-config/src/virtual/deprecation-versions.ts "List of EmberData Deprecations")
110
+ *
111
+ * @module @warp-drive/build-config/deprecations
112
+ * @main @warp-drive/build-config/deprecations
113
+ */
114
+
115
+ /**
116
+ * The following list represents deprecations currently active.
117
+ *
118
+ * Some deprecation flags guard multiple deprecation IDs. All
119
+ * associated IDs are listed.
120
+ *
121
+ * @class CurrentDeprecations
122
+ * @public
123
+ */
124
+ const DEPRECATE_CATCH_ALL = '99.0';
125
+ /**
126
+ * **id: ember-data:deprecate-non-strict-types**
127
+ *
128
+ * Currently, EmberData expects that the `type` property associated with
129
+ * a resource follows several conventions.
130
+ *
131
+ * - The `type` property must be a non-empty string
132
+ * - The `type` property must be singular
133
+ * - The `type` property must be dasherized
134
+ *
135
+ * We are deprecating support for types that do not match this pattern
136
+ * in order to unlock future improvements in which we can support `type`
137
+ * being any string of your choosing.
138
+ *
139
+ * The goal is that in the future, you will be able to use any string
140
+ * so long as it matches what your configured cache, identifier generation,
141
+ * and schemas expect.
142
+ *
143
+ * E.G. It will matter not that your string is in a specific format like
144
+ * singular, dasherized, etc. so long as everywhere you refer to the type
145
+ * you use the same string.
146
+ *
147
+ * If using @ember-data/model, there will always be a restriction that the
148
+ * `type` must match the path on disk where the model is defined.
149
+ *
150
+ * e.g. `app/models/foo/bar-bem.js` must have a type of `foo/bar-bem`
151
+ *
152
+ * @property DEPRECATE_NON_STRICT_TYPES
153
+ * @since 5.3
154
+ * @until 6.0
155
+ * @public
156
+ */
157
+ const DEPRECATE_NON_STRICT_TYPES = '5.3';
158
+
159
+ /**
160
+ * **id: ember-data:deprecate-non-strict-id**
161
+ *
162
+ * Currently, EmberData expects that the `id` property associated with
163
+ * a resource is a string.
164
+ *
165
+ * However, for legacy support in many locations we would accept a number
166
+ * which would then immediately be coerced into a string.
167
+ *
168
+ * We are deprecating this legacy support for numeric IDs.
169
+ *
170
+ * The goal is that in the future, you will be able to use any ID format
171
+ * so long as everywhere you refer to the ID you use the same format.
172
+ *
173
+ * However, for identifiers we will always use string IDs and so any
174
+ * custom identifier configuration should provide a string ID.
175
+ *
176
+ * @property DEPRECATE_NON_STRICT_ID
177
+ * @since 5.3
178
+ * @until 6.0
179
+ * @public
180
+ */
181
+ const DEPRECATE_NON_STRICT_ID = '5.3';
182
+
183
+ /**
184
+ * **id: <none yet assigned>**
185
+ *
186
+ * This is a planned deprecation which will trigger when observer or computed
187
+ * chains are used to watch for changes on any EmberData LiveArray, CollectionRecordArray,
188
+ * ManyArray or PromiseManyArray.
189
+ *
190
+ * Support for these chains is currently guarded by the deprecation flag
191
+ * listed here, enabling removal of the behavior if desired.
192
+ *
193
+ * @property DEPRECATE_COMPUTED_CHAINS
194
+ * @since 5.0
195
+ * @until 6.0
196
+ * @public
197
+ */
198
+ const DEPRECATE_COMPUTED_CHAINS = '5.0';
199
+
200
+ /**
201
+ * **id: ember-data:deprecate-legacy-imports**
202
+ *
203
+ * Deprecates when importing from `ember-data/*` instead of `@ember-data/*`
204
+ * in order to prepare for the eventual removal of the legacy `ember-data/*`
205
+ *
206
+ * All imports from `ember-data/*` should be updated to `@ember-data/*`
207
+ * except for `ember-data/store`. When you are using `ember-data` (as opposed to
208
+ * installing the indivudal packages) you should import from `ember-data/store`
209
+ * instead of `@ember-data/store` in order to receive the appropriate configuration
210
+ * of defaults.
211
+ *
212
+ * @property DEPRECATE_LEGACY_IMPORTS
213
+ * @since 5.3
214
+ * @until 6.0
215
+ * @public
216
+ */
217
+ const DEPRECATE_LEGACY_IMPORTS = '5.3';
218
+
219
+ /**
220
+ * **id: ember-data:deprecate-non-unique-collection-payloads**
221
+ *
222
+ * Deprecates when the data for a hasMany relationship contains
223
+ * duplicate identifiers.
224
+ *
225
+ * Previously, relationships would silently de-dupe the data
226
+ * when received, but this behavior is being removed in favor
227
+ * of erroring if the same related record is included multiple
228
+ * times.
229
+ *
230
+ * For instance, in JSON:API the below relationship data would
231
+ * be considered invalid:
232
+ *
233
+ * ```json
234
+ * {
235
+ * "data": {
236
+ * "type": "article",
237
+ * "id": "1",
238
+ * "relationships": {
239
+ * "comments": {
240
+ * "data": [
241
+ * { "type": "comment", "id": "1" },
242
+ * { "type": "comment", "id": "2" },
243
+ * { "type": "comment", "id": "1" } // duplicate
244
+ * ]
245
+ * }
246
+ * }
247
+ * }
248
+ * ```
249
+ *
250
+ * To resolve this deprecation, either update your server to
251
+ * not include duplicate data, or implement normalization logic
252
+ * in either a request handler or serializer which removes
253
+ * duplicate data from relationship payloads.
254
+ *
255
+ * @property DEPRECATE_NON_UNIQUE_PAYLOADS
256
+ * @since 5.3
257
+ * @until 6.0
258
+ * @public
259
+ */
260
+ const DEPRECATE_NON_UNIQUE_PAYLOADS = '5.3';
261
+
262
+ /**
263
+ * **id: ember-data:deprecate-relationship-remote-update-clearing-local-state**
264
+ *
265
+ * Deprecates when a relationship is updated remotely and the local state
266
+ * is cleared of all changes except for "new" records.
267
+ *
268
+ * Instead, any records not present in the new payload will be considered
269
+ * "removed" while any records present in the new payload will be considered "added".
270
+ *
271
+ * This allows us to "commit" local additions and removals, preserving any additions
272
+ * or removals that are not yet reflected in the remote state.
273
+ *
274
+ * For instance, given the following initial state:
275
+ *
276
+ * remote: A, B, C
277
+ * local: add D, E
278
+ * remove B, C
279
+ * => A, D, E
280
+ *
281
+ *
282
+ * If after an update, the remote state is now A, B, D, F then the new state will be
283
+ *
284
+ * remote: A, B, D, F
285
+ * local: add E
286
+ * remove B
287
+ * => A, D, E, F
288
+ *
289
+ * Under the old behavior the updated local state would instead have been
290
+ * => A, B, D, F
291
+ *
292
+ * Similarly, if a belongsTo remote State was A while its local state was B,
293
+ * then under the old behavior if the remote state changed to C, the local state
294
+ * would be updated to C. Under the new behavior, the local state would remain B.
295
+ *
296
+ * If the remote state was A while its local state was `null`, then under the old
297
+ * behavior if the remote state changed to C, the local state would be updated to C.
298
+ * Under the new behavior, the local state would remain `null`.
299
+ *
300
+ * Thus the new correct mental model is that the state of the relationship at any point
301
+ * in time is whatever the most recent remote state is, plus any local additions or removals
302
+ * you have made that have not yet been reflected by the remote state.
303
+ *
304
+ * > Note: The old behavior extended to modifying the inverse of a relationship. So if
305
+ * > you had local state not reflected in the new remote state, inverses would be notified
306
+ * > and their state reverted as well when "resetting" the relationship.
307
+ * > Under the new behavior, since the local state is preserved the inverses will also
308
+ * > not be reverted.
309
+ *
310
+ * ### Resolving this deprecation
311
+ *
312
+ * Resolving this deprecation can be done individually for each relationship
313
+ * or globally for all relationships.
314
+ *
315
+ * To resolve it globally, set the `DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE`
316
+ * to `false` in ember-cli-build.js
317
+ *
318
+ * ```js
319
+ * const { setConfig } = await import('@warp-drive/build-config');
320
+ *
321
+ * let app = new EmberApp(defaults, {});
322
+ *
323
+ * setConfig(app, __dirname, {
324
+ * deprecations: {
325
+ * // set to false to strip the deprecated code (thereby opting into the new behavior)
326
+ * DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE: false
327
+ * }
328
+ * });
329
+ * ```
330
+ *
331
+ * To resolve this deprecation on an individual relationship, adjust the `options` passed to
332
+ * the relationship. For relationships with inverses, both sides MUST be migrated to the new
333
+ * behavior at the same time.
334
+ *
335
+ * ```js
336
+ * class Person extends Model {
337
+ * @hasMany('person', {
338
+ * async: false,
339
+ * inverse: null,
340
+ * resetOnRemoteUpdate: false
341
+ * }) children;
342
+ *
343
+ * @belongsTo('person', {
344
+ * async: false,
345
+ * inverse: null,
346
+ * resetOnRemoteUpdate: false
347
+ * }) parent;
348
+ * }
349
+ * ```
350
+ *
351
+ * > Note: false is the only valid value here, all other values (including missing)
352
+ * > will be treated as true, where `true` is the legacy behavior that is now deprecated.
353
+ *
354
+ * Once you have migrated all relationships, you can remove the the resetOnRemoteUpdate
355
+ * option and set the deprecation flag to false in ember-cli-build.
356
+ *
357
+ * ### What if I don't want the new behavior?
358
+ *
359
+ * EmberData's philosophy is to not make assumptions about your application. Where possible
360
+ * we seek out "100%" solutions – solutions that work for all use cases - and where that is
361
+ * not possible we default to "90%" solutions – solutions that work for the vast majority of use
362
+ * cases. In the case of "90%" solutions we look for primitives that allow you to resolve the
363
+ * 10% case in your application. If no such primitives exist, we provide an escape hatch that
364
+ * ensures you can build the behavior you need without adopting the cost of the default solution.
365
+ *
366
+ * In this case, the old behavior was a "40%" solution. The inability for an application developer
367
+ * to determine what changes were made locally, and thus what changes should be preserved, made
368
+ * it impossible to build certain features easily, or in some cases at all. The proliferation of
369
+ * feature requests, bug reports (from folks surprised by the prior behavior) and addon attempts
370
+ * in this space are all evidence of this.
371
+ *
372
+ * We believe the new behavior is a "90%" solution. It works for the vast majority of use cases,
373
+ * often without noticeable changes to existing application behavior, and provides primitives that
374
+ * allow you to build the behavior you need for the remaining 10%.
375
+ *
376
+ * The great news is that this behavior defaults to trusting your API similar to the old behavior.
377
+ * If your API is correct, you will not need to make any changes to your application to adopt
378
+ * the new behavior.
379
+ *
380
+ * This means the 10% cases are those where you can't trust your API to provide the correct
381
+ * information. In these cases, because you now have cheap access to a diff of the relationship
382
+ * state, there are a few options that weren't available before:
383
+ *
384
+ * - you can adjust returned API payloads to contain the expected changes that it doesn't include
385
+ * - you can modify local state by adding or removing records on the HasMany record array to remove
386
+ * any local changes that were not returned by the API.
387
+ * - you can use `<Cache>.mutate(mutation)` to directly modify the local cache state of the relationship
388
+ * to match the expected state.
389
+ *
390
+ * What this version (5.3) does not yet provide is a way to directly modify the cache's remote state
391
+ * for the relationship via public APIs other than via the broader action of upserting a response via
392
+ * `<Cache>.put(document)`. However, such an API was sketched in the Cache 2.1 RFC
393
+ * `<Cache>.patch(operation)` and is likely to be added in a future 5.x release of EmberData.
394
+ *
395
+ * This version (5.3) also does not yet provide a way to directly modify the graph (a general purpose
396
+ * subset of cache behaviors specific to relationships) via public APIs. However, during the
397
+ * 5.x release series we will be working on finalizing the Graph API and making it public.
398
+ *
399
+ * If none of these options work for you, you can always opt-out more broadly by implementing
400
+ * a custom Cache with the relationship behaviors you need.
401
+ *
402
+ * @property DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE
403
+ * @since 5.3
404
+ * @until 6.0
405
+ * @public
406
+ */
407
+ const DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE = '5.3';
408
+
409
+ /**
410
+ * **id: ember-data:deprecate-many-array-duplicates**
411
+ *
412
+ * When the flag is `true` (default), adding duplicate records to a `ManyArray`
413
+ * is deprecated in non-production environments. In production environments,
414
+ * duplicate records added to a `ManyArray` will be deduped and no error will
415
+ * be thrown.
416
+ *
417
+ * When the flag is `false`, an error will be thrown when duplicates are added.
418
+ *
419
+ * @property DEPRECATE_MANY_ARRAY_DUPLICATES
420
+ * @since 5.3
421
+ * @until 6.0
422
+ * @public
423
+ */
424
+ const DEPRECATE_MANY_ARRAY_DUPLICATES = '5.3';
425
+
426
+ /**
427
+ * **id: ember-data:deprecate-store-extends-ember-object**
428
+ *
429
+ * When the flag is `true` (default), the Store class will extend from `@ember/object`.
430
+ * When the flag is `false` or `ember-source` is not present, the Store will not extend
431
+ * from EmberObject.
432
+ *
433
+ * @property DEPRECATE_STORE_EXTENDS_EMBER_OBJECT
434
+ * @since 5.4
435
+ * @until 6.0
436
+ * @public
437
+ */
438
+ const DEPRECATE_STORE_EXTENDS_EMBER_OBJECT = '5.4';
439
+
440
+ /**
441
+ * **id: ember-data:schema-service-updates**
442
+ *
443
+ * When the flag is `true` (default), the legacy schema
444
+ * service features will be enabled on the store and
445
+ * the service, and deprecations will be thrown when
446
+ * they are used.
447
+ *
448
+ * Deprecated features include:
449
+ *
450
+ * - `Store.registerSchema` method is deprecated in favor of the `Store.createSchemaService` hook
451
+ * - `Store.registerSchemaDefinitionService` method is deprecated in favor of the `Store.createSchemaService` hook
452
+ * - `Store.getSchemaDefinitionService` method is deprecated in favor of `Store.schema` property
453
+ * - `SchemaService.doesTypeExist` method is deprecated in favor of the `SchemaService.hasResource` method
454
+ * - `SchemaService.attributesDefinitionFor` method is deprecated in favor of the `SchemaService.fields` method
455
+ * - `SchemaService.relationshipsDefinitionFor` method is deprecated in favor of the `SchemaService.fields` method
456
+ *
457
+ * @property ENABLE_LEGACY_SCHEMA_SERVICE
458
+ * @since 5.4
459
+ * @until 6.0
460
+ * @public
461
+ */
462
+ const ENABLE_LEGACY_SCHEMA_SERVICE = '5.4';
463
+
464
+ /**
465
+ * **id: warp-drive.ember-inflector**
466
+ *
467
+ * Deprecates the use of ember-inflector for pluralization and singularization in favor
468
+ * of the `@ember-data/request-utils` package.
469
+ *
470
+ * Rule configuration methods (singular, plural, uncountable, irregular) and
471
+ * usage methods (singularize, pluralize) are are available as imports from
472
+ * `@ember-data/request-utils/string`
473
+ *
474
+ * Notable differences with ember-inflector:
475
+ * - there cannot be multiple inflector instances with separate rules
476
+ * - pluralization does not support a count argument
477
+ * - string caches now default to 10k entries instead of 1k, and this
478
+ * size is now configurable. Additionally, the cache is now a LRU cache
479
+ * instead of a first-N cache.
480
+ *
481
+ * This deprecation can be resolved by removing usage of ember-inflector or by using
482
+ * both ember-inflector and @ember-data/request-utils in parallel and updating your
483
+ * EmberData/WarpDrive build config to mark the deprecation as resolved
484
+ * in ember-cli-build
485
+ *
486
+ * ```js
487
+ * setConfig(app, __dirname, { deprecations: { DEPRECATE_EMBER_INFLECTOR: false }});
488
+ * ```
489
+ *
490
+ * @property DEPRECATE_EMBER_INFLECTOR
491
+ * @since 5.3
492
+ * @until 6.0
493
+ * @public
494
+ */
495
+ const DEPRECATE_EMBER_INFLECTOR = '5.3';
496
+
497
+ /**
498
+ * This is a special flag that can be used to opt-in early to receiving deprecations introduced in 6.x
499
+ * which have had their infra backported to 5.x versions of EmberData.
500
+ *
501
+ * When this flag is not present or set to `true`, the deprecations from the 6.x branch
502
+ * will not print their messages and the deprecation cannot be resolved.
503
+ *
504
+ * When this flag is present and set to `false`, the deprecations from the 6.x branch will
505
+ * print and can be resolved.
506
+ *
507
+ * @property DISABLE_7X_DEPRECATIONS
508
+ * @since 5.3
509
+ * @until 7.0
510
+ * @public
511
+ */
512
+ const DISABLE_7X_DEPRECATIONS = '7.0';
513
+
514
+ const CURRENT_DEPRECATIONS = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
515
+ __proto__: null,
516
+ DEPRECATE_CATCH_ALL,
517
+ DEPRECATE_COMPUTED_CHAINS,
518
+ DEPRECATE_EMBER_INFLECTOR,
519
+ DEPRECATE_LEGACY_IMPORTS,
520
+ DEPRECATE_MANY_ARRAY_DUPLICATES,
521
+ DEPRECATE_NON_STRICT_ID,
522
+ DEPRECATE_NON_STRICT_TYPES,
523
+ DEPRECATE_NON_UNIQUE_PAYLOADS,
524
+ DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE,
525
+ DEPRECATE_STORE_EXTENDS_EMBER_OBJECT,
526
+ DISABLE_7X_DEPRECATIONS,
527
+ ENABLE_LEGACY_SCHEMA_SERVICE
528
+ }, Symbol.toStringTag, { value: 'Module' }));
529
+
530
+ function deprecationIsResolved(deprecatedSince, compatVersion) {
531
+ return semver.lte(semver.minVersion(deprecatedSince), semver.minVersion(compatVersion));
532
+ }
533
+ const NextMajorVersion = '6.';
534
+ function deprecationIsNextMajorCycle(deprecatedSince) {
535
+ return deprecatedSince.startsWith(NextMajorVersion);
536
+ }
537
+ function getDeprecations(compatVersion, deprecations) {
538
+ const flags = {};
539
+ const keys = Object.keys(CURRENT_DEPRECATIONS);
540
+ const DISABLE_7X_DEPRECATIONS = deprecations?.DISABLE_7X_DEPRECATIONS ?? true;
541
+ keys.forEach(flag => {
542
+ const deprecatedSince = CURRENT_DEPRECATIONS[flag];
543
+ const isDeactivatedDeprecationNotice = DISABLE_7X_DEPRECATIONS && deprecationIsNextMajorCycle(deprecatedSince);
544
+ let flagState = true; // default to no code-stripping
545
+
546
+ if (!isDeactivatedDeprecationNotice) {
547
+ // if we have a specific flag setting, use it
548
+ if (typeof deprecations?.[flag] === 'boolean') {
549
+ flagState = deprecations?.[flag];
550
+ } else if (compatVersion) {
551
+ // if we are told we are compatible with a version
552
+ // we check if we can strip this flag
553
+ const isResolved = deprecationIsResolved(deprecatedSince, compatVersion);
554
+ // if we've resolved, we strip (by setting the flag to false)
555
+ /*
556
+ if (DEPRECATED_FEATURE) {
557
+ // deprecated code path
558
+ } else {
559
+ // if needed a non-deprecated code path
560
+ }
561
+ */
562
+ flagState = !isResolved;
563
+ }
564
+ }
565
+
566
+ // console.log(`${flag}=${flagState} (${deprecatedSince} <= ${compatVersion})`);
567
+ flags[flag] = flagState;
568
+ });
569
+ return flags;
570
+ }
571
+
572
+ /**
573
+ * ## Canary Features
574
+ *
575
+ * EmberData allows users to test features that are implemented but not yet
576
+ * available even in canary.
577
+ *
578
+ * Typically these features represent work that might introduce a new concept,
579
+ * new API, change an API, or risk an unintended change in behavior to consuming
580
+ * applications.
581
+ *
582
+ * Such features have their implementations guarded by a "feature flag", and the
583
+ * flag is only activated once the core-data team is prepared to ship the work
584
+ * in a canary release.
585
+ *
586
+ * ### Installing Canary
587
+ *
588
+ * To test a feature you MUST be using a canary build. Canary builds are published
589
+ * to `npm` and can be installed using a precise tag (such as `ember-data@3.16.0-alpha.1`)
590
+ * or by installing the latest dist-tag published to the `canary` channel using your javascript
591
+ * package manager of choice. For instance with [pnpm](https://pnpm.io/)
592
+
593
+ ```cli
594
+ pnpm add ember-data@canary
595
+ ```
596
+ *
597
+ * ### Activating a Canary Feature
598
+ *
599
+ * Once you have installed canary, feature-flags can be activated at build-time
600
+ *
601
+ * by setting an environment variable:
602
+ *
603
+ * ```cli
604
+ * # Activate a single flag
605
+ * EMBER_DATA_FEATURE_OVERRIDE=SOME_FLAG ember build
606
+ *
607
+ * # Activate multiple flags by separating with commas
608
+ * EMBER_DATA_FEATURE_OVERRIDE=SOME_FLAG,OTHER_FLAG ember build
609
+ *
610
+ * # Activate all flags
611
+ * EMBER_DATA_FEATURE_OVERRIDE=ENABLE_ALL_OPTIONAL ember build
612
+ * ```
613
+ *
614
+ * or by setting the appropriate flag in your `ember-cli-build` file:
615
+ *
616
+ * ```ts
617
+ * let app = new EmberApp(defaults, {
618
+ * emberData: {
619
+ * features: {
620
+ * SAMPLE_FEATURE_FLAG: false // utliize existing behavior, strip code for the new feature
621
+ * OTHER_FEATURE_FLAG: true // utilize this new feature, strip code for the older behavior
622
+ * }
623
+ * }
624
+ * })
625
+ * ```
626
+ *
627
+ * **The "off" branch of feature-flagged code is always stripped from production builds.**
628
+ *
629
+ * The list of available feature-flags is located [here](https://github.com/emberjs/data/tree/main/packages/build-config/src/virtual/canary-features.ts "List of EmberData FeatureFlags")
630
+ *
631
+ *
632
+ * ### Preparing a Project to use a Canary Feature
633
+ *
634
+ * For most projects, simple version detection should be enough.
635
+ * Using the provided version compatibility helpers from [embroider-macros](https://github.com/embroider-build/embroider/tree/main/packages/macros#readme)
636
+ * the following can be done:
637
+ *
638
+ * ```js
639
+ * if (macroCondition(dependencySatisfies('@ember-data/store', '5.0'))) {
640
+ * // do thing
641
+ * }
642
+ * ```
643
+ *
644
+ @module @warp-drive/build-config/canary-features
645
+ @main @warp-drive/build-config/canary-features
646
+ */
647
+ /**
648
+ This is the current list of features used at build time for canary releases.
649
+ If empty there are no features currently gated by feature flags.
650
+
651
+ The valid values are:
652
+
653
+ - `true` | The feature is **enabled** at all times, and cannot be disabled.
654
+ - `false` | The feature is **disabled** at all times, and cannot be enabled.
655
+ - `null` | The feature is **disabled by default**, but can be enabled via configuration.
656
+
657
+ @class CanaryFeatureFlags
658
+ @public
659
+ */
660
+ const SAMPLE_FEATURE_FLAG = null;
661
+
662
+ const CURRENT_FEATURES = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
663
+ __proto__: null,
664
+ SAMPLE_FEATURE_FLAG
665
+ }, Symbol.toStringTag, { value: 'Module' }));
666
+
667
+ const dirname = typeof __dirname !== 'undefined' ? __dirname : url.fileURLToPath(new URL(".", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cjs-set-config.cjs', document.baseURI).href))));
668
+ const relativePkgPath = path.join(dirname, '../package.json');
669
+ const version = JSON.parse(fs.readFileSync(relativePkgPath, 'utf-8')).version;
670
+ const isCanary = version.includes('alpha');
671
+ function getFeatures(isProd) {
672
+ const features = Object.assign({}, CURRENT_FEATURES);
673
+ const keys = Object.keys(features);
674
+ if (!isCanary) {
675
+ // disable all features with a current value of `null`
676
+ for (const feature of keys) {
677
+ let featureValue = features[feature];
678
+ if (featureValue === null) {
679
+ features[feature] = false;
680
+ }
681
+ }
682
+ return features;
683
+ }
684
+ const FEATURE_OVERRIDES = process.env.EMBER_DATA_FEATURE_OVERRIDE;
685
+ if (FEATURE_OVERRIDES === 'ENABLE_ALL_OPTIONAL') {
686
+ // enable all features with a current value of `null`
687
+ for (const feature of keys) {
688
+ let featureValue = features[feature];
689
+ if (featureValue === null) {
690
+ features[feature] = true;
691
+ }
692
+ }
693
+ } else if (FEATURE_OVERRIDES === 'DISABLE_ALL') {
694
+ // disable all features, including those with a value of `true`
695
+ for (const feature of keys) {
696
+ features[feature] = false;
697
+ }
698
+ } else if (FEATURE_OVERRIDES) {
699
+ // enable only the specific features listed in the environment
700
+ // variable (comma separated)
701
+ const forcedFeatures = FEATURE_OVERRIDES.split(',');
702
+ for (let i = 0; i < forcedFeatures.length; i++) {
703
+ let featureName = forcedFeatures[i];
704
+ if (!keys.includes(featureName)) {
705
+ throw new Error(`Unknown feature flag: ${featureName}`);
706
+ }
707
+ features[featureName] = true;
708
+ }
709
+ }
710
+ if (isProd) {
711
+ // disable all features with a current value of `null`
712
+ for (const feature of keys) {
713
+ let featureValue = features[feature];
714
+ if (featureValue === null) {
715
+ features[feature] = false;
716
+ }
717
+ }
718
+ }
719
+ return features;
720
+ }
721
+
722
+ /**
723
+ * ## Debugging
724
+ *
725
+ * Many portions of the internals are helpfully instrumented with logging that can be activated
726
+ * at build time. This instrumentation is always removed from production builds or any builds
727
+ * that has not explicitly activated it. To activate it set the appropriate flag to `true`.
728
+ *
729
+ @module @warp-drive/build-config/debugging
730
+ @main @warp-drive/build-config/debugging
731
+ */
732
+ /**
733
+ *
734
+ * Many portions of the internals are helpfully instrumented with logging that can be activated
735
+ at build time. This instrumentation is always removed from production builds or any builds
736
+ that has not explicitly activated it. To activate it set the appropriate flag to `true`.
737
+
738
+ ```ts
739
+ let app = new EmberApp(defaults, {
740
+ emberData: {
741
+ debug: {
742
+ LOG_PAYLOADS: false, // data store received to update cache with
743
+ LOG_OPERATIONS: false, // updates to cache remote state
744
+ LOG_MUTATIONS: false, // updates to cache local state
745
+ LOG_NOTIFICATIONS: false,
746
+ LOG_REQUESTS: false,
747
+ LOG_REQUEST_STATUS: false,
748
+ LOG_IDENTIFIERS: false,
749
+ LOG_GRAPH: false,
750
+ LOG_INSTANCE_CACHE: false,
751
+ }
752
+ }
753
+ });
754
+ ```
755
+
756
+ @class DebugLogging
757
+ @public
758
+ */
759
+ /**
760
+ * log payloads received by the store
761
+ * via `push` or returned from a delete/update/create
762
+ * operation.
763
+ *
764
+ * @property {boolean} LOG_PAYLOADS
765
+ * @public
766
+ */
767
+ const LOG_PAYLOADS = false;
768
+ /**
769
+ * log remote-state updates to the cache
770
+ *
771
+ * @property {boolean} LOG_OPERATIONS
772
+ * @public
773
+ */
774
+ const LOG_OPERATIONS = false;
775
+ /**
776
+ * log local-state updates to the cache
777
+ *
778
+ * @property {boolean} LOG_MUTATIONS
779
+ * @public
780
+ */
781
+ const LOG_MUTATIONS = false;
782
+ /**
783
+ * log notifications received by the NotificationManager
784
+ *
785
+ * @property {boolean} LOG_NOTIFICATIONS
786
+ * @public
787
+ */
788
+ const LOG_NOTIFICATIONS = false;
789
+ /**
790
+ * log requests issued by the RequestManager
791
+ *
792
+ * @property {boolean} LOG_REQUESTS
793
+ * @public
794
+ */
795
+ const LOG_REQUESTS = false;
796
+ /**
797
+ * log updates to requests the store has issued to
798
+ * the network (adapter) to fulfill.
799
+ *
800
+ * @property {boolean} LOG_REQUEST_STATUS
801
+ * @public
802
+ */
803
+ const LOG_REQUEST_STATUS = false;
804
+ /**
805
+ * log peek, generation and updates to
806
+ * Record Identifiers.
807
+ *
808
+ * @property {boolean} LOG_IDENTIFIERS
809
+ * @public
810
+ */
811
+ const LOG_IDENTIFIERS = false;
812
+ /**
813
+ * log updates received by the graph (relationship pointer storage)
814
+ *
815
+ * @property {boolean} LOG_GRAPH
816
+ * @public
817
+ */
818
+ const LOG_GRAPH = false;
819
+ /**
820
+ * log creation/removal of RecordData and Record
821
+ * instances.
822
+ *
823
+ * @property {boolean} LOG_INSTANCE_CACHE
824
+ * @public
825
+ */
826
+ const LOG_INSTANCE_CACHE = false;
827
+
828
+ const LOGGING = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
829
+ __proto__: null,
830
+ LOG_GRAPH,
831
+ LOG_IDENTIFIERS,
832
+ LOG_INSTANCE_CACHE,
833
+ LOG_MUTATIONS,
834
+ LOG_NOTIFICATIONS,
835
+ LOG_OPERATIONS,
836
+ LOG_PAYLOADS,
837
+ LOG_REQUESTS,
838
+ LOG_REQUEST_STATUS
839
+ }, Symbol.toStringTag, { value: 'Module' }));
840
+
841
+ const _MacrosConfig = EmbroiderMacros.MacrosConfig;
842
+ function recastMacrosConfig(macros) {
843
+ if (!('globalConfig' in macros)) {
844
+ throw new Error('Expected MacrosConfig to have a globalConfig property');
845
+ }
846
+ return macros;
847
+ }
848
+ function setConfig(context, appRoot, config) {
849
+ const macros = recastMacrosConfig(_MacrosConfig.for(context, appRoot));
850
+ const isLegacySupport = config.___legacy_support;
851
+ const hasDeprecatedConfig = isLegacySupport && Object.keys(config).length > 1;
852
+ const hasInitiatedConfig = macros.globalConfig['WarpDrive'];
853
+
854
+ // setConfig called by user prior to legacy support called
855
+ if (isLegacySupport && hasInitiatedConfig) {
856
+ if (hasDeprecatedConfig) {
857
+ throw new Error('You have provided a config object to setConfig, but are also using the legacy emberData options key in ember-cli-build. Please remove the emberData key from options.');
858
+ }
859
+ return;
860
+ }
861
+
862
+ // legacy support called prior to user setConfig
863
+ if (isLegacySupport && hasDeprecatedConfig) {
864
+ console.warn(`You are using the legacy emberData key in your ember-cli-build.js file. This key is deprecated and will be removed in the next major version of EmberData/WarpDrive. Please use \`import { setConfig } from '@warp-drive/build-config';\` instead.`);
865
+ }
866
+
867
+ // included hooks run during class initialization of the EmberApp instance
868
+ // so our hook will run before the user has a chance to call setConfig
869
+ // else we could print a useful message here
870
+ // else if (isLegacySupport) {
871
+ // console.warn(
872
+ // `WarpDrive requires your ember-cli-build file to set a base configuration for the project.\n\nUsage:\n\t\`import { setConfig } from '@warp-drive/build-config';\n\tsetConfig(app, __dirname, {});\``
873
+ // );
874
+ // }
875
+
876
+ const debugOptions = Object.assign({}, LOGGING, config.debug);
877
+ const env = getEnv();
878
+ const DEPRECATIONS = getDeprecations(config.compatWith || null, config.deprecations);
879
+ const FEATURES = getFeatures(env.PRODUCTION);
880
+ const includeDataAdapterInProduction = typeof config.includeDataAdapterInProduction === 'boolean' ? config.includeDataAdapterInProduction : true;
881
+ const includeDataAdapter = env.PRODUCTION ? includeDataAdapterInProduction : true;
882
+ const finalizedConfig = {
883
+ debug: debugOptions,
884
+ polyfillUUID: config.polyfillUUID ?? false,
885
+ includeDataAdapter,
886
+ compatWith: config.compatWith ?? null,
887
+ deprecations: DEPRECATIONS,
888
+ features: FEATURES,
889
+ env
890
+ };
891
+ macros.setGlobalConfig(undefined, 'WarpDrive', finalizedConfig);
892
+ }
893
+
894
+ exports.setConfig = setConfig;
895
+ //# sourceMappingURL=cjs-set-config.cjs.map