@sylphx/sdk 0.4.0 → 0.5.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/dist/index.d.cts +583 -144
- package/dist/index.d.ts +583 -144
- package/dist/index.js +697 -267
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +691 -269
- package/dist/index.mjs.map +1 -1
- package/dist/nextjs/index.js +43 -24
- package/dist/nextjs/index.js.map +1 -1
- package/dist/nextjs/index.mjs +43 -24
- package/dist/nextjs/index.mjs.map +1 -1
- package/dist/react/index.d.cts +61 -33
- package/dist/react/index.d.ts +61 -33
- package/dist/react/index.js +907 -749
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +907 -749
- package/dist/react/index.mjs.map +1 -1
- package/dist/server/index.d.cts +355 -18
- package/dist/server/index.d.ts +355 -18
- package/dist/server/index.js +529 -11
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +525 -11
- package/dist/server/index.mjs.map +1 -1
- package/dist/web-analytics.js.map +1 -1
- package/dist/web-analytics.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/web-analytics.d.cts +0 -90
- package/dist/web-analytics.d.ts +0 -90
package/dist/react/index.d.cts
CHANGED
|
@@ -664,6 +664,32 @@ type NativeStepContext = {
|
|
|
664
664
|
* @param duration Human-readable duration: '5s', '30m', '2h', '1d'.
|
|
665
665
|
*/
|
|
666
666
|
sleep(name: string, duration: string): Promise<void>;
|
|
667
|
+
/**
|
|
668
|
+
* Pause execution until a named event is published via TriggersClient.publishEvent().
|
|
669
|
+
*
|
|
670
|
+
* On first encounter: signals the platform to wait for the event; stops execution.
|
|
671
|
+
* After the event arrives: returns the event payload.
|
|
672
|
+
* If timeout expires before event arrives: returns null.
|
|
673
|
+
*
|
|
674
|
+
* @param name Step identifier (must be unique within the handler).
|
|
675
|
+
* @param eventName The event name to listen for (e.g. 'user.approved').
|
|
676
|
+
* @param options Optional timeout ('24h', '7d') and payload filter.
|
|
677
|
+
*
|
|
678
|
+
* @example Human-in-the-loop approval
|
|
679
|
+
* ```typescript
|
|
680
|
+
* const approval = await step.waitForEvent<{ approvedBy: string }>(
|
|
681
|
+
* 'wait-approval',
|
|
682
|
+
* 'order.approved',
|
|
683
|
+
* { timeout: '48h', filter: { orderId: payload.orderId } },
|
|
684
|
+
* )
|
|
685
|
+
* if (!approval) throw new Error('Approval timed out')
|
|
686
|
+
* await notifyCustomer(approval.approvedBy)
|
|
687
|
+
* ```
|
|
688
|
+
*/
|
|
689
|
+
waitForEvent<T = unknown>(name: string, eventName: string, options?: {
|
|
690
|
+
timeout?: string;
|
|
691
|
+
filter?: Record<string, unknown>;
|
|
692
|
+
}): Promise<T | null>;
|
|
667
693
|
};
|
|
668
694
|
/**
|
|
669
695
|
* A named task definition registered with sylphx.tasks.define().
|
|
@@ -705,52 +731,54 @@ interface TaskRunStatus {
|
|
|
705
731
|
}
|
|
706
732
|
|
|
707
733
|
/**
|
|
708
|
-
* SDK Configuration
|
|
734
|
+
* SDK Configuration — ADR-055 Connection URL API
|
|
709
735
|
*
|
|
710
|
-
*
|
|
711
|
-
* `
|
|
736
|
+
* v0.5.0: The primary entry point is `createClient(url)` which accepts
|
|
737
|
+
* a `sylphx://` connection URL. The old `createConfig({ ref, publicKey })`
|
|
738
|
+
* API is removed.
|
|
712
739
|
*
|
|
713
|
-
*
|
|
714
|
-
*
|
|
715
|
-
*
|
|
716
|
-
* - `SylphxClientConfig` — React hooks return value (appId, platformUrl only)
|
|
717
|
-
* - `SylphxProviderProps` — React provider component props
|
|
718
|
-
* - `SylphxMiddlewareConfig` — Next.js middleware options
|
|
719
|
-
*
|
|
720
|
-
* @example Server-side usage
|
|
721
|
-
* ```ts
|
|
722
|
-
* import { createConfig, track } from '@sylphx/sdk'
|
|
740
|
+
* @example
|
|
741
|
+
* ```typescript
|
|
742
|
+
* import { createClient } from '@sylphx/sdk'
|
|
723
743
|
*
|
|
724
|
-
* const
|
|
725
|
-
*
|
|
744
|
+
* const sylphx = createClient(process.env.SYLPHX_URL!)
|
|
745
|
+
* // Parses: sylphx://pk_prod_{hex}@bold-river-a1b2c3.sylphx.com
|
|
726
746
|
* ```
|
|
727
747
|
*/
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* SDK Configuration object — immutable, frozen.
|
|
751
|
+
*
|
|
752
|
+
* Created by `createClient()` or `createServerClient()`.
|
|
753
|
+
* Passed to all pure SDK functions (`track()`, `signIn()`, etc.).
|
|
754
|
+
*/
|
|
728
755
|
interface SylphxConfig {
|
|
756
|
+
/** The credential string (pk_* or sk_*) */
|
|
757
|
+
readonly credential: string;
|
|
758
|
+
/** Credential type: 'pk' (publishable) or 'sk' (secret) */
|
|
759
|
+
readonly credentialType: 'pk' | 'sk';
|
|
760
|
+
/** Target environment: dev, stg, prod, or prev */
|
|
761
|
+
readonly env: 'dev' | 'stg' | 'prod' | 'prev';
|
|
762
|
+
/** Resource slug (first DNS label), e.g. 'bold-river-a1b2c3' */
|
|
763
|
+
readonly slug: string;
|
|
764
|
+
/** Pre-computed API base URL, e.g. 'https://bold-river-a1b2c3.sylphx.com/v1' */
|
|
765
|
+
readonly baseUrl: string;
|
|
766
|
+
/** Optional access token for authenticated requests */
|
|
767
|
+
readonly accessToken?: string;
|
|
729
768
|
/**
|
|
730
|
-
* Secret key
|
|
731
|
-
*
|
|
732
|
-
* Get from Platform Console → Apps → Your App → Environments.
|
|
769
|
+
* Secret key — populated when credentialType is 'sk'.
|
|
770
|
+
* Backward-compatible alias for `credential` when credential is sk_*.
|
|
733
771
|
*/
|
|
734
772
|
readonly secretKey?: string;
|
|
735
773
|
/**
|
|
736
|
-
* Publishable key
|
|
737
|
-
*
|
|
738
|
-
* Get from Platform Console → Apps → Your App → Environments.
|
|
774
|
+
* Publishable key — populated when credentialType is 'pk'.
|
|
775
|
+
* Backward-compatible alias for `credential` when credential is pk_*.
|
|
739
776
|
*/
|
|
740
777
|
readonly publicKey?: string;
|
|
741
778
|
/**
|
|
742
|
-
*
|
|
743
|
-
* Extracted from the key automatically (ADR-021).
|
|
744
|
-
* The SDK targets: https://{ref}.api.sylphx.com/v1
|
|
779
|
+
* @deprecated Use `slug`. Backward-compatible alias.
|
|
745
780
|
*/
|
|
746
781
|
readonly ref: string;
|
|
747
|
-
/**
|
|
748
|
-
* Pre-computed base URL: https://{ref}.api.sylphx.com/v1
|
|
749
|
-
* Derived from the embedded ref in the key.
|
|
750
|
-
*/
|
|
751
|
-
readonly baseUrl: string;
|
|
752
|
-
/** Optional: Current access token for authenticated requests */
|
|
753
|
-
readonly accessToken?: string;
|
|
754
782
|
}
|
|
755
783
|
|
|
756
784
|
interface components {
|
|
@@ -13404,8 +13432,8 @@ interface UseHasPermissionReturn {
|
|
|
13404
13432
|
* Pure client-side permission check hook.
|
|
13405
13433
|
*
|
|
13406
13434
|
* Operates on a permissions array — no API call. Use with:
|
|
13407
|
-
* -
|
|
13408
|
-
* -
|
|
13435
|
+
* - Permissions array from useMemberPermissions() hook
|
|
13436
|
+
* - Any string[] of permission keys from your application state
|
|
13409
13437
|
*
|
|
13410
13438
|
* Accepts a single permission string or an array. When given an array,
|
|
13411
13439
|
* returns both OR (`allowedAny`) and AND (`allowedAll`) results.
|
package/dist/react/index.d.ts
CHANGED
|
@@ -664,6 +664,32 @@ type NativeStepContext = {
|
|
|
664
664
|
* @param duration Human-readable duration: '5s', '30m', '2h', '1d'.
|
|
665
665
|
*/
|
|
666
666
|
sleep(name: string, duration: string): Promise<void>;
|
|
667
|
+
/**
|
|
668
|
+
* Pause execution until a named event is published via TriggersClient.publishEvent().
|
|
669
|
+
*
|
|
670
|
+
* On first encounter: signals the platform to wait for the event; stops execution.
|
|
671
|
+
* After the event arrives: returns the event payload.
|
|
672
|
+
* If timeout expires before event arrives: returns null.
|
|
673
|
+
*
|
|
674
|
+
* @param name Step identifier (must be unique within the handler).
|
|
675
|
+
* @param eventName The event name to listen for (e.g. 'user.approved').
|
|
676
|
+
* @param options Optional timeout ('24h', '7d') and payload filter.
|
|
677
|
+
*
|
|
678
|
+
* @example Human-in-the-loop approval
|
|
679
|
+
* ```typescript
|
|
680
|
+
* const approval = await step.waitForEvent<{ approvedBy: string }>(
|
|
681
|
+
* 'wait-approval',
|
|
682
|
+
* 'order.approved',
|
|
683
|
+
* { timeout: '48h', filter: { orderId: payload.orderId } },
|
|
684
|
+
* )
|
|
685
|
+
* if (!approval) throw new Error('Approval timed out')
|
|
686
|
+
* await notifyCustomer(approval.approvedBy)
|
|
687
|
+
* ```
|
|
688
|
+
*/
|
|
689
|
+
waitForEvent<T = unknown>(name: string, eventName: string, options?: {
|
|
690
|
+
timeout?: string;
|
|
691
|
+
filter?: Record<string, unknown>;
|
|
692
|
+
}): Promise<T | null>;
|
|
667
693
|
};
|
|
668
694
|
/**
|
|
669
695
|
* A named task definition registered with sylphx.tasks.define().
|
|
@@ -705,52 +731,54 @@ interface TaskRunStatus {
|
|
|
705
731
|
}
|
|
706
732
|
|
|
707
733
|
/**
|
|
708
|
-
* SDK Configuration
|
|
734
|
+
* SDK Configuration — ADR-055 Connection URL API
|
|
709
735
|
*
|
|
710
|
-
*
|
|
711
|
-
* `
|
|
736
|
+
* v0.5.0: The primary entry point is `createClient(url)` which accepts
|
|
737
|
+
* a `sylphx://` connection URL. The old `createConfig({ ref, publicKey })`
|
|
738
|
+
* API is removed.
|
|
712
739
|
*
|
|
713
|
-
*
|
|
714
|
-
*
|
|
715
|
-
*
|
|
716
|
-
* - `SylphxClientConfig` — React hooks return value (appId, platformUrl only)
|
|
717
|
-
* - `SylphxProviderProps` — React provider component props
|
|
718
|
-
* - `SylphxMiddlewareConfig` — Next.js middleware options
|
|
719
|
-
*
|
|
720
|
-
* @example Server-side usage
|
|
721
|
-
* ```ts
|
|
722
|
-
* import { createConfig, track } from '@sylphx/sdk'
|
|
740
|
+
* @example
|
|
741
|
+
* ```typescript
|
|
742
|
+
* import { createClient } from '@sylphx/sdk'
|
|
723
743
|
*
|
|
724
|
-
* const
|
|
725
|
-
*
|
|
744
|
+
* const sylphx = createClient(process.env.SYLPHX_URL!)
|
|
745
|
+
* // Parses: sylphx://pk_prod_{hex}@bold-river-a1b2c3.sylphx.com
|
|
726
746
|
* ```
|
|
727
747
|
*/
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* SDK Configuration object — immutable, frozen.
|
|
751
|
+
*
|
|
752
|
+
* Created by `createClient()` or `createServerClient()`.
|
|
753
|
+
* Passed to all pure SDK functions (`track()`, `signIn()`, etc.).
|
|
754
|
+
*/
|
|
728
755
|
interface SylphxConfig {
|
|
756
|
+
/** The credential string (pk_* or sk_*) */
|
|
757
|
+
readonly credential: string;
|
|
758
|
+
/** Credential type: 'pk' (publishable) or 'sk' (secret) */
|
|
759
|
+
readonly credentialType: 'pk' | 'sk';
|
|
760
|
+
/** Target environment: dev, stg, prod, or prev */
|
|
761
|
+
readonly env: 'dev' | 'stg' | 'prod' | 'prev';
|
|
762
|
+
/** Resource slug (first DNS label), e.g. 'bold-river-a1b2c3' */
|
|
763
|
+
readonly slug: string;
|
|
764
|
+
/** Pre-computed API base URL, e.g. 'https://bold-river-a1b2c3.sylphx.com/v1' */
|
|
765
|
+
readonly baseUrl: string;
|
|
766
|
+
/** Optional access token for authenticated requests */
|
|
767
|
+
readonly accessToken?: string;
|
|
729
768
|
/**
|
|
730
|
-
* Secret key
|
|
731
|
-
*
|
|
732
|
-
* Get from Platform Console → Apps → Your App → Environments.
|
|
769
|
+
* Secret key — populated when credentialType is 'sk'.
|
|
770
|
+
* Backward-compatible alias for `credential` when credential is sk_*.
|
|
733
771
|
*/
|
|
734
772
|
readonly secretKey?: string;
|
|
735
773
|
/**
|
|
736
|
-
* Publishable key
|
|
737
|
-
*
|
|
738
|
-
* Get from Platform Console → Apps → Your App → Environments.
|
|
774
|
+
* Publishable key — populated when credentialType is 'pk'.
|
|
775
|
+
* Backward-compatible alias for `credential` when credential is pk_*.
|
|
739
776
|
*/
|
|
740
777
|
readonly publicKey?: string;
|
|
741
778
|
/**
|
|
742
|
-
*
|
|
743
|
-
* Extracted from the key automatically (ADR-021).
|
|
744
|
-
* The SDK targets: https://{ref}.api.sylphx.com/v1
|
|
779
|
+
* @deprecated Use `slug`. Backward-compatible alias.
|
|
745
780
|
*/
|
|
746
781
|
readonly ref: string;
|
|
747
|
-
/**
|
|
748
|
-
* Pre-computed base URL: https://{ref}.api.sylphx.com/v1
|
|
749
|
-
* Derived from the embedded ref in the key.
|
|
750
|
-
*/
|
|
751
|
-
readonly baseUrl: string;
|
|
752
|
-
/** Optional: Current access token for authenticated requests */
|
|
753
|
-
readonly accessToken?: string;
|
|
754
782
|
}
|
|
755
783
|
|
|
756
784
|
interface components {
|
|
@@ -13404,8 +13432,8 @@ interface UseHasPermissionReturn {
|
|
|
13404
13432
|
* Pure client-side permission check hook.
|
|
13405
13433
|
*
|
|
13406
13434
|
* Operates on a permissions array — no API call. Use with:
|
|
13407
|
-
* -
|
|
13408
|
-
* -
|
|
13435
|
+
* - Permissions array from useMemberPermissions() hook
|
|
13436
|
+
* - Any string[] of permission keys from your application state
|
|
13409
13437
|
*
|
|
13410
13438
|
* Accepts a single permission string or an array. When given an array,
|
|
13411
13439
|
* returns both OR (`allowedAny`) and AND (`allowedAll`) results.
|