@foir/sdk 0.5.0 → 0.8.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/CHANGELOG.md +1126 -0
- package/README.md +94 -0
- package/dist/auth/auth.d.ts +243 -0
- package/dist/auth/hosted.d.ts +40 -0
- package/dist/auth/index.d.ts +21 -0
- package/dist/auth/operations.d.ts +144 -0
- package/dist/auth/ops.d.ts +99 -0
- package/dist/auth/session-client.d.ts +76 -0
- package/dist/auth-session.js +137 -0
- package/dist/auth.js +973 -92
- package/dist/chunk-IGNLWT3H.js +35 -0
- package/dist/chunk-OHYVKTGB.js +45 -0
- package/dist/chunk-TAL5H6VA.js +39 -0
- package/dist/client/platform-client.d.ts +29 -0
- package/dist/client.js +275 -37
- package/dist/codegen/block-registry.d.ts +13 -23
- package/dist/codegen/block-registry.js +3 -31
- package/dist/codegen/block-scaffold.d.ts +12 -25
- package/dist/codegen/block-scaffold.js +3 -41
- package/dist/codegen/index.d.ts +12 -61
- package/dist/codegen/index.js +7 -11
- package/dist/codegen/item-registry.d.ts +28 -0
- package/dist/codegen/item-registry.js +7 -0
- package/dist/codegen/item-scaffold.d.ts +29 -0
- package/dist/codegen/item-scaffold.js +7 -0
- package/dist/codegen/preset.d.ts +67 -0
- package/dist/codegen/shared.d.ts +36 -0
- package/dist/components/EditorProvider.d.ts +36 -0
- package/dist/content/content-renderer.d.ts +113 -0
- package/dist/content/index.d.ts +18 -0
- package/dist/content/richtext.d.ts +118 -0
- package/dist/content.js +227 -80
- package/dist/data/builtins.d.ts +506 -0
- package/dist/data/client.d.ts +166 -0
- package/dist/data/document.d.ts +251 -0
- package/dist/data/index.d.ts +73 -0
- package/dist/data/manifest.d.ts +424 -0
- package/dist/data/schema.d.ts +313 -0
- package/dist/data/selection.d.ts +524 -0
- package/dist/data/subjects.d.ts +221 -0
- package/dist/data/subscription-document.d.ts +75 -0
- package/dist/data/subscriptions.d.ts +181 -0
- package/dist/data/transport.d.ts +325 -0
- package/dist/data/ws-transport.d.ts +197 -0
- package/dist/data.js +1683 -0
- package/dist/graphql/cdn-route.d.ts +26 -0
- package/dist/graphql/client.d.ts +30 -0
- package/dist/graphql/content-client.d.ts +66 -0
- package/dist/graphql/foir-request.d.ts +47 -0
- package/dist/hooks/useAutoResize.d.ts +22 -0
- package/dist/hooks/useEditor.d.ts +16 -0
- package/dist/index.d.ts +10 -394
- package/dist/media/BlurhashCanvas.d.ts +10 -0
- package/dist/media/ProgressiveMedia.d.ts +56 -0
- package/dist/media/index.d.ts +18 -0
- package/dist/media/media.d.ts +139 -0
- package/dist/media/screen-capture.d.ts +81 -0
- package/dist/media/useProgressiveLoad.d.ts +23 -0
- package/dist/media.js +102 -0
- package/dist/next/cookieAdapter.d.ts +26 -0
- package/dist/next/index.d.ts +15 -0
- package/dist/next/middleware.d.ts +49 -0
- package/dist/next/session.d.ts +53 -0
- package/dist/next.js +763 -78
- package/dist/protocol/constants.d.ts +6 -0
- package/dist/protocol/messages.d.ts +155 -0
- package/dist/protocol/validation.d.ts +8 -0
- package/dist/push/index.d.ts +14 -0
- package/dist/push/operations.d.ts +22 -0
- package/dist/push/web-push.d.ts +39 -0
- package/dist/push.js +892 -78
- package/dist/react/FoirFeedback.d.ts +62 -0
- package/dist/react/FoirProvider.d.ts +116 -0
- package/dist/react/OAuthButtons.d.ts +20 -0
- package/dist/react/SignIn.d.ts +22 -0
- package/dist/react/UserButton.d.ts +13 -0
- package/dist/react/feedback-notes.d.ts +101 -0
- package/dist/react/index.d.ts +25 -0
- package/dist/react/localStorageAdapter.d.ts +10 -0
- package/dist/react.js +1373 -91
- package/dist/{realtime.d.ts → realtime/index.d.ts} +35 -16
- package/dist/realtime.js +1 -1
- package/dist/server/callback-client.d.ts +92 -0
- package/dist/server/events-client.d.ts +279 -0
- package/dist/server/index.d.ts +12 -0
- package/dist/server/operation-types.d.ts +134 -0
- package/dist/server/require-scoped-token.d.ts +76 -0
- package/dist/server/server-client.d.ts +34 -0
- package/dist/server/types.d.ts +54 -0
- package/dist/server/verify-scoped-token.d.ts +100 -0
- package/dist/server/webhook-helpers.d.ts +36 -0
- package/dist/server.js +298 -0
- package/dist/transport/foir-http.d.ts +234 -0
- package/dist/transport/persisted-query.d.ts +68 -0
- package/dist/transport/retry.d.ts +61 -0
- package/dist/types/index.d.ts +124 -0
- package/package.json +35 -13
- package/dist/auth.d.ts +0 -382
- package/dist/chunk-ADO5FJNM.js +0 -30
- package/dist/client.d.ts +0 -135
- package/dist/content.d.ts +0 -96
- package/dist/media.d.ts +0 -234
- package/dist/next.d.ts +0 -178
- package/dist/push.d.ts +0 -109
- package/dist/react.d.ts +0 -319
- package/dist/server.d.ts +0 -534
- package/dist/shared-DkWlEd2Z.d.ts +0 -18
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Protocol version for compatibility checks. */
|
|
2
|
+
export declare const PROTOCOL_VERSION = "1.0";
|
|
3
|
+
/** Maximum allowed iframe resize height in pixels. */
|
|
4
|
+
export declare const MAX_RESIZE_HEIGHT = 100000;
|
|
5
|
+
/** Path segments that must be rejected to prevent prototype pollution. */
|
|
6
|
+
export declare const DANGEROUS_PATH_SEGMENTS: string[];
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostMessage protocol types between EIDE platform host and extension iframes.
|
|
3
|
+
*
|
|
4
|
+
* Inlined from the platform protocol to keep the SDK zero-dep.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Messages sent FROM the platform host TO the iframe extension.
|
|
8
|
+
*/
|
|
9
|
+
export type HostToEditorMessage = {
|
|
10
|
+
type: 'init';
|
|
11
|
+
payload: {
|
|
12
|
+
values: Record<string, unknown>;
|
|
13
|
+
metadata?: Record<string, unknown>;
|
|
14
|
+
modelKey: string;
|
|
15
|
+
recordId: string;
|
|
16
|
+
naturalKey?: string;
|
|
17
|
+
versionId: string | null;
|
|
18
|
+
variantKey: string | null;
|
|
19
|
+
locale: string | null;
|
|
20
|
+
schema: unknown;
|
|
21
|
+
mode: 'edit' | 'readonly';
|
|
22
|
+
theme: 'light' | 'dark';
|
|
23
|
+
apiKey: string;
|
|
24
|
+
apiUrl: string;
|
|
25
|
+
connectionDomain?: string;
|
|
26
|
+
configMode?: 'editor' | 'sidebar';
|
|
27
|
+
selectedFieldKeys?: string[];
|
|
28
|
+
selectableFields?: Array<{
|
|
29
|
+
key: string;
|
|
30
|
+
label: string;
|
|
31
|
+
type: string;
|
|
32
|
+
}>;
|
|
33
|
+
localeContext?: {
|
|
34
|
+
currentLocale: string;
|
|
35
|
+
sourceLocale: string;
|
|
36
|
+
isTranslating: boolean;
|
|
37
|
+
locales: Array<{
|
|
38
|
+
code: string;
|
|
39
|
+
displayName: string;
|
|
40
|
+
isDefault: boolean;
|
|
41
|
+
}>;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
} | {
|
|
45
|
+
type: 'values-changed';
|
|
46
|
+
payload: {
|
|
47
|
+
values: Record<string, unknown>;
|
|
48
|
+
source: 'remote';
|
|
49
|
+
};
|
|
50
|
+
} | {
|
|
51
|
+
type: 'variant-changed';
|
|
52
|
+
payload: {
|
|
53
|
+
variantKey: string;
|
|
54
|
+
values: Record<string, unknown>;
|
|
55
|
+
};
|
|
56
|
+
} | {
|
|
57
|
+
type: 'save-result';
|
|
58
|
+
payload: {
|
|
59
|
+
success: boolean;
|
|
60
|
+
error?: string;
|
|
61
|
+
versionId?: string;
|
|
62
|
+
};
|
|
63
|
+
} | {
|
|
64
|
+
type: 'publish-result';
|
|
65
|
+
payload: {
|
|
66
|
+
success: boolean;
|
|
67
|
+
error?: string;
|
|
68
|
+
};
|
|
69
|
+
} | {
|
|
70
|
+
type: 'theme-changed';
|
|
71
|
+
payload: {
|
|
72
|
+
theme: 'light' | 'dark';
|
|
73
|
+
};
|
|
74
|
+
} | {
|
|
75
|
+
type: 'selection-changed';
|
|
76
|
+
payload: {
|
|
77
|
+
selectedFieldKeys: string[];
|
|
78
|
+
fields: Array<{
|
|
79
|
+
key: string;
|
|
80
|
+
label: string;
|
|
81
|
+
type: string;
|
|
82
|
+
}>;
|
|
83
|
+
};
|
|
84
|
+
} | {
|
|
85
|
+
type: 'locale-changed';
|
|
86
|
+
payload: {
|
|
87
|
+
currentLocale: string;
|
|
88
|
+
sourceLocale: string;
|
|
89
|
+
isTranslating: boolean;
|
|
90
|
+
locales: Array<{
|
|
91
|
+
code: string;
|
|
92
|
+
displayName: string;
|
|
93
|
+
isDefault: boolean;
|
|
94
|
+
}>;
|
|
95
|
+
};
|
|
96
|
+
} | {
|
|
97
|
+
type: 'operation-result';
|
|
98
|
+
payload: {
|
|
99
|
+
requestId: string;
|
|
100
|
+
success: boolean;
|
|
101
|
+
result?: unknown;
|
|
102
|
+
error?: {
|
|
103
|
+
code: string;
|
|
104
|
+
message: string;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Messages sent FROM the iframe extension TO the platform host.
|
|
110
|
+
*/
|
|
111
|
+
export type EditorToHostMessage = {
|
|
112
|
+
type: 'ready';
|
|
113
|
+
payload: Record<string, never>;
|
|
114
|
+
} | {
|
|
115
|
+
type: 'update-values';
|
|
116
|
+
payload: {
|
|
117
|
+
values: Record<string, unknown>;
|
|
118
|
+
};
|
|
119
|
+
} | {
|
|
120
|
+
type: 'update-field';
|
|
121
|
+
payload: {
|
|
122
|
+
path: string;
|
|
123
|
+
value: unknown;
|
|
124
|
+
};
|
|
125
|
+
} | {
|
|
126
|
+
type: 'request-save';
|
|
127
|
+
payload: Record<string, never>;
|
|
128
|
+
} | {
|
|
129
|
+
type: 'request-publish';
|
|
130
|
+
payload: Record<string, never>;
|
|
131
|
+
} | {
|
|
132
|
+
type: 'resize';
|
|
133
|
+
payload: {
|
|
134
|
+
height: number;
|
|
135
|
+
};
|
|
136
|
+
} | {
|
|
137
|
+
type: 'dirty';
|
|
138
|
+
payload: {
|
|
139
|
+
isDirty: boolean;
|
|
140
|
+
};
|
|
141
|
+
} | {
|
|
142
|
+
type: 'request-navigate';
|
|
143
|
+
payload: {
|
|
144
|
+
path: string;
|
|
145
|
+
};
|
|
146
|
+
} | {
|
|
147
|
+
type: 'request-operation';
|
|
148
|
+
payload: {
|
|
149
|
+
operationKey: string;
|
|
150
|
+
input?: Record<string, unknown>;
|
|
151
|
+
requestId: string;
|
|
152
|
+
/** Execution mode: 'sync' waits for completion, 'async' queues and returns. */
|
|
153
|
+
mode?: 'sync' | 'async';
|
|
154
|
+
};
|
|
155
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime validation for postMessage payloads.
|
|
3
|
+
*/
|
|
4
|
+
import type { HostToEditorMessage, EditorToHostMessage } from './messages';
|
|
5
|
+
/** Validate an incoming message from a custom editor iframe (editor -> host). */
|
|
6
|
+
export declare function isValidEditorMessage(data: unknown): data is EditorToHostMessage;
|
|
7
|
+
/** Validate an incoming message from the platform host (host -> editor). */
|
|
8
|
+
export declare function isValidHostMessage(data: unknown): data is HostToEditorMessage;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@foir/sdk/push` — native Web Push (VAPID) enrolment for browser web apps.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { enableWebPush } from '@foir/sdk/push';
|
|
7
|
+
*
|
|
8
|
+
* await enableWebPush({ adapter, env }); // registers /foir-sw.js + a WEB token
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export { enableWebPush, disableWebPush, isWebPushSupported, } from './web-push';
|
|
12
|
+
export type { EnableWebPushOptions, EnableWebPushResult, DisableWebPushOptions, } from './web-push';
|
|
13
|
+
export { WebPushConfigDocument, RegisterDeviceTokenDocument, UnregisterDeviceTokenDocument, } from './operations';
|
|
14
|
+
export type { RegisterDeviceTokenInput } from './operations';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
2
|
+
/** The project's non-secret VAPID public key a browser subscribes with. */
|
|
3
|
+
export declare const WebPushConfigDocument: TypedDocumentNode<{
|
|
4
|
+
webPushConfig: {
|
|
5
|
+
vapidPublicKey: string;
|
|
6
|
+
} | null;
|
|
7
|
+
}, Record<string, never>>;
|
|
8
|
+
export interface RegisterDeviceTokenInput {
|
|
9
|
+
token: string;
|
|
10
|
+
platform: 'IOS' | 'ANDROID' | 'WEB';
|
|
11
|
+
deviceName?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const RegisterDeviceTokenDocument: TypedDocumentNode<{
|
|
14
|
+
registerDeviceToken: boolean;
|
|
15
|
+
}, {
|
|
16
|
+
input: RegisterDeviceTokenInput;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const UnregisterDeviceTokenDocument: TypedDocumentNode<{
|
|
19
|
+
unregisterDeviceToken: boolean;
|
|
20
|
+
}, {
|
|
21
|
+
token: string;
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { SessionAdapter } from '../auth/auth';
|
|
2
|
+
import type { FoirEnv } from '../graphql/foir-request';
|
|
3
|
+
export interface EnableWebPushOptions {
|
|
4
|
+
adapter: SessionAdapter;
|
|
5
|
+
env: FoirEnv;
|
|
6
|
+
/** Path the service worker is served from (must be same-origin). Default `/foir-sw.js`. */
|
|
7
|
+
swPath?: string;
|
|
8
|
+
/** Service-worker registration scope. Default `/`. */
|
|
9
|
+
scope?: string;
|
|
10
|
+
/** Optional label stored alongside the device token. */
|
|
11
|
+
deviceName?: string;
|
|
12
|
+
}
|
|
13
|
+
export type EnableWebPushResult = {
|
|
14
|
+
ok: true;
|
|
15
|
+
subscription: PushSubscription;
|
|
16
|
+
} | {
|
|
17
|
+
ok: false;
|
|
18
|
+
reason: 'unsupported' | 'denied' | 'no-config';
|
|
19
|
+
};
|
|
20
|
+
export interface DisableWebPushOptions {
|
|
21
|
+
adapter: SessionAdapter;
|
|
22
|
+
env: FoirEnv;
|
|
23
|
+
/** Scope the service worker was registered with. Default `/`. */
|
|
24
|
+
scope?: string;
|
|
25
|
+
}
|
|
26
|
+
/** True when the current browser supports the Web Push APIs this helper needs. */
|
|
27
|
+
export declare function isWebPushSupported(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Subscribe the current browser to Foir Web Push and register the subscription
|
|
30
|
+
* as a `WEB` device token. Idempotent: reuses an existing subscription when one
|
|
31
|
+
* is already present. Returns `{ ok: false }` (never throws) when the browser
|
|
32
|
+
* is unsupported or the user declines permission.
|
|
33
|
+
*/
|
|
34
|
+
export declare function enableWebPush(opts: EnableWebPushOptions): Promise<EnableWebPushResult>;
|
|
35
|
+
/**
|
|
36
|
+
* Unsubscribe the current browser from Web Push and deregister the device
|
|
37
|
+
* token. Returns `false` when there was no active subscription to remove.
|
|
38
|
+
*/
|
|
39
|
+
export declare function disableWebPush(opts: DisableWebPushOptions): Promise<boolean>;
|