@anakonn/ankk 0.1.2 → 0.1.4
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.
- package/dist/index.js +209 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2157,7 +2157,7 @@ var {
|
|
|
2157
2157
|
// package.json
|
|
2158
2158
|
var package_default = {
|
|
2159
2159
|
name: "@anakonn/ankk",
|
|
2160
|
-
version: "0.1.
|
|
2160
|
+
version: "0.1.4",
|
|
2161
2161
|
description: "Bun-first CLI for the ankk public API.",
|
|
2162
2162
|
private: false,
|
|
2163
2163
|
license: "UNLICENSED",
|
|
@@ -17377,13 +17377,16 @@ var readProcessStdin = async () => Bun.stdin.text();
|
|
|
17377
17377
|
import { readFile as readFile3, stat } from "fs/promises";
|
|
17378
17378
|
import { basename } from "path";
|
|
17379
17379
|
var runMediaUploadCommand = async ({
|
|
17380
|
+
alt,
|
|
17380
17381
|
brandRef,
|
|
17381
17382
|
client,
|
|
17382
17383
|
contentType,
|
|
17384
|
+
description,
|
|
17383
17385
|
fetch,
|
|
17384
17386
|
file: file2,
|
|
17385
17387
|
io,
|
|
17386
|
-
outputMode: outputMode2
|
|
17388
|
+
outputMode: outputMode2,
|
|
17389
|
+
type
|
|
17387
17390
|
}) => {
|
|
17388
17391
|
const upload = await readMediaUploadFile(file2, contentType);
|
|
17389
17392
|
const prepared = responseOrThrow(await client.POST("/v1/media/uploads", {
|
|
@@ -17404,10 +17407,21 @@ var runMediaUploadCommand = async ({
|
|
|
17404
17407
|
if (!uploaded.ok) {
|
|
17405
17408
|
throw new Error(`Media upload failed with HTTP ${uploaded.status}.`);
|
|
17406
17409
|
}
|
|
17410
|
+
const media = responseOrThrow(await client.POST("/v1/media", {
|
|
17411
|
+
body: {
|
|
17412
|
+
brand_ref: brandRef,
|
|
17413
|
+
origin_url: prepared.origin_url,
|
|
17414
|
+
content_type: prepared.content_type,
|
|
17415
|
+
...type ? { type } : {},
|
|
17416
|
+
...alt !== undefined ? { alt } : {},
|
|
17417
|
+
...description !== undefined ? { description } : {}
|
|
17418
|
+
}
|
|
17419
|
+
}));
|
|
17407
17420
|
writeOutput(io, outputMode2, {
|
|
17408
|
-
...
|
|
17421
|
+
...media,
|
|
17409
17422
|
uploaded: true
|
|
17410
|
-
}, `
|
|
17423
|
+
}, `media_ref: ${media.media_ref}
|
|
17424
|
+
url: ${media.url}`);
|
|
17411
17425
|
};
|
|
17412
17426
|
var mediaUploadPolicies = {
|
|
17413
17427
|
".gif": { contentType: "image/gif", maxSize: 20 * 1024 * 1024 },
|
|
@@ -17565,6 +17579,113 @@ var createProgram = ({
|
|
|
17565
17579
|
}));
|
|
17566
17580
|
writeOutput(context.io, context.outputMode, result, `Brand profile updated: ${result.brand_ref}`);
|
|
17567
17581
|
});
|
|
17582
|
+
const brandWiki = brands.command("wiki").description("Manage Brand Wiki documents");
|
|
17583
|
+
const brandWikiHome = brandWiki.command("home").description("Manage Brand Wiki Home");
|
|
17584
|
+
brandWikiHome.command("get").description("Get Brand Wiki Home").requiredOption("--brand-ref <brand_ref>", "Brand reference").action(async (options) => {
|
|
17585
|
+
const context = await resolveCommandContext({ env, fetch, io, program: program2 });
|
|
17586
|
+
const result = responseOrThrow(await context.client.GET("/v1/brands/{brand_ref}/wiki/home", {
|
|
17587
|
+
params: { path: { brand_ref: options.brandRef } }
|
|
17588
|
+
}));
|
|
17589
|
+
writeOutput(context.io, context.outputMode, result, formatBrandWikiEntry(result));
|
|
17590
|
+
});
|
|
17591
|
+
brandWikiHome.command("patch").description("Update Brand Wiki Home").requiredOption("--brand-ref <brand_ref>", "Brand reference").requiredOption("--file <path>", "JSON request body file, or - for stdin").action(async (options) => {
|
|
17592
|
+
const context = await resolveCommandContext({ env, fetch, io, program: program2 });
|
|
17593
|
+
const body = apiBody(readObjectBody(await readJsonInput(options.file), "Brand Wiki Home patch body"));
|
|
17594
|
+
const result = responseOrThrow(await context.client.PATCH("/v1/brands/{brand_ref}/wiki/home", {
|
|
17595
|
+
body,
|
|
17596
|
+
params: { path: { brand_ref: options.brandRef } }
|
|
17597
|
+
}));
|
|
17598
|
+
writeOutput(context.io, context.outputMode, result, `Brand Wiki Home updated: ${result.brand_ref}`);
|
|
17599
|
+
});
|
|
17600
|
+
withBrandRef(brandWiki.command("list").description("List searchable Brand Wiki entries")).action(async (options) => {
|
|
17601
|
+
const context = await resolveCommandContext({ env, fetch, io, program: program2 });
|
|
17602
|
+
const result = responseOrThrow(await context.client.GET("/v1/brands/{brand_ref}/wiki", {
|
|
17603
|
+
params: { path: { brand_ref: options.brandRef } }
|
|
17604
|
+
}));
|
|
17605
|
+
writeOutput(context.io, context.outputMode, result, formatGenericRead(result));
|
|
17606
|
+
});
|
|
17607
|
+
withBrandRef(brandWiki.command("create").description("Create a Brand Wiki entry").requiredOption("--file <path>", "JSON request body file, or - for stdin")).action(async (options) => {
|
|
17608
|
+
const context = await resolveCommandContext({ env, fetch, io, program: program2 });
|
|
17609
|
+
const body = apiBody(readObjectBody(await readJsonInput(options.file), "Brand Wiki create body"));
|
|
17610
|
+
const result = responseOrThrow(await context.client.POST("/v1/brands/{brand_ref}/wiki", {
|
|
17611
|
+
body,
|
|
17612
|
+
params: { path: { brand_ref: options.brandRef } }
|
|
17613
|
+
}));
|
|
17614
|
+
writeOutput(context.io, context.outputMode, result, `Brand Wiki entry created: ${result.entry_id}`);
|
|
17615
|
+
});
|
|
17616
|
+
withBrandRef(brandWiki.command("search").description("Search Brand Wiki entries").requiredOption("--query <text>", "Search query")).option("--limit <number>", "Maximum results", parsePositiveInteger).action(async (options) => {
|
|
17617
|
+
const context = await resolveCommandContext({ env, fetch, io, program: program2 });
|
|
17618
|
+
const result = responseOrThrow(await context.client.GET("/v1/brands/{brand_ref}/wiki/search", {
|
|
17619
|
+
params: {
|
|
17620
|
+
path: { brand_ref: options.brandRef },
|
|
17621
|
+
query: {
|
|
17622
|
+
...options.limit !== undefined ? { limit: options.limit } : {},
|
|
17623
|
+
q: options.query
|
|
17624
|
+
}
|
|
17625
|
+
}
|
|
17626
|
+
}));
|
|
17627
|
+
writeOutput(context.io, context.outputMode, result, formatGenericRead(result));
|
|
17628
|
+
});
|
|
17629
|
+
withBrandRef(brandWiki.command("pending").description("List pending Brand Wiki user questions")).action(async (options) => {
|
|
17630
|
+
const context = await resolveCommandContext({ env, fetch, io, program: program2 });
|
|
17631
|
+
const result = responseOrThrow(await context.client.GET("/v1/brands/{brand_ref}/wiki/pending", {
|
|
17632
|
+
params: { path: { brand_ref: options.brandRef } }
|
|
17633
|
+
}));
|
|
17634
|
+
writeOutput(context.io, context.outputMode, result, formatGenericRead(result));
|
|
17635
|
+
});
|
|
17636
|
+
withBrandRef(brandWiki.command("trash").description("List deleted Brand Wiki entries")).action(async (options) => {
|
|
17637
|
+
const context = await resolveCommandContext({ env, fetch, io, program: program2 });
|
|
17638
|
+
const result = responseOrThrow(await context.client.GET("/v1/brands/{brand_ref}/wiki/trash", {
|
|
17639
|
+
params: { path: { brand_ref: options.brandRef } }
|
|
17640
|
+
}));
|
|
17641
|
+
writeOutput(context.io, context.outputMode, result, formatGenericRead(result));
|
|
17642
|
+
});
|
|
17643
|
+
withBrandRef(brandWiki.command("get").description("Get a Brand Wiki entry").argument("<entry_id>", "Brand Wiki entry id")).action(async (entryId, options) => {
|
|
17644
|
+
const context = await resolveCommandContext({ env, fetch, io, program: program2 });
|
|
17645
|
+
const result = responseOrThrow(await context.client.GET("/v1/brands/{brand_ref}/wiki/{entry_id}", {
|
|
17646
|
+
params: { path: { brand_ref: options.brandRef, entry_id: entryId } }
|
|
17647
|
+
}));
|
|
17648
|
+
writeOutput(context.io, context.outputMode, result, formatBrandWikiEntry(result));
|
|
17649
|
+
});
|
|
17650
|
+
withBrandRef(brandWiki.command("patch").description("Update a Brand Wiki entry").argument("<entry_id>", "Brand Wiki entry id").requiredOption("--file <path>", "JSON request body file, or - for stdin")).action(async (entryId, options) => {
|
|
17651
|
+
const context = await resolveCommandContext({ env, fetch, io, program: program2 });
|
|
17652
|
+
const body = apiBody(readObjectBody(await readJsonInput(options.file), "Brand Wiki patch body"));
|
|
17653
|
+
const result = responseOrThrow(await context.client.PATCH("/v1/brands/{brand_ref}/wiki/{entry_id}", {
|
|
17654
|
+
body,
|
|
17655
|
+
params: { path: { brand_ref: options.brandRef, entry_id: entryId } }
|
|
17656
|
+
}));
|
|
17657
|
+
writeOutput(context.io, context.outputMode, result, `Brand Wiki entry updated: ${result.entry_id}`);
|
|
17658
|
+
});
|
|
17659
|
+
for (const command of [
|
|
17660
|
+
{
|
|
17661
|
+
method: "DELETE",
|
|
17662
|
+
name: "delete",
|
|
17663
|
+
path: "/v1/brands/{brand_ref}/wiki/{entry_id}",
|
|
17664
|
+
text: "Soft delete a Brand Wiki entry"
|
|
17665
|
+
},
|
|
17666
|
+
{
|
|
17667
|
+
method: "DELETE",
|
|
17668
|
+
name: "purge",
|
|
17669
|
+
path: "/v1/brands/{brand_ref}/wiki/{entry_id}/purge",
|
|
17670
|
+
text: "Permanently delete a Brand Wiki entry"
|
|
17671
|
+
},
|
|
17672
|
+
{
|
|
17673
|
+
method: "POST",
|
|
17674
|
+
name: "restore",
|
|
17675
|
+
path: "/v1/brands/{brand_ref}/wiki/{entry_id}/restore",
|
|
17676
|
+
text: "Restore a deleted Brand Wiki entry"
|
|
17677
|
+
}
|
|
17678
|
+
]) {
|
|
17679
|
+
withBrandRef(brandWiki.command(command.name).description(command.text).argument("<entry_id>", "Brand Wiki entry id")).action(async (entryId, options) => {
|
|
17680
|
+
const context = await resolveCommandContext({ env, fetch, io, program: program2 });
|
|
17681
|
+
const result = responseOrThrow(command.method === "POST" ? await context.client.POST(command.path, {
|
|
17682
|
+
params: { path: { brand_ref: options.brandRef, entry_id: entryId } }
|
|
17683
|
+
}) : await context.client.DELETE(command.path, {
|
|
17684
|
+
params: { path: { brand_ref: options.brandRef, entry_id: entryId } }
|
|
17685
|
+
}));
|
|
17686
|
+
writeOutput(context.io, context.outputMode, result, `Brand Wiki entry ${command.name}: ${result.entry_id}`);
|
|
17687
|
+
});
|
|
17688
|
+
}
|
|
17568
17689
|
const connections = program2.command("connections").description("Read SNS provider connections");
|
|
17569
17690
|
withBrandRef(connections.command("list").description("List provider connections")).option("--sns-type <sns_type>", "SNS type filter").action(async (options) => {
|
|
17570
17691
|
const context = await resolveCommandContext({ env, fetch, io, program: program2 });
|
|
@@ -17626,19 +17747,70 @@ var createProgram = ({
|
|
|
17626
17747
|
}));
|
|
17627
17748
|
writeOutput(context.io, context.outputMode, result, formatContentPublishResult(result, body));
|
|
17628
17749
|
});
|
|
17629
|
-
const media = program2.command("media").description("
|
|
17630
|
-
withBrandRef(media.command("
|
|
17750
|
+
const media = program2.command("media").description("Manage brand-owned media assets");
|
|
17751
|
+
withBrandRef(media.command("list").description("List brand-owned media")).option("--kind <kind>", "Media kind filter: image, video").option("--type <type>", "Media type filter: logo, banner, product, gallery, other").action(async (options) => {
|
|
17752
|
+
const context = await resolveCommandContext({ env, fetch, io, program: program2 });
|
|
17753
|
+
const kind = options.kind ? parseMediaKind(options.kind) : undefined;
|
|
17754
|
+
const type = options.type ? parseMediaType(options.type) : undefined;
|
|
17755
|
+
const result = responseOrThrow(await context.client.GET("/v1/media", {
|
|
17756
|
+
params: {
|
|
17757
|
+
query: {
|
|
17758
|
+
brand_ref: options.brandRef,
|
|
17759
|
+
...kind ? { kind } : {},
|
|
17760
|
+
...type ? { type } : {}
|
|
17761
|
+
}
|
|
17762
|
+
}
|
|
17763
|
+
}));
|
|
17764
|
+
writeOutput(context.io, context.outputMode, result, formatGenericRead(result));
|
|
17765
|
+
});
|
|
17766
|
+
withBrandRef(media.command("upload").description("Upload and register an image or video file").argument("<file>", "Media file path")).option("--type <type>", "Media type: logo, banner, product, gallery, other").option("--alt <text>", "Alternative text").option("--description <text>", "Media description").option("--content-type <content_type>", "Override detected MIME type").action(async (file2, options) => {
|
|
17631
17767
|
const context = await resolveCommandContext({ env, fetch, io, program: program2 });
|
|
17632
17768
|
await runMediaUploadCommand({
|
|
17769
|
+
alt: options.alt,
|
|
17633
17770
|
brandRef: options.brandRef,
|
|
17634
17771
|
client: context.client,
|
|
17635
17772
|
contentType: options.contentType,
|
|
17773
|
+
description: options.description,
|
|
17636
17774
|
fetch,
|
|
17637
17775
|
file: file2,
|
|
17638
17776
|
io: context.io,
|
|
17639
|
-
outputMode: context.outputMode
|
|
17777
|
+
outputMode: context.outputMode,
|
|
17778
|
+
type: options.type ? parseMediaType(options.type) : undefined
|
|
17640
17779
|
});
|
|
17641
17780
|
});
|
|
17781
|
+
withBrandRef(media.command("update").description("Update media metadata").argument("<media_ref>", "Media reference")).option("--type <type>", "Media type: logo, banner, product, gallery, other").option("--alt <text>", "Alternative text").option("--description <text>", "Media description").action(async (mediaRef, options) => {
|
|
17782
|
+
const context = await resolveCommandContext({ env, fetch, io, program: program2 });
|
|
17783
|
+
const result = responseOrThrow(await context.client.PATCH("/v1/media/{media_ref}", {
|
|
17784
|
+
body: apiBody({
|
|
17785
|
+
...options.type ? { type: parseMediaType(options.type) } : {},
|
|
17786
|
+
...options.alt !== undefined ? { alt: options.alt } : {},
|
|
17787
|
+
...options.description !== undefined ? { description: options.description } : {}
|
|
17788
|
+
}),
|
|
17789
|
+
params: {
|
|
17790
|
+
path: {
|
|
17791
|
+
media_ref: mediaRef
|
|
17792
|
+
},
|
|
17793
|
+
query: {
|
|
17794
|
+
brand_ref: options.brandRef
|
|
17795
|
+
}
|
|
17796
|
+
}
|
|
17797
|
+
}));
|
|
17798
|
+
writeOutput(context.io, context.outputMode, result, `Media updated: ${result.media_ref}`);
|
|
17799
|
+
});
|
|
17800
|
+
withBrandRef(media.command("delete").description("Delete media metadata").argument("<media_ref>", "Media reference")).action(async (mediaRef, options) => {
|
|
17801
|
+
const context = await resolveCommandContext({ env, fetch, io, program: program2 });
|
|
17802
|
+
const result = responseOrThrow(await context.client.DELETE("/v1/media/{media_ref}", {
|
|
17803
|
+
params: {
|
|
17804
|
+
path: {
|
|
17805
|
+
media_ref: mediaRef
|
|
17806
|
+
},
|
|
17807
|
+
query: {
|
|
17808
|
+
brand_ref: options.brandRef
|
|
17809
|
+
}
|
|
17810
|
+
}
|
|
17811
|
+
}));
|
|
17812
|
+
writeOutput(context.io, context.outputMode, result, `Media deleted: ${result.media_ref}`);
|
|
17813
|
+
});
|
|
17642
17814
|
withBrandRef(content.command("cancel").description("Cancel scheduled SNS content").argument("<content_id>", "Content id")).option("--file <path>", "JSON request body file, or - for stdin").action(async (contentId, options) => {
|
|
17643
17815
|
const context = await resolveCommandContext({ env, fetch, io, program: program2 });
|
|
17644
17816
|
const body = await readBodyOrBrandRef(options, "SNS content cancel body");
|
|
@@ -17985,6 +18157,18 @@ var formatBrandInfo = (response) => {
|
|
|
17985
18157
|
].join(`
|
|
17986
18158
|
`);
|
|
17987
18159
|
};
|
|
18160
|
+
var formatBrandWikiEntry = (response) => [
|
|
18161
|
+
`entry_id: ${response.entry_id}`,
|
|
18162
|
+
`brand_ref: ${response.brand_ref}`,
|
|
18163
|
+
`type: ${response.type}`,
|
|
18164
|
+
`title: ${response.title}`,
|
|
18165
|
+
`question: ${response.question ?? "none"}`,
|
|
18166
|
+
`is_active: ${response.is_active ? "yes" : "no"}`,
|
|
18167
|
+
`body_length: ${response.body_markdown?.length ?? 0}`,
|
|
18168
|
+
`summary_length: ${response.summary?.length ?? 0}`,
|
|
18169
|
+
`updated_at: ${response.updated_at}`
|
|
18170
|
+
].join(`
|
|
18171
|
+
`);
|
|
17988
18172
|
var readBrandInfoPatchBody = (value) => {
|
|
17989
18173
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
17990
18174
|
throw new Error("Brand info patch body must be a JSON object.");
|
|
@@ -17998,6 +18182,24 @@ var readObjectBody = (value, name) => {
|
|
|
17998
18182
|
return value;
|
|
17999
18183
|
};
|
|
18000
18184
|
var apiBody = (body) => body;
|
|
18185
|
+
var parsePositiveInteger = (value) => {
|
|
18186
|
+
const parsed = Number.parseInt(value, 10);
|
|
18187
|
+
if (!Number.isInteger(parsed) || parsed <= 0)
|
|
18188
|
+
throw new Error(`Expected a positive integer: ${value}`);
|
|
18189
|
+
return parsed;
|
|
18190
|
+
};
|
|
18191
|
+
var mediaKinds = ["image", "video"];
|
|
18192
|
+
var mediaTypes = ["logo", "banner", "product", "gallery", "other"];
|
|
18193
|
+
var parseMediaKind = (value) => {
|
|
18194
|
+
if (mediaKinds.includes(value))
|
|
18195
|
+
return value;
|
|
18196
|
+
throw new Error(`Unsupported media kind: ${value}`);
|
|
18197
|
+
};
|
|
18198
|
+
var parseMediaType = (value) => {
|
|
18199
|
+
if (mediaTypes.includes(value))
|
|
18200
|
+
return value;
|
|
18201
|
+
throw new Error(`Unsupported media type: ${value}`);
|
|
18202
|
+
};
|
|
18001
18203
|
var readBodyOrBrandRef = async (options, name) => {
|
|
18002
18204
|
if (options.file) {
|
|
18003
18205
|
return readObjectBody(await readJsonInput(options.file), name);
|