okai 0.0.32 → 0.0.34

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/api.d.ts CHANGED
@@ -125,7 +125,7 @@ declare global {
125
125
  export function route(path:string, opt?:{ summary?:string, notes?:string, verbs?:string, priority?:number, matches?:string, }|string) : ClassDecoratorDef
126
126
  export function icon(opt?:{ svg?:string, uri?:string, alt?:string, cls?:string, }) : ClassDecoratorDef
127
127
  export function field(opt?:InputAttrOptions & { name?:string, fieldCss?:string, inputCss?:string, labelCss?:string, }) : ClassDecoratorDef
128
- export function tag(name:string) : ClassDecoratorDef
128
+ export function tag(name?:string) : ClassDecoratorDef
129
129
  export function worker(name:string) : ClassDecoratorDef
130
130
  export function notes(notes:string) : ClassDecoratorDef
131
131
  export function namedConnection(name:string) : ClassDecoratorDef
@@ -167,7 +167,7 @@ declare global {
167
167
  export function flags() : ClassDecoratorDef
168
168
  export function enumMember(opt:{ value:string }) : ClassFieldDecoratorDef
169
169
 
170
- export function validate(validator:string) : ClassFieldDecoratorDef
170
+ export function validate(validator?:string) : ClassFieldDecoratorDef
171
171
  export function validateNull() : ClassFieldDecoratorDef
172
172
  export function validateEmpty() : ClassFieldDecoratorDef
173
173
  export function validateEmail() : ClassFieldDecoratorDef
package/dist/cs-ast.js CHANGED
@@ -648,8 +648,9 @@ export class CSharpAst {
648
648
  else if (prop.type === 'List`1' && this.commonValueTypes.includes(prop.genericArgs[0])) {
649
649
  prop.attributes.push(...inputTagAttrs);
650
650
  }
651
- const emptyValidateAttr = prop.attributes.find(x => x.name.toLowerCase() === 'validate');
652
- if (emptyValidateAttr && emptyValidateAttr.constructorArgs?.[0]?.value === '') {
651
+ const emptyValidateAttr = prop.attributes
652
+ .find(x => x.name.toLowerCase() === 'validate' && !x.constructorArgs?.length && !x.args?.length);
653
+ if (emptyValidateAttr) {
653
654
  prop.attributes = prop.attributes.filter(x => x !== emptyValidateAttr);
654
655
  }
655
656
  }
@@ -708,6 +709,11 @@ export class CSharpAst {
708
709
  prop.attributes.push(...inputTagAttrs);
709
710
  }
710
711
  }
712
+ const emptyValidateAttr = prop.attributes
713
+ .find(x => x.name.toLowerCase() === 'validate' && !x.constructorArgs?.length && !x.args?.length);
714
+ if (emptyValidateAttr) {
715
+ prop.attributes = prop.attributes.filter(x => x !== emptyValidateAttr);
716
+ }
711
717
  }
712
718
  if (isAuditBase) {
713
719
  updateApi.requiresAuth = true;
@@ -838,6 +844,7 @@ export const Transforms = {
838
844
  addAutoIncrementAttrs,
839
845
  addIconsToKnownTypes,
840
846
  hideReferenceProperties,
847
+ removeEmptyAttributes,
841
848
  ],
842
849
  };
843
850
  export function toMetadataTypes(ast, transforms) {
@@ -919,6 +926,22 @@ export function replaceIds(gen) {
919
926
  }
920
927
  }
921
928
  }
929
+ export function removeEmptyAttributes(gen) {
930
+ const removeEmptyAttrsNamed = ['icon', 'description', 'notes', 'tag', 'icon', 'alias']; // 'validate' removed in gen APIs
931
+ const filterEmptyAttrs = (attrs) => attrs.filter(x => !(removeEmptyAttrsNamed.includes(x.name.toLowerCase()) && !x.constructorArgs?.length && !x.args?.length));
932
+ for (const type of gen.classes) {
933
+ if (type.attributes) {
934
+ type.attributes = filterEmptyAttrs(type.attributes);
935
+ }
936
+ if (type.properties) {
937
+ for (const prop of type.properties) {
938
+ if (prop.attributes) {
939
+ prop.attributes = filterEmptyAttrs(prop.attributes);
940
+ }
941
+ }
942
+ }
943
+ }
944
+ }
922
945
  export function convertReferenceTypes(gen) {
923
946
  for (const type of gen.classes) {
924
947
  for (let i = 0; i < type.properties.length; i++) {
@@ -1061,7 +1084,7 @@ export function addIconsToKnownTypes(gen) {
1061
1084
  const existingIcon = type.attributes.find(x => x.name === 'Icon');
1062
1085
  if (existingIcon) {
1063
1086
  // remove empty icon
1064
- if (existingIcon.constructorArgs?.[0]?.value === '') {
1087
+ if (existingIcon.constructorArgs?.length === 0 && existingIcon.args?.length === 0) {
1065
1088
  type.attributes = type.attributes.filter(x => x !== existingIcon);
1066
1089
  }
1067
1090
  return;
package/dist/icons.js CHANGED
@@ -66,8 +66,9 @@ export const IconMap = {
66
66
  Team: S('0 0 16 16', `<path fill='currentColor' d='M6.002 4a1.998 1.998 0 1 1 3.996 0a1.998 1.998 0 0 1-3.996 0M8 3.002a.998.998 0 1 0 0 1.996a.998.998 0 0 0 0-1.996M11 4.5a1.5 1.5 0 1 1 3 0a1.5 1.5 0 0 1-3 0m1.5-.5a.5.5 0 1 0 0 1a.5.5 0 0 0 0-1m-9-1a1.5 1.5 0 1 0 0 3a1.5 1.5 0 0 0 0-3M3 4.5a.5.5 0 1 1 1 0a.5.5 0 0 1-1 0M4.268 7A2 2 0 0 0 4 8H2v2.5a1.5 1.5 0 0 0 2.096 1.377c.074.331.19.647.34.942A2.5 2.5 0 0 1 1 10.5V8a1 1 0 0 1 1-1zm7.296 5.819A2.5 2.5 0 0 0 15 10.5V8a1 1 0 0 0-1-1h-2.268c.17.294.268.635.268 1h2v2.5a1.5 1.5 0 0 1-2.096 1.377q-.114.498-.34.942M6 6.999a1 1 0 0 0-1 1V11a3 3 0 0 0 6 0V8a1 1 0 0 0-1-1zm0 1h4V11a2 2 0 0 1-4 0z'/>`),
67
67
  Signup: S(`0 0 16 16`, `<g fill='currentColor'><path fill-rule='evenodd' d='M10.854 7.146a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708 0l-1.5-1.5a.5.5 0 1 1 .708-.708L7.5 9.793l2.646-2.647a.5.5 0 0 1 .708 0z'/><path d='M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1v-1z'/><path d='M9.5 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5h3zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3z'/></g>`),
68
68
  Company: S(`0 0 24 24`, `<path fill='currentColor' d='M18 15h-2v2h2m0-6h-2v2h2m2 6h-8v-2h2v-2h-2v-2h2v-2h-2V9h8M10 7H8V5h2m0 6H8V9h2m0 6H8v-2h2m0 6H8v-2h2M6 7H4V5h2m0 6H4V9h2m0 6H4v-2h2m0 6H4v-2h2m6-10V3H2v18h20V7z'/>`),
69
- Location: S(`0 0 24 24`, `<path fill='currentColor' d='M12 6.5A2.5 2.5 0 0 1 14.5 9a2.5 2.5 0 0 1-2.5 2.5A2.5 2.5 0 0 1 9.5 9A2.5 2.5 0 0 1 12 6.5M12 2a7 7 0 0 1 7 7c0 5.25-7 13-7 13S5 14.25 5 9a7 7 0 0 1 7-7m0 2a5 5 0 0 0-5 5c0 1 0 3 5 9.71C17 12 17 10 17 9a5 5 0 0 0-5-5'/>`),
70
69
  Member: S('0 0 256 256', `<path fill='currentColor' d='M200 136H56.46A72.08 72.08 0 0 0 128 200h72a8 8 0 0 1 0 16h-72a88 88 0 0 1 0-176h72a8 8 0 0 1 0 16h-72a72.08 72.08 0 0 0-71.54 64H200a8 8 0 0 1 0 16'/>`),
70
+ Location: S(`0 0 24 24`, `<path fill='currentColor' d='M12 6.5A2.5 2.5 0 0 1 14.5 9a2.5 2.5 0 0 1-2.5 2.5A2.5 2.5 0 0 1 9.5 9A2.5 2.5 0 0 1 12 6.5M12 2a7 7 0 0 1 7 7c0 5.25-7 13-7 13S5 14.25 5 9a7 7 0 0 1 7-7m0 2a5 5 0 0 0-5 5c0 1 0 3 5 9.71C17 12 17 10 17 9a5 5 0 0 0-5-5'/>`),
71
+ Region: S(`0 0 16 16`, `<path fill='currentColor' d='M6.5 2.309v8.69a.5.5 0 0 1-.032.176L9.5 12.691V3.809zm-1-.04L2 3.825v8.906l3.527-1.568a.5.5 0 0 1-.027-.164zm.274-1.216a.5.5 0 0 1 .471.01l3.768 1.884l4.284-1.904A.5.5 0 0 1 15 1.5v10a.5.5 0 0 1-.297.457l-4.5 2a.5.5 0 0 1-.427-.01l-3.789-1.894l-4.283 1.904a.5.5 0 0 1-.703-.457v-10a.5.5 0 0 1 .297-.457zM10.5 3.825v8.906l3.5-1.556V2.27z'/>`),
71
72
  /** Admin */
72
73
  Dashboard: P + `viewBox='0 0 24 24' fill='none' stroke-width='1.5' stroke='currentColor'><path stroke-linecap='round' stroke-linejoin='round' d='M2.25 12l8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25' /></svg>`,
73
74
  Stats: S(`0 0 24 24`, `<path fill='currentColor' d='M8.143 15.857H5.57V9.43h2.572v6.428zm5.143 0h-2.572V3h2.572v12.857zm5.142 0h-2.571v-9h2.571v9z'/><path fill='currentColor' fill-rule='evenodd' d='M21 20.714H3v-2h18v2z' clip-rule='evenodd'/>`),
@@ -75,7 +76,7 @@ export const IconMap = {
75
76
  Project: S(`0 0 24 24`, `<circle cx='12' cy='6' r='1' fill='currentColor'/><path fill='currentColor' d='M6 17h12v2H6zm4-5.17l2.792 2.794l3.932-3.935L18 12V8h-4l1.31 1.275l-2.519 2.519L10 9l-4 4l1.414 1.414z'/><path fill='currentColor' d='M19 3h-3.298a5 5 0 0 0-.32-.425l-.01-.012a4.43 4.43 0 0 0-2.89-1.518a2.6 2.6 0 0 0-.964 0a4.43 4.43 0 0 0-2.89 1.518l-.01.012a5 5 0 0 0-.32.424V3H5a3.003 3.003 0 0 0-3 3v14a3.003 3.003 0 0 0 3 3h14a3.003 3.003 0 0 0 3-3V6a3.003 3.003 0 0 0-3-3m1 17a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h4.55a2.5 2.5 0 0 1 4.9 0H19a1 1 0 0 1 1 1Z'/>`),
76
77
  Task: S(`0 0 32 32`, `<path fill='currentColor' d='M10.293 5.293L7 8.586L5.707 7.293L4.293 8.707L7 11.414l4.707-4.707zM14 7v2h14V7zm0 8v2h14v-2zm0 8v2h14v-2z'/>`),
77
78
  /** Security */
78
- Padlock: S(`0 0 512 512`, `<path fill='#B1B4B5' d='M376.749 349.097c-13.531 0-24.5-10.969-24.5-24.5V181.932c0-48.083-39.119-87.203-87.203-87.203-48.083 0-87.203 39.119-87.203 87.203v82.977c0 13.531-10.969 24.5-24.5 24.5s-24.5-10.969-24.5-24.5v-82.977c0-75.103 61.1-136.203 136.203-136.203s136.203 61.1 136.203 136.203v142.665c0 13.531-10.969 24.5-24.5 24.5z'/><path fill='#FFB636' d='M414.115 497.459H115.977c-27.835 0-50.4-22.565-50.4-50.4V274.691c0-27.835 22.565-50.4 50.4-50.4h298.138c27.835 0 50.4 22.565 50.4 50.4v172.367c0 27.836-22.565 50.401-50.4 50.401z'/><path fill='#FFD469' d='M109.311 456.841h-2.525c-7.953 0-14.4-6.447-14.4-14.4V279.309c0-7.953 6.447-14.4 14.4-14.4h2.525c7.953 0 14.4 6.447 14.4 14.4v163.132c0 7.953-6.447 14.4-14.4 14.4z'/>`),
79
+ Lock: S(`0 0 24 24`, `<path fill='currentColor' d='M12 13a1.49 1.49 0 0 0-1 2.61V17a1 1 0 0 0 2 0v-1.39A1.49 1.49 0 0 0 12 13m5-4V7A5 5 0 0 0 7 7v2a3 3 0 0 0-3 3v7a3 3 0 0 0 3 3h10a3 3 0 0 0 3-3v-7a3 3 0 0 0-3-3M9 7a3 3 0 0 1 6 0v2H9Zm9 12a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1Z'/>`),
79
80
  /** Bookings */
80
81
  Booking: S(`0 0 24 24`, `<path fill='currentColor' d='M16 10H8c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1zm3-7h-1V2c0-.55-.45-1-1-1s-1 .45-1 1v1H8V2c0-.55-.45-1-1-1s-1 .45-1 1v1H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-1 16H6c-.55 0-1-.45-1-1V8h14v10c0 .55-.45 1-1 1zm-5-5H8c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1z'/>`),
81
82
  Coupon: S(`0 0 24 24`, `<path fill='currentColor' d='M2 9.5V4a1 1 0 0 1 1-1h18a1 1 0 0 1 1 1v5.5a2.5 2.5 0 1 0 0 5V20a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1v-5.5a2.5 2.5 0 1 0 0-5zm2-1.532a4.5 4.5 0 0 1 0 8.064V19h16v-2.968a4.5 4.5 0 0 1 0-8.064V5H4v2.968zM9 9h6v2H9V9zm0 4h6v2H9v-2z' />`),
@@ -84,7 +85,6 @@ export const IconMap = {
84
85
  Time: S(`0 0 24 24`, `<path fill='currentColor' d='M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10s-4.477 10-10 10m0-2a8 8 0 1 0 0-16a8 8 0 0 0 0 16m1-8h4v2h-6V7h2z'/>`),
85
86
  Feature: S(`0 0 24 24`, `<path fill='currentColor' d='m8.58 17.25l.92-3.89l-3-2.58l3.95-.37L12 6.8l1.55 3.65l3.95.33l-3 2.58l.92 3.89L12 15.19zM12 2a10 10 0 0 1 10 10a10 10 0 0 1-10 10A10 10 0 0 1 2 12A10 10 0 0 1 12 2m0 2a8 8 0 0 0-8 8a8 8 0 0 0 8 8a8 8 0 0 0 8-8a8 8 0 0 0-8-8'/>`),
86
87
  Enroll: S(`0 0 14 14`, `<g fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round'><path d='M6.35.5h6.302c.469 0 .849.38.849.849v6.778c0 .47-.38.85-.849.85H7.5M3.149 4.001a1.75 1.75 0 1 0 0-3.501a1.75 1.75 0 0 0 0 3.501'/><path d='M9 5.527C9 4.96 8.54 4.5 7.973 4.5H3.149v0A2.65 2.65 0 0 0 .5 7.149V9.5h1.135l.379 4h2.27l.872-6.945h2.817C8.54 6.555 9 6.095 9 5.527'/></g>`),
87
- Lesson: S(`0 0 14 14`, `<g fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round'><path d='M6.35.5h6.302c.469 0 .849.38.849.849v6.778c0 .47-.38.85-.849.85H7.5M3.149 4.001a1.75 1.75 0 1 0 0-3.501a1.75 1.75 0 0 0 0 3.501'/><path d='M9 5.527C9 4.96 8.54 4.5 7.973 4.5H3.149v0A2.65 2.65 0 0 0 .5 7.149V9.5h1.135l.379 4h2.27l.872-6.945h2.817C8.54 6.555 9 6.095 9 5.527'/></g>`),
88
88
  Course: S(`0 0 512 512`, `<path fill='currentColor' d='M464 48c-67.61.29-117.87 9.6-154.24 25.69c-27.14 12-37.76 21.08-37.76 51.84V448c41.57-37.5 78.46-48 224-48V48ZM48 48c67.61.29 117.87 9.6 154.24 25.69c27.14 12 37.76 21.08 37.76 51.84V448c-41.57-37.5-78.46-48-224-48V48Z'/>`),
89
89
  Quiz: S(`0 0 24 24`, `<path fill='currentColor' d='M20 16V4H8v12zm2 0c0 1.1-.9 2-2 2H8c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h12c1.1 0 2 .9 2 2zm-6 4v2H4c-1.1 0-2-.9-2-2V7h2v13zM14.2 5q-1.35 0-2.1.6c-.5.4-.8 1-.8 1.8h1.9c0-.3.1-.5.3-.7c.2-.1.4-.2.7-.2s.6.1.8.3s.3.4.3.8c0 .3-.1.6-.2.8s-.4.4-.6.6c-.5.3-.9.6-1 .9c-.4.2-.5.6-.5 1.1h2c0-.3 0-.6.1-.7c.1-.2.3-.4.5-.5c.4-.2.8-.5 1.1-.9c.3-.5.5-.9.5-1.4c0-.8-.3-1.4-.8-1.8c-.5-.5-1.3-.7-2.2-.7M13 12v2h2v-2z'/>`),
90
90
  Question: S(`0 0 16 16`, `<path fill='currentColor' d='M9 11H6c0-3 1.6-4 2.7-4.6q.6-.3.9-.6c.5-.5.3-1.2.2-1.4c-.3-.7-1-1.4-2.3-1.4C5.4 3 5 4.9 5 5.3l-3-.4C2.2 3.2 3.7 0 7.5 0c2.3 0 4.3 1.3 5.1 3.2c.7 1.7.4 3.5-.8 4.7c-.5.5-1.1.8-1.6 1.1c-.9.5-1.2 1-1.2 2m.5 3a2 2 0 1 1-3.999.001A2 2 0 0 1 9.5 14'/>`),
@@ -110,6 +110,9 @@ export const IconMap = {
110
110
  Gift: S(`0 0 14 14`, `<g fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round'><path d='M13.5 2.5h-7v5h7zm-3.5 0v5M8.5.5l1.5 2l1.5-2M.5 11l2.444 2.036a2 2 0 0 0 1.28.463h6.442c.46 0 .834-.373.834-.833c0-.92-.746-1.667-1.667-1.667H5.354'/><path d='m3.5 10l.75.75a1.06 1.06 0 0 0 1.5-1.5L4.586 8.085A2 2 0 0 0 3.17 7.5H.5'/></g>`),
111
111
  Deduct: S(`0 0 20 20`, `<path fill='currentColor' d='M10 20a10 10 0 1 1 0-20a10 10 0 0 1 0 20m0-2a8 8 0 1 0 0-16a8 8 0 0 0 0 16m5-9v2H5V9z'/>`),
112
112
  Tax: S(`0 0 24 24`, `<g fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' color='currentColor'><path d='M2 8.57c0-1.197.482-1.93 1.48-2.486l4.11-2.287C9.743 2.6 10.82 2 12 2s2.257.6 4.41 1.797l4.11 2.287C21.517 6.64 22 7.373 22 8.57c0 .324 0 .487-.035.62c-.186.7-.821.811-1.434.811H3.469c-.613 0-1.247-.11-1.434-.811C2 9.056 2 8.893 2 8.569M4 10v8.5M8 10v8.5m3 0H5a3 3 0 0 0-3 3a.5.5 0 0 0 .5.5H11m10.5-7.5l-7 7'/><circle cx='15.25' cy='15.25' r='.75'/><circle cx='20.75' cy='20.75' r='.75'/></g>`),
113
+ Performance: S(`0 0 32 32`, `<path fill='currentColor' d='M26 16a9.9 9.9 0 0 0-1.14-4.618l-1.495 1.496A7.95 7.95 0 0 1 24 16zm-2.586-6L22 8.586L17.285 13.3A3 3 0 0 0 16 13a3 3 0 1 0 3 3a3 3 0 0 0-.3-1.285zM16 17a1 1 0 1 1 1-1a1 1 0 0 1-1 1m0-9a8 8 0 0 1 3.122.635l1.496-1.496A9.986 9.986 0 0 0 6 16h2a8.01 8.01 0 0 1 8-8'/><path fill='currentColor' d='M16 30a14 14 0 1 1 14-14a14.016 14.016 0 0 1-14 14m0-26a12 12 0 1 0 12 12A12.014 12.014 0 0 0 16 4'/>`),
114
+ Review: S(`0 0 24 24`, `<path fill='currentColor' d='M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5l-1.5 1.5l-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16A6.5 6.5 0 0 1 3 9.5A6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14S14 12 14 9.5S12 5 9.5 5'/>`),
115
+ Range: S(`0 0 24 24`, `<path fill='currentColor' d='m7 17l-5-5l5-5l1.4 1.4L5.825 11h12.35L15.6 8.4L17 7l5 5l-5 5l-1.4-1.4l2.575-2.6H5.825L8.4 15.6z'/>`),
113
116
  Skill: S(`0 0 256 256`, `<path fill='currentColor' d='M188 48a27.75 27.75 0 0 0-12 2.71V44a28 28 0 0 0-54.65-8.6A28 28 0 0 0 80 60v64l-3.82-6.13a28 28 0 0 0-48.6 27.82c16 33.77 28.93 57.72 43.72 72.69C86.24 233.54 103.2 240 128 240a88.1 88.1 0 0 0 88-88V76a28 28 0 0 0-28-28m12 104a72.08 72.08 0 0 1-72 72c-20.38 0-33.51-4.88-45.33-16.85C69.44 193.74 57.26 171 41.9 138.58a6 6 0 0 0-.3-.58a12 12 0 0 1 20.79-12a2 2 0 0 0 .14.23l18.67 30A8 8 0 0 0 96 152V60a12 12 0 0 1 24 0v60a8 8 0 0 0 16 0V44a12 12 0 0 1 24 0v76a8 8 0 0 0 16 0V76a12 12 0 0 1 24 0Z'/>`),
114
117
  /** Media */
115
118
  Creative: S(`0 0 15 15`, `<path fill='currentColor' d='M10.71 3L7.85.15a.5.5 0 0 0-.707-.003L7.14.15L4.29 3H1.5a.5.5 0 0 0-.5.5v9a.5.5 0 0 0 .5.5h12a.5.5 0 0 0 .5-.5v-9a.5.5 0 0 0-.5-.5zM7.5 1.21L9.29 3H5.71zM13 12H2V4h11zM5 7a1 1 0 1 1 0-2a1 1 0 0 1 0 2zm7 4H4.5L6 8l1.25 2.5L9.5 6z'/>`),
@@ -117,6 +120,8 @@ export const IconMap = {
117
120
  Artist: S(`0 0 32 32`, `<g fill='currentColor'><path d='M24 19a3 3 0 1 0 0-6a3 3 0 0 0 0 6Zm0-1a2 2 0 1 1 0-4a2 2 0 0 1 0 4Zm-7.5-9.25a2.25 2.25 0 1 1-4.5 0a2.25 2.25 0 0 1 4.5 0Zm-6 4a2.25 2.25 0 1 1-4.5 0a2.25 2.25 0 0 1 4.5 0ZM8.25 22a2.25 2.25 0 1 0 0-4.5a2.25 2.25 0 0 0 0 4.5ZM16 24.25a2.25 2.25 0 1 1-4.5 0a2.25 2.25 0 0 1 4.5 0Z'/><path d='M16.2 31a16.717 16.717 0 0 1-7.84-2.622a15.045 15.045 0 0 1-6.948-9.165A13.032 13.032 0 0 1 2.859 9.22c3.757-6.2 12.179-8.033 19.588-4.256c4.419 2.255 7.724 6.191 8.418 10.03a6.8 6.8 0 0 1-1.612 6.02c-2.158 2.356-4.943 2.323-6.967 2.3h-.007c-1.345-.024-2.185 0-2.386.4c.07.308.192.604.36.873a3.916 3.916 0 0 1-.209 4.807A4.7 4.7 0 0 1 16.2 31ZM14.529 5a11.35 11.35 0 0 0-9.961 5.25a11.048 11.048 0 0 0-1.218 8.473a13.03 13.03 0 0 0 6.03 7.934c3.351 1.988 7.634 3.3 9.111 1.473c.787-.968.537-1.565-.012-2.622a2.843 2.843 0 0 1-.372-2.7c.781-1.54 2.518-1.523 4.2-1.5c1.835.025 3.917.05 5.472-1.649a4.909 4.909 0 0 0 1.12-4.314c-.578-3.2-3.536-6.653-7.358-8.6a15.482 15.482 0 0 0-7.01-1.74L14.529 5Z'/></g>`),
118
121
  Modifier: S(`0 0 24 24`, `<path fill='currentColor' d='M19.75 2A2.25 2.25 0 0 1 22 4.25v5.462a3.25 3.25 0 0 1-.952 2.298l-8.5 8.503a3.255 3.255 0 0 1-4.597.001L3.489 16.06a3.25 3.25 0 0 1-.004-4.596l8.5-8.51a3.25 3.25 0 0 1 2.3-.953h5.465Zm0 1.5h-5.466c-.464 0-.91.185-1.238.513l-8.512 8.523a1.75 1.75 0 0 0 .015 2.462l4.461 4.454a1.755 1.755 0 0 0 2.477 0l8.5-8.503a1.75 1.75 0 0 0 .513-1.237V4.25a.75.75 0 0 0-.75-.75ZM17 5.502a1.5 1.5 0 1 1 0 3a1.5 1.5 0 0 1 0-3Z'/>`),
119
122
  Album: S(`0 0 24 24`, `<path fill='currentColor' d='M11.024 11.536L10 10l-2 3h9l-3.5-5z'/><circle cx='9.503' cy='7.497' r='1.503' fill='currentColor'/><path fill='currentColor' d='M19 2H6c-1.206 0-3 .799-3 3v14c0 2.201 1.794 3 3 3h15v-2H6.012C5.55 19.988 5 19.806 5 19s.55-.988 1.012-1H21V4c0-1.103-.897-2-2-2zm0 14H5V5c0-.806.55-.988 1-1h13v12z'/>`),
123
+ Content: S(`0 0 16 16`, `<path fill='currentColor' fill-rule='evenodd' d='M12 3.5H4A1.5 1.5 0 0 0 2.5 5v.5h11V5A1.5 1.5 0 0 0 12 3.5M2.5 11V7h2v5.5H4A1.5 1.5 0 0 1 2.5 11M6 12.5h6a1.5 1.5 0 0 0 1.5-1.5V7H6zM4 2a3 3 0 0 0-3 3v6a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3V5a3 3 0 0 0-3-3z' clip-rule='evenodd'/>`),
124
+ Video: S(`0 0 24 24`, `<path fill='currentColor' d='M15 8v8H5V8zm1-2H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4V7a1 1 0 0 0-1-1'/>`),
120
125
  /** Sales & Marketing */
121
126
  Sales: S(`0 0 24 24`, `<g fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5'><path d='M14 9.846c-1-.923-3.667-1.23-3.667.616S14 11.385 14 13.23s-3 1.846-4 .615m2 .857V16m0-6.887V8M2 8l9.732-4.866a.6.6 0 0 1 .536 0L22 8'/><path d='M20 11v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8'/></g>`),
122
127
  Channel: S(`0 0 24 24`, `<path fill='none' stroke='currentColor' stroke-width='2' d='M2 9h20v13H2zm19-7l-8 7h-2L3 2'/>`),
@@ -147,12 +152,14 @@ export const IconMap = {
147
152
  Approve: S(`0 0 24 24`, `<path fill='currentColor' d='m23 12l-2.44-2.78l.34-3.68l-3.61-.82l-1.89-3.18L12 3L8.6 1.54L6.71 4.72l-3.61.81l.34 3.68L1 12l2.44 2.78l-.34 3.69l3.61.82l1.89 3.18L12 21l3.4 1.46l1.89-3.18l3.61-.82l-.34-3.68zm-13 5l-4-4l1.41-1.41L10 14.17l6.59-6.59L18 9z'/>`),
148
153
  Actual: S(`0 0 24 24`, `<path fill='none' stroke='currentColor' stroke-width='2' d='M9 15v3c0 .943 0 1.414-.293 1.707S7.943 20 7 20H6c-.943 0-1.414 0-1.707-.293S4 18.943 4 18v-1c0-.943 0-1.414.293-1.707S5.057 15 6 15zm6-11h5v5m0-5L9 15'/>`),
149
154
  Refund: S(`0 0 20 20`, `<path fill='currentColor' fill-rule='evenodd' d='M5 2a2 2 0 0 0-2 2v14l3.5-2l3.5 2l3.5-2l3.5 2V4a2 2 0 0 0-2-2zm4.707 3.707a1 1 0 0 0-1.414-1.414l-3 3a1 1 0 0 0 0 1.414l3 3a1 1 0 0 0 1.414-1.414L8.414 9H10a3 3 0 0 1 3 3v1a1 1 0 1 0 2 0v-1a5 5 0 0 0-5-5H8.414z' clip-rule='evenodd'/>`),
155
+ Play: S(`0 0 24 24`, `<path fill='currentColor' d='M8 5.14v14l11-7z'/>`),
150
156
  Result: S(`0 0 2048 2048`, `<path fill='currentColor' d='M2048 640v640h-768v512H128v128H0V0h128v128h1408v512zM128 256v384h1280V256zm1024 1408v-384H128v384zm768-512V768H128v384z'/>`),
151
157
  /** CMS */
152
158
  Page: S('0 0 24 24', `<g fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5'><path d='M4 21.4V2.6a.6.6 0 0 1 .6-.6h11.652a.6.6 0 0 1 .424.176l3.148 3.148A.6.6 0 0 1 20 5.75V21.4a.6.6 0 0 1-.6.6H4.6a.6.6 0 0 1-.6-.6M8 10h8m-8 8h8m-8-4h4'/><path d='M16 2v3.4a.6.6 0 0 0 .6.6H20'/></g>`),
153
159
  Tag: S('0 0 24 24', `<g fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'><path d='M6.5 7.5a1 1 0 1 0 2 0a1 1 0 1 0-2 0'/><path d='M3 6v5.172a2 2 0 0 0 .586 1.414l7.71 7.71a2.41 2.41 0 0 0 3.408 0l5.592-5.592a2.41 2.41 0 0 0 0-3.408l-7.71-7.71A2 2 0 0 0 11.172 3H6a3 3 0 0 0-3 3'/></g>`),
154
160
  Type: S('0 0 24 24', `<path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M5 7V6a2 2 0 0 1 2-2h5m7 3V6a2 2 0 0 0-2-2h-5m0 0v16m0 0H9m3 0h3'/>`),
155
161
  Category: S('0 0 24 24', `<path fill='currentColor' d='m2.25 8.452l9.5 5.48a.5.5 0 0 0 .5 0l9.5-5.48a.5.5 0 0 0 0-.866l-9.5-5.476a.51.51 0 0 0-.5 0l-9.5 5.476a.5.5 0 0 0 0 .866M12 3.122l8.499 4.898L12 12.923L3.501 8.02zm9.248 12.404L12 20.921l-9.248-5.395a.5.5 0 1 0-.504.864l9.5 5.542a.5.5 0 0 0 .504 0l9.5-5.542a.5.5 0 1 0-.504-.864m0-4L12 16.921l-9.248-5.395a.5.5 0 1 0-.504.864l9.5 5.542a.5.5 0 0 0 .504 0l9.5-5.542a.5.5 0 1 0-.504-.864'/>`),
162
+ Folder: S('0 0 24 24', `<path fill='currentColor' d='M4 20q-.825 0-1.412-.587T2 18V6q0-.825.588-1.412T4 4h6l2 2h8q.825 0 1.413.588T22 8v10q0 .825-.587 1.413T20 20zm0-2h16V8h-8.825l-2-2H4zm0 0V6z'/>`),
156
163
  Menu: S('0 0 24 24', `<path fill='currentColor' d='M2 2h20v20H2zm2 2v5.5h16V4zm16 7.5H4V20h16zM5.996 6H8v2h-.004v.004h-2zM10 6h8v2h-8z'/>`),
157
164
  MenuItem: S('0 0 24 24', `<path fill='currentColor' d='M3 6h10v2H3zm0 10h10v2H3zm0-5h12v2H3zm13-4l-1.42 1.39L18.14 12l-3.56 3.61L16 17l5-5z'/>`),
158
165
  Setting: S('-2 -4 24 24', `<path fill='currentColor' d='M9 12V1a1 1 0 1 1 2 0v11h1a1 1 0 0 1 0 2h-1v1a1 1 0 0 1-2 0v-1H8a1 1 0 0 1 0-2zm7-10V1a1 1 0 0 1 2 0v1h1a1 1 0 0 1 0 2h-1v11a1 1 0 0 1-2 0V4h-1a1 1 0 0 1 0-2zM4 5h1a1 1 0 1 1 0 2H4v8a1 1 0 0 1-2 0V7H1a1 1 0 1 1 0-2h1V1a1 1 0 1 1 2 0z'/>`),
@@ -162,6 +169,11 @@ export const IconMap = {
162
169
  Policy: S('0 0 24 24', `<path fill='currentColor' d='m21 5l-9-4l-9 4v6c0 5.55 3.84 10.74 9 12c2.3-.56 4.33-1.9 5.88-3.71l-3.12-3.12a4.994 4.994 0 0 1-6.29-.64a5.003 5.003 0 0 1 0-7.07a5.003 5.003 0 0 1 7.07 0a5.006 5.006 0 0 1 .64 6.29l2.9 2.9C20.29 15.69 21 13.38 21 11z'/><circle cx='12' cy='12' r='3' fill='currentColor'/>`),
163
170
  Resource: S('0 0 24 24', `<path fill='currentColor' d='M13.272 1v2.65l6.613 3.89v7.745l2.465 1.295l-.93 1.77l-2.507-1.317l-5.641 3.317V23h-2v-2.65l-5.69-3.346l-3.12 1.304l-.77-1.845l2.967-1.24V7.539l6.613-3.889V1zm-1 4.382l-4.64 2.73l4.64 2.728l4.64-2.729zm5.613 4.477l-4.613 2.713v5.458l4.613-2.713zm-6.613 8.17v-5.457L6.66 9.859v5.458z'/>`),
164
171
  Ticket: S('0 0 24 24', `<path fill='currentColor' d='M4 4a2 2 0 0 0-2 2v4a2 2 0 0 1 2 2a2 2 0 0 1-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 1-2-2a2 2 0 0 1 2-2V6a2 2 0 0 0-2-2zm0 2h16v2.54c-1.24.71-2 2.03-2 3.46s.76 2.75 2 3.46V18H4v-2.54c1.24-.71 2-2.03 2-3.46s-.76-2.75-2-3.46z'/>`),
172
+ Favorite: S('0 0 24 24', `<path fill='currentColor' d='M12 2.5a1 1 0 0 1 .894.553l2.58 5.158l5.67.824a1 1 0 0 1 .554 1.706l-4.127 4.024l.928 5.674a1 1 0 0 1-1.455 1.044L12 18.807l-5.044 2.676a1 1 0 0 1-1.455-1.044l.928-5.674l-4.127-4.024a1 1 0 0 1 .554-1.706l5.67-.824l2.58-5.158A1 1 0 0 1 12 2.5m0 3.236l-1.918 3.836a1 1 0 0 1-.75.543l-4.184.608l3.05 2.973a1 1 0 0 1 .289.878L7.8 18.771l3.731-1.98a1 1 0 0 1 .938 0l3.731 1.98l-.687-4.197a1 1 0 0 1 .289-.877l3.05-2.974l-4.183-.608a1 1 0 0 1-.75-.543z'/>`),
173
+ Email: S('0 0 24 24', `<path fill='currentColor' d='M22 6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2zm-2 0l-8 5l-8-5zm0 12H4V8l8 5l8-5z'/>`),
174
+ News: S('0 0 20 20', `<path fill='currentColor' d='M3 6c0-1.1.9-2 2-2h8l4-4h2v16h-2l-4-4H5a2 2 0 0 1-2-2H1V6zm8 9v5H8l-1.67-5H5v-2h8v2z'/>`),
175
+ Search: S('0 0 24 24', `<path fill='currentColor' d='m19.6 21l-6.3-6.3q-.75.6-1.725.95T9.5 16q-2.725 0-4.612-1.888T3 9.5t1.888-4.612T9.5 3t4.613 1.888T16 9.5q0 1.1-.35 2.075T14.7 13.3l6.3 6.3zM9.5 14q1.875 0 3.188-1.312T14 9.5t-1.312-3.187T9.5 5T6.313 6.313T5 9.5t1.313 3.188T9.5 14'/>`),
176
+ Save: S('0 0 24 24', `<path fill='currentColor' d='M7 19v-6h10v6h2V7.828L16.172 5H5v14zM4 3h13l4 4v13a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1m5 12v4h6v-4z'/></`),
165
177
  /** Formatting */
166
178
  PlainText: S(`0 0 256 256`, `<path fill='currentColor' d='M212 56v32a12 12 0 0 1-24 0V68h-48v120h20a12 12 0 0 1 0 24H96a12 12 0 0 1 0-24h20V68H68v20a12 12 0 0 1-24 0V56a12 12 0 0 1 12-12h144a12 12 0 0 1 12 12Z'/>`),
167
179
  Markup: S(`0 0 24 24`, `<path fill='currentColor' d='M10 20q-.425 0-.713-.288T9 19v-5q-2.075 0-3.538-1.463T4 9q0-2.075 1.463-3.538T9 4h8q.425 0 .713.288T18 5q0 .425-.288.713T17 6h-1v13q0 .425-.288.713T15 20q-.425 0-.713-.288T14 19V6h-3v13q0 .425-.288.713T10 20Z'/>`),
@@ -169,14 +181,20 @@ export const IconMap = {
169
181
  /** Components */
170
182
  Navigation: S(`0 0 24 24`, `<path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m3 11l19-9l-9 19l-2-8z'/>`),
171
183
  Alert: S(`0 0 24 24`, `<path fill='currentColor' d='M12 2L1 21h22M12 6l7.53 13H4.47M11 10v4h2v-4m-2 6v2h2v-2'/>`),
184
+ Data: S(`0 0 24 24`, `<path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M18 12v5c0 1.657-2.686 3-6 3s-6-1.343-6-3v-5m12 0V7m0 5c0 1.657-2.686 3-6 3s-6-1.343-6-3m12-5c0-1.657-2.686-3-6-3S6 5.343 6 7m12 0c0 1.657-2.686 3-6 3S6 8.657 6 7m0 5V7'/>`),
185
+ Tool: S(`0 0 24 24`, `<path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M7 10h3V7L6.5 3.5a6 6 0 0 1 8 8l6 6a2 2 0 0 1-3 3l-6-6a6 6 0 0 1-8-8z'/>`),
172
186
  /** Actions */
173
187
  Completed: S(`0 0 2048 2048`, `<path fill='currentColor' d='M1024 0q141 0 272 36t244 104t207 160t161 207t103 245t37 272q0 141-36 272t-104 244t-160 207t-207 161t-245 103t-272 37q-141 0-272-36t-244-104t-207-160t-161-207t-103-245t-37-272q0-141 36-272t104-244t160-207t207-161T752 37t272-37m603 685l-136-136l-659 659l-275-275l-136 136l411 411z'/>`),
174
188
  Failed: S(`0 0 2048 2048`, `<path fill='currentColor' d='M1024 0q141 0 272 36t244 104t207 160t161 207t103 245t37 272q0 141-36 272t-104 244t-160 207t-207 161t-245 103t-272 37q-141 0-272-36t-244-104t-207-160t-161-207t-103-245t-37-272q0-141 36-272t104-244t160-207t207-161T752 37t272-37m113 1024l342-342l-113-113l-342 342l-342-342l-113 113l342 342l-342 342l113 113l342-342l342 342l113-113z'/>`),
175
189
  };
176
190
  export const IconGroups = {
177
- User: ['AppUser'],
178
- Company: ['Organization'],
179
- Contact: ['Customer', 'Client', 'Employee', 'Applicant'],
191
+ User: ['AppUser', 'Author'],
192
+ Contact: ['Customer', 'Client', 'Employee', 'Applicant', 'Candidate', 'Staff'],
193
+ Company: ['Organization', 'Conference', 'City'],
194
+ Account: ['Profile'],
195
+ Team: ['Collab', 'Collaboration'],
196
+ Region: ['Country', 'State', 'Province', 'Capital'],
197
+ Lock: ['Security', 'Padlock', 'Secure'],
180
198
  Location: ['Address', 'JobLocation'],
181
199
  Time: ['TimeSlot', 'DateRange'],
182
200
  Feature: ['Amenity'],
@@ -186,28 +204,52 @@ export const IconGroups = {
186
204
  Check: ['Require'],
187
205
  Screening: ['PhoneScreen'],
188
206
  Artifact: ['Media'],
189
- Product: ['Sku'],
207
+ Product: ['Sku', 'Item', 'Restock', 'Stock'],
190
208
  Order: ['Invoice'],
191
209
  LineItem: ['InvoiceItem'],
192
210
  Opportunity: ['Lead', 'Deal'],
193
211
  Connect: ['Interaction'],
194
212
  Conversion: ['Convert'],
195
- Expense: ['Cost', 'Price', 'Amount'],
213
+ Expense: ['Cost', 'Price', 'Amount', 'Salary'],
196
214
  Approve: ['Approval'],
197
215
  Refund: ['Return', 'Reimburse'],
198
216
  Library: ['Module'],
199
217
  Page: ['Article', 'Document'],
200
218
  Policy: ['Privacy', 'CompanyPolicy'],
201
- Gift: ['Benefit'],
219
+ Gift: ['Benefit', 'Service', 'Share', 'Sharing', 'Reward'],
202
220
  Deduct: ['Deduction'],
203
221
  Tax: ['Taxes'],
204
222
  Tag: ['Label'],
205
223
  Type: ['Title', 'JobTitle'],
206
224
  Message: ['Note'],
207
- Category: ['Group', 'Department'],
225
+ Category: ['Department'],
226
+ Folder: ['Group'],
208
227
  Markup: ['TextMarkup'],
209
228
  HtmlFormat: ['RichHtml'],
210
229
  Alert: ['Notification'],
230
+ Enroll: ['Enrollment', 'Lesson', 'Access'],
231
+ Actual: ['Request'],
232
+ Pay: ['Paystub'],
233
+ Post: ['Posting'],
234
+ Content: ['Website', 'Blog', 'Template', 'LandingPage', 'Portal', 'Workspace'],
235
+ Menu: ['Nav', 'Form', 'MenuList'],
236
+ Skill: ['Qualification', 'Certification', 'Experience', 'Training', 'Requirement'],
237
+ Analytics: ['Level', 'Metric', 'Kpi', 'Goal', 'Objective'],
238
+ Review: ['Audit', 'Status'],
239
+ Comment: ['Feedback'],
240
+ Vote: ['Rating', 'Rank', 'Score', 'Priority'],
241
+ Favorite: ['Bookmark', 'Star'],
242
+ Logs: ['Detail', 'Details', 'History', 'Log', 'Record', 'Journal', 'Entry', 'Transaction'],
243
+ PlainText: ['Field'],
244
+ Ship: ['Shipment'],
245
+ Setting: ['Adjustment', 'Configuration', 'Setup'],
246
+ Activity: ['Movement'],
247
+ Attachment: ['File'],
248
+ News: ['Announcement'],
249
+ Data: ['Database'],
250
+ Channel: ['Stream', 'Broadcast', 'Feed', 'Session'],
251
+ Search: ['Filter', 'Lookup', 'Query', 'Match'],
252
+ Save: ['Saved', 'Archive', 'Backup', 'Download', 'Export'],
211
253
  };
212
254
  export const Icons = withAliases(IconMap, IconGroups);
213
255
  const IconKeys = Object.keys(Icons).sort((a, b) => b.length - a.length);
package/dist/index.js CHANGED
@@ -115,7 +115,7 @@ function parseArgs(...args) {
115
115
  ret.prompt = (ret.prompt ?? '') + arg;
116
116
  }
117
117
  }
118
- if (ret.type === "prompt") {
118
+ if (ret.type === "prompt" || ret.type === "chat") {
119
119
  if (!ret.cached && process.env.OKAI_CACHED) {
120
120
  ret.cached = true;
121
121
  }
@@ -190,6 +190,57 @@ Options:
190
190
  process.exit(exitCode);
191
191
  return;
192
192
  }
193
+ if (command.type === "list") {
194
+ if (command.list == "models") {
195
+ const url = new URL('/models/list', command.baseUrl);
196
+ if (command.verbose)
197
+ console.log(`GET: ${url}`);
198
+ const res = await fetch(url);
199
+ if (!res.ok) {
200
+ console.log(`Failed to fetch models: ${res.statusText}`);
201
+ process.exit(1);
202
+ }
203
+ const models = await res.text();
204
+ console.log(models);
205
+ process.exit(0);
206
+ }
207
+ }
208
+ if (command.type === "chat") {
209
+ try {
210
+ const url = new URL('/chat', command.baseUrl);
211
+ const formData = new FormData();
212
+ formData.append('prompt', command.prompt);
213
+ if (command.system) {
214
+ formData.append('system', command.system);
215
+ }
216
+ if (command.models) {
217
+ formData.append('model', command.models);
218
+ if (command.license) {
219
+ formData.append('license', command.license);
220
+ }
221
+ }
222
+ if (command.verbose)
223
+ console.log(`POST: ${url}`);
224
+ const res = await fetch(url, {
225
+ method: 'POST',
226
+ body: formData,
227
+ });
228
+ if (!res.ok) {
229
+ console.log(`Failed to chat: ${res.statusText}`);
230
+ process.exit(1);
231
+ }
232
+ const response = await res.json();
233
+ if (command.verbose)
234
+ console.log(JSON.stringify(response, undefined, 2));
235
+ const content = response.choices[response.choices.length - 1]?.message?.content;
236
+ console.log(content);
237
+ }
238
+ catch (err) {
239
+ console.error(err);
240
+ }
241
+ process.exit(0);
242
+ }
243
+ // Requires running in context of ServiceStack App
193
244
  const info = command.info = projectInfo(process.cwd());
194
245
  if (!info) {
195
246
  if (!info) {
@@ -213,21 +264,6 @@ Options:
213
264
  if (command.ignoreSsl) {
214
265
  process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
215
266
  }
216
- if (command.type === "list") {
217
- if (command.list == "models") {
218
- const url = new URL('/models/list', command.baseUrl);
219
- if (command.verbose)
220
- console.log(`GET: ${url}`);
221
- const res = await fetch(url);
222
- if (!res.ok) {
223
- console.log(`Failed to fetch models: ${res.statusText}`);
224
- process.exit(1);
225
- }
226
- const models = await res.text();
227
- console.log(models);
228
- process.exit(0);
229
- }
230
- }
231
267
  if (command.type == "init" && command.info) {
232
268
  const toApiFile = path.join(info.serviceModelDir, 'api.d.ts');
233
269
  fs.copyFileSync(path.join(import.meta.dirname, 'api.d.ts'), toApiFile);
@@ -433,41 +469,6 @@ Options:
433
469
  await acceptGist(command, command.accept);
434
470
  process.exit(0);
435
471
  }
436
- if (command.type === "chat") {
437
- try {
438
- const url = new URL('/chat', command.baseUrl);
439
- const formData = new FormData();
440
- formData.append('prompt', command.prompt);
441
- if (command.system) {
442
- formData.append('system', command.system);
443
- }
444
- if (command.models) {
445
- formData.append('model', command.models);
446
- if (command.license) {
447
- formData.append('license', command.license);
448
- }
449
- }
450
- if (command.verbose)
451
- console.log(`POST: ${url}`);
452
- const res = await fetch(url, {
453
- method: 'POST',
454
- body: formData,
455
- });
456
- if (!res.ok) {
457
- console.log(`Failed to chat: ${res.statusText}`);
458
- process.exit(1);
459
- }
460
- const response = await res.json();
461
- if (command.verbose)
462
- console.log(JSON.stringify(response, undefined, 2));
463
- const content = response.choices[response.choices.length - 1]?.message?.content;
464
- console.log(content);
465
- }
466
- catch (err) {
467
- console.error(err);
468
- }
469
- process.exit(0);
470
- }
471
472
  if (command.type === "prompt") {
472
473
  try {
473
474
  if (!info.serviceModelDir)
package/dist/utils.js CHANGED
@@ -258,3 +258,11 @@ export function createError(errorCode, message, fieldName) {
258
258
  })
259
259
  });
260
260
  }
261
+ export function isBinary(contentType) {
262
+ return contentType && !contentType.endsWith('+xml') &&
263
+ (contentType.startsWith('image/')
264
+ || contentType.startsWith('video/')
265
+ || contentType.startsWith('audio/')
266
+ || contentType.endsWith('octet-stream')
267
+ || contentType.endsWith('compressed'));
268
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "okai",
3
3
  "type": "module",
4
- "version": "0.0.32",
4
+ "version": "0.0.34",
5
5
  "bin": "./dist/okai.js",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",