@foir/sdk 0.21.0 → 0.23.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.
Files changed (62) hide show
  1. package/CHANGELOG.md +135 -1
  2. package/README.md +15 -15
  3. package/dist/app/client.d.ts +93 -86
  4. package/dist/app/contract/proto/apps/v1/apps_pb.d.ts +14 -13
  5. package/dist/app/dispatch.d.ts +5 -5
  6. package/dist/app/errors.d.ts +17 -15
  7. package/dist/app/index.d.ts +4 -4
  8. package/dist/app/naming.d.ts +1 -1
  9. package/dist/app/ticket.d.ts +2 -2
  10. package/dist/app/vocabulary.generated.d.ts +2 -2
  11. package/dist/app-contract.js +3 -3
  12. package/dist/app.js +92 -90
  13. package/dist/auth/access.d.ts +19 -19
  14. package/dist/auth/auth.d.ts +251 -117
  15. package/dist/auth/grant-table.generated.d.ts +5 -4
  16. package/dist/auth/hosted.d.ts +38 -14
  17. package/dist/auth/index.d.ts +9 -9
  18. package/dist/auth/operations.d.ts +153 -33
  19. package/dist/auth/ops.d.ts +39 -21
  20. package/dist/auth/session-client.d.ts +3 -3
  21. package/dist/auth-session.js +3 -3
  22. package/dist/auth.js +400 -250
  23. package/dist/client.js +5 -8
  24. package/dist/codegen/preset.d.ts +1 -1
  25. package/dist/data/builtins.d.ts +26 -26
  26. package/dist/data/client.d.ts +3 -3
  27. package/dist/data/decimal.d.ts +1 -1
  28. package/dist/data/index.d.ts +1 -1
  29. package/dist/data/manifest.d.ts +1 -1
  30. package/dist/data/schema.d.ts +2 -2
  31. package/dist/data/transport.d.ts +14 -13
  32. package/dist/data/ws-transport.d.ts +1 -1
  33. package/dist/data.js +8 -11
  34. package/dist/graphql/content-client.d.ts +13 -13
  35. package/dist/index.js +1 -4
  36. package/dist/live/drift.d.ts +1 -1
  37. package/dist/media/screen-capture.d.ts +1 -1
  38. package/dist/next/index.d.ts +2 -2
  39. package/dist/next/session.d.ts +10 -10
  40. package/dist/next.js +78 -60
  41. package/dist/placement/index.d.ts +13 -13
  42. package/dist/placement.js +127 -116
  43. package/dist/push.js +62 -44
  44. package/dist/react/FoirFeedback.d.ts +2 -2
  45. package/dist/react/FoirProvider.d.ts +24 -24
  46. package/dist/react/SignIn.d.ts +4 -4
  47. package/dist/react/UserButton.d.ts +1 -1
  48. package/dist/react/feedback-notes.d.ts +8 -6
  49. package/dist/react/index.d.ts +3 -3
  50. package/dist/react.js +238 -209
  51. package/dist/realtime/index.d.ts +1 -1
  52. package/dist/server/callback-client.d.ts +4 -4
  53. package/dist/server/events-client.d.ts +21 -21
  54. package/dist/server/operation-types.d.ts +8 -8
  55. package/dist/server/require-scoped-token.d.ts +3 -3
  56. package/dist/server/types.d.ts +2 -2
  57. package/dist/server/verify-scoped-token.d.ts +3 -3
  58. package/dist/server.js +130 -126
  59. package/dist/transport/foir-http.d.ts +14 -14
  60. package/dist/transport/key-kind.d.ts +1 -12
  61. package/dist/types/index.d.ts +2 -2
  62. package/package.json +1 -1
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * The split exists so the second one is possible. The Foir-specific transport
13
13
  * concerns — which api key is in play, the preview schema channel header, the
14
- * optional customer bearer, and the `FoirRequestError` shape — are identical on
14
+ * optional user bearer, and the `FoirRequestError` shape — are identical on
15
15
  * both, and duplicating them is exactly how the two surfaces would drift. So
16
16
  * they live here once and `foir-request.ts` re-exports them unchanged; the only
17
17
  * thing that stayed behind is the part that needs `print`.
@@ -31,7 +31,7 @@ export interface FoirEnv {
31
31
  *
32
32
  * Preview is selected at the environment level, not per-request: load a
33
33
  * preview env file that sets `FOIR_PREVIEW=true` + the preview environment's
34
- * own `pk_…` key holding `drafts:read` as `PLATFORM_PREVIEW_API_KEY`, instead
34
+ * own publishable key holding `drafts:read` as `PLATFORM_PREVIEW_API_KEY`, instead
35
35
  * of the default env.
36
36
  * The site-wide mode keeps draft semantics consistent — every loader sees
37
37
  * the same preview/published view of the world. Intended for non-production
@@ -206,8 +206,8 @@ export declare function readFoirRateLimit(headers: Headers): FoirRateLimitSnapsh
206
206
  export declare function readFoirRetryAfterMs(headers: Headers): number | undefined;
207
207
  export interface FoirRequestOptions {
208
208
  /**
209
- * Customer bearer token. api-public still needs the `x-api-key` to resolve
210
- * the project; the bearer adds the customer identity for self-scoped reads
209
+ * User bearer token. api-public still needs the `x-api-key` to resolve
210
+ * the project; the bearer adds the user identity for self-scoped reads
211
211
  * (e.g. `myProfile`). Used by `@foir/sdk/auth`'s post-login profile fetch.
212
212
  */
213
213
  bearerToken?: string;
@@ -256,7 +256,7 @@ export interface FoirRequestOptions {
256
256
  onRateLimit?: (snapshot: FoirRateLimitSnapshot | undefined) => void;
257
257
  }
258
258
  /**
259
- * Supplies the current customer bearer. Sync or async so consumers can read a
259
+ * Supplies the current user bearer. Sync or async so consumers can read a
260
260
  * cookie session (Hydrogen/Remix), a KV store, an in-memory value, etc. Returns
261
261
  * the token when signed in, or `null`/`undefined` when signed out.
262
262
  *
@@ -265,7 +265,7 @@ export interface FoirRequestOptions {
265
265
  * they would end up accepting subtly different things.
266
266
  */
267
267
  export type FoirTokenProvider = () => string | null | undefined | Promise<string | null | undefined>;
268
- /** A request made with an api key, optionally for a signed-in customer. */
268
+ /** A request made with an api key, optionally for a signed-in user. */
269
269
  export interface FoirKeyHeaderInput {
270
270
  apiKey: string;
271
271
  /**
@@ -305,7 +305,7 @@ export interface FoirKeyHeaderInput {
305
305
  *
306
306
  * The token is the whole credential. api-public takes the scoped path when
307
307
  * `X-Foir-Token` is present and never reads `x-api-key` on it, and the
308
- * organization, the customer and the schema channel all come from the token's
308
+ * organization, the user and the schema channel all come from the token's
309
309
  * own claims, so none of the key-side inputs has anything to say here.
310
310
  */
311
311
  export interface FoirDispatchHeaderInput {
@@ -337,7 +337,7 @@ export declare function refuseCredentialHeaders(extra: Readonly<Record<string, s
337
337
  * authorization difference nobody would notice until it mattered.
338
338
  *
339
339
  * Two credentials, and a request carries exactly one: an api key (with its
340
- * optional customer bearer, organization and channel), or an operation's
340
+ * optional user bearer, organization and channel), or an operation's
341
341
  * dispatch token. A dispatch request never writes `x-api-key`.
342
342
  */
343
343
  /** The header a server names the visitor it calls for in. */
@@ -412,7 +412,7 @@ export declare function foirApiEndpoint(apiUrl: string, path: `/${string}`): str
412
412
  /**
413
413
  * Foir DISCARDED a credential you sent, and served the request without it.
414
414
  *
415
- * A customer JWT is optional: if it fails to verify, the read is served as an
415
+ * A user JWT is optional: if it fails to verify, the read is served as an
416
416
  * ordinary anonymous one rather than refused, because plenty of reads
417
417
  * legitimately have nobody signed in. That is the right behaviour and it has a
418
418
  * sharp edge — a lapsed token and a genuinely anonymous request produce the
@@ -424,9 +424,9 @@ export declare function foirApiEndpoint(apiUrl: string, path: `/${string}`): str
424
424
  */
425
425
  export interface FoirAuthDowngrade {
426
426
  /** Always `"rejected"`. */
427
- customerToken: string;
427
+ userToken: string;
428
428
  /**
429
- * `expired` — re-exchange and retry. `invalid` — not a customer token for
429
+ * `expired` — re-exchange and retry. `invalid` — not a user token for
430
430
  * this environment. `wrong_project` — the token and the api-key name
431
431
  * different projects.
432
432
  */
@@ -435,7 +435,7 @@ export interface FoirAuthDowngrade {
435
435
  servedAs: string;
436
436
  }
437
437
  /**
438
- * A request that sent a customer token was served without it.
438
+ * A request that sent a user token was served without it.
439
439
  *
440
440
  * Thrown only to a caller that asked (`rejectDowngrade`): one that sent the
441
441
  * token because it wants the signed-in answer, and would otherwise be handed the
@@ -448,9 +448,9 @@ export declare class FoirAuthDowngradedError extends FoirRequestError {
448
448
  constructor(downgrade: FoirAuthDowngrade);
449
449
  }
450
450
  /**
451
- * The customer's session is over: its token was rejected and could not be
451
+ * The user's session is over: its token was rejected and could not be
452
452
  * refreshed. It is what a signed-in request gets in place of the anonymous
453
- * answer. Send the customer to sign in again.
453
+ * answer. Send the user to sign in again.
454
454
  */
455
455
  export declare class FoirSessionExpiredError extends FoirRequestError {
456
456
  constructor(options?: {
@@ -6,30 +6,19 @@
6
6
  * app's pages. An admin key is a machine's own: a sync job, a pipeline, a tool.
7
7
  * A key says its kind in its first letters, so this is decided without a
8
8
  * request.
9
- *
10
- * A key minted before a key had a kind says an older type. A `pk_` key is a
11
- * publishable key. An `sk_` or a `tc_` key says only that it is not public:
12
- * the platform holds it as an admin key, and it is reported here as `older`,
13
- * so that a caller who refuses an admin key by name does not refuse a key
14
- * whose holder has not yet been able to mint a server key in its place.
15
9
  */
16
10
  export type FoirKeyKind = 'publishable' | 'server' | 'admin';
17
- /** What a key's prefix says of it: its kind, or that it is an older secret. */
18
- export type FoirKeyPrefixKind = FoirKeyKind | 'older';
19
11
  /** Where each credential is for, and which key an app holds. */
20
12
  export declare const FOIR_CREDENTIALS_DOC = "https://docs.foir.dev/credentials";
21
13
  /**
22
14
  * What a key says of itself by its prefix, or `undefined` for a string that
23
15
  * is no key Fóir made.
24
16
  */
25
- export declare function foirKeyKind(apiKey: string | null | undefined): FoirKeyPrefixKind | undefined;
17
+ export declare function foirKeyKind(apiKey: string | null | undefined): FoirKeyKind | undefined;
26
18
  /**
27
19
  * What an app's client says when it is handed an admin key, naming the client
28
20
  * it was handed to. An admin key is a machine's own, so every client an app
29
21
  * builds refuses one before any request, in the same words.
30
- *
31
- * Only a key that says it is an admin key by its prefix is refused. A key
32
- * minted before a key had a kind does not say, and is let through.
33
22
  */
34
23
  export declare function adminKeyRefusal(client: string): string;
35
24
  /**
@@ -21,7 +21,7 @@ export interface EditorInit {
21
21
  apiUrl: string;
22
22
  /** Config connection domain (e.g. my-store.myshopify.com) */
23
23
  connectionDomain?: string;
24
- /** How this editor is rendered in the admin UI. */
24
+ /** How this editor is rendered in the console. */
25
25
  configMode?: 'editor' | 'sidebar';
26
26
  /** Currently selected field keys (sidebar mode). */
27
27
  selectedFieldKeys?: string[];
@@ -67,7 +67,7 @@ export interface EditorContextValue {
67
67
  resize: (height: number) => void;
68
68
  /** Report dirty state (unsaved changes). */
69
69
  setDirty: (isDirty: boolean) => void;
70
- /** Request the host to navigate to an admin path. */
70
+ /** Request the host to navigate to a console path. */
71
71
  requestNavigate: (path: string) => void;
72
72
  /** Request the host to execute a platform operation. Returns the result.
73
73
  * `mode` controls whether the platform waits for the operation to complete
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foir/sdk",
3
- "version": "0.21.0",
3
+ "version": "0.23.0",
4
4
  "description": "Official Foir SDK — editor iframe client + server-side platform helpers",
5
5
  "type": "module",
6
6
  "publishConfig": {