@warp-drive-mirror/build-config 0.0.0-beta.1 → 0.0.0-beta.3

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