Skip to content

Commit 2ef8720

Browse files
authored
Merge branch 'v2-dev' into fix/DX-3943
2 parents 4b7ea36 + 09ea761 commit 2ef8720

29 files changed

Lines changed: 1441 additions & 1068 deletions

File tree

.talismanrc

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,4 @@
11
fileignoreconfig:
22
- filename: pnpm-lock.yaml
3-
checksum: 264c0294416c2aa2028c8283831aa7ed17d63e8c69553a7b2b9774336bc0811f
4-
- filename: packages/contentstack-bootstrap/test/bootstrap.test.js
5-
checksum: 37b502482fc32831c39091dd1755e8b0a9f6f8bac89e5eb9d397c6af1f213d83
6-
- filename: packages/contentstack-bootstrap/test/utils.test.js
7-
checksum: e0ca2eb58ab1c3ac3b4d9c14a17bb8f4788678074dd65f6acc128a8a8f51997f
8-
- filename: packages/contentstack-export-to-csv/test/unit/base-command.test.ts
9-
checksum: 4c2befce053135453c1db31f21351bf3f797ff2f15723ca52e183ed6ed9e48e4
10-
- filename: packages/contentstack-export-to-csv/test/unit/utils/teams-export.functional.test.ts
11-
checksum: 17cdae91c22a935309bf4514b6616f1aea91fd0166fede182e673ade43667a36
12-
- filename: packages/contentstack-export-to-csv/test/unit/utils/interactive.test.ts
13-
checksum: 72c1e719e5c51a42debc817a5fe5bb1adee63b2d823df2e9ee36d0b970db7886
14-
- filename: packages/contentstack-export-to-csv/test/unit/utils/api-client.functional.test.ts
15-
checksum: 6d6638919ef7260f642d32cf730e2654d159d2d3582714fb2d7a9c209b9c6eeb
16-
- filename: packages/contentstack-export-to-csv/test/unit/commands/export-to-csv.test.ts
17-
checksum: 9621a9d013796e99a25e894404c4d7c6799bd33bde77852f09d5e32b4d1c1c49
3+
checksum: 71b97a29a577e59d746967b4717acd013d624fd1cbf7d796647c9ef6d7652165
184
version: '1.0'

packages/contentstack-asset-management/src/types/cs-assets-api.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,28 @@ export type CSAssetsAPIConfig = {
115115
context?: Record<string, unknown>;
116116
};
117117

118+
// ---------------------------------------------------------------------------
119+
// Bulk mutate (CS Assets / AM API)
120+
// ---------------------------------------------------------------------------
121+
122+
export type BulkDeleteAssetItem = { uid: string; locale: string };
123+
124+
export type BulkDeleteAssetsPayload = { assets: BulkDeleteAssetItem[] };
125+
126+
export type BulkDeleteAssetsResponse = {
127+
notice?: string;
128+
job_id?: string;
129+
};
130+
131+
export type BulkMoveAssetsPayload = {
132+
asset_uids: string[];
133+
target_folder_uid: string;
134+
};
135+
136+
export type BulkMoveAssetsResponse = {
137+
notice?: string;
138+
};
139+
118140
/**
119141
* Adapter interface for Contentstack Assets API calls.
120142
* Used by export and (future) import.
@@ -127,6 +149,16 @@ export interface ICSAssetsAdapter {
127149
getWorkspaceAssets(spaceUid: string, workspaceUid?: string): Promise<unknown>;
128150
getWorkspaceFolders(spaceUid: string, workspaceUid?: string): Promise<unknown>;
129151
getWorkspaceAssetTypes(spaceUid: string): Promise<AssetTypesResponse>;
152+
bulkDeleteAssets(
153+
spaceUid: string,
154+
workspaceUid: string | undefined,
155+
payload: BulkDeleteAssetsPayload,
156+
): Promise<BulkDeleteAssetsResponse>;
157+
bulkMoveAssets(
158+
spaceUid: string,
159+
workspaceUid: string | undefined,
160+
payload: BulkMoveAssetsPayload,
161+
): Promise<BulkMoveAssetsResponse>;
130162
}
131163

132164
/**

packages/contentstack-asset-management/src/utils/cs-assets-api-adapter.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import { HttpClient, log, authenticationHandler, handleAndLogError } from '@cont
55
import type {
66
CSAssetsAPIConfig,
77
AssetTypesResponse,
8+
BulkDeleteAssetsPayload,
9+
BulkDeleteAssetsResponse,
10+
BulkMoveAssetsPayload,
11+
BulkMoveAssetsResponse,
812
CreateAssetMetadata,
913
CreateAssetTypePayload,
1014
CreateFieldPayload,
@@ -364,4 +368,28 @@ export class CSAssetsAdapter implements ICSAssetsAdapter {
364368
async createAssetType(payload: CreateAssetTypePayload): Promise<{ asset_type: { uid: string } }> {
365369
return this.postJson<{ asset_type: { uid: string } }>('/api/asset_types', payload);
366370
}
371+
372+
/**
373+
* POST /api/spaces/{spaceUid}/assets/bulk/delete — bulk delete assets (per locale entries).
374+
*/
375+
async bulkDeleteAssets(
376+
spaceUid: string,
377+
workspaceUid: string = 'main',
378+
payload: BulkDeleteAssetsPayload,
379+
): Promise<BulkDeleteAssetsResponse> {
380+
const path = `/api/spaces/${encodeURIComponent(spaceUid)}/assets/bulk/delete?workspace=${encodeURIComponent(workspaceUid)}`;
381+
return this.postJson<BulkDeleteAssetsResponse>(path, payload, { space_key: spaceUid });
382+
}
383+
384+
/**
385+
* POST /api/spaces/{spaceUid}/assets/bulk-move — move assets into a folder.
386+
*/
387+
async bulkMoveAssets(
388+
spaceUid: string,
389+
workspaceUid: string = 'main',
390+
payload: BulkMoveAssetsPayload,
391+
): Promise<BulkMoveAssetsResponse> {
392+
const path = `/api/spaces/${encodeURIComponent(spaceUid)}/assets/bulk-move?workspace=${encodeURIComponent(workspaceUid)}`;
393+
return this.postJson<BulkMoveAssetsResponse>(path, payload, { space_key: spaceUid });
394+
}
367395
}

packages/contentstack-bootstrap/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@contentstack/cli-cm-bootstrap",
33
"description": "Bootstrap contentstack apps",
4-
"version": "2.0.0-beta.19",
4+
"version": "2.0.0-beta.18",
55
"author": "Contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"scripts": {
@@ -19,7 +19,7 @@
1919
"@contentstack/cli-cm-seed": "~2.0.0-beta.18",
2020
"@contentstack/cli-command": "~2.0.0-beta.7",
2121
"@contentstack/cli-utilities": "~2.0.0-beta.8",
22-
"@contentstack/cli-config": "~2.0.0-beta.9",
22+
"@contentstack/cli-config": "~2.0.0-beta.10",
2323
"@oclif/core": "^4.3.0",
2424
"inquirer": "12.11.1",
2525
"mkdirp": "^2.1.6",
@@ -70,4 +70,4 @@
7070
}
7171
},
7272
"repository": "contentstack/cli"
73-
}
73+
}

packages/contentstack-clone/src/core/util/clone-handler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ export class CloneHandler {
573573
// Resolve path to package root - go up 3 levels from __dirname (core/util -> package root)
574574
const packageRoot = path.resolve(__dirname, '../../..');
575575
const exportDir = path.join(packageRoot, 'contents');
576+
this.config.contentDir = exportDir;
576577
log.debug(`Export directory: ${exportDir}`, this.config.cloneContext);
577578
const cmd: string[] = ['-k', exportConfig.apiKey || exportConfig.source_stack, '-d', exportDir];
578579

@@ -807,7 +808,7 @@ export class CloneHandler {
807808
// Export root only (single-branch layout: modules live directly under -d, not pathDir/<branch>)
808809
const cloneTypePackageRoot = path.resolve(__dirname, '../../..');
809810
this.config.contentDir =
810-
this.config.pathDir || path.join(cloneTypePackageRoot, 'contents');
811+
this.config.contentDir || this.config.pathDir || path.join(cloneTypePackageRoot, 'contents');
811812
log.debug(`Clone content directory: ${this.config.contentDir}`, this.config.cloneContext);
812813

813814
if (!this.config.cloneType) {

packages/contentstack-export/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dependencies": {
88
"@contentstack/cli-command": "~2.0.0-beta.7",
99
"@contentstack/cli-utilities": "~2.0.0-beta.8",
10-
"@contentstack/cli-variants": "~2.0.0-beta.13",
10+
"@contentstack/cli-variants": "~2.0.0-beta.14",
1111
"@contentstack/cli-asset-management": "~1.0.0-beta.2",
1212
"@oclif/core": "^4.8.0",
1313
"async": "^3.2.6",
@@ -23,7 +23,7 @@
2323
},
2424
"devDependencies": {
2525
"@contentstack/cli-auth": "~2.0.0-beta.12",
26-
"@contentstack/cli-config": "~2.0.0-beta.9",
26+
"@contentstack/cli-config": "~2.0.0-beta.10",
2727
"@contentstack/cli-dev-dependencies": "~2.0.0-beta.0",
2828
"@oclif/plugin-help": "^6.2.28",
2929
"@oclif/test": "^4.1.18",
@@ -99,4 +99,4 @@
9999
}
100100
},
101101
"repository": "https://github.com/contentstack/cli"
102-
}
102+
}

packages/contentstack-import/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"@contentstack/cli-audit": "~2.0.0-beta.12",
99
"@contentstack/cli-command": "~2.0.0-beta.7",
1010
"@contentstack/cli-utilities": "~2.0.0-beta.8",
11-
"@contentstack/cli-variants": "~2.0.0-beta.13",
11+
"@contentstack/cli-variants": "~2.0.0-beta.14",
1212
"@contentstack/cli-asset-management": "~1.0.0-beta.2",
1313
"@oclif/core": "^4.3.0",
1414
"big-json": "^3.2.0",

packages/contentstack-import/src/utils/asset-helper.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,12 @@ export const lookupAssets = function (
266266
}
267267

268268
find(data.content_type.schema, data.entry);
269+
// findFileUrls scans the whole entry object, but is only triggered inside find() when a
270+
// text field has markdown/rich_text_type metadata. Content types with no such fields
271+
// (e.g. those storing asset URLs in plain text fields) never call findFileUrls, so URLs
272+
// in those fields are never collected. Calling it once unconditionally here ensures all
273+
// asset URLs in the entry are always captured, regardless of schema shape.
274+
findFileUrls({ field_metadata: {} }, data.entry, assetUrls);
269275
updateFileFields(data.entry, data, null, mappedAssetUids, matchedUids, unmatchedUids, mappedAssetUrls);
270276
assetUids = _.uniq(assetUids);
271277
assetUrls = _.uniq(assetUrls);

packages/contentstack-import/src/utils/import-config-handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,14 @@ const setupConfig = async (importCmdFlags: any): Promise<ImportConfig> => {
138138

139139
if (existsSync(spacesDir) && existsSync(stackSettingsPath)) {
140140
try {
141-
const stackSettings = JSON.parse(readFileSync(stackSettingsPath));
141+
const stackSettings = readFileSync(stackSettingsPath);
142142
if (stackSettings?.am_v2) {
143143
config.csAssetsEnabled = true;
144144
config.csAssetsUrl = configHandler.get('region')?.csAssetsUrl;
145145

146146
if (existsSync(stackJsonPath)) {
147147
try {
148-
const stackData = JSON.parse(readFileSync(stackJsonPath));
148+
const stackData = readFileSync(stackJsonPath);
149149
const apiKey = stackData?.api_key || stackData?.stackHeaders?.api_key;
150150
if (apiKey) {
151151
config.source_stack = apiKey;

packages/contentstack-query-export/src/core/module-exporter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class ModuleExporter {
6363
if (options.alias) {
6464
cmd.push('-a', options.alias);
6565
} else if (this.exportQueryConfig.managementToken) {
66-
cmd.push('-a', this.exportQueryConfig.managementToken);
66+
cmd.push('-a', this.exportQueryConfig.alias);
6767
}
6868

6969
// Branch

0 commit comments

Comments
 (0)