@lunnoa/client 1.0.0 → 1.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.
package/dist/index.cjs CHANGED
@@ -533,7 +533,8 @@ var DEFINE_KINDS = {
533
533
  aiConnection: "aiConnection",
534
534
  action: "action",
535
535
  workflow: "workflow",
536
- agent: "agent"
536
+ agent: "agent",
537
+ entityType: "entityType"
537
538
  };
538
539
  function defineConnection(config = {}) {
539
540
  return { kind: DEFINE_KINDS.connection, ...config };
@@ -568,6 +569,19 @@ function defineAgent(config) {
568
569
  }
569
570
  return { kind: DEFINE_KINDS.agent, ...config };
570
571
  }
572
+ function defineEntityType(config) {
573
+ if (!config.slug?.trim()) {
574
+ throw new Error("defineEntityType requires slug");
575
+ }
576
+ if (!config.attributeSchema || typeof config.attributeSchema !== "object" || Array.isArray(config.attributeSchema)) {
577
+ throw new Error("defineEntityType requires attributeSchema object");
578
+ }
579
+ return {
580
+ kind: DEFINE_KINDS.entityType,
581
+ allowUnknownAttributes: false,
582
+ ...config
583
+ };
584
+ }
571
585
  function resolveActionAppId(action) {
572
586
  if (action.appId?.trim()) {
573
587
  return action.appId.trim();
@@ -1045,6 +1059,21 @@ var EntitiesResource = class {
1045
1059
  };
1046
1060
 
1047
1061
  // src/resources/entity-types.ts
1062
+ function entityTypeDefinitionToUpsert(def) {
1063
+ return {
1064
+ slug: def.slug,
1065
+ name: def.name,
1066
+ namePlural: def.namePlural,
1067
+ description: def.description,
1068
+ icon: def.icon,
1069
+ color: def.color,
1070
+ attributeSchema: def.attributeSchema,
1071
+ stateSchema: def.stateSchema,
1072
+ isEnabled: def.isEnabled,
1073
+ allowUnknownAttributes: def.allowUnknownAttributes ?? false,
1074
+ managedByCode: true
1075
+ };
1076
+ }
1048
1077
  var EntityTypesResource = class {
1049
1078
  constructor(http) {
1050
1079
  this.http = http;
@@ -1075,6 +1104,19 @@ var EntityTypesResource = class {
1075
1104
  query: { expansion: serializeCsv(options.expansion) }
1076
1105
  });
1077
1106
  }
1107
+ /**
1108
+ * Creates or updates an entity type by workspace-scoped slug.
1109
+ * Prefer the CLI (`npx @lunnoa/client entity-types deploy`) for happy-path deploy.
1110
+ */
1111
+ upsertBySlug(definition) {
1112
+ const payload = "kind" in definition && definition.kind === "entityType" ? entityTypeDefinitionToUpsert(definition) : definition;
1113
+ return this.http.post("/api/object-types/upsert", {
1114
+ body: payload,
1115
+ query: {
1116
+ expansion: "attributeSchema,stateSchema,description"
1117
+ }
1118
+ });
1119
+ }
1078
1120
  };
1079
1121
 
1080
1122
  // src/resources/approvals.ts
@@ -2158,7 +2200,9 @@ exports.defineAction = defineAction;
2158
2200
  exports.defineAgent = defineAgent;
2159
2201
  exports.defineAiConnection = defineAiConnection;
2160
2202
  exports.defineConnection = defineConnection;
2203
+ exports.defineEntityType = defineEntityType;
2161
2204
  exports.defineWorkflow = defineWorkflow;
2205
+ exports.entityTypeDefinitionToUpsert = entityTypeDefinitionToUpsert;
2162
2206
  exports.isBrowserEnvironment = isBrowserEnvironment;
2163
2207
  exports.isLoginRequires2FA = isLoginRequires2FA;
2164
2208
  exports.iterateOffset = iterateOffset;