@lunnoa/client 0.0.0-development → 1.1.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.
package/dist/index.js CHANGED
@@ -531,7 +531,8 @@ var DEFINE_KINDS = {
531
531
  aiConnection: "aiConnection",
532
532
  action: "action",
533
533
  workflow: "workflow",
534
- agent: "agent"
534
+ agent: "agent",
535
+ entityType: "entityType"
535
536
  };
536
537
  function defineConnection(config = {}) {
537
538
  return { kind: DEFINE_KINDS.connection, ...config };
@@ -566,6 +567,19 @@ function defineAgent(config) {
566
567
  }
567
568
  return { kind: DEFINE_KINDS.agent, ...config };
568
569
  }
570
+ function defineEntityType(config) {
571
+ if (!config.slug?.trim()) {
572
+ throw new Error("defineEntityType requires slug");
573
+ }
574
+ if (!config.attributeSchema || typeof config.attributeSchema !== "object" || Array.isArray(config.attributeSchema)) {
575
+ throw new Error("defineEntityType requires attributeSchema object");
576
+ }
577
+ return {
578
+ kind: DEFINE_KINDS.entityType,
579
+ allowUnknownAttributes: false,
580
+ ...config
581
+ };
582
+ }
569
583
  function resolveActionAppId(action) {
570
584
  if (action.appId?.trim()) {
571
585
  return action.appId.trim();
@@ -1043,6 +1057,21 @@ var EntitiesResource = class {
1043
1057
  };
1044
1058
 
1045
1059
  // src/resources/entity-types.ts
1060
+ function entityTypeDefinitionToUpsert(def) {
1061
+ return {
1062
+ slug: def.slug,
1063
+ name: def.name,
1064
+ namePlural: def.namePlural,
1065
+ description: def.description,
1066
+ icon: def.icon,
1067
+ color: def.color,
1068
+ attributeSchema: def.attributeSchema,
1069
+ stateSchema: def.stateSchema,
1070
+ isEnabled: def.isEnabled,
1071
+ allowUnknownAttributes: def.allowUnknownAttributes ?? false,
1072
+ managedByCode: true
1073
+ };
1074
+ }
1046
1075
  var EntityTypesResource = class {
1047
1076
  constructor(http) {
1048
1077
  this.http = http;
@@ -1073,6 +1102,19 @@ var EntityTypesResource = class {
1073
1102
  query: { expansion: serializeCsv(options.expansion) }
1074
1103
  });
1075
1104
  }
1105
+ /**
1106
+ * Creates or updates an entity type by workspace-scoped slug.
1107
+ * Prefer the CLI (`npx @lunnoa/client entity-types deploy`) for happy-path deploy.
1108
+ */
1109
+ upsertBySlug(definition) {
1110
+ const payload = "kind" in definition && definition.kind === "entityType" ? entityTypeDefinitionToUpsert(definition) : definition;
1111
+ return this.http.post("/api/object-types/upsert", {
1112
+ body: payload,
1113
+ query: {
1114
+ expansion: "attributeSchema,stateSchema,description"
1115
+ }
1116
+ });
1117
+ }
1076
1118
  };
1077
1119
 
1078
1120
  // src/resources/approvals.ts
@@ -1533,12 +1575,42 @@ var QueueItemsResource = class {
1533
1575
  `/api/queues/${queueId}/items/${itemId}`
1534
1576
  );
1535
1577
  }
1536
- /** Adds an item to a queue. */
1578
+ /** Adds an item to a queue. Pass `objectId` to link the item to an entity. */
1537
1579
  create(queueId, data) {
1538
1580
  return this.http.post(`/api/queues/${queueId}/items`, {
1539
1581
  body: data
1540
1582
  });
1541
1583
  }
1584
+ /**
1585
+ * Lists queue items linked to an Object across all queues in the workspace.
1586
+ * Use for Object detail "Work" panels.
1587
+ */
1588
+ listByObject(objectId, options = {}) {
1589
+ return this.http.get(
1590
+ `/api/objects/${objectId}/queue-items`,
1591
+ {
1592
+ query: {
1593
+ status: options.status,
1594
+ limit: options.limit,
1595
+ offset: options.offset,
1596
+ expansion: serializeCsv(options.expansion)
1597
+ }
1598
+ }
1599
+ );
1600
+ }
1601
+ /** Async-iterates every queue item linked to an Object. */
1602
+ iterateByObject(objectId, options = {}) {
1603
+ return iterateOffset(async (offset) => {
1604
+ const result = await this.listByObject(objectId, {
1605
+ ...options,
1606
+ offset
1607
+ });
1608
+ return {
1609
+ items: result.items ?? [],
1610
+ pagination: result.pagination
1611
+ };
1612
+ });
1613
+ }
1542
1614
  /** Adds many items to a queue in one call. */
1543
1615
  bulkCreate(queueId, data) {
1544
1616
  return this.http.post(
@@ -2089,6 +2161,6 @@ function createServerClient(options) {
2089
2161
  });
2090
2162
  }
2091
2163
 
2092
- export { API_KEY_PREFIX, ActionsResource, AgentChatClient, AgentChatStream, AgentsResource, ApprovalsResource, AuthResource, ConnectionsResource, DEFINE_KINDS, DiscoveryResource, EntitiesResource, EntityTypesResource, ExecutionProgressStream, ExecutionTimeoutError, ExecutionsResource, HttpClient, KnowledgeResource, LunnoaApiError, LunnoaClient, ProjectsResource, QueueItemsResource, QueuesResource, RunsResource, SsoAuthResource, TasksResource, VariablesResource, WorkflowAppsResource, WorkflowsResource, assertApiKeyAllowedInEnvironment, createBrowserClient, createLocalStorageTokenStore, createMemoryTokenStore, createServerClient, defineAction, defineAgent, defineAiConnection, defineConnection, defineWorkflow, isBrowserEnvironment, isLoginRequires2FA, iterateOffset, iteratePages, parseSseEvents, parseSseStream, resolveActionAppId, resolveActionId };
2164
+ export { API_KEY_PREFIX, ActionsResource, AgentChatClient, AgentChatStream, AgentsResource, ApprovalsResource, AuthResource, ConnectionsResource, DEFINE_KINDS, DiscoveryResource, EntitiesResource, EntityTypesResource, ExecutionProgressStream, ExecutionTimeoutError, ExecutionsResource, HttpClient, KnowledgeResource, LunnoaApiError, LunnoaClient, ProjectsResource, QueueItemsResource, QueuesResource, RunsResource, SsoAuthResource, TasksResource, VariablesResource, WorkflowAppsResource, WorkflowsResource, assertApiKeyAllowedInEnvironment, createBrowserClient, createLocalStorageTokenStore, createMemoryTokenStore, createServerClient, defineAction, defineAgent, defineAiConnection, defineConnection, defineEntityType, defineWorkflow, entityTypeDefinitionToUpsert, isBrowserEnvironment, isLoginRequires2FA, iterateOffset, iteratePages, parseSseEvents, parseSseStream, resolveActionAppId, resolveActionId };
2093
2165
  //# sourceMappingURL=index.js.map
2094
2166
  //# sourceMappingURL=index.js.map