node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
/// <reference types="node" />
import { Duplex } from 'stream';
import type { Core } from '@strapi/types';
/**
* Generate and consume assets streams in order to stream each file individually
*/
export declare const createAssetsStream: (strapi: Core.Strapi) => Duplex;
//# sourceMappingURL=assets.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../../../src/strapi/providers/local-source/assets.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAyB,MAAM,QAAQ,CAAC;AAGvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AA0F1C;;GAEG;AACH,eAAO,MAAM,kBAAkB,WAAY,KAAK,MAAM,KAAG,MAiDxD,CAAC"}

View File

@@ -0,0 +1,123 @@
'use strict';
var path = require('path');
var stream = require('stream');
var fse = require('fs-extra');
function getFileStream(filepath, strapi1, isLocal = false) {
if (isLocal) {
// Todo: handle errors
return fse.createReadStream(filepath);
}
const readableStream = new stream.PassThrough();
// fetch the image from remote url and stream it
strapi1.fetch(filepath).then((res)=>{
if (res.status !== 200) {
readableStream.emit('error', new Error(`Request failed with status code ${res.status}`));
return;
}
if (res.body) {
// pipe the image data
stream.Readable.fromWeb(res.body).pipe(readableStream);
} else {
readableStream.emit('error', new Error('Empty data found for file'));
}
}).catch((error)=>{
readableStream.emit('error', error);
});
return readableStream;
}
function getFileStats(filepath, strapi1, isLocal = false) {
if (isLocal) {
return fse.stat(filepath);
}
return new Promise((resolve, reject)=>{
strapi1.fetch(filepath).then((res)=>{
if (res.status !== 200) {
reject(new Error(`Request failed with status code ${res.status}`));
return;
}
const contentLength = res.headers.get('content-length');
const stats = {
size: contentLength ? parseInt(contentLength, 10) : 0
};
resolve(stats);
}).catch((error)=>{
reject(error);
});
});
}
async function signFile(file) {
const { provider } = strapi.plugins.upload;
const { provider: providerName } = strapi.config.get('plugin.upload');
const isPrivate = await provider.isPrivate();
if (file?.provider === providerName && isPrivate) {
const signUrl = async (file)=>{
const signedUrl = await provider.getSignedUrl(file);
file.url = signedUrl.url;
};
// Sign the original file
await signUrl(file);
// Sign each file format
if (file.formats) {
for (const format of Object.keys(file.formats)){
await signUrl(file.formats[format]);
}
}
}
}
/**
* Generate and consume assets streams in order to stream each file individually
*/ const createAssetsStream = (strapi1)=>{
const generator = async function*() {
const stream = strapi1.db.queryBuilder('plugin::upload.file')// Create a query builder instance (default type is 'select')
// Fetch all columns
.select('*')// Get a readable stream
.stream();
for await (const file of stream){
const isLocalProvider = file.provider === 'local';
if (!isLocalProvider) {
await signFile(file);
}
const filepath = isLocalProvider ? path.join(strapi1.dirs.static.public, file.url) : file.url;
const stats = await getFileStats(filepath, strapi1, isLocalProvider);
const stream = getFileStream(filepath, strapi1, isLocalProvider);
yield {
metadata: file,
filepath,
filename: file.hash + file.ext,
stream,
stats: {
size: stats.size
}
};
if (file.formats) {
for (const format of Object.keys(file.formats)){
const fileFormat = file.formats[format];
const fileFormatFilepath = isLocalProvider ? path.join(strapi1.dirs.static.public, fileFormat.url) : fileFormat.url;
const fileFormatStats = await getFileStats(fileFormatFilepath, strapi1, isLocalProvider);
const fileFormatStream = getFileStream(fileFormatFilepath, strapi1, isLocalProvider);
const metadata = {
...fileFormat,
type: format,
id: file.id,
mainHash: file.hash
};
yield {
metadata,
filepath: fileFormatFilepath,
filename: fileFormat.hash + fileFormat.ext,
stream: fileFormatStream,
stats: {
size: fileFormatStats.size
}
};
}
}
}
};
return stream.Duplex.from(generator());
};
exports.createAssetsStream = createAssetsStream;
//# sourceMappingURL=assets.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,121 @@
import { join } from 'path';
import { Duplex, PassThrough, Readable } from 'stream';
import { createReadStream, stat } from 'fs-extra';
function getFileStream(filepath, strapi1, isLocal = false) {
if (isLocal) {
// Todo: handle errors
return createReadStream(filepath);
}
const readableStream = new PassThrough();
// fetch the image from remote url and stream it
strapi1.fetch(filepath).then((res)=>{
if (res.status !== 200) {
readableStream.emit('error', new Error(`Request failed with status code ${res.status}`));
return;
}
if (res.body) {
// pipe the image data
Readable.fromWeb(res.body).pipe(readableStream);
} else {
readableStream.emit('error', new Error('Empty data found for file'));
}
}).catch((error)=>{
readableStream.emit('error', error);
});
return readableStream;
}
function getFileStats(filepath, strapi1, isLocal = false) {
if (isLocal) {
return stat(filepath);
}
return new Promise((resolve, reject)=>{
strapi1.fetch(filepath).then((res)=>{
if (res.status !== 200) {
reject(new Error(`Request failed with status code ${res.status}`));
return;
}
const contentLength = res.headers.get('content-length');
const stats = {
size: contentLength ? parseInt(contentLength, 10) : 0
};
resolve(stats);
}).catch((error)=>{
reject(error);
});
});
}
async function signFile(file) {
const { provider } = strapi.plugins.upload;
const { provider: providerName } = strapi.config.get('plugin.upload');
const isPrivate = await provider.isPrivate();
if (file?.provider === providerName && isPrivate) {
const signUrl = async (file)=>{
const signedUrl = await provider.getSignedUrl(file);
file.url = signedUrl.url;
};
// Sign the original file
await signUrl(file);
// Sign each file format
if (file.formats) {
for (const format of Object.keys(file.formats)){
await signUrl(file.formats[format]);
}
}
}
}
/**
* Generate and consume assets streams in order to stream each file individually
*/ const createAssetsStream = (strapi1)=>{
const generator = async function*() {
const stream = strapi1.db.queryBuilder('plugin::upload.file')// Create a query builder instance (default type is 'select')
// Fetch all columns
.select('*')// Get a readable stream
.stream();
for await (const file of stream){
const isLocalProvider = file.provider === 'local';
if (!isLocalProvider) {
await signFile(file);
}
const filepath = isLocalProvider ? join(strapi1.dirs.static.public, file.url) : file.url;
const stats = await getFileStats(filepath, strapi1, isLocalProvider);
const stream = getFileStream(filepath, strapi1, isLocalProvider);
yield {
metadata: file,
filepath,
filename: file.hash + file.ext,
stream,
stats: {
size: stats.size
}
};
if (file.formats) {
for (const format of Object.keys(file.formats)){
const fileFormat = file.formats[format];
const fileFormatFilepath = isLocalProvider ? join(strapi1.dirs.static.public, fileFormat.url) : fileFormat.url;
const fileFormatStats = await getFileStats(fileFormatFilepath, strapi1, isLocalProvider);
const fileFormatStream = getFileStream(fileFormatFilepath, strapi1, isLocalProvider);
const metadata = {
...fileFormat,
type: format,
id: file.id,
mainHash: file.hash
};
yield {
metadata,
filepath: fileFormatFilepath,
filename: fileFormat.hash + fileFormat.ext,
stream: fileFormatStream,
stats: {
size: fileFormatStats.size
}
};
}
}
}
};
return Duplex.from(generator());
};
export { createAssetsStream };
//# sourceMappingURL=assets.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,8 @@
/// <reference types="node" />
import { Readable } from 'stream';
import type { Core } from '@strapi/types';
/**
* Create a readable stream that export the Strapi app configuration
*/
export declare const createConfigurationStream: (strapi: Core.Strapi) => Readable;
//# sourceMappingURL=configuration.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../../src/strapi/providers/local-source/configuration.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGlC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAI1C;;GAEG;AACH,eAAO,MAAM,yBAAyB,WAAY,KAAK,MAAM,KAAG,QAyB/D,CAAC"}

View File

@@ -0,0 +1,39 @@
'use strict';
var stream = require('stream');
var streamChain = require('stream-chain');
var fp = require('lodash/fp');
/**
* Create a readable stream that export the Strapi app configuration
*/ const createConfigurationStream = (strapi)=>{
return stream.Readable.from(async function* configurationGenerator() {
// Core Store
const coreStoreStream = streamChain.chain([
strapi.db.queryBuilder('strapi::core-store').stream(),
(data)=>fp.set('value', JSON.parse(data.value), data),
wrapConfigurationItem('core-store')
]);
// Webhook
const webhooksStream = streamChain.chain([
strapi.db.queryBuilder('strapi::webhook').stream(),
wrapConfigurationItem('webhook')
]);
const streams = [
coreStoreStream,
webhooksStream
];
for (const stream of streams){
for await (const item of stream){
yield item;
}
}
}());
};
const wrapConfigurationItem = (type)=>(value)=>({
type,
value
});
exports.createConfigurationStream = createConfigurationStream;
//# sourceMappingURL=configuration.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"configuration.js","sources":["../../../../src/strapi/providers/local-source/configuration.ts"],"sourcesContent":["import { Readable } from 'stream';\nimport { chain } from 'stream-chain';\nimport { set } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\n\nimport type { IConfiguration } from '../../../../types';\n\n/**\n * Create a readable stream that export the Strapi app configuration\n */\nexport const createConfigurationStream = (strapi: Core.Strapi): Readable => {\n return Readable.from(\n (async function* configurationGenerator(): AsyncGenerator<IConfiguration> {\n // Core Store\n const coreStoreStream = chain([\n strapi.db.queryBuilder('strapi::core-store').stream(),\n (data) => set('value', JSON.parse(data.value), data),\n wrapConfigurationItem('core-store'),\n ]);\n\n // Webhook\n const webhooksStream = chain([\n strapi.db.queryBuilder('strapi::webhook').stream(),\n wrapConfigurationItem('webhook'),\n ]);\n\n const streams = [coreStoreStream, webhooksStream];\n\n for (const stream of streams) {\n for await (const item of stream) {\n yield item;\n }\n }\n })()\n );\n};\n\nconst wrapConfigurationItem = (type: 'core-store' | 'webhook') => (value: unknown) => ({\n type,\n value,\n});\n"],"names":["createConfigurationStream","strapi","Readable","from","configurationGenerator","coreStoreStream","chain","db","queryBuilder","stream","data","set","JSON","parse","value","wrapConfigurationItem","webhooksStream","streams","item","type"],"mappings":";;;;;;AAOA;;IAGaA,MAAAA,yBAAAA,GAA4B,CAACC,MAAAA,GAAAA;AACxC,IAAA,OAAOC,eAASC,CAAAA,IAAI,CACjB,gBAAgBC,sBAAAA,GAAAA;;AAEf,QAAA,MAAMC,kBAAkBC,iBAAM,CAAA;AAC5BL,YAAAA,MAAAA,CAAOM,EAAE,CAACC,YAAY,CAAC,sBAAsBC,MAAM,EAAA;YACnD,CAACC,IAAAA,GAASC,OAAI,OAASC,EAAAA,IAAAA,CAAKC,KAAK,CAACH,IAAAA,CAAKI,KAAK,CAAGJ,EAAAA,IAAAA,CAAAA;YAC/CK,qBAAsB,CAAA,YAAA;AACvB,SAAA,CAAA;;AAGD,QAAA,MAAMC,iBAAiBV,iBAAM,CAAA;AAC3BL,YAAAA,MAAAA,CAAOM,EAAE,CAACC,YAAY,CAAC,mBAAmBC,MAAM,EAAA;YAChDM,qBAAsB,CAAA,SAAA;AACvB,SAAA,CAAA;AAED,QAAA,MAAME,OAAU,GAAA;AAACZ,YAAAA,eAAAA;AAAiBW,YAAAA;AAAe,SAAA;QAEjD,KAAK,MAAMP,UAAUQ,OAAS,CAAA;YAC5B,WAAW,MAAMC,QAAQT,MAAQ,CAAA;gBAC/B,MAAMS,IAAAA;AACR;AACF;AACF,KAAA,EAAA,CAAA;AAEJ;AAEA,MAAMH,qBAAwB,GAAA,CAACI,IAAmC,GAAA,CAACL,SAAoB;AACrFK,YAAAA,IAAAA;AACAL,YAAAA;SACF,CAAA;;;;"}

View File

@@ -0,0 +1,37 @@
import { Readable } from 'stream';
import { chain } from 'stream-chain';
import { set } from 'lodash/fp';
/**
* Create a readable stream that export the Strapi app configuration
*/ const createConfigurationStream = (strapi)=>{
return Readable.from(async function* configurationGenerator() {
// Core Store
const coreStoreStream = chain([
strapi.db.queryBuilder('strapi::core-store').stream(),
(data)=>set('value', JSON.parse(data.value), data),
wrapConfigurationItem('core-store')
]);
// Webhook
const webhooksStream = chain([
strapi.db.queryBuilder('strapi::webhook').stream(),
wrapConfigurationItem('webhook')
]);
const streams = [
coreStoreStream,
webhooksStream
];
for (const stream of streams){
for await (const item of stream){
yield item;
}
}
}());
};
const wrapConfigurationItem = (type)=>(value)=>({
type,
value
});
export { createConfigurationStream };
//# sourceMappingURL=configuration.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"configuration.mjs","sources":["../../../../src/strapi/providers/local-source/configuration.ts"],"sourcesContent":["import { Readable } from 'stream';\nimport { chain } from 'stream-chain';\nimport { set } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\n\nimport type { IConfiguration } from '../../../../types';\n\n/**\n * Create a readable stream that export the Strapi app configuration\n */\nexport const createConfigurationStream = (strapi: Core.Strapi): Readable => {\n return Readable.from(\n (async function* configurationGenerator(): AsyncGenerator<IConfiguration> {\n // Core Store\n const coreStoreStream = chain([\n strapi.db.queryBuilder('strapi::core-store').stream(),\n (data) => set('value', JSON.parse(data.value), data),\n wrapConfigurationItem('core-store'),\n ]);\n\n // Webhook\n const webhooksStream = chain([\n strapi.db.queryBuilder('strapi::webhook').stream(),\n wrapConfigurationItem('webhook'),\n ]);\n\n const streams = [coreStoreStream, webhooksStream];\n\n for (const stream of streams) {\n for await (const item of stream) {\n yield item;\n }\n }\n })()\n );\n};\n\nconst wrapConfigurationItem = (type: 'core-store' | 'webhook') => (value: unknown) => ({\n type,\n value,\n});\n"],"names":["createConfigurationStream","strapi","Readable","from","configurationGenerator","coreStoreStream","chain","db","queryBuilder","stream","data","set","JSON","parse","value","wrapConfigurationItem","webhooksStream","streams","item","type"],"mappings":";;;;AAOA;;IAGaA,MAAAA,yBAAAA,GAA4B,CAACC,MAAAA,GAAAA;AACxC,IAAA,OAAOC,QAASC,CAAAA,IAAI,CACjB,gBAAgBC,sBAAAA,GAAAA;;AAEf,QAAA,MAAMC,kBAAkBC,KAAM,CAAA;AAC5BL,YAAAA,MAAAA,CAAOM,EAAE,CAACC,YAAY,CAAC,sBAAsBC,MAAM,EAAA;YACnD,CAACC,IAAAA,GAASC,IAAI,OAASC,EAAAA,IAAAA,CAAKC,KAAK,CAACH,IAAAA,CAAKI,KAAK,CAAGJ,EAAAA,IAAAA,CAAAA;YAC/CK,qBAAsB,CAAA,YAAA;AACvB,SAAA,CAAA;;AAGD,QAAA,MAAMC,iBAAiBV,KAAM,CAAA;AAC3BL,YAAAA,MAAAA,CAAOM,EAAE,CAACC,YAAY,CAAC,mBAAmBC,MAAM,EAAA;YAChDM,qBAAsB,CAAA,SAAA;AACvB,SAAA,CAAA;AAED,QAAA,MAAME,OAAU,GAAA;AAACZ,YAAAA,eAAAA;AAAiBW,YAAAA;AAAe,SAAA;QAEjD,KAAK,MAAMP,UAAUQ,OAAS,CAAA;YAC5B,WAAW,MAAMC,QAAQT,MAAQ,CAAA;gBAC/B,MAAMS,IAAAA;AACR;AACF;AACF,KAAA,EAAA,CAAA;AAEJ;AAEA,MAAMH,qBAAwB,GAAA,CAACI,IAAmC,GAAA,CAACL,SAAoB;AACrFK,YAAAA,IAAAA;AACAL,YAAAA;SACF,CAAA;;;;"}

View File

@@ -0,0 +1,13 @@
/// <reference types="node" />
import { Readable, Transform } from 'stream';
import type { Core } from '@strapi/types';
/**
* Generate and consume content-types streams in order to stream each entity individually
*/
export declare const createEntitiesStream: (strapi: Core.Strapi) => Readable;
/**
* Create an entity transform stream which convert the output of
* the multi-content-types stream to the transfer entity format
*/
export declare const createEntitiesTransformStream: () => Transform;
//# sourceMappingURL=entities.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../../../src/strapi/providers/local-source/entities.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAU,MAAM,eAAe,CAAC;AAKlD;;GAEG;AACH,eAAO,MAAM,oBAAoB,WAAY,KAAK,MAAM,KAAG,QAuC1D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,6BAA6B,QAAO,SAchD,CAAC"}

View File

@@ -0,0 +1,62 @@
'use strict';
var stream = require('stream');
var entity = require('../../queries/entity.js');
require('lodash/fp');
/**
* Generate and consume content-types streams in order to stream each entity individually
*/ const createEntitiesStream = (strapi)=>{
const contentTypes = Object.values(strapi.contentTypes);
async function* contentTypeStreamGenerator() {
for (const contentType of contentTypes){
const query = entity.createEntityQuery(strapi).call(null, contentType.uid);
const stream = strapi.db// Create a query builder instance (default type is 'select')
.queryBuilder(contentType.uid)// Fetch all columns
.select('*')// Apply the populate
.populate(query.deepPopulateComponentLikeQuery)// Get a readable stream
.stream();
yield {
contentType,
stream
};
}
}
return stream.Readable.from(async function* entitiesGenerator() {
for await (const { stream, contentType } of contentTypeStreamGenerator()){
try {
for await (const entity of stream){
yield {
entity,
contentType
};
}
} catch {
// ignore
} finally{
stream.destroy();
}
}
}());
};
/**
* Create an entity transform stream which convert the output of
* the multi-content-types stream to the transfer entity format
*/ const createEntitiesTransformStream = ()=>{
return new stream.Transform({
objectMode: true,
transform (data, _encoding, callback) {
const { entity, contentType } = data;
const { id, ...attributes } = entity;
callback(null, {
type: contentType.uid,
id,
data: attributes
});
}
});
};
exports.createEntitiesStream = createEntitiesStream;
exports.createEntitiesTransformStream = createEntitiesTransformStream;
//# sourceMappingURL=entities.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"entities.js","sources":["../../../../src/strapi/providers/local-source/entities.ts"],"sourcesContent":["import { Readable, Transform } from 'stream';\nimport type { Core, Struct } from '@strapi/types';\n\nimport * as shared from '../../queries';\nimport { IEntity } from '../../../../types';\n\n/**\n * Generate and consume content-types streams in order to stream each entity individually\n */\nexport const createEntitiesStream = (strapi: Core.Strapi): Readable => {\n const contentTypes: Struct.ContentTypeSchema[] = Object.values(strapi.contentTypes);\n\n async function* contentTypeStreamGenerator() {\n for (const contentType of contentTypes) {\n const query = shared.entity.createEntityQuery(strapi).call(null, contentType.uid);\n\n const stream: Readable = strapi.db\n // Create a query builder instance (default type is 'select')\n .queryBuilder(contentType.uid)\n // Fetch all columns\n .select('*')\n // Apply the populate\n .populate(query.deepPopulateComponentLikeQuery)\n // Get a readable stream\n .stream();\n\n yield { contentType, stream };\n }\n }\n\n return Readable.from(\n (async function* entitiesGenerator(): AsyncGenerator<{\n entity: IEntity;\n contentType: Struct.ContentTypeSchema;\n }> {\n for await (const { stream, contentType } of contentTypeStreamGenerator()) {\n try {\n for await (const entity of stream) {\n yield { entity, contentType };\n }\n } catch {\n // ignore\n } finally {\n stream.destroy();\n }\n }\n })()\n );\n};\n\n/**\n * Create an entity transform stream which convert the output of\n * the multi-content-types stream to the transfer entity format\n */\nexport const createEntitiesTransformStream = (): Transform => {\n return new Transform({\n objectMode: true,\n transform(data, _encoding, callback) {\n const { entity, contentType } = data;\n const { id, ...attributes } = entity;\n\n callback(null, {\n type: contentType.uid,\n id,\n data: attributes,\n });\n },\n });\n};\n"],"names":["createEntitiesStream","strapi","contentTypes","Object","values","contentTypeStreamGenerator","contentType","query","shared","call","uid","stream","db","queryBuilder","select","populate","deepPopulateComponentLikeQuery","Readable","from","entitiesGenerator","entity","destroy","createEntitiesTransformStream","Transform","objectMode","transform","data","_encoding","callback","id","attributes","type"],"mappings":";;;;;;AAMA;;IAGaA,MAAAA,oBAAAA,GAAuB,CAACC,MAAAA,GAAAA;AACnC,IAAA,MAAMC,YAA2CC,GAAAA,MAAAA,CAAOC,MAAM,CAACH,OAAOC,YAAY,CAAA;IAElF,gBAAgBG,0BAAAA,GAAAA;QACd,KAAK,MAAMC,eAAeJ,YAAc,CAAA;YACtC,MAAMK,KAAAA,GAAQC,wBAA+B,CAACP,MAAAA,CAAAA,CAAQQ,IAAI,CAAC,IAAMH,EAAAA,WAAAA,CAAYI,GAAG,CAAA;AAEhF,YAAA,MAAMC,MAAmBV,GAAAA,MAAAA,CAAOW,EAC9B;AACCC,aAAAA,YAAY,CAACP,WAAAA,CAAYI,GAAG,CAC7B;aACCI,MAAM,CAAC,IACR;AACCC,aAAAA,QAAQ,CAACR,KAAAA,CAAMS,8BAA8B,CAC9C;aACCL,MAAM,EAAA;YAET,MAAM;AAAEL,gBAAAA,WAAAA;AAAaK,gBAAAA;AAAO,aAAA;AAC9B;AACF;AAEA,IAAA,OAAOM,eAASC,CAAAA,IAAI,CACjB,gBAAgBC,iBAAAA,GAAAA;AAIf,QAAA,WAAW,MAAM,EAAER,MAAM,EAAEL,WAAW,EAAE,IAAID,0BAA8B,EAAA,CAAA;YACxE,IAAI;gBACF,WAAW,MAAMe,UAAUT,MAAQ,CAAA;oBACjC,MAAM;AAAES,wBAAAA,MAAAA;AAAQd,wBAAAA;AAAY,qBAAA;AAC9B;AACF,aAAA,CAAE,OAAM;;aAEE,QAAA;AACRK,gBAAAA,MAAAA,CAAOU,OAAO,EAAA;AAChB;AACF;AACF,KAAA,EAAA,CAAA;AAEJ;AAEA;;;UAIaC,6BAAgC,GAAA,IAAA;AAC3C,IAAA,OAAO,IAAIC,gBAAU,CAAA;QACnBC,UAAY,EAAA,IAAA;AACZC,QAAAA,SAAAA,CAAAA,CAAUC,IAAI,EAAEC,SAAS,EAAEC,QAAQ,EAAA;AACjC,YAAA,MAAM,EAAER,MAAM,EAAEd,WAAW,EAAE,GAAGoB,IAAAA;AAChC,YAAA,MAAM,EAAEG,EAAE,EAAE,GAAGC,YAAY,GAAGV,MAAAA;AAE9BQ,YAAAA,QAAAA,CAAS,IAAM,EAAA;AACbG,gBAAAA,IAAAA,EAAMzB,YAAYI,GAAG;AACrBmB,gBAAAA,EAAAA;gBACAH,IAAMI,EAAAA;AACR,aAAA,CAAA;AACF;AACF,KAAA,CAAA;AACF;;;;;"}

View File

@@ -0,0 +1,59 @@
import { Readable, Transform } from 'stream';
import { createEntityQuery } from '../../queries/entity.mjs';
import 'lodash/fp';
/**
* Generate and consume content-types streams in order to stream each entity individually
*/ const createEntitiesStream = (strapi)=>{
const contentTypes = Object.values(strapi.contentTypes);
async function* contentTypeStreamGenerator() {
for (const contentType of contentTypes){
const query = createEntityQuery(strapi).call(null, contentType.uid);
const stream = strapi.db// Create a query builder instance (default type is 'select')
.queryBuilder(contentType.uid)// Fetch all columns
.select('*')// Apply the populate
.populate(query.deepPopulateComponentLikeQuery)// Get a readable stream
.stream();
yield {
contentType,
stream
};
}
}
return Readable.from(async function* entitiesGenerator() {
for await (const { stream, contentType } of contentTypeStreamGenerator()){
try {
for await (const entity of stream){
yield {
entity,
contentType
};
}
} catch {
// ignore
} finally{
stream.destroy();
}
}
}());
};
/**
* Create an entity transform stream which convert the output of
* the multi-content-types stream to the transfer entity format
*/ const createEntitiesTransformStream = ()=>{
return new Transform({
objectMode: true,
transform (data, _encoding, callback) {
const { entity, contentType } = data;
const { id, ...attributes } = entity;
callback(null, {
type: contentType.uid,
id,
data: attributes
});
}
});
};
export { createEntitiesStream, createEntitiesTransformStream };
//# sourceMappingURL=entities.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"entities.mjs","sources":["../../../../src/strapi/providers/local-source/entities.ts"],"sourcesContent":["import { Readable, Transform } from 'stream';\nimport type { Core, Struct } from '@strapi/types';\n\nimport * as shared from '../../queries';\nimport { IEntity } from '../../../../types';\n\n/**\n * Generate and consume content-types streams in order to stream each entity individually\n */\nexport const createEntitiesStream = (strapi: Core.Strapi): Readable => {\n const contentTypes: Struct.ContentTypeSchema[] = Object.values(strapi.contentTypes);\n\n async function* contentTypeStreamGenerator() {\n for (const contentType of contentTypes) {\n const query = shared.entity.createEntityQuery(strapi).call(null, contentType.uid);\n\n const stream: Readable = strapi.db\n // Create a query builder instance (default type is 'select')\n .queryBuilder(contentType.uid)\n // Fetch all columns\n .select('*')\n // Apply the populate\n .populate(query.deepPopulateComponentLikeQuery)\n // Get a readable stream\n .stream();\n\n yield { contentType, stream };\n }\n }\n\n return Readable.from(\n (async function* entitiesGenerator(): AsyncGenerator<{\n entity: IEntity;\n contentType: Struct.ContentTypeSchema;\n }> {\n for await (const { stream, contentType } of contentTypeStreamGenerator()) {\n try {\n for await (const entity of stream) {\n yield { entity, contentType };\n }\n } catch {\n // ignore\n } finally {\n stream.destroy();\n }\n }\n })()\n );\n};\n\n/**\n * Create an entity transform stream which convert the output of\n * the multi-content-types stream to the transfer entity format\n */\nexport const createEntitiesTransformStream = (): Transform => {\n return new Transform({\n objectMode: true,\n transform(data, _encoding, callback) {\n const { entity, contentType } = data;\n const { id, ...attributes } = entity;\n\n callback(null, {\n type: contentType.uid,\n id,\n data: attributes,\n });\n },\n });\n};\n"],"names":["createEntitiesStream","strapi","contentTypes","Object","values","contentTypeStreamGenerator","contentType","query","shared","call","uid","stream","db","queryBuilder","select","populate","deepPopulateComponentLikeQuery","Readable","from","entitiesGenerator","entity","destroy","createEntitiesTransformStream","Transform","objectMode","transform","data","_encoding","callback","id","attributes","type"],"mappings":";;;;AAMA;;IAGaA,MAAAA,oBAAAA,GAAuB,CAACC,MAAAA,GAAAA;AACnC,IAAA,MAAMC,YAA2CC,GAAAA,MAAAA,CAAOC,MAAM,CAACH,OAAOC,YAAY,CAAA;IAElF,gBAAgBG,0BAAAA,GAAAA;QACd,KAAK,MAAMC,eAAeJ,YAAc,CAAA;YACtC,MAAMK,KAAAA,GAAQC,iBAA+B,CAACP,MAAAA,CAAAA,CAAQQ,IAAI,CAAC,IAAMH,EAAAA,WAAAA,CAAYI,GAAG,CAAA;AAEhF,YAAA,MAAMC,MAAmBV,GAAAA,MAAAA,CAAOW,EAC9B;AACCC,aAAAA,YAAY,CAACP,WAAAA,CAAYI,GAAG,CAC7B;aACCI,MAAM,CAAC,IACR;AACCC,aAAAA,QAAQ,CAACR,KAAAA,CAAMS,8BAA8B,CAC9C;aACCL,MAAM,EAAA;YAET,MAAM;AAAEL,gBAAAA,WAAAA;AAAaK,gBAAAA;AAAO,aAAA;AAC9B;AACF;AAEA,IAAA,OAAOM,QAASC,CAAAA,IAAI,CACjB,gBAAgBC,iBAAAA,GAAAA;AAIf,QAAA,WAAW,MAAM,EAAER,MAAM,EAAEL,WAAW,EAAE,IAAID,0BAA8B,EAAA,CAAA;YACxE,IAAI;gBACF,WAAW,MAAMe,UAAUT,MAAQ,CAAA;oBACjC,MAAM;AAAES,wBAAAA,MAAAA;AAAQd,wBAAAA;AAAY,qBAAA;AAC9B;AACF,aAAA,CAAE,OAAM;;aAEE,QAAA;AACRK,gBAAAA,MAAAA,CAAOU,OAAO,EAAA;AAChB;AACF;AACF,KAAA,EAAA,CAAA;AAEJ;AAEA;;;UAIaC,6BAAgC,GAAA,IAAA;AAC3C,IAAA,OAAO,IAAIC,SAAU,CAAA;QACnBC,UAAY,EAAA,IAAA;AACZC,QAAAA,SAAAA,CAAAA,CAAUC,IAAI,EAAEC,SAAS,EAAEC,QAAQ,EAAA;AACjC,YAAA,MAAM,EAAER,MAAM,EAAEd,WAAW,EAAE,GAAGoB,IAAAA;AAChC,YAAA,MAAM,EAAEG,EAAE,EAAE,GAAGC,YAAY,GAAGV,MAAAA;AAE9BQ,YAAAA,QAAAA,CAAS,IAAM,EAAA;AACbG,gBAAAA,IAAAA,EAAMzB,YAAYI,GAAG;AACrBmB,gBAAAA,EAAAA;gBACAH,IAAMI,EAAAA;AACR,aAAA,CAAA;AACF;AACF,KAAA,CAAA;AACF;;;;"}

View File

@@ -0,0 +1,30 @@
/// <reference types="node" />
import { Readable } from 'stream';
import type { Core, Struct } from '@strapi/types';
import type { IMetadata, ISourceProvider, ProviderType } from '../../../../types';
import type { IDiagnosticReporter } from '../../../utils/diagnostic';
export interface ILocalStrapiSourceProviderOptions {
getStrapi(): Core.Strapi | Promise<Core.Strapi>;
autoDestroy?: boolean;
}
export declare const createLocalStrapiSourceProvider: (options: ILocalStrapiSourceProviderOptions) => LocalStrapiSourceProvider;
declare class LocalStrapiSourceProvider implements ISourceProvider {
#private;
name: string;
type: ProviderType;
options: ILocalStrapiSourceProviderOptions;
strapi?: Core.Strapi;
constructor(options: ILocalStrapiSourceProviderOptions);
bootstrap(diagnostics?: IDiagnosticReporter): Promise<void>;
close(): Promise<void>;
getMetadata(): IMetadata;
createEntitiesReadStream(): Promise<Readable>;
createLinksReadStream(): Readable;
createConfigurationReadStream(): Readable;
getSchemas(): Record<string, Struct.Schema>;
createSchemasReadStream(): Readable;
createAssetsReadStream(): Readable;
}
export type ILocalStrapiSourceProvider = InstanceType<typeof LocalStrapiSourceProvider>;
export {};
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/strapi/providers/local-source/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAQrE,MAAM,WAAW,iCAAiC;IAChD,SAAS,IAAI,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEhD,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,eAAO,MAAM,+BAA+B,YAAa,iCAAiC,8BAEzF,CAAC;AAEF,cAAM,yBAA0B,YAAW,eAAe;;IACxD,IAAI,SAA0B;IAE9B,IAAI,EAAE,YAAY,CAAY;IAE9B,OAAO,EAAE,iCAAiC,CAAC;IAE3C,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;gBAIT,OAAO,EAAE,iCAAiC;IAIhD,SAAS,CAAC,WAAW,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAiD3D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAU5B,WAAW,IAAI,SAAS;IAalB,wBAAwB,IAAI,OAAO,CAAC,QAAQ,CAAC;IAYnD,qBAAqB,IAAI,QAAQ;IAOjC,6BAA6B,IAAI,QAAQ;IAMzC,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;IAW3C,uBAAuB,IAAI,QAAQ;IAInC,sBAAsB,IAAI,QAAQ;CAWnC;AAED,MAAM,MAAM,0BAA0B,GAAG,YAAY,CAAC,OAAO,yBAAyB,CAAC,CAAC"}

View File

@@ -0,0 +1,154 @@
'use strict';
var stream = require('stream');
var streamChain = require('stream-chain');
var entities = require('./entities.js');
var links = require('./links.js');
var configuration = require('./configuration.js');
var assets = require('./assets.js');
require('crypto');
require('lodash/fp');
var schema = require('../../../utils/schema.js');
require('events');
var providers = require('../../../utils/providers.js');
function _class_private_field_loose_base(receiver, privateKey) {
if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
throw new TypeError("attempted to use private field on non-instance");
}
return receiver;
}
var id = 0;
function _class_private_field_loose_key(name) {
return "__private_" + id++ + "_" + name;
}
const createLocalStrapiSourceProvider = (options)=>{
return new LocalStrapiSourceProvider(options);
};
var _diagnostics = /*#__PURE__*/ _class_private_field_loose_key("_diagnostics"), _reportInfo = /*#__PURE__*/ _class_private_field_loose_key("_reportInfo"), /**
* Reports an error to the diagnostic reporter.
*/ _reportError = /*#__PURE__*/ _class_private_field_loose_key("_reportError"), /**
* Handles errors that occur in read streams.
*/ _handleStreamError = /*#__PURE__*/ _class_private_field_loose_key("_handleStreamError");
class LocalStrapiSourceProvider {
async bootstrap(diagnostics) {
_class_private_field_loose_base(this, _diagnostics)[_diagnostics] = diagnostics;
this.strapi = await this.options.getStrapi();
this.strapi.db.lifecycles.disable();
}
async close() {
const { autoDestroy } = this.options;
providers.assertValidStrapi(this.strapi);
this.strapi.db.lifecycles.enable();
// Basically `!== false` but more deterministic
if (autoDestroy === undefined || autoDestroy === true) {
await this.strapi?.destroy();
}
}
getMetadata() {
_class_private_field_loose_base(this, _reportInfo)[_reportInfo]('getting metadata');
const strapiVersion = strapi.config.get('info.strapi');
const createdAt = new Date().toISOString();
return {
createdAt,
strapi: {
version: strapiVersion
}
};
}
async createEntitiesReadStream() {
providers.assertValidStrapi(this.strapi, 'Not able to stream entities');
_class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating entities read stream');
return streamChain.chain([
// Entities stream
entities.createEntitiesStream(this.strapi),
// Transform stream
entities.createEntitiesTransformStream()
]);
}
createLinksReadStream() {
providers.assertValidStrapi(this.strapi, 'Not able to stream links');
_class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating links read stream');
return links.createLinksStream(this.strapi);
}
createConfigurationReadStream() {
providers.assertValidStrapi(this.strapi, 'Not able to stream configuration');
_class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating configuration read stream');
return configuration.createConfigurationStream(this.strapi);
}
getSchemas() {
providers.assertValidStrapi(this.strapi, 'Not able to get Schemas');
_class_private_field_loose_base(this, _reportInfo)[_reportInfo]('getting schemas');
const schemas = schema.schemasToValidJSON({
...this.strapi.contentTypes,
...this.strapi.components
});
return schema.mapSchemasValues(schemas);
}
createSchemasReadStream() {
return stream.Readable.from(Object.values(this.getSchemas()));
}
createAssetsReadStream() {
providers.assertValidStrapi(this.strapi, 'Not able to stream assets');
_class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating assets read stream');
const stream = assets.createAssetsStream(this.strapi);
stream.on('error', (err)=>{
_class_private_field_loose_base(this, _handleStreamError)[_handleStreamError]('assets', err);
});
return stream;
}
constructor(options){
Object.defineProperty(this, _reportInfo, {
value: reportInfo
});
Object.defineProperty(this, _reportError, {
value: reportError
});
Object.defineProperty(this, _handleStreamError, {
value: handleStreamError
});
Object.defineProperty(this, _diagnostics, {
writable: true,
value: void 0
});
this.name = 'source::local-strapi';
this.type = 'source';
this.options = options;
}
}
function reportInfo(message) {
_class_private_field_loose_base(this, _diagnostics)[_diagnostics]?.report({
details: {
createdAt: new Date(),
message,
origin: 'local-source-provider'
},
kind: 'info'
});
}
function reportError(message, error) {
_class_private_field_loose_base(this, _diagnostics)[_diagnostics]?.report({
details: {
createdAt: new Date(),
message,
error,
severity: 'fatal',
name: error.name
},
kind: 'error'
});
}
function handleStreamError(streamType, err) {
const { message, stack } = err;
const errorMessage = `[Data transfer] Error in ${streamType} read stream: ${message}`;
const formattedError = {
message: errorMessage,
stack,
timestamp: new Date().toISOString()
};
this.strapi?.log.error(formattedError);
_class_private_field_loose_base(this, _reportError)[_reportError](formattedError.message, err);
}
exports.createLocalStrapiSourceProvider = createLocalStrapiSourceProvider;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,152 @@
import { Readable } from 'stream';
import { chain } from 'stream-chain';
import { createEntitiesStream, createEntitiesTransformStream } from './entities.mjs';
import { createLinksStream } from './links.mjs';
import { createConfigurationStream } from './configuration.mjs';
import { createAssetsStream } from './assets.mjs';
import 'crypto';
import 'lodash/fp';
import { schemasToValidJSON, mapSchemasValues } from '../../../utils/schema.mjs';
import 'events';
import { assertValidStrapi } from '../../../utils/providers.mjs';
function _class_private_field_loose_base(receiver, privateKey) {
if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
throw new TypeError("attempted to use private field on non-instance");
}
return receiver;
}
var id = 0;
function _class_private_field_loose_key(name) {
return "__private_" + id++ + "_" + name;
}
const createLocalStrapiSourceProvider = (options)=>{
return new LocalStrapiSourceProvider(options);
};
var _diagnostics = /*#__PURE__*/ _class_private_field_loose_key("_diagnostics"), _reportInfo = /*#__PURE__*/ _class_private_field_loose_key("_reportInfo"), /**
* Reports an error to the diagnostic reporter.
*/ _reportError = /*#__PURE__*/ _class_private_field_loose_key("_reportError"), /**
* Handles errors that occur in read streams.
*/ _handleStreamError = /*#__PURE__*/ _class_private_field_loose_key("_handleStreamError");
class LocalStrapiSourceProvider {
async bootstrap(diagnostics) {
_class_private_field_loose_base(this, _diagnostics)[_diagnostics] = diagnostics;
this.strapi = await this.options.getStrapi();
this.strapi.db.lifecycles.disable();
}
async close() {
const { autoDestroy } = this.options;
assertValidStrapi(this.strapi);
this.strapi.db.lifecycles.enable();
// Basically `!== false` but more deterministic
if (autoDestroy === undefined || autoDestroy === true) {
await this.strapi?.destroy();
}
}
getMetadata() {
_class_private_field_loose_base(this, _reportInfo)[_reportInfo]('getting metadata');
const strapiVersion = strapi.config.get('info.strapi');
const createdAt = new Date().toISOString();
return {
createdAt,
strapi: {
version: strapiVersion
}
};
}
async createEntitiesReadStream() {
assertValidStrapi(this.strapi, 'Not able to stream entities');
_class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating entities read stream');
return chain([
// Entities stream
createEntitiesStream(this.strapi),
// Transform stream
createEntitiesTransformStream()
]);
}
createLinksReadStream() {
assertValidStrapi(this.strapi, 'Not able to stream links');
_class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating links read stream');
return createLinksStream(this.strapi);
}
createConfigurationReadStream() {
assertValidStrapi(this.strapi, 'Not able to stream configuration');
_class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating configuration read stream');
return createConfigurationStream(this.strapi);
}
getSchemas() {
assertValidStrapi(this.strapi, 'Not able to get Schemas');
_class_private_field_loose_base(this, _reportInfo)[_reportInfo]('getting schemas');
const schemas = schemasToValidJSON({
...this.strapi.contentTypes,
...this.strapi.components
});
return mapSchemasValues(schemas);
}
createSchemasReadStream() {
return Readable.from(Object.values(this.getSchemas()));
}
createAssetsReadStream() {
assertValidStrapi(this.strapi, 'Not able to stream assets');
_class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating assets read stream');
const stream = createAssetsStream(this.strapi);
stream.on('error', (err)=>{
_class_private_field_loose_base(this, _handleStreamError)[_handleStreamError]('assets', err);
});
return stream;
}
constructor(options){
Object.defineProperty(this, _reportInfo, {
value: reportInfo
});
Object.defineProperty(this, _reportError, {
value: reportError
});
Object.defineProperty(this, _handleStreamError, {
value: handleStreamError
});
Object.defineProperty(this, _diagnostics, {
writable: true,
value: void 0
});
this.name = 'source::local-strapi';
this.type = 'source';
this.options = options;
}
}
function reportInfo(message) {
_class_private_field_loose_base(this, _diagnostics)[_diagnostics]?.report({
details: {
createdAt: new Date(),
message,
origin: 'local-source-provider'
},
kind: 'info'
});
}
function reportError(message, error) {
_class_private_field_loose_base(this, _diagnostics)[_diagnostics]?.report({
details: {
createdAt: new Date(),
message,
error,
severity: 'fatal',
name: error.name
},
kind: 'error'
});
}
function handleStreamError(streamType, err) {
const { message, stack } = err;
const errorMessage = `[Data transfer] Error in ${streamType} read stream: ${message}`;
const formattedError = {
message: errorMessage,
stack,
timestamp: new Date().toISOString()
};
this.strapi?.log.error(formattedError);
_class_private_field_loose_base(this, _reportError)[_reportError](formattedError.message, err);
}
export { createLocalStrapiSourceProvider };
//# sourceMappingURL=index.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,8 @@
/// <reference types="node" />
import { Readable } from 'stream';
import type { Core } from '@strapi/types';
/**
* Create a Readable which will stream all the links from a Strapi instance
*/
export declare const createLinksStream: (strapi: Core.Strapi) => Readable;
//# sourceMappingURL=links.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../../../../src/strapi/providers/local-source/links.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAK1C;;GAEG;AACH,eAAO,MAAM,iBAAiB,WAAY,KAAK,MAAM,KAAG,QAiBvD,CAAC"}

View File

@@ -0,0 +1,26 @@
'use strict';
var stream = require('stream');
var link = require('../../queries/link.js');
/**
* Create a Readable which will stream all the links from a Strapi instance
*/ const createLinksStream = (strapi)=>{
const uids = [
...Object.keys(strapi.contentTypes),
...Object.keys(strapi.components)
];
// Async generator stream that returns every link from a Strapi instance
return stream.Readable.from(async function* linkGenerator() {
const query = link.createLinkQuery(strapi);
for (const uid of uids){
const generator = query().generateAll(uid);
for await (const link of generator){
yield link;
}
}
}());
};
exports.createLinksStream = createLinksStream;
//# sourceMappingURL=links.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"links.js","sources":["../../../../src/strapi/providers/local-source/links.ts"],"sourcesContent":["import { Readable } from 'stream';\nimport type { Core } from '@strapi/types';\n\nimport type { ILink } from '../../../../types';\nimport { createLinkQuery } from '../../queries/link';\n\n/**\n * Create a Readable which will stream all the links from a Strapi instance\n */\nexport const createLinksStream = (strapi: Core.Strapi): Readable => {\n const uids = [...Object.keys(strapi.contentTypes), ...Object.keys(strapi.components)] as string[];\n\n // Async generator stream that returns every link from a Strapi instance\n return Readable.from(\n (async function* linkGenerator(): AsyncGenerator<ILink> {\n const query = createLinkQuery(strapi);\n\n for (const uid of uids) {\n const generator = query().generateAll(uid);\n\n for await (const link of generator) {\n yield link;\n }\n }\n })()\n );\n};\n"],"names":["createLinksStream","strapi","uids","Object","keys","contentTypes","components","Readable","from","linkGenerator","query","createLinkQuery","uid","generator","generateAll","link"],"mappings":";;;;;AAMA;;IAGaA,MAAAA,iBAAAA,GAAoB,CAACC,MAAAA,GAAAA;AAChC,IAAA,MAAMC,IAAO,GAAA;WAAIC,MAAOC,CAAAA,IAAI,CAACH,MAAAA,CAAOI,YAAY,CAAA;WAAMF,MAAOC,CAAAA,IAAI,CAACH,MAAAA,CAAOK,UAAU;AAAE,KAAA;;AAGrF,IAAA,OAAOC,eAASC,CAAAA,IAAI,CACjB,gBAAgBC,aAAAA,GAAAA;AACf,QAAA,MAAMC,QAAQC,oBAAgBV,CAAAA,MAAAA,CAAAA;QAE9B,KAAK,MAAMW,OAAOV,IAAM,CAAA;YACtB,MAAMW,SAAAA,GAAYH,KAAQI,EAAAA,CAAAA,WAAW,CAACF,GAAAA,CAAAA;YAEtC,WAAW,MAAMG,QAAQF,SAAW,CAAA;gBAClC,MAAME,IAAAA;AACR;AACF;AACF,KAAA,EAAA,CAAA;AAEJ;;;;"}

View File

@@ -0,0 +1,24 @@
import { Readable } from 'stream';
import { createLinkQuery } from '../../queries/link.mjs';
/**
* Create a Readable which will stream all the links from a Strapi instance
*/ const createLinksStream = (strapi)=>{
const uids = [
...Object.keys(strapi.contentTypes),
...Object.keys(strapi.components)
];
// Async generator stream that returns every link from a Strapi instance
return Readable.from(async function* linkGenerator() {
const query = createLinkQuery(strapi);
for (const uid of uids){
const generator = query().generateAll(uid);
for await (const link of generator){
yield link;
}
}
}());
};
export { createLinksStream };
//# sourceMappingURL=links.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"links.mjs","sources":["../../../../src/strapi/providers/local-source/links.ts"],"sourcesContent":["import { Readable } from 'stream';\nimport type { Core } from '@strapi/types';\n\nimport type { ILink } from '../../../../types';\nimport { createLinkQuery } from '../../queries/link';\n\n/**\n * Create a Readable which will stream all the links from a Strapi instance\n */\nexport const createLinksStream = (strapi: Core.Strapi): Readable => {\n const uids = [...Object.keys(strapi.contentTypes), ...Object.keys(strapi.components)] as string[];\n\n // Async generator stream that returns every link from a Strapi instance\n return Readable.from(\n (async function* linkGenerator(): AsyncGenerator<ILink> {\n const query = createLinkQuery(strapi);\n\n for (const uid of uids) {\n const generator = query().generateAll(uid);\n\n for await (const link of generator) {\n yield link;\n }\n }\n })()\n );\n};\n"],"names":["createLinksStream","strapi","uids","Object","keys","contentTypes","components","Readable","from","linkGenerator","query","createLinkQuery","uid","generator","generateAll","link"],"mappings":";;;AAMA;;IAGaA,MAAAA,iBAAAA,GAAoB,CAACC,MAAAA,GAAAA;AAChC,IAAA,MAAMC,IAAO,GAAA;WAAIC,MAAOC,CAAAA,IAAI,CAACH,MAAAA,CAAOI,YAAY,CAAA;WAAMF,MAAOC,CAAAA,IAAI,CAACH,MAAAA,CAAOK,UAAU;AAAE,KAAA;;AAGrF,IAAA,OAAOC,QAASC,CAAAA,IAAI,CACjB,gBAAgBC,aAAAA,GAAAA;AACf,QAAA,MAAMC,QAAQC,eAAgBV,CAAAA,MAAAA,CAAAA;QAE9B,KAAK,MAAMW,OAAOV,IAAM,CAAA;YACtB,MAAMW,SAAAA,GAAYH,KAAQI,EAAAA,CAAAA,WAAW,CAACF,GAAAA,CAAAA;YAEtC,WAAW,MAAMG,QAAQF,SAAW,CAAA;gBAClC,MAAME,IAAAA;AACR;AACF;AACF,KAAA,EAAA,CAAA;AAEJ;;;;"}