arcy.js 0.1.0 → 0.1.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.
package/dist/index.d.ts CHANGED
@@ -22,6 +22,21 @@ type Unsubscribe = () => void;
22
22
  */
23
23
  type AttributeValue = string | number | boolean | null | string[];
24
24
  type Attributes = Record<string, AttributeValue>;
25
+ /**
26
+ * What a caller may hand `identify()`, and it is deliberately wider than what
27
+ * goes on the wire (ADR 0194).
28
+ *
29
+ * `undefined` means "nothing to send for this key": the key is dropped from the
30
+ * payload before it leaves the browser, silently, and never reaches the server.
31
+ * It exists because every auth SDK returns optional fields, so the line an
32
+ * operator naturally writes is `user_email: user.primaryEmailAddress?.emailAddress`,
33
+ * and a type that refuses it refuses the install snippet we publish.
34
+ *
35
+ * This keeps the three spellings distinct. An absent key means "do not touch",
36
+ * `null` means "clear it", and a value means "set it". `undefined` is the first
37
+ * of those, spelled the way JavaScript spells it.
38
+ */
39
+ type AttributesInput = Record<string, AttributeValue | undefined>;
25
40
  /**
26
41
  * The complete set of `init()` options, and it is complete by design
27
42
  * (PRODUCT_SCOPE §11.5.1, resolved at G1 as Q41). **Reopened once, D733**
@@ -41,6 +56,21 @@ type Attributes = Record<string, AttributeValue>;
41
56
  interface ArcyOptions {
42
57
  /** Consent signal for behavioral telemetry. A cookie banner is code. */
43
58
  telemetry?: boolean;
59
+ /**
60
+ * Where the widget talks to ARCY, if not `https://api.arcyai.com`.
61
+ *
62
+ * The fifth escape hatch (D1396, ADR 0186), and it exists for one reason:
63
+ * a page under a Content Security Policy has to name every origin the
64
+ * widget reaches, and a customer who would rather name none can rewrite a
65
+ * path on their own domain to our API and pass it here. Session, chat,
66
+ * flows, telemetry, image uploads and the panel's web fonts all follow it,
67
+ * so proxying moves the whole widget rather than most of it.
68
+ *
69
+ * An origin or an origin with a path prefix, no trailing slash, for
70
+ * example `https://example.com/_arcy`. Anything that is not a string is
71
+ * ignored with a warning, like every other bad option.
72
+ */
73
+ apiBase?: string;
44
74
  /**
45
75
  * The host app usually knows the user's language before ARCY loads.
46
76
  *
@@ -106,9 +136,9 @@ interface IdentifyOptions {
106
136
  }
107
137
  interface Arcy {
108
138
  init(token: string, options?: ArcyOptions): Promise<void>;
109
- identify(userId: string, attributes?: Attributes, options?: IdentifyOptions): Promise<void>;
110
- identifyAnonymous(attributes?: Attributes): Promise<void>;
111
- updateUser(attributes?: Attributes): Promise<void>;
139
+ identify(userId: string, attributes?: AttributesInput, options?: IdentifyOptions): Promise<void>;
140
+ identifyAnonymous(attributes?: AttributesInput): Promise<void>;
141
+ updateUser(attributes?: AttributesInput): Promise<void>;
112
142
  reset(): void;
113
143
  open(): void;
114
144
  close(): void;
@@ -121,13 +151,19 @@ interface Arcy {
121
151
  * so the ESM, CJS, and IIFE builds all carry the same value with no build-time
122
152
  * indirection. Bumped with the package version.
123
153
  */
124
- declare const VERSION = "0.1.0";
154
+ declare const VERSION = "0.1.1";
125
155
 
126
156
  /**
127
- * The namespace object. In the HTML build this is what `window.arcy` is; in
128
- * the npm build it is the default export. Both builds resolve to the same
129
- * object so a call written against one path behaves identically on the other.
157
+ * The namespace object, and the npm build's default export. `src/browser.ts`
158
+ * builds the same object for `window.arcy` on the script path.
159
+ *
160
+ * The two entry points differ in exactly one argument (ADR 0185): this one
161
+ * loads the chat panel, the flow engine and the picker with `import()`, so
162
+ * they become chunks in the customer's own build on the customer's own
163
+ * origin. The script build injects them from the CDN, which is the origin
164
+ * its install snippet already comes from. Nothing else about the two paths
165
+ * differs, and a call written against one behaves identically on the other.
130
166
  */
131
167
  declare const arcy: Arcy;
132
168
 
133
- export { type Arcy, type ArcyEvent, type ArcyEventHandler, type ArcyOptions, type AttributeValue, type Attributes, type Unsubscribe, VERSION, arcy as default };
169
+ export { type Arcy, type ArcyEvent, type ArcyEventHandler, type ArcyOptions, type AttributeValue, type Attributes, type AttributesInput, type Unsubscribe, VERSION, arcy as default };