@asiyst/sdk 0.1.8 → 0.1.9

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/README.md CHANGED
@@ -28,11 +28,14 @@ import { Asiyst } from "@asiyst/sdk";
28
28
  await Asiyst.init({
29
29
  projectId: "<PUBLIC_PROJECT_ID>",
30
30
  publicKey: "<PUBLIC_KEY>",
31
+ avatarId: "<PUBLIC_AVATAR_ID>",
31
32
  });
32
33
  ```
33
34
 
34
35
  Do not pass a secret API key as `publicKey` or omit `projectId`.
35
36
 
37
+ `avatarId` selects the avatar that the dashboard configured for this project. It is a public identifier, not an authorization credential. The SDK sends it as a selection hint while the Asiyst API still authenticates and authorizes the project with the public project key.
38
+
36
39
  ```ts
37
40
  await Asiyst.init({
38
41
  publicKey: "<PUBLIC_KEY>",
package/dist/index.cjs CHANGED
@@ -71,7 +71,7 @@ var ALL_ACTION_KINDS = [
71
71
  ];
72
72
 
73
73
  // src/core/constants.ts
74
- var SDK_VERSION = "0.1.7" ;
74
+ var SDK_VERSION = "0.1.9" ;
75
75
  var DEFAULT_API_BASE_URL = "https://nqhxpgsjofzqudyqkqib.supabase.co/functions/v1/api";
76
76
  var CONFIG_SCHEMA_VERSION = 1;
77
77
  var HOST_ELEMENT_ID = "asiyst-host";
@@ -370,9 +370,19 @@ function validateInitOptions(options) {
370
370
  if (projectIdValue.length > 128 || options.publicKey.trim().length > 256) {
371
371
  throw new ConfigurationError("project credentials exceed allowed length");
372
372
  }
373
+ const avatarId = typeof options.avatarId === "string" ? options.avatarId.trim() : "";
374
+ if (options.avatarId !== void 0 && (!avatarId || avatarId.length > 128 || !/^[A-Za-z0-9_-]+$/.test(avatarId))) {
375
+ throw new ConfigurationError("Asiyst SDK: avatarId is invalid.");
376
+ }
377
+ const position = options.position === void 0 ? void 0 : ANCHORS.includes(options.position) ? options.position : void 0;
378
+ if (options.position !== void 0 && !position) {
379
+ throw new ConfigurationError("Asiyst SDK: position is invalid.");
380
+ }
373
381
  return {
374
382
  projectId: projectIdValue,
375
- publicKey: options.publicKey.trim()
383
+ publicKey: options.publicKey.trim(),
384
+ avatarId: avatarId || void 0,
385
+ position
376
386
  };
377
387
  }
378
388
 
@@ -423,6 +433,7 @@ var HttpTransport = class {
423
433
  "Content-Type": "application/json",
424
434
  "X-Asiyst-Project-Id": this.options.projectId,
425
435
  "X-Asiyst-Public-Key": this.options.publicKey,
436
+ ...this.options.avatarId ? { "X-Asiyst-Avatar-Id": this.options.avatarId } : {},
426
437
  "X-Asiyst-SDK-Version": SDK_VERSION
427
438
  },
428
439
  body: req.body === void 0 ? void 0 : JSON.stringify(req.body),
@@ -652,6 +663,7 @@ var ConfigManager = class {
652
663
  return {
653
664
  ...base,
654
665
  mode: this.options.mode ?? base.mode,
666
+ position: this.options.position ?? base.position,
655
667
  allowedActions: this.options.allowedActions ?? base.allowedActions
656
668
  };
657
669
  }
@@ -2359,7 +2371,8 @@ var AsiystRuntime = class {
2359
2371
  const transport = new HttpTransport({
2360
2372
  apiBaseUrl: options.apiBaseUrl ?? DEFAULT_API_BASE_URL,
2361
2373
  projectId: options.projectId,
2362
- publicKey: options.publicKey
2374
+ publicKey: options.publicKey,
2375
+ avatarId: options.avatarId
2363
2376
  });
2364
2377
  this.cloud = new CloudClient(transport, options.projectId);
2365
2378
  this.config = new ConfigManager(options, this.cloud, this.events);