@strapi/core 0.0.0-next.281b331dc777a6a76694c122f7d1d9bc8c783747 → 0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa
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.
Potentially problematic release.
This version of @strapi/core might be problematic. Click here for more details.
- package/dist/Strapi.d.ts.map +1 -1
- package/dist/Strapi.js +4 -4
- package/dist/Strapi.js.map +1 -1
- package/dist/Strapi.mjs +4 -4
- package/dist/Strapi.mjs.map +1 -1
- package/dist/configuration/config-loader.js.map +1 -1
- package/dist/configuration/config-loader.mjs.map +1 -1
- package/dist/configuration/urls.js.map +1 -1
- package/dist/configuration/urls.mjs.map +1 -1
- package/dist/container.js.map +1 -1
- package/dist/container.mjs.map +1 -1
- package/dist/core-api/routes/index.js.map +1 -1
- package/dist/core-api/routes/index.mjs.map +1 -1
- package/dist/core-api/routes/validation/mappers.js.map +1 -1
- package/dist/core-api/routes/validation/mappers.mjs.map +1 -1
- package/dist/core-api/routes/validation/utils.js.map +1 -1
- package/dist/core-api/routes/validation/utils.mjs.map +1 -1
- package/dist/core-api/service/collection-type.js.map +1 -1
- package/dist/core-api/service/collection-type.mjs.map +1 -1
- package/dist/core-api/service/single-type.js.map +1 -1
- package/dist/core-api/service/single-type.mjs.map +1 -1
- package/dist/domain/content-type/index.js.map +1 -1
- package/dist/domain/content-type/index.mjs.map +1 -1
- package/dist/domain/module/index.js.map +1 -1
- package/dist/domain/module/index.mjs.map +1 -1
- package/dist/ee/index.js.map +1 -1
- package/dist/ee/index.mjs.map +1 -1
- package/dist/ee/license.js +1 -2
- package/dist/ee/license.js.map +1 -1
- package/dist/ee/license.mjs +1 -2
- package/dist/ee/license.mjs.map +1 -1
- package/dist/factories.js.map +1 -1
- package/dist/factories.mjs.map +1 -1
- package/dist/loaders/apis.js.map +1 -1
- package/dist/loaders/apis.mjs.map +1 -1
- package/dist/loaders/components.js.map +1 -1
- package/dist/loaders/components.mjs.map +1 -1
- package/dist/loaders/plugins/get-enabled-plugins.js.map +1 -1
- package/dist/loaders/plugins/get-enabled-plugins.mjs.map +1 -1
- package/dist/loaders/plugins/index.js.map +1 -1
- package/dist/loaders/plugins/index.mjs.map +1 -1
- package/dist/loaders/src-index.js.map +1 -1
- package/dist/loaders/src-index.mjs.map +1 -1
- package/dist/middlewares/logger.js.map +1 -1
- package/dist/middlewares/logger.mjs.map +1 -1
- package/dist/middlewares/response-time.js.map +1 -1
- package/dist/middlewares/response-time.mjs.map +1 -1
- package/dist/middlewares/security.d.ts.map +1 -1
- package/dist/middlewares/security.js +2 -15
- package/dist/middlewares/security.js.map +1 -1
- package/dist/middlewares/security.mjs +2 -15
- package/dist/middlewares/security.mjs.map +1 -1
- package/dist/migrations/database/5.0.0-discard-drafts.js +1 -1
- package/dist/migrations/database/5.0.0-discard-drafts.js.map +1 -1
- package/dist/migrations/database/5.0.0-discard-drafts.mjs +1 -1
- package/dist/migrations/database/5.0.0-discard-drafts.mjs.map +1 -1
- package/dist/migrations/first-published-at.js.map +1 -1
- package/dist/migrations/first-published-at.mjs.map +1 -1
- package/dist/package.json.js +14 -14
- package/dist/package.json.mjs +14 -14
- package/dist/providers/index.js +1 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/index.mjs +1 -1
- package/dist/providers/index.mjs.map +1 -1
- package/dist/providers/{sessionManager.d.ts → session-manager.d.ts} +1 -1
- package/dist/providers/session-manager.d.ts.map +1 -0
- package/dist/providers/{sessionManager.js → session-manager.js} +6 -4
- package/dist/providers/session-manager.js.map +1 -0
- package/dist/providers/{sessionManager.mjs → session-manager.mjs} +6 -4
- package/dist/providers/session-manager.mjs.map +1 -0
- package/dist/registries/apis.js.map +1 -1
- package/dist/registries/apis.mjs.map +1 -1
- package/dist/registries/custom-fields.js.map +1 -1
- package/dist/registries/custom-fields.mjs.map +1 -1
- package/dist/registries/namespace.js.map +1 -1
- package/dist/registries/namespace.mjs.map +1 -1
- package/dist/registries/plugins.js.map +1 -1
- package/dist/registries/plugins.mjs.map +1 -1
- package/dist/registries/policies.js.map +1 -1
- package/dist/registries/policies.mjs.map +1 -1
- package/dist/services/config.js.map +1 -1
- package/dist/services/config.mjs.map +1 -1
- package/dist/services/content-api/index.js.map +1 -1
- package/dist/services/content-api/index.mjs.map +1 -1
- package/dist/services/content-api/permissions/index.js.map +1 -1
- package/dist/services/content-api/permissions/index.mjs.map +1 -1
- package/dist/services/core-store.js.map +1 -1
- package/dist/services/core-store.mjs.map +1 -1
- package/dist/services/document-service/components.js.map +1 -1
- package/dist/services/document-service/components.mjs.map +1 -1
- package/dist/services/document-service/repository.js +1 -1
- package/dist/services/document-service/repository.js.map +1 -1
- package/dist/services/document-service/repository.mjs +1 -1
- package/dist/services/document-service/repository.mjs.map +1 -1
- package/dist/services/document-service/transform/fields.js.map +1 -1
- package/dist/services/document-service/transform/fields.mjs.map +1 -1
- package/dist/services/document-service/transform/id-map.js.map +1 -1
- package/dist/services/document-service/transform/id-map.mjs.map +1 -1
- package/dist/services/document-service/utils/clean-component-join-table.d.ts.map +1 -1
- package/dist/services/document-service/utils/clean-component-join-table.js +7 -0
- package/dist/services/document-service/utils/clean-component-join-table.js.map +1 -1
- package/dist/services/document-service/utils/clean-component-join-table.mjs +7 -0
- package/dist/services/document-service/utils/clean-component-join-table.mjs.map +1 -1
- package/dist/services/entity-service/index.js.map +1 -1
- package/dist/services/entity-service/index.mjs.map +1 -1
- package/dist/services/entity-validator/blocks-validator.js.map +1 -1
- package/dist/services/entity-validator/blocks-validator.mjs.map +1 -1
- package/dist/services/entity-validator/index.js.map +1 -1
- package/dist/services/entity-validator/index.mjs.map +1 -1
- package/dist/services/metrics/sender.d.ts.map +1 -1
- package/dist/services/metrics/sender.js +2 -1
- package/dist/services/metrics/sender.js.map +1 -1
- package/dist/services/metrics/sender.mjs +2 -1
- package/dist/services/metrics/sender.mjs.map +1 -1
- package/dist/services/server/compose-endpoint.js.map +1 -1
- package/dist/services/server/compose-endpoint.mjs.map +1 -1
- package/dist/services/server/index.js.map +1 -1
- package/dist/services/server/index.mjs.map +1 -1
- package/dist/services/server/middleware.js.map +1 -1
- package/dist/services/server/middleware.mjs.map +1 -1
- package/dist/services/server/register-routes.js.map +1 -1
- package/dist/services/server/register-routes.mjs.map +1 -1
- package/dist/services/server/routing.js.map +1 -1
- package/dist/services/server/routing.mjs.map +1 -1
- package/dist/services/session-manager.d.ts +8 -1
- package/dist/services/session-manager.d.ts.map +1 -1
- package/dist/services/session-manager.js +74 -21
- package/dist/services/session-manager.js.map +1 -1
- package/dist/services/session-manager.mjs +74 -21
- package/dist/services/session-manager.mjs.map +1 -1
- package/dist/services/webhook-runner.js.map +1 -1
- package/dist/services/webhook-runner.mjs.map +1 -1
- package/dist/services/worker-queue.js.map +1 -1
- package/dist/services/worker-queue.mjs.map +1 -1
- package/dist/utils/fetch.js.map +1 -1
- package/dist/utils/fetch.mjs.map +1 -1
- package/dist/utils/filepath-to-prop-path.js.map +1 -1
- package/dist/utils/filepath-to-prop-path.mjs.map +1 -1
- package/dist/utils/load-config-file.js.map +1 -1
- package/dist/utils/load-config-file.mjs.map +1 -1
- package/dist/utils/startup-logger.js.map +1 -1
- package/dist/utils/startup-logger.mjs.map +1 -1
- package/package.json +14 -14
- package/dist/providers/sessionManager.d.ts.map +0 -1
- package/dist/providers/sessionManager.js.map +0 -1
- package/dist/providers/sessionManager.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"5.0.0-discard-drafts.js","sources":["../../../src/migrations/database/5.0.0-discard-drafts.ts"],"sourcesContent":["/**\n * This migration is responsible for creating the draft counterpart for all the entries that were in a published state.\n *\n * In v4, entries could either be in a draft or published state, but not both at the same time.\n * In v5, we introduced the concept of document, and an entry can be in a draft or published state.\n *\n * This means the migration needs to create the draft counterpart if an entry was published.\n *\n * This migration performs the following steps:\n * 1. Creates draft entries for all published entries, without it's components, dynamic zones or relations.\n * 2. Using the document service, discard those same drafts to copy its relations.\n */\n\n/* eslint-disable no-continue */\nimport type { UID } from '@strapi/types';\nimport type { Database, Migration } from '@strapi/database';\nimport { async, contentTypes } from '@strapi/utils';\nimport { createDocumentService } from '../../services/document-service';\n\ntype DocumentVersion = { documentId: string; locale: string };\ntype Knex = Parameters<Migration['up']>[0];\n\n/**\n * Check if the model has draft and publish enabled.\n */\nconst hasDraftAndPublish = async (trx: Knex, meta: any) => {\n const hasTable = await trx.schema.hasTable(meta.tableName);\n\n if (!hasTable) {\n return false;\n }\n\n const uid = meta.uid as UID.ContentType;\n const model = strapi.getModel(uid);\n const hasDP = contentTypes.hasDraftAndPublish(model);\n if (!hasDP) {\n return false;\n }\n\n return true;\n};\n\n/**\n * Copy all the published entries to draft entries, without it's components, dynamic zones or relations.\n * This ensures all necessary draft's exist before copying it's relations.\n */\nasync function copyPublishedEntriesToDraft({\n db,\n trx,\n uid,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n}) {\n // Extract all scalar attributes to use in the insert query\n const meta = db.metadata.get(uid);\n\n // Get scalar attributes that will be copied over the new draft\n const scalarAttributes = Object.values(meta.attributes).reduce((acc, attribute: any) => {\n if (['id'].includes(attribute.columnName)) {\n return acc;\n }\n\n if (contentTypes.isScalarAttribute(attribute)) {\n acc.push(attribute.columnName);\n }\n\n return acc;\n }, [] as string[]);\n\n /**\n * Query to copy the published entries into draft entries.\n *\n * INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n * SELECT columnName1, columnName2, columnName3, ...\n * FROM tableName\n */\n await trx\n // INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n .into(\n trx.raw(`?? (${scalarAttributes.map(() => `??`).join(', ')})`, [\n meta.tableName,\n ...scalarAttributes,\n ])\n )\n .insert((subQb: typeof trx) => {\n // SELECT columnName1, columnName2, columnName3, ...\n subQb\n .select(\n ...scalarAttributes.map((att: string) => {\n // Override 'publishedAt' and 'updatedAt' attributes\n if (att === 'published_at') {\n return trx.raw('NULL as ??', 'published_at');\n }\n\n return att;\n })\n )\n .from(meta.tableName)\n // Only select entries that were published\n .whereNotNull('published_at');\n });\n}\n\n/**\n * Load a batch of versions to discard.\n *\n * Versions with only a draft version will be ignored.\n * Only versions with a published version (which always have a draft version) will be discarded.\n */\nexport async function* getBatchToDiscard({\n db,\n trx,\n uid,\n defaultBatchSize = 1000,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n defaultBatchSize?: number;\n}) {\n const client = db.config.connection.client;\n const isSQLite =\n typeof client === 'string' && ['sqlite', 'sqlite3', 'better-sqlite3'].includes(client);\n\n // The SQLite documentation states that the maximum number of terms in a\n // compound SELECT statement is 500 by default.\n // See: https://www.sqlite.org/limits.html\n // To ensure a successful migration, we limit the batch size to 500 for SQLite.\n const batchSize = isSQLite ? Math.min(defaultBatchSize, 500) : defaultBatchSize;\n let offset = 0;\n let hasMore = true;\n\n while (hasMore) {\n // Look for the published entries to discard\n const batch: DocumentVersion[] = await db\n .queryBuilder(uid)\n .select(['id', 'documentId', 'locale'])\n .where({ publishedAt: { $ne: null } })\n .limit(batchSize)\n .offset(offset)\n .orderBy('id')\n .transacting(trx)\n .execute();\n\n if (batch.length < batchSize) {\n hasMore = false;\n }\n\n offset += batchSize;\n yield batch;\n }\n}\n\n/**\n * 2 pass migration to create the draft entries for all the published entries.\n * And then discard the drafts to copy the relations.\n */\nconst migrateUp = async (trx: Knex, db: Database) => {\n const dpModels = [];\n for (const meta of db.metadata.values()) {\n const hasDP = await hasDraftAndPublish(trx, meta);\n if (hasDP) {\n dpModels.push(meta);\n }\n }\n\n /**\n * Create plain draft entries for all the entries that were published.\n */\n for (const model of dpModels) {\n await copyPublishedEntriesToDraft({ db, trx, uid: model.uid });\n }\n\n /**\n * Discard the drafts will copy the relations from the published entries to the newly created drafts.\n *\n * Load a batch of entries (batched to prevent loading millions of rows at once ),\n * and discard them using the document service.\n *\n * NOTE: This is using a custom document service without any validations,\n * to prevent the migration from failing if users already had invalid data in V4.\n * E.g. @see https://github.com/strapi/strapi/issues/21583\n */\n const documentService = createDocumentService(strapi, {\n async validateEntityCreation(_, data) {\n return data;\n },\n async validateEntityUpdate(_, data) {\n // Data can be partially empty on partial updates\n // This migration doesn't trigger any update (or partial update),\n // so it's safe to return the data as is.\n return data as any;\n },\n });\n\n for (const model of dpModels) {\n const discardDraft = async (entry: DocumentVersion) =>\n documentService(model.uid as UID.ContentType).discardDraft({\n documentId: entry.documentId,\n locale: entry.locale,\n });\n\n for await (const batch of getBatchToDiscard({ db, trx, uid: model.uid })) {\n // NOTE: concurrency had to be disabled to prevent a race condition with self-references\n // TODO: improve performance in a safe way\n await async.map(batch, discardDraft, { concurrency: 1 });\n }\n }\n};\n\nexport const discardDocumentDrafts: Migration = {\n name: 'core::5.0.0-discard-drafts',\n async up(trx, db) {\n await migrateUp(trx, db);\n },\n async down() {\n throw new Error('not implemented');\n },\n};\n"],"names":["hasDraftAndPublish","trx","meta","hasTable","schema","tableName","uid","model","strapi","getModel","hasDP","contentTypes","copyPublishedEntriesToDraft","db","metadata","get","scalarAttributes","Object","values","attributes","reduce","acc","attribute","includes","columnName","isScalarAttribute","push","into","raw","map","join","insert","subQb","select","att","from","whereNotNull","getBatchToDiscard","defaultBatchSize","client","config","connection","isSQLite","batchSize","Math","min","offset","hasMore","batch","queryBuilder","where","publishedAt","$ne","limit","orderBy","transacting","execute","length","migrateUp","dpModels","documentService","createDocumentService","validateEntityCreation","_","data","validateEntityUpdate","discardDraft","entry","documentId","locale","async","concurrency","discardDocumentDrafts","name","up","down","Error"],"mappings":";;;;;AAsBA;;IAGA,MAAMA,kBAAqB,GAAA,OAAOC,GAAWC,EAAAA,IAAAA,GAAAA;IAC3C,MAAMC,QAAAA,GAAW,MAAMF,GAAIG,CAAAA,MAAM,CAACD,QAAQ,CAACD,KAAKG,SAAS,CAAA;AAEzD,IAAA,IAAI,CAACF,QAAU,EAAA;QACb,OAAO,KAAA;AACT;IAEA,MAAMG,GAAAA,GAAMJ,KAAKI,GAAG;IACpB,MAAMC,KAAAA,GAAQC,MAAO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,aAAA,CAAA;QAEF,WAAW,MAAMrB,SAASX,iBAAkB,CAAA;AAAExB,YAAAA,EAAAA;AAAIZ,YAAAA,GAAAA;AAAKK,YAAAA,GAAAA,EAAKC,MAAMD;SAAQ,CAAA,CAAA;;;AAGxE,YAAA,MAAMgE,iBAAMzC,CAAAA,GAAG,CAACmB,KAAAA,EAAOkB,YAAc,EAAA;gBAAEK,WAAa,EAAA;AAAE,aAAA,CAAA;AACxD;AACF;AACF,CAAA;MAEaC,qBAAmC,GAAA;IAC9CC,IAAM,EAAA,4BAAA;IACN,MAAMC,EAAAA,CAAAA,CAAGzE,GAAG,EAAEY,EAAE,EAAA;AACd,QAAA,MAAM6C,UAAUzD,GAAKY,EAAAA,EAAAA,CAAAA;AACvB,KAAA;IACA,MAAM8D,IAAAA,CAAAA,GAAAA;AACJ,QAAA,MAAM,IAAIC,KAAM,CAAA,iBAAA,CAAA;AAClB;AACF;;;;;"}
|
|
1
|
+
{"version":3,"file":"5.0.0-discard-drafts.js","sources":["../../../src/migrations/database/5.0.0-discard-drafts.ts"],"sourcesContent":["/**\n * This migration is responsible for creating the draft counterpart for all the entries that were in a published state.\n *\n * In v4, entries could either be in a draft or published state, but not both at the same time.\n * In v5, we introduced the concept of document, and an entry can be in a draft or published state.\n *\n * This means the migration needs to create the draft counterpart if an entry was published.\n *\n * This migration performs the following steps:\n * 1. Creates draft entries for all published entries, without it's components, dynamic zones or relations.\n * 2. Using the document service, discard those same drafts to copy its relations.\n */\n\n/* eslint-disable no-continue */\nimport type { UID } from '@strapi/types';\nimport type { Database, Migration } from '@strapi/database';\nimport { async, contentTypes } from '@strapi/utils';\nimport { createDocumentService } from '../../services/document-service';\n\ntype DocumentVersion = { documentId: string; locale: string };\ntype Knex = Parameters<Migration['up']>[0];\n\n/**\n * Check if the model has draft and publish enabled.\n */\nconst hasDraftAndPublish = async (trx: Knex, meta: any) => {\n const hasTable = await trx.schema.hasTable(meta.tableName);\n\n if (!hasTable) {\n return false;\n }\n\n const uid = meta.uid as UID.ContentType;\n const model = strapi.getModel(uid);\n const hasDP = contentTypes.hasDraftAndPublish(model);\n if (!hasDP) {\n return false;\n }\n\n return true;\n};\n\n/**\n * Copy all the published entries to draft entries, without it's components, dynamic zones or relations.\n * This ensures all necessary draft's exist before copying it's relations.\n */\nasync function copyPublishedEntriesToDraft({\n db,\n trx,\n uid,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n}) {\n // Extract all scalar attributes to use in the insert query\n const meta = db.metadata.get(uid);\n\n // Get scalar attributes that will be copied over the new draft\n const scalarAttributes = Object.values(meta.attributes).reduce((acc, attribute: any) => {\n if (['id'].includes(attribute.columnName)) {\n return acc;\n }\n\n if (contentTypes.isScalarAttribute(attribute)) {\n acc.push(attribute.columnName);\n }\n\n return acc;\n }, [] as string[]);\n\n /**\n * Query to copy the published entries into draft entries.\n *\n * INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n * SELECT columnName1, columnName2, columnName3, ...\n * FROM tableName\n */\n await trx\n // INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n .into(\n trx.raw(`?? (${scalarAttributes.map(() => `??`).join(', ')})`, [\n meta.tableName,\n ...scalarAttributes,\n ])\n )\n .insert((subQb: typeof trx) => {\n // SELECT columnName1, columnName2, columnName3, ...\n subQb\n .select(\n ...scalarAttributes.map((att: string) => {\n // Override 'publishedAt' and 'updatedAt' attributes\n if (att === 'published_at') {\n return trx.raw('NULL as ??', 'published_at');\n }\n\n return att;\n })\n )\n .from(meta.tableName)\n // Only select entries that were published\n .whereNotNull('published_at');\n });\n}\n\n/**\n * Load a batch of versions to discard.\n *\n * Versions with only a draft version will be ignored.\n * Only versions with a published version (which always have a draft version) will be discarded.\n */\nexport async function* getBatchToDiscard({\n db,\n trx,\n uid,\n defaultBatchSize = 1000,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n defaultBatchSize?: number;\n}) {\n const client = db.config.connection.client;\n const isSQLite =\n typeof client === 'string' && ['sqlite', 'sqlite3', 'better-sqlite3'].includes(client);\n\n // The SQLite documentation states that the maximum number of terms in a\n // compound SELECT statement is 500 by default.\n // See: https://www.sqlite.org/limits.html\n // To ensure a successful migration, we limit the batch size to 500 for SQLite.\n const batchSize = isSQLite ? Math.min(defaultBatchSize, 500) : defaultBatchSize;\n let offset = 0;\n let hasMore = true;\n\n while (hasMore) {\n // Look for the published entries to discard\n const batch: DocumentVersion[] = await db\n .queryBuilder(uid)\n .select(['id', 'documentId', 'locale'])\n .where({ publishedAt: { $ne: null } })\n .limit(batchSize)\n .offset(offset)\n .orderBy('id')\n .transacting(trx)\n .execute();\n\n if (batch.length < batchSize) {\n hasMore = false;\n }\n\n offset += batchSize;\n yield batch;\n }\n}\n\n/**\n * 2 pass migration to create the draft entries for all the published entries.\n * And then discard the drafts to copy the relations.\n */\nconst migrateUp = async (trx: Knex, db: Database) => {\n const dpModels = [];\n for (const meta of Array.from(db.metadata.values())) {\n const hasDP = await hasDraftAndPublish(trx, meta);\n if (hasDP) {\n dpModels.push(meta);\n }\n }\n\n /**\n * Create plain draft entries for all the entries that were published.\n */\n for (const model of dpModels) {\n await copyPublishedEntriesToDraft({ db, trx, uid: model.uid });\n }\n\n /**\n * Discard the drafts will copy the relations from the published entries to the newly created drafts.\n *\n * Load a batch of entries (batched to prevent loading millions of rows at once ),\n * and discard them using the document service.\n *\n * NOTE: This is using a custom document service without any validations,\n * to prevent the migration from failing if users already had invalid data in V4.\n * E.g. @see https://github.com/strapi/strapi/issues/21583\n */\n const documentService = createDocumentService(strapi, {\n async validateEntityCreation(_, data) {\n return data;\n },\n async validateEntityUpdate(_, data) {\n // Data can be partially empty on partial updates\n // This migration doesn't trigger any update (or partial update),\n // so it's safe to return the data as is.\n return data as any;\n },\n });\n\n for (const model of dpModels) {\n const discardDraft = async (entry: DocumentVersion) =>\n documentService(model.uid as UID.ContentType).discardDraft({\n documentId: entry.documentId,\n locale: entry.locale,\n });\n\n for await (const batch of getBatchToDiscard({ db, trx, uid: model.uid })) {\n // NOTE: concurrency had to be disabled to prevent a race condition with self-references\n // TODO: improve performance in a safe way\n await async.map(batch, discardDraft, { concurrency: 1 });\n }\n }\n};\n\nexport const discardDocumentDrafts: Migration = {\n name: 'core::5.0.0-discard-drafts',\n async up(trx, db) {\n await migrateUp(trx, db);\n },\n async down() {\n throw new Error('not implemented');\n },\n};\n"],"names":["hasDraftAndPublish","trx","meta","hasTable","schema","tableName","uid","model","strapi","getModel","hasDP","contentTypes","copyPublishedEntriesToDraft","db","metadata","get","scalarAttributes","Object","values","attributes","reduce","acc","attribute","includes","columnName","isScalarAttribute","push","into","raw","map","join","insert","subQb","select","att","from","whereNotNull","getBatchToDiscard","defaultBatchSize","client","config","connection","isSQLite","batchSize","Math","min","offset","hasMore","batch","queryBuilder","where","publishedAt","$ne","limit","orderBy","transacting","execute","length","migrateUp","dpModels","Array","documentService","createDocumentService","validateEntityCreation","_","data","validateEntityUpdate","discardDraft","entry","documentId","locale","async","concurrency","discardDocumentDrafts","name","up","down","Error"],"mappings":";;;;;AAsBA;;IAGA,MAAMA,kBAAqB,GAAA,OAAOC,GAAWC,EAAAA,IAAAA,GAAAA;IAC3C,MAAMC,QAAAA,GAAW,MAAMF,GAAIG,CAAAA,MAAM,CAACD,QAAQ,CAACD,KAAKG,SAAS,CAAA;AAEzD,IAAA,IAAI,CAACF,QAAU,EAAA;QACb,OAAO,KAAA;AACT;IAEA,MAAMG,GAAAA,GAAMJ,KAAKI,GAAG;IACpB,MAAMC,KAAAA,GAAQC,MAAOC,CAAAA,QAAQ,CAACH,GAAAA,CAAAA;IAC9B,MAAMI,KAAAA,GAAQC,wBAAaX,CAAAA,kBAAkB,CAACO,KAAAA,CAAAA;AAC9C,IAAA,IAAI,CAACG,KAAO,EAAA;QACV,OAAO,KAAA;AACT;IAEA,OAAO,IAAA;AACT,CAAA;AAEA;;;IAIA,eAAeE,4BAA4B,EACzCC,EAAE,EACFZ,GAAG,EACHK,GAAG,EAKJ,EAAA;;AAEC,IAAA,MAAMJ,IA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;AACF;AACF,CAAA;MAEaC,qBAAmC,GAAA;IAC9CC,IAAM,EAAA,4BAAA;IACN,MAAMC,EAAAA,CAAAA,CAAG1E,GAAG,EAAEY,EAAE,EAAA;AACd,QAAA,MAAM6C,UAAUzD,GAAKY,EAAAA,EAAAA,CAAAA;AACvB,KAAA;IACA,MAAM+D,IAAAA,CAAAA,GAAAA;AACJ,QAAA,MAAM,IAAIC,KAAM,CAAA,iBAAA,CAAA;AAClB;AACF;;;;;"}
|
|
@@ -98,7 +98,7 @@ import { createDocumentService } from '../../services/document-service/index.mjs
|
|
|
98
98
|
* And then discard the drafts to copy the relations.
|
|
99
99
|
*/ const migrateUp = async (trx, db)=>{
|
|
100
100
|
const dpModels = [];
|
|
101
|
-
for (const meta of db.metadata.values()){
|
|
101
|
+
for (const meta of Array.from(db.metadata.values())){
|
|
102
102
|
const hasDP = await hasDraftAndPublish(trx, meta);
|
|
103
103
|
if (hasDP) {
|
|
104
104
|
dpModels.push(meta);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"5.0.0-discard-drafts.mjs","sources":["../../../src/migrations/database/5.0.0-discard-drafts.ts"],"sourcesContent":["/**\n * This migration is responsible for creating the draft counterpart for all the entries that were in a published state.\n *\n * In v4, entries could either be in a draft or published state, but not both at the same time.\n * In v5, we introduced the concept of document, and an entry can be in a draft or published state.\n *\n * This means the migration needs to create the draft counterpart if an entry was published.\n *\n * This migration performs the following steps:\n * 1. Creates draft entries for all published entries, without it's components, dynamic zones or relations.\n * 2. Using the document service, discard those same drafts to copy its relations.\n */\n\n/* eslint-disable no-continue */\nimport type { UID } from '@strapi/types';\nimport type { Database, Migration } from '@strapi/database';\nimport { async, contentTypes } from '@strapi/utils';\nimport { createDocumentService } from '../../services/document-service';\n\ntype DocumentVersion = { documentId: string; locale: string };\ntype Knex = Parameters<Migration['up']>[0];\n\n/**\n * Check if the model has draft and publish enabled.\n */\nconst hasDraftAndPublish = async (trx: Knex, meta: any) => {\n const hasTable = await trx.schema.hasTable(meta.tableName);\n\n if (!hasTable) {\n return false;\n }\n\n const uid = meta.uid as UID.ContentType;\n const model = strapi.getModel(uid);\n const hasDP = contentTypes.hasDraftAndPublish(model);\n if (!hasDP) {\n return false;\n }\n\n return true;\n};\n\n/**\n * Copy all the published entries to draft entries, without it's components, dynamic zones or relations.\n * This ensures all necessary draft's exist before copying it's relations.\n */\nasync function copyPublishedEntriesToDraft({\n db,\n trx,\n uid,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n}) {\n // Extract all scalar attributes to use in the insert query\n const meta = db.metadata.get(uid);\n\n // Get scalar attributes that will be copied over the new draft\n const scalarAttributes = Object.values(meta.attributes).reduce((acc, attribute: any) => {\n if (['id'].includes(attribute.columnName)) {\n return acc;\n }\n\n if (contentTypes.isScalarAttribute(attribute)) {\n acc.push(attribute.columnName);\n }\n\n return acc;\n }, [] as string[]);\n\n /**\n * Query to copy the published entries into draft entries.\n *\n * INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n * SELECT columnName1, columnName2, columnName3, ...\n * FROM tableName\n */\n await trx\n // INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n .into(\n trx.raw(`?? (${scalarAttributes.map(() => `??`).join(', ')})`, [\n meta.tableName,\n ...scalarAttributes,\n ])\n )\n .insert((subQb: typeof trx) => {\n // SELECT columnName1, columnName2, columnName3, ...\n subQb\n .select(\n ...scalarAttributes.map((att: string) => {\n // Override 'publishedAt' and 'updatedAt' attributes\n if (att === 'published_at') {\n return trx.raw('NULL as ??', 'published_at');\n }\n\n return att;\n })\n )\n .from(meta.tableName)\n // Only select entries that were published\n .whereNotNull('published_at');\n });\n}\n\n/**\n * Load a batch of versions to discard.\n *\n * Versions with only a draft version will be ignored.\n * Only versions with a published version (which always have a draft version) will be discarded.\n */\nexport async function* getBatchToDiscard({\n db,\n trx,\n uid,\n defaultBatchSize = 1000,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n defaultBatchSize?: number;\n}) {\n const client = db.config.connection.client;\n const isSQLite =\n typeof client === 'string' && ['sqlite', 'sqlite3', 'better-sqlite3'].includes(client);\n\n // The SQLite documentation states that the maximum number of terms in a\n // compound SELECT statement is 500 by default.\n // See: https://www.sqlite.org/limits.html\n // To ensure a successful migration, we limit the batch size to 500 for SQLite.\n const batchSize = isSQLite ? Math.min(defaultBatchSize, 500) : defaultBatchSize;\n let offset = 0;\n let hasMore = true;\n\n while (hasMore) {\n // Look for the published entries to discard\n const batch: DocumentVersion[] = await db\n .queryBuilder(uid)\n .select(['id', 'documentId', 'locale'])\n .where({ publishedAt: { $ne: null } })\n .limit(batchSize)\n .offset(offset)\n .orderBy('id')\n .transacting(trx)\n .execute();\n\n if (batch.length < batchSize) {\n hasMore = false;\n }\n\n offset += batchSize;\n yield batch;\n }\n}\n\n/**\n * 2 pass migration to create the draft entries for all the published entries.\n * And then discard the drafts to copy the relations.\n */\nconst migrateUp = async (trx: Knex, db: Database) => {\n const dpModels = [];\n for (const meta of db.metadata.values()) {\n const hasDP = await hasDraftAndPublish(trx, meta);\n if (hasDP) {\n dpModels.push(meta);\n }\n }\n\n /**\n * Create plain draft entries for all the entries that were published.\n */\n for (const model of dpModels) {\n await copyPublishedEntriesToDraft({ db, trx, uid: model.uid });\n }\n\n /**\n * Discard the drafts will copy the relations from the published entries to the newly created drafts.\n *\n * Load a batch of entries (batched to prevent loading millions of rows at once ),\n * and discard them using the document service.\n *\n * NOTE: This is using a custom document service without any validations,\n * to prevent the migration from failing if users already had invalid data in V4.\n * E.g. @see https://github.com/strapi/strapi/issues/21583\n */\n const documentService = createDocumentService(strapi, {\n async validateEntityCreation(_, data) {\n return data;\n },\n async validateEntityUpdate(_, data) {\n // Data can be partially empty on partial updates\n // This migration doesn't trigger any update (or partial update),\n // so it's safe to return the data as is.\n return data as any;\n },\n });\n\n for (const model of dpModels) {\n const discardDraft = async (entry: DocumentVersion) =>\n documentService(model.uid as UID.ContentType).discardDraft({\n documentId: entry.documentId,\n locale: entry.locale,\n });\n\n for await (const batch of getBatchToDiscard({ db, trx, uid: model.uid })) {\n // NOTE: concurrency had to be disabled to prevent a race condition with self-references\n // TODO: improve performance in a safe way\n await async.map(batch, discardDraft, { concurrency: 1 });\n }\n }\n};\n\nexport const discardDocumentDrafts: Migration = {\n name: 'core::5.0.0-discard-drafts',\n async up(trx, db) {\n await migrateUp(trx, db);\n },\n async down() {\n throw new Error('not implemented');\n },\n};\n"],"names":["hasDraftAndPublish","trx","meta","hasTable","schema","tableName","uid","model","strapi","getModel","hasDP","contentTypes","copyPublishedEntriesToDraft","db","metadata","get","scalarAttributes","Object","values","attributes","reduce","acc","attribute","includes","columnName","isScalarAttribute","push","into","raw","map","join","insert","subQb","select","att","from","whereNotNull","getBatchToDiscard","defaultBatchSize","client","config","connection","isSQLite","batchSize","Math","min","offset","hasMore","batch","queryBuilder","where","publishedAt","$ne","limit","orderBy","transacting","execute","length","migrateUp","dpModels","documentService","createDocumentService","validateEntityCreation","_","data","validateEntityUpdate","discardDraft","entry","documentId","locale","async","concurrency","discardDocumentDrafts","name","up","down","Error"],"mappings":";;;AAsBA;;IAGA,MAAMA,kBAAqB,GAAA,OAAOC,GAAWC,EAAAA,IAAAA,GAAAA;IAC3C,MAAMC,QAAAA,GAAW,MAAMF,GAAIG,CAAAA,MAAM,CAACD,QAAQ,CAACD,KAAKG,SAAS,CAAA;AAEzD,IAAA,IAAI,CAACF,QAAU,EAAA;QACb,OAAO,KAAA;AACT;IAEA,MAAMG,GAAAA,GAAMJ,KAAKI,GAAG;IACpB,MAAMC,KAAAA,GAAQC,MAAOC,CAAAA,QAAQ,CAACH,GAAAA,CAAAA;IAC9B,MAAMI,KAAAA,GAAQC,YAAaX,CAAAA,kBAAkB,CAACO,KAAAA,CAAAA;AAC9C,IAAA,IAAI,CAACG,KAAO,EAAA;QACV,OAAO,KAAA;AACT;IAEA,OAAO,IAAA;AACT,CAAA;AAEA;;;IAIA,eAAeE,4BAA4B,EACzCC,EAAE,EACFZ,GAAG,EACHK,GAA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,CAAA;AACxD;AACF;AACF,CAAA;MAEaC,qBAAmC,GAAA;IAC9CC,IAAM,EAAA,4BAAA;IACN,MAAMC,EAAAA,CAAAA,CAAGzE,GAAG,EAAEY,EAAE,EAAA;AACd,QAAA,MAAM6C,UAAUzD,GAAKY,EAAAA,EAAAA,CAAAA;AACvB,KAAA;IACA,MAAM8D,IAAAA,CAAAA,GAAAA;AACJ,QAAA,MAAM,IAAIC,KAAM,CAAA,iBAAA,CAAA;AAClB;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"5.0.0-discard-drafts.mjs","sources":["../../../src/migrations/database/5.0.0-discard-drafts.ts"],"sourcesContent":["/**\n * This migration is responsible for creating the draft counterpart for all the entries that were in a published state.\n *\n * In v4, entries could either be in a draft or published state, but not both at the same time.\n * In v5, we introduced the concept of document, and an entry can be in a draft or published state.\n *\n * This means the migration needs to create the draft counterpart if an entry was published.\n *\n * This migration performs the following steps:\n * 1. Creates draft entries for all published entries, without it's components, dynamic zones or relations.\n * 2. Using the document service, discard those same drafts to copy its relations.\n */\n\n/* eslint-disable no-continue */\nimport type { UID } from '@strapi/types';\nimport type { Database, Migration } from '@strapi/database';\nimport { async, contentTypes } from '@strapi/utils';\nimport { createDocumentService } from '../../services/document-service';\n\ntype DocumentVersion = { documentId: string; locale: string };\ntype Knex = Parameters<Migration['up']>[0];\n\n/**\n * Check if the model has draft and publish enabled.\n */\nconst hasDraftAndPublish = async (trx: Knex, meta: any) => {\n const hasTable = await trx.schema.hasTable(meta.tableName);\n\n if (!hasTable) {\n return false;\n }\n\n const uid = meta.uid as UID.ContentType;\n const model = strapi.getModel(uid);\n const hasDP = contentTypes.hasDraftAndPublish(model);\n if (!hasDP) {\n return false;\n }\n\n return true;\n};\n\n/**\n * Copy all the published entries to draft entries, without it's components, dynamic zones or relations.\n * This ensures all necessary draft's exist before copying it's relations.\n */\nasync function copyPublishedEntriesToDraft({\n db,\n trx,\n uid,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n}) {\n // Extract all scalar attributes to use in the insert query\n const meta = db.metadata.get(uid);\n\n // Get scalar attributes that will be copied over the new draft\n const scalarAttributes = Object.values(meta.attributes).reduce((acc, attribute: any) => {\n if (['id'].includes(attribute.columnName)) {\n return acc;\n }\n\n if (contentTypes.isScalarAttribute(attribute)) {\n acc.push(attribute.columnName);\n }\n\n return acc;\n }, [] as string[]);\n\n /**\n * Query to copy the published entries into draft entries.\n *\n * INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n * SELECT columnName1, columnName2, columnName3, ...\n * FROM tableName\n */\n await trx\n // INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n .into(\n trx.raw(`?? (${scalarAttributes.map(() => `??`).join(', ')})`, [\n meta.tableName,\n ...scalarAttributes,\n ])\n )\n .insert((subQb: typeof trx) => {\n // SELECT columnName1, columnName2, columnName3, ...\n subQb\n .select(\n ...scalarAttributes.map((att: string) => {\n // Override 'publishedAt' and 'updatedAt' attributes\n if (att === 'published_at') {\n return trx.raw('NULL as ??', 'published_at');\n }\n\n return att;\n })\n )\n .from(meta.tableName)\n // Only select entries that were published\n .whereNotNull('published_at');\n });\n}\n\n/**\n * Load a batch of versions to discard.\n *\n * Versions with only a draft version will be ignored.\n * Only versions with a published version (which always have a draft version) will be discarded.\n */\nexport async function* getBatchToDiscard({\n db,\n trx,\n uid,\n defaultBatchSize = 1000,\n}: {\n db: Database;\n trx: Knex;\n uid: string;\n defaultBatchSize?: number;\n}) {\n const client = db.config.connection.client;\n const isSQLite =\n typeof client === 'string' && ['sqlite', 'sqlite3', 'better-sqlite3'].includes(client);\n\n // The SQLite documentation states that the maximum number of terms in a\n // compound SELECT statement is 500 by default.\n // See: https://www.sqlite.org/limits.html\n // To ensure a successful migration, we limit the batch size to 500 for SQLite.\n const batchSize = isSQLite ? Math.min(defaultBatchSize, 500) : defaultBatchSize;\n let offset = 0;\n let hasMore = true;\n\n while (hasMore) {\n // Look for the published entries to discard\n const batch: DocumentVersion[] = await db\n .queryBuilder(uid)\n .select(['id', 'documentId', 'locale'])\n .where({ publishedAt: { $ne: null } })\n .limit(batchSize)\n .offset(offset)\n .orderBy('id')\n .transacting(trx)\n .execute();\n\n if (batch.length < batchSize) {\n hasMore = false;\n }\n\n offset += batchSize;\n yield batch;\n }\n}\n\n/**\n * 2 pass migration to create the draft entries for all the published entries.\n * And then discard the drafts to copy the relations.\n */\nconst migrateUp = async (trx: Knex, db: Database) => {\n const dpModels = [];\n for (const meta of Array.from(db.metadata.values())) {\n const hasDP = await hasDraftAndPublish(trx, meta);\n if (hasDP) {\n dpModels.push(meta);\n }\n }\n\n /**\n * Create plain draft entries for all the entries that were published.\n */\n for (const model of dpModels) {\n await copyPublishedEntriesToDraft({ db, trx, uid: model.uid });\n }\n\n /**\n * Discard the drafts will copy the relations from the published entries to the newly created drafts.\n *\n * Load a batch of entries (batched to prevent loading millions of rows at once ),\n * and discard them using the document service.\n *\n * NOTE: This is using a custom document service without any validations,\n * to prevent the migration from failing if users already had invalid data in V4.\n * E.g. @see https://github.com/strapi/strapi/issues/21583\n */\n const documentService = createDocumentService(strapi, {\n async validateEntityCreation(_, data) {\n return data;\n },\n async validateEntityUpdate(_, data) {\n // Data can be partially empty on partial updates\n // This migration doesn't trigger any update (or partial update),\n // so it's safe to return the data as is.\n return data as any;\n },\n });\n\n for (const model of dpModels) {\n const discardDraft = async (entry: DocumentVersion) =>\n documentService(model.uid as UID.ContentType).discardDraft({\n documentId: entry.documentId,\n locale: entry.locale,\n });\n\n for await (const batch of getBatchToDiscard({ db, trx, uid: model.uid })) {\n // NOTE: concurrency had to be disabled to prevent a race condition with self-references\n // TODO: improve performance in a safe way\n await async.map(batch, discardDraft, { concurrency: 1 });\n }\n }\n};\n\nexport const discardDocumentDrafts: Migration = {\n name: 'core::5.0.0-discard-drafts',\n async up(trx, db) {\n await migrateUp(trx, db);\n },\n async down() {\n throw new Error('not implemented');\n },\n};\n"],"names":["hasDraftAndPublish","trx","meta","hasTable","schema","tableName","uid","model","strapi","getModel","hasDP","contentTypes","copyPublishedEntriesToDraft","db","metadata","get","scalarAttributes","Object","values","attributes","reduce","acc","attribute","includes","columnName","isScalarAttribute","push","into","raw","map","join","insert","subQb","select","att","from","whereNotNull","getBatchToDiscard","defaultBatchSize","client","config","connection","isSQLite","batchSize","Math","min","offset","hasMore","batch","queryBuilder","where","publishedAt","$ne","limit","orderBy","transacting","execute","length","migrateUp","dpModels","Array","documentService","createDocumentService","validateEntityCreation","_","data","validateEntityUpdate","discardDraft","entry","documentId","locale","async","concurrency","discardDocumentDrafts","name","up","down","Error"],"mappings":";;;AAsBA;;IAGA,MAAMA,kBAAqB,GAAA,OAAOC,GAAWC,EAAAA,IAAAA,GAAAA;IAC3C,MAAMC,QAAAA,GAAW,MAAMF,GAAIG,CAAAA,MAAM,CAACD,QAAQ,CAACD,KAAKG,SAAS,CAAA;AAEzD,IAAA,IAAI,CAACF,QAAU,EAAA;QACb,OAAO,KAAA;AACT;IAEA,MAAMG,GAAAA,GAAMJ,KAAKI,GAAG;IACpB,MAAMC,KAAAA,GAAQC,MAAOC,CAAAA,QAAQ,CAACH,GAAAA,CAAAA;IAC9B,MAAMI,KAAAA,GAAQC,YAAaX,CAAAA,kBAAkB,CAACO,KAAAA,CAAAA;AAC9C,IAAA,IAAI,CAACG,KAAO,EAAA;QACV,OAAO,KAAA;AACT;IAEA,OAAO,IAAA;AACT,CAAA;AAEA;;;IAIA,eAAeE,4BAA4B,EACzCC,EAAE,EACFZ,GAAG,EACHK,GAAG,EAKJ,EAAA;;AAEC,IAAA,MAAMJ,IAAOW,GAAAA,EAAAA,CAAGC,QAAQ,CAACC,GAAG,CAACT,GAAAA,CAAAA;;IAG7B,MAAMU,gBAAAA,GAAmBC,MAAOC,CAAAA,MAAM,CAAChB,IAAAA,CAAKiB,UAAU,CAAEC,CAAAA,MAAM,CAAC,CAACC,GAAKC,EAAAA,SAAAA,GAAAA;QACnE,IAAI;AAAC,YAAA;AAAK,SAAA,CAACC,QAAQ,CAACD,SAAU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A,CAAA;AAClB;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"first-published-at.js","sources":["../../src/migrations/first-published-at.ts"],"sourcesContent":["import { contentTypes as contentTypesUtils } from '@strapi/utils';\nimport _ from 'lodash';\nimport { Input } from './draft-publish';\n\ninterface ContentTypeData {\n id: number;\n documentId: string;\n publishedAt: Date;\n firstPublishedAt: Date;\n locale: string;\n}\n\nconst enableFirstPublishedAt = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n return strapi.db.transaction(async (trx) => {\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const contentType = contentTypes[uid];\n\n if (!contentTypesUtils.hasFirstPublishedAtField(contentType)) {\n continue;\n }\n\n if (!contentType.attributes?.firstPublishedAt) {\n continue;\n }\n\n const content: ContentTypeData[] = await strapi.db\n .queryBuilder(uid)\n .select('*')\n .transacting(trx)\n .execute();\n\n // Process content types in pairs: draft and published.\n // If only one exist, which means the value is not published yet and we can ignore it\n const groupedContent = _.groupBy(content, (item) => `${item.documentId}-${item.locale}`);\n\n for (const items of Object.values(groupedContent)) {\n // If there is only one item, which means nothing is published yet for this locale\n if (items.length <= 1) {\n continue;\n }\n\n // If firstPublishedAt is already present, do not do anything\n if (items[0].firstPublishedAt != null && items[1].firstPublishedAt != null) {\n continue;\n }\n\n const publishedContent = items.filter((item) => item.publishedAt != null).at(0);\n if (!publishedContent) {\n continue;\n }\n\n await strapi.db\n .queryBuilder(uid)\n .update({\n firstPublishedAt: new Date(publishedContent.publishedAt),\n })\n .where({\n documentId: publishedContent.documentId,\n locale: publishedContent.locale,\n })\n .transacting(trx)\n .execute();\n }\n }\n });\n};\n\nexport { enableFirstPublishedAt as enable };\n"],"names":["enableFirstPublishedAt","oldContentTypes","contentTypes","strapi","db","transaction","trx","uid","contentType","contentTypesUtils","hasFirstPublishedAtField","attributes","firstPublishedAt","content","queryBuilder","select","transacting","execute","groupedContent","_","groupBy","item","documentId","locale","items","Object","values","length","publishedContent","filter","publishedAt","at","update","Date","where"],"mappings":";;;;;AAYA,MAAMA,yBAAyB,OAAO,EAAEC,eAAe,EAAEC,YAAY,EAAS,GAAA;AAC5E,IAAA,IAAI,CAACD,eAAiB,EAAA;AACpB,QAAA;AACF;AAEA,IAAA,OAAOE,MAAOC,CAAAA,EAAE,CAACC,WAAW,CAAC,OAAOC,GAAAA,GAAAA;QAClC,IAAK,MAAMC,OAAOL,YAAc,CAAA;AAC9B,YAAA,IAAI,CAACD,eAAe,CAACM,GAAAA,CAAI,EAAE;AACzB,gBAAA;AACF;YAEA,MAAMC,WAAAA,GAAcN,YAAY,CAACK,GAAI,CAAA;AAErC,YAAA,IAAI,CAACE,wBAAAA,CAAkBC,wBAAwB,CAACF,WAAc,CAAA,EAAA;AAC5D,gBAAA;AACF;AAEA,YAAA,IAAI,CAACA,WAAAA,CAAYG,UAAU,EAAEC,gBAAkB,EAAA;AAC7C,gBAAA;AACF;AAEA,YAAA,MAAMC,OAA6B,GAAA,MAAMV,MAAOC,CAAAA,EAAE,CAC/CU,YAAY,CAACP,GACbQ,CAAAA,CAAAA,MAAM,CAAC,GAAA,CAAA,CACPC,WAAW,CAACV,KACZW,OAAO,EAAA;;;AAIV,YAAA,MAAMC,
|
|
1
|
+
{"version":3,"file":"first-published-at.js","sources":["../../src/migrations/first-published-at.ts"],"sourcesContent":["import { contentTypes as contentTypesUtils } from '@strapi/utils';\nimport _ from 'lodash';\nimport { Input } from './draft-publish';\n\ninterface ContentTypeData {\n id: number;\n documentId: string;\n publishedAt: Date;\n firstPublishedAt: Date;\n locale: string;\n}\n\nconst enableFirstPublishedAt = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n return strapi.db.transaction(async (trx) => {\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const contentType = contentTypes[uid];\n\n if (!contentTypesUtils.hasFirstPublishedAtField(contentType)) {\n continue;\n }\n\n if (!contentType.attributes?.firstPublishedAt) {\n continue;\n }\n\n const content: ContentTypeData[] = await strapi.db\n .queryBuilder(uid)\n .select('*')\n .transacting(trx)\n .execute();\n\n // Process content types in pairs: draft and published.\n // If only one exist, which means the value is not published yet and we can ignore it\n const groupedContent = _.groupBy(content, (item) => `${item.documentId}-${item.locale}`);\n\n for (const items of Object.values(groupedContent)) {\n // If there is only one item, which means nothing is published yet for this locale\n if (items.length <= 1) {\n continue;\n }\n\n // If firstPublishedAt is already present, do not do anything\n if (items[0].firstPublishedAt != null && items[1].firstPublishedAt != null) {\n continue;\n }\n\n const publishedContent = items.filter((item) => item.publishedAt != null).at(0);\n if (!publishedContent) {\n continue;\n }\n\n await strapi.db\n .queryBuilder(uid)\n .update({\n firstPublishedAt: new Date(publishedContent.publishedAt),\n })\n .where({\n documentId: publishedContent.documentId,\n locale: publishedContent.locale,\n })\n .transacting(trx)\n .execute();\n }\n }\n });\n};\n\nexport { enableFirstPublishedAt as enable };\n"],"names":["enableFirstPublishedAt","oldContentTypes","contentTypes","strapi","db","transaction","trx","uid","contentType","contentTypesUtils","hasFirstPublishedAtField","attributes","firstPublishedAt","content","queryBuilder","select","transacting","execute","groupedContent","_","groupBy","item","documentId","locale","items","Object","values","length","publishedContent","filter","publishedAt","at","update","Date","where"],"mappings":";;;;;AAYA,MAAMA,yBAAyB,OAAO,EAAEC,eAAe,EAAEC,YAAY,EAAS,GAAA;AAC5E,IAAA,IAAI,CAACD,eAAiB,EAAA;AACpB,QAAA;AACF;AAEA,IAAA,OAAOE,MAAOC,CAAAA,EAAE,CAACC,WAAW,CAAC,OAAOC,GAAAA,GAAAA;QAClC,IAAK,MAAMC,OAAOL,YAAc,CAAA;AAC9B,YAAA,IAAI,CAACD,eAAe,CAACM,GAAAA,CAAI,EAAE;AACzB,gBAAA;AACF;YAEA,MAAMC,WAAAA,GAAcN,YAAY,CAACK,GAAI,CAAA;AAErC,YAAA,IAAI,CAACE,wBAAAA,CAA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AYM,iBAAiBN,UAAU;AACvCC,oBAAAA,MAAAA,EAAQK,iBAAiBL;iBAE1BP,CAAAA,CAAAA,WAAW,CAACV,GAAAA,CAAAA,CACZW,OAAO,EAAA;AACZ;AACF;AACF,KAAA,CAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"first-published-at.mjs","sources":["../../src/migrations/first-published-at.ts"],"sourcesContent":["import { contentTypes as contentTypesUtils } from '@strapi/utils';\nimport _ from 'lodash';\nimport { Input } from './draft-publish';\n\ninterface ContentTypeData {\n id: number;\n documentId: string;\n publishedAt: Date;\n firstPublishedAt: Date;\n locale: string;\n}\n\nconst enableFirstPublishedAt = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n return strapi.db.transaction(async (trx) => {\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const contentType = contentTypes[uid];\n\n if (!contentTypesUtils.hasFirstPublishedAtField(contentType)) {\n continue;\n }\n\n if (!contentType.attributes?.firstPublishedAt) {\n continue;\n }\n\n const content: ContentTypeData[] = await strapi.db\n .queryBuilder(uid)\n .select('*')\n .transacting(trx)\n .execute();\n\n // Process content types in pairs: draft and published.\n // If only one exist, which means the value is not published yet and we can ignore it\n const groupedContent = _.groupBy(content, (item) => `${item.documentId}-${item.locale}`);\n\n for (const items of Object.values(groupedContent)) {\n // If there is only one item, which means nothing is published yet for this locale\n if (items.length <= 1) {\n continue;\n }\n\n // If firstPublishedAt is already present, do not do anything\n if (items[0].firstPublishedAt != null && items[1].firstPublishedAt != null) {\n continue;\n }\n\n const publishedContent = items.filter((item) => item.publishedAt != null).at(0);\n if (!publishedContent) {\n continue;\n }\n\n await strapi.db\n .queryBuilder(uid)\n .update({\n firstPublishedAt: new Date(publishedContent.publishedAt),\n })\n .where({\n documentId: publishedContent.documentId,\n locale: publishedContent.locale,\n })\n .transacting(trx)\n .execute();\n }\n }\n });\n};\n\nexport { enableFirstPublishedAt as enable };\n"],"names":["enableFirstPublishedAt","oldContentTypes","contentTypes","strapi","db","transaction","trx","uid","contentType","contentTypesUtils","hasFirstPublishedAtField","attributes","firstPublishedAt","content","queryBuilder","select","transacting","execute","groupedContent","_","groupBy","item","documentId","locale","items","Object","values","length","publishedContent","filter","publishedAt","at","update","Date","where"],"mappings":";;;AAYA,MAAMA,yBAAyB,OAAO,EAAEC,eAAe,gBAAEC,cAAY,EAAS,GAAA;AAC5E,IAAA,IAAI,CAACD,eAAiB,EAAA;AACpB,QAAA;AACF;AAEA,IAAA,OAAOE,MAAOC,CAAAA,EAAE,CAACC,WAAW,CAAC,OAAOC,GAAAA,GAAAA;QAClC,IAAK,MAAMC,OAAOL,cAAc,CAAA;AAC9B,YAAA,IAAI,CAACD,eAAe,CAACM,GAAAA,CAAI,EAAE;AACzB,gBAAA;AACF;YAEA,MAAMC,WAAAA,GAAcN,cAAY,CAACK,GAAI,CAAA;AAErC,YAAA,IAAI,CAACE,YAAAA,CAAkBC,wBAAwB,CAACF,WAAc,CAAA,EAAA;AAC5D,gBAAA;AACF;AAEA,YAAA,IAAI,CAACA,WAAAA,CAAYG,UAAU,EAAEC,gBAAkB,EAAA;AAC7C,gBAAA;AACF;AAEA,YAAA,MAAMC,OAA6B,GAAA,MAAMV,MAAOC,CAAAA,EAAE,CAC/CU,YAAY,CAACP,GACbQ,CAAAA,CAAAA,MAAM,CAAC,GAAA,CAAA,CACPC,WAAW,CAACV,KACZW,OAAO,EAAA;;;AAIV,YAAA,MAAMC,
|
|
1
|
+
{"version":3,"file":"first-published-at.mjs","sources":["../../src/migrations/first-published-at.ts"],"sourcesContent":["import { contentTypes as contentTypesUtils } from '@strapi/utils';\nimport _ from 'lodash';\nimport { Input } from './draft-publish';\n\ninterface ContentTypeData {\n id: number;\n documentId: string;\n publishedAt: Date;\n firstPublishedAt: Date;\n locale: string;\n}\n\nconst enableFirstPublishedAt = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n return strapi.db.transaction(async (trx) => {\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const contentType = contentTypes[uid];\n\n if (!contentTypesUtils.hasFirstPublishedAtField(contentType)) {\n continue;\n }\n\n if (!contentType.attributes?.firstPublishedAt) {\n continue;\n }\n\n const content: ContentTypeData[] = await strapi.db\n .queryBuilder(uid)\n .select('*')\n .transacting(trx)\n .execute();\n\n // Process content types in pairs: draft and published.\n // If only one exist, which means the value is not published yet and we can ignore it\n const groupedContent = _.groupBy(content, (item) => `${item.documentId}-${item.locale}`);\n\n for (const items of Object.values(groupedContent)) {\n // If there is only one item, which means nothing is published yet for this locale\n if (items.length <= 1) {\n continue;\n }\n\n // If firstPublishedAt is already present, do not do anything\n if (items[0].firstPublishedAt != null && items[1].firstPublishedAt != null) {\n continue;\n }\n\n const publishedContent = items.filter((item) => item.publishedAt != null).at(0);\n if (!publishedContent) {\n continue;\n }\n\n await strapi.db\n .queryBuilder(uid)\n .update({\n firstPublishedAt: new Date(publishedContent.publishedAt),\n })\n .where({\n documentId: publishedContent.documentId,\n locale: publishedContent.locale,\n })\n .transacting(trx)\n .execute();\n }\n }\n });\n};\n\nexport { enableFirstPublishedAt as enable };\n"],"names":["enableFirstPublishedAt","oldContentTypes","contentTypes","strapi","db","transaction","trx","uid","contentType","contentTypesUtils","hasFirstPublishedAtField","attributes","firstPublishedAt","content","queryBuilder","select","transacting","execute","groupedContent","_","groupBy","item","documentId","locale","items","Object","values","length","publishedContent","filter","publishedAt","at","update","Date","where"],"mappings":";;;AAYA,MAAMA,yBAAyB,OAAO,EAAEC,eAAe,gBAAEC,cAAY,EAAS,GAAA;AAC5E,IAAA,IAAI,CAACD,eAAiB,EAAA;AACpB,QAAA;AACF;AAEA,IAAA,OAAOE,MAAOC,CAAAA,EAAE,CAACC,WAAW,CAAC,OAAOC,GAAAA,GAAAA;QAClC,IAAK,MAAMC,OAAOL,cAAc,CAAA;AAC9B,YAAA,IAAI,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AAM,CAAC;oBACNpB,gBAAkB,EAAA,IAAIqB,IAAKL,CAAAA,gBAAAA,CAAiBE,WAAW;AACzD,iBAAA,CAAA,CACCI,KAAK,CAAC;AACLZ,oBAAAA,UAAAA,EAAYM,iBAAiBN,UAAU;AACvCC,oBAAAA,MAAAA,EAAQK,iBAAiBL;iBAE1BP,CAAAA,CAAAA,WAAW,CAACV,GAAAA,CAAAA,CACZW,OAAO,EAAA;AACZ;AACF;AACF,KAAA,CAAA;AACF;;;;"}
|
package/dist/package.json.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var name = "@strapi/core";
|
|
6
|
-
var version = "0.0.0-next.
|
|
6
|
+
var version = "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa";
|
|
7
7
|
var description = "Core of Strapi";
|
|
8
8
|
var homepage = "https://strapi.io";
|
|
9
9
|
var bugs = {
|
|
@@ -59,14 +59,14 @@ var dependencies = {
|
|
|
59
59
|
"@koa/cors": "5.0.0",
|
|
60
60
|
"@koa/router": "12.0.2",
|
|
61
61
|
"@paralleldrive/cuid2": "2.2.2",
|
|
62
|
-
"@strapi/admin": "0.0.0-next.
|
|
63
|
-
"@strapi/database": "0.0.0-next.
|
|
64
|
-
"@strapi/generators": "0.0.0-next.
|
|
65
|
-
"@strapi/logger": "0.0.0-next.
|
|
66
|
-
"@strapi/permissions": "0.0.0-next.
|
|
67
|
-
"@strapi/types": "0.0.0-next.
|
|
68
|
-
"@strapi/typescript-utils": "0.0.0-next.
|
|
69
|
-
"@strapi/utils": "0.0.0-next.
|
|
62
|
+
"@strapi/admin": "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa",
|
|
63
|
+
"@strapi/database": "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa",
|
|
64
|
+
"@strapi/generators": "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa",
|
|
65
|
+
"@strapi/logger": "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa",
|
|
66
|
+
"@strapi/permissions": "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa",
|
|
67
|
+
"@strapi/types": "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa",
|
|
68
|
+
"@strapi/typescript-utils": "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa",
|
|
69
|
+
"@strapi/utils": "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa",
|
|
70
70
|
"@vercel/stega": "0.1.2",
|
|
71
71
|
bcryptjs: "2.4.3",
|
|
72
72
|
boxen: "5.1.2",
|
|
@@ -115,7 +115,7 @@ var dependencies = {
|
|
|
115
115
|
};
|
|
116
116
|
var devDependencies = {
|
|
117
117
|
"@strapi/ts-zen": "^0.2.0",
|
|
118
|
-
"@swc/core": "1.
|
|
118
|
+
"@swc/core": "1.13.5",
|
|
119
119
|
"@types/bcryptjs": "2.4.3",
|
|
120
120
|
"@types/configstore": "5.0.1",
|
|
121
121
|
"@types/delegates": "1.0.0",
|
|
@@ -131,15 +131,15 @@ var devDependencies = {
|
|
|
131
131
|
"@types/koa__router": "12.0.0",
|
|
132
132
|
"@types/lodash": "^4.14.191",
|
|
133
133
|
"@types/mime-types": "2.1.1",
|
|
134
|
-
"@types/node": "
|
|
134
|
+
"@types/node": "24.10.0",
|
|
135
135
|
"@types/node-schedule": "2.1.7",
|
|
136
136
|
"@types/statuses": "2.0.1",
|
|
137
|
-
"eslint-config-custom": "0.0.0-next.
|
|
137
|
+
"eslint-config-custom": "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa",
|
|
138
138
|
supertest: "6.3.3",
|
|
139
|
-
tsconfig: "0.0.0-next.
|
|
139
|
+
tsconfig: "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa"
|
|
140
140
|
};
|
|
141
141
|
var engines = {
|
|
142
|
-
node: ">=
|
|
142
|
+
node: ">=20.0.0 <=24.x.x",
|
|
143
143
|
npm: ">=6.0.0"
|
|
144
144
|
};
|
|
145
145
|
var pkg = {
|
package/dist/package.json.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var name = "@strapi/core";
|
|
2
|
-
var version = "0.0.0-next.
|
|
2
|
+
var version = "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa";
|
|
3
3
|
var description = "Core of Strapi";
|
|
4
4
|
var homepage = "https://strapi.io";
|
|
5
5
|
var bugs = {
|
|
@@ -55,14 +55,14 @@ var dependencies = {
|
|
|
55
55
|
"@koa/cors": "5.0.0",
|
|
56
56
|
"@koa/router": "12.0.2",
|
|
57
57
|
"@paralleldrive/cuid2": "2.2.2",
|
|
58
|
-
"@strapi/admin": "0.0.0-next.
|
|
59
|
-
"@strapi/database": "0.0.0-next.
|
|
60
|
-
"@strapi/generators": "0.0.0-next.
|
|
61
|
-
"@strapi/logger": "0.0.0-next.
|
|
62
|
-
"@strapi/permissions": "0.0.0-next.
|
|
63
|
-
"@strapi/types": "0.0.0-next.
|
|
64
|
-
"@strapi/typescript-utils": "0.0.0-next.
|
|
65
|
-
"@strapi/utils": "0.0.0-next.
|
|
58
|
+
"@strapi/admin": "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa",
|
|
59
|
+
"@strapi/database": "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa",
|
|
60
|
+
"@strapi/generators": "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa",
|
|
61
|
+
"@strapi/logger": "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa",
|
|
62
|
+
"@strapi/permissions": "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa",
|
|
63
|
+
"@strapi/types": "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa",
|
|
64
|
+
"@strapi/typescript-utils": "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa",
|
|
65
|
+
"@strapi/utils": "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa",
|
|
66
66
|
"@vercel/stega": "0.1.2",
|
|
67
67
|
bcryptjs: "2.4.3",
|
|
68
68
|
boxen: "5.1.2",
|
|
@@ -111,7 +111,7 @@ var dependencies = {
|
|
|
111
111
|
};
|
|
112
112
|
var devDependencies = {
|
|
113
113
|
"@strapi/ts-zen": "^0.2.0",
|
|
114
|
-
"@swc/core": "1.
|
|
114
|
+
"@swc/core": "1.13.5",
|
|
115
115
|
"@types/bcryptjs": "2.4.3",
|
|
116
116
|
"@types/configstore": "5.0.1",
|
|
117
117
|
"@types/delegates": "1.0.0",
|
|
@@ -127,15 +127,15 @@ var devDependencies = {
|
|
|
127
127
|
"@types/koa__router": "12.0.0",
|
|
128
128
|
"@types/lodash": "^4.14.191",
|
|
129
129
|
"@types/mime-types": "2.1.1",
|
|
130
|
-
"@types/node": "
|
|
130
|
+
"@types/node": "24.10.0",
|
|
131
131
|
"@types/node-schedule": "2.1.7",
|
|
132
132
|
"@types/statuses": "2.0.1",
|
|
133
|
-
"eslint-config-custom": "0.0.0-next.
|
|
133
|
+
"eslint-config-custom": "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa",
|
|
134
134
|
supertest: "6.3.3",
|
|
135
|
-
tsconfig: "0.0.0-next.
|
|
135
|
+
tsconfig: "0.0.0-next.29273b8e8a9a5aa635e5680190eda01f861431aa"
|
|
136
136
|
};
|
|
137
137
|
var engines = {
|
|
138
|
-
node: ">=
|
|
138
|
+
node: ">=20.0.0 <=24.x.x",
|
|
139
139
|
npm: ">=6.0.0"
|
|
140
140
|
};
|
|
141
141
|
var pkg = {
|
package/dist/providers/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var admin = require('./admin.js');
|
|
|
4
4
|
var coreStore = require('./coreStore.js');
|
|
5
5
|
var cron = require('./cron.js');
|
|
6
6
|
var registries = require('./registries.js');
|
|
7
|
-
var sessionManager = require('./
|
|
7
|
+
var sessionManager = require('./session-manager.js');
|
|
8
8
|
var telemetry = require('./telemetry.js');
|
|
9
9
|
var webhooks = require('./webhooks.js');
|
|
10
10
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/providers/index.ts"],"sourcesContent":["import admin from './admin';\nimport coreStore from './coreStore';\nimport cron from './cron';\nimport registries from './registries';\nimport sessionManager from './
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/providers/index.ts"],"sourcesContent":["import admin from './admin';\nimport coreStore from './coreStore';\nimport cron from './cron';\nimport registries from './registries';\nimport sessionManager from './session-manager';\nimport telemetry from './telemetry';\nimport webhooks from './webhooks';\n\nimport type { Provider } from './provider';\n\nexport const providers: Provider[] = [\n registries,\n admin,\n coreStore,\n sessionManager,\n webhooks,\n telemetry,\n cron,\n];\n"],"names":["providers","registries","admin","coreStore","sessionManager","webhooks","telemetry","cron"],"mappings":";;;;;;;;;;MAUaA,SAAwB,GAAA;AACnCC,IAAAA,UAAAA;AACAC,IAAAA,KAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,cAAAA;AACAC,IAAAA,QAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA;;;;;"}
|
package/dist/providers/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import admin from './admin.mjs';
|
|
|
2
2
|
import coreStore from './coreStore.mjs';
|
|
3
3
|
import cron from './cron.mjs';
|
|
4
4
|
import registries from './registries.mjs';
|
|
5
|
-
import sessionManager from './
|
|
5
|
+
import sessionManager from './session-manager.mjs';
|
|
6
6
|
import telemetry from './telemetry.mjs';
|
|
7
7
|
import webhooks from './webhooks.mjs';
|
|
8
8
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/providers/index.ts"],"sourcesContent":["import admin from './admin';\nimport coreStore from './coreStore';\nimport cron from './cron';\nimport registries from './registries';\nimport sessionManager from './
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/providers/index.ts"],"sourcesContent":["import admin from './admin';\nimport coreStore from './coreStore';\nimport cron from './cron';\nimport registries from './registries';\nimport sessionManager from './session-manager';\nimport telemetry from './telemetry';\nimport webhooks from './webhooks';\n\nimport type { Provider } from './provider';\n\nexport const providers: Provider[] = [\n registries,\n admin,\n coreStore,\n sessionManager,\n webhooks,\n telemetry,\n cron,\n];\n"],"names":["providers","registries","admin","coreStore","sessionManager","webhooks","telemetry","cron"],"mappings":";;;;;;;;MAUaA,SAAwB,GAAA;AACnCC,IAAAA,UAAAA;AACAC,IAAAA,KAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,cAAAA;AACAC,IAAAA,QAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-manager.d.ts","sourceRoot":"","sources":["../../src/providers/session-manager.ts"],"names":[],"mappings":";AAYA,wBAoBG"}
|
|
@@ -5,17 +5,19 @@ var sessionManager$1 = require('../services/session-manager.js');
|
|
|
5
5
|
|
|
6
6
|
var sessionManager = provider.defineProvider({
|
|
7
7
|
init (strapi) {
|
|
8
|
+
strapi.add('sessionManager', ()=>sessionManager$1.createSessionManager({
|
|
9
|
+
db: strapi.db
|
|
10
|
+
}));
|
|
11
|
+
},
|
|
12
|
+
async register (strapi) {
|
|
8
13
|
// Get JWT secret from admin auth settings (same as admin token service)
|
|
9
14
|
const adminAuth = strapi.config.get('admin.auth', {});
|
|
10
15
|
const jwtSecret = adminAuth.secret;
|
|
11
16
|
if (!jwtSecret) {
|
|
12
17
|
throw new Error('Missing admin.auth.secret configuration. The SessionManager requires a JWT secret');
|
|
13
18
|
}
|
|
14
|
-
strapi.add('sessionManager', ()=>sessionManager$1.createSessionManager({
|
|
15
|
-
db: strapi.db
|
|
16
|
-
}));
|
|
17
19
|
}
|
|
18
20
|
});
|
|
19
21
|
|
|
20
22
|
module.exports = sessionManager;
|
|
21
|
-
//# sourceMappingURL=
|
|
23
|
+
//# sourceMappingURL=session-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-manager.js","sources":["../../src/providers/session-manager.ts"],"sourcesContent":["import type { Algorithm } from 'jsonwebtoken';\nimport { defineProvider } from './provider';\nimport { createSessionManager } from '../services/session-manager';\n\ninterface AdminAuthConfig {\n secret?: string;\n options?: {\n algorithm?: Algorithm;\n [key: string]: unknown;\n };\n}\n\nexport default defineProvider({\n init(strapi) {\n strapi.add('sessionManager', () =>\n createSessionManager({\n db: strapi.db,\n })\n );\n },\n\n async register(strapi) {\n // Get JWT secret from admin auth settings (same as admin token service)\n const adminAuth = strapi.config.get<AdminAuthConfig>('admin.auth', {});\n const jwtSecret = adminAuth.secret;\n\n if (!jwtSecret) {\n throw new Error(\n 'Missing admin.auth.secret configuration. The SessionManager requires a JWT secret'\n );\n }\n },\n});\n"],"names":["defineProvider","init","strapi","add","createSessionManager","db","register","adminAuth","config","get","jwtSecret","secret","Error"],"mappings":";;;;;AAYA,qBAAeA,uBAAe,CAAA;AAC5BC,IAAAA,IAAAA,CAAAA,CAAKC,MAAM,EAAA;AACTA,QAAAA,MAAAA,CAAOC,GAAG,CAAC,gBAAkB,EAAA,IAC3BC,qCAAqB,CAAA;AACnBC,gBAAAA,EAAAA,EAAIH,OAAOG;AACb,aAAA,CAAA,CAAA;AAEJ,KAAA;AAEA,IAAA,MAAMC,UAASJ,MAAM,EAAA;;AAEnB,QAAA,MAAMK,YAAYL,MAAOM,CAAAA,MAAM,CAACC,GAAG,CAAkB,cAAc,EAAC,CAAA;QACpE,MAAMC,SAAAA,GAAYH,UAAUI,MAAM;AAElC,QAAA,IAAI,CAACD,SAAW,EAAA;AACd,YAAA,MAAM,IAAIE,KACR,CAAA,mFAAA,CAAA;AAEJ;AACF;AACF,CAAG,CAAA;;;;"}
|
|
@@ -3,17 +3,19 @@ import { createSessionManager } from '../services/session-manager.mjs';
|
|
|
3
3
|
|
|
4
4
|
var sessionManager = defineProvider({
|
|
5
5
|
init (strapi) {
|
|
6
|
+
strapi.add('sessionManager', ()=>createSessionManager({
|
|
7
|
+
db: strapi.db
|
|
8
|
+
}));
|
|
9
|
+
},
|
|
10
|
+
async register (strapi) {
|
|
6
11
|
// Get JWT secret from admin auth settings (same as admin token service)
|
|
7
12
|
const adminAuth = strapi.config.get('admin.auth', {});
|
|
8
13
|
const jwtSecret = adminAuth.secret;
|
|
9
14
|
if (!jwtSecret) {
|
|
10
15
|
throw new Error('Missing admin.auth.secret configuration. The SessionManager requires a JWT secret');
|
|
11
16
|
}
|
|
12
|
-
strapi.add('sessionManager', ()=>createSessionManager({
|
|
13
|
-
db: strapi.db
|
|
14
|
-
}));
|
|
15
17
|
}
|
|
16
18
|
});
|
|
17
19
|
|
|
18
20
|
export { sessionManager as default };
|
|
19
|
-
//# sourceMappingURL=
|
|
21
|
+
//# sourceMappingURL=session-manager.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-manager.mjs","sources":["../../src/providers/session-manager.ts"],"sourcesContent":["import type { Algorithm } from 'jsonwebtoken';\nimport { defineProvider } from './provider';\nimport { createSessionManager } from '../services/session-manager';\n\ninterface AdminAuthConfig {\n secret?: string;\n options?: {\n algorithm?: Algorithm;\n [key: string]: unknown;\n };\n}\n\nexport default defineProvider({\n init(strapi) {\n strapi.add('sessionManager', () =>\n createSessionManager({\n db: strapi.db,\n })\n );\n },\n\n async register(strapi) {\n // Get JWT secret from admin auth settings (same as admin token service)\n const adminAuth = strapi.config.get<AdminAuthConfig>('admin.auth', {});\n const jwtSecret = adminAuth.secret;\n\n if (!jwtSecret) {\n throw new Error(\n 'Missing admin.auth.secret configuration. The SessionManager requires a JWT secret'\n );\n }\n },\n});\n"],"names":["defineProvider","init","strapi","add","createSessionManager","db","register","adminAuth","config","get","jwtSecret","secret","Error"],"mappings":";;;AAYA,qBAAeA,cAAe,CAAA;AAC5BC,IAAAA,IAAAA,CAAAA,CAAKC,MAAM,EAAA;AACTA,QAAAA,MAAAA,CAAOC,GAAG,CAAC,gBAAkB,EAAA,IAC3BC,oBAAqB,CAAA;AACnBC,gBAAAA,EAAAA,EAAIH,OAAOG;AACb,aAAA,CAAA,CAAA;AAEJ,KAAA;AAEA,IAAA,MAAMC,UAASJ,MAAM,EAAA;;AAEnB,QAAA,MAAMK,YAAYL,MAAOM,CAAAA,MAAM,CAACC,GAAG,CAAkB,cAAc,EAAC,CAAA;QACpE,MAAMC,SAAAA,GAAYH,UAAUI,MAAM;AAElC,QAAA,IAAI,CAACD,SAAW,EAAA;AACd,YAAA,MAAM,IAAIE,KACR,CAAA,mFAAA,CAAA;AAEJ;AACF;AACF,CAAG,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apis.js","sources":["../../src/registries/apis.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\n\nconst apisRegistry = (strapi: Core.Strapi) => {\n const apis: Record<string, unknown> = {};\n\n return {\n get(name: string) {\n return apis[name];\n },\n getAll() {\n return apis;\n },\n add(apiName: string, apiConfig: unknown) {\n if (has(apiName, apis)) {\n throw new Error(`API ${apiName} has already been registered.`);\n }\n\n const api = strapi.get('modules').add(`api::${apiName}`, apiConfig);\n\n apis[apiName] = api;\n\n return apis[apiName];\n },\n };\n};\n\nexport default apisRegistry;\n"],"names":["apisRegistry","strapi","apis","get","name","getAll","add","apiName","apiConfig","has","Error","api"],"mappings":";;;;AAGA,MAAMA,eAAe,CAACC,MAAAA,GAAAA;AACpB,IAAA,MAAMC,OAAgC,EAAC;IAEvC,OAAO;AACLC,QAAAA,GAAAA,CAAAA,CAAIC,IAAY,EAAA;YACd,OAAOF,IAAI,CAACE,IAAK,CAAA;AACnB,SAAA;AACAC,QAAAA,MAAAA,CAAAA,GAAAA;YACE,OAAOH,IAAAA;AACT,SAAA;QACAI,GAAIC,CAAAA,CAAAA,OAAe,EAAEC,SAAkB,EAAA;YACrC,IAAIC,MAAAA,CAAIF,SAASL,IAAO,CAAA,EAAA;AACtB,gBAAA,MAAM,IAAIQ,KAAM,CAAA,CAAC,IAAI,EAAEH,OAAAA,CAAQ,6BAA6B,CAAC,CAAA;AAC/D;
|
|
1
|
+
{"version":3,"file":"apis.js","sources":["../../src/registries/apis.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\n\nconst apisRegistry = (strapi: Core.Strapi) => {\n const apis: Record<string, unknown> = {};\n\n return {\n get(name: string) {\n return apis[name];\n },\n getAll() {\n return apis;\n },\n add(apiName: string, apiConfig: unknown) {\n if (has(apiName, apis)) {\n throw new Error(`API ${apiName} has already been registered.`);\n }\n\n const api = strapi.get('modules').add(`api::${apiName}`, apiConfig);\n\n apis[apiName] = api;\n\n return apis[apiName];\n },\n };\n};\n\nexport default apisRegistry;\n"],"names":["apisRegistry","strapi","apis","get","name","getAll","add","apiName","apiConfig","has","Error","api"],"mappings":";;;;AAGA,MAAMA,eAAe,CAACC,MAAAA,GAAAA;AACpB,IAAA,MAAMC,OAAgC,EAAC;IAEvC,OAAO;AACLC,QAAAA,GAAAA,CAAAA,CAAIC,IAAY,EAAA;YACd,OAAOF,IAAI,CAACE,IAAK,CAAA;AACnB,SAAA;AACAC,QAAAA,MAAAA,CAAAA,GAAAA;YACE,OAAOH,IAAAA;AACT,SAAA;QACAI,GAAIC,CAAAA,CAAAA,OAAe,EAAEC,SAAkB,EAAA;YACrC,IAAIC,MAAAA,CAAIF,SAASL,IAAO,CAAA,EAAA;AACtB,gBAAA,MAAM,IAAIQ,KAAM,CAAA,CAAC,IAAI,EAAEH,OAAAA,CAAQ,6BAA6B,CAAC,CAAA;AAC/D;YAEA,MAAMI,GAAAA,GAAMV,MAAOE,CAAAA,GAAG,CAAC,SAAA,CAAA,CAAWG,GAAG,CAAC,CAAC,KAAK,EAAEC,OAAAA,CAAAA,CAAS,EAAEC,SAAAA,CAAAA;YAEzDN,IAAI,CAACK,QAAQ,GAAGI,GAAAA;YAEhB,OAAOT,IAAI,CAACK,OAAQ,CAAA;AACtB;AACF,KAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apis.mjs","sources":["../../src/registries/apis.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\n\nconst apisRegistry = (strapi: Core.Strapi) => {\n const apis: Record<string, unknown> = {};\n\n return {\n get(name: string) {\n return apis[name];\n },\n getAll() {\n return apis;\n },\n add(apiName: string, apiConfig: unknown) {\n if (has(apiName, apis)) {\n throw new Error(`API ${apiName} has already been registered.`);\n }\n\n const api = strapi.get('modules').add(`api::${apiName}`, apiConfig);\n\n apis[apiName] = api;\n\n return apis[apiName];\n },\n };\n};\n\nexport default apisRegistry;\n"],"names":["apisRegistry","strapi","apis","get","name","getAll","add","apiName","apiConfig","has","Error","api"],"mappings":";;AAGA,MAAMA,eAAe,CAACC,MAAAA,GAAAA;AACpB,IAAA,MAAMC,OAAgC,EAAC;IAEvC,OAAO;AACLC,QAAAA,GAAAA,CAAAA,CAAIC,IAAY,EAAA;YACd,OAAOF,IAAI,CAACE,IAAK,CAAA;AACnB,SAAA;AACAC,QAAAA,MAAAA,CAAAA,GAAAA;YACE,OAAOH,IAAAA;AACT,SAAA;QACAI,GAAIC,CAAAA,CAAAA,OAAe,EAAEC,SAAkB,EAAA;YACrC,IAAIC,GAAAA,CAAIF,SAASL,IAAO,CAAA,EAAA;AACtB,gBAAA,MAAM,IAAIQ,KAAM,CAAA,CAAC,IAAI,EAAEH,OAAAA,CAAQ,6BAA6B,CAAC,CAAA;AAC/D;
|
|
1
|
+
{"version":3,"file":"apis.mjs","sources":["../../src/registries/apis.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\n\nconst apisRegistry = (strapi: Core.Strapi) => {\n const apis: Record<string, unknown> = {};\n\n return {\n get(name: string) {\n return apis[name];\n },\n getAll() {\n return apis;\n },\n add(apiName: string, apiConfig: unknown) {\n if (has(apiName, apis)) {\n throw new Error(`API ${apiName} has already been registered.`);\n }\n\n const api = strapi.get('modules').add(`api::${apiName}`, apiConfig);\n\n apis[apiName] = api;\n\n return apis[apiName];\n },\n };\n};\n\nexport default apisRegistry;\n"],"names":["apisRegistry","strapi","apis","get","name","getAll","add","apiName","apiConfig","has","Error","api"],"mappings":";;AAGA,MAAMA,eAAe,CAACC,MAAAA,GAAAA;AACpB,IAAA,MAAMC,OAAgC,EAAC;IAEvC,OAAO;AACLC,QAAAA,GAAAA,CAAAA,CAAIC,IAAY,EAAA;YACd,OAAOF,IAAI,CAACE,IAAK,CAAA;AACnB,SAAA;AACAC,QAAAA,MAAAA,CAAAA,GAAAA;YACE,OAAOH,IAAAA;AACT,SAAA;QACAI,GAAIC,CAAAA,CAAAA,OAAe,EAAEC,SAAkB,EAAA;YACrC,IAAIC,GAAAA,CAAIF,SAASL,IAAO,CAAA,EAAA;AACtB,gBAAA,MAAM,IAAIQ,KAAM,CAAA,CAAC,IAAI,EAAEH,OAAAA,CAAQ,6BAA6B,CAAC,CAAA;AAC/D;YAEA,MAAMI,GAAAA,GAAMV,MAAOE,CAAAA,GAAG,CAAC,SAAA,CAAA,CAAWG,GAAG,CAAC,CAAC,KAAK,EAAEC,OAAAA,CAAAA,CAAS,EAAEC,SAAAA,CAAAA;YAEzDN,IAAI,CAACK,QAAQ,GAAGI,GAAAA;YAEhB,OAAOT,IAAI,CAACK,OAAQ,CAAA;AACtB;AACF,KAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-fields.js","sources":["../../src/registries/custom-fields.ts"],"sourcesContent":["import { has, isPlainObject } from 'lodash/fp';\n\nimport type { Core, Modules } from '@strapi/types';\n\nconst ALLOWED_TYPES = [\n 'biginteger',\n 'boolean',\n 'date',\n 'datetime',\n 'decimal',\n 'email',\n 'enumeration',\n 'float',\n 'integer',\n 'json',\n 'password',\n 'richtext',\n 'string',\n 'text',\n 'time',\n 'uid',\n] as const;\n\nconst customFieldsRegistry = (strapi: Core.Strapi) => {\n const customFields: Record<string, unknown> = {};\n\n return {\n getAll() {\n return customFields;\n },\n get(customField: string) {\n const registeredCustomField = customFields[customField];\n if (!registeredCustomField) {\n throw new Error(`Could not find Custom Field: ${customField}`);\n }\n\n return registeredCustomField;\n },\n add(\n customField:\n | Modules.CustomFields.CustomFieldServerOptions\n | Modules.CustomFields.CustomFieldServerOptions[]\n ) {\n const customFieldList = Array.isArray(customField) ? customField : [customField];\n\n for (const cf of customFieldList) {\n if (!has('name', cf) || !has('type', cf)) {\n throw new Error(`Custom fields require a 'name' and 'type' key`);\n }\n\n const { name, plugin, type, inputSize } = cf;\n if (!ALLOWED_TYPES.includes(type)) {\n throw new Error(\n `Custom field type: '${type}' is not a valid Strapi type or it can't be used with a Custom Field`\n );\n }\n\n const isValidObjectKey = /^(?![0-9])[a-zA-Z0-9$_-]+$/g;\n if (!isValidObjectKey.test(name)) {\n throw new Error(`Custom field name: '${name}' is not a valid object key`);\n }\n\n // Validate inputSize when provided\n if (inputSize) {\n if (\n !isPlainObject(inputSize) ||\n !has('default', inputSize) ||\n !has('isResizable', inputSize)\n ) {\n throw new Error(`inputSize should be an object with 'default' and 'isResizable' keys`);\n }\n if (![4, 6, 8, 12].includes(inputSize.default)) {\n throw new Error('Custom fields require a valid default input size');\n }\n if (typeof inputSize.isResizable !== 'boolean') {\n throw new Error('Custom fields should specify if their input is resizable');\n }\n }\n\n // When no plugin is specified, or it isn't found in Strapi, default to global\n const uid =\n plugin && strapi.plugin(plugin) ? `plugin::${plugin}.${name}` : `global::${name}`;\n\n if (has(uid, customFields)) {\n throw new Error(`Custom field: '${uid}' has already been registered`);\n }\n\n customFields[uid] = cf;\n }\n },\n };\n};\n\nexport default customFieldsRegistry;\n"],"names":["ALLOWED_TYPES","customFieldsRegistry","strapi","customFields","getAll","get","customField","registeredCustomField","Error","add","customFieldList","Array","isArray","cf","has","name","plugin","type","inputSize","includes","isValidObjectKey","test","isPlainObject","default","isResizable","uid"],"mappings":";;;;AAIA,MAAMA,aAAgB,GAAA;AACpB,IAAA,YAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,SAAA;AACA,IAAA,OAAA;AACA,IAAA,aAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,UAAA;AACA,IAAA,QAAA;AACA,IAAA,MAAA;AACA,IAAA,MAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,uBAAuB,CAACC,MAAAA,GAAAA;AAC5B,IAAA,MAAMC,eAAwC,EAAC;IAE/C,OAAO;AACLC,QAAAA,MAAAA,CAAAA,GAAAA;YACE,OAAOD,YAAAA;AACT,SAAA;AACAE,QAAAA,GAAAA,CAAAA,CAAIC,WAAmB,EAAA;YACrB,MAAMC,qBAAAA,GAAwBJ,YAAY,CAACG,WAAY,CAAA;AACvD,YAAA,IAAI,CAACC,qBAAuB,EAAA;AAC1B,gBAAA,MAAM,IAAIC,
|
|
1
|
+
{"version":3,"file":"custom-fields.js","sources":["../../src/registries/custom-fields.ts"],"sourcesContent":["import { has, isPlainObject } from 'lodash/fp';\n\nimport type { Core, Modules } from '@strapi/types';\n\nconst ALLOWED_TYPES = [\n 'biginteger',\n 'boolean',\n 'date',\n 'datetime',\n 'decimal',\n 'email',\n 'enumeration',\n 'float',\n 'integer',\n 'json',\n 'password',\n 'richtext',\n 'string',\n 'text',\n 'time',\n 'uid',\n] as const;\n\nconst customFieldsRegistry = (strapi: Core.Strapi) => {\n const customFields: Record<string, unknown> = {};\n\n return {\n getAll() {\n return customFields;\n },\n get(customField: string) {\n const registeredCustomField = customFields[customField];\n if (!registeredCustomField) {\n throw new Error(`Could not find Custom Field: ${customField}`);\n }\n\n return registeredCustomField;\n },\n add(\n customField:\n | Modules.CustomFields.CustomFieldServerOptions\n | Modules.CustomFields.CustomFieldServerOptions[]\n ) {\n const customFieldList = Array.isArray(customField) ? customField : [customField];\n\n for (const cf of customFieldList) {\n if (!has('name', cf) || !has('type', cf)) {\n throw new Error(`Custom fields require a 'name' and 'type' key`);\n }\n\n const { name, plugin, type, inputSize } = cf;\n if (!ALLOWED_TYPES.includes(type)) {\n throw new Error(\n `Custom field type: '${type}' is not a valid Strapi type or it can't be used with a Custom Field`\n );\n }\n\n const isValidObjectKey = /^(?![0-9])[a-zA-Z0-9$_-]+$/g;\n if (!isValidObjectKey.test(name)) {\n throw new Error(`Custom field name: '${name}' is not a valid object key`);\n }\n\n // Validate inputSize when provided\n if (inputSize) {\n if (\n !isPlainObject(inputSize) ||\n !has('default', inputSize) ||\n !has('isResizable', inputSize)\n ) {\n throw new Error(`inputSize should be an object with 'default' and 'isResizable' keys`);\n }\n if (![4, 6, 8, 12].includes(inputSize.default)) {\n throw new Error('Custom fields require a valid default input size');\n }\n if (typeof inputSize.isResizable !== 'boolean') {\n throw new Error('Custom fields should specify if their input is resizable');\n }\n }\n\n // When no plugin is specified, or it isn't found in Strapi, default to global\n const uid =\n plugin && strapi.plugin(plugin) ? `plugin::${plugin}.${name}` : `global::${name}`;\n\n if (has(uid, customFields)) {\n throw new Error(`Custom field: '${uid}' has already been registered`);\n }\n\n customFields[uid] = cf;\n }\n },\n };\n};\n\nexport default customFieldsRegistry;\n"],"names":["ALLOWED_TYPES","customFieldsRegistry","strapi","customFields","getAll","get","customField","registeredCustomField","Error","add","customFieldList","Array","isArray","cf","has","name","plugin","type","inputSize","includes","isValidObjectKey","test","isPlainObject","default","isResizable","uid"],"mappings":";;;;AAIA,MAAMA,aAAgB,GAAA;AACpB,IAAA,YAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,SAAA;AACA,IAAA,OAAA;AACA,IAAA,aAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,UAAA;AACA,IAAA,QAAA;AACA,IAAA,MAAA;AACA,IAAA,MAAA;AACA,IAAA;AACD,CAAA;AAED,M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AA2B,CAAC,CAAA;AAC1E;;AAGA,gBAAA,IAAIG,SAAW,EAAA;oBACb,IACE,CAACI,gBAAcJ,CAAAA,SAAAA,CAAAA,IACf,CAACJ,MAAAA,CAAI,WAAWI,SAChB,CAAA,IAAA,CAACJ,MAAI,CAAA,aAAA,EAAeI,SACpB,CAAA,EAAA;AACA,wBAAA,MAAM,IAAIV,KAAAA,CAAM,CAAC,mEAAmE,CAAC,CAAA;AACvF;AACA,oBAAA,IAAI,CAAC;AAAC,wBAAA,CAAA;AAAG,wBAAA,CAAA;AAAG,wBAAA,CAAA;AAAG,wBAAA;AAAG,qBAAA,CAACW,QAAQ,CAACD,SAAUK,CAAAA,OAAO,CAAG,EAAA;AAC9C,wBAAA,MAAM,IAAIf,KAAM,CAAA,kDAAA,CAAA;AAClB;AACA,oBAAA,IAAI,OAAOU,SAAAA,CAAUM,WAAW,KAAK,SAAW,EAAA;AAC9C,wBAAA,MAAM,IAAIhB,KAAM,CAAA,0DAAA,CAAA;AAClB;AACF;;AAGA,gBAAA,MAAMiB,MACJT,MAAUd,IAAAA,MAAAA,CAAOc,MAAM,CAACA,UAAU,CAAC,QAAQ,EAAEA,MAAAA,CAAO,CAAC,EAAED,IAAAA,CAAAA,CAAM,GAAG,CAAC,QAAQ,EAAEA,IAAM,CAAA,CAAA;gBAEnF,IAAID,MAAAA,CAAIW,KAAKtB,YAAe,CAAA,EAAA;AAC1B,oBAAA,MAAM,IAAIK,KAAM,CAAA,CAAC,eAAe,EAAEiB,GAAAA,CAAI,6BAA6B,CAAC,CAAA;AACtE;gBAEAtB,YAAY,CAACsB,IAAI,GAAGZ,EAAAA;AACtB;AACF;AACF,KAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-fields.mjs","sources":["../../src/registries/custom-fields.ts"],"sourcesContent":["import { has, isPlainObject } from 'lodash/fp';\n\nimport type { Core, Modules } from '@strapi/types';\n\nconst ALLOWED_TYPES = [\n 'biginteger',\n 'boolean',\n 'date',\n 'datetime',\n 'decimal',\n 'email',\n 'enumeration',\n 'float',\n 'integer',\n 'json',\n 'password',\n 'richtext',\n 'string',\n 'text',\n 'time',\n 'uid',\n] as const;\n\nconst customFieldsRegistry = (strapi: Core.Strapi) => {\n const customFields: Record<string, unknown> = {};\n\n return {\n getAll() {\n return customFields;\n },\n get(customField: string) {\n const registeredCustomField = customFields[customField];\n if (!registeredCustomField) {\n throw new Error(`Could not find Custom Field: ${customField}`);\n }\n\n return registeredCustomField;\n },\n add(\n customField:\n | Modules.CustomFields.CustomFieldServerOptions\n | Modules.CustomFields.CustomFieldServerOptions[]\n ) {\n const customFieldList = Array.isArray(customField) ? customField : [customField];\n\n for (const cf of customFieldList) {\n if (!has('name', cf) || !has('type', cf)) {\n throw new Error(`Custom fields require a 'name' and 'type' key`);\n }\n\n const { name, plugin, type, inputSize } = cf;\n if (!ALLOWED_TYPES.includes(type)) {\n throw new Error(\n `Custom field type: '${type}' is not a valid Strapi type or it can't be used with a Custom Field`\n );\n }\n\n const isValidObjectKey = /^(?![0-9])[a-zA-Z0-9$_-]+$/g;\n if (!isValidObjectKey.test(name)) {\n throw new Error(`Custom field name: '${name}' is not a valid object key`);\n }\n\n // Validate inputSize when provided\n if (inputSize) {\n if (\n !isPlainObject(inputSize) ||\n !has('default', inputSize) ||\n !has('isResizable', inputSize)\n ) {\n throw new Error(`inputSize should be an object with 'default' and 'isResizable' keys`);\n }\n if (![4, 6, 8, 12].includes(inputSize.default)) {\n throw new Error('Custom fields require a valid default input size');\n }\n if (typeof inputSize.isResizable !== 'boolean') {\n throw new Error('Custom fields should specify if their input is resizable');\n }\n }\n\n // When no plugin is specified, or it isn't found in Strapi, default to global\n const uid =\n plugin && strapi.plugin(plugin) ? `plugin::${plugin}.${name}` : `global::${name}`;\n\n if (has(uid, customFields)) {\n throw new Error(`Custom field: '${uid}' has already been registered`);\n }\n\n customFields[uid] = cf;\n }\n },\n };\n};\n\nexport default customFieldsRegistry;\n"],"names":["ALLOWED_TYPES","customFieldsRegistry","strapi","customFields","getAll","get","customField","registeredCustomField","Error","add","customFieldList","Array","isArray","cf","has","name","plugin","type","inputSize","includes","isValidObjectKey","test","isPlainObject","default","isResizable","uid"],"mappings":";;AAIA,MAAMA,aAAgB,GAAA;AACpB,IAAA,YAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,SAAA;AACA,IAAA,OAAA;AACA,IAAA,aAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,UAAA;AACA,IAAA,QAAA;AACA,IAAA,MAAA;AACA,IAAA,MAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,uBAAuB,CAACC,MAAAA,GAAAA;AAC5B,IAAA,MAAMC,eAAwC,EAAC;IAE/C,OAAO;AACLC,QAAAA,MAAAA,CAAAA,GAAAA;YACE,OAAOD,YAAAA;AACT,SAAA;AACAE,QAAAA,GAAAA,CAAAA,CAAIC,WAAmB,EAAA;YACrB,MAAMC,qBAAAA,GAAwBJ,YAAY,CAACG,WAAY,CAAA;AACvD,YAAA,IAAI,CAACC,qBAAuB,EAAA;AAC1B,gBAAA,MAAM,IAAIC,
|
|
1
|
+
{"version":3,"file":"custom-fields.mjs","sources":["../../src/registries/custom-fields.ts"],"sourcesContent":["import { has, isPlainObject } from 'lodash/fp';\n\nimport type { Core, Modules } from '@strapi/types';\n\nconst ALLOWED_TYPES = [\n 'biginteger',\n 'boolean',\n 'date',\n 'datetime',\n 'decimal',\n 'email',\n 'enumeration',\n 'float',\n 'integer',\n 'json',\n 'password',\n 'richtext',\n 'string',\n 'text',\n 'time',\n 'uid',\n] as const;\n\nconst customFieldsRegistry = (strapi: Core.Strapi) => {\n const customFields: Record<string, unknown> = {};\n\n return {\n getAll() {\n return customFields;\n },\n get(customField: string) {\n const registeredCustomField = customFields[customField];\n if (!registeredCustomField) {\n throw new Error(`Could not find Custom Field: ${customField}`);\n }\n\n return registeredCustomField;\n },\n add(\n customField:\n | Modules.CustomFields.CustomFieldServerOptions\n | Modules.CustomFields.CustomFieldServerOptions[]\n ) {\n const customFieldList = Array.isArray(customField) ? customField : [customField];\n\n for (const cf of customFieldList) {\n if (!has('name', cf) || !has('type', cf)) {\n throw new Error(`Custom fields require a 'name' and 'type' key`);\n }\n\n const { name, plugin, type, inputSize } = cf;\n if (!ALLOWED_TYPES.includes(type)) {\n throw new Error(\n `Custom field type: '${type}' is not a valid Strapi type or it can't be used with a Custom Field`\n );\n }\n\n const isValidObjectKey = /^(?![0-9])[a-zA-Z0-9$_-]+$/g;\n if (!isValidObjectKey.test(name)) {\n throw new Error(`Custom field name: '${name}' is not a valid object key`);\n }\n\n // Validate inputSize when provided\n if (inputSize) {\n if (\n !isPlainObject(inputSize) ||\n !has('default', inputSize) ||\n !has('isResizable', inputSize)\n ) {\n throw new Error(`inputSize should be an object with 'default' and 'isResizable' keys`);\n }\n if (![4, 6, 8, 12].includes(inputSize.default)) {\n throw new Error('Custom fields require a valid default input size');\n }\n if (typeof inputSize.isResizable !== 'boolean') {\n throw new Error('Custom fields should specify if their input is resizable');\n }\n }\n\n // When no plugin is specified, or it isn't found in Strapi, default to global\n const uid =\n plugin && strapi.plugin(plugin) ? `plugin::${plugin}.${name}` : `global::${name}`;\n\n if (has(uid, customFields)) {\n throw new Error(`Custom field: '${uid}' has already been registered`);\n }\n\n customFields[uid] = cf;\n }\n },\n };\n};\n\nexport default customFieldsRegistry;\n"],"names":["ALLOWED_TYPES","customFieldsRegistry","strapi","customFields","getAll","get","customField","registeredCustomField","Error","add","customFieldList","Array","isArray","cf","has","name","plugin","type","inputSize","includes","isValidObjectKey","test","isPlainObject","default","isResizable","uid"],"mappings":";;AAIA,MAAMA,aAAgB,GAAA;AACpB,IAAA,YAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,SAAA;AACA,IAAA,OAAA;AACA,IAAA,aAAA;A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
1
|
-
{"version":3,"file":"namespace.js","sources":["../../src/registries/namespace.ts"],"sourcesContent":["const hasNamespace = (name: string, namespace: string) => {\n if (!namespace) {\n return true;\n }\n\n if (namespace.endsWith('::')) {\n return name.startsWith(namespace);\n }\n return name.startsWith(`${namespace}.`);\n};\n\nconst addNamespace = (name: string, namespace: string) => {\n if (namespace.endsWith('::')) {\n return `${namespace}${name}`;\n }\n return `${namespace}.${name}`;\n};\n\nconst removeNamespace = (name: string, namespace: string) => {\n if (namespace.endsWith('::')) {\n return name.replace(namespace, '');\n }\n return name.replace(`${namespace}.`, '');\n};\n\nexport { addNamespace, removeNamespace, hasNamespace };\n"],"names":["hasNamespace","name","namespace","endsWith","startsWith","addNamespace","removeNamespace","replace"],"mappings":";;AAAMA,MAAAA,YAAAA,GAAe,CAACC,IAAcC,EAAAA,SAAAA,GAAAA;AAClC,IAAA,IAAI,CAACA,SAAW,EAAA;QACd,OAAO,IAAA;AACT;IAEA,IAAIA,SAAAA,CAAUC,QAAQ,CAAC,IAAO,CAAA,EAAA;QAC5B,OAAOF,IAAAA,CAAKG,UAAU,CAACF,SAAAA,CAAAA;AACzB;AACA,IAAA,OAAOD,KAAKG,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"namespace.js","sources":["../../src/registries/namespace.ts"],"sourcesContent":["const hasNamespace = (name: string, namespace: string) => {\n if (!namespace) {\n return true;\n }\n\n if (namespace.endsWith('::')) {\n return name.startsWith(namespace);\n }\n return name.startsWith(`${namespace}.`);\n};\n\nconst addNamespace = (name: string, namespace: string) => {\n if (namespace.endsWith('::')) {\n return `${namespace}${name}`;\n }\n return `${namespace}.${name}`;\n};\n\nconst removeNamespace = (name: string, namespace: string) => {\n if (namespace.endsWith('::')) {\n return name.replace(namespace, '');\n }\n return name.replace(`${namespace}.`, '');\n};\n\nexport { addNamespace, removeNamespace, hasNamespace };\n"],"names":["hasNamespace","name","namespace","endsWith","startsWith","addNamespace","removeNamespace","replace"],"mappings":";;AAAMA,MAAAA,YAAAA,GAAe,CAACC,IAAcC,EAAAA,SAAAA,GAAAA;AAClC,IAAA,IAAI,CAACA,SAAW,EAAA;QACd,OAAO,IAAA;AACT;IAEA,IAAIA,SAAAA,CAAUC,QAAQ,CAAC,IAAO,CAAA,EAAA;QAC5B,OAAOF,IAAAA,CAAKG,UAAU,CAACF,SAAAA,CAAAA;AACzB;AACA,IAAA,OAAOD,KAAKG,UAAU,CAAC,CAAGF,EAAAA,SAAAA,CAAU,CAAC,CAAC,CAAA;AACxC;AAEMG,MAAAA,YAAAA,GAAe,CAACJ,IAAcC,EAAAA,SAAAA,GAAAA;IAClC,IAAIA,SAAAA,CAAUC,QAAQ,CAAC,IAAO,CAAA,EAAA;QAC5B,OAAO,CAAA,EAAGD,YAAYD,IAAM,CAAA,CAAA;AAC9B;AACA,IAAA,OAAO,CAAGC,EAAAA,SAAAA,CAAU,CAAC,EAAED,IAAM,CAAA,CAAA;AAC/B;AAEMK,MAAAA,eAAAA,GAAkB,CAACL,IAAcC,EAAAA,SAAAA,GAAAA;IACrC,IAAIA,SAAAA,CAAUC,QAAQ,CAAC,IAAO,CAAA,EAAA;QAC5B,OAAOF,IAAAA,CAAKM,OAAO,CAACL,SAAW,EAAA,EAAA,CAAA;AACjC;AACA,IAAA,OAAOD,KAAKM,OAAO,CAAC,GAAGL,SAAU,CAAA,CAAC,CAAC,EAAE,EAAA,CAAA;AACvC;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespace.mjs","sources":["../../src/registries/namespace.ts"],"sourcesContent":["const hasNamespace = (name: string, namespace: string) => {\n if (!namespace) {\n return true;\n }\n\n if (namespace.endsWith('::')) {\n return name.startsWith(namespace);\n }\n return name.startsWith(`${namespace}.`);\n};\n\nconst addNamespace = (name: string, namespace: string) => {\n if (namespace.endsWith('::')) {\n return `${namespace}${name}`;\n }\n return `${namespace}.${name}`;\n};\n\nconst removeNamespace = (name: string, namespace: string) => {\n if (namespace.endsWith('::')) {\n return name.replace(namespace, '');\n }\n return name.replace(`${namespace}.`, '');\n};\n\nexport { addNamespace, removeNamespace, hasNamespace };\n"],"names":["hasNamespace","name","namespace","endsWith","startsWith","addNamespace","removeNamespace","replace"],"mappings":"AAAMA,MAAAA,YAAAA,GAAe,CAACC,IAAcC,EAAAA,SAAAA,GAAAA;AAClC,IAAA,IAAI,CAACA,SAAW,EAAA;QACd,OAAO,IAAA;AACT;IAEA,IAAIA,SAAAA,CAAUC,QAAQ,CAAC,IAAO,CAAA,EAAA;QAC5B,OAAOF,IAAAA,CAAKG,UAAU,CAACF,SAAAA,CAAAA;AACzB;AACA,IAAA,OAAOD,KAAKG,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"namespace.mjs","sources":["../../src/registries/namespace.ts"],"sourcesContent":["const hasNamespace = (name: string, namespace: string) => {\n if (!namespace) {\n return true;\n }\n\n if (namespace.endsWith('::')) {\n return name.startsWith(namespace);\n }\n return name.startsWith(`${namespace}.`);\n};\n\nconst addNamespace = (name: string, namespace: string) => {\n if (namespace.endsWith('::')) {\n return `${namespace}${name}`;\n }\n return `${namespace}.${name}`;\n};\n\nconst removeNamespace = (name: string, namespace: string) => {\n if (namespace.endsWith('::')) {\n return name.replace(namespace, '');\n }\n return name.replace(`${namespace}.`, '');\n};\n\nexport { addNamespace, removeNamespace, hasNamespace };\n"],"names":["hasNamespace","name","namespace","endsWith","startsWith","addNamespace","removeNamespace","replace"],"mappings":"AAAMA,MAAAA,YAAAA,GAAe,CAACC,IAAcC,EAAAA,SAAAA,GAAAA;AAClC,IAAA,IAAI,CAACA,SAAW,EAAA;QACd,OAAO,IAAA;AACT;IAEA,IAAIA,SAAAA,CAAUC,QAAQ,CAAC,IAAO,CAAA,EAAA;QAC5B,OAAOF,IAAAA,CAAKG,UAAU,CAACF,SAAAA,CAAAA;AACzB;AACA,IAAA,OAAOD,KAAKG,UAAU,CAAC,CAAGF,EAAAA,SAAAA,CAAU,CAAC,CAAC,CAAA;AACxC;AAEMG,MAAAA,YAAAA,GAAe,CAACJ,IAAcC,EAAAA,SAAAA,GAAAA;IAClC,IAAIA,SAAAA,CAAUC,QAAQ,CAAC,IAAO,CAAA,EAAA;QAC5B,OAAO,CAAA,EAAGD,YAAYD,IAAM,CAAA,CAAA;AAC9B;AACA,IAAA,OAAO,CAAGC,EAAAA,SAAAA,CAAU,CAAC,EAAED,IAAM,CAAA,CAAA;AAC/B;AAEMK,MAAAA,eAAAA,GAAkB,CAACL,IAAcC,EAAAA,SAAAA,GAAAA;IACrC,IAAIA,SAAAA,CAAUC,QAAQ,CAAC,IAAO,CAAA,EAAA;QAC5B,OAAOF,IAAAA,CAAKM,OAAO,CAACL,SAAW,EAAA,EAAA,CAAA;AACjC;AACA,IAAA,OAAOD,KAAKM,OAAO,CAAC,GAAGL,SAAU,CAAA,CAAC,CAAC,EAAE,EAAA,CAAA;AACvC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.js","sources":["../../src/registries/plugins.ts"],"sourcesContent":["import { has } from 'lodash/fp';\n\nimport type { Core } from '@strapi/types';\n\ntype PluginMap = Record<string, Core.Plugin>;\n\nconst pluginsRegistry = (strapi: Core.Strapi) => {\n const plugins: PluginMap = {};\n\n return {\n get(name: string) {\n return plugins[name];\n },\n getAll() {\n return plugins;\n },\n add(name: string, pluginConfig: Core.Plugin) {\n if (has(name, plugins)) {\n throw new Error(`Plugin ${name} has already been registered.`);\n }\n\n const pluginModule = strapi.get('modules').add(`plugin::${name}`, pluginConfig);\n plugins[name] = pluginModule;\n\n return plugins[name];\n },\n };\n};\n\nexport default pluginsRegistry;\n"],"names":["pluginsRegistry","strapi","plugins","get","name","getAll","add","pluginConfig","has","Error","pluginModule"],"mappings":";;;;AAMA,MAAMA,kBAAkB,CAACC,MAAAA,GAAAA;AACvB,IAAA,MAAMC,UAAqB,EAAC;IAE5B,OAAO;AACLC,QAAAA,GAAAA,CAAAA,CAAIC,IAAY,EAAA;YACd,OAAOF,OAAO,CAACE,IAAK,CAAA;AACtB,SAAA;AACAC,QAAAA,MAAAA,CAAAA,GAAAA;YACE,OAAOH,OAAAA;AACT,SAAA;QACAI,GAAIF,CAAAA,CAAAA,IAAY,EAAEG,YAAyB,EAAA;YACzC,IAAIC,MAAAA,CAAIJ,MAAMF,OAAU,CAAA,EAAA;AACtB,gBAAA,MAAM,IAAIO,KAAM,CAAA,CAAC,OAAO,EAAEL,IAAAA,CAAK,6BAA6B,CAAC,CAAA;AAC/D;
|
|
1
|
+
{"version":3,"file":"plugins.js","sources":["../../src/registries/plugins.ts"],"sourcesContent":["import { has } from 'lodash/fp';\n\nimport type { Core } from '@strapi/types';\n\ntype PluginMap = Record<string, Core.Plugin>;\n\nconst pluginsRegistry = (strapi: Core.Strapi) => {\n const plugins: PluginMap = {};\n\n return {\n get(name: string) {\n return plugins[name];\n },\n getAll() {\n return plugins;\n },\n add(name: string, pluginConfig: Core.Plugin) {\n if (has(name, plugins)) {\n throw new Error(`Plugin ${name} has already been registered.`);\n }\n\n const pluginModule = strapi.get('modules').add(`plugin::${name}`, pluginConfig);\n plugins[name] = pluginModule;\n\n return plugins[name];\n },\n };\n};\n\nexport default pluginsRegistry;\n"],"names":["pluginsRegistry","strapi","plugins","get","name","getAll","add","pluginConfig","has","Error","pluginModule"],"mappings":";;;;AAMA,MAAMA,kBAAkB,CAACC,MAAAA,GAAAA;AACvB,IAAA,MAAMC,UAAqB,EAAC;IAE5B,OAAO;AACLC,QAAAA,GAAAA,CAAAA,CAAIC,IAAY,EAAA;YACd,OAAOF,OAAO,CAACE,IAAK,CAAA;AACtB,SAAA;AACAC,QAAAA,MAAAA,CAAAA,GAAAA;YACE,OAAOH,OAAAA;AACT,SAAA;QACAI,GAAIF,CAAAA,CAAAA,IAAY,EAAEG,YAAyB,EAAA;YACzC,IAAIC,MAAAA,CAAIJ,MAAMF,OAAU,CAAA,EAAA;AACtB,gBAAA,MAAM,IAAIO,KAAM,CAAA,CAAC,OAAO,EAAEL,IAAAA,CAAK,6BAA6B,CAAC,CAAA;AAC/D;YAEA,MAAMM,YAAAA,GAAeT,MAAOE,CAAAA,GAAG,CAAC,SAAA,CAAA,CAAWG,GAAG,CAAC,CAAC,QAAQ,EAAEF,IAAAA,CAAAA,CAAM,EAAEG,YAAAA,CAAAA;YAClEL,OAAO,CAACE,KAAK,GAAGM,YAAAA;YAEhB,OAAOR,OAAO,CAACE,IAAK,CAAA;AACtB;AACF,KAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.mjs","sources":["../../src/registries/plugins.ts"],"sourcesContent":["import { has } from 'lodash/fp';\n\nimport type { Core } from '@strapi/types';\n\ntype PluginMap = Record<string, Core.Plugin>;\n\nconst pluginsRegistry = (strapi: Core.Strapi) => {\n const plugins: PluginMap = {};\n\n return {\n get(name: string) {\n return plugins[name];\n },\n getAll() {\n return plugins;\n },\n add(name: string, pluginConfig: Core.Plugin) {\n if (has(name, plugins)) {\n throw new Error(`Plugin ${name} has already been registered.`);\n }\n\n const pluginModule = strapi.get('modules').add(`plugin::${name}`, pluginConfig);\n plugins[name] = pluginModule;\n\n return plugins[name];\n },\n };\n};\n\nexport default pluginsRegistry;\n"],"names":["pluginsRegistry","strapi","plugins","get","name","getAll","add","pluginConfig","has","Error","pluginModule"],"mappings":";;AAMA,MAAMA,kBAAkB,CAACC,MAAAA,GAAAA;AACvB,IAAA,MAAMC,UAAqB,EAAC;IAE5B,OAAO;AACLC,QAAAA,GAAAA,CAAAA,CAAIC,IAAY,EAAA;YACd,OAAOF,OAAO,CAACE,IAAK,CAAA;AACtB,SAAA;AACAC,QAAAA,MAAAA,CAAAA,GAAAA;YACE,OAAOH,OAAAA;AACT,SAAA;QACAI,GAAIF,CAAAA,CAAAA,IAAY,EAAEG,YAAyB,EAAA;YACzC,IAAIC,GAAAA,CAAIJ,MAAMF,OAAU,CAAA,EAAA;AACtB,gBAAA,MAAM,IAAIO,KAAM,CAAA,CAAC,OAAO,EAAEL,IAAAA,CAAK,6BAA6B,CAAC,CAAA;AAC/D;
|
|
1
|
+
{"version":3,"file":"plugins.mjs","sources":["../../src/registries/plugins.ts"],"sourcesContent":["import { has } from 'lodash/fp';\n\nimport type { Core } from '@strapi/types';\n\ntype PluginMap = Record<string, Core.Plugin>;\n\nconst pluginsRegistry = (strapi: Core.Strapi) => {\n const plugins: PluginMap = {};\n\n return {\n get(name: string) {\n return plugins[name];\n },\n getAll() {\n return plugins;\n },\n add(name: string, pluginConfig: Core.Plugin) {\n if (has(name, plugins)) {\n throw new Error(`Plugin ${name} has already been registered.`);\n }\n\n const pluginModule = strapi.get('modules').add(`plugin::${name}`, pluginConfig);\n plugins[name] = pluginModule;\n\n return plugins[name];\n },\n };\n};\n\nexport default pluginsRegistry;\n"],"names":["pluginsRegistry","strapi","plugins","get","name","getAll","add","pluginConfig","has","Error","pluginModule"],"mappings":";;AAMA,MAAMA,kBAAkB,CAACC,MAAAA,GAAAA;AACvB,IAAA,MAAMC,UAAqB,EAAC;IAE5B,OAAO;AACLC,QAAAA,GAAAA,CAAAA,CAAIC,IAAY,EAAA;YACd,OAAOF,OAAO,CAACE,IAAK,CAAA;AACtB,SAAA;AACAC,QAAAA,MAAAA,CAAAA,GAAAA;YACE,OAAOH,OAAAA;AACT,SAAA;QACAI,GAAIF,CAAAA,CAAAA,IAAY,EAAEG,YAAyB,EAAA;YACzC,IAAIC,GAAAA,CAAIJ,MAAMF,OAAU,CAAA,EAAA;AACtB,gBAAA,MAAM,IAAIO,KAAM,CAAA,CAAC,OAAO,EAAEL,IAAAA,CAAK,6BAA6B,CAAC,CAAA;AAC/D;YAEA,MAAMM,YAAAA,GAAeT,MAAOE,CAAAA,GAAG,CAAC,SAAA,CAAA,CAAWG,GAAG,CAAC,CAAC,QAAQ,EAAEF,IAAAA,CAAAA,CAAM,EAAEG,YAAAA,CAAAA;YAClEL,OAAO,CAACE,KAAK,GAAGM,YAAAA;YAEhB,OAAOR,OAAO,CAACE,IAAK,CAAA;AACtB;AACF,KAAA;AACF;;;;"}
|