@strapi/core 0.0.0-experimental.e9144fc8a193f9875a2c0832d689c14001c79f00 → 0.0.0-experimental.eb2d102c03f0984bece7258f6e0e8ab9ee39c82d

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.
@@ -5,6 +5,7 @@ export declare const loadConfiguration: (opts: StrapiOptions) => {
5
5
  autoReload: boolean;
6
6
  environment: string | undefined;
7
7
  uuid: any;
8
+ installId: any;
8
9
  packageJsonStrapi: Pick<any, string | number | symbol>;
9
10
  info: any;
10
11
  admin: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAGA,OAAO,CAAC,MAAM,QAAQ,CAAC;AAUvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAqC/C,eAAO,MAAM,iBAAiB,SAAU,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wEAiDpD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAGA,OAAO,CAAC,MAAM,QAAQ,CAAC;AAUvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAqC/C,eAAO,MAAM,iBAAiB,SAAU,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wEAkDpD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"license.d.ts","sourceRoot":"","sources":["../../src/ee/license.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAI1C,UAAU,WAAW;IACnB,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAA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E,OAC9B,MAAM,aACA,MAAM,iBAkClB,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -312,7 +312,7 @@ const getDirs = ({ appDir, distDir }, config)=>({
312
312
  });
313
313
 
314
314
  var name = "@strapi/core";
315
- var version = "0.0.0-experimental.e9144fc8a193f9875a2c0832d689c14001c79f00";
315
+ var version = "0.0.0-experimental.eb2d102c03f0984bece7258f6e0e8ab9ee39c82d";
316
316
  var description = "Core of Strapi";
317
317
  var homepage = "https://strapi.io";
318
318
  var bugs = {
@@ -368,14 +368,14 @@ var dependencies = {
368
368
  "@koa/cors": "5.0.0",
369
369
  "@koa/router": "12.0.2",
370
370
  "@paralleldrive/cuid2": "2.2.2",
371
- "@strapi/admin": "0.0.0-experimental.e9144fc8a193f9875a2c0832d689c14001c79f00",
372
- "@strapi/database": "0.0.0-experimental.e9144fc8a193f9875a2c0832d689c14001c79f00",
373
- "@strapi/generators": "0.0.0-experimental.e9144fc8a193f9875a2c0832d689c14001c79f00",
374
- "@strapi/logger": "0.0.0-experimental.e9144fc8a193f9875a2c0832d689c14001c79f00",
375
- "@strapi/permissions": "0.0.0-experimental.e9144fc8a193f9875a2c0832d689c14001c79f00",
376
- "@strapi/types": "0.0.0-experimental.e9144fc8a193f9875a2c0832d689c14001c79f00",
377
- "@strapi/typescript-utils": "0.0.0-experimental.e9144fc8a193f9875a2c0832d689c14001c79f00",
378
- "@strapi/utils": "0.0.0-experimental.e9144fc8a193f9875a2c0832d689c14001c79f00",
371
+ "@strapi/admin": "0.0.0-experimental.eb2d102c03f0984bece7258f6e0e8ab9ee39c82d",
372
+ "@strapi/database": "0.0.0-experimental.eb2d102c03f0984bece7258f6e0e8ab9ee39c82d",
373
+ "@strapi/generators": "0.0.0-experimental.eb2d102c03f0984bece7258f6e0e8ab9ee39c82d",
374
+ "@strapi/logger": "0.0.0-experimental.eb2d102c03f0984bece7258f6e0e8ab9ee39c82d",
375
+ "@strapi/permissions": "0.0.0-experimental.eb2d102c03f0984bece7258f6e0e8ab9ee39c82d",
376
+ "@strapi/types": "0.0.0-experimental.eb2d102c03f0984bece7258f6e0e8ab9ee39c82d",
377
+ "@strapi/typescript-utils": "0.0.0-experimental.eb2d102c03f0984bece7258f6e0e8ab9ee39c82d",
378
+ "@strapi/utils": "0.0.0-experimental.eb2d102c03f0984bece7258f6e0e8ab9ee39c82d",
379
379
  bcryptjs: "2.4.3",
380
380
  boxen: "5.1.2",
381
381
  chalk: "4.1.2",
@@ -394,7 +394,7 @@ var dependencies = {
394
394
  "http-errors": "2.0.0",
395
395
  inquirer: "8.2.5",
396
396
  "is-docker": "2.2.1",
397
- koa: "2.15.2",
397
+ koa: "2.15.4",
398
398
  "koa-body": "6.0.1",
399
399
  "koa-compose": "4.1.0",
400
400
  "koa-compress": "5.1.1",
@@ -415,7 +415,7 @@ var dependencies = {
415
415
  semver: "7.5.4",
416
416
  statuses: "2.0.1",
417
417
  typescript: "5.4.4",
418
- undici: "6.19.2",
418
+ undici: "6.21.1",
419
419
  yup: "0.32.9"
420
420
  };
421
421
  var devDependencies = {
@@ -438,9 +438,9 @@ var devDependencies = {
438
438
  "@types/node": "18.19.24",
439
439
  "@types/node-schedule": "2.1.7",
440
440
  "@types/statuses": "2.0.1",
441
- "eslint-config-custom": "0.0.0-experimental.e9144fc8a193f9875a2c0832d689c14001c79f00",
441
+ "eslint-config-custom": "0.0.0-experimental.eb2d102c03f0984bece7258f6e0e8ab9ee39c82d",
442
442
  supertest: "6.3.3",
443
- tsconfig: "0.0.0-experimental.e9144fc8a193f9875a2c0832d689c14001c79f00"
443
+ tsconfig: "0.0.0-experimental.eb2d102c03f0984bece7258f6e0e8ab9ee39c82d"
444
444
  };
445
445
  var engines = {
446
446
  node: ">=18.0.0 <=22.x.x",
@@ -516,6 +516,7 @@ const loadConfiguration = (opts)=>{
516
516
  autoReload,
517
517
  environment: process.env.NODE_ENV,
518
518
  uuid: _.get(pkgJSON, 'strapi.uuid'),
519
+ installId: _.get(pkgJSON, 'strapi.installId'),
519
520
  packageJsonStrapi: _.omit(_.get(pkgJSON, 'strapi', {}), 'uuid'),
520
521
  info: {
521
522
  ...pkgJSON,
@@ -1246,6 +1247,7 @@ const throwError = ()=>{
1246
1247
  throw new LicenseCheckError('Could not proceed to the online validation of your license.', true);
1247
1248
  };
1248
1249
  const fetchLicense = async ({ strapi }, key, projectId)=>{
1250
+ const { installId: installIdFromPackageJson } = strapi.config;
1249
1251
  const response = await strapi.fetch(`https://license.strapi.io/api/licenses/validate`, {
1250
1252
  method: 'POST',
1251
1253
  headers: {
@@ -1254,7 +1256,7 @@ const fetchLicense = async ({ strapi }, key, projectId)=>{
1254
1256
  body: JSON.stringify({
1255
1257
  key,
1256
1258
  projectId,
1257
- deviceId: strapiUtils.machineID()
1259
+ installId: strapiUtils.installID(projectId, installIdFromPackageJson)
1258
1260
  })
1259
1261
  }).catch(throwError);
1260
1262
  const contentType = response.headers.get('Content-Type');
@@ -6770,7 +6772,7 @@ const EVENTS = {
6770
6772
  * Loads lingering relations that need to be updated when overriding a published or draft entry.
6771
6773
  * This is necessary because the relations are uni-directional and the target entry is not aware of the source entry.
6772
6774
  * This is not the case for bi-directional relations, where the target entry is also linked to the source entry.
6773
- */ const load = async (uid, { oldVersions, newVersions })=>{
6775
+ */ const load$1 = async (uid, { oldVersions, newVersions })=>{
6774
6776
  const updates = [];
6775
6777
  // Iterate all components and content types to find relations that need to be updated
6776
6778
  await strapi.db.transaction(async ({ trx })=>{
@@ -6845,7 +6847,7 @@ const EVENTS = {
6845
6847
  * @param oldEntries The old entries that are being overridden
6846
6848
  * @param newEntries The new entries that are overriding the old ones
6847
6849
  * @param oldRelations The relations that were previously loaded with `load` @see load
6848
- */ const sync = async (oldEntries, newEntries, oldRelations)=>{
6850
+ */ const sync$1 = async (oldEntries, newEntries, oldRelations)=>{
6849
6851
  /**
6850
6852
  * Create a map of old entry ids to new entry ids
6851
6853
  *
@@ -6875,6 +6877,137 @@ const EVENTS = {
6875
6877
  });
6876
6878
  };
6877
6879
 
6880
+ /**
6881
+ * Loads all bidirectional relations that need to be synchronized when content entries change state
6882
+ * (e.g., during publish/unpublish operations).
6883
+ *
6884
+ * In Strapi, bidirectional relations allow maintaining order from both sides of the relation.
6885
+ * When an entry is published, the following occurs:
6886
+ *
6887
+ * 1. The old published entry is deleted
6888
+ * 2. A new entry is created with all its relations
6889
+ *
6890
+ * This process affects relation ordering in the following way:
6891
+ *
6892
+ * Initial state (Entry A related to X, Y, Z):
6893
+ * ```
6894
+ * Entry A (draft) Entry A (published)
6895
+ * │ │
6896
+ * ├──(1)→ X ├──(1)→ X
6897
+ * ├──(2)→ Y ├──(2)→ Y
6898
+ * └──(3)→ Z └──(3)→ Z
6899
+ *
6900
+ * X's perspective: Y's perspective: Z's perspective:
6901
+ * └──(2)→ Entry A └──(1)→ Entry A └──(3)→ Entry A
6902
+ * ```
6903
+ *
6904
+ * After publishing Entry A (without relation order sync):
6905
+ * ```
6906
+ * Entry A (draft) Entry A (new published)
6907
+ * │ │
6908
+ * ├──(1)→ X ├──(1)→ X
6909
+ * ├──(2)→ Y ├──(2)→ Y
6910
+ * └──(3)→ Z └──(3)→ Z
6911
+ *
6912
+ * X's perspective: Y's perspective: Z's perspective:
6913
+ * └──(3)→ Entry A └──(3)→ Entry A └──(3)→ Entry A
6914
+ * (all relations appear last in order)
6915
+ * ```
6916
+ *
6917
+ * This module preserves the original ordering from both perspectives by:
6918
+ * 1. Capturing the relation order before the entry state changes
6919
+ * 2. Restoring this order after the new relations are created
6920
+ *
6921
+ * @param uid - The unique identifier of the content type being processed
6922
+ * @param context - Object containing arrays of old and new entry versions
6923
+ * @returns Array of objects containing join table metadata and relations to be updated
6924
+ */ const load = async (uid, { oldVersions })=>{
6925
+ const relationsToUpdate = [];
6926
+ await strapi.db.transaction(async ({ trx })=>{
6927
+ const contentTypes = Object.values(strapi.contentTypes);
6928
+ const components = Object.values(strapi.components);
6929
+ for (const model of [
6930
+ ...contentTypes,
6931
+ ...components
6932
+ ]){
6933
+ const dbModel = strapi.db.metadata.get(model.uid);
6934
+ for (const attribute of Object.values(dbModel.attributes)){
6935
+ // Skip if not a bidirectional relation targeting our content type
6936
+ if (attribute.type !== 'relation' || attribute.target !== uid || !(attribute.inversedBy || attribute.mappedBy)) {
6937
+ continue;
6938
+ }
6939
+ const joinTable = attribute.joinTable;
6940
+ if (!joinTable) {
6941
+ continue;
6942
+ }
6943
+ const { name: targetColumnName } = joinTable.inverseJoinColumn;
6944
+ // Load all relations that need their order preserved
6945
+ const oldEntryIds = oldVersions.map((entry)=>entry.id);
6946
+ const existingRelations = await strapi.db.getConnection().select('*').from(joinTable.name).whereIn(targetColumnName, oldEntryIds).transacting(trx);
6947
+ if (existingRelations.length > 0) {
6948
+ relationsToUpdate.push({
6949
+ joinTable,
6950
+ relations: existingRelations
6951
+ });
6952
+ }
6953
+ }
6954
+ }
6955
+ });
6956
+ return relationsToUpdate;
6957
+ };
6958
+ /**
6959
+ * Synchronizes the order of bidirectional relations after content entries have changed state.
6960
+ *
6961
+ * When entries change state (e.g., draft → published), their IDs change and all relations are recreated.
6962
+ * While the order of relations from the entry's perspective is maintained (as they're created in order),
6963
+ * the inverse relations (from related entries' perspective) would all appear last in order since they're new.
6964
+ *
6965
+ * Example:
6966
+ * ```
6967
+ * Before publish:
6968
+ * Article(id:1) →(order:1)→ Category(id:5)
6969
+ * Category(id:5) →(order:3)→ Article(id:1)
6970
+ *
6971
+ * After publish (without sync):
6972
+ * Article(id:2) →(order:1)→ Category(id:5) [order preserved]
6973
+ * Category(id:5) →(order:99)→ Article(id:2) [order lost - appears last]
6974
+ *
6975
+ * After sync:
6976
+ * Article(id:2) →(order:1)→ Category(id:5) [order preserved]
6977
+ * Category(id:5) →(order:3)→ Article(id:2) [order restored]
6978
+ * ```
6979
+ *
6980
+ * @param oldEntries - Array of previous entry versions with their IDs and locales
6981
+ * @param newEntries - Array of new entry versions with their IDs and locales
6982
+ * @param existingRelations - Array of join table data containing the relations to be updated
6983
+ */ const sync = async (oldEntries, newEntries, existingRelations)=>{
6984
+ // Group new entries by locale for easier lookup
6985
+ const newEntriesByLocale = fp.keyBy('locale', newEntries);
6986
+ // Create a mapping of old entry IDs to new entry IDs based on locale
6987
+ const entryIdMapping = oldEntries.reduce((acc, oldEntry)=>{
6988
+ const newEntry = newEntriesByLocale[oldEntry.locale];
6989
+ if (!newEntry) return acc;
6990
+ acc[oldEntry.id] = newEntry.id;
6991
+ return acc;
6992
+ }, {});
6993
+ await strapi.db.transaction(async ({ trx })=>{
6994
+ for (const { joinTable, relations } of existingRelations){
6995
+ const sourceColumn = joinTable.inverseJoinColumn.name;
6996
+ const targetColumn = joinTable.joinColumn.name;
6997
+ const orderColumn = joinTable.orderColumnName;
6998
+ // Update order values for each relation
6999
+ // TODO: Find a way to batch it more efficiently
7000
+ await strapiUtils.async.map(relations, (relation)=>{
7001
+ const { [sourceColumn]: oldSourceId, [targetColumn]: targetId, [orderColumn]: originalOrder } = relation;
7002
+ // Update the order column for the new relation entry
7003
+ return trx.from(joinTable.name).where(sourceColumn, entryIdMapping[oldSourceId]).where(targetColumn, targetId).update({
7004
+ [orderColumn]: originalOrder
7005
+ });
7006
+ });
7007
+ }
7008
+ });
7009
+ };
7010
+
6878
7011
  const textNodeValidator = strapiUtils.yup.object().shape({
6879
7012
  type: strapiUtils.yup.string().equals([
6880
7013
  'text'
@@ -7903,7 +8036,11 @@ const createContentTypeRepository = (uid, validator = entityValidator)=>{
7903
8036
  })
7904
8037
  ]);
7905
8038
  // Load any unidirectional relation targetting the old published entries
7906
- const relationsToSync = await load(uid, {
8039
+ const relationsToSync = await load$1(uid, {
8040
+ newVersions: draftsToPublish,
8041
+ oldVersions: oldPublishedVersions
8042
+ });
8043
+ const bidirectionalRelationsToSync = await load(uid, {
7907
8044
  newVersions: draftsToPublish,
7908
8045
  oldVersions: oldPublishedVersions
7909
8046
  });
@@ -7912,10 +8049,14 @@ const createContentTypeRepository = (uid, validator = entityValidator)=>{
7912
8049
  // Transform draft entry data and create published versions
7913
8050
  const publishedEntries = await strapiUtils.async.map(draftsToPublish, (draft)=>entries.publish(draft, queryParams));
7914
8051
  // Sync unidirectional relations with the new published entries
7915
- await sync([
8052
+ await sync$1([
7916
8053
  ...oldPublishedVersions,
7917
8054
  ...draftsToPublish
7918
8055
  ], publishedEntries, relationsToSync);
8056
+ await sync([
8057
+ ...oldPublishedVersions,
8058
+ ...draftsToPublish
8059
+ ], publishedEntries, bidirectionalRelationsToSync);
7919
8060
  publishedEntries.forEach(emitEvent('entry.publish'));
7920
8061
  return {
7921
8062
  documentId,
@@ -7973,7 +8114,11 @@ const createContentTypeRepository = (uid, validator = entityValidator)=>{
7973
8114
  })
7974
8115
  ]);
7975
8116
  // Load any unidirectional relation targeting the old drafts
7976
- const relationsToSync = await load(uid, {
8117
+ const relationsToSync = await load$1(uid, {
8118
+ newVersions: versionsToDraft,
8119
+ oldVersions: oldDrafts
8120
+ });
8121
+ const bidirectionalRelationsToSync = await load(uid, {
7977
8122
  newVersions: versionsToDraft,
7978
8123
  oldVersions: oldDrafts
7979
8124
  });
@@ -7982,10 +8127,14 @@ const createContentTypeRepository = (uid, validator = entityValidator)=>{
7982
8127
  // Transform published entry data and create draft versions
7983
8128
  const draftEntries = await strapiUtils.async.map(versionsToDraft, (entry)=>entries.discardDraft(entry, queryParams));
7984
8129
  // Sync unidirectional relations with the new draft entries
7985
- await sync([
8130
+ await sync$1([
7986
8131
  ...oldDrafts,
7987
8132
  ...versionsToDraft
7988
8133
  ], draftEntries, relationsToSync);
8134
+ await sync([
8135
+ ...oldDrafts,
8136
+ ...versionsToDraft
8137
+ ], draftEntries, bidirectionalRelationsToSync);
7989
8138
  draftEntries.forEach(emitEvent('entry.draft-discard'));
7990
8139
  return {
7991
8140
  documentId,
@@ -8433,8 +8582,8 @@ const ANALYTICS_URI = 'https://analytics.strapi.io';
8433
8582
  /**
8434
8583
  * Create a send function for event with all the necessary metadata
8435
8584
  */ var createSender = ((strapi)=>{
8436
- const { uuid } = strapi.config;
8437
- const deviceId = strapiUtils.machineID();
8585
+ const { uuid, installId: installIdFromPackageJson } = strapi.config;
8586
+ const installId = strapiUtils.installID(uuid, installIdFromPackageJson);
8438
8587
  const serverRootPath = strapi.dirs.app.root;
8439
8588
  const adminRootPath = path.join(strapi.dirs.app.root, 'src', 'admin');
8440
8589
  const anonymousUserProperties = {
@@ -8457,12 +8606,14 @@ const ANALYTICS_URI = 'https://analytics.strapi.io';
8457
8606
  addPackageJsonStrapiMetadata(anonymousGroupProperties, strapi);
8458
8607
  return async (event, payload = {}, opts = {})=>{
8459
8608
  const userId = generateAdminUserHash(strapi);
8609
+ // TO REMOVE
8610
+ console.log(`[TELEMETRY INSTANCE] installId: ${installId}, userId: ${userId}`);
8460
8611
  const reqParams = {
8461
8612
  method: 'POST',
8462
8613
  body: JSON.stringify({
8463
8614
  event,
8464
8615
  userId,
8465
- deviceId,
8616
+ installId,
8466
8617
  eventProperties: payload.eventProperties,
8467
8618
  userProperties: userId ? {
8468
8619
  ...anonymousUserProperties,