- Add Activepieces fork with SmoothSchedule custom piece - Create integrations app with Activepieces service layer - Add embed token endpoint for iframe integration - Create Automations page with embedded workflow builder - Add sidebar visibility fix for embed mode - Add list inactive customers endpoint to Public API - Include SmoothSchedule triggers: event created/updated/cancelled - Include SmoothSchedule actions: create/update/cancel events, list resources/services/customers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
71 lines
2.0 KiB
TypeScript
71 lines
2.0 KiB
TypeScript
import assert from 'node:assert';
|
|
import { PieceMetadata } from '../../../packages/pieces/community/framework/src';
|
|
import { StatusCodes } from 'http-status-codes';
|
|
import { HttpHeader } from '../../../packages/pieces/community/common/src';
|
|
import { AP_CLOUD_API_BASE, findNewPieces, pieceMetadataExists } from '../utils/piece-script-utils';
|
|
import { chunk } from '../../../packages/shared/src/lib/common/utils/utils';
|
|
assert(process.env['AP_CLOUD_API_KEY'], 'API Key is not defined');
|
|
|
|
const { AP_CLOUD_API_KEY } = process.env;
|
|
|
|
const insertPieceMetadata = async (
|
|
pieceMetadata: PieceMetadata
|
|
): Promise<void> => {
|
|
const body = JSON.stringify(pieceMetadata);
|
|
|
|
const headers = {
|
|
['api-key']: AP_CLOUD_API_KEY,
|
|
[HttpHeader.CONTENT_TYPE]: 'application/json'
|
|
};
|
|
|
|
const cloudResponse = await fetch(`${AP_CLOUD_API_BASE}/admin/pieces`, {
|
|
method: 'POST',
|
|
headers,
|
|
body
|
|
});
|
|
|
|
if (cloudResponse.status !== StatusCodes.OK && cloudResponse.status !== StatusCodes.CONFLICT) {
|
|
throw new Error(await cloudResponse.text());
|
|
}
|
|
};
|
|
|
|
|
|
|
|
const insertMetadataIfNotExist = async (pieceMetadata: PieceMetadata) => {
|
|
console.info(
|
|
`insertMetadataIfNotExist, name: ${pieceMetadata.name}, version: ${pieceMetadata.version}`
|
|
);
|
|
|
|
const metadataAlreadyExist = await pieceMetadataExists(
|
|
pieceMetadata.name,
|
|
pieceMetadata.version
|
|
);
|
|
|
|
if (metadataAlreadyExist) {
|
|
console.info(`insertMetadataIfNotExist, piece metadata already inserted`);
|
|
return;
|
|
}
|
|
|
|
await insertPieceMetadata(pieceMetadata);
|
|
};
|
|
|
|
const insertMetadata = async (piecesMetadata: PieceMetadata[]) => {
|
|
const batches = chunk(piecesMetadata, 30)
|
|
for (const batch of batches) {
|
|
await Promise.all(batch.map(insertMetadataIfNotExist))
|
|
await new Promise(resolve => setTimeout(resolve, 5000))
|
|
}
|
|
};
|
|
|
|
const main = async () => {
|
|
console.log('update pieces metadata: started')
|
|
|
|
const piecesMetadata = await findNewPieces()
|
|
await insertMetadata(piecesMetadata)
|
|
|
|
console.log('update pieces metadata: completed')
|
|
process.exit()
|
|
}
|
|
|
|
main()
|