@usefillo/core 0.3.0 → 0.3.1
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 +1 -1
- package/dist/index.d.ts +8 -7
- package/dist/index.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ npm i @usefillo/core
|
|
|
15
15
|
```ts
|
|
16
16
|
import { createClient, defineForm, validateResponse, visibleBlocks } from "@usefillo/core";
|
|
17
17
|
|
|
18
|
-
const client = createClient({
|
|
18
|
+
const client = createClient({ key: "pk_live_…" });
|
|
19
19
|
|
|
20
20
|
const form = defineForm({
|
|
21
21
|
id: "cust-feedback",
|
package/dist/index.d.ts
CHANGED
|
@@ -342,17 +342,17 @@ interface FormDraftSpec {
|
|
|
342
342
|
declare function assembleForm(spec: FormDraftSpec): FormSchema;
|
|
343
343
|
|
|
344
344
|
interface FilloClientOptions {
|
|
345
|
-
/**
|
|
346
|
-
* Where the SDK sends requests. Defaults to the hosted API (https://fillo.so).
|
|
347
|
-
* Only set this if you reverse-proxy Fillo through your own domain — e.g. to
|
|
348
|
-
* keep traffic first-party or dodge ad-blockers, like PostHog's api_host.
|
|
349
|
-
*/
|
|
350
|
-
baseUrl?: string;
|
|
351
345
|
/**
|
|
352
346
|
* Publishable workspace key (pk_…) — safe to ship in client code. Required
|
|
353
347
|
* only for syncing code-defined forms into the workspace.
|
|
354
348
|
*/
|
|
355
349
|
key?: string;
|
|
350
|
+
/**
|
|
351
|
+
* Internal: send requests to this page's own origin instead of the hosted
|
|
352
|
+
* API. Used only by Fillo's own first-party pages (hosted forms, marketing)
|
|
353
|
+
* so they hit localhost in dev and fillo.so in prod. Not for embedding.
|
|
354
|
+
*/
|
|
355
|
+
sameOrigin?: boolean;
|
|
356
356
|
fetch?: typeof fetch;
|
|
357
357
|
}
|
|
358
358
|
interface PublishedForm {
|
|
@@ -497,7 +497,8 @@ interface ProvisionWorkspaceResult {
|
|
|
497
497
|
*/
|
|
498
498
|
declare function provisionWorkspace(options: {
|
|
499
499
|
email: string;
|
|
500
|
-
|
|
500
|
+
/** Internal: hit this page's own origin (Fillo's own pages). */
|
|
501
|
+
sameOrigin?: boolean;
|
|
501
502
|
/** Free-form provenance label, e.g. "agent" | "cli". */
|
|
502
503
|
source?: string;
|
|
503
504
|
fetch?: typeof fetch;
|
package/dist/index.js
CHANGED
|
@@ -696,7 +696,7 @@ var FilloClient = class {
|
|
|
696
696
|
/** Publishable workspace key, when configured. */
|
|
697
697
|
key;
|
|
698
698
|
constructor(options = {}) {
|
|
699
|
-
this.baseUrl =
|
|
699
|
+
this.baseUrl = options.sameOrigin ? "" : DEFAULT_BASE_URL;
|
|
700
700
|
this.key = options.key;
|
|
701
701
|
this.fetch = options.fetch ?? ((...args) => globalThis.fetch(...args));
|
|
702
702
|
}
|
|
@@ -1026,9 +1026,9 @@ function createClient(options = {}) {
|
|
|
1026
1026
|
return new FilloClient(options);
|
|
1027
1027
|
}
|
|
1028
1028
|
async function provisionWorkspace(options) {
|
|
1029
|
-
const
|
|
1029
|
+
const base = options.sameOrigin ? "" : DEFAULT_BASE_URL;
|
|
1030
1030
|
const doFetch = options.fetch ?? ((...args) => globalThis.fetch(...args));
|
|
1031
|
-
const res = await doFetch(`${
|
|
1031
|
+
const res = await doFetch(`${base}/api/v1/workspaces/provision`, {
|
|
1032
1032
|
method: "POST",
|
|
1033
1033
|
headers: { "Content-Type": "application/json" },
|
|
1034
1034
|
body: JSON.stringify({ email: options.email, source: options.source ?? "sdk" })
|