@neopress/cli 4.0.0 → 4.2.0

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.
Files changed (4) hide show
  1. package/README.md +109 -0
  2. package/dist/bin.cjs +697 -117
  3. package/dist/index.js +207 -44
  4. package/package.json +12 -2
package/dist/index.js CHANGED
@@ -18,11 +18,11 @@ function __rest(s, e) {
18
18
  }
19
19
  function __awaiter(thisArg, _arguments, P, generator) {
20
20
  function adopt(value) {
21
- return value instanceof P ? value : new P(function(resolve) {
22
- resolve(value);
21
+ return value instanceof P ? value : new P(function(resolve2) {
22
+ resolve2(value);
23
23
  });
24
24
  }
25
- return new (P || (P = Promise))(function(resolve, reject) {
25
+ return new (P || (P = Promise))(function(resolve2, reject) {
26
26
  function fulfilled(value) {
27
27
  try {
28
28
  step(generator.next(value));
@@ -38,7 +38,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
38
38
  }
39
39
  }
40
40
  function step(result) {
41
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
41
+ result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
42
42
  }
43
43
  step((generator = generator.apply(thisArg, _arguments || [])).next());
44
44
  });
@@ -409,18 +409,18 @@ var PostgrestError = class extends Error {
409
409
  }
410
410
  };
411
411
  function sleep(ms, signal) {
412
- return new Promise((resolve) => {
412
+ return new Promise((resolve2) => {
413
413
  if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
414
- resolve();
414
+ resolve2();
415
415
  return;
416
416
  }
417
417
  const id = setTimeout(() => {
418
418
  signal === null || signal === void 0 || signal.removeEventListener("abort", onAbort);
419
- resolve();
419
+ resolve2();
420
420
  }, ms);
421
421
  function onAbort() {
422
422
  clearTimeout(id);
423
- resolve();
423
+ resolve2();
424
424
  }
425
425
  signal === null || signal === void 0 || signal.addEventListener("abort", onAbort);
426
426
  });
@@ -8369,15 +8369,15 @@ var RealtimeChannel = class _RealtimeChannel {
8369
8369
  }
8370
8370
  }
8371
8371
  } else {
8372
- return new Promise((resolve) => {
8372
+ return new Promise((resolve2) => {
8373
8373
  var _a3, _b2, _c;
8374
8374
  const push = this.channelAdapter.push(args.type, args, opts.timeout || this.timeout);
8375
8375
  if (args.type === "broadcast" && !((_c = (_b2 = (_a3 = this.params) === null || _a3 === void 0 ? void 0 : _a3.config) === null || _b2 === void 0 ? void 0 : _b2.broadcast) === null || _c === void 0 ? void 0 : _c.ack)) {
8376
- resolve("ok");
8376
+ resolve2("ok");
8377
8377
  }
8378
- push.receive("ok", () => resolve("ok"));
8379
- push.receive("error", () => resolve("error"));
8380
- push.receive("timeout", () => resolve("timed out"));
8378
+ push.receive("ok", () => resolve2("ok"));
8379
+ push.receive("error", () => resolve2("error"));
8380
+ push.receive("timeout", () => resolve2("timed out"));
8381
8381
  });
8382
8382
  }
8383
8383
  }
@@ -8402,8 +8402,8 @@ var RealtimeChannel = class _RealtimeChannel {
8402
8402
  * @category Realtime
8403
8403
  */
8404
8404
  async unsubscribe(timeout = this.timeout) {
8405
- return new Promise((resolve) => {
8406
- this.channelAdapter.unsubscribe(timeout).receive("ok", () => resolve("ok")).receive("timeout", () => resolve("timed out")).receive("error", () => resolve("error"));
8405
+ return new Promise((resolve2) => {
8406
+ this.channelAdapter.unsubscribe(timeout).receive("ok", () => resolve2("ok")).receive("timeout", () => resolve2("timed out")).receive("error", () => resolve2("error"));
8407
8407
  });
8408
8408
  }
8409
8409
  /**
@@ -8484,8 +8484,8 @@ var RealtimeChannel = class _RealtimeChannel {
8484
8484
  }
8485
8485
  /** @internal */
8486
8486
  _notThisChannelEvent(event, ref) {
8487
- const { close, error: error48, leave, join: join2 } = CHANNEL_EVENTS;
8488
- const events = [close, error48, leave, join2];
8487
+ const { close, error: error48, leave, join: join3 } = CHANNEL_EVENTS;
8488
+ const events = [close, error48, leave, join3];
8489
8489
  return ref && events.includes(event) && ref !== this.joinPush.ref;
8490
8490
  }
8491
8491
  /** @internal */
@@ -8598,11 +8598,11 @@ var SocketAdapter = class {
8598
8598
  this.socket.connect();
8599
8599
  }
8600
8600
  disconnect(callback, code, reason, timeout = 1e4) {
8601
- return new Promise((resolve) => {
8602
- setTimeout(() => resolve("timeout"), timeout);
8601
+ return new Promise((resolve2) => {
8602
+ setTimeout(() => resolve2("timeout"), timeout);
8603
8603
  this.socket.disconnect(() => {
8604
8604
  callback();
8605
- resolve("ok");
8605
+ resolve2("ok");
8606
8606
  }, code, reason);
8607
8607
  });
8608
8608
  }
@@ -10016,7 +10016,7 @@ var _getRequestParams = (method, options, parameters, body) => {
10016
10016
  return _objectSpread22(_objectSpread22({}, params), parameters);
10017
10017
  };
10018
10018
  async function _handleRequest(fetcher, method, url2, options, parameters, body, namespace) {
10019
- return new Promise((resolve, reject) => {
10019
+ return new Promise((resolve2, reject) => {
10020
10020
  fetcher(url2, _getRequestParams(method, options, parameters, body)).then((result) => {
10021
10021
  if (!result.ok) throw result;
10022
10022
  if (options === null || options === void 0 ? void 0 : options.noResolveJson) return result;
@@ -10026,7 +10026,7 @@ async function _handleRequest(fetcher, method, url2, options, parameters, body,
10026
10026
  if (!contentType || !contentType.includes("application/json")) return {};
10027
10027
  }
10028
10028
  return result.json();
10029
- }).then((data) => resolve(data)).catch((error48) => handleError(error48, reject, options, namespace));
10029
+ }).then((data) => resolve2(data)).catch((error48) => handleError(error48, reject, options, namespace));
10030
10030
  });
10031
10031
  }
10032
10032
  function createFetchApi(namespace = "storage") {
@@ -20271,11 +20271,11 @@ var DEFAULT_TRACE_PROPAGATION_OPTIONS = {
20271
20271
  };
20272
20272
  function __awaiter2(thisArg, _arguments, P, generator) {
20273
20273
  function adopt(value) {
20274
- return value instanceof P ? value : new P(function(resolve) {
20275
- resolve(value);
20274
+ return value instanceof P ? value : new P(function(resolve2) {
20275
+ resolve2(value);
20276
20276
  });
20277
20277
  }
20278
- return new (P || (P = Promise))(function(resolve, reject) {
20278
+ return new (P || (P = Promise))(function(resolve2, reject) {
20279
20279
  function fulfilled(value) {
20280
20280
  try {
20281
20281
  step(generator.next(value));
@@ -20291,7 +20291,7 @@ function __awaiter2(thisArg, _arguments, P, generator) {
20291
20291
  }
20292
20292
  }
20293
20293
  function step(result) {
20294
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
20294
+ result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
20295
20295
  }
20296
20296
  step((generator = generator.apply(thisArg, _arguments || [])).next());
20297
20297
  });
@@ -21146,6 +21146,27 @@ function serializeTemplate(t) {
21146
21146
  createdAt: t.created_at
21147
21147
  };
21148
21148
  }
21149
+ function serializeHeadshot(h) {
21150
+ return {
21151
+ id: h.id,
21152
+ imageUrl: h.image_url,
21153
+ width: h.width,
21154
+ height: h.height,
21155
+ aspectRatio: h.aspect_ratio,
21156
+ mimeType: h.mime_type,
21157
+ byteSize: h.byte_size,
21158
+ ageBand: h.age_band,
21159
+ gender: h.gender,
21160
+ ethnicity: h.ethnicity,
21161
+ attire: h.attire,
21162
+ variationIndex: h.variation_index,
21163
+ gptPrompt: h.gpt_prompt,
21164
+ tags: h.tags ?? [],
21165
+ isActive: h.is_active,
21166
+ createdAt: h.created_at,
21167
+ updatedAt: h.updated_at
21168
+ };
21169
+ }
21149
21170
  function serializeSite(site) {
21150
21171
  return {
21151
21172
  id: site.id,
@@ -35492,8 +35513,8 @@ var SiteHistoryService = class _SiteHistoryService {
35492
35513
  const previousLock = _SiteHistoryService.sessionLocks.get(key) ?? Promise.resolve();
35493
35514
  let releaseCurrentLock = () => {
35494
35515
  };
35495
- const currentLock = new Promise((resolve) => {
35496
- releaseCurrentLock = resolve;
35516
+ const currentLock = new Promise((resolve2) => {
35517
+ releaseCurrentLock = resolve2;
35497
35518
  });
35498
35519
  const queuedLock = previousLock.catch(() => {
35499
35520
  }).then(() => currentLock);
@@ -36828,6 +36849,113 @@ var TemplatesEndpoint = class {
36828
36849
  }
36829
36850
  };
36830
36851
 
36852
+ // ../sdk/dist/endpoints/headshots.js
36853
+ var HeadshotsEndpoint = class {
36854
+ client;
36855
+ constructor(client) {
36856
+ this.client = client;
36857
+ }
36858
+ async list(params) {
36859
+ const { page, limit, offset } = this.client.resolvePagination(params);
36860
+ let query = this.client.db.from("headshot_pool").select("*", { count: "exact" });
36861
+ if (params?.ageBand)
36862
+ query = query.eq("age_band", params.ageBand);
36863
+ if (params?.gender)
36864
+ query = query.eq("gender", params.gender);
36865
+ if (params?.ethnicity)
36866
+ query = query.eq("ethnicity", params.ethnicity);
36867
+ if (params?.attire)
36868
+ query = query.eq("attire", params.attire);
36869
+ if (params?.isActive !== void 0)
36870
+ query = query.eq("is_active", params.isActive);
36871
+ const { data, error: error48, count } = await query.order("age_band", { ascending: true }).order("gender", { ascending: true }).order("ethnicity", { ascending: true }).order("variation_index", { ascending: true }).range(offset, offset + limit - 1);
36872
+ if (error48)
36873
+ throw new NeopressApiError("DB_ERROR", error48.message, 0, error48);
36874
+ return {
36875
+ data: (data ?? []).map((r) => serializeHeadshot(r)),
36876
+ pagination: this.client.paginationMeta(page, limit, offset, count ?? 0)
36877
+ };
36878
+ }
36879
+ async get(id) {
36880
+ const { data, error: error48 } = await this.client.db.from("headshot_pool").select("*").eq("id", id).single();
36881
+ if (error48)
36882
+ throw new NeopressApiError("DB_ERROR", error48.message, 0, error48);
36883
+ return serializeHeadshot(data);
36884
+ }
36885
+ async create(params) {
36886
+ const values = {
36887
+ image_url: params.imageUrl,
36888
+ age_band: params.ageBand,
36889
+ gender: params.gender,
36890
+ ethnicity: params.ethnicity,
36891
+ variation_index: params.variationIndex
36892
+ };
36893
+ if (params.attire !== void 0)
36894
+ values.attire = params.attire;
36895
+ if (params.width !== void 0)
36896
+ values.width = params.width;
36897
+ if (params.height !== void 0)
36898
+ values.height = params.height;
36899
+ if (params.aspectRatio !== void 0)
36900
+ values.aspect_ratio = params.aspectRatio;
36901
+ if (params.mimeType !== void 0)
36902
+ values.mime_type = params.mimeType;
36903
+ if (params.byteSize !== void 0)
36904
+ values.byte_size = params.byteSize;
36905
+ if (params.gptPrompt !== void 0)
36906
+ values.gpt_prompt = params.gptPrompt;
36907
+ if (params.tags !== void 0)
36908
+ values.tags = params.tags;
36909
+ if (params.isActive !== void 0)
36910
+ values.is_active = params.isActive;
36911
+ const { data, error: error48 } = await this.client.db.from("headshot_pool").insert(values).select().single();
36912
+ if (error48)
36913
+ throw new NeopressApiError("DB_ERROR", error48.message, 0, error48);
36914
+ return serializeHeadshot(data);
36915
+ }
36916
+ async update(id, params) {
36917
+ const values = {};
36918
+ if (params.imageUrl !== void 0)
36919
+ values.image_url = params.imageUrl;
36920
+ if (params.ageBand !== void 0)
36921
+ values.age_band = params.ageBand;
36922
+ if (params.gender !== void 0)
36923
+ values.gender = params.gender;
36924
+ if (params.ethnicity !== void 0)
36925
+ values.ethnicity = params.ethnicity;
36926
+ if (params.attire !== void 0)
36927
+ values.attire = params.attire;
36928
+ if (params.variationIndex !== void 0)
36929
+ values.variation_index = params.variationIndex;
36930
+ if (params.width !== void 0)
36931
+ values.width = params.width;
36932
+ if (params.height !== void 0)
36933
+ values.height = params.height;
36934
+ if (params.aspectRatio !== void 0)
36935
+ values.aspect_ratio = params.aspectRatio;
36936
+ if (params.mimeType !== void 0)
36937
+ values.mime_type = params.mimeType;
36938
+ if (params.byteSize !== void 0)
36939
+ values.byte_size = params.byteSize;
36940
+ if (params.gptPrompt !== void 0)
36941
+ values.gpt_prompt = params.gptPrompt;
36942
+ if (params.tags !== void 0)
36943
+ values.tags = params.tags;
36944
+ if (params.isActive !== void 0)
36945
+ values.is_active = params.isActive;
36946
+ const { data, error: error48 } = await this.client.db.from("headshot_pool").update(values).eq("id", id).select().single();
36947
+ if (error48)
36948
+ throw new NeopressApiError("DB_ERROR", error48.message, 0, error48);
36949
+ return serializeHeadshot(data);
36950
+ }
36951
+ async delete(id) {
36952
+ const { error: error48 } = await this.client.db.from("headshot_pool").delete().eq("id", id);
36953
+ if (error48)
36954
+ throw new NeopressApiError("DB_ERROR", error48.message, 0, error48);
36955
+ return { id, deleted: true };
36956
+ }
36957
+ };
36958
+
36831
36959
  // ../sdk/dist/client.js
36832
36960
  var NeopressClient = class {
36833
36961
  baseUrl;
@@ -36848,6 +36976,7 @@ var NeopressClient = class {
36848
36976
  entryReferences;
36849
36977
  analytics;
36850
36978
  templates;
36979
+ headshots;
36851
36980
  constructor(options) {
36852
36981
  this.baseUrl = (options.baseUrl || "https://app.neopress.ai").replace(/\/$/, "");
36853
36982
  this.accessToken = options.accessToken || "";
@@ -36866,6 +36995,7 @@ var NeopressClient = class {
36866
36995
  this.entryReferences = new EntryReferencesEndpoint(this);
36867
36996
  this.analytics = new AnalyticsEndpoint(this);
36868
36997
  this.templates = new TemplatesEndpoint(this);
36998
+ this.headshots = new HeadshotsEndpoint(this);
36869
36999
  }
36870
37000
  get siteBasePath() {
36871
37001
  return `/api/v1/sites/${this.siteId}`;
@@ -37071,23 +37201,44 @@ function fail(message, code = 1) {
37071
37201
 
37072
37202
  // src/utils/config.ts
37073
37203
  import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
37074
- import { dirname } from "path";
37204
+ import { dirname, join as join2, resolve } from "path";
37205
+ import { homedir as homedir2 } from "os";
37075
37206
  var PROJECT_CONFIG = ".neopressrc.json";
37076
37207
  var WORKSPACE_CONFIG = ".neopress/config.json";
37077
- function readProjectConfig() {
37078
- let config2 = {};
37079
- for (const file2 of [PROJECT_CONFIG, WORKSPACE_CONFIG]) {
37080
- try {
37081
- const parsed = JSON.parse(readFileSync2(file2, "utf-8"));
37082
- config2 = {
37083
- ...config2,
37084
- ...typeof parsed.siteId === "number" ? { siteId: parsed.siteId } : {},
37085
- ...typeof parsed.baseUrl === "string" ? { baseUrl: parsed.baseUrl } : {}
37086
- };
37087
- } catch {
37208
+ function readConfigFileAt(path) {
37209
+ try {
37210
+ const parsed = JSON.parse(readFileSync2(path, "utf-8"));
37211
+ return {
37212
+ ...typeof parsed.siteId === "number" ? { siteId: parsed.siteId } : {},
37213
+ ...typeof parsed.baseUrl === "string" ? { baseUrl: parsed.baseUrl } : {}
37214
+ };
37215
+ } catch {
37216
+ return {};
37217
+ }
37218
+ }
37219
+ function locateProjectConfig(startDir = process.cwd()) {
37220
+ const home = resolve(homedir2());
37221
+ let dir = resolve(startDir);
37222
+ while (true) {
37223
+ let merged = {};
37224
+ let foundPath;
37225
+ for (const rel of [PROJECT_CONFIG, WORKSPACE_CONFIG]) {
37226
+ const p = join2(dir, rel);
37227
+ const cfg = readConfigFileAt(p);
37228
+ if (Object.keys(cfg).length > 0) {
37229
+ merged = { ...merged, ...cfg };
37230
+ if (!foundPath) foundPath = p;
37231
+ }
37088
37232
  }
37233
+ if (Object.keys(merged).length > 0) return { config: merged, path: foundPath };
37234
+ const parent = dirname(dir);
37235
+ if (dir === home || parent === dir) break;
37236
+ dir = parent;
37089
37237
  }
37090
- return config2;
37238
+ return { config: {} };
37239
+ }
37240
+ function readProjectConfig() {
37241
+ return locateProjectConfig().config;
37091
37242
  }
37092
37243
  function writeWorkspaceConfig(next) {
37093
37244
  mkdirSync2(dirname(WORKSPACE_CONFIG), { recursive: true });
@@ -37114,12 +37265,24 @@ function setActiveSiteId(siteId) {
37114
37265
  }
37115
37266
  }
37116
37267
  var siteOverride;
37117
- function getSiteTarget() {
37268
+ function resolveSiteTarget() {
37118
37269
  if (siteOverride) {
37119
37270
  const n = parseInt(siteOverride, 10);
37120
- return String(n) === siteOverride ? n : siteOverride;
37271
+ const value = String(n) === siteOverride ? n : siteOverride;
37272
+ return { value, source: "flag", detail: "--site" };
37273
+ }
37274
+ const envSiteId = process.env.NEOPRESS_SITE_ID;
37275
+ if (envSiteId) return { value: parseInt(envSiteId, 10), source: "env", detail: "NEOPRESS_SITE_ID" };
37276
+ const located = locateProjectConfig();
37277
+ if (typeof located.config.siteId === "number") {
37278
+ return { value: located.config.siteId, source: "project-config", detail: located.path };
37121
37279
  }
37122
- return getSiteId();
37280
+ const active = loadSession().activeSiteId;
37281
+ if (active) return { value: active, source: "global-active", detail: "sites use" };
37282
+ return { value: void 0, source: "none" };
37283
+ }
37284
+ function getSiteTarget() {
37285
+ return resolveSiteTarget().value;
37123
37286
  }
37124
37287
 
37125
37288
  // src/utils/client.ts
package/package.json CHANGED
@@ -1,15 +1,25 @@
1
1
  {
2
2
  "name": "@neopress/cli",
3
- "version": "4.0.0",
3
+ "version": "4.2.0",
4
4
  "description": "Neopress CLI — manage your Neopress site from the terminal",
5
5
  "type": "module",
6
+ "keywords": [
7
+ "neopress",
8
+ "cli",
9
+ "cms",
10
+ "headless-cms",
11
+ "website-builder",
12
+ "content-management",
13
+ "ai-agent"
14
+ ],
6
15
  "bin": {
7
16
  "neopress": "./dist/bin.cjs"
8
17
  },
9
18
  "main": "./dist/index.js",
10
19
  "types": "./dist/index.d.ts",
11
20
  "files": [
12
- "dist"
21
+ "dist",
22
+ "README.md"
13
23
  ],
14
24
  "publishConfig": {
15
25
  "access": "public"