@localess/cli 3.0.2-dev.20260426174629 → 3.0.2

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 (2) hide show
  1. package/dist/index.mjs +91 -38
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -315,11 +315,64 @@ var D = new e("login").description("Login to Localess CLI").option("-o, --origin
315
315
  return e.ADD_MISSING = "add-missing", e.UPDATE_EXISTING = "update-existing", e.DELETE_MISSING = "delete-missing", e;
316
316
  }({}), M = /* @__PURE__ */ function(e) {
317
317
  return e.FLAT = "flat", e.NESTED = "nested", e;
318
- }({}), N = "/**\n * Generated by Localess CLI\n * Do not edit manually.\n */\n\n/**\n * Content Asset define reference to a Asset.\n */\nexport interface ContentAsset {\n /** Define the type of Asset */\n kind: 'ASSET';\n /** Unique identifier for the asset. */\n uri: string;\n}\n\n/**\n * Content Link define reference to a Link.\n */\nexport interface ContentLink {\n /** Define the type of Link */\n kind: 'LINK';\n /** Define the target of the link. _blank for new tab and _self for same tab. */\n target: '_blank' | '_self';\n /** Define the type of Link. URL for external links and Content for internal links. */\n type: 'url' | 'content';\n /** If type is content, then it will be Content ID. Otherwise it will be URL. */\n uri: string;\n}\n\n/**\n * Content Reference define reference to a Content.\n */\nexport interface ContentReference {\n /** Define the type of Reference */\n kind: 'REFERENCE';\n /** Unique identifier for the Content Document. */\n uri: string;\n}\n\n/**\n * Content RichText define content as JSON Object.\n */\nexport interface ContentRichText {\n /** Define the type of Content Node */\n type?: string;\n /** List of Content Nodes */\n content?: ContentRichText[];\n}\n";
318
+ }({});
319
+ //#endregion
320
+ //#region src/commands/types/generate/generator.ts
321
+ function N(e) {
322
+ return `/**
323
+ * Generated by Localess CLI
324
+ * Do not edit manually.
325
+ */
326
+
327
+ /**
328
+ * Content Asset define reference to a Asset.
329
+ */
330
+ export interface ${e}ContentAsset {
331
+ /** Define the type of Asset */
332
+ kind: 'ASSET';
333
+ /** Unique identifier for the asset. */
334
+ uri: string;
335
+ }
336
+
337
+ /**
338
+ * Content Link define reference to a Link.
339
+ */
340
+ export interface ${e}ContentLink {
341
+ /** Define the type of Link */
342
+ kind: 'LINK';
343
+ /** Define the target of the link. _blank for new tab and _self for same tab. */
344
+ target: '_blank' | '_self';
345
+ /** Define the type of Link. URL for external links and Content for internal links. */
346
+ type: 'url' | 'content';
347
+ /** If type is content, then it will be Content ID. Otherwise it will be URL. */
348
+ uri: string;
349
+ }
350
+
351
+ /**
352
+ * Content Reference define reference to a Content.
353
+ */
354
+ export interface ${e}ContentReference {
355
+ /** Define the type of Reference */
356
+ kind: 'REFERENCE';
357
+ /** Unique identifier for the Content Document. */
358
+ uri: string;
359
+ }
360
+
361
+ /**
362
+ * Content RichText define content as JSON Object.
363
+ */
364
+ export interface ${e}ContentRichText {
365
+ /** Define the type of Content Node */
366
+ type?: string;
367
+ /** List of Content Nodes */
368
+ content?: ${e}ContentRichText[];
369
+ }
370
+ `;
371
+ }
319
372
  function P(e) {
320
373
  return e.replace(/[-_\s]+([a-zA-Z0-9])/g, (e, t) => t.toUpperCase()).replace(/^[a-z]/, (e) => e.toUpperCase());
321
374
  }
322
- function F(e) {
375
+ function F(e, t) {
323
376
  switch (e.kind) {
324
377
  case A.TEXT:
325
378
  case A.TEXTAREA:
@@ -329,63 +382,63 @@ function F(e) {
329
382
  case A.DATETIME: return "string";
330
383
  case A.NUMBER: return "number";
331
384
  case A.BOOLEAN: return "boolean";
332
- case A.RICH_TEXT: return "ContentRichText";
333
- case A.LINK: return "ContentLink";
334
- case A.ASSET: return "ContentAsset";
335
- case A.ASSETS: return "ContentAsset[]";
336
- case A.REFERENCE: return "ContentReference";
337
- case A.REFERENCES: return "ContentReference[]";
338
- case A.OPTION: return e.source ? P(e.source) : "string";
339
- case A.OPTIONS: return e.source ? `${P(e.source)}[]` : "string[]";
385
+ case A.RICH_TEXT: return `${t}ContentRichText`;
386
+ case A.LINK: return `${t}ContentLink`;
387
+ case A.ASSET: return `${t}ContentAsset`;
388
+ case A.ASSETS: return `${t}ContentAsset[]`;
389
+ case A.REFERENCE: return `${t}ContentReference`;
390
+ case A.REFERENCES: return `${t}ContentReference[]`;
391
+ case A.OPTION: return e.source ? t + P(e.source) : "string";
392
+ case A.OPTIONS: return e.source ? `${t + P(e.source)}[]` : "string[]";
340
393
  case A.SCHEMA: {
341
- let t = e.schemas;
342
- if (!t || t.length === 0) return "unknown";
343
- let n = t.map((e) => P(e));
344
- return n.length === 1 ? n[0] : n.join(" | ");
394
+ let n = e.schemas;
395
+ if (!n || n.length === 0) return "unknown";
396
+ let r = n.map((e) => t + P(e));
397
+ return r.length === 1 ? r[0] : r.join(" | ");
345
398
  }
346
399
  case A.SCHEMAS: {
347
- let t = e.schemas;
348
- if (!t || t.length === 0) return "unknown[]";
349
- let n = t.map((e) => P(e));
350
- return `${n.length === 1 ? n[0] : `(${n.join(" | ")})`}[]`;
400
+ let n = e.schemas;
401
+ if (!n || n.length === 0) return "unknown[]";
402
+ let r = n.map((e) => t + P(e));
403
+ return `${r.length === 1 ? r[0] : `(${r.join(" | ")})`}[]`;
351
404
  }
352
405
  }
353
406
  }
354
407
  function I(e, t = "") {
355
408
  return `${t}/**\n${t} * ${e}\n${t} */`;
356
409
  }
357
- function L(e) {
358
- let t = [N], n = [];
359
- for (let [r, i] of Object.entries(e)) {
360
- let e = P(r), a = i.description ? `${I(i.description)}\n` : "";
361
- if (i.type === k.ENUM) {
362
- let n = i.values ?? [];
363
- if (n.length === 0) t.push(`${a}export type ${e} = string;\n`);
410
+ function L(e, t = "") {
411
+ let n = [N(t)], r = [];
412
+ for (let [i, a] of Object.entries(e)) {
413
+ let e = t + P(i), o = a.description ? `${I(a.description)}\n` : "";
414
+ if (a.type === k.ENUM) {
415
+ let t = a.values ?? [];
416
+ if (t.length === 0) n.push(`${o}export type ${e} = string;\n`);
364
417
  else {
365
- let r = n.map((e) => `'${e.value}'`).join(" | ");
366
- t.push(`${a}export type ${e} = ${r};\n`);
418
+ let r = t.map((e) => `'${e.value}'`).join(" | ");
419
+ n.push(`${o}export type ${e} = ${r};\n`);
367
420
  }
368
421
  } else {
369
- let o = i;
370
- i.type === k.ROOT && n.push(e);
371
- let s = [
422
+ let s = a;
423
+ a.type === k.ROOT && r.push(e);
424
+ let c = [
372
425
  " /** Unique identifier of a component in a content. */",
373
426
  " _id: string;",
374
427
  " /** Unique identifier for the Schema object. */",
375
- ` _schema: '${r}';`,
376
- ...(o.fields ?? []).flatMap((e) => {
377
- let t = F(e), n = e.required ? "" : "?", r = [];
378
- return e.description && r.push(` /** ${e.description} */`), r.push(` ${e.name}${n}: ${t};`), r;
428
+ ` _schema: '${i}';`,
429
+ ...(s.fields ?? []).flatMap((e) => {
430
+ let n = F(e, t), r = e.required ? "" : "?", i = [];
431
+ return e.description && i.push(` /** ${e.description} */`), i.push(` ${e.name}${r}: ${n};`), i;
379
432
  })
380
433
  ];
381
- t.push(`${a}export interface ${e} {\n${s.join("\n")}\n}\n`);
434
+ n.push(`${o}export interface ${e} {\n${c.join("\n")}\n}\n`);
382
435
  }
383
436
  }
384
- return t.push("/**\n* ContentData defined Object to connect all possible root Schemas.\n*/"), n.length > 0 ? t.push(`export type ContentData = ${n.join(" | ")};\n`) : t.push("export type ContentData = unknown;\n"), t.join("\n");
437
+ return n.push("/**\n* ContentData defined Object to connect all possible root Schemas.\n*/"), r.length > 0 ? n.push(`export type ${t}ContentData = ${r.join(" | ")};\n`) : n.push(`export type ${t}ContentData = unknown;\n`), n.join("\n");
385
438
  }
386
439
  //#endregion
387
440
  //#region src/commands/types/generate/index.ts
388
- var R = s(u.cwd(), b, "localess.ts"), z = new e("generate").description("Generate types for your schemas").option("-p, --path <path>", "Path to the file where to save the generated types. Default is .localess/localess.ts", R).action(async (e) => {
441
+ var R = s(u.cwd(), b, "localess.ts"), z = new e("generate").description("Generate types for your schemas").option("-p, --path <path>", "Path to the file where to save the generated types. Default is .localess/localess.ts", R).option("--prefix <prefix>", "Prefix to prepend to all generated type names", "").action(async (e) => {
389
442
  console.log("Types in with options:", e);
390
443
  let t = await w();
391
444
  if (!t.isLoggedIn) {
@@ -400,7 +453,7 @@ var R = s(u.cwd(), b, "localess.ts"), z = new e("generate").description("Generat
400
453
  console.log("Fetching schemas from Localess...");
401
454
  let r = await n.getSchemas();
402
455
  console.log("Generating types...");
403
- let i = L(r);
456
+ let i = L(r, e.prefix);
404
457
  await x(e.path, i), console.log(`Types written to ${e.path}`);
405
458
  }), B = new e("types").description("Generate types for your schemas").addCommand(z), V = d.record(d.string(), d.string()), H = d.enum(["add-missing", "update-existing"]);
406
459
  d.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@localess/cli",
3
- "version": "3.0.2-dev.20260426174629",
3
+ "version": "3.0.2",
4
4
  "description": "Localess Command Line.",
5
5
  "keywords": [
6
6
  "localess",